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.jmx.test;
023:
024: import javax.management.ObjectName;
025: import javax.naming.InitialContext;
026:
027: import org.jboss.test.JBossTestCase;
028: import org.jboss.test.jmx.eardeployment.a.interfaces.SessionAHome;
029: import org.jboss.test.jmx.eardeployment.a.interfaces.SessionA;
030:
031: /**
032: * Tests of Manifest ClassPath behavior.
033: *
034: * @author <a href="mailto:julien_viet@yahoo.fr">Julien Viet</a>
035: * @author Scott.Stark@jboss.org
036: * @version $Revision: 57211 $
037: */
038: public class CPManifestUnitTestCase extends JBossTestCase {
039:
040: public CPManifestUnitTestCase(String name) {
041: super (name);
042: }
043:
044: /**
045: * Test that an ear with the following structure:
046: * cpmanifest.ear
047: * -+ abstract.jar
048: * -+ concrete.jar, -> ClassPath: abstract.jar
049: * whose application.xml only refers to concrete.jar is able to deploy
050: * because abstract.jar is loaded due to the concrete.jar manifest ClassPath.
051: */
052: public void testEarJarManifest() throws Exception {
053: getLog().info("+++ testEarJarManifest");
054: deploy("cpmanifest.ear");
055: Object home = getInitialContext().lookup("Concrete");
056: getLog().info("Found Concrete home=" + home);
057: undeploy("cpmanifest.ear");
058: }
059:
060: /**
061: * Test that an ear with the following structure:
062: * cpcircular-manifest.ear
063: * -+ abstract2.jar, -> ClassPath: concrete2.jar
064: * -+ concrete2.jar, -> ClassPath: abstract2.jar
065: * whose application.xml only refers to concrete.jar does not cause the
066: * server to spin due to the circular ClassPath references.
067: */
068: public void testCircularManifest() throws Exception {
069: getLog().info("+++ testCircularManifest");
070: deploy("cpcircular-manifest.ear");
071: Object home = getInitialContext().lookup("Concrete");
072: getLog().info("Found Concrete home=" + home);
073: undeploy("cpcircular-manifest.ear");
074: }
075:
076: /**
077: * Test that an ear with the following structure:
078: * external.ear
079: * -+ external.sar, -> ClassPath: external-util.jar
080: * -+ external-util.jar
081: * whose jboss-app.xml only refers to external.sar is able to
082: * load the mbean service in the external.sar
083: */
084: public void testSARManifest() throws Exception {
085: getLog().info("+++ testSARManifest");
086: deploy("external.ear");
087: ObjectName serviceName = new ObjectName(
088: "test:name=ExternalClass");
089: boolean isRegisterd = getServer().isRegistered(serviceName);
090: assertTrue("ExternalClass service is registered", isRegisterd);
091: undeploy("external.ear");
092: }
093:
094: /**
095: * Test that an ear with the following structure:
096: * cpejbs-manifest.ear
097: * -+ ejbjar1.jar, -> ClassPath: ejbjar2.jar
098: * -+ ejbjar2.jar, -> ClassPath: ejbjar1.jar
099: * loads the ejbs.
100: */
101: public void testEJBJarManifest() throws Exception {
102: getLog().info("+++ testEJBJarManifest");
103: deploy("cpejbs-manifest.ear");
104: ObjectName ejb1Name = new ObjectName(
105: "jboss.j2ee:service=EJB,jndiName=eardeployment/SessionA");
106: boolean isRegisterd = getServer().isRegistered(ejb1Name);
107: assertTrue("eardeployment/SessionA is registered", isRegisterd);
108: ObjectName ejb2Name = new ObjectName(
109: "jboss.j2ee:service=EJB,jndiName=eardeployment/SessionB");
110: isRegisterd = getServer().isRegistered(ejb2Name);
111: assertTrue("eardeployment/SessionB is registered", isRegisterd);
112:
113: InitialContext ctx = new InitialContext();
114: SessionAHome home = (SessionAHome) ctx
115: .lookup("eardeployment/SessionA");
116: SessionA bean = home.create();
117: bean.callB();
118: bean.remove();
119: undeploy("cpejbs-manifest.ear");
120: }
121: }
|