Package org.xsocket.connection

Examples of org.xsocket.connection.BlockingConnection


    IServer server = new HttpServer(hdl);
    ConnectionUtils.start(server);
 
 

    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
     
    con.write("POST /test HTTP/1.1\r\n" +
          "Host: localhost\r\n" +
          "User-Agent: test\r\n" +
          "Transfer-Encoding: Chunked\r\n" +
          "\r\n" +
          "5\r\n" +
          "123");
   
    QAUtil.sleep(200);
    con.close();
   
    QAUtil.sleep(1000);
   
    Assert.assertNotNull(hdl.getException());
    Assert.assertFalse(hdl.isClosed());
View Full Code Here


    IServer server = new HttpServer(hdl);
    ConnectionUtils.start(server);
 
 

    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
     
    con.write("POST /test HTTP/1.1\r\n" +
          "Host: localhost\r\n" +
          "User-Agent: test\r\n" +
          "Content-Length: 10\r\n" +
          "\r\n" +
          "1234567");
   
    QAUtil.sleep(100);
    con.close();
   
    QAUtil.sleep(1000);
   
    Assert.assertFalse(hdl.isClosed());
    Assert.assertFalse(hdl.isCompleteListenerCalled());
View Full Code Here

    IServer server = new HttpServer(hdl);
    server.start();
 
 

    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
     
    con.write("GET /test HTTP/1.1\r\n" +
          "Host: localhost\r\n" +
          "User-Agent: test\r\n" +
          "\r\n");

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

    Assert.assertTrue(header.indexOf("200") != -1);
   
    Assert.assertTrue(hdl.getDataWriter().isComplete());
View Full Code Here

    IServer server = new HttpServer(hdl);
    ConnectionUtils.start(server);
 
 

    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
     
    con.write("GET /test HTTP/1.1\r\n" +
          "Host: localhost\r\n" +
          "User-Agent: test\r\n" +
          "\r\n");


    QAUtil.sleep(200);
    server.close();
   
    QAUtil.sleep(1000);
   
    Assert.assertFalse(hdl.getDataWriter().isComplete());
    Assert.assertTrue(hdl.getDataWriter().getException() != null);

    con.close();
   
  }
View Full Code Here

   
    IServer server = new HttpServer(root);
    server.start();
   
   
    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("xWorker")) {
      String msg = "RequestHandler should be executed by xWorker not by " + h2.getOnRequestThreadname();
      System.out.println(msg);
      Assert.fail(msg);
    }
   
    con.close();
    server.close();
  }
View Full Code Here

    root.addLast(h2);
   
    IServer server = new HttpServer(root);
    server.start();
   
    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(200);
   
    Assert.assertEquals(1, h1.countOnRequestCalled());
    Assert.assertFalse(h1.onRequestThreadname.startsWith("xWorker"));
    Assert.assertEquals(1, h2.countOnRequestCalled());
    Assert.assertFalse(h2.onRequestThreadname.startsWith("xWorker"));
   
    con.close();
    server.close();
  }
View Full Code Here

    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("xWorker"));
    Assert.assertEquals(1, h2.countOnRequestCalled());
    Assert.assertTrue(h2.getOnRequestThreadname().startsWith("xWorker"));
   
    con.close();
    server.close();
  }
View Full Code Here

   
    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("xWorker")) {
      String msg = "RequestHandler should be executed by xWorker not by " + h2.getOnRequestThreadname();
      System.out.println(msg);
      Assert.fail(msg);
    }
   
    con.close();
    server.close();
  }
View Full Code Here

   
    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("xWorker")) {
      String msg = "RequestHandler should be executed by xWorker not by " + h2.getOnRequestThreadname();
      System.out.println(msg);
      Assert.fail(msg);
    }
   
    con.close();
    server.close();
  }
View Full Code Here

   
    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("xWorker"));
    Assert.assertEquals(1, h2.getCountOnRequestTimeoutCalled());
    Assert.assertTrue(h2.onRequestTimeoutThreadname.startsWith("xWorker"));
   
   
    con.close();
    server.close();
  }
View Full Code Here

TOP

Related Classes of org.xsocket.connection.BlockingConnection

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.