Package org.xlightweb

Examples of org.xlightweb.RequestHandlerChain


      System.out.println("testChainHandledByFileServiceNotSuccessor");
   
      File file = QAUtil.createTestfile_400k();
      String basepath = file.getParentFile().getAbsolutePath();

    RequestHandlerChain chain = new RequestHandlerChain();
    chain.addLast(new FileServiceRequestHandler(basepath));
    chain.addLast(new BusinessHandler());
   
    IServer server = new HttpServer(chain);
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
View Full Code Here


      System.out.println("testChainLogInterceptor");
 
      File file = QAUtil.createTestfile_400k();
      String basepath = file.getParentFile().getAbsolutePath();

    RequestHandlerChain chain = new RequestHandlerChain();
    chain.addLast(new LogHandler());
    FileServiceRequestHandler fileSrv = new FileServiceRequestHandler(basepath);
    chain.addLast(fileSrv);
   
    IServer server = new HttpServer(chain);
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
View Full Code Here

        System.out.println("testCachingValidationBased");

        File file = QAUtil.createTestfile_40k();
        String basepath = file.getParentFile().getAbsolutePath();
       
        RequestHandlerChain chain = new RequestHandlerChain();
        chain.addLast(new CacheHandler(500));
        chain.addLast(new FileServiceRequestHandler(basepath, true));
       
        IServer server = new HttpServer(chain);
        server.start();
       
        // first request
View Full Code Here

        System.out.println("testCachingExpiredBased");

        File file = QAUtil.createTestfile_40k();
        String basepath = file.getParentFile().getAbsolutePath();
       
        RequestHandlerChain chain = new RequestHandlerChain();
        chain.addLast(new CacheHandler(500));
        chain.addLast(new FileServiceRequestHandler(basepath, 60));
       
        IServer server = new HttpServer(chain);
        server.start();
       
        // first request
View Full Code Here

 
  @Test
  public void testReplaceResponseBound() throws Exception {
 
    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 {
           
            BodyDataSink bodyDataSink = exchange.send(new HttpResponseHeader(200, "text/plain"), 9);
            bodyDataSink.write("Hello");
            QAUtil.sleep(200);
            bodyDataSink.write(" You");
            bodyDataSink.close();         
          }
         
          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

 
  @Test
  public void testTimestamp() throws Exception {
 
    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 {
 
    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 {
   
    RequestHandlerChain chain = new RequestHandlerChain();
   
    CaesarCipherHandler caesarCipherHandler = new CaesarCipherHandler(-1);
    chain.addLast(caesarCipherHandler);
   
    AuditFilter auditHandler = new AuditFilter();
    chain.addLast(auditHandler);
   
    chain.addLast(new EchoHandler());
   
    IServer server = new HttpServer(chain);
    ConnectionUtils.start(server);
 
   
View Full Code Here

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

  @Test
  public void testLifeCycle() throws Exception {

    RequestHandlerChain root = new RequestHandlerChain();
   
    RequestHandler h1 = new RequestHandler();
    root.addLast(h1);
   
    RequestHandler h2 = new RequestHandler();
    root.addLast(h2);
   
    IServer server = new HttpServer(root);
    ConnectionUtils.start(server);
   
    Assert.assertEquals(1, h1.getCountOnInitCalled());
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.