List of usage examples for org.apache.http.localserver ResponseBasicUnauthorized ResponseBasicUnauthorized
ResponseBasicUnauthorized
From source file:com.yahoo.gondola.container.utils.LocalTestServer.java
public LocalTestServer(HttpRequestHandler handler) { try {//w w w . j a va2s. c o m setUp(); HttpProcessor httpproc = HttpProcessorBuilder.create().add(new ResponseDate()) .add(new ResponseServer(LocalServerTestBase.ORIGIN)).add(new ResponseContent()) .add(new ResponseConnControl()).add(new RequestBasicAuth()).add(new ResponseBasicUnauthorized()) .build(); this.serverBootstrap.setHttpProcessor(httpproc); this.serverBootstrap.registerHandler("*", handler); host = start(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.apache.brooklyn.util.core.ResourceUtilsHttpTest.java
@BeforeClass(alwaysRun = true) public void setUp() throws Exception { utils = ResourceUtils.create(this, "mycontext"); server = new TestHttpServer().interceptor(new ResponseServer()).interceptor(new ResponseBasicUnauthorized()) .interceptor(new RequestBasicAuth()).handler("/simple", new TestHttpRequestHandler().response("OK")) .handler("/empty", new TestHttpRequestHandler().code(HttpStatus.SC_NO_CONTENT)) .handler("/missing", new TestHttpRequestHandler().code(HttpStatus.SC_NOT_FOUND).response("Missing")) .handler("/redirect", new TestHttpRequestHandler().code(HttpStatus.SC_MOVED_TEMPORARILY).response("Redirect") .header("Location", "/simple")) .handler("/cycle", new TestHttpRequestHandler().code(HttpStatus.SC_MOVED_TEMPORARILY).response("Redirect") .header("Location", "/cycle")) .handler("/secure", new TestHttpRequestHandler().code(HttpStatus.SC_MOVED_TEMPORARILY).response("Redirect") .header("Location", "https://0.0.0.0/")) .handler("/auth", new AuthHandler("test", "test", "OK")) .handler("/auth_escape", new AuthHandler("test@me:/", "test", "OK")) .handler("/auth_escape2", new AuthHandler("test@me:test", "", "OK")) .handler("/no_credentials", new CheckNoCredentials()).start(); baseUrl = server.getUrl();/*from w w w.j a va2 s. co m*/ }
From source file:brooklyn.util.ResourceUtilsHttpTest.java
@BeforeClass(alwaysRun = true) public void setUp() throws Exception { utils = ResourceUtils.create(this, "mycontext"); BasicHttpProcessor httpProcessor = new BasicHttpProcessor(); httpProcessor.addInterceptor(new ResponseServer()); httpProcessor.addInterceptor(new ResponseContent()); httpProcessor.addInterceptor(new ResponseConnControl()); httpProcessor.addInterceptor(new RequestBasicAuth()); httpProcessor.addInterceptor(new ResponseBasicUnauthorized()); server = new LocalTestServer(httpProcessor, null); server.register("/simple", new SimpleResponseHandler("OK")); server.register("/empty", new SimpleResponseHandler(HttpStatus.SC_NO_CONTENT, "")); server.register("/missing", new SimpleResponseHandler(HttpStatus.SC_NOT_FOUND, "Missing")); server.register("/redirect", new SimpleResponseHandler(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect", new BasicHeader("Location", "/simple"))); server.register("/cycle", new SimpleResponseHandler(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect", new BasicHeader("Location", "/cycle"))); server.register("/secure", new SimpleResponseHandler(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect", new BasicHeader("Location", "https://0.0.0.0/"))); server.register("/auth", new AuthHandler("test", "test", "OK")); server.register("/auth_escape", new AuthHandler("test@me:/", "test", "OK")); server.register("/auth_escape2", new AuthHandler("test@me:test", "", "OK")); server.register("/no_credentials", new CheckNoCredentials()); server.start();//from w ww.ja v a 2s .co m InetSocketAddress addr = server.getServiceAddress(); baseUrl = "http://" + addr.getHostName() + ":" + addr.getPort(); }
From source file:com.asakusafw.yaess.jobqueue.client.HttpJobClientTest.java
/** * Initializes the test.//from w w w . ja v a 2 s . co m * @throws Exception if some errors were occurred */ @Before public void setUp() throws Exception { BasicHttpProcessor proc = new BasicHttpProcessor(); proc.addInterceptor(new ResponseDate()); proc.addInterceptor(new ResponseServer()); proc.addInterceptor(new ResponseContent()); proc.addInterceptor(new ResponseConnControl()); proc.addInterceptor(new RequestBasicAuth()); proc.addInterceptor(new ResponseBasicUnauthorized()); server = new LocalTestServer(proc, null); server.start(); InetSocketAddress address = server.getServiceAddress(); baseUrl = new URL("http", address.getHostName(), address.getPort(), "/").toExternalForm(); }
From source file:org.apache.camel.component.http4.HttpAuthenticationTest.java
@Override protected BasicHttpProcessor getBasicHttpProcessor() { BasicHttpProcessor httpproc = new BasicHttpProcessor(); httpproc.addInterceptor(new RequestBasicAuth()); httpproc.addInterceptor(new ResponseContent()); httpproc.addInterceptor(new ResponseBasicUnauthorized()); return httpproc; }
From source file:org.apache.brooklyn.util.HttpAssertsTest.java
private TestHttpServer initializeServerUnstarted() { return new TestHttpServer().interceptor(new ResponseServer()).interceptor(new ResponseBasicUnauthorized()) .interceptor(new RequestBasicAuth()).handler("/simple", new TestHttpRequestHandler().response("OK")) .handler("/empty", new TestHttpRequestHandler().code(HttpStatus.SC_NO_CONTENT)) .handler("/missing", new TestHttpRequestHandler().code(HttpStatus.SC_NOT_FOUND).response("Missing")) .handler("/redirect", new TestHttpRequestHandler().code(HttpStatus.SC_MOVED_TEMPORARILY).response("Redirect") .header("Location", "/simple")) .handler("/cycle", new TestHttpRequestHandler().code(HttpStatus.SC_MOVED_TEMPORARILY).response("Redirect") .header("Location", "/cycle")) .handler("/secure", new TestHttpRequestHandler().code(HttpStatus.SC_MOVED_TEMPORARILY) .response("Redirect").header("Location", "https://0.0.0.0/")); }