Search in sources :

Example 6 with JettyServerManager

use of com.adaptris.core.management.webserver.JettyServerManager in project interlok by adaptris.

the class JettyMgmtComponentTest method testFromXml_Relative.

@Test
public void testFromXml_Relative() throws Exception {
    JettyServerComponent jetty = new JettyServerComponent();
    String xmlFile = BaseCase.PROPERTIES.getProperty(JETTY_MGMT_XML_RELATIVE);
    int portForServer = PortManager.nextUnusedPort(18080);
    try {
        Properties jettyConfig = new Properties();
        jettyConfig.setProperty("jetty.http.port", String.valueOf(portForServer));
        jettyConfig.setProperty(ServerBuilder.WEB_SERVER_CONFIG_FILE_NAME_CGF_KEY, xmlFile);
        jetty.init(jettyConfig);
        jetty.start();
        Thread.sleep(250);
        final JettyServerManager mgr = JettyServerManager.getInstance();
        Awaitility.await().atMost(MAX_STARTUP_WAIT).with().pollInterval(STARTUP_POLL).until(() -> mgr.isStarted());
    } finally {
        stopAndDestroy(jetty);
        PortManager.release(portForServer);
    }
}
Also used : Properties(java.util.Properties) JettyServerManager(com.adaptris.core.management.webserver.JettyServerManager) Test(org.junit.Test)

Example 7 with JettyServerManager

use of com.adaptris.core.management.webserver.JettyServerManager in project interlok by adaptris.

the class JettyMgmtComponentTest method testFailsafe_WithOverrideDescriptor.

@Test
public void testFailsafe_WithOverrideDescriptor() throws Exception {
    JettyServerComponent jetty = new JettyServerComponent();
    String xmlFile = BaseCase.PROPERTIES.getProperty(JETTY_MGMT_XML);
    int portForServer = PortManager.nextUnusedPort(18080);
    try {
        Properties jettyConfig = new Properties();
        jettyConfig.setProperty("jetty.http.port", String.valueOf(portForServer));
        jettyConfig.put("jetty.deploy.defaultsDescriptorPath", getClass().getClassLoader().getResource(JettyServerManager.DEFAULT_DESCRIPTOR_XML).toString());
        jetty.init(jettyConfig);
        jetty.start();
        Thread.sleep(250);
        final JettyServerManager mgr = JettyServerManager.getInstance();
        Awaitility.await().atMost(MAX_STARTUP_WAIT).with().pollInterval(STARTUP_POLL).until(() -> mgr.isStarted());
    } finally {
        stopAndDestroy(jetty);
        PortManager.release(portForServer);
    }
}
Also used : Properties(java.util.Properties) JettyServerManager(com.adaptris.core.management.webserver.JettyServerManager) Test(org.junit.Test)

Example 8 with JettyServerManager

use of com.adaptris.core.management.webserver.JettyServerManager in project interlok by adaptris.

the class JettyMgmtComponentTest method testFailsafe.

@Test
public void testFailsafe() throws Exception {
    JettyServerComponent jetty = new JettyServerComponent();
    String xmlFile = BaseCase.PROPERTIES.getProperty(JETTY_MGMT_XML);
    int portForServer = PortManager.nextUnusedPort(18080);
    try {
        Properties jettyConfig = new Properties();
        jettyConfig.setProperty(Constants.CFG_JMX_LOCAL_ADAPTER_UID, "service:jmx:jmxmp://localhost:5555");
        jettyConfig.setProperty(Constants.BOOTSTRAP_PROPERTIES_RESOURCE_KEY, "bootstrap.properties");
        jettyConfig.setProperty("jetty.http.port", String.valueOf(portForServer));
        jetty.init(jettyConfig);
        jetty.start();
        Thread.sleep(250);
        final JettyServerManager mgr = JettyServerManager.getInstance();
        Awaitility.await().atMost(MAX_STARTUP_WAIT).with().pollInterval(STARTUP_POLL).until(() -> mgr.isStarted());
    } finally {
        stopAndDestroy(jetty);
        PortManager.release(portForServer);
    }
}
Also used : Properties(java.util.Properties) JettyServerManager(com.adaptris.core.management.webserver.JettyServerManager) Test(org.junit.Test)

Example 9 with JettyServerManager

use of com.adaptris.core.management.webserver.JettyServerManager in project interlok by adaptris.

the class EmbeddedJettyHelper method startServer.

public void startServer() throws Exception {
    jetty = new JettyServerComponent();
    jetty.init(jettyConfig);
    jetty.start();
    Thread.sleep(250);
    final JettyServerManager mgr = JettyServerManager.getInstance();
    while (!mgr.isStarted()) {
        Thread.sleep(250);
    }
}
Also used : JettyServerComponent(com.adaptris.core.management.jetty.JettyServerComponent) JettyServerManager(com.adaptris.core.management.webserver.JettyServerManager)

Aggregations

JettyServerManager (com.adaptris.core.management.webserver.JettyServerManager)9 Properties (java.util.Properties)6 Test (org.junit.Test)6 CoreException (com.adaptris.core.CoreException)2 JettyServerComponent (com.adaptris.core.management.jetty.JettyServerComponent)1 HashMap (java.util.HashMap)1