Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_57962205
redisson
提交
79a7ead8
R
redisson
项目概览
weixin_57962205
/
redisson
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redisson
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
79a7ead8
编写于
12月 24, 2018
作者:
N
Nikita Koksharov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactoring
上级
6025bab1
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
43 addition
and
30 deletion
+43
-30
redisson/src/test/java/org/redisson/RedissonBucketTest.java
redisson/src/test/java/org/redisson/RedissonBucketTest.java
+2
-0
redisson/src/test/java/org/redisson/RedissonMapReactiveTest.java
...n/src/test/java/org/redisson/RedissonMapReactiveTest.java
+6
-3
redisson/src/test/java/org/redisson/RedissonPriorityBlockingDequeTest.java
.../java/org/redisson/RedissonPriorityBlockingDequeTest.java
+1
-1
redisson/src/test/java/org/redisson/RedissonRuntimeEnvironment.java
...rc/test/java/org/redisson/RedissonRuntimeEnvironment.java
+1
-1
redisson/src/test/java/org/redisson/RedissonScriptReactiveTest.java
...rc/test/java/org/redisson/RedissonScriptReactiveTest.java
+5
-3
redisson/src/test/java/org/redisson/RedissonScriptTest.java
redisson/src/test/java/org/redisson/RedissonScriptTest.java
+5
-7
redisson/src/test/java/org/redisson/RedissonTest.java
redisson/src/test/java/org/redisson/RedissonTest.java
+1
-1
redisson/src/test/java/org/redisson/RedissonTopicPatternTest.java
.../src/test/java/org/redisson/RedissonTopicPatternTest.java
+2
-1
redisson/src/test/java/org/redisson/RedissonTopicTest.java
redisson/src/test/java/org/redisson/RedissonTopicTest.java
+10
-7
redisson/src/test/java/org/redisson/rx/RedissonMapRxTest.java
...sson/src/test/java/org/redisson/rx/RedissonMapRxTest.java
+6
-3
redisson/src/test/java/org/redisson/rx/RedissonScriptRxTest.java
...n/src/test/java/org/redisson/rx/RedissonScriptRxTest.java
+4
-3
未找到文件。
redisson/src/test/java/org/redisson/RedissonBucketTest.java
浏览文件 @
79a7ead8
...
...
@@ -8,6 +8,7 @@ import java.util.List;
import
java.util.concurrent.TimeUnit
;
import
org.junit.Assert
;
import
org.junit.Assume
;
import
org.junit.Test
;
import
org.redisson.RedisRunner.FailedToStartRedisException
;
import
org.redisson.RedisRunner.RedisProcess
;
...
...
@@ -19,6 +20,7 @@ public class RedissonBucketTest extends BaseTest {
@Test
public
void
testSizeInMemory
()
{
Assume
.
assumeTrue
(
RedisRunner
.
getDefaultRedisServerInstance
().
getRedisVersion
().
compareTo
(
"4.0.0"
)
>
0
);
RBucket
<
Integer
>
al
=
redisson
.
getBucket
(
"test"
);
al
.
set
(
1234
);
assertThat
(
al
.
sizeInMemory
()).
isEqualTo
(
55
);
...
...
redisson/src/test/java/org/redisson/RedissonMapReactiveTest.java
浏览文件 @
79a7ead8
...
...
@@ -15,6 +15,9 @@ import java.util.concurrent.ExecutionException;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.redisson.api.RMapReactive
;
import
org.redisson.client.codec.DoubleCodec
;
import
org.redisson.client.codec.IntegerCodec
;
import
org.redisson.codec.CompositeCodec
;
public
class
RedissonMapReactiveTest
extends
BaseReactiveTest
{
...
...
@@ -122,7 +125,7 @@ public class RedissonMapReactiveTest extends BaseReactiveTest {
@Test
public
void
testAddAndGet
()
throws
InterruptedException
{
RMapReactive
<
Integer
,
Integer
>
map
=
redisson
.
getMap
(
"getAll"
);
RMapReactive
<
Integer
,
Integer
>
map
=
redisson
.
getMap
(
"getAll"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
)
);
sync
(
map
.
put
(
1
,
100
));
Integer
res
=
sync
(
map
.
addAndGet
(
1
,
12
));
...
...
@@ -130,7 +133,7 @@ public class RedissonMapReactiveTest extends BaseReactiveTest {
res
=
sync
(
map
.
get
(
1
));
Assert
.
assertEquals
(
112
,
(
int
)
res
);
RMapReactive
<
Integer
,
Double
>
map2
=
redisson
.
getMap
(
"getAll2"
);
RMapReactive
<
Integer
,
Double
>
map2
=
redisson
.
getMap
(
"getAll2"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
DoubleCodec
.
INSTANCE
)
);
sync
(
map2
.
put
(
1
,
new
Double
(
100.2
)));
Double
res2
=
sync
(
map2
.
addAndGet
(
1
,
new
Double
(
12.1
)));
...
...
@@ -138,7 +141,7 @@ public class RedissonMapReactiveTest extends BaseReactiveTest {
res2
=
sync
(
map2
.
get
(
1
));
Assert
.
assertTrue
(
new
Double
(
112.3
).
compareTo
(
res2
)
==
0
);
RMapReactive
<
String
,
Integer
>
mapStr
=
redisson
.
getMap
(
"mapStr"
);
RMapReactive
<
String
,
Integer
>
mapStr
=
redisson
.
getMap
(
"mapStr"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
)
);
assertThat
(
sync
(
mapStr
.
put
(
"1"
,
100
))).
isNull
();
assertThat
(
sync
(
mapStr
.
addAndGet
(
"1"
,
12
))).
isEqualTo
(
112
);
...
...
redisson/src/test/java/org/redisson/RedissonPriorityBlockingDequeTest.java
浏览文件 @
79a7ead8
...
...
@@ -102,7 +102,7 @@ public class RedissonPriorityBlockingDequeTest extends BaseTest {
long
s
=
System
.
currentTimeMillis
();
assertThat
(
queue1
.
pollFirst
(
5
,
TimeUnit
.
SECONDS
)).
isNull
();
assertThat
(
System
.
currentTimeMillis
()
-
s
).
isGreaterThan
(
50
00
);
assertThat
(
System
.
currentTimeMillis
()
-
s
).
isGreaterThan
(
49
00
);
}
@Test
...
...
redisson/src/test/java/org/redisson/RedissonRuntimeEnvironment.java
浏览文件 @
79a7ead8
...
...
@@ -9,7 +9,7 @@ import java.util.Locale;
public
class
RedissonRuntimeEnvironment
{
public
static
final
boolean
isTravis
=
"true"
.
equalsIgnoreCase
(
System
.
getProperty
(
"travisEnv"
));
public
static
final
String
redisBinaryPath
=
System
.
getProperty
(
"redisBinary"
,
"C:\\Devel\\projects\\redis\\
redis-x64-4.0.2.2
\\redis-server.exe"
);
public
static
final
String
redisBinaryPath
=
System
.
getProperty
(
"redisBinary"
,
"C:\\Devel\\projects\\redis\\
Redis-x64-3.2.100
\\redis-server.exe"
);
public
static
final
String
tempDir
=
System
.
getProperty
(
"java.io.tmpdir"
);
public
static
final
String
OS
;
public
static
final
boolean
isWindows
;
...
...
redisson/src/test/java/org/redisson/RedissonScriptReactiveTest.java
浏览文件 @
79a7ead8
...
...
@@ -9,15 +9,17 @@ import org.junit.Assert;
import
org.junit.Test
;
import
org.redisson.api.RScript
;
import
org.redisson.api.RScriptReactive
;
import
org.redisson.api.RScriptRx
;
import
org.redisson.client.RedisException
;
import
org.redisson.client.codec.StringCodec
;
public
class
RedissonScriptReactiveTest
extends
BaseReactiveTest
{
@Test
public
void
testEval
()
{
RScriptReactive
script
=
redisson
.
getScript
();
List
<
Object
>
res
=
sync
(
script
.
<
List
<
Object
>>
eval
(
RScript
.
Mode
.
READ_ONLY
,
"return {1,2,3.3333,'\"foo\"
',nil,'bar'}"
,
RScript
.
ReturnType
.
MULTI
,
Collections
.
emptyList
()));
assertThat
(
res
).
containsExactly
(
1L
,
2L
,
3L
,
"foo"
);
RScriptReactive
script
=
redisson
.
getScript
(
StringCodec
.
INSTANCE
);
List
<
Object
>
res
=
sync
(
script
.
eval
(
RScript
.
Mode
.
READ_ONLY
,
"return {'1','2','3.3333','foo
',nil,'bar'}"
,
RScript
.
ReturnType
.
MULTI
,
Collections
.
emptyList
()));
assertThat
(
res
).
containsExactly
(
"1"
,
"2"
,
"3.3333"
,
"foo"
);
}
@Test
...
...
redisson/src/test/java/org/redisson/RedissonScriptTest.java
浏览文件 @
79a7ead8
...
...
@@ -31,7 +31,6 @@ public class RedissonScriptTest extends BaseTest {
l
=
l
+
1
;
}
StringCodec
codec
=
new
StringCodec
();
String
max
=
"'[DENY"
+
"\t"
+
"TESTREDISSON"
+
"\t"
+
"1506524856099'"
;
String
min
=
"'[DENY"
+
"\t"
+
"TESTREDISSON"
+
"\t"
+
"1506524856000'"
;
String
luaScript1
=
"local d = {}; d[1] = redis.call('zrevrangebylex','ABCD17436',"
+
max
+
","
+
min
+
",'LIMIT',0,5); "
;
...
...
@@ -39,15 +38,14 @@ public class RedissonScriptTest extends BaseTest {
luaScript1
=
luaScript1
+
" d[3] = redis.call('zrevrangebylex','ABCD17436',"
+
max
+
","
+
min
+
",'LIMIT',0,25); "
;
luaScript1
=
luaScript1
+
" return d;"
;
Future
<
Object
>
r1
=
redisson
.
getScript
().
evalAsync
(
RScript
.
Mode
.
READ_ONLY
,
codec
,
List
<
List
<
Object
>>
objs
=
redisson
.
getScript
(
StringCodec
.
INSTANCE
).
eval
(
RScript
.
Mode
.
READ_ONLY
,
luaScript1
,
RScript
.
ReturnType
.
MULTI
,
Collections
.
emptyList
());
List
<
List
<
Object
>>
obj1
=
(
List
<
List
<
Object
>>)
r1
.
get
();
assertThat
(
obj
1
).
hasSize
(
3
);
assertThat
(
obj
1
.
get
(
0
)).
hasSize
(
5
);
assertThat
(
obj
1
.
get
(
1
)).
hasSize
(
15
);
assertThat
(
obj
1
.
get
(
2
)).
hasSize
(
25
);
assertThat
(
obj
s
).
hasSize
(
3
);
assertThat
(
obj
s
.
get
(
0
)).
hasSize
(
5
);
assertThat
(
obj
s
.
get
(
1
)).
hasSize
(
15
);
assertThat
(
obj
s
.
get
(
2
)).
hasSize
(
25
);
}
@Test
...
...
redisson/src/test/java/org/redisson/RedissonTest.java
浏览文件 @
79a7ead8
...
...
@@ -433,7 +433,7 @@ public class RedissonTest {
System
.
out
.
println
(
"master "
+
master
.
getRedisServerAddressAndPort
()
+
" has been stopped!"
);
Thread
.
sleep
(
TimeUnit
.
SECONDS
.
toMillis
(
2
0
));
Thread
.
sleep
(
TimeUnit
.
SECONDS
.
toMillis
(
3
0
));
RedisProcess
newMaster
=
null
;
Collection
<
ClusterNode
>
newMasterNodes
=
redisson
.
getClusterNodesGroup
().
getNodes
(
NodeType
.
MASTER
);
...
...
redisson/src/test/java/org/redisson/RedissonTopicPatternTest.java
浏览文件 @
79a7ead8
...
...
@@ -3,6 +3,7 @@ package org.redisson;
import
static
org
.
awaitility
.
Awaitility
.
await
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.CountDownLatch
;
...
...
@@ -28,7 +29,7 @@ import org.redisson.config.Config;
public
class
RedissonTopicPatternTest
extends
BaseTest
{
public
static
class
Message
{
public
static
class
Message
implements
Serializable
{
private
String
name
;
...
...
redisson/src/test/java/org/redisson/RedissonTopicTest.java
浏览文件 @
79a7ead8
...
...
@@ -18,6 +18,7 @@ import java.util.concurrent.Future;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicLong
;
import
org.awaitility.Duration
;
import
org.junit.After
;
...
...
@@ -151,7 +152,9 @@ public class RedissonTopicTest {
CountDownLatch
latch
=
new
CountDownLatch
(
count
);
RTopic
eventsTopic
=
redisson
.
getTopic
(
"eventsTopic"
);
AtomicInteger
co
=
new
AtomicInteger
();
eventsTopic
.
addListener
(
String
.
class
,
(
channel
,
msg
)
->
{
co
.
incrementAndGet
();
latch
.
countDown
();
});
...
...
@@ -161,7 +164,7 @@ public class RedissonTopicTest {
Thread
.
sleep
(
10
);
}
assertThat
(
latch
.
await
(
3
0
,
TimeUnit
.
SECONDS
)).
isTrue
();
assertThat
(
latch
.
await
(
4
0
,
TimeUnit
.
SECONDS
)).
isTrue
();
redisson
.
shutdown
();
}
...
...
@@ -201,7 +204,7 @@ public class RedissonTopicTest {
futures
.
add
(
s
);
}
executor
.
shutdown
();
Assert
.
assertTrue
(
executor
.
awaitTermination
(
threads
*
loops
*
10
00
,
TimeUnit
.
SECONDS
));
Assert
.
assertTrue
(
executor
.
awaitTermination
(
1
00
,
TimeUnit
.
SECONDS
));
for
(
Future
<?>
future
:
futures
)
{
future
.
get
();
...
...
@@ -561,18 +564,17 @@ public class RedissonTopicTest {
redisson2
.
shutdown
();
}
volatile
long
counter
;
@Test
public
void
testHeavyLoad
()
throws
InterruptedException
{
final
CountDownLatch
messageRecieved
=
new
CountDownLatch
(
1000
);
AtomicLong
counter
=
new
AtomicLong
();
RedissonClient
redisson1
=
BaseTest
.
createInstance
();
RTopic
topic1
=
redisson1
.
getTopic
(
"topic"
);
topic1
.
addListener
(
Message
.
class
,
(
channel
,
msg
)
->
{
Assert
.
assertEquals
(
new
Message
(
"123"
),
msg
);
messageRecieved
.
countDown
();
counter
++
;
counter
.
incrementAndGet
()
;
});
RedissonClient
redisson2
=
BaseTest
.
createInstance
();
...
...
@@ -582,7 +584,8 @@ public class RedissonTopicTest {
messageRecieved
.
countDown
();
});
for
(
int
i
=
0
;
i
<
5000
;
i
++)
{
int
count
=
10000
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
topic2
.
publish
(
new
Message
(
"123"
));
}
...
...
@@ -590,7 +593,7 @@ public class RedissonTopicTest {
Thread
.
sleep
(
1000
);
Assert
.
assertEquals
(
5000
,
counter
);
Assert
.
assertEquals
(
count
,
counter
.
get
()
);
redisson1
.
shutdown
();
redisson2
.
shutdown
();
...
...
redisson/src/test/java/org/redisson/rx/RedissonMapRxTest.java
浏览文件 @
79a7ead8
...
...
@@ -15,6 +15,9 @@ import java.util.concurrent.ExecutionException;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.redisson.api.RMapRx
;
import
org.redisson.client.codec.DoubleCodec
;
import
org.redisson.client.codec.IntegerCodec
;
import
org.redisson.codec.CompositeCodec
;
public
class
RedissonMapRxTest
extends
BaseRxTest
{
...
...
@@ -122,7 +125,7 @@ public class RedissonMapRxTest extends BaseRxTest {
@Test
public
void
testAddAndGet
()
throws
InterruptedException
{
RMapRx
<
Integer
,
Integer
>
map
=
redisson
.
getMap
(
"getAll"
);
RMapRx
<
Integer
,
Integer
>
map
=
redisson
.
getMap
(
"getAll"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
)
);
sync
(
map
.
put
(
1
,
100
));
Integer
res
=
sync
(
map
.
addAndGet
(
1
,
12
));
...
...
@@ -130,7 +133,7 @@ public class RedissonMapRxTest extends BaseRxTest {
res
=
sync
(
map
.
get
(
1
));
Assert
.
assertEquals
(
112
,
(
int
)
res
);
RMapRx
<
Integer
,
Double
>
map2
=
redisson
.
getMap
(
"getAll2"
);
RMapRx
<
Integer
,
Double
>
map2
=
redisson
.
getMap
(
"getAll2"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
DoubleCodec
.
INSTANCE
)
);
sync
(
map2
.
put
(
1
,
new
Double
(
100.2
)));
Double
res2
=
sync
(
map2
.
addAndGet
(
1
,
new
Double
(
12.1
)));
...
...
@@ -138,7 +141,7 @@ public class RedissonMapRxTest extends BaseRxTest {
res2
=
sync
(
map2
.
get
(
1
));
Assert
.
assertTrue
(
new
Double
(
112.3
).
compareTo
(
res2
)
==
0
);
RMapRx
<
String
,
Integer
>
mapStr
=
redisson
.
getMap
(
"mapStr"
);
RMapRx
<
String
,
Integer
>
mapStr
=
redisson
.
getMap
(
"mapStr"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
)
);
assertThat
(
sync
(
mapStr
.
put
(
"1"
,
100
))).
isNull
();
assertThat
(
sync
(
mapStr
.
addAndGet
(
"1"
,
12
))).
isEqualTo
(
112
);
...
...
redisson/src/test/java/org/redisson/rx/RedissonScriptRxTest.java
浏览文件 @
79a7ead8
...
...
@@ -10,14 +10,15 @@ import org.junit.Test;
import
org.redisson.api.RScript
;
import
org.redisson.api.RScriptRx
;
import
org.redisson.client.RedisException
;
import
org.redisson.client.codec.StringCodec
;
public
class
RedissonScriptRxTest
extends
BaseRxTest
{
@Test
public
void
testEval
()
{
RScriptRx
script
=
redisson
.
getScript
();
List
<
Object
>
res
=
sync
(
script
.
<
List
<
Object
>>
eval
(
RScript
.
Mode
.
READ_ONLY
,
"return {1,2,3.3333,'\"foo\"
',nil,'bar'}"
,
RScript
.
ReturnType
.
MULTI
,
Collections
.
emptyList
()));
assertThat
(
res
).
containsExactly
(
1L
,
2L
,
3L
,
"foo"
);
RScriptRx
script
=
redisson
.
getScript
(
StringCodec
.
INSTANCE
);
List
<
Object
>
res
=
sync
(
script
.
eval
(
RScript
.
Mode
.
READ_ONLY
,
"return {'1','2','3.3333','foo
',nil,'bar'}"
,
RScript
.
ReturnType
.
MULTI
,
Collections
.
emptyList
()));
assertThat
(
res
).
containsExactly
(
"1"
,
"2"
,
"3.3333"
,
"foo"
);
}
@Test
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录