Package org.xlightweb.client

Examples of org.xlightweb.client.HttpClientConnection$ExtendedClosedChannelException


       
        IServer server = new Server(hdl);
        server.start();
       
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
        IHttpResponse response = con.call(new GetRequest("/"));
       
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("12345", response.getBlockingBody().readString());
        Assert.assertEquals("me", response.getServer());
       
        con.close();
        server.close();
    }   
View Full Code Here


      String basepath = file.getParentFile().getAbsolutePath();
   
    IServer server = new HttpServer(new FileServiceRequestHandler(basepath));
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   

    IHttpRequest request = new GetRequest("/" + file.getName());
    request.setHeader("Range", "bytes=74-74");
   
    IHttpResponse response = con.call(request);
   
    Assert.assertEquals(206, response.getStatus());
    Assert.assertEquals(">", response.getBody().readString());
   
    file.delete();
    con.close();
    server.close();
  }
View Full Code Here

      String basepath = file.getParentFile().getAbsolutePath();
   
    IServer server = new HttpServer(new FileServiceRequestHandler(basepath));
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   

    IHttpRequest request = new GetRequest("/" + file.getName());
    request.setHeader("Range", "bytes=0-0");
   
    IHttpResponse response = con.call(request);
   
    Assert.assertEquals(206, response.getStatus());
    Assert.assertEquals("<", response.getBody().readString());
   
    file.delete();
    con.close();
    server.close();
  }
View Full Code Here

      String basepath = file.getParentFile().getAbsolutePath();
   
    IServer server = new HttpServer(new FileServiceRequestHandler(basepath));
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   

    IHttpRequest request = new GetRequest("/" + file.getName());
    request.setHeader("Range", "bytes=-10");
   
    IHttpResponse response = con.call(request);
   
    Assert.assertEquals(206, response.getStatus());
    Assert.assertEquals("le></head>", response.getBody().readString());
   
    file.delete();
    con.close();
    server.close();
 
View Full Code Here

      String basepath = file.getParentFile().getAbsolutePath();
   
    IServer server = new HttpServer(new FileServiceRequestHandler(basepath));
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   

    IHttpRequest request = new GetRequest("/" + file.getName());
    request.setHeader("Range", "bytes=-1");
   
    IHttpResponse response = con.call(request);
   
    Assert.assertEquals(206, response.getStatus());
    Assert.assertEquals(">", response.getBody().readString());
   
    file.delete();
    con.close();
    server.close();
 
View Full Code Here

      String basepath = file.getParentFile().getAbsolutePath();
   
    IServer server = new HttpServer(new FileServiceRequestHandler(basepath));
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   

    IHttpRequest request = new GetRequest("/" + file.getName());
    request.setHeader("Range", "bytes=170-");
   
    IHttpResponse response = con.call(request);
   
    Assert.assertEquals(400, response.getStatus());
   
    file.delete();
    con.close();
    server.close();
  }
View Full Code Here

      String basepath = file.getParentFile().getAbsolutePath();
   
    IServer server = new HttpServer(new FileServiceRequestHandler(basepath));
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   

    IHttpRequest request = new GetRequest("/" + file.getName());
    request.setHeader("Range", "bytes=0-0,-1");
   
    IHttpResponse response = con.call(request);
       
    Assert.assertEquals(206, response.getStatus());
   
    file.delete();
    con.close();
    server.close();
 
View Full Code Here

      String basepath = file.getParentFile().getAbsolutePath();
   
    IServer server = new HttpServer(new FileServiceRequestHandler(basepath));
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   

    IHttpRequest request = new GetRequest("/" + file.getName());
    request.setHeader("Range", "bytes=0-0,37-67,-1");
   
    IHttpResponse response = con.call(request);
   
    QAUtil.sleep(1000);
    System.out.println(response);
   
    Assert.assertEquals(206, response.getStatus());
   
    file.delete();
    con.close();
    server.close();
  }   
View Full Code Here

      String basepath = file.getParentFile().getAbsolutePath();
   
    IServer server = new HttpServer(new FileServiceRequestHandler(basepath));
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());

    IHttpResponse response = con.call(new GetRequest("/" + file.getName()));
    Assert.assertEquals(200, response.getStatus());
   
    response.getBody().readString();
   
    String lastModified = response.getHeader("Last-Modified");
    GetRequest secondRequest = new GetRequest("/" + file.getName());
    secondRequest.setHeader("If-Modified-Since", lastModified);
   
    response = con.call(secondRequest);
    Assert.assertEquals("unexpected response " + response, 304, response.getStatus());
   
   
    file.delete();
    con.close();
    server.close();
  }
View Full Code Here

    chain.addLast(new BusinessHandler());
   
    IServer server = new HttpServer(chain);
    server.start();
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());

    IHttpResponse response = con.call(new GetRequest("/" + file.getName()));
    Assert.assertEquals(200, response.getStatus());

    File tempFile = QAUtil.createTempfile();
   
    RandomAccessFile raf = new RandomAccessFile(tempFile, "rw");
    FileChannel fc = raf.getChannel();
   
    BodyDataSource source = response.getBody();
    source.transferTo(fc);
   
    fc.close();
    raf.close();
   
    Assert.assertTrue(QAUtil.isEquals(file, tempFile));

    tempFile.delete();
    file.delete();
    con.close();
    server.close();
  }
View Full Code Here

TOP

Related Classes of org.xlightweb.client.HttpClientConnection$ExtendedClosedChannelException

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.