Browse Source

test

pull/3/MERGE
CalvinKirs 4 years ago
parent
commit
cc14b24326
  1. 18
      dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java

18
dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java

@ -42,7 +42,7 @@ public class TaskResponseServiceTest {
private ProcessService processService; private ProcessService processService;
@InjectMocks @InjectMocks
TaskResponseService taskResponseService; TaskResponseService taskRspService;
@Mock @Mock
private Channel channel; private Channel channel;
@ -55,7 +55,7 @@ public class TaskResponseServiceTest {
@Before @Before
public void before() { public void before() {
taskResponseService.start(); taskRspService.start();
ackEvent = TaskResponseEvent.newAck(ExecutionStatus.RUNNING_EXECUTION, ackEvent = TaskResponseEvent.newAck(ExecutionStatus.RUNNING_EXECUTION,
new Date(), new Date(),
@ -82,13 +82,21 @@ public class TaskResponseServiceTest {
public void testAddResponse() { public void testAddResponse() {
Mockito.when(processService.findTaskInstanceById(Mockito.any())).thenReturn(taskInstance); Mockito.when(processService.findTaskInstanceById(Mockito.any())).thenReturn(taskInstance);
Mockito.when(channel.writeAndFlush(Mockito.any())).thenReturn(null); Mockito.when(channel.writeAndFlush(Mockito.any())).thenReturn(null);
taskResponseService.addResponse(ackEvent); taskRspService.addResponse(ackEvent);
taskResponseService.addResponse(resultEvent); taskRspService.addResponse(resultEvent);
} }
@After @After
public void after() { public void after() {
taskResponseService.stop();
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Assert.assertEquals(0, taskRspService.getEventQueue().size());
taskRspService.stop();
} }
} }

Loading…
Cancel
Save