01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * 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.cmp2.commerce;
23:
24: import java.util.Collection;
25: import java.util.HashSet;
26: import java.util.Set;
27: import java.util.Iterator;
28: import javax.naming.InitialContext;
29: import javax.ejb.EJBLocalObject;
30:
31: import junit.framework.Test;
32: import junit.framework.TestCase;
33: import junit.framework.TestSuite;
34: import org.apache.log4j.Category;
35: import org.jboss.test.util.ejb.EJBTestCase;
36:
37: public class TxTesterTest extends EJBTestCase {
38: public static Test suite() {
39: TestSuite testSuite = new TestSuite("TxTesterTest");
40: testSuite.addTestSuite(TxTesterTest.class);
41: return testSuite;
42: }
43:
44: public TxTesterTest(String name) {
45: super (name);
46: }
47:
48: private Category log = Category.getInstance(getClass());
49: private TxTesterHome txTesterHome;
50:
51: /**
52: * Looks up all of the home interfaces and creates the initial data.
53: * Looking up objects in JNDI is expensive, so it should be done once
54: * and cached.
55: * @throws Exception if a problem occures while finding the home interfaces,
56: * or if an problem occures while createing the initial data
57: */
58: public void setUp() throws Exception {
59: InitialContext jndi = new InitialContext();
60:
61: txTesterHome = (TxTesterHome) jndi.lookup("commerce/TxTester");
62: }
63:
64: public void testTxTester_none() throws Exception {
65: TxTester txTester = null;
66: try {
67: txTester = txTesterHome.create();
68: boolean result = txTester.accessCMRCollectionWithoutTx();
69:
70: if (!result)
71: fail("Expected accessCMRCollectionWithoutTx to throw an exception");
72: } finally {
73: if (txTester != null) {
74: txTester.remove();
75: }
76: }
77: }
78: }
|