提交 495a01b6 编写于 作者: M maowei.ymw 提交者: von gosling

Remove unnecessary code in test case

上级 f1772539
...@@ -167,10 +167,7 @@ public class DefaultMQProducerTest { ...@@ -167,10 +167,7 @@ public class DefaultMQProducerTest {
@Test @Test
public void testSendMessageAsync_Success() throws RemotingException, InterruptedException, MQBrokerException, MQClientException { public void testSendMessageAsync_Success() throws RemotingException, InterruptedException, MQBrokerException, MQClientException {
ExecutorService callbackExecutor = Executors.newSingleThreadExecutor();
final CountDownLatch countDownLatch = new CountDownLatch(1); final CountDownLatch countDownLatch = new CountDownLatch(1);
when(mQClientAPIImpl.getRemotingClient()).thenReturn((nettyRemotingClient));
when(nettyRemotingClient.getCallbackExecutor()).thenReturn(callbackExecutor);
producer.send(message, new SendCallback() { producer.send(message, new SendCallback() {
@Override @Override
public void onSuccess(SendResult sendResult) { public void onSuccess(SendResult sendResult) {
...@@ -186,15 +183,11 @@ public class DefaultMQProducerTest { ...@@ -186,15 +183,11 @@ public class DefaultMQProducerTest {
} }
}); });
countDownLatch.await(3000L, TimeUnit.MILLISECONDS); countDownLatch.await(3000L, TimeUnit.MILLISECONDS);
callbackExecutor.shutdown();
} }
@Test @Test
public void testSendMessageAsync() throws RemotingException, MQClientException, InterruptedException { public void testSendMessageAsync() throws RemotingException, MQClientException, InterruptedException {
final AtomicInteger cc = new AtomicInteger(0); final AtomicInteger cc = new AtomicInteger(0);
final CountDownLatch countDownLatch = new CountDownLatch(6); final CountDownLatch countDownLatch = new CountDownLatch(6);
ExecutorService callbackExecutor = Executors.newSingleThreadExecutor();
when(mQClientAPIImpl.getRemotingClient()).thenReturn((nettyRemotingClient));
when(nettyRemotingClient.getCallbackExecutor()).thenReturn(callbackExecutor);
SendCallback sendCallback = new SendCallback() { SendCallback sendCallback = new SendCallback() {
@Override @Override
...@@ -226,16 +219,13 @@ public class DefaultMQProducerTest { ...@@ -226,16 +219,13 @@ public class DefaultMQProducerTest {
producer.send(message,messageQueueSelector,null,sendCallback,1000); producer.send(message,messageQueueSelector,null,sendCallback,1000);
countDownLatch.await(3000L, TimeUnit.MILLISECONDS); countDownLatch.await(3000L, TimeUnit.MILLISECONDS);
callbackExecutor.shutdown();
assertThat(cc.get()).isEqualTo(6); assertThat(cc.get()).isEqualTo(6);
} }
@Test @Test
public void testSendMessageAsync_BodyCompressed() throws RemotingException, InterruptedException, MQBrokerException, MQClientException { public void testSendMessageAsync_BodyCompressed() throws RemotingException, InterruptedException, MQBrokerException, MQClientException {
ExecutorService callbackExecutor = Executors.newSingleThreadExecutor();
final CountDownLatch countDownLatch = new CountDownLatch(1); final CountDownLatch countDownLatch = new CountDownLatch(1);
when(mQClientAPIImpl.getRemotingClient()).thenReturn((nettyRemotingClient));
when(nettyRemotingClient.getCallbackExecutor()).thenReturn(callbackExecutor);
producer.send(bigMessage, new SendCallback() { producer.send(bigMessage, new SendCallback() {
@Override @Override
public void onSuccess(SendResult sendResult) { public void onSuccess(SendResult sendResult) {
...@@ -251,7 +241,6 @@ public class DefaultMQProducerTest { ...@@ -251,7 +241,6 @@ public class DefaultMQProducerTest {
} }
}); });
countDownLatch.await(3000L, TimeUnit.MILLISECONDS); countDownLatch.await(3000L, TimeUnit.MILLISECONDS);
callbackExecutor.shutdown();
} }
@Test @Test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册