use of io.airlift.http.server.testing.TestingHttpServer 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();
}
Aggregations