Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
2988a1e6
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
268
Star
16139
Fork
68
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
2988a1e6
编写于
4月 15, 2018
作者:
S
shutian.lzh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make unit tests compilable
上级
b1e77b4c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
33 addition
and
141 deletion
+33
-141
example/src/main/java/org/apache/rocketmq/example/openmessaging/SimpleProducer.java
...apache/rocketmq/example/openmessaging/SimpleProducer.java
+2
-2
openmessaging/src/test/java/io/openmessaging/rocketmq/consumer/PullConsumerImplTest.java
...openmessaging/rocketmq/consumer/PullConsumerImplTest.java
+8
-11
openmessaging/src/test/java/io/openmessaging/rocketmq/consumer/PushConsumerImplTest.java
...openmessaging/rocketmq/consumer/PushConsumerImplTest.java
+5
-8
openmessaging/src/test/java/io/openmessaging/rocketmq/producer/ProducerImplTest.java
.../io/openmessaging/rocketmq/producer/ProducerImplTest.java
+7
-7
openmessaging/src/test/java/io/openmessaging/rocketmq/producer/SequenceProducerImplTest.java
...messaging/rocketmq/producer/SequenceProducerImplTest.java
+0
-86
openmessaging/src/test/java/io/openmessaging/rocketmq/promise/DefaultPromiseTest.java
...io/openmessaging/rocketmq/promise/DefaultPromiseTest.java
+11
-27
未找到文件。
example/src/main/java/org/apache/rocketmq/example/openmessaging/SimpleProducer.java
浏览文件 @
2988a1e6
...
@@ -27,8 +27,8 @@ import java.nio.charset.Charset;
...
@@ -27,8 +27,8 @@ import java.nio.charset.Charset;
public
class
SimpleProducer
{
public
class
SimpleProducer
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
final
MessagingAccessPoint
messagingAccessPoint
=
OMS
final
MessagingAccessPoint
messagingAccessPoint
=
.
getMessagingAccessPoint
(
"openmessaging:rocketmq://IP1:9876,IP2:9876/namespace
"
);
OMS
.
getMessagingAccessPoint
(
"oms:rocketmq://localhost:9876/default:default
"
);
final
Producer
producer
=
messagingAccessPoint
.
createProducer
();
final
Producer
producer
=
messagingAccessPoint
.
createProducer
();
...
...
openmessaging/src/test/java/io/openmessaging/rocketmq/consumer/PullConsumerImplTest.java
浏览文件 @
2988a1e6
...
@@ -18,12 +18,9 @@ package io.openmessaging.rocketmq.consumer;
...
@@ -18,12 +18,9 @@ package io.openmessaging.rocketmq.consumer;
import
io.openmessaging.BytesMessage
;
import
io.openmessaging.BytesMessage
;
import
io.openmessaging.Message
;
import
io.openmessaging.Message
;
import
io.openmessaging.MessageHeader
;
import
io.openmessaging.MessagingAccessPoint
;
import
io.openmessaging.MessagingAccessPoint
;
import
io.openmessaging.MessagingAccessPointFactory
;
import
io.openmessaging.OMS
;
import
io.openmessaging.OMS
;
import
io.openmessaging.PropertyKeys
;
import
io.openmessaging.consumer.PullConsumer
;
import
io.openmessaging.PullConsumer
;
import
io.openmessaging.rocketmq.config.ClientConfig
;
import
io.openmessaging.rocketmq.config.ClientConfig
;
import
io.openmessaging.rocketmq.domain.NonStandardKeys
;
import
io.openmessaging.rocketmq.domain.NonStandardKeys
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
...
@@ -50,11 +47,11 @@ public class PullConsumerImplTest {
...
@@ -50,11 +47,11 @@ public class PullConsumerImplTest {
@Before
@Before
public
void
init
()
throws
NoSuchFieldException
,
IllegalAccessException
{
public
void
init
()
throws
NoSuchFieldException
,
IllegalAccessException
{
final
MessagingAccessPoint
messagingAccessPoint
=
MessagingAccessPointFactory
final
MessagingAccessPoint
messagingAccessPoint
=
OMS
.
getMessagingAccessPoint
(
"openmessaging:rocketmq://IP1:9876,IP2:9876/namespace"
);
.
getMessagingAccessPoint
(
"openmessaging:rocketmq://IP1:9876,IP2:9876/namespace"
);
consumer
=
messagingAccessPoint
.
createPullConsumer
(
queueName
,
consumer
=
messagingAccessPoint
.
createPullConsumer
(
OMS
.
newKeyValue
().
put
(
NonStandardKeys
.
CONSUMER_GROUP
,
"TestGroup"
));
OMS
.
newKeyValue
().
put
(
NonStandardKeys
.
CONSUMER_GROUP
,
"TestGroup"
)
);
consumer
.
attachQueue
(
queueName
);
Field
field
=
PullConsumerImpl
.
class
.
getDeclaredField
(
"rocketmqPullConsumer"
);
Field
field
=
PullConsumerImpl
.
class
.
getDeclaredField
(
"rocketmqPullConsumer"
);
field
.
setAccessible
(
true
);
field
.
setAccessible
(
true
);
...
@@ -83,18 +80,18 @@ public class PullConsumerImplTest {
...
@@ -83,18 +80,18 @@ public class PullConsumerImplTest {
when
(
localMessageCache
.
poll
()).
thenReturn
(
consumedMsg
);
when
(
localMessageCache
.
poll
()).
thenReturn
(
consumedMsg
);
Message
message
=
consumer
.
poll
();
Message
message
=
consumer
.
receive
();
assertThat
(
message
.
headers
().
getString
(
MessageHeader
.
MESSAGE_ID
)).
isEqualTo
(
"NewMsgId"
);
assertThat
(
message
.
sysHeaders
().
getString
(
Message
.
BuiltinKeys
.
MESSAGE_ID
)).
isEqualTo
(
"NewMsgId"
);
assertThat
(((
BytesMessage
)
message
).
getBody
()).
isEqualTo
(
testBody
);
assertThat
(((
BytesMessage
)
message
).
getBody
()).
isEqualTo
(
testBody
);
}
}
@Test
@Test
public
void
testPoll_WithTimeout
()
{
public
void
testPoll_WithTimeout
()
{
//There is a default timeout value, @see ClientConfig#omsOperationTimeout.
//There is a default timeout value, @see ClientConfig#omsOperationTimeout.
Message
message
=
consumer
.
poll
();
Message
message
=
consumer
.
receive
();
assertThat
(
message
).
isNull
();
assertThat
(
message
).
isNull
();
message
=
consumer
.
poll
(
OMS
.
newKeyValue
().
put
(
PropertyKeys
.
OPERATION_
TIMEOUT
,
100
));
message
=
consumer
.
receive
(
OMS
.
newKeyValue
().
put
(
Message
.
BuiltinKeys
.
TIMEOUT
,
100
));
assertThat
(
message
).
isNull
();
assertThat
(
message
).
isNull
();
}
}
}
}
\ No newline at end of file
openmessaging/src/test/java/io/openmessaging/rocketmq/consumer/PushConsumerImplTest.java
浏览文件 @
2988a1e6
...
@@ -18,13 +18,10 @@ package io.openmessaging.rocketmq.consumer;
...
@@ -18,13 +18,10 @@ package io.openmessaging.rocketmq.consumer;
import
io.openmessaging.BytesMessage
;
import
io.openmessaging.BytesMessage
;
import
io.openmessaging.Message
;
import
io.openmessaging.Message
;
import
io.openmessaging.MessageHeader
;
import
io.openmessaging.consumer.MessageListener
;
import
io.openmessaging.MessageListener
;
import
io.openmessaging.MessagingAccessPoint
;
import
io.openmessaging.MessagingAccessPoint
;
import
io.openmessaging.MessagingAccessPointFactory
;
import
io.openmessaging.OMS
;
import
io.openmessaging.OMS
;
import
io.openmessaging.PushConsumer
;
import
io.openmessaging.consumer.PushConsumer
;
import
io.openmessaging.ReceivedMessageContext
;
import
io.openmessaging.rocketmq.domain.NonStandardKeys
;
import
io.openmessaging.rocketmq.domain.NonStandardKeys
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.util.Collections
;
import
java.util.Collections
;
...
@@ -49,7 +46,7 @@ public class PushConsumerImplTest {
...
@@ -49,7 +46,7 @@ public class PushConsumerImplTest {
@Before
@Before
public
void
init
()
throws
NoSuchFieldException
,
IllegalAccessException
{
public
void
init
()
throws
NoSuchFieldException
,
IllegalAccessException
{
final
MessagingAccessPoint
messagingAccessPoint
=
MessagingAccessPointFactory
final
MessagingAccessPoint
messagingAccessPoint
=
OMS
.
getMessagingAccessPoint
(
"openmessaging:rocketmq://IP1:9876,IP2:9876/namespace"
);
.
getMessagingAccessPoint
(
"openmessaging:rocketmq://IP1:9876,IP2:9876/namespace"
);
consumer
=
messagingAccessPoint
.
createPushConsumer
(
consumer
=
messagingAccessPoint
.
createPushConsumer
(
OMS
.
newKeyValue
().
put
(
NonStandardKeys
.
CONSUMER_GROUP
,
"TestGroup"
));
OMS
.
newKeyValue
().
put
(
NonStandardKeys
.
CONSUMER_GROUP
,
"TestGroup"
));
...
@@ -75,8 +72,8 @@ public class PushConsumerImplTest {
...
@@ -75,8 +72,8 @@ public class PushConsumerImplTest {
consumedMsg
.
setTopic
(
"HELLO_QUEUE"
);
consumedMsg
.
setTopic
(
"HELLO_QUEUE"
);
consumer
.
attachQueue
(
"HELLO_QUEUE"
,
new
MessageListener
()
{
consumer
.
attachQueue
(
"HELLO_QUEUE"
,
new
MessageListener
()
{
@Override
@Override
public
void
on
Message
(
final
Message
message
,
final
ReceivedMessage
Context
context
)
{
public
void
on
Received
(
Message
message
,
Context
context
)
{
assertThat
(
message
.
headers
().
getString
(
MessageHeader
.
MESSAGE_ID
)).
isEqualTo
(
"NewMsgId"
);
assertThat
(
message
.
sysHeaders
().
getString
(
Message
.
BuiltinKeys
.
MESSAGE_ID
)).
isEqualTo
(
"NewMsgId"
);
assertThat
(((
BytesMessage
)
message
).
getBody
()).
isEqualTo
(
testBody
);
assertThat
(((
BytesMessage
)
message
).
getBody
()).
isEqualTo
(
testBody
);
context
.
ack
();
context
.
ack
();
}
}
...
...
openmessaging/src/test/java/io/openmessaging/rocketmq/producer/ProducerImplTest.java
浏览文件 @
2988a1e6
...
@@ -17,9 +17,9 @@
...
@@ -17,9 +17,9 @@
package
io.openmessaging.rocketmq.producer
;
package
io.openmessaging.rocketmq.producer
;
import
io.openmessaging.MessagingAccessPoint
;
import
io.openmessaging.MessagingAccessPoint
;
import
io.openmessaging.MessagingAccessPointFactory
;
import
io.openmessaging.OMS
;
import
io.openmessaging.Producer
;
import
io.openmessaging.exception.OMSRuntimeException
;
import
io.openmessaging.exception.OMSRuntimeException
;
import
io.openmessaging.producer.Producer
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
org.apache.rocketmq.client.exception.MQBrokerException
;
import
org.apache.rocketmq.client.exception.MQBrokerException
;
import
org.apache.rocketmq.client.exception.MQClientException
;
import
org.apache.rocketmq.client.exception.MQClientException
;
...
@@ -49,7 +49,7 @@ public class ProducerImplTest {
...
@@ -49,7 +49,7 @@ public class ProducerImplTest {
@Before
@Before
public
void
init
()
throws
NoSuchFieldException
,
IllegalAccessException
{
public
void
init
()
throws
NoSuchFieldException
,
IllegalAccessException
{
final
MessagingAccessPoint
messagingAccessPoint
=
MessagingAccessPointFactory
final
MessagingAccessPoint
messagingAccessPoint
=
OMS
.
getMessagingAccessPoint
(
"openmessaging:rocketmq://IP1:9876,IP2:9876/namespace"
);
.
getMessagingAccessPoint
(
"openmessaging:rocketmq://IP1:9876,IP2:9876/namespace"
);
producer
=
messagingAccessPoint
.
createProducer
();
producer
=
messagingAccessPoint
.
createProducer
();
...
@@ -67,8 +67,8 @@ public class ProducerImplTest {
...
@@ -67,8 +67,8 @@ public class ProducerImplTest {
sendResult
.
setMsgId
(
"TestMsgID"
);
sendResult
.
setMsgId
(
"TestMsgID"
);
sendResult
.
setSendStatus
(
SendStatus
.
SEND_OK
);
sendResult
.
setSendStatus
(
SendStatus
.
SEND_OK
);
when
(
rocketmqProducer
.
send
(
any
(
Message
.
class
),
anyLong
())).
thenReturn
(
sendResult
);
when
(
rocketmqProducer
.
send
(
any
(
Message
.
class
),
anyLong
())).
thenReturn
(
sendResult
);
io
.
openmessaging
.
SendResult
omsResult
=
io
.
openmessaging
.
producer
.
SendResult
omsResult
=
producer
.
send
(
producer
.
createBytesMessage
ToTopic
(
"HELLO_TOPIC"
,
new
byte
[]
{
'a'
}));
producer
.
send
(
producer
.
createBytesMessage
(
"HELLO_TOPIC"
,
new
byte
[]
{
'a'
}));
assertThat
(
omsResult
.
messageId
()).
isEqualTo
(
"TestMsgID"
);
assertThat
(
omsResult
.
messageId
()).
isEqualTo
(
"TestMsgID"
);
}
}
...
@@ -80,7 +80,7 @@ public class ProducerImplTest {
...
@@ -80,7 +80,7 @@ public class ProducerImplTest {
when
(
rocketmqProducer
.
send
(
any
(
Message
.
class
),
anyLong
())).
thenReturn
(
sendResult
);
when
(
rocketmqProducer
.
send
(
any
(
Message
.
class
),
anyLong
())).
thenReturn
(
sendResult
);
try
{
try
{
producer
.
send
(
producer
.
createBytesMessage
ToTopic
(
"HELLO_TOPIC"
,
new
byte
[]
{
'a'
}));
producer
.
send
(
producer
.
createBytesMessage
(
"HELLO_TOPIC"
,
new
byte
[]
{
'a'
}));
failBecauseExceptionWasNotThrown
(
OMSRuntimeException
.
class
);
failBecauseExceptionWasNotThrown
(
OMSRuntimeException
.
class
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
assertThat
(
e
).
hasMessageContaining
(
"Send message to RocketMQ broker failed."
);
assertThat
(
e
).
hasMessageContaining
(
"Send message to RocketMQ broker failed."
);
...
@@ -91,7 +91,7 @@ public class ProducerImplTest {
...
@@ -91,7 +91,7 @@ public class ProducerImplTest {
public
void
testSend_WithException
()
throws
InterruptedException
,
RemotingException
,
MQClientException
,
MQBrokerException
{
public
void
testSend_WithException
()
throws
InterruptedException
,
RemotingException
,
MQClientException
,
MQBrokerException
{
when
(
rocketmqProducer
.
send
(
any
(
Message
.
class
),
anyLong
())).
thenThrow
(
MQClientException
.
class
);
when
(
rocketmqProducer
.
send
(
any
(
Message
.
class
),
anyLong
())).
thenThrow
(
MQClientException
.
class
);
try
{
try
{
producer
.
send
(
producer
.
createBytesMessage
ToTopic
(
"HELLO_TOPIC"
,
new
byte
[]
{
'a'
}));
producer
.
send
(
producer
.
createBytesMessage
(
"HELLO_TOPIC"
,
new
byte
[]
{
'a'
}));
failBecauseExceptionWasNotThrown
(
OMSRuntimeException
.
class
);
failBecauseExceptionWasNotThrown
(
OMSRuntimeException
.
class
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
assertThat
(
e
).
hasMessageContaining
(
"Send message to RocketMQ broker failed."
);
assertThat
(
e
).
hasMessageContaining
(
"Send message to RocketMQ broker failed."
);
...
...
openmessaging/src/test/java/io/openmessaging/rocketmq/producer/SequenceProducerImplTest.java
已删除
100644 → 0
浏览文件 @
b1e77b4c
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
io.openmessaging.rocketmq.producer
;
import
io.openmessaging.BytesMessage
;
import
io.openmessaging.MessageHeader
;
import
io.openmessaging.MessagingAccessPoint
;
import
io.openmessaging.MessagingAccessPointFactory
;
import
io.openmessaging.SequenceProducer
;
import
java.lang.reflect.Field
;
import
org.apache.rocketmq.client.exception.MQBrokerException
;
import
org.apache.rocketmq.client.exception.MQClientException
;
import
org.apache.rocketmq.client.producer.DefaultMQProducer
;
import
org.apache.rocketmq.client.producer.SendResult
;
import
org.apache.rocketmq.client.producer.SendStatus
;
import
org.apache.rocketmq.common.message.Message
;
import
org.apache.rocketmq.remoting.exception.RemotingException
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.ArgumentMatchers
;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
SequenceProducerImplTest
{
private
SequenceProducer
producer
;
@Mock
private
DefaultMQProducer
rocketmqProducer
;
@Before
public
void
init
()
throws
NoSuchFieldException
,
IllegalAccessException
{
final
MessagingAccessPoint
messagingAccessPoint
=
MessagingAccessPointFactory
.
getMessagingAccessPoint
(
"openmessaging:rocketmq://IP1:9876,IP2:9876/namespace"
);
producer
=
messagingAccessPoint
.
createSequenceProducer
();
Field
field
=
AbstractOMSProducer
.
class
.
getDeclaredField
(
"rocketmqProducer"
);
field
.
setAccessible
(
true
);
field
.
set
(
producer
,
rocketmqProducer
);
messagingAccessPoint
.
startup
();
producer
.
startup
();
}
@Test
public
void
testSend_WithCommit
()
throws
InterruptedException
,
RemotingException
,
MQClientException
,
MQBrokerException
{
SendResult
sendResult
=
new
SendResult
();
sendResult
.
setMsgId
(
"TestMsgID"
);
sendResult
.
setSendStatus
(
SendStatus
.
SEND_OK
);
when
(
rocketmqProducer
.
send
(
ArgumentMatchers
.<
Message
>
anyList
())).
thenReturn
(
sendResult
);
when
(
rocketmqProducer
.
getMaxMessageSize
()).
thenReturn
(
1024
);
final
BytesMessage
message
=
producer
.
createBytesMessageToTopic
(
"HELLO_TOPIC"
,
new
byte
[]
{
'a'
});
producer
.
send
(
message
);
producer
.
commit
();
assertThat
(
message
.
headers
().
getString
(
MessageHeader
.
MESSAGE_ID
)).
isEqualTo
(
"TestMsgID"
);
}
@Test
public
void
testRollback
()
{
when
(
rocketmqProducer
.
getMaxMessageSize
()).
thenReturn
(
1024
);
final
BytesMessage
message
=
producer
.
createBytesMessageToTopic
(
"HELLO_TOPIC"
,
new
byte
[]
{
'a'
});
producer
.
send
(
message
);
producer
.
rollback
();
producer
.
commit
();
//Commit nothing.
assertThat
(
message
.
headers
().
getString
(
MessageHeader
.
MESSAGE_ID
)).
isEqualTo
(
null
);
}
}
\ No newline at end of file
openmessaging/src/test/java/io/openmessaging/rocketmq/promise/DefaultPromiseTest.java
浏览文件 @
2988a1e6
...
@@ -16,8 +16,9 @@
...
@@ -16,8 +16,9 @@
*/
*/
package
io.openmessaging.rocketmq.promise
;
package
io.openmessaging.rocketmq.promise
;
import
io.openmessaging.Future
;
import
io.openmessaging.FutureListener
;
import
io.openmessaging.Promise
;
import
io.openmessaging.Promise
;
import
io.openmessaging.PromiseListener
;
import
io.openmessaging.exception.OMSRuntimeException
;
import
io.openmessaging.exception.OMSRuntimeException
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -63,14 +64,10 @@ public class DefaultPromiseTest {
...
@@ -63,14 +64,10 @@ public class DefaultPromiseTest {
@Test
@Test
public
void
testAddListener
()
throws
Exception
{
public
void
testAddListener
()
throws
Exception
{
promise
.
addListener
(
new
Promis
eListener
<
String
>()
{
promise
.
addListener
(
new
Futur
eListener
<
String
>()
{
@Override
@Override
public
void
operationComplete
d
(
final
Promise
<
String
>
promis
e
)
{
public
void
operationComplete
(
Future
<
String
>
futur
e
)
{
assertThat
(
promise
.
get
()).
isEqualTo
(
"Done"
);
assertThat
(
promise
.
get
()).
isEqualTo
(
"Done"
);
}
@Override
public
void
operationFailed
(
final
Promise
<
String
>
promise
)
{
}
}
});
});
...
@@ -80,15 +77,10 @@ public class DefaultPromiseTest {
...
@@ -80,15 +77,10 @@ public class DefaultPromiseTest {
@Test
@Test
public
void
testAddListener_ListenerAfterSet
()
throws
Exception
{
public
void
testAddListener_ListenerAfterSet
()
throws
Exception
{
promise
.
set
(
"Done"
);
promise
.
set
(
"Done"
);
promise
.
addListener
(
new
PromiseListener
<
String
>()
{
promise
.
addListener
(
new
FutureListener
<
String
>()
{
@Override
public
void
operationCompleted
(
final
Promise
<
String
>
promise
)
{
assertThat
(
promise
.
get
()).
isEqualTo
(
"Done"
);
}
@Override
@Override
public
void
operation
Failed
(
final
Promise
<
String
>
promis
e
)
{
public
void
operation
Complete
(
Future
<
String
>
futur
e
)
{
assertThat
(
future
.
get
()).
isEqualTo
(
"Done"
);
}
}
});
});
}
}
...
@@ -97,13 +89,9 @@ public class DefaultPromiseTest {
...
@@ -97,13 +89,9 @@ public class DefaultPromiseTest {
public
void
testAddListener_WithException_ListenerAfterSet
()
throws
Exception
{
public
void
testAddListener_WithException_ListenerAfterSet
()
throws
Exception
{
final
Throwable
exception
=
new
OMSRuntimeException
(
"-1"
,
"Test Error"
);
final
Throwable
exception
=
new
OMSRuntimeException
(
"-1"
,
"Test Error"
);
promise
.
setFailure
(
exception
);
promise
.
setFailure
(
exception
);
promise
.
addListener
(
new
PromiseListener
<
String
>()
{
promise
.
addListener
(
new
FutureListener
<
String
>()
{
@Override
public
void
operationCompleted
(
final
Promise
<
String
>
promise
)
{
}
@Override
@Override
public
void
operation
Failed
(
final
Promise
<
String
>
promis
e
)
{
public
void
operation
Complete
(
Future
<
String
>
futur
e
)
{
assertThat
(
promise
.
getThrowable
()).
isEqualTo
(
exception
);
assertThat
(
promise
.
getThrowable
()).
isEqualTo
(
exception
);
}
}
});
});
...
@@ -112,13 +100,9 @@ public class DefaultPromiseTest {
...
@@ -112,13 +100,9 @@ public class DefaultPromiseTest {
@Test
@Test
public
void
testAddListener_WithException
()
throws
Exception
{
public
void
testAddListener_WithException
()
throws
Exception
{
final
Throwable
exception
=
new
OMSRuntimeException
(
"-1"
,
"Test Error"
);
final
Throwable
exception
=
new
OMSRuntimeException
(
"-1"
,
"Test Error"
);
promise
.
addListener
(
new
PromiseListener
<
String
>()
{
promise
.
addListener
(
new
FutureListener
<
String
>()
{
@Override
public
void
operationCompleted
(
final
Promise
<
String
>
promise
)
{
}
@Override
@Override
public
void
operation
Failed
(
final
Promise
<
String
>
promis
e
)
{
public
void
operation
Complete
(
Future
<
String
>
futur
e
)
{
assertThat
(
promise
.
getThrowable
()).
isEqualTo
(
exception
);
assertThat
(
promise
.
getThrowable
()).
isEqualTo
(
exception
);
}
}
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录