Search in sources :

Example 1 with TestingHttpServerModule

use of io.airlift.http.server.testing.TestingHttpServerModule in project airlift by airlift.

the class TestMBeanServerResource method setup.

@BeforeMethod
public void setup() throws Exception {
    Bootstrap app = new Bootstrap(new TestingNodeModule(), new TestingHttpServerModule(), new JsonModule(), new JmxHttpRpcModule(TheServlet.class), binder -> {
        binder.bind(MBeanServer.class).toInstance(platformMBeanServer);
        binder.bind(TestMBean.class).in(Scopes.SINGLETON);
    });
    Injector injector = app.doNotInitializeLogging().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    TestingHttpServer server = injector.getInstance(TestingHttpServer.class);
    testMBean = injector.getInstance(TestMBean.class);
    testMBeanName = new ObjectName(generatedNameOf(TestMBean.class));
    MBeanExporter exporter = new MBeanExporter(platformMBeanServer);
    exporter.export(testMBeanName.toString(), testMBean);
    JMXConnector connect = JMXConnectorFactory.connect(new JMXServiceURL("service:jmx:" + server.getBaseUrl()), ImmutableMap.of(JMXConnector.CREDENTIALS, new String[] { "foo", "bar" }));
    mbeanServerConnection = connect.getMBeanServerConnection();
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) TestingHttpServerModule(io.airlift.http.server.testing.TestingHttpServerModule) TestingNodeModule(io.airlift.node.testing.TestingNodeModule) MBeanExporter(org.weakref.jmx.MBeanExporter) JsonModule(io.airlift.json.JsonModule) TheServlet(io.airlift.http.server.TheServlet) ObjectName(javax.management.ObjectName) LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) Injector(com.google.inject.Injector) JMXConnector(javax.management.remote.JMXConnector) TestingHttpServer(io.airlift.http.server.testing.TestingHttpServer) Bootstrap(io.airlift.bootstrap.Bootstrap) MBeanServer(javax.management.MBeanServer) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with TestingHttpServerModule

use of io.airlift.http.server.testing.TestingHttpServerModule in project airlift by airlift.

the class TestServer method setup.

@BeforeMethod
public void setup() throws Exception {
    Bootstrap app = new Bootstrap(new TestingNodeModule(), new TestingHttpServerModule(), new JsonModule(), new JaxrsModule(), new JmxHttpModule(), new JmxModule(), new MainModule());
    Injector injector = app.doNotInitializeLogging().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    server = injector.getInstance(TestingHttpServer.class);
    client = new JettyHttpClient();
}
Also used : LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) TestingHttpServerModule(io.airlift.http.server.testing.TestingHttpServerModule) JmxModule(io.airlift.jmx.JmxModule) TestingNodeModule(io.airlift.node.testing.TestingNodeModule) Injector(com.google.inject.Injector) JettyHttpClient(io.airlift.http.client.jetty.JettyHttpClient) JaxrsModule(io.airlift.jaxrs.JaxrsModule) TestingHttpServer(io.airlift.http.server.testing.TestingHttpServer) Bootstrap(io.airlift.bootstrap.Bootstrap) JsonModule(io.airlift.json.JsonModule) JmxHttpModule(io.airlift.jmx.JmxHttpModule) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with TestingHttpServerModule

use of io.airlift.http.server.testing.TestingHttpServerModule in project airlift by airlift.

the class TestServer method setup.

@BeforeMethod
public void setup() {
    Bootstrap app = new Bootstrap(new TestingNodeModule(), new InMemoryEventModule(), new TestingHttpServerModule(), new JsonModule(), new JaxrsModule(), new MainModule());
    Injector injector = app.doNotInitializeLogging().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    server = injector.getInstance(TestingHttpServer.class);
    store = injector.getInstance(PersonStore.class);
    eventClient = injector.getInstance(InMemoryEventClient.class);
    client = new JettyHttpClient();
}
Also used : TestingHttpServerModule(io.airlift.http.server.testing.TestingHttpServerModule) InMemoryEventClient(io.airlift.event.client.InMemoryEventClient) TestingNodeModule(io.airlift.node.testing.TestingNodeModule) JaxrsModule(io.airlift.jaxrs.JaxrsModule) JsonModule(io.airlift.json.JsonModule) InMemoryEventModule(io.airlift.event.client.InMemoryEventModule) LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) Injector(com.google.inject.Injector) JettyHttpClient(io.airlift.http.client.jetty.JettyHttpClient) TestingHttpServer(io.airlift.http.server.testing.TestingHttpServer) Bootstrap(io.airlift.bootstrap.Bootstrap) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with TestingHttpServerModule

use of io.airlift.http.server.testing.TestingHttpServerModule in project airlift by airlift.

the class TestMBeanResource method setup.

@BeforeClass
public void setup() {
    Bootstrap app = new Bootstrap(new TestingNodeModule(), new TestingHttpServerModule(), new JsonModule(), new JaxrsModule(), new JmxHttpModule(), binder -> binder.bind(MBeanServer.class).toInstance(mbeanServer));
    Injector injector = app.quiet().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    server = injector.getInstance(TestingHttpServer.class);
    client = new JettyHttpClient();
}
Also used : LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) TestingHttpServerModule(io.airlift.http.server.testing.TestingHttpServerModule) TestingNodeModule(io.airlift.node.testing.TestingNodeModule) Injector(com.google.inject.Injector) JettyHttpClient(io.airlift.http.client.jetty.JettyHttpClient) JaxrsModule(io.airlift.jaxrs.JaxrsModule) TestingHttpServer(io.airlift.http.server.testing.TestingHttpServer) Bootstrap(io.airlift.bootstrap.Bootstrap) JsonModule(io.airlift.json.JsonModule) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

Injector (com.google.inject.Injector)4 Bootstrap (io.airlift.bootstrap.Bootstrap)4 LifeCycleManager (io.airlift.bootstrap.LifeCycleManager)4 TestingHttpServer (io.airlift.http.server.testing.TestingHttpServer)4 TestingHttpServerModule (io.airlift.http.server.testing.TestingHttpServerModule)4 JsonModule (io.airlift.json.JsonModule)4 TestingNodeModule (io.airlift.node.testing.TestingNodeModule)4 JettyHttpClient (io.airlift.http.client.jetty.JettyHttpClient)3 JaxrsModule (io.airlift.jaxrs.JaxrsModule)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 InMemoryEventClient (io.airlift.event.client.InMemoryEventClient)1 InMemoryEventModule (io.airlift.event.client.InMemoryEventModule)1 TheServlet (io.airlift.http.server.TheServlet)1 JmxHttpModule (io.airlift.jmx.JmxHttpModule)1 JmxModule (io.airlift.jmx.JmxModule)1 MBeanServer (javax.management.MBeanServer)1 ObjectName (javax.management.ObjectName)1 JMXConnector (javax.management.remote.JMXConnector)1 JMXServiceURL (javax.management.remote.JMXServiceURL)1 BeforeClass (org.testng.annotations.BeforeClass)1