Search in sources :

Example 1 with Server

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

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

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

Aggregations

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