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.cts.test;
023:
024: import javax.naming.InitialContext;
025:
026: import org.jboss.test.cts.jms.ContainerMBox;
027: import org.jboss.test.cts.interfaces.CtsCmp2Session;
028: import org.jboss.test.cts.interfaces.CtsCmp2SessionHome;
029:
030: import junit.framework.Test;
031: import junit.framework.TestSuite;
032:
033: import org.jboss.test.JBossTestCase;
034:
035: /** Tests of versioned deployments using ear scoped class loader.
036: * @author Scott.Stark@jboss.org
037: * @version $Revision: 57211 $
038: */
039: public class CtsCmp2UnitTestCase extends JBossTestCase {
040: public CtsCmp2UnitTestCase(String name) {
041: super (name);
042: }
043:
044: protected void setUp() throws Exception {
045: }
046:
047: public void testV1() throws Exception {
048: try {
049: deploy("cts-v1cmp.ear");
050: InitialContext ctx = new InitialContext();
051: CtsCmp2SessionHome home = (CtsCmp2SessionHome) ctx
052: .lookup("v1/CtsCmp2SessionBean");
053: CtsCmp2Session session = home.create();
054: session.testV1();
055: } finally {
056: undeploy("cts-v1cmp.ear");
057: } // end of try-catch
058: }
059:
060: public void testV2() throws Exception {
061: try {
062: deploy("cts-v1cmp.ear");
063: try {
064: deploy("cts-v2cmp.ear");
065: InitialContext ctx = new InitialContext();
066: CtsCmp2SessionHome home = (CtsCmp2SessionHome) ctx
067: .lookup("v2/CtsCmp2SessionBean");
068: CtsCmp2Session session = home.create();
069: session.testV2();
070: } finally {
071: undeploy("cts-v2cmp.ear");
072: } // end of finally
073: } finally {
074: undeploy("cts-v1cmp.ear");
075: } // end of try-catch
076: }
077:
078: public void testV1Sar() throws Exception {
079: try {
080: deploy("cts-v1cmp-sar.ear");
081: InitialContext ctx = new InitialContext();
082: CtsCmp2SessionHome home = (CtsCmp2SessionHome) ctx
083: .lookup("v1/CtsCmp2SessionBean");
084: CtsCmp2Session session = home.create();
085: session.testV1();
086: } finally {
087: undeploy("cts-v1cmp-sar.ear");
088: } // end of try-catch
089: }
090:
091: public void testV2Sar() throws Exception {
092: try {
093: getLog().debug("Deploying cts-v1cmp-sar.ear");
094: deploy("cts-v1cmp-sar.ear");
095: getLog().debug("Deployed cts-v1cmp-sar.ear");
096: try {
097: getLog().debug("Deploying cts-v2cmp-sar.ear");
098: deploy("cts-v2cmp-sar.ear");
099: getLog().debug("Deployed cts-v2cmp-sar.ear");
100: InitialContext ctx = new InitialContext();
101: CtsCmp2SessionHome home = (CtsCmp2SessionHome) ctx
102: .lookup("v2/CtsCmp2SessionBean");
103: getLog().debug("Found CtsCmp2SessionHome");
104: CtsCmp2Session session = home.create();
105: getLog().debug("Created CtsCmp2Session");
106: session.testV2();
107: getLog().debug("Invoked CtsCmp2Session.testV2()");
108: } finally {
109: undeploy("cts-v2cmp-sar.ear");
110: } // end of finally
111: } finally {
112: undeploy("cts-v1cmp-sar.ear");
113: } // end of try-catch
114: }
115:
116: public static Test suite() throws Exception {
117: TestSuite suite = new TestSuite();
118: suite.addTest(new CtsCmp2UnitTestCase("testV1"));
119: suite.addTest(new CtsCmp2UnitTestCase("testV2"));
120: suite.addTest(new CtsCmp2UnitTestCase("testV1Sar"));
121: suite.addTest(new CtsCmp2UnitTestCase("testV2Sar"));
122: return suite;
123: }
124: }
|