001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.classloader.leak.test;
023:
024: import javax.naming.InitialContext;
025:
026: import junit.framework.Test;
027:
028: import org.jboss.test.classloader.leak.ejb3.Ejb3StatefulSession;
029: import org.jboss.test.classloader.leak.ejb3.Ejb3StatelessSession;
030:
031: /**
032: * Similar to {@link ClassloaderLeakUnitTestCase}, but uses EJB3 instead
033: * of EJB2. Doesn't repeat the non-EJB related tests, nor does it go through
034: * all the various permutations of Jakarta Commons Logging packaging.
035: * <p/>
036: * If these tests are run with JBoss Profiler's jbossAgent (.dll or .so) on the path
037: * and the AS is started with -agentlib:jbossAgent, in case of classloader leakage
038: * an extensive report will be logged to the server log, showing the path to root of
039: * all references to the classloader.
040: *
041: * @author Brian Stansberry
042: */
043: public class Ejb3ClassloaderLeakUnitTestCase extends
044: ClassloaderLeakTestBase {
045: private static final String SIMPLE_EJB = "classloader-leak-ejb3.jar";
046: private static final String SIMPLE_EAR = "classloader-leak-simple-ejb3.ear";
047: private static final String SIMPLE_ISOLATED_EAR = "classloader-leak-simple-isolated-ejb3.ear";
048: private static final String NO_WEB_EAR = "classloader-leak-noweb-ejb3.ear";
049: private static final String ISOLATED_NO_WEB_EAR = "classloader-leak-noweb-isolated-ejb3.ear";
050:
051: private static final String EJB3_SLSB = "EJB3_SLSB";
052: private static final String EJB3_SFSB = "EJB3_SFSB";
053: private static final String EJB3_SLSB_TCCL = "EJB3_SLSB_TCCL";
054: private static final String EJB3_SFSB_TCCL = "EJB3_SFSB_TCCL";
055: private static final String EJB3_TLP_SLSB = "EJB3_TLP_SLSB";
056: private static final String EJB3_TLP_SLSB_TCCL = "EJB3_TLP_SLSB_TCCL";
057:
058: private static final String[] EJB3 = new String[] { EJB3_SLSB,
059: EJB3_SLSB_TCCL, EJB3_SFSB, EJB3_SFSB_TCCL, EJB3_TLP_SLSB,
060: EJB3_TLP_SLSB_TCCL };
061:
062: public Ejb3ClassloaderLeakUnitTestCase(String name) {
063: super (name);
064: }
065:
066: public static Test suite() throws Exception {
067: return getDeploySetup(Ejb3ClassloaderLeakUnitTestCase.class,
068: "classloader-leak-test.sar");
069: }
070:
071: public void testSimpleEjb() throws Exception {
072: ejbTest(SIMPLE_EJB);
073: }
074:
075: public void testSimpleEar() throws Exception {
076: earTest(SIMPLE_EAR);
077: }
078:
079: public void testNoWebEar() throws Exception {
080: ejbTest(NO_WEB_EAR);
081: }
082:
083: public void testSimpleIsolatedEar() throws Exception {
084: earTest(SIMPLE_ISOLATED_EAR);
085: }
086:
087: public void testIsolatedNoWebEar() throws Exception {
088: ejbTest(ISOLATED_NO_WEB_EAR);
089: }
090:
091: protected String getWarContextPath() {
092: return "classloader-leak-ejb3";
093: }
094:
095: protected String[] getEjbKeys() {
096: return EJB3;
097: }
098:
099: protected void makeEjbRequests() throws Exception {
100: InitialContext ctx = new InitialContext();
101: Ejb3StatelessSession ejb3slsb = (Ejb3StatelessSession) ctx
102: .lookup("Ejb3StatelessSession/remote");
103: ejb3slsb.log("EJB");
104: Ejb3StatefulSession ejb3sfsb = (Ejb3StatefulSession) ctx
105: .lookup("Ejb3StatefulSession/remote");
106: ejb3sfsb.log("EJB");
107: Ejb3StatelessSession tlpejb3slsb = (Ejb3StatelessSession) ctx
108: .lookup("ThreadLocalPoolEjb3StatelessSession/remote");
109: tlpejb3slsb.log("EJB");
110: }
111: }
|