Package com.linkedin.databus2.test

Examples of com.linkedin.databus2.test.ConditionCheck


        log.info("======> step " + i + ": complete.");
        if (0 != testId)
        {
          //if it was an iteration with an error, sleep a bit until we make sure the client
          //channel has been disconnected
          TestUtil.assertWithBackoff(new ConditionCheck()
          {
            @Override
            public boolean check()
            {
              return !conn._channel.isConnected();
View Full Code Here


      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);
View Full Code Here

    //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;
View Full Code Here

    //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);
View Full Code Here

    return buf;
  }

  static void waitForServerConnection(final NettyHttpDatabusRelayConnection conn, final Logger log)
  {
    TestUtil.assertWithBackoff(new ConditionCheck()
    {
      @Override
      public boolean check()
      {
        return null != conn._channel && conn._channel.isConnected();
View Full Code Here

  static void waitForCallback(final TestingConnectionCallback callback,
                       final TestResponseProcessors.TestConnectionStateMessage.State state,
                       final Logger log)
  {
    TestUtil.assertWithBackoff(new ConditionCheck()
    {
      @Override
      public boolean check()
      {
        TestResponseProcessors.TestConnectionStateMessage lastMsg = callback.getLastMsg();
View Full Code Here

        //It seems that there is a race condition between the writeFuture succeeding
        //and the writeComplete message getting to the handler. Make sure that the
        //writeComplete has got to the handler before we do anything else with
        //the channel.
        final GenericHttpResponseHandler handler = getResponseHandler(channel);
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return handler._messageState.hasSentRequest();
          }
        }, "request sent", 1000, log);

      HttpResponse resp = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
      resp.setContent(null);
      resp.setHeader(HttpHeaders.Names.CONTENT_LENGTH, 0);
      sendServerResponse(clientAddr, resp, 1000);
      final List<String> callbacks = respProcessor.getCallbacks();
      TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return 2 == callbacks.size();
View Full Code Here

        //It seems that there is a race condition between the writeFuture succeeding
        //and the writeComplete message getting to the handler. Make sure that the
        //writeComplete has got to the handler before we do anything else with
        //the channel.
        final GenericHttpResponseHandler handler = getResponseHandler(channel);
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return handler._messageState.hasSentRequest();
          }
        }, "request sent", 1000, log);

        HttpResponse resp = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        resp.setContent(null);
        resp.setHeader(HttpHeaders.Names.CONTENT_LENGTH, 0);
        sendServerResponse(clientAddr, resp, 1000);
        TestUtil.sleep(200);
        sendServerClose(clientAddr, -1);
        final List<String> callbacks = respProcessor.getCallbacks();
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return 2 == callbacks.size();
View Full Code Here

        //It seems that there is a race condition between the writeFuture succeeding
        //and the writeComplete message getting to the handler. Make sure that the
        //writeComplete has got to the handler before we do anything else with
        //the channel.
        final GenericHttpResponseHandler handler = getResponseHandler(channel);
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return handler._messageState.hasSentRequest();
          }
        }, "request sent", 1000, log);

        Channels.fireExceptionCaught(channel, new ReadTimeoutException());
        channel.close();

        final List<String> callbacks = respProcessor.getCallbacks();
        final List<String> closeCallbacks = closeListener.getCallbacks();

        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            log.debug("# callbacks:" + callbacks + ";expecting 1");
View Full Code Here

        //It seems that there is a race condition between the writeFuture succeeding
        //and the writeComplete message getting to the handler. Make sure that the
        //writeComplete has got to the handler before we do anything else with
        //the channel.
        final GenericHttpResponseHandler handler = getResponseHandler(channel);
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return handler._messageState.hasSentRequest();
          }
        }, "request sent", 1000, log);

        HttpResponse resp = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        resp.setHeader(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
        sendServerResponse(clientAddr, resp, 1000);

        HttpChunk chunk1 = new DefaultHttpChunk(ChannelBuffers.wrappedBuffer("chunk1".getBytes(Charset.defaultCharset())));
        sendServerResponse(clientAddr, chunk1, 1000);

        HttpChunk chunk2 = new DefaultHttpChunk(ChannelBuffers.wrappedBuffer("chunk2".getBytes(Charset.defaultCharset())));
        sendServerResponse(clientAddr, chunk2, 1000);

        sendServerResponse(clientAddr, new DefaultHttpChunkTrailer(), 1000);

        final List<String> callbacks = respProcessor.getCallbacks();
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return callbacks.size() == 5;
View Full Code Here

TOP

Related Classes of com.linkedin.databus2.test.ConditionCheck

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.