Package org.xsocket.connection

Examples of org.xsocket.connection.Server


                return true;
            }
        };
       
        IServer server = new Server(dh);
        server.start();


        HttpClient httpClient = new HttpClient();
        httpClient.setCallReturnOnMessage(true);
       
        IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/test"));
       
        Assert.assertEquals(200, response.getStatus());
        Assert.assertTrue(response.getNonBlockingBody().isCompleteReceived());
       
        httpClient.close();
        server.close();
    }
View Full Code Here


                return true;
            }
        };
       
        IServer server = new Server(dh);
        server.start();


        HttpClient httpClient = new HttpClient();
        httpClient.setCallReturnOnMessage(true);
       
        IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/test"));
       
        Assert.assertEquals(200, response.getStatus());
        Assert.assertTrue(response.getNonBlockingBody().isCompleteReceived());
       
        httpClient.close();
        server.close();
    }   
View Full Code Here

                return true;
            }
        };
       
        IServer server = new Server(dh);
        server.start();


        HttpClient httpClient = new HttpClient();
        httpClient.setMaxRetries(4);
        httpClient.setCallReturnOnMessage(true);
       
        try {
            httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/test"));
            Assert.fail("IOException expected");
        } catch (IOException expected) { }
       
       
        httpClient.close();
        server.close();
    }
View Full Code Here


    // start xSocket
    Context ctx = new Context("/ctx0");
    ctx.addHandler("/ctx1/*", new CompareParametersHandler());
    Server server = new HttpServer(ctx);
    ConnectionUtils.start(server);
   
   
   
   
    GetRequest reqXSocket = new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx0/ctx1/test/test2");
    reqXSocket.setHeader("Host", "localhost");
    reqXSocket.setHeader("User-Agent", "me");

   
    GetRequest reqJetty = new GetRequest("http://localhost:" + servletEngine.getLocalPort() + "/ctx0/ctx1/test/test2");
    reqJetty.setHeader("Host", "localhost");
    reqJetty.setHeader("User-Agent", "me");

   
    IBlockingConnection conXSocket = new BlockingConnection("localhost", server.getLocalPort());
    IBlockingConnection conJetty = new BlockingConnection("localhost", servletEngine.getLocalPort());

    conXSocket.write(reqXSocket.toString());
   
    String header = conXSocket.readStringByDelimiter("\r\n\r\n");
    int contentLength = QAUtil.readContentLength(header);
     
    String bodyXSocket = conXSocket.readStringByLength(contentLength);
   
   
    conJetty.write(reqJetty.toString());
   
    String headerJetty = conJetty.readStringByDelimiter("\r\n\r\n");
    int contentLengthJetty = QAUtil.readContentLength(headerJetty);
     
    String bodyJetty = conJetty.readStringByLength(contentLengthJetty);
   
    Assert.assertEquals(bodyXSocket, bodyJetty);

    conJetty.close();
    conXSocket.close();
    servletEngine.stop();
    server.close();
  }
View Full Code Here

    Context ctxSub = new Context(ctxRoot, "/ctx1");
   
    ctxRoot.addHandler("/ctx1/uuu/*", new DoNothingHandler());
   
    ctxSub.addHandler("/test/*", new CompareParametersHandler());
    Server server = new HttpServer(ctxRoot);
    ConnectionUtils.start(server);
   
   

    GetRequest reqXSocket = new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx0/ctx1/test/test2");
    reqXSocket.setHeader("Host", "localhost");
    reqXSocket.setHeader("User-Agent", "me");

   
    GetRequest reqJetty = new GetRequest("http://localhost:" + jettyServer.getConnectors()[0].getLocalPort() + "/ctx0/ctx1/test/test2");
    reqJetty.setHeader("Host", "localhost");
    reqJetty.setHeader("User-Agent", "me");

   
    IBlockingConnection conXSocket = new BlockingConnection("localhost", server.getLocalPort());
    IBlockingConnection conJetty = new BlockingConnection("localhost", jettyServer.getConnectors()[0].getLocalPort());

    conXSocket.write(reqXSocket.toString());
   
    String header = conXSocket.readStringByDelimiter("\r\n\r\n");
    int contentLength = QAUtil.readContentLength(header);
     
    String bodyXSocket = conXSocket.readStringByLength(contentLength);
   
   
    conJetty.write(reqJetty.toString());
   
    String headerJetty = conJetty.readStringByDelimiter("\r\n\r\n");
    int contentLengthJetty = QAUtil.readContentLength(headerJetty);
     
    String bodyJetty = conJetty.readStringByLength(contentLengthJetty);
   
    Assert.assertEquals(bodyXSocket, bodyJetty);

    conJetty.close();
    conXSocket.close();
   
    jettyServer.stop();
    server.close();
  }
View Full Code Here

                return true;
            }
        };
       
        IServer server = new Server(dh);
        server.start();

       
        HttpClient httpClient = new HttpClient();
       
        GetRequest request = new GetRequest("http://localhost:" + server.getLocalPort() + "/test");
        IHttpResponse response = httpClient.call(request);
       
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("12345", response.getBlockingBody().readString());
       
        httpClient.close();
        server.close();
    }
View Full Code Here

                return true;
            }
        };
       
        IServer server = new Server(dh);
        server.start();

       
        HttpClient httpClient = new HttpClient();
       
        GetRequest request = new GetRequest("http://localhost:" + server.getLocalPort() + "/test");
        IHttpResponse response = httpClient.call(request);
       
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("12345", response.getBlockingBody().readString());
       
        httpClient.close();
        server.close();
    }
View Full Code Here

                return true;
            }
        };
       
        IServer server = new Server(dh);
        server.start();

       
        HttpClient httpClient = new HttpClient();
       
        GetRequest request = new GetRequest("http://localhost:" + server.getLocalPort() + "/test");
        IHttpResponse response = httpClient.call(request);
       
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("12345", response.getBlockingBody().readString());
       
        httpClient.close();
        server.close();
    }
View Full Code Here

                return true;
            }
        };
       
        IServer server = new Server(dh);
        server.start();

       
        HttpClient httpClient = new HttpClient();
       
        GetRequest request = new GetRequest("http://localhost:" + server.getLocalPort() + "/test");
        ResponseHandler respHdl = new ResponseHandler();
        httpClient.send(request, respHdl);
       
       
        while (respHdl.getResponse() == null) {
            QAUtil.sleep(100);
        }
       
        IHttpResponse response = respHdl.getResponse();
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("12345", response.getBlockingBody().readString());
       
        httpClient.close();
        server.close();
    }
View Full Code Here

                return true;
            }
        };
       
        IServer server = new Server(dh);
        server.start();

       
        HttpClient httpClient = new HttpClient();
        httpClient.setMaxRetries(6);
       
        GetRequest request = new GetRequest("http://localhost:" + server.getLocalPort() + "/test");
       
        try {
            IHttpResponse response = httpClient.call(request);
            Assert.fail("IOException expected");
        } catch (IOException expected) {  }
       
        httpClient.close();
        server.close();
    }
View Full Code Here

TOP

Related Classes of org.xsocket.connection.Server

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.