KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > ojb > tests > ClassTagIsolationLevelAttributeTests


1 package xdoclet.modules.ojb.tests;
2
3 /* Copyright 2003-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * 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  */

17
18 /**
19  * Tests for the ojb.class tag with the isolation-level attribute.
20  *
21  * @author <a HREF="mailto:tomdz@users.sourceforge.net">Thomas Dudziak (tomdz@users.sourceforge.net)</a>
22  */

23 public class ClassTagIsolationLevelAttributeTests extends OjbTestBase
24 {
25     public ClassTagIsolationLevelAttributeTests(String JavaDoc name)
26     {
27         super(name);
28     }
29
30     // Test of isolation-level attribute: with empty value
31
public void testIsolationLevel1()
32     {
33         addClass(
34             "test.A",
35             "package test;\n"+
36             "/** @ojb.class isolation-level=\"\" */\n"+
37             "public class A {}\n");
38
39         assertNull(runOjbXDoclet(OJB_DEST_FILE));
40         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
41     }
42
43     // Test of isolation-level attribute: with invalid value
44
public void testIsolationLevel2()
45     {
46         addClass(
47             "test.A",
48             "package test;\n"+
49             "/** @ojb.class isolation-level=\"some\" */\n"+
50             "public class A {}\n");
51
52         assertNull(runOjbXDoclet(OJB_DEST_FILE));
53         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
54     }
55
56     // Test of isolation-level attribute: with 'read-uncommitted' value
57
public void testIsolationLevel3()
58     {
59         addClass(
60             "test.A",
61             "package test;\n"+
62             "/** @ojb.class isolation-level=\"read-uncommitted\" */\n"+
63             "public class A {}\n");
64
65         assertEqualsOjbDescriptorFile(
66             "<class-descriptor\n"+
67             " class=\"test.A\"\n"+
68             " isolation-level=\"read-uncommitted\"\n"+
69             " table=\"A\"\n"+
70             ">\n"+
71             "</class-descriptor>",
72             runOjbXDoclet(OJB_DEST_FILE));
73         assertEqualsTorqueSchemaFile(
74             "<database name=\"ojbtest\">\n"+
75             " <table name=\"A\">\n"+
76             " </table>\n"+
77             "</database>",
78             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
79     }
80
81     // Test of isolation-level attribute: with 'read-committed' value
82
public void testIsolationLevel4()
83     {
84         addClass(
85             "test.A",
86             "package test;\n"+
87             "/** @ojb.class isolation-level=\"read-committed\" */\n"+
88             "public class A {}\n");
89
90         assertEqualsOjbDescriptorFile(
91             "<class-descriptor\n"+
92             " class=\"test.A\"\n"+
93             " isolation-level=\"read-committed\"\n"+
94             " table=\"A\"\n"+
95             ">\n"+
96             "</class-descriptor>",
97             runOjbXDoclet(OJB_DEST_FILE));
98         assertEqualsTorqueSchemaFile(
99             "<database name=\"ojbtest\">\n"+
100             " <table name=\"A\">\n"+
101             " </table>\n"+
102             "</database>",
103             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
104     }
105
106     // Test of isolation-level attribute: with 'repeatable-read' value
107
public void testIsolationLevel5()
108     {
109         addClass(
110             "test.A",
111             "package test;\n"+
112             "/** @ojb.class isolation-level=\"repeatable-read\" */\n"+
113             "public class A {}\n");
114
115         assertEqualsOjbDescriptorFile(
116             "<class-descriptor\n"+
117             " class=\"test.A\"\n"+
118             " isolation-level=\"repeatable-read\"\n"+
119             " table=\"A\"\n"+
120             ">\n"+
121             "</class-descriptor>",
122             runOjbXDoclet(OJB_DEST_FILE));
123         assertEqualsTorqueSchemaFile(
124             "<database name=\"ojbtest\">\n"+
125             " <table name=\"A\">\n"+
126             " </table>\n"+
127             "</database>",
128             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
129     }
130
131     // Test of isolation-level attribute: with 'serializable' value
132
public void testIsolationLevel6()
133     {
134         addClass(
135             "test.A",
136             "package test;\n"+
137             "/** @ojb.class isolation-level=\"serializable\" */\n"+
138             "public class A {}\n");
139
140         assertEqualsOjbDescriptorFile(
141             "<class-descriptor\n"+
142             " class=\"test.A\"\n"+
143             " isolation-level=\"serializable\"\n"+
144             " table=\"A\"\n"+
145             ">\n"+
146             "</class-descriptor>",
147             runOjbXDoclet(OJB_DEST_FILE));
148         assertEqualsTorqueSchemaFile(
149             "<database name=\"ojbtest\">\n"+
150             " <table name=\"A\">\n"+
151             " </table>\n"+
152             "</database>",
153             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
154     }
155
156     // Test of isolation-level attribute: with 'optimistic' value
157
public void testIsolationLevel7()
158     {
159         addClass(
160             "test.A",
161             "package test;\n"+
162             "/** @ojb.class isolation-level=\"optimistic\" */\n"+
163             "public class A {}\n");
164
165         assertEqualsOjbDescriptorFile(
166             "<class-descriptor\n"+
167             " class=\"test.A\"\n"+
168             " isolation-level=\"optimistic\"\n"+
169             " table=\"A\"\n"+
170             ">\n"+
171             "</class-descriptor>",
172             runOjbXDoclet(OJB_DEST_FILE));
173         assertEqualsTorqueSchemaFile(
174             "<database name=\"ojbtest\">\n"+
175             " <table name=\"A\">\n"+
176             " </table>\n"+
177             "</database>",
178             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
179     }
180
181 }
182
Popular Tags