[jboss-cvs] JBossAS SVN: r60165 - branches/Branch_4_2/testsuite/src/main/org/jboss/test/classloader/leak/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 1 14:17:07 EST 2007


Author: bstansberry at jboss.com
Date: 2007-02-01 14:17:07 -0500 (Thu, 01 Feb 2007)
New Revision: 60165

Added:
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/classloader/leak/test/ClassloaderLeakUnitTestCase.java
Removed:
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/classloader/leak/test/ClassloaderLeakTest.java
Log:
Properly name the ClassloaderLeakUnitTestCase

Deleted: branches/Branch_4_2/testsuite/src/main/org/jboss/test/classloader/leak/test/ClassloaderLeakTest.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/classloader/leak/test/ClassloaderLeakTest.java	2007-02-01 19:11:44 UTC (rev 60164)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/classloader/leak/test/ClassloaderLeakTest.java	2007-02-01 19:17:07 UTC (rev 60165)
@@ -1,348 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.classloader.leak.test;
-
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.naming.InitialContext;
-
-import junit.framework.Test;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.JBossTestCase;
-import org.jboss.test.classloader.leak.clstore.ClassLoaderTrackerMBean;
-import org.jboss.test.classloader.leak.ejb.interfaces.StatelessSession;
-import org.jboss.test.classloader.leak.ejb.interfaces.StatelessSessionHome;
-
-/**
- * Test for classloader leaks following deployment, use and undeployment
- * of various packages (wars, ejb jars and ears with and without scoped
- * classloaders).
- * <p/>
- * These tests were originally written to test for leaks caused by Jakarta 
- * Commons Logging.  As a result, there are various permutations of the tests
- * that store copies of commons-logging in different locations on the classpath.
- * <p/>
- * If these test are run with JBoss Profiler's jbossAgent (.dll or .so) on the path
- * and the AS is started with -agentlib:jbossAgent, in case of classloader leakage
- * an extensive report will be logged to the server log, showing the path to root of
- * all references to the classloader.
- * 
- * @author Brian Stansberry
- */
-public class ClassloaderLeakTest extends JBossTestCase
-{
-   private static final String SIMPLE_WAR = "classloader-leak-simple.war";
-   private static final String WAR_WITH_JCL = "classloader-leak-in-war.war";
-   private static final String SIMPLE_EJB = "classloader-leak-ejb.jar"; 
-   private static final String SIMPLE_EAR = "classloader-leak-simple.ear"; 
-   private static final String EAR_WITH_JCL = "classloader-leak-in-ear.ear";
-   private static final String SIMPLE_ISOLATED_EAR = "classloader-leak-simple-isolated.ear";
-   private static final String ISOLATED_EAR_WITH_JCL = "classloader-leak-in-ear-isolated.ear";
-   private static final String EAR_WITH_DUAL_JCL = "classloader-leak-dual.ear";
-   private static final String ISOLATED_EAR_WITH_DUAL_JCL = "classloader-leak-dual-isolated.ear";
-   private static final String NO_WEB_EAR = "classloader-leak-noweb.ear";
-   private static final String ISOLATED_NO_WEB_EAR = "classloader-leak-noweb-isolated.ear";
-   
-   private static final String WEBAPP = "WEBAPP";
-   private static final String EJB = "EJB";
-   
-   private static final Set deployments = new HashSet();
-   
-   private String baseURL = null;
-
-   public ClassloaderLeakTest(String name)
-   {
-      super(name);
-   }
-   
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-      cleanDeployments();
-      
-      removeClassLoader(WEBAPP);
-      removeClassLoader(EJB);
-      
-      baseURL = "http://" + getServerHost() + ":8080/classloader-leak/";
-   }
-   
-   protected void tearDown() throws Exception
-   {
-      cleanDeployments();
-      
-      removeClassLoader(WEBAPP);
-      removeClassLoader(EJB);
-      
-      super.tearDown();
-   }
-   
-   private void cleanDeployments() throws Exception
-   {
-      Iterator it = deployments.iterator();
-      while (it.hasNext())
-      {
-         undeploy((String) it.next(), false);
-         it = deployments.iterator();
-      }
-   }
-   
-   private void undeploy(String deployment, boolean propagateFailure)
-         throws Exception
-   {
-      try
-      {
-         undeploy(deployment);
-         deployments.remove(deployment);
-      }
-      catch (Exception e)
-      {
-         if (propagateFailure)
-            throw e;
-         else
-            log.error("Exception during undeploy of " + deployment, e);
-      }
-   }
-   
-   private void deployJCLUser(String deployment) throws Exception
-   {
-      deploy(deployment);
-      deployments.add(deployment);
-   }
-   
-   public void testSimpleWar() throws Exception
-   {
-      warTest(SIMPLE_WAR, true);
-   }
-   
-   public void testWarWithJcl() throws Exception
-   {
-      warTest(WAR_WITH_JCL, true);
-   }
-   
-   public void testSimpleEjb() throws Exception
-   {
-      ejbTest(SIMPLE_EJB);
-   }
-   
-   public void testSimpleEar() throws Exception
-   {
-      earTest(SIMPLE_EAR);
-   }
-   
-   public void testEarWithJcl() throws Exception
-   {
-      earTest(EAR_WITH_JCL);
-   }
-   
-   public void testNoWebEar() throws Exception
-   {
-      ejbTest(NO_WEB_EAR);
-   }
-   
-   public void testSimpleIsolatedEar() throws Exception
-   {
-      earTest(SIMPLE_ISOLATED_EAR);
-   }
-   
-   public void testIsolatedNoWebEar() throws Exception
-   {
-      ejbTest(ISOLATED_NO_WEB_EAR);
-   }
-   
-   public void testIsolatedEarWithJcl() throws Exception
-   {
-      earTest(ISOLATED_EAR_WITH_JCL);
-   }
-   
-   public void testEarWithDualJcl() throws Exception
-   {
-      earTest(EAR_WITH_DUAL_JCL);
-   }
-   
-   public void testIsolatedEarWithDualJcl() throws Exception
-   {
-      earTest(ISOLATED_EAR_WITH_DUAL_JCL);
-   }
-   
-   private void warTest(String deployment, boolean makeRequest) throws Exception
-   {
-      if (hasClassLoader(WEBAPP))
-         throw new IllegalStateException("Classloader already registered for " + WEBAPP);
-      
-      deployJCLUser(deployment);
-      
-
-      if (makeRequest)
-      {
-         makeWebRequest(baseURL + "SimpleServlet", WEBAPP);
-         makeWebRequest(baseURL + "simple.jsp", WEBAPP);
-      }
-      
-      assertTrue("WEBAPP classloader registered", hasClassLoader(WEBAPP));
-      
-      undeploy(deployment, true);
-      
-      flushSecurityCache("HsqlDbRealm");
-      
-      sleep(500);
-      
-      assertTrue("WEBAPP classloader unregistered", hasClassLoaderBeenReleased(WEBAPP));
-   }
-   
-   private void ejbTest(String deployment) throws Exception
-   {
-      if (hasClassLoader(EJB))
-         throw new IllegalStateException("Classloader already registered for " + WEBAPP);
-      
-      deployJCLUser(deployment);
-      
-      makeEjbRequest();
-      
-      assertTrue("EJB classloader registered", hasClassLoader(EJB));
-      
-      undeploy(deployment, true);
-      
-      flushSecurityCache("HsqlDbRealm");
-      
-      sleep(500);
-      
-      assertTrue("WEBAPP classloader unregistered", hasClassLoaderBeenReleased(WEBAPP));
-   }
-   
-   private void earTest(String deployment) throws Exception
-   {
-      if (hasClassLoader(WEBAPP))
-         throw new IllegalStateException("Classloader already registered for " + WEBAPP);
-      
-      if (hasClassLoader(EJB))
-         throw new IllegalStateException("Classloader already registered for " + EJB);
-      
-      deployJCLUser(deployment);
-      
-      makeWebRequest(baseURL + "simple.jsp", WEBAPP);
-      makeWebRequest(baseURL + "SimpleServlet", WEBAPP);
-      
-      assertTrue("WEBAPP classloader registered", hasClassLoader(WEBAPP));
-      
-      makeWebRequest(baseURL + "ejb.jsp", EJB);
-      makeWebRequest(baseURL + "EJBServlet", EJB);
-      
-      makeEjbRequest();
-      
-      assertTrue("EJB classloader registered", hasClassLoader(EJB));
-         
-      undeploy(deployment, true);
-      
-      flushSecurityCache("HsqlDbRealm");
-      
-      sleep(500);
-
-      if (!hasClassLoaderBeenReleased(WEBAPP))
-      {
-         if (!hasClassLoaderBeenReleased(EJB))
-            fail("Both EJB and WEBAPP classloaders unregistered");
-         fail("WEBAPP classloader unregistered");
-      }
-      assertTrue("EJB classloader unregistered", hasClassLoaderBeenReleased(EJB));
-      
-   }
-   
-   private boolean hasClassLoader(String key) throws Exception
-   {
-      MBeanServerConnection adaptor = delegate.getServer();
-      ObjectName on = new ObjectName(ClassLoaderTrackerMBean.OBJECT_NAME);
-      Object[] params = { key };
-      String[] signature = new String[] { String.class.getName() };
-      return ((Boolean) adaptor.invoke(on, "hasClassLoader", params, signature)).booleanValue();
-   }
-   
-   private boolean hasClassLoaderBeenReleased(String key) throws Exception
-   {
-      MBeanServerConnection adaptor = delegate.getServer();
-      ObjectName on = new ObjectName(ClassLoaderTrackerMBean.OBJECT_NAME);
-      Object[] params = { key };
-      String[] signature = new String[] { String.class.getName() };
-      return ((Boolean) adaptor.invoke(on, "hasClassLoaderBeenReleased", params, signature)).booleanValue();
-   }
-   
-   private void removeClassLoader(String key) throws Exception
-   {
-      MBeanServerConnection adaptor = delegate.getServer();
-      ObjectName on = new ObjectName(ClassLoaderTrackerMBean.OBJECT_NAME);
-      Object[] params = { key };
-      String[] signature = new String[] { String.class.getName() };
-      adaptor.invoke(on, "removeClassLoader", params, signature);
-   }
-   
-   private void flushSecurityCache(String domain) throws Exception
-   {
-      log.debug("Flushing security cache " + domain);
-      MBeanServerConnection adaptor = delegate.getServer();
-      ObjectName on = new ObjectName(ClassLoaderTrackerMBean.OBJECT_NAME);
-      Object[] params = { domain };
-      String[] signature = new String[] { String.class.getName() };
-      adaptor.invoke(on, "flushSecurityCache", params, signature);
-   }
-   
-   private void makeWebRequest(String url, String responseContent)
-   {
-      HttpClient client = new HttpClient();
-      GetMethod method = new GetMethod(url);
-      int responseCode = 0;
-      try
-      {
-         responseCode = client.executeMethod(method);
-         
-         assertTrue("Get OK with url: " +url + " responseCode: " +responseCode
-               , responseCode == HttpURLConnection.HTTP_OK);
-         
-         String rsp = new String(method.getResponseBody());
-         
-         assertTrue("Response contains " + responseContent, rsp.indexOf(responseContent) >= 0);
-      } catch (IOException e)
-      {
-         e.printStackTrace();
-         fail("HttpClient executeMethod fails." +e.toString());
-      }
-   }
-   
-   private void makeEjbRequest() throws Exception
-   {
-      InitialContext ctx = this.getInitialContext();
-      StatelessSessionHome home = (StatelessSessionHome) ctx.lookup("ClassloaderLeakStatelessSession");
-      StatelessSession bean = home.create();
-      bean.log("EJB");
-   }
-
-   public static Test suite() throws Exception
-   {
-      return getDeploySetup(ClassloaderLeakTest.class, "classloader-leak-test.sar");
-   }
-}

Copied: branches/Branch_4_2/testsuite/src/main/org/jboss/test/classloader/leak/test/ClassloaderLeakUnitTestCase.java (from rev 60163, branches/Branch_4_2/testsuite/src/main/org/jboss/test/classloader/leak/test/ClassloaderLeakTest.java)
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/classloader/leak/test/ClassloaderLeakUnitTestCase.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/classloader/leak/test/ClassloaderLeakUnitTestCase.java	2007-02-01 19:17:07 UTC (rev 60165)
@@ -0,0 +1,348 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classloader.leak.test;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.classloader.leak.clstore.ClassLoaderTrackerMBean;
+import org.jboss.test.classloader.leak.ejb.interfaces.StatelessSession;
+import org.jboss.test.classloader.leak.ejb.interfaces.StatelessSessionHome;
+
+/**
+ * Test for classloader leaks following deployment, use and undeployment
+ * of various packages (wars, ejb jars and ears with and without scoped
+ * classloaders).
+ * <p/>
+ * These tests were originally written to test for leaks caused by Jakarta 
+ * Commons Logging.  As a result, there are various permutations of the tests
+ * that store copies of commons-logging in different locations on the classpath.
+ * <p/>
+ * If these test are run with JBoss Profiler's jbossAgent (.dll or .so) on the path
+ * and the AS is started with -agentlib:jbossAgent, in case of classloader leakage
+ * an extensive report will be logged to the server log, showing the path to root of
+ * all references to the classloader.
+ * 
+ * @author Brian Stansberry
+ */
+public class ClassloaderLeakUnitTestCase extends JBossTestCase
+{
+   private static final String SIMPLE_WAR = "classloader-leak-simple.war";
+   private static final String WAR_WITH_JCL = "classloader-leak-in-war.war";
+   private static final String SIMPLE_EJB = "classloader-leak-ejb.jar"; 
+   private static final String SIMPLE_EAR = "classloader-leak-simple.ear"; 
+   private static final String EAR_WITH_JCL = "classloader-leak-in-ear.ear";
+   private static final String SIMPLE_ISOLATED_EAR = "classloader-leak-simple-isolated.ear";
+   private static final String ISOLATED_EAR_WITH_JCL = "classloader-leak-in-ear-isolated.ear";
+   private static final String EAR_WITH_DUAL_JCL = "classloader-leak-dual.ear";
+   private static final String ISOLATED_EAR_WITH_DUAL_JCL = "classloader-leak-dual-isolated.ear";
+   private static final String NO_WEB_EAR = "classloader-leak-noweb.ear";
+   private static final String ISOLATED_NO_WEB_EAR = "classloader-leak-noweb-isolated.ear";
+   
+   private static final String WEBAPP = "WEBAPP";
+   private static final String EJB = "EJB";
+   
+   private static final Set deployments = new HashSet();
+   
+   private String baseURL = null;
+
+   public ClassloaderLeakUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      cleanDeployments();
+      
+      removeClassLoader(WEBAPP);
+      removeClassLoader(EJB);
+      
+      baseURL = "http://" + getServerHost() + ":8080/classloader-leak/";
+   }
+   
+   protected void tearDown() throws Exception
+   {
+      cleanDeployments();
+      
+      removeClassLoader(WEBAPP);
+      removeClassLoader(EJB);
+      
+      super.tearDown();
+   }
+   
+   private void cleanDeployments() throws Exception
+   {
+      Iterator it = deployments.iterator();
+      while (it.hasNext())
+      {
+         undeploy((String) it.next(), false);
+         it = deployments.iterator();
+      }
+   }
+   
+   private void undeploy(String deployment, boolean propagateFailure)
+         throws Exception
+   {
+      try
+      {
+         undeploy(deployment);
+         deployments.remove(deployment);
+      }
+      catch (Exception e)
+      {
+         if (propagateFailure)
+            throw e;
+         else
+            log.error("Exception during undeploy of " + deployment, e);
+      }
+   }
+   
+   private void deployJCLUser(String deployment) throws Exception
+   {
+      deploy(deployment);
+      deployments.add(deployment);
+   }
+   
+   public void testSimpleWar() throws Exception
+   {
+      warTest(SIMPLE_WAR, true);
+   }
+   
+   public void testWarWithJcl() throws Exception
+   {
+      warTest(WAR_WITH_JCL, true);
+   }
+   
+   public void testSimpleEjb() throws Exception
+   {
+      ejbTest(SIMPLE_EJB);
+   }
+   
+   public void testSimpleEar() throws Exception
+   {
+      earTest(SIMPLE_EAR);
+   }
+   
+   public void testEarWithJcl() throws Exception
+   {
+      earTest(EAR_WITH_JCL);
+   }
+   
+   public void testNoWebEar() throws Exception
+   {
+      ejbTest(NO_WEB_EAR);
+   }
+   
+   public void testSimpleIsolatedEar() throws Exception
+   {
+      earTest(SIMPLE_ISOLATED_EAR);
+   }
+   
+   public void testIsolatedNoWebEar() throws Exception
+   {
+      ejbTest(ISOLATED_NO_WEB_EAR);
+   }
+   
+   public void testIsolatedEarWithJcl() throws Exception
+   {
+      earTest(ISOLATED_EAR_WITH_JCL);
+   }
+   
+   public void testEarWithDualJcl() throws Exception
+   {
+      earTest(EAR_WITH_DUAL_JCL);
+   }
+   
+   public void testIsolatedEarWithDualJcl() throws Exception
+   {
+      earTest(ISOLATED_EAR_WITH_DUAL_JCL);
+   }
+   
+   private void warTest(String deployment, boolean makeRequest) throws Exception
+   {
+      if (hasClassLoader(WEBAPP))
+         throw new IllegalStateException("Classloader already registered for " + WEBAPP);
+      
+      deployJCLUser(deployment);
+      
+
+      if (makeRequest)
+      {
+         makeWebRequest(baseURL + "SimpleServlet", WEBAPP);
+         makeWebRequest(baseURL + "simple.jsp", WEBAPP);
+      }
+      
+      assertTrue("WEBAPP classloader registered", hasClassLoader(WEBAPP));
+      
+      undeploy(deployment, true);
+      
+      flushSecurityCache("HsqlDbRealm");
+      
+      sleep(500);
+      
+      assertTrue("WEBAPP classloader unregistered", hasClassLoaderBeenReleased(WEBAPP));
+   }
+   
+   private void ejbTest(String deployment) throws Exception
+   {
+      if (hasClassLoader(EJB))
+         throw new IllegalStateException("Classloader already registered for " + WEBAPP);
+      
+      deployJCLUser(deployment);
+      
+      makeEjbRequest();
+      
+      assertTrue("EJB classloader registered", hasClassLoader(EJB));
+      
+      undeploy(deployment, true);
+      
+      flushSecurityCache("HsqlDbRealm");
+      
+      sleep(500);
+      
+      assertTrue("WEBAPP classloader unregistered", hasClassLoaderBeenReleased(WEBAPP));
+   }
+   
+   private void earTest(String deployment) throws Exception
+   {
+      if (hasClassLoader(WEBAPP))
+         throw new IllegalStateException("Classloader already registered for " + WEBAPP);
+      
+      if (hasClassLoader(EJB))
+         throw new IllegalStateException("Classloader already registered for " + EJB);
+      
+      deployJCLUser(deployment);
+      
+      makeWebRequest(baseURL + "simple.jsp", WEBAPP);
+      makeWebRequest(baseURL + "SimpleServlet", WEBAPP);
+      
+      assertTrue("WEBAPP classloader registered", hasClassLoader(WEBAPP));
+      
+      makeWebRequest(baseURL + "ejb.jsp", EJB);
+      makeWebRequest(baseURL + "EJBServlet", EJB);
+      
+      makeEjbRequest();
+      
+      assertTrue("EJB classloader registered", hasClassLoader(EJB));
+         
+      undeploy(deployment, true);
+      
+      flushSecurityCache("HsqlDbRealm");
+      
+      sleep(500);
+
+      if (!hasClassLoaderBeenReleased(WEBAPP))
+      {
+         if (!hasClassLoaderBeenReleased(EJB))
+            fail("Both EJB and WEBAPP classloaders unregistered");
+         fail("WEBAPP classloader unregistered");
+      }
+      assertTrue("EJB classloader unregistered", hasClassLoaderBeenReleased(EJB));
+      
+   }
+   
+   private boolean hasClassLoader(String key) throws Exception
+   {
+      MBeanServerConnection adaptor = delegate.getServer();
+      ObjectName on = new ObjectName(ClassLoaderTrackerMBean.OBJECT_NAME);
+      Object[] params = { key };
+      String[] signature = new String[] { String.class.getName() };
+      return ((Boolean) adaptor.invoke(on, "hasClassLoader", params, signature)).booleanValue();
+   }
+   
+   private boolean hasClassLoaderBeenReleased(String key) throws Exception
+   {
+      MBeanServerConnection adaptor = delegate.getServer();
+      ObjectName on = new ObjectName(ClassLoaderTrackerMBean.OBJECT_NAME);
+      Object[] params = { key };
+      String[] signature = new String[] { String.class.getName() };
+      return ((Boolean) adaptor.invoke(on, "hasClassLoaderBeenReleased", params, signature)).booleanValue();
+   }
+   
+   private void removeClassLoader(String key) throws Exception
+   {
+      MBeanServerConnection adaptor = delegate.getServer();
+      ObjectName on = new ObjectName(ClassLoaderTrackerMBean.OBJECT_NAME);
+      Object[] params = { key };
+      String[] signature = new String[] { String.class.getName() };
+      adaptor.invoke(on, "removeClassLoader", params, signature);
+   }
+   
+   private void flushSecurityCache(String domain) throws Exception
+   {
+      log.debug("Flushing security cache " + domain);
+      MBeanServerConnection adaptor = delegate.getServer();
+      ObjectName on = new ObjectName(ClassLoaderTrackerMBean.OBJECT_NAME);
+      Object[] params = { domain };
+      String[] signature = new String[] { String.class.getName() };
+      adaptor.invoke(on, "flushSecurityCache", params, signature);
+   }
+   
+   private void makeWebRequest(String url, String responseContent)
+   {
+      HttpClient client = new HttpClient();
+      GetMethod method = new GetMethod(url);
+      int responseCode = 0;
+      try
+      {
+         responseCode = client.executeMethod(method);
+         
+         assertTrue("Get OK with url: " +url + " responseCode: " +responseCode
+               , responseCode == HttpURLConnection.HTTP_OK);
+         
+         String rsp = new String(method.getResponseBody());
+         
+         assertTrue("Response contains " + responseContent, rsp.indexOf(responseContent) >= 0);
+      } catch (IOException e)
+      {
+         e.printStackTrace();
+         fail("HttpClient executeMethod fails." +e.toString());
+      }
+   }
+   
+   private void makeEjbRequest() throws Exception
+   {
+      InitialContext ctx = this.getInitialContext();
+      StatelessSessionHome home = (StatelessSessionHome) ctx.lookup("ClassloaderLeakStatelessSession");
+      StatelessSession bean = home.create();
+      bean.log("EJB");
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(ClassloaderLeakUnitTestCase.class, "classloader-leak-test.sar");
+   }
+}




More information about the jboss-cvs-commits mailing list