Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.Channel


    ChannelFuture connectFuture = _clientBootstrap.connect(_serverAddress);
    connectFuture.awaitUninterruptibly(1, TimeUnit.SECONDS);
    assertTrue("connect succeeded", connectFuture.isSuccess());

    HttpRequest request = new DefaultHttpRequest(HTTP_1_1, HttpMethod.GET, "/test");
    Channel requestChannel = connectFuture.getChannel();
    ChannelFuture writeFuture = requestChannel.write(request);

    writeFuture.awaitUninterruptibly(1, TimeUnit.SECONDS);
    assertTrue("connect succeeded", writeFuture.isSuccess());

    HttpResponse response = _responseHandler.getResponse();
View Full Code Here


  }

  @Override
  public void channelClosed(ChannelHandlerContext ctx,
                                         ChannelStateEvent e) throws Exception {
    Channel channel = e.getChannel();
    SocketAddress a = (null != channel) ? channel.getRemoteAddress() : null;
    _log.info("channel to peer closed: " + a);

    synchronized (this){
      _channelState = ChannelState.CHANNEL_CLOSED;
View Full Code Here

    {
      connectFuture.awaitUninterruptibly();
    }
    assertTrue("connect succeeded", connectFuture.isSuccess());

    Channel requestChannel = connectFuture.getChannel();
    ChannelFuture writeFuture = requestChannel.write(request);

    if (_timeoutPolicy == TimeoutPolicy.SEND_TIMEOUT ||
        _timeoutPolicy == TimeoutPolicy.ALL_TIMEOUTS)
    {
      writeFuture.awaitUninterruptibly(1000, TimeUnit.SECONDS);
View Full Code Here

      TestResponseProcessors.TestConnectionStateMessage msg = new TestResponseProcessors.TestConnectionStateMessage();
      conn.requestSources(msg);
      waitForServerConnection(conn, log);

      // introspect connection to server
      Channel channel = conn._channel;
      final SocketAddress clientAddr = channel.getLocalAddress();
      TestUtil.assertWithBackoff(new ConditionCheck()
      {
        @Override
        public boolean check()
        {
          return null != _dummyServer.getChildChannel(clientAddr);
        }
      }, "client connection established", 1000, log);

      Channel serverChannel = _dummyServer.getChildChannel(clientAddr);
      ChannelPipeline serverPipeline = serverChannel.getPipeline();
      SimpleObjectCaptureHandler objCapture = (SimpleObjectCaptureHandler)serverPipeline.get("3");

      // verify server gets the /sources request
      HttpResponse sourcesResp = runHappyPathSources(log,
                                                     callback,
View Full Code Here

    conn.requestSources(msg);

    waitForServerConnection(conn, log);

    //introspect connection to server
    Channel channel = conn._channel;
    SocketAddress clientAddr = channel.getLocalAddress();

    Channel serverChannel = _dummyServer.getChildChannel(clientAddr);
    ChannelPipeline serverPipeline = serverChannel.getPipeline();
    SimpleObjectCaptureHandler objCapture = (SimpleObjectCaptureHandler)serverPipeline.get("3");

    Assert.assertTrue(objCapture.waitForMessage(1000, 0));
    Object msgObj = objCapture.getMessages().get(0);
    Assert.assertTrue(msgObj instanceof HttpRequest);
View Full Code Here

    conn.requestSources(msg);

    waitForServerConnection(conn, log);

    //introspect connection to server
    Channel channel = conn._channel;
    SocketAddress clientAddr = channel.getLocalAddress();

    Channel serverChannel = _dummyServer.getChildChannel(clientAddr);
    ChannelPipeline serverPipeline = serverChannel.getPipeline();
    SimpleObjectCaptureHandler objCapture = (SimpleObjectCaptureHandler)serverPipeline.get("3");

    //verify server gets the /source request
    runHappyPathSources(log,
                            callback,
View Full Code Here

    conn.requestSources(msg);

    waitForServerConnection(conn, log);

    //introspect connection to server
    Channel channel = conn._channel;
    SocketAddress clientAddr = channel.getLocalAddress();

    Channel serverChannel = _dummyServer.getChildChannel(clientAddr);
    ChannelPipeline serverPipeline = serverChannel.getPipeline();
    SimpleObjectCaptureHandler objCapture = (SimpleObjectCaptureHandler)serverPipeline.get("3");

    //verify server gets the /source request
    HttpResponse sourcesResp =
        runHappyPathSources(log,
View Full Code Here

    conn.requestSources(msg);

    waitForServerConnection(conn, log);

    //introspect connection to server
    Channel channel = conn._channel;
    SocketAddress clientAddr = channel.getLocalAddress();

    Channel serverChannel = _dummyServer.getChildChannel(clientAddr);
    ChannelPipeline serverPipeline = serverChannel.getPipeline();
    SimpleObjectCaptureHandler objCapture = (SimpleObjectCaptureHandler)serverPipeline.get("3");

    //verify server gets the /source request
    HttpResponse sourcesResp =
        runHappyPathSources(log,
View Full Code Here

    conn.requestSources(msg);

    waitForServerConnection(conn, log);

    //introspect connection to server
    Channel channel = conn._channel;
    SocketAddress clientAddr = channel.getLocalAddress();

    Channel serverChannel = _dummyServer.getChildChannel(clientAddr);
    ChannelPipeline serverPipeline = serverChannel.getPipeline();
    SimpleObjectCaptureHandler objCapture = (SimpleObjectCaptureHandler)serverPipeline.get("3");

    Assert.assertTrue(objCapture.waitForMessage(1000, 0));
    Object msgObj = objCapture.getMessages().get(0);
    Assert.assertTrue(msgObj instanceof HttpRequest);

    HttpRequest msgReq = (HttpRequest)msgObj;
    Assert.assertTrue(msgReq.getUri().startsWith("/sources"))// now has "?protocolVersion=X" appended

    serverChannel.close();

    waitForCallback(callback,
                    TestResponseProcessors.TestConnectionStateMessage.State.SOURCES_RESPONSE_ERROR,
                    log);
    Assert.assertNull(remoteExceptionHandler.getLastException());
View Full Code Here

    conn.requestSources(msg);

    waitForServerConnection(conn, log);

    //introspect connection to server
    Channel channel = conn._channel;
    SocketAddress clientAddr = channel.getLocalAddress();
    final SocketAddress finalClientAddr = clientAddr;

    TestUtil.assertWithBackoff(new ConditionCheck()
    {
      @Override
      public boolean check()
      {
        return _dummyServer.getChildChannel(finalClientAddr) != null;
      }
    }, "client connected", 100, log);

    Channel serverChannel = _dummyServer.getChildChannel(clientAddr);
    ChannelPipeline serverPipeline = serverChannel.getPipeline();
    SimpleObjectCaptureHandler objCapture = (SimpleObjectCaptureHandler)serverPipeline.get("3");

    //verify server gets the /source request
    runHappyPathSources(log,
                            callback,
                            remoteExceptionHandler,
                            clientAddr,
                            objCapture);


    callback.clearLastMsg();
    objCapture.clear();
    conn.requestRegister("1", msg);

    //verify server gets the /register request
    HttpRequest msgReq = captureRequest(objCapture);
    Assert.assertTrue(msgReq.getUri().startsWith("/register"));

    serverChannel.close();

    waitForCallback(callback,
                    TestResponseProcessors.TestConnectionStateMessage.State.REGISTER_RESPONSE_ERROR,
                    log);
    Assert.assertNull(remoteExceptionHandler.getLastException());
View Full Code Here

TOP

Related Classes of org.jboss.netty.channel.Channel

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.