public static void main(String args[]) throws Exception { Application application = new ApplicationBootstrap("exhibitor-test") .addServer("main", bs -> bs.addToPipeline(new SmartHttpPipeline())) .build(); application .getState() .getZkClient() .getClient() .create() .creatingParentsIfNeeded() .forPath("/test/key", "value".getBytes()); } }
@Before public void before() { application = new ApplicationBootstrap("xio.testZipkinApplication") .addServer( "exampleServer", (bs) -> bs.addToPipeline(new SmartHttpPipeline(TestHandler::new))) .build(); MetricRegistry metricRegistry = mock(MetricRegistry.class); requestsMeter = mock(Meter.class); when(metricRegistry.meter("requests")).thenReturn(requestsMeter); successMeter = mock(Meter.class); when(metricRegistry.meter("statusClassSuccess")).thenReturn(successMeter); application.getState().setMetricRegistry(metricRegistry); }
@Before public void before() throws Exception { ApplicationConfig appConfig = ApplicationConfig.fromConfig("xio.testZipkinApplication"); application = new ApplicationBootstrap(appConfig, XioTracingDecorator::new) .addServer( "exampleServer", (bs) -> bs.addToPipeline(new SmartHttpPipeline(TestHandler::new))) .build(); }
@Test public void buildHttp11Server() { XioServerBootstrap bootstrap = XioServerBootstrap.fromConfig("xio.testHttpsServer").addToPipeline(new SmartHttpPipeline()); XioServer server = bootstrap.build(); assertEquals("ssl-http/1.1", server.getInstrumentation().applicationProtocol()); } }
@Test public void testServe404() { XioServerBootstrap bootstrap = XioServerBootstrap.fromConfig("xio.testHttpServer") .addToPipeline( new SmartHttpPipeline( new XioPipelineFragment() { public String applicationProtocol() { return ""; } public void buildHandlers( ApplicationState appState, XioServerConfig config, XioServerState state, ChannelPipeline pipeline) { pipeline.addLast(new XioHttp404Handler()); } })); try (XioServer server = bootstrap.build()) { Response response = ClientHelper.http(server.getInstrumentation().addressBound()); assertEquals(404, response.code()); assertEquals(server.getInstrumentation() != null, true); } } }