Package org.xlightweb

Examples of org.xlightweb.RequestHandlerChain


 
  @Test
  public void testTimestamp() throws Exception {
      System.out.println("testTimestamp");
 
    RequestHandlerChain chain = new RequestHandlerChain();
   
    chain.addLast(new TimestampHandler());
    chain.addLast(new EchoHandler());
   
    IServer server = new HttpServer(chain);
    ConnectionUtils.start(server);
 
   
View Full Code Here


  @Test
  public void testAudit() throws Exception {
      System.out.println("testAudit");
 
    RequestHandlerChain chain = new RequestHandlerChain();
   
    AuditFilter auditFilter = new AuditFilter();
    chain.addLast(auditFilter);
    chain.addLast(new EchoHandler());
   
    IServer server = new HttpServer(chain);
    ConnectionUtils.start(server);
   
   
View Full Code Here

  @Test
  public void testAuditAndCaesarCipher() throws Exception {
      System.out.println("testAuditAndCaesarCipher");
   
    RequestHandlerChain chain = new RequestHandlerChain();
   
    CaesarCipherHandler caesarCipherHandler = new CaesarCipherHandler(-1);
    chain.addLast(caesarCipherHandler);
   
    AuditFilter auditHandler = new AuditFilter();
    chain.addLast(auditHandler);
   
    chain.addLast(new EchoHandler());
   
    HttpServer server = new HttpServer(chain);
    server.start();
 
   
View Full Code Here

        }       
      }
    };
   
   
    RequestHandlerChain chain = new RequestHandlerChain();
    chain.addLast(auditFilter);
    chain.addLast(new HeaderInfoServerHandler());
   
    HttpServer server = new HttpServer(0, chain);
    server.setCloseOnSendingError(false);
    ConnectionUtils.start(server);
 
View Full Code Here

 
  @Test
  public void testReplaceRequest() throws Exception {
      System.out.println("testReplaceRequest");
 
    RequestHandlerChain chain = new RequestHandlerChain();
   
    IHttpRequestHandler filter = new IHttpRequestHandler() {

      public void onRequest(final IHttpExchange exchange) throws IOException {

        PostRequest newRequest = new PostRequest(exchange.getRequest().getRequestUrl().toString(), "text/plain", "Hello");
       
        IHttpResponseHandler respHdl = new IHttpResponseHandler() {
       
          public void onResponse(IHttpResponse response) throws IOException {
            exchange.send(response);
          }
         
          public void onException(IOException ioe) {
           
          }
         
        };
       
       
        exchange.forward(newRequest, respHdl);
      }
    };
   
   
    chain.addLast(filter);
    chain.addLast(new EchoHandler());
   
    IServer server = new HttpServer(0, chain);
    ConnectionUtils.start(server);
   
   
View Full Code Here

      System.out.println("testReplaceStreamedRequest");
 
      System.setProperty("org.xlightweb.showDetailedError", "true");

     
    RequestHandlerChain chain = new RequestHandlerChain();
   
    IHttpRequestHandler filter = new IHttpRequestHandler() {

      public void onRequest(final IHttpExchange exchange) throws IOException {
       
        IHttpResponseHandler respHdl = new IHttpResponseHandler() {
       
          public void onResponse(IHttpResponse response) throws IOException {
            exchange.send(response);
          }
         
          public void onException(IOException ioe) {
           
          }
         
        };
       
       
       
        BodyDataSink bodyDataSink = exchange.forward(new HttpRequestHeader("POST", exchange.getRequest().getRequestUrl().toString()), respHdl);
        bodyDataSink.write("Hel");
        QAUtil.sleep(200);
       
        bodyDataSink.write("lo");
        bodyDataSink.close();
      }
    };
   
   
    chain.addLast(filter);
    chain.addLast(new EchoHandler());
   
    IServer server = new HttpServer(chain);
    server.start();
   
   
View Full Code Here

 
  @Test
  public void testReplaceResponse() throws Exception {
      System.out.println("testReplaceResponse");
 
    RequestHandlerChain chain = new RequestHandlerChain();
   
    IHttpRequestHandler filter = new IHttpRequestHandler() {

      public void onRequest(final IHttpExchange exchange) throws IOException {

        IHttpResponseHandler respHdl = new IHttpResponseHandler() {
       
          public void onResponse(IHttpResponse response) throws IOException {
         
            HttpResponse newResponse = new HttpResponse(200, "text/plain", "Hello You");
            exchange.send(newResponse);
          }
         
          public void onException(IOException ioe) {
           
          }
         
        };
       
       
        exchange.forward(exchange.getRequest(), respHdl);
      }
    };
   
   
    chain.addLast(filter);
    chain.addLast(new EchoHandler());
   
    IServer server = new HttpServer(0, chain);
    ConnectionUtils.start(server);
   
   
View Full Code Here

public final class RequestHandlerChainTest {

  @Test
  public void testFirstHandler() throws Exception {
     RequestHandlerChain chain = new RequestHandlerChain();
   
    RequestHandler h1 = new RequestHandler("/test");
    chain.addLast(h1);
   
    RequestHandler h2 = new RequestHandler("/bs");
    chain.addLast(h2);

    IHttpServer server = new HttpServer(chain);
    server.start();
   
   
View Full Code Here

  }

 
  @Test
  public void testSecondHandler() throws Exception {
        RequestHandlerChain chain = new RequestHandlerChain();
       
        RequestHandler h1 = new RequestHandler("/test");
        chain.addLast(h1);
       
        RequestHandler h2 = new RequestHandler("/bs");
        chain.addLast(h2);

        IHttpServer server = new HttpServer(chain);
        server.start();
       
       
View Full Code Here

 
 
    @Test
    public void testNoHandler() throws Exception {
        RequestHandlerChain chain = new RequestHandlerChain();
       
        RequestHandler h1 = new RequestHandler("/test");
        chain.addLast(h1);
       
        RequestHandler h2 = new RequestHandler("/bs");
        chain.addLast(h2);

        IHttpServer server = new HttpServer(chain);
        server.start();
       
       
View Full Code Here

TOP

Related Classes of org.xlightweb.RequestHandlerChain

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.