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); }
public void start(Config config) { ApplicationState appState = new ApplicationState(ApplicationConfig.fromConfig(proxyConfig, config)); Stream<ProxyRouteConfig> proxyRouteConfigs = Arrays.stream(routeConfig.split(",")).map(it -> new ProxyRouteConfig(config.getConfig(it))); ProxyClientFactory clientFactory = new ProxyClientFactory(appState); RouteStates routeStates = new RouteStates(proxyRouteConfigs, appState, clientFactory); application = new ApplicationBootstrap(appState.config()) .addServer( "main", bs -> bs.addToPipeline( new SmartHttpPipeline() { @Override public ChannelHandler getApplicationRouter() { return new PipelineRouter(routeStates.routeMap()) { @Override protected void channelRead0(ChannelHandlerContext ctx, Request msg) { super.channelRead0(ctx, msg); if (msg.endOfMessage()) { requestCount.incrementAndGet(); } } }; } })) .build(); }
public Application build() { addServer("main", bs -> bs.addToPipeline(pipelineFragment())); return super.build(); }
@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 testProxy() throws Exception { InetSocketAddress proxiedAddress = new InetSocketAddress("127.0.0.1", server.getPort()); Application application = new ApplicationBootstrap("xio.proxyApplication") .addServer("proxyServer", (bs) -> bs.addToPipeline(proxyFragment(proxiedAddress))) .build(); Dispatcher dispatcher = new Dispatcher() { @Override public MockResponse dispatch(RecordedRequest request) throws InterruptedException { return new MockResponse().setBody("['I am a json response']"); } }; server.setDispatcher(dispatcher); InetSocketAddress proxy = application.instrumentation("proxyServer").boundAddress(); Request request = buildRequest(proxy); Response response = get(request); RecordedRequest servedRequest = server.takeRequest(); application.close(); assertEquals("/api/v1/fives/hand/slap", servedRequest.getRequestUrl().encodedPath()); }