[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/transport/socket/timeout ...

Ron Sigal ron_sigal at yahoo.com
Thu Jan 25 00:39:54 EST 2007


  User: rsigal  
  Date: 07/01/25 00:39:54

  Modified:    src/tests/org/jboss/test/remoting/transport/socket/timeout 
                        Tag: remoting_2_x CallbackTimeoutTestCase.java
  Log:
  JBREM-690:  Added test method for asynchronous callbacks.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +63 -0     JBossRemoting/src/tests/org/jboss/test/remoting/transport/socket/timeout/Attic/CallbackTimeoutTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CallbackTimeoutTestCase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/transport/socket/timeout/Attic/CallbackTimeoutTestCase.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -b -r1.1.2.1 -r1.1.2.2
  --- CallbackTimeoutTestCase.java	25 Jan 2007 05:24:40 -0000	1.1.2.1
  +++ CallbackTimeoutTestCase.java	25 Jan 2007 05:39:54 -0000	1.1.2.2
  @@ -41,6 +41,7 @@
   import org.jboss.remoting.callback.Callback;
   import org.jboss.remoting.callback.HandleCallbackException;
   import org.jboss.remoting.callback.InvokerCallbackHandler;
  +import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
   import org.jboss.remoting.transport.Connector;
   import org.jboss.remoting.transport.PortUtil;
   
  @@ -48,7 +49,7 @@
    * Unit test written for JBREM-690: http://jira.jboss.com/jira/browse/JBREM-690.
    * 
    * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
  - * @version $Revision: 1.1.2.1 $
  + * @version $Revision: 1.1.2.2 $
    * <p>
    * Copyright Jan 10, 2007
    * </p>
  @@ -60,6 +61,7 @@
      
      protected static final String INVOKE = "invoke";
      protected static final String CALLBACK = "callback";
  +   protected static final String CALLBACK_ONEWAY = "callbackOneway";
      
      
      public void setUp() throws Exception
  @@ -121,6 +123,53 @@
      }
      
      
  +
  +   public void testOnewayCallbackTimeout() throws Throwable
  +   {
  +      log.info("entering " + getName());
  +      String host = InetAddress.getLocalHost().getHostAddress();
  +      int port = PortUtil.findFreePort(host);
  +      String locatorURI = getTransport() + "://" + host + ":" + port;
  +      InvokerLocator locator = new InvokerLocator(locatorURI);
  +      HashMap serverConfig = new HashMap();
  +      serverConfig.put(InvokerLocator.FORCE_REMOTE, "true");
  +      addExtraServerConfig(serverConfig);
  +      Connector connector = new Connector(locator, serverConfig);
  +      connector.create();
  +      connector.addInvocationHandler("test", new TestHandler());
  +      connector.start();
  +      
  +      HashMap clientConfig = new HashMap();
  +      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
  +      addExtraClientConfig(clientConfig);
  +      Client client = new Client(locator, clientConfig);
  +      client.connect();
  +      TestCallbackHandler callbackHandler = new TestCallbackHandler();
  +      client.addListener(callbackHandler, null, null, true);
  +      
  +      Object response = client.invoke(INVOKE);
  +      assertEquals(INVOKE, response);
  +      log.info("invocation succeeded");
  +
  +      client.invoke(CALLBACK_ONEWAY);
  +      Thread.sleep(1000);
  +      assertTrue(callbackHandler.receivedCallback);
  +      log.info("received first callback");
  +      
  +      Thread.sleep(ServerInvoker.DEFAULT_TIMEOUT_PERIOD + 5000);
  +
  +      callbackHandler.receivedCallback = false;
  +      client.invoke(CALLBACK_ONEWAY);
  +      Thread.sleep(1000);
  +      assertTrue(callbackHandler.receivedCallback);
  +      log.info("received second callback");
  +      
  +      client.disconnect();
  +      connector.stop();
  +      log.info(getName() + " PASSES");
  +   }
  +   
  +   
      protected String getTransport()
      {
         return "socket";
  @@ -164,6 +213,20 @@
                  throw e;
               }
            }
  +         else if (CALLBACK_ONEWAY.equals(command))
  +         {
  +            try
  +            {
  +               ServerInvokerCallbackHandler sich = (ServerInvokerCallbackHandler) callbackHandler;
  +               sich.handleCallbackOneway(new Callback("callback"), true);
  +               return null;
  +            }
  +            catch (HandleCallbackException e)
  +            {
  +               log.error("error handling callback");
  +               throw e;
  +            }
  +         }
            else
            {
               log.error("unrecognized command: " + command);
  
  
  



More information about the jboss-cvs-commits mailing list