[jboss-cvs] JBossAS SVN: r60808 - in trunk/testsuite/src/main/org/jboss/test/cluster: test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 22 15:42:50 EST 2007


Author: jerrygauth
Date: 2007-02-22 15:42:50 -0500 (Thu, 22 Feb 2007)
New Revision: 60808

Modified:
   trunk/testsuite/src/main/org/jboss/test/cluster/rpc/Person.java
   trunk/testsuite/src/main/org/jboss/test/cluster/rpc/RPCUser.java
   trunk/testsuite/src/main/org/jboss/test/cluster/rpc/RPCUserMBean.java
   trunk/testsuite/src/main/org/jboss/test/cluster/test/RPCTestCase.java
Log:
JBAS-4006, add deserialization test to cluster - completed

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/rpc/Person.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/rpc/Person.java	2007-02-22 20:23:34 UTC (rev 60807)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/rpc/Person.java	2007-02-22 20:42:50 UTC (rev 60808)
@@ -19,6 +19,7 @@
    private String state;
    private String postal;
    private String employer;
+   private boolean notified = false;
     
    private Person() {}
     
@@ -92,6 +93,16 @@
        return age;
     }
     
+    public void setNotified(boolean notified)
+    {
+       this.notified = notified;
+    }
+    
+    public boolean getNotified()
+    {
+       return notified;
+    }
+    
     public String toString()
     {
        StringBuffer sb = new StringBuffer();

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/rpc/RPCUser.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/rpc/RPCUser.java	2007-02-22 20:23:34 UTC (rev 60807)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/rpc/RPCUser.java	2007-02-22 20:42:50 UTC (rev 60808)
@@ -42,6 +42,7 @@
    private static final String SERVICE_NAME = "RPCTestCase";
    private static final String METHOD_GET_PERSON = "getPerson";
    private static final String METHOD_GET_PERSON_MATCH = "getPersonMatch";
+   private static final String METHOD_NOTIFY_PERSON = "notifyPerson";
 
    protected String partitionName;
    protected HAPartition partition = null;
@@ -103,6 +104,18 @@
       return partition.callMethodOnCluster(SERVICE_NAME, METHOD_GET_PERSON_MATCH, parms, types, false);
    }
    
+   public ArrayList runRetrieveFromCoordinator() throws Exception
+   {
+      return partition.callMethodOnCoordinatorNode(SERVICE_NAME, METHOD_GET_PERSON, null, null, false);
+   }
+   
+   public void runNotifyAllAsynch() throws Exception
+   {
+      Object[] parms = new Object[]{Boolean.TRUE};
+      Class[] types = new Class[]{Boolean.class};
+      partition.callAsynchMethodOnCluster(SERVICE_NAME, METHOD_NOTIFY_PERSON, parms, types, false);
+   }
+   
    public Person getPerson()
    {
       return myPerson;
@@ -115,5 +128,10 @@
       else
          return null;
    }
+   
+   public void notifyPerson(Boolean notify)
+   {
+      myPerson.setNotified(notify.booleanValue());
+   }
 
 }

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/rpc/RPCUserMBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/rpc/RPCUserMBean.java	2007-02-22 20:23:34 UTC (rev 60807)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/rpc/RPCUserMBean.java	2007-02-22 20:42:50 UTC (rev 60808)
@@ -14,6 +14,8 @@
     
     public ArrayList runRetrieveAll() throws Exception;
     public ArrayList runRetrieveQuery(PersonQuery query) throws Exception;
+    public ArrayList runRetrieveFromCoordinator() throws Exception;
+    public void runNotifyAllAsynch() throws Exception;
     public void setPartitionName(String name);
     public String getPartitionName();
     

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/test/RPCTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/test/RPCTestCase.java	2007-02-22 20:23:34 UTC (rev 60807)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/test/RPCTestCase.java	2007-02-22 20:42:50 UTC (rev 60808)
@@ -127,9 +127,31 @@
       RMIAdaptor[] adaptors = getAdaptors();
       RMIAdaptorExt server0 = (RMIAdaptorExt) adaptors[0];
       RMIAdaptorExt server1 = (RMIAdaptorExt) adaptors[1];
-      log.info("server0: " + server0 + "; server1: " + server1);
       ObjectName rpcService = new ObjectName(RPC_SERVICE);
       
+      // this will set the 'notified' attribute to true for all Person objects in RPCUser
+      server0.invoke(rpcService, "runNotifyAllAsynch", null, null);
+      Thread.sleep(5000);
+      
+      // confirm the attribute has been set successfully on each node
+      Object obj1 = server1.invoke(rpcService, "runRetrieveAll", null, null);
+      assertNotNull("expected ArrayList as result type, got null", obj1);
+      assertTrue( "expected ArrayList as result type, got " +obj1.getClass().getName(), obj1 instanceof ArrayList);
+      ArrayList responses = (ArrayList)obj1;
+      
+      // there should be two Person responses, the 'notified' attribute should be true
+      assertEquals("Result should contain two responses; ", 2, responses.size());      
+      for (int i = 0; i < responses.size(); i++)
+      {
+         Object response = responses.get(i);
+         if (response instanceof Exception)
+            fail("received exception response: " + ((Exception)response).toString());
+         assertTrue("expected Person as response type, got " +response.getClass().getName(), response instanceof Person);
+         Person person = (Person)response;
+         assertTrue("expected true as response value, got false for " + person.getName(),
+                     (person.getNotified() == true));
+         
+      }
    }
    
    public void testMethodOnCoordinatorNode() throws Exception
@@ -138,10 +160,24 @@
       
       RMIAdaptor[] adaptors = getAdaptors();
       RMIAdaptorExt server0 = (RMIAdaptorExt) adaptors[0];
-      RMIAdaptorExt server1 = (RMIAdaptorExt) adaptors[1];
-      log.info("server0: " + server0 + "; server1: " + server1);
       ObjectName rpcService = new ObjectName(RPC_SERVICE);
       
+      Object obj0 = server0.invoke(rpcService, "runRetrieveFromCoordinator", null, null);
+      assertNotNull("expected ArrayList as result type, got null", obj0);
+      assertTrue( "expected ArrayList as result type, got " +obj0.getClass().getName(), obj0 instanceof ArrayList);
+      ArrayList responses = (ArrayList)obj0;
+
+      // there should be one Person response
+      assertEquals("Result should contain one response; ", 1, responses.size());  
+      Object response = responses.get(0);
+      if (response instanceof Exception)
+         fail("received exception response: " + ((Exception)response).toString());
+      assertTrue("expected Person as response type, got " +response.getClass().getName(), response instanceof Person);
+
+      String employer = "WidgetsRUs";
+      String respEmpl = ((Person)response).getEmployer();
+      assertTrue("expected " + employer + " as selected response value, got " + respEmpl,
+                  (employer.equalsIgnoreCase(respEmpl)));
    }
 
 }




More information about the jboss-cvs-commits mailing list