KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jca > test > LocalWrapperCleanupUnitTestCase


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.jca.test;
23
24 import org.jboss.test.JBossTestCase;
25 import junit.framework.Test;
26 import org.jboss.test.jca.interfaces.LocalWrapperCleanupTestSessionHome;
27 import org.jboss.test.jca.interfaces.LocalWrapperCleanupTestSession;
28 import javax.transaction.UserTransaction JavaDoc;
29
30 /**
31  * LocalWrapperCleanupUnitTestCase.java
32  *
33  *
34  * Created: Thu May 23 17:20:54 2002
35  *
36  * @author <a HREF="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
37  * @version
38  */

39
40 public class LocalWrapperCleanupUnitTestCase extends JBossTestCase
41 {
42    LocalWrapperCleanupTestSessionHome sh;
43    LocalWrapperCleanupTestSession s;
44
45
46    public LocalWrapperCleanupUnitTestCase (String JavaDoc name)
47    {
48       super(name);
49    }
50
51    protected void setUp() throws Exception JavaDoc
52    {
53       sh = (LocalWrapperCleanupTestSessionHome)getInitialContext().lookup("LocalWrapperCleanupTestSession");
54       s = sh.create();
55    }
56
57    protected void tearDown() throws Exception JavaDoc
58    {
59    }
60
61    public static Test suite() throws Exception JavaDoc
62    {
63       Test t1 = getDeploySetup(LocalWrapperCleanupUnitTestCase.class, "jcatest.jar");
64       Test t2 = getDeploySetup(t1, "hsqldb-singleconnection-ds.xml");
65       Test t3 = getDeploySetup(t2, "testadapter-ds.xml");
66       return getDeploySetup(t3, "jbosstestadapter.rar");
67    }
68
69
70    /**
71     * The <code>testAutoCommitInReturnedConnection</code> method tests that
72     * if you set autocommit off and return a connection to the pool, when you
73     * get it back, autocommit is on again.
74     *
75     * @exception Exception if an error occurs
76     */

77    public void testAutoCommitInReturnedConnection() throws Exception JavaDoc
78    {
79       s.testAutoCommitInReturnedConnection();
80    }
81
82    public void testReadOnly() throws Exception JavaDoc
83    {
84       s.testReadOnly();
85    }
86
87    /**
88     * The <code>testAutoCommit</code> method tests that autocommit is really on
89     * when connections are obtained from the pool.
90     *
91     * @exception Exception if an error occurs
92     */

93    public void testAutoCommit() throws Exception JavaDoc
94    {
95       s.testAutoCommit();
96    }
97
98
99    /**
100     * The <code>testAutoCommitOffInUserTx</code> method tests that an
101     * explicit tx started with usertx turns off autocommit. This
102     * should have a different target bean that is BMT. NotSupported
103     * works, but it probably shouldn't.
104     *
105     * @exception Exception if an error occurs
106     */

107    public void testAutoCommitOffInUserTx() throws Exception JavaDoc
108    {
109       s.testAutoCommitOffInUserTx();
110    }
111
112    /**
113     * The <code>testAutoCommitOffInUserTx2</code> method tests the same thing
114     * with the connection re-obtained after the tx is started. This
115     * should have a different target bean that is BMT. NotSupported
116     * works, but it probably shouldn't.
117     *
118     * @exception Exception if an error occurs
119     */

120    public void testAutoCommitOffInUserTx2() throws Exception JavaDoc
121    {
122       s.testAutoCommitOffInUserTx2();
123    }
124
125    /**
126     * The <code>testAutoCommitOffInRemoteUserTx</code> method tests the same
127     * operations but all called from here: thus the operations presumably occur
128     * in different threads.
129     *
130     * @exception Exception if an error occurs
131     */

132    public void testAutoCommitOffInRemoteUserTx() throws Exception JavaDoc
133    {
134       try
135       {
136          s.createTable();
137          UserTransaction JavaDoc ut = (UserTransaction JavaDoc)getInitialContext().lookup("UserTransaction");
138          ut.begin();
139          s.insertAndCheckAutoCommit();
140          ut.rollback();
141       }
142       finally
143       {
144          s.checkRowAndDropTable();
145       } // end of try-catch
146

147    }
148
149    /*This test requires a real database with actual transaction isolation, not hsqldb.
150    public void testTxIsolationInReturnedConnection() throws Exception
151    {
152       s.testTxIsolationInReturnedConnection();
153    }
154    */

155
156    public void testManualNoCommitRollback() throws Exception JavaDoc
157    {
158       try
159       {
160          s.createTable();
161          s.testManualNoCommitRollback();
162       }
163       finally
164       {
165          s.addRowCheckAndDropTable();
166       }
167    }
168
169    public void testManualSecondNoCommitRollback() throws Exception JavaDoc
170    {
171       try
172       {
173          s.createTable();
174          s.testManualSecondNoCommitRollback();
175       }
176       finally
177       {
178          s.addRowCheckAndDropTable();
179       }
180    }
181
182 }
183
Popular Tags