[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/callback/acknowledge ...

Ron Sigal ron_sigal at yahoo.com
Wed Aug 22 23:13:40 EDT 2007


  User: rsigal  
  Date: 07/08/22 23:13:40

  Modified:    src/tests/org/jboss/test/remoting/callback/acknowledge  Tag:
                        remoting_2_2_0_GA CallbackAcknowledgeTestCase.java
  Log:
  JBREM-641:  Merged changes from branch 2_2_2_experimental: synchronized with remoting_2_x branch, adding additional test methods for blocking mode for pull callbacks.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.4.4.1 +345 -9    JBossRemoting/src/tests/org/jboss/test/remoting/callback/acknowledge/CallbackAcknowledgeTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CallbackAcknowledgeTestCase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/callback/acknowledge/CallbackAcknowledgeTestCase.java,v
  retrieving revision 1.2.2.4
  retrieving revision 1.2.2.4.4.1
  diff -u -b -r1.2.2.4 -r1.2.2.4.4.1
  --- CallbackAcknowledgeTestCase.java	21 Nov 2006 07:01:37 -0000	1.2.2.4
  +++ CallbackAcknowledgeTestCase.java	23 Aug 2007 03:13:40 -0000	1.2.2.4.4.1
  @@ -105,7 +105,7 @@
       * after the callbacks have been retrieved and (presumably) processed. Two
       * InvokerCallbackHandlers are registered.
       */
  -   public void testPullApplicationAckDifferentHandlers()
  +   public void testNonblockingPullApplicationAckDifferentHandlers()
      {
         log.info("entering " + getName());
         try
  @@ -145,10 +145,55 @@
      /**
       * In this test, the connection is configured for pull callbacks, and the
       * acknowledgements should be made by an explicit call to Client.acknowledgeCallback()
  +    * after the callbacks have been retrieved and (presumably) processed. Two
  +    * InvokerCallbackHandlers are registered.
  +    */
  +   public void testBlockingPullApplicationAckDifferentHandlers()
  +   {
  +      log.info("entering " + getName());
  +      try
  +      {
  +         TestCallbackHandler callbackHandler1 = new TestCallbackHandler();
  +         client.addListener(callbackHandler1);
  +         TestCallbackHandler callbackHandler2 = new TestCallbackHandler();
  +         client.addListener(callbackHandler2);
  +         assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  +         client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST);
  +         HashMap metadata = new HashMap();
  +         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING);
  +         List callbacks1 = client.getCallbacks(callbackHandler1, metadata);
  +         assertEquals(2, callbacks1.size());
  +         List callbacks2 = client.getCallbacks(callbackHandler2, metadata);
  +         assertEquals(2, callbacks2.size());
  +         assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  +         assertEquals(2, client.acknowledgeCallbacks(callbackHandler1, callbacks1));
  +         assertEquals(2, TestInvocationHandler.callbacksAcknowledged);
  +         assertEquals(2, client.acknowledgeCallbacks(callbackHandler2, callbacks2));
  +         assertEquals(4, TestInvocationHandler.callbacksAcknowledged);
  +         assertTrue(TestInvocationHandler.callbackResponses.isEmpty());
  +         Thread.sleep(1000);
  +         assertEquals(0, callbackHandler1.callbacksReceived);
  +         assertEquals(0, callbackHandler2.callbacksReceived);
  +         client.removeListener(callbackHandler1);
  +         client.removeListener(callbackHandler2);
  +         log.info(getName() + " PASSES");
  +      }
  +      catch (Throwable e)
  +      {
  +         log.info(getName() + " FAILS");
  +         e.printStackTrace();
  +         fail();
  +      }
  +   }
  +
  +   
  +   /**
  +    * In this test, the connection is configured for pull callbacks, and the
  +    * acknowledgements should be made by an explicit call to Client.acknowledgeCallback()
       * after the callbacks have been retrieved and (presumably) processed. A single
       * InvokerCallbackHandler is registered twice but treated as a single instance.
       */
  -   public void testPullApplicationAckSameHandler()
  +   public void testNonblockingPullApplicationAckSameHandler()
      {
         log.info("entering " + getName());
         try
  @@ -179,6 +224,44 @@
   
   
      /**
  +    * In this test, the connection is configured for pull callbacks, and the
  +    * acknowledgements should be made by an explicit call to Client.acknowledgeCallback()
  +    * after the callbacks have been retrieved and (presumably) processed. A single
  +    * InvokerCallbackHandler is registered twice but treated as a single instance.
  +    */
  +   public void testBlockingPullApplicationAckSameHandler()
  +   {
  +      log.info("entering " + getName());
  +      try
  +      {
  +         TestCallbackHandler callbackHandler = new TestCallbackHandler();
  +         client.addListener(callbackHandler);
  +         client.addListener(callbackHandler);
  +         assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  +         client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST);
  +         HashMap metadata = new HashMap();
  +         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING);
  +         List callbacks = client.getCallbacks(callbackHandler, metadata);
  +         assertEquals(2, callbacks.size());
  +         assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  +         assertEquals(2, client.acknowledgeCallbacks(callbackHandler, callbacks));
  +         assertEquals(2, TestInvocationHandler.callbacksAcknowledged);
  +         assertTrue(TestInvocationHandler.callbackResponses.isEmpty());
  +         Thread.sleep(1000);
  +         assertEquals(0, callbackHandler.callbacksReceived);
  +         client.removeListener(callbackHandler);
  +         log.info(getName() + " PASSES");
  +      }
  +      catch (Throwable e)
  +      {
  +         log.info(getName() + " FAILS");
  +         e.printStackTrace();
  +         fail();
  +      }
  +   }
  +      
  +
  +   /**
       * In this test, the connection is configured for pull callbacks.  The
       * server requests that Remoting handle push callback acknowledgements,
       * but that should have no effect.  Instead, callback acknowledgements
  @@ -186,7 +269,7 @@
       * the callback has been retrieved and (presumably) processed.
       * Two distinct InvokerCallbackHandlers are used.
       */
  -   public void testPullRemotingAckDifferentHandlers()
  +   public void testNonblockingPullRemotingAckDifferentHandlers()
      {
         log.info("entering " + getName());
         try
  @@ -223,6 +306,52 @@
   
   
      /**
  +    * In this test, the connection is configured for pull callbacks.  The
  +    * server requests that Remoting handle push callback acknowledgements,
  +    * but that should have no effect.  Instead, callback acknowledgements
  +    * should be made by an explicit call to Client.acknowledgeCallback() after
  +    * the callback has been retrieved and (presumably) processed.
  +    * Two distinct InvokerCallbackHandlers are used.
  +    */
  +   public void testPullRemotingAckDifferentHandlers()
  +   {
  +      log.info("entering " + getName());
  +      try
  +      {
  +         TestCallbackHandler callbackHandler1 = new TestCallbackHandler();
  +         client.addListener(callbackHandler1);
  +         TestCallbackHandler callbackHandler2 = new TestCallbackHandler();
  +         client.addListener(callbackHandler2);
  +         assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  +         client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST);
  +         HashMap metadata = new HashMap();
  +         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING);
  +         List callbacks1 = client.getCallbacks(callbackHandler1, metadata);
  +         assertEquals(2, callbacks1.size());
  +         List callbacks2 = client.getCallbacks(callbackHandler2, metadata);
  +         assertEquals(2, callbacks2.size());
  +         assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  +         assertEquals(2, client.acknowledgeCallbacks(callbackHandler1, callbacks1));
  +         assertEquals(2, TestInvocationHandler.callbacksAcknowledged);
  +         assertEquals(2, client.acknowledgeCallbacks(callbackHandler2, callbacks2));
  +         assertEquals(4, TestInvocationHandler.callbacksAcknowledged);
  +         assertTrue(TestInvocationHandler.callbackResponses.isEmpty());
  +         Thread.sleep(1000);
  +         assertEquals(0, callbackHandler1.callbacksReceived);
  +         client.removeListener(callbackHandler1);
  +         client.removeListener(callbackHandler2);
  +         log.info(getName() + " PASSES");
  +      }
  +      catch (Throwable e)
  +      {
  +         log.info(getName() + " FAILS");
  +         e.printStackTrace();
  +         fail();
  +      }
  +   }
  +   
  +   
  +   /**
       * In this test, the connection is configured pull callbacks.  The
       * server requests that Remoting handle push callback acknowledgements,
       * but that should have no effect. Instead, acknowledgements should be made
  @@ -230,7 +359,7 @@
       * has been retrieved and (presumably) processed. A single InvokerCallbackHandler
       * is registered twice but treated as a single instance.
       */
  -   public void testPullRemotingAckSameHandler()
  +   public void testNonblockingPullRemotingAckSameHandler()
      {
         log.info("entering " + getName());
         try
  @@ -261,13 +390,53 @@
   
   
      /**
  +    * In this test, the connection is configured pull callbacks.  The
  +    * server requests that Remoting handle push callback acknowledgements,
  +    * but that should have no effect. Instead, acknowledgements should be made
  +    * by an explicit call to Client.acknowledgeCallback() after the callback
  +    * has been retrieved and (presumably) processed. A single InvokerCallbackHandler
  +    * is registered twice but treated as a single instance.
  +    */
  +   public void testBlockingPullRemotingAckSameHandler()
  +   {
  +      log.info("entering " + getName());
  +      try
  +      {
  +         TestCallbackHandler callbackHandler = new TestCallbackHandler();
  +         client.addListener(callbackHandler);
  +         client.addListener(callbackHandler);
  +         assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  +         client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST);
  +         HashMap metadata = new HashMap();
  +         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING);
  +         List callbacks = client.getCallbacks(callbackHandler, metadata);
  +         assertEquals(2, callbacks.size());
  +         assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  +         assertEquals(2, client.acknowledgeCallbacks(callbackHandler, callbacks));
  +         assertEquals(2, TestInvocationHandler.callbacksAcknowledged);
  +         assertTrue(TestInvocationHandler.callbackResponses.isEmpty());
  +         Thread.sleep(1000);
  +         assertEquals(0, callbackHandler.callbacksReceived);
  +         client.removeListener(callbackHandler);
  +         log.info(getName() + " PASSES");
  +      }
  +      catch (Throwable e)
  +      {
  +         log.info(getName() + " FAILS");
  +         e.printStackTrace();
  +         fail();
  +      }
  +   }
  +
  +
  +   /**
       * In this test the connection is configured for push callbacks implemented in
       * Remoting by polling the server for callbacks and pushing them (on the client
       * side) to the InvokerCallbackHandler.  The acknowledgements should be made
       * explicitly by the InvokerCallbackHandler.  Two distinct InvokerCallbackHandlers
       * are registered.
       */
  -   public void testPollApplicationAckDifferentHandlers()
  +   public void testNonblockingPollApplicationAckDifferentHandlers()
      {
         log.info("entering " + getName());
         try
  @@ -275,6 +444,53 @@
            TestCallbackHandler callbackHandler1 = new TestCallbackHandler(client, 1);
            HashMap metadata = new HashMap();
            metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "100");
  +         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING);
  +         client.addListener(callbackHandler1, metadata);
  +         TestCallbackHandler callbackHandler2 = new TestCallbackHandler(client, 2);
  +         client.addListener(callbackHandler2, metadata);
  +         assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  +         client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST);
  +         Thread.sleep(1000);
  +         assertEquals(2, callbackHandler1.callbacksReceived);
  +         assertEquals(2, callbackHandler2.callbacksReceived);
  +         assertEquals(4, TestInvocationHandler.callbacksAcknowledged);
  +         //key: message #: handler id: callbacks received
  +         String response111 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 1: 1";
  +         assertTrue(TestInvocationHandler.callbackResponses.contains(response111));
  +         String response212 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 1: 2";
  +         assertTrue(TestInvocationHandler.callbackResponses.contains(response212));
  +         String response121 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 2: 1";
  +         assertTrue(TestInvocationHandler.callbackResponses.contains(response121));
  +         String response222 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 2: 2";
  +         assertTrue(TestInvocationHandler.callbackResponses.contains(response222));
  +         client.removeListener(callbackHandler1);
  +         client.removeListener(callbackHandler2);
  +         log.info(getName() + " PASSES");
  +      }
  +      catch (Throwable e)
  +      {
  +         log.info(getName() + " FAILS");
  +         e.printStackTrace();
  +         fail();
  +      }
  +   }
  +
  +
  +   /**
  +    * In this test the connection is configured for push callbacks implemented in
  +    * Remoting by polling the server for callbacks and pushing them (on the client
  +    * side) to the InvokerCallbackHandler.  The acknowledgements should be made
  +    * explicitly by the InvokerCallbackHandler.  Two distinct InvokerCallbackHandlers
  +    * are registered.
  +    */
  +   public void testBlockingPollApplicationAckDifferentHandlers()
  +   {
  +      log.info("entering " + getName());
  +      try
  +      {
  +         TestCallbackHandler callbackHandler1 = new TestCallbackHandler(client, 1);
  +         HashMap metadata = new HashMap();
  +         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING);
            client.addListener(callbackHandler1, metadata);
            TestCallbackHandler callbackHandler2 = new TestCallbackHandler(client, 2);
            client.addListener(callbackHandler2, metadata);
  @@ -313,7 +529,7 @@
       * registered twice but the Client treats it as a single instance.  The
       * acknowledgements should be made explicitly by the InvokerCallbackHandler.
       */
  -   public void testPollApplicationAckSameHandler()
  +   public void testNonblockingPollApplicationAckSameHandler()
      {
         log.info("entering " + getName());
         try
  @@ -321,6 +537,47 @@
            TestCallbackHandler callbackHandler = new TestCallbackHandler(client);
            HashMap metadata = new HashMap();
            metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "100");
  +         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING);
  +         client.addListener(callbackHandler, metadata);
  +         client.addListener(callbackHandler, metadata);
  +         assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  +         client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST);
  +         Thread.sleep(1000);
  +         assertEquals(2, callbackHandler.callbacksReceived);
  +         assertEquals(2, TestInvocationHandler.callbacksAcknowledged);
  +         //key: message #: handler id: callbacks received
  +         String response101 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 0: 1";
  +         assertTrue(TestInvocationHandler.callbackResponses.contains(response101));
  +         String response202 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 0: 2";
  +         assertTrue(TestInvocationHandler.callbackResponses.contains(response202));
  +         client.removeListener(callbackHandler);
  +         Thread.sleep(4000);
  +         log.info(getName() + " PASSES");
  +      }
  +      catch (Throwable e)
  +      {
  +         log.info(getName() + " FAILS");
  +         e.printStackTrace();
  +         fail();
  +      }
  +   }
  +
  +
  +   /**
  +    * In this test the connection is configured for push callbacks implemented in
  +    * Remoting by polling the server for callbacks and pushing them (on the client
  +    * side) to the InvokerCallbackHandler.  A single InvokerCallbackHandler is
  +    * registered twice but the Client treats it as a single instance.  The
  +    * acknowledgements should be made explicitly by the InvokerCallbackHandler.
  +    */
  +   public void testBlockingPollApplicationAckSameHandler()
  +   {
  +      log.info("entering " + getName());
  +      try
  +      {
  +         TestCallbackHandler callbackHandler = new TestCallbackHandler(client);
  +         HashMap metadata = new HashMap();
  +         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING);
            client.addListener(callbackHandler, metadata);
            client.addListener(callbackHandler, metadata);
            assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  @@ -334,6 +591,7 @@
            String response202 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 0: 2";
            assertTrue(TestInvocationHandler.callbackResponses.contains(response202));
            client.removeListener(callbackHandler);
  +         Thread.sleep(4000);
            log.info(getName() + " PASSES");
         }
         catch (Throwable e)
  @@ -353,7 +611,7 @@
       * after it has pushed the callback to the InvokerCallbackHandler.  Two
       * distinct InvokerCallbackHandlers are registered.
       */
  -   public void testPollRemotingAckDifferentHandlers()
  +   public void testNonblockingPollRemotingAckDifferentHandlers()
      {
         log.info("entering " + getName());
         try
  @@ -361,6 +619,46 @@
            TestCallbackHandler callbackHandler1 = new TestCallbackHandler();
            HashMap metadata = new HashMap();
            metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "100");
  +         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING);
  +         client.addListener(callbackHandler1, metadata);
  +         TestCallbackHandler callbackHandler2 = new TestCallbackHandler();
  +         client.addListener(callbackHandler2, metadata);
  +         assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  +         client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST);
  +         Thread.sleep(1000);
  +         assertEquals(2, callbackHandler1.callbacksReceived);
  +         assertEquals(2, callbackHandler2.callbacksReceived);
  +         assertEquals(4, TestInvocationHandler.callbacksAcknowledged);
  +         assertTrue(TestInvocationHandler.callbackResponses.isEmpty());
  +         client.removeListener(callbackHandler1);
  +         client.removeListener(callbackHandler2);
  +         log.info(getName() + " PASSES");
  +      }
  +      catch (Throwable e)
  +      {
  +         log.info(getName() + " FAILS");
  +         e.printStackTrace();
  +         fail();
  +      }
  +   }
  +
  +   
  +   /**
  +    * In this test the connection is configured for push callbacks implemented in
  +    * Remoting by polling the server for callbacks and pushing them (on the client
  +    * side) to the InvokerCallbackHandler.  The acknowledgement should be made
  +    * implicitly by CallbackPoller, which it does by calling Client.acknowledgeCallback()
  +    * after it has pushed the callback to the InvokerCallbackHandler.  Two
  +    * distinct InvokerCallbackHandlers are registered.
  +    */
  +   public void testBlockingPollRemotingAckDifferentHandlers()
  +   {
  +      log.info("entering " + getName());
  +      try
  +      {
  +         TestCallbackHandler callbackHandler1 = new TestCallbackHandler();
  +         HashMap metadata = new HashMap();
  +         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING);
            client.addListener(callbackHandler1, metadata);
            TestCallbackHandler callbackHandler2 = new TestCallbackHandler();
            client.addListener(callbackHandler2, metadata);
  @@ -393,7 +691,7 @@
       * InvokerCallbackHandler is registered twice, but the Client recognizes only a
       * single instance.
       */
  -   public void testPollRemotingAckSameHandler()
  +   public void testNonblockingPollRemotingAckSameHandler()
      {
         log.info("entering " + getName());
         try
  @@ -401,6 +699,44 @@
            TestCallbackHandler callbackHandler = new TestCallbackHandler();
            HashMap metadata = new HashMap();
            metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "100");
  +         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING);
  +         client.addListener(callbackHandler, metadata);
  +         client.addListener(callbackHandler, metadata);
  +         assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  +         client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST);
  +         Thread.sleep(1000);
  +         assertEquals(2, callbackHandler.callbacksReceived);
  +         assertEquals(2, TestInvocationHandler.callbacksAcknowledged);
  +         assertTrue(TestInvocationHandler.callbackResponses.isEmpty());
  +         client.removeListener(callbackHandler);
  +         log.info(getName() + " PASSES");
  +      }
  +      catch (Throwable e)
  +      {
  +         log.info(getName() + " FAILS");
  +         e.printStackTrace();
  +         fail();
  +      }
  +   }
  +
  +   
  +   /**
  +    * In this test the connection is configured for push callbacks implemented in
  +    * Remoting by polling the server for callbacks and pushing them (on the client
  +    * side) to the InvokerCallbackHandler.  The acknowledgement should be made
  +    * implicitly by CallbackPoller, which it does by calling Client.acknowledgeCallback()
  +    * after it has pushed the callback to the InvokerCallbackHandler.  A single
  +    * InvokerCallbackHandler is registered twice, but the Client recognizes only a
  +    * single instance.
  +    */
  +   public void testBlockingPollRemotingAckSameHandler()
  +   {
  +      log.info("entering " + getName());
  +      try
  +      {
  +         TestCallbackHandler callbackHandler = new TestCallbackHandler();
  +         HashMap metadata = new HashMap();
  +         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING);
            client.addListener(callbackHandler, metadata);
            client.addListener(callbackHandler, metadata);
            assertEquals(0, TestInvocationHandler.callbacksAcknowledged);
  
  
  



More information about the jboss-cvs-commits mailing list