use of oap.concurrent.SynchronizedThread in project oap by oaplatform.
the class BackgroundMessageStreamTest method sendIsExecutedInSeparateThread.
@Test
public void sendIsExecutedInSeparateThread() {
TestTransport transport = new TestTransport();
BackgroundMessageStream<String> stream = new BackgroundMessageStream<>(transport, new GuaranteedDeliveryTransport(1));
stream.send("Msg1");
assertThat(transport.messages).isEmpty();
SynchronizedThread thread = new SynchronizedThread(stream);
thread.start();
Threads.sleepSafely(100);
thread.stop();
assertThat(transport.messages).containsExactly("Msg1");
}
use of oap.concurrent.SynchronizedThread in project oap by oaplatform.
the class WsServiceSessionTest method startServer.
@BeforeClass
public void startServer() {
Env.resetPorts();
Metrics.resetAll();
server.start();
ws.bind("test", GenericCorsPolicy.DEFAULT, new TestWS(), true, sessionManager, Collections.emptyList(), Protocol.HTTP);
PlainHttpListener http = new PlainHttpListener(server, Env.port());
listener = new SynchronizedThread(http);
listener.start();
}
use of oap.concurrent.SynchronizedThread in project oap by oaplatform.
the class BackgroundMessageStreamTest method testSendIsExecutedInSeparateThread.
@Test
public void testSendIsExecutedInSeparateThread() throws InterruptedException {
BackgroundMessageStream<String> backgroundStream = new BackgroundMessageStream<>(transport, guaranteedDeliveryTransport);
backgroundStream.send("Msg1");
verifyZeroInteractions(guaranteedDeliveryTransport);
verifyZeroInteractions(transport);
SynchronizedThread thread = new SynchronizedThread(backgroundStream);
thread.start();
Threads.sleepSafely(100);
thread.stop();
verify(guaranteedDeliveryTransport, times(1)).send("Msg1", transport);
}
Aggregations