KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cmp2 > commerce > TxTesterTest


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.cmp2.commerce;
23
24 import java.util.Collection JavaDoc;
25 import java.util.HashSet JavaDoc;
26 import java.util.Set JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import javax.naming.InitialContext JavaDoc;
29 import javax.ejb.EJBLocalObject JavaDoc;
30
31 import junit.framework.Test;
32 import junit.framework.TestCase;
33 import junit.framework.TestSuite;
34 import org.apache.log4j.Category;
35 import net.sourceforge.junitejb.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 JavaDoc 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 JavaDoc {
59       InitialContext JavaDoc jndi = new InitialContext JavaDoc();
60
61       txTesterHome =
62             (TxTesterHome) jndi.lookup("commerce/TxTester");
63    }
64
65    public void testTxTester_none() throws Exception JavaDoc {
66       TxTester txTester = null;
67       try {
68          txTester = txTesterHome.create();
69          boolean result = txTester.accessCMRCollectionWithoutTx();
70
71          if (!result)
72             fail("Expected accessCMRCollectionWithoutTx to throw an exception");
73       } finally {
74          if(txTester != null) {
75             txTester.remove();
76          }
77       }
78    }
79 }
80
Popular Tags