KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cts > test > CtsCmp2UnitTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.cts.test;
23
24 import javax.naming.InitialContext JavaDoc;
25
26 import org.jboss.test.cts.jms.ContainerMBox;
27 import org.jboss.test.cts.interfaces.CtsCmp2Session;
28 import org.jboss.test.cts.interfaces.CtsCmp2SessionHome;
29
30 import junit.framework.Test;
31 import junit.framework.TestSuite;
32
33 import org.jboss.test.JBossTestCase;
34
35 /** Tests of versioned deployments using ear scoped class loader.
36  * @author Scott.Stark@jboss.org
37  * @version $Revision: 37406 $
38  */

39 public class CtsCmp2UnitTestCase extends JBossTestCase
40 {
41    public CtsCmp2UnitTestCase(String JavaDoc name)
42    {
43       super(name);
44    }
45
46    protected void setUp() throws Exception JavaDoc
47    {
48    }
49
50    public void testV1() throws Exception JavaDoc
51    {
52       try
53       {
54          deploy("cts-v1cmp.ear");
55          InitialContext JavaDoc ctx = new InitialContext JavaDoc();
56          CtsCmp2SessionHome home = (CtsCmp2SessionHome) ctx.lookup("v1/CtsCmp2SessionBean");
57          CtsCmp2Session session = home.create();
58          session.testV1();
59       }
60       finally
61       {
62          undeploy("cts-v1cmp.ear");
63       } // end of try-catch
64
}
65
66    public void testV2() throws Exception JavaDoc
67    {
68       try
69       {
70          deploy("cts-v1cmp.ear");
71          try
72          {
73             deploy("cts-v2cmp.ear");
74             InitialContext JavaDoc ctx = new InitialContext JavaDoc();
75             CtsCmp2SessionHome home = (CtsCmp2SessionHome) ctx.lookup("v2/CtsCmp2SessionBean");
76             CtsCmp2Session session = home.create();
77             session.testV2();
78          }
79          finally
80          {
81             undeploy("cts-v2cmp.ear");
82          } // end of finally
83
}
84       finally
85       {
86          undeploy("cts-v1cmp.ear");
87       } // end of try-catch
88
}
89
90    public void testV1Sar() throws Exception JavaDoc
91    {
92       try
93       {
94          deploy("cts-v1cmp-sar.ear");
95          InitialContext JavaDoc ctx = new InitialContext JavaDoc();
96          CtsCmp2SessionHome home = (CtsCmp2SessionHome) ctx.lookup("v1/CtsCmp2SessionBean");
97          CtsCmp2Session session = home.create();
98          session.testV1();
99       }
100       finally
101       {
102          undeploy("cts-v1cmp-sar.ear");
103       } // end of try-catch
104
}
105
106    public void testV2Sar() throws Exception JavaDoc
107    {
108       try
109       {
110          getLog().debug("Deploying cts-v1cmp-sar.ear");
111          deploy("cts-v1cmp-sar.ear");
112          getLog().debug("Deployed cts-v1cmp-sar.ear");
113          try
114          {
115             getLog().debug("Deploying cts-v2cmp-sar.ear");
116             deploy("cts-v2cmp-sar.ear");
117             getLog().debug("Deployed cts-v2cmp-sar.ear");
118             InitialContext JavaDoc ctx = new InitialContext JavaDoc();
119             CtsCmp2SessionHome home = (CtsCmp2SessionHome) ctx.lookup("v2/CtsCmp2SessionBean");
120             getLog().debug("Found CtsCmp2SessionHome");
121             CtsCmp2Session session = home.create();
122             getLog().debug("Created CtsCmp2Session");
123             session.testV2();
124             getLog().debug("Invoked CtsCmp2Session.testV2()");
125          }
126          finally
127          {
128             undeploy("cts-v2cmp-sar.ear");
129          } // end of finally
130
}
131       finally
132       {
133          undeploy("cts-v1cmp-sar.ear");
134       } // end of try-catch
135
}
136
137    public static Test suite() throws Exception JavaDoc
138    {
139       TestSuite suite = new TestSuite();
140       suite.addTest(new CtsCmp2UnitTestCase("testV1"));
141       suite.addTest(new CtsCmp2UnitTestCase("testV2"));
142       suite.addTest(new CtsCmp2UnitTestCase("testV1Sar"));
143       suite.addTest(new CtsCmp2UnitTestCase("testV2Sar"));
144       return suite;
145    }
146 }
147
Popular Tags