Search in sources :

Example 6 with ServerConfig

use of org.webpieces.webserver.api.ServerConfig in project webpieces by deanhiller.

the class FeatureTest method startServer.

@Override
protected void startServer() {
    metrics = new SimpleMeterRegistry();
    Server webserver = new Server(getOverrides(metrics), new AppOverridesModule(), new ServerConfig(JavaCache.getCacheLocation()), args);
    webserver.start();
    serverHttpsAddr = new InetSocketAddress("localhost", webserver.getUnderlyingHttpsChannel().getLocalAddress().getPort());
    serverHttpAddr = new InetSocketAddress("localhost", webserver.getUnderlyingHttpChannel().getLocalAddress().getPort());
}
Also used : ServerConfig(org.webpieces.webserver.api.ServerConfig) Server(webpiecesxxxxxpackage.Server) InetSocketAddress(java.net.InetSocketAddress) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry)

Example 7 with ServerConfig

use of org.webpieces.webserver.api.ServerConfig in project webpieces by deanhiller.

the class TestLesson7AdvancedCookiesCrud method setUp.

@Before
public void setUp() throws InterruptedException, ClassNotFoundException, ExecutionException, TimeoutException {
    log.info("Setting up test");
    Asserts.assertWasCompiledWithParamNames("test");
    // clear in-memory database
    jdbc.dropAllTablesFromDatabase();
    SimpleMeterRegistry metrics = new SimpleMeterRegistry();
    // you may want to create this server ONCE in a static method BUT if you do, also remember to clear out all your
    // mocks after every test AND you can no longer run single threaded(tradeoffs, tradeoffs)
    // This is however pretty fast to do in many systems...
    Server webserver = new Server(getOverrides(metrics), null, new ServerConfig(JavaCache.getCacheLocation()), args);
    webserver.start();
    HttpSocket https11Socket = connectHttps(null, webserver.getUnderlyingHttpChannel().getLocalAddress());
    webBrowser = new WebBrowserSimulator(https11Socket);
}
Also used : ServerConfig(org.webpieces.webserver.api.ServerConfig) HttpSocket(org.webpieces.httpclient11.api.HttpSocket) WebBrowserSimulator(org.webpieces.webserver.test.WebBrowserSimulator) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Before(org.junit.Before)

Example 8 with ServerConfig

use of org.webpieces.webserver.api.ServerConfig in project webpieces by deanhiller.

the class TestLesson3Errors method setUp.

@Before
public void setUp() throws InterruptedException, ClassNotFoundException, ExecutionException, TimeoutException {
    Asserts.assertWasCompiledWithParamNames("test");
    // clear in-memory database
    jdbc.dropAllTablesFromDatabase();
    metrics = new SimpleMeterRegistry();
    // you may want to create this server ONCE in a static method BUT if you do, also remember to clear out all your
    // mocks after every test AND you can no longer run single threaded(tradeoffs, tradeoffs)
    // This is however pretty fast to do in many systems...
    Server webserver = new Server(getOverrides(metrics), new AppOverridesModule(), new ServerConfig(JavaCache.getCacheLocation()), args);
    webserver.start();
    http11Socket = connectHttp(webserver.getUnderlyingHttpChannel().getLocalAddress());
}
Also used : ServerConfig(org.webpieces.webserver.api.ServerConfig) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Before(org.junit.Before)

Example 9 with ServerConfig

use of org.webpieces.webserver.api.ServerConfig in project webpieces by deanhiller.

the class TestLesson5WithSelenium method setUp.

@Before
public void setUp() throws InterruptedException, ClassNotFoundException {
    driver = new FirefoxDriver();
    Asserts.assertWasCompiledWithParamNames("test");
    jdbc.dropAllTablesFromDatabase();
    metrics = new SimpleMeterRegistry();
    // you may want to create this server ONCE in a static method BUT if you do, also remember to clear out all your
    // mocks after every test and NOT drop tables but clear and re-populate
    Server webserver = new Server(new OverridesForTestRealServer(metrics), new AppOverridesModule(), new ServerConfig(JavaCache.getCacheLocation()), args);
    webserver.start();
    httpPort = webserver.getUnderlyingHttpChannel().getLocalAddress().getPort();
    httpsPort = webserver.getUnderlyingHttpsChannel().getLocalAddress().getPort();
}
Also used : ServerConfig(org.webpieces.webserver.api.ServerConfig) OverridesForTestRealServer(org.webpieces.webserver.test.OverridesForTestRealServer) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) OverridesForTestRealServer(org.webpieces.webserver.test.OverridesForTestRealServer) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Before(org.junit.Before)

Aggregations

ServerConfig (org.webpieces.webserver.api.ServerConfig)9 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)6 Before (org.junit.Before)5 Test (org.junit.Test)2 InetSocketAddress (java.net.InetSocketAddress)1 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)1 HttpSocket (org.webpieces.httpclient11.api.HttpSocket)1 OverridesForTestRealServer (org.webpieces.webserver.test.OverridesForTestRealServer)1 WebBrowserSimulator (org.webpieces.webserver.test.WebBrowserSimulator)1 Server (webpiecesxxxxxpackage.Server)1