01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.openejb.test.stateful;
17:
18: import org.apache.openejb.test.TestManager;
19: import org.apache.openejb.test.TestFailureException;
20:
21: public class StatefulPersistenceContextTests extends StatefulTestClient {
22:
23: protected PersistenceContextStatefulObject ejbObject;
24: protected PersistenceContextStatefulHome ejbHome;
25:
26: public StatefulPersistenceContextTests() {
27: super ("PERSISTENCE_CONTEXT.");
28: }
29:
30: protected void setUp() throws Exception {
31: super .setUp();
32: ejbHome = (PersistenceContextStatefulHome) initialContext
33: .lookup("client/tests/stateful/PersistenceContextStatefulBean");
34: ejbObject = ejbHome.create();
35:
36: /*[2] Create database table */
37: TestManager.getDatabase().createEntityTable();
38: }
39:
40: /**
41: * Tears down the fixture, for example, close a network connection.
42: * This method is called after a test is executed.
43: */
44: protected void tearDown() throws Exception {
45: try {
46: /*[1] Drop database table */
47: TestManager.getDatabase().dropEntityTable();
48: } catch (Exception e) {
49: throw e;
50: } finally {
51: super .tearDown();
52: }
53: }
54:
55: public void test01_persistenceContext() {
56: try {
57: ejbObject.testPersistenceContext();
58: } catch (TestFailureException e) {
59: throw e.error;
60: } catch (Exception e) {
61: fail("Received Exception " + e.getClass() + " : "
62: + e.getMessage());
63: }
64: }
65:
66: public void test02_extendedPersistenceContext() {
67: try {
68: ejbObject.testExtendedPersistenceContext();
69: } catch (TestFailureException e) {
70: throw e.error;
71: } catch (Exception e) {
72: fail("Received Exception " + e.getClass() + " : "
73: + e.getMessage());
74: }
75: }
76:
77: public void test03_propagatedPersistenceContext() {
78: try {
79: ejbObject.testPropagatedPersistenceContext();
80: } catch (TestFailureException e) {
81: throw e.error;
82: } catch (Exception e) {
83: fail("Received Exception " + e.getClass() + " : "
84: + e.getMessage());
85: }
86: }
87:
88: public void test04_propogation() {
89: try {
90: ejbObject.testPropgation();
91: } catch (TestFailureException e) {
92: throw e.error;
93: } catch (Exception e) {
94: fail("Received Exception " + e.getClass() + " : "
95: + e.getMessage());
96: }
97: }
98: }
|