@Test public void testUseIP() throws Exception { Context ctx = new Context(); ctx.put("useIP", "true"); Interceptor.Builder builder = InterceptorBuilderFactory .newInstance(InterceptorType.HOST.toString()); builder.configure(ctx); Interceptor interceptor = builder.build(); final String ORIGINAL_HOST = "originalhost"; Event eventBeforeIntercept = EventBuilder.withBody("test event", Charsets.UTF_8); eventBeforeIntercept.getHeaders().put(Constants.HOST, ORIGINAL_HOST); Assert.assertEquals(ORIGINAL_HOST, eventBeforeIntercept.getHeaders() .get(Constants.HOST)); String expectedHost = InetAddress.getLocalHost().getHostAddress(); Event eventAfterIntercept = interceptor.intercept(eventBeforeIntercept); String actualHost = eventAfterIntercept.getHeaders().get(Constants.HOST); Assert.assertNotNull(actualHost); Assert.assertEquals(expectedHost, actualHost); }
@Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(header)) { return event; } if(host != null) { headers.put(header, host); } return event; }
HostInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(header)) { return event; } if(host != null) { headers.put(header, host); } return event; } }
HostInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(header)) { return event; } if(host != null) { headers.put(header, host); } return event; } private  HostInterceptor(boolean preserveExisting,
      boolean useIP, String header); }
HostInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(header)) { return event; } if(host != null) { headers.put(header, host); } return event; } private  HostInterceptor(boolean preserveExisting,
      boolean useIP, String header); @Override void initialize(); @Override Event intercept(Event event); @Override List<Event> intercept(List<Event> events); @Override void close(); }
HostInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(header)) { return event; } if(host != null) { headers.put(header, host); } return event; } private  HostInterceptor(boolean preserveExisting,
      boolean useIP, String header); @Override void initialize(); @Override Event intercept(Event event); @Override List<Event> intercept(List<Event> events); @Override void close();  }