[jboss-cvs] JBossAS SVN: r65052 - trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 4 12:47:32 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-09-04 12:47:32 -0400 (Tue, 04 Sep 2007)
New Revision: 65052

Modified:
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java
Log:
[JBAS-4663] Replace JBossClusteredTestCase usage of RMIAdaptor
Fix test so it understands that replication involves serialization

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java	2007-09-04 16:44:25 UTC (rev 65051)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java	2007-09-04 16:47:32 UTC (rev 65052)
@@ -24,6 +24,7 @@
 import java.io.IOException;
 import java.net.HttpURLConnection;
 
+import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
 
 import junit.framework.Test;
@@ -32,7 +33,6 @@
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.jboss.cache.Fqn;
-import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
 import org.jboss.test.JBossClusteredTestCase;
 import org.jboss.test.cluster.testutil.SessionTestUtil;
 import org.jboss.test.cluster.testutil.WebTestBase;
@@ -101,7 +101,7 @@
          warFqn_ = fqn.toString();
       }
       
-      RMIAdaptor[] adaptors = getAdaptors();
+      MBeanServerConnection[] adaptors = getAdaptors();
       if (!deployed0)
       {
          deploy(adaptors[0]);
@@ -137,27 +137,18 @@
       makeGet(client, baseURL0_ +setUrl);
       
       // Get the Attribute set
-      String attr0 = makeGet(client, baseURL0_ +getUrl);
+      String attr0 = checkDeserialization(client, baseURL0_ +getUrl, false);
       
-      sleepThread(DEFAULT_SLEEP);
-      
-      // Make connection to server 1 and get
-      setCookieDomainToThisServer(client, servers_[1]);
-      String attr1 = makeGet(client, baseURL1_ + getUrl);
-      
-      // check for replication first
-      assertEquals("attributes match", attr0, attr1);
-      
       // sleep up to 11 secs to allow max idle to be reached 
       // and tomcat background process to run
       // assuming that max idle in jboss-web.xml = 10 secs
       // and tomcat background process is using the default = 10 secs
-      sleepThread(11000);
+      sleepThread(11100);
       
       // activate the session by requesting the attribute
       // Make connection to server 0 and get
       setCookieDomainToThisServer(client, servers_[0]);
-      String attr2 = checkDeserialization(client, baseURL0_ + getUrl);
+      String attr2 = checkDeserialization(client, baseURL0_ + getUrl, true);
       
       assertEquals("attribute match after activation", attr0, attr2);
    }
@@ -173,24 +164,19 @@
 
       getLog().debug(setUrl + ":::::::" + getUrl);
 
-      RMIAdaptor[] adaptors = getAdaptors();
+      MBeanServerConnection[] adaptors = getAdaptors();
       // Create an instance of HttpClient.
       HttpClient client = new HttpClient();
       // Set the session attribute first
       makeGet(client, baseURL0_ +setUrl);
       
-      // Get the Attribute set
-      String attr0 = makeGet(client, baseURL0_ +getUrl);
+      // Get the Attribute set; confirm session wasn't deserialized
+      String attr0 = checkDeserialization(client, baseURL0_ +getUrl, false);
       
-      sleepThread(DEFAULT_SLEEP);
+      // passivation-min-idle-time is set to 1 sec, so sleep that
+      // long so our session can be passivated
+      sleepThread(1100);
       
-      // Make connection to server 1 and get
-      setCookieDomainToThisServer(client, servers_[1]);
-      String attr1 = makeGet(client, baseURL1_ + getUrl);
-      
-      // check for replication first
-      assertEquals("attributes match", attr0, attr1);
-      
       // Create enough sessions on server0 to trigger passivation
       // assuming that max-active-sessions is set to 20 in jboss-web.xml
       getLog().debug("current active sessions = " + SessionTestUtil.getSessionIds(adaptors[0], warFqn_));
@@ -208,10 +194,10 @@
       getLog().debug("to reach max active sessions we needed to create " + clients.length + " clients");
       
       
-      // activate the session by requesting the attribute
       // Make connection to server 0 and get
+      // activate the session and confirm that it was deserialized (passivated)      
       setCookieDomainToThisServer(client, servers_[0]);
-      String attr2 = checkDeserialization(client, baseURL0_ + getUrl);
+      String attr2 = checkDeserialization(client, baseURL0_ + getUrl, true);
       
       assertEquals("attribute match after activation", attr0, attr2);      
    }
@@ -229,7 +215,7 @@
        
        // Undeploy from server1 to ensure that a redeploy on server0
        // results in sessions coming from disk, not server1
-       RMIAdaptor[] adaptors = getAdaptors();
+       MBeanServerConnection[] adaptors = getAdaptors();
        deployed1 = false;
        undeploy(adaptors[1]);
        
@@ -241,9 +227,6 @@
        // Set the session attribute first
        makeGet(client, baseURL0_ +setUrl);
        
-       // replicate the session to server1
-       sleepThread(DEFAULT_SLEEP);
-       
        //   Get the Attribute set
        String attr = makeGetWithState(client, baseURL0_ +getUrl);
        
@@ -268,15 +251,17 @@
        
    }
    
-   private void deploy(RMIAdaptor adaptor) throws Exception
+   private void deploy(MBeanServerConnection adaptor) throws Exception
    {
       deploy(adaptor, getWarName() + ".war");   
    }
    
-   private void undeploy(RMIAdaptor adaptor) throws Exception
+   private void undeploy(MBeanServerConnection adaptor) throws Exception
    {
       undeploy(adaptor, getWarName() + ".war");   
-   }/**
+   }
+   
+   /**
     * Makes a http call to the jsp that retrieves the attribute stored on the
     * session. When the attribute values mathes with the one retrieved earlier,
     * we have HttpSessionReplication.
@@ -286,7 +271,7 @@
     * @param url
     * @return session attribute
     */
-   protected String checkDeserialization(HttpClient client, String url)
+   protected String checkDeserialization(HttpClient client, String url, boolean expectDeserialized)
       throws IOException
    {
       getLog().debug("checkDeserialization(): trying to get from url " +url);
@@ -306,7 +291,7 @@
       
       Header hdr = method.getResponseHeader("X-SessionDeserialzied");
       Boolean sawAttr = hdr != null ? Boolean.valueOf(hdr.getValue()) : Boolean.FALSE;
-      assertTrue("Session was deserialized", sawAttr.booleanValue());
+      assertEquals("Session deserialization as expected", expectDeserialized, sawAttr.booleanValue());
       
       // Read the response body.
       byte[] responseBody = method.getResponseBody();




More information about the jboss-cvs-commits mailing list