Examples of IBlockingConnection


Examples of org.xsocket.connection.IBlockingConnection

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

   
    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());

    con.write(req.toString());
   
    String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
    int contentLength = QAUtil.readContentLength(header);
     
    String body = con.readStringByLength(contentLength);
    Assert.assertEquals("OK", body);

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

Examples of org.xsocket.connection.IBlockingConnection

    GetRequest reqJetty = new GetRequest("http://localhost:" + servletEngine.getLocalPort() + "/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);
   

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

Examples of org.xsocket.connection.IBlockingConnection

    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

Examples of org.xsocket.connection.IBlockingConnection

    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

Examples of org.xsocket.connection.IBlockingConnection

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

   
    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());

    con.write(req.toString());

    String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
    int contentLength = QAUtil.readContentLength(header);
    String body = con.readStringByLength(contentLength);
   
    Assert.assertTrue(header.indexOf("200") != -1);
    Assert.assertEquals("OK", body);
   
   
    Assert.assertNotNull(hdl.getRequest());
    Assert.assertTrue(hdl.getOnRequestThreadname().startsWith("xServerPool"));
   
    Assert.assertEquals(1, hdl.getCountOnConnect());
    Assert.assertTrue(hdl.getOnConnectThreadname().startsWith("xServerPool"));
   
    con.close();
    QAUtil.sleep(200);

    Assert.assertEquals(1, hdl.getCountOnDisconnect());
    Assert.assertTrue(hdl.getOnConnectThreadname().startsWith("xServerPool"));
   
View Full Code Here

Examples of org.xsocket.connection.IBlockingConnection

   
    server.start();
   
   
   
    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());



    QAUtil.sleep(1500);

    Assert.assertEquals(1, hdl.getCountOnRequestTimeout());
    if (!hdl.getOnRequestTimeoutThreadname().startsWith("xServerPool")) {
      System.out.println("handler executed by " + hdl.getOnRequestTimeoutThreadname() + " not by xServerPool...");
      Assert.fail("handler executed by " + hdl.getOnRequestTimeoutThreadname() + " not by xServerPool...");
    }
   
    con.close();
    server.close();
  }
View Full Code Here

Examples of org.xsocket.connection.IBlockingConnection

    root.addLast(h2);
   
    IServer server = new HttpServer(root);
    server.start();
   
    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());

    con.write("POST / HTTP/1.1\r\n" +
          "Host: localhost\r\n" +
          "User-Agent: me\r\n" +
          "Content-Length: 4\r\n" +
          "\r\n");
     
   
    QAUtil.sleep(500);

    Assert.assertEquals(0, h1.countOnRequestCalled());
    Assert.assertEquals(0, h2.countOnRequestCalled());

    con.write("1234");

    String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
    int contentLength = QAUtil.readContentLength(header);
     
    con.readByteBufferByLength(contentLength);
   

   
    QAUtil.sleep(200);
   
    Assert.assertEquals(1, h1.countOnRequestCalled());
    Assert.assertTrue(h1.getOnRequestThreadname().startsWith("xServerPool"));
    Assert.assertEquals(1, h2.countOnRequestCalled());
    Assert.assertTrue(h2.getOnRequestThreadname().startsWith("xServerPool"));
   
    con.close();
    server.close();
  }
View Full Code Here

Examples of org.xsocket.connection.IBlockingConnection

   
    IServer server = new HttpServer(root);
    ConnectionUtils.start(server);
   
   
    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());

    con.write("GET / HTTP/1.1\r\n" +
          "Host: localhost\r\n" +
          "User-Agent: me\r\n" +
          "\r\n");
     
    String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
    int contentLength = QAUtil.readContentLength(header);
     
    con.readByteBufferByLength(contentLength);

   
    QAUtil.sleep(400);
   
    if (h1.countOnRequestCalled() != 1) {
      String msg = "RequestFilter should haven been called once not " + h1.countOnRequestCalled();
      System.out.println(msg);
      Assert.fail(msg)
    }
   
   
    if (h2.countOnRequestCalled() != 1) {
      String msg = "RequestHandler should haven been called once not " + h2.countOnRequestCalled();
      System.out.println(msg);
      Assert.fail(msg)
    }

   
    if (!h2.getOnRequestThreadname().startsWith("xServerPool")) {
      String msg = "RequestHandler should be executed by xServerPool not by " + h2.getOnRequestThreadname();
      System.out.println(msg);
      Assert.fail(msg);
    }
   
    con.close();
    server.close();
  }
View Full Code Here

Examples of org.xsocket.connection.IBlockingConnection

   
    IServer server = new HttpServer(root);
    ConnectionUtils.start(server);
   
   
    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());

    con.write("GET / HTTP/1.1\r\n" +
          "Host: localhost\r\n" +
          "User-Agent: me\r\n" +
          "\r\n");
     
    String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
    int contentLength = QAUtil.readContentLength(header);
     
    con.readByteBufferByLength(contentLength);

   
    QAUtil.sleep(400);
   
    if (h1.countOnRequestCalled() != 1) {
      String msg = "RequestFilter should haven been called once not " + h1.countOnRequestCalled();
      System.out.println(msg);
      Assert.fail(msg)
    }
   
   
    if (h2.countOnRequestCalled() != 1) {
      String msg = "RequestHandler should haven been called once not " + h2.countOnRequestCalled();
      System.out.println(msg);
      Assert.fail(msg)
    }

   
    if (!h2.getOnRequestThreadname().startsWith("xServerPool")) {
      String msg = "RequestHandler should be executed by xServerPool not by " + h2.getOnRequestThreadname();
      System.out.println(msg);
      Assert.fail(msg);
    }
   
    con.close();
    server.close();
  }
View Full Code Here

Examples of org.xsocket.connection.IBlockingConnection

   
    HttpServer server = new HttpServer(root);
    server.setRequestTimeoutMillis(1000);
    ConnectionUtils.start(server);
   
    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());

     
   
    QAUtil.sleep(1500);
   
    Assert.assertEquals(1, h1.getCountOnRequestTimeoutCalled());
    Assert.assertTrue(h1.onRequestTimeoutThreadname.startsWith("xServerPool"));
    Assert.assertEquals(1, h2.getCountOnRequestTimeoutCalled());
    Assert.assertTrue(h2.onRequestTimeoutThreadname.startsWith("xServerPool"));
   
   
    con.close();
    server.close();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.