Search in sources :

Example 1 with PlainHttpListener

use of oap.http.PlainHttpListener in project oap by oaplatform.

the class WsFileUploaderTest method beforeMethod.

@BeforeMethod
@Override
public void beforeMethod() throws Exception {
    Env.resetPorts();
    super.beforeMethod();
    kernel = new Kernel(Lists.empty());
    kernel.start();
    path = Env.tmpPath("/tmp");
    Files.ensureDirectory(path);
    medias.clear();
    server = new Server(100);
    ws = new WebServices(server, new SessionManager(10, null, "/"), GenericCorsPolicy.DEFAULT, WsConfig.CONFIGURATION.fromResource(getClass(), "ws-multipart.conf"));
    WsFileUploader service = new WsFileUploader(path, 1024 * 1024, -1, singletonList(new VastMediaProcessing(shell("ffprobe -v quiet -print_format xml -show_format -sexagesimal -show_streams {FILE}"), 10000L)));
    service.addListener((media, mediaInfo, mediaContext) -> WsFileUploaderTest.this.medias.add(__(media, mediaInfo)));
    kernel.register("upload", service);
    ws.start();
    listener = new SynchronizedThread(new PlainHttpListener(server, Env.port()));
    listener.start();
    Cuid.reset("p", 1);
}
Also used : VastMediaProcessing(oap.media.postprocessing.VastMediaProcessing) Server(oap.http.Server) WebServices(oap.ws.WebServices) SessionManager(oap.ws.SessionManager) SynchronizedThread(oap.concurrent.SynchronizedThread) PlainHttpListener(oap.http.PlainHttpListener) Kernel(oap.application.Kernel) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with PlainHttpListener

use of oap.http.PlainHttpListener in project oap by oaplatform.

the class AbstractWebServicesTest method startServer.

@BeforeClass
public void startServer() {
    Env.resetPorts();
    kernel = new Kernel(Lists.empty());
    server = new Server(100);
    ws = new WebServices(server, new SessionManager(10, null, "/"), GenericCorsPolicy.DEFAULT, Lists.map(getConfig(), n -> WsConfig.CONFIGURATION.fromResource(getClass(), n)));
    kernel.start();
    registerServices(kernel);
    ws.start();
    listener = new SynchronizedThread(new PlainHttpListener(server, Env.port()));
    listener.start();
}
Also used : Server(oap.http.Server) SynchronizedThread(oap.concurrent.SynchronizedThread) PlainHttpListener(oap.http.PlainHttpListener) Kernel(oap.application.Kernel) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with PlainHttpListener

use of oap.http.PlainHttpListener in project oap by oaplatform.

the class WebServicesPerformance method blockingThreads.

@Test
public void blockingThreads() {
    Server server = new Server(5000);
    SynchronizedThread listener = new SynchronizedThread(new PlainHttpListener(server, Env.port()));
    listener.start();
    try {
        WebServices ws = new WebServices(server, SESSION_MANAGER, GenericCorsPolicy.DEFAULT);
        ws.bind("x/v/math", GenericCorsPolicy.DEFAULT, new MathWS(), false, SESSION_MANAGER, Collections.emptyList(), Protocol.HTTP);
        HttpAsserts.reset();
        benchmark("Server.invocations", samples, () -> HttpAsserts.assertGet(HTTP_URL("/x/v/math/id?a=aaa")).responded(200, "OK", ContentType.APPLICATION_JSON, "\"aaa\"")).inThreads(5000).run();
        HttpAsserts.reset();
    } finally {
        listener.stop();
        server.stop();
    }
}
Also used : NioServer(oap.http.nio.NioServer) Server(oap.http.Server) SynchronizedThread(oap.concurrent.SynchronizedThread) PlainHttpListener(oap.http.PlainHttpListener) Test(org.testng.annotations.Test)

Example 4 with PlainHttpListener

use of oap.http.PlainHttpListener in project oap by oaplatform.

the class AbstractWsValidateTest method beforeClass.

@BeforeClass
public void beforeClass() {
    Env.resetPorts();
    Metrics.resetAll();
    server.start();
    for (val wsInstance : getWsInstances()) ws.bind("test", GenericCorsPolicy.DEFAULT, wsInstance, false, SESSION_MANAGER, Collections.emptyList(), Protocol.HTTP);
    PlainHttpListener http = new PlainHttpListener(server, Env.port());
    listener = new SynchronizedThread(http);
    listener.start();
}
Also used : lombok.val(lombok.val) SynchronizedThread(oap.concurrent.SynchronizedThread) PlainHttpListener(oap.http.PlainHttpListener) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with PlainHttpListener

use of oap.http.PlainHttpListener 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)

Aggregations

SynchronizedThread (oap.concurrent.SynchronizedThread)5 PlainHttpListener (oap.http.PlainHttpListener)5 Server (oap.http.Server)3 BeforeClass (org.testng.annotations.BeforeClass)3 Kernel (oap.application.Kernel)2 lombok.val (lombok.val)1 NioServer (oap.http.nio.NioServer)1 VastMediaProcessing (oap.media.postprocessing.VastMediaProcessing)1 SessionManager (oap.ws.SessionManager)1 WebServices (oap.ws.WebServices)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1