Search in sources :

Example 6 with SynchronizedThread

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");
}
Also used : SynchronizedThread(oap.concurrent.SynchronizedThread) Test(org.testng.annotations.Test)

Example 7 with SynchronizedThread

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();
}
Also used : SynchronizedThread(oap.concurrent.SynchronizedThread) PlainHttpListener(oap.http.PlainHttpListener) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with SynchronizedThread

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);
}
Also used : SynchronizedThread(oap.concurrent.SynchronizedThread) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test) AbstractTest(oap.testng.AbstractTest)

Aggregations

SynchronizedThread (oap.concurrent.SynchronizedThread)8 PlainHttpListener (oap.http.PlainHttpListener)5 BeforeClass (org.testng.annotations.BeforeClass)4 Server (oap.http.Server)3 Test (org.testng.annotations.Test)3 Kernel (oap.application.Kernel)2 lombok.val (lombok.val)1 NioServer (oap.http.nio.NioServer)1 VastMediaProcessing (oap.media.postprocessing.VastMediaProcessing)1 AbstractTest (oap.testng.AbstractTest)1 SessionManager (oap.ws.SessionManager)1 WebServices (oap.ws.WebServices)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 Matchers.anyString (org.mockito.Matchers.anyString)1 BeforeMethod (org.testng.annotations.BeforeMethod)1