Package org.xlightweb.client

Examples of org.xlightweb.client.HttpClientConnection$IBodySinkPair


        server3.start();
       
        System.out.println("testManualConnectionContinueHeaderUnexpectedResponse server: " + server3.getLocalPort());

       
        HttpClientConnection con = new HttpClientConnection("localhost", server3.getLocalPort());
        System.out.println("conn connected to " + con.getRemotePort());
       
        HttpRequestHeader requestHeader = new HttpRequestHeader("POST", "http://localhost:" + server3.getLocalPort() + "/test", "text/plain; charset=iso-8859-1");
       
        String data = "test1234567890";
        FutureResponseHandler respHdl = new FutureResponseHandler();
        BodyDataSink dataSink = con.send(requestHeader, data.length(), respHdl);
        dataSink.write("test1234567890");
       
        IHttpResponse response = respHdl.getResponse();
       
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals(data, response.getBlockingBody().readString());
       
       
        con.close();
        server3.close();
    }
View Full Code Here


        HttpServer server = new HttpServer(new ContinueHandler());
        server.start();
       
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
        HttpRequestHeader requestHeader = new HttpRequestHeader("POST", "http://localhost:" + server.getLocalPort() + "/test?waittime=4000&checkEarlyData=false", "text/plain; charset=iso-8859-1");
        requestHeader.setHeader("Expect", "100-Continue");
       
    
        String data = "test1234567890";
        ResponseHandler respHdl = new ResponseHandler(data);
        BodyDataSink dataSink = con.send(requestHeader, respHdl);
        respHdl.setBodyDataSink(dataSink);
        dataSink.flush();
       

        while ((respHdl.getLastResponse() == null) || (respHdl.getLastResponse().getStatus() == 100)) {
            QAUtil.sleep(100);
        }
       
        QAUtil.sleep(300);
       
        IHttpResponse response = respHdl.getLastResponse();
       
        Assert.assertEquals(100, respHdl.getLastContinue().getStatus());
        Assert.assertEquals("Continue (autogenerated by xLightweb - continue timeout 3000 millis reached)", respHdl.getLastContinue().getReason());
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals(data, response.getBlockingBody().readString());
       
        con.close();
        server.close();
    }
View Full Code Here

     
      Server server = new Server(dh);
      server.start();
     
     
      HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
     
      IHttpResponse response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("12345", response.getBlockingBody().readString());
     
        response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("12345", response.getBlockingBody().readString());

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

       
        Server server = new Server(dh);
        server.start();
       
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
       
        IHttpResponse response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, response.getStatus());
       
        QAUtil.sleep(1000);
        NonBlockingBodyDataSource dataSource = response.getNonBlockingBody();
       
        BodyDataHandler dataHandler = new BodyDataHandler();
        dataSource.setDataHandler(dataHandler);
       
        QAUtil.sleep(500);
        Assert.assertNull(dataHandler.exceptionRef.get());
        Assert.assertEquals("123", dataHandler.dataRef.get());
               
        dataSource.close();
        QAUtil.sleep(500);
        Assert.assertFalse(con.isOpen());
       
        QAUtil.sleep(500);
        Assert.assertNotNull(dataHandler.exceptionRef.get());
       
        server.close();
View Full Code Here

       
        Server server = new Server(dh);
        server.start();
       
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
       
        IHttpResponse response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, response.getStatus());
       
        QAUtil.sleep(1000);
        NonBlockingBodyDataSource dataSource = response.getNonBlockingBody();
       
        BodyDataHandler dataHandler = new BodyDataHandler();
        dataSource.setDataHandler(dataHandler);
       
        QAUtil.sleep(1000);
        Assert.assertNull(dataHandler.exceptionRef.get());
        Assert.assertEquals("123", dataHandler.dataRef.get());
               
        dataSource.destroy();
        Assert.assertFalse(con.isOpen());
       
        QAUtil.sleep(1000);
        Assert.assertNotNull(dataHandler.exceptionRef.get());
       
        server.close();
View Full Code Here

        };
       
        WebContainer server = new WebContainer(servlet);
        server.start();
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
       
        IHttpResponse response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("12345", response.getBlockingBody().readString());
       
        response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("12345", response.getBlockingBody().readString());

       
        con.close();
        server.stop();
    }
View Full Code Here

        };
       
        WebContainer server = new WebContainer(servlet);
        server.start();
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
       
        IHttpResponse response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));

        Assert.assertEquals(200, response.getStatus());
        String body = response.getBlockingBody().readString();
       
        Assert.assertEquals(sb.toString().length(), body.length());
        Assert.assertEquals(sb.toString(), body);
       
        con.close();
        server.stop();
    }
View Full Code Here

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

       
        Server server = new Server(dh);
        server.start();
       
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
       
        try {
            IHttpResponse response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
            Assert.assertEquals(200, response.getStatus());

            response.getBlockingBody().readString();
            Assert.fail("ProtocolException expected");
        } catch (ProtocolException expected) {  }
       
        con.close();
        server.close();
  }
View Full Code Here

       
        Server server = new Server(dh);
        server.start();
       
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
       
        try {
            con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
            Assert.fail("ProtocolException expected");
        } catch (ProtocolException expected) { }
       
        server.close();
    }
View Full Code Here

TOP

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

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.