KickJava   Java API By Example, From Geeks To Geeks.

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


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 proxy and proxy-prefetching-limit attributes.
20  *
21  * @author <a HREF="mailto:tomdz@users.sourceforge.net">Thomas Dudziak (tomdz@users.sourceforge.net)</a>
22  */

23 public class ClassTagProxyAttributeTests extends OjbTestBase
24 {
25     public ClassTagProxyAttributeTests(String JavaDoc name)
26     {
27         super(name);
28     }
29
30     // Test of proxy attribute: with no value
31
public void testProxy1()
32     {
33         addClass(
34             "test.A",
35             "package test;\n"+
36             "/** @ojb.class proxy=\"\" */\n"+
37             "public class A {}\n");
38
39         assertEqualsOjbDescriptorFile(
40             "<class-descriptor\n"+
41             " class=\"test.A\"\n"+
42             " table=\"A\"\n"+
43             ">\n"+
44             "</class-descriptor>",
45             runOjbXDoclet(OJB_DEST_FILE));
46         assertEqualsTorqueSchemaFile(
47             "<database name=\"ojbtest\">\n"+
48             " <table name=\"A\">\n"+
49             " </table>\n"+
50             "</database>",
51             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
52     }
53
54     // Test of proxy attribute: with "dynamic" value
55
public void testProxy2()
56     {
57         addClass(
58             "test.A",
59             "package test;\n"+
60             "/** @ojb.class proxy=\"dynamic\" */\n"+
61             "public class A {}\n");
62
63         assertEqualsOjbDescriptorFile(
64             "<class-descriptor\n"+
65             " class=\"test.A\"\n"+
66             " proxy=\"dynamic\"\n"+
67             " table=\"A\"\n"+
68             ">\n"+
69             "</class-descriptor>",
70             runOjbXDoclet(OJB_DEST_FILE));
71         assertEqualsTorqueSchemaFile(
72             "<database name=\"ojbtest\">\n"+
73             " <table name=\"A\">\n"+
74             " </table>\n"+
75             "</database>",
76             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
77     }
78
79     // Test of proxy attribute: with class name value
80
// TODO Check that the class is really there
81
public void testProxy3()
82     {
83         addClass(
84             "test.A",
85             "package test;\n"+
86             "/** @ojb.class proxy=\"SomeProxy\" */\n"+
87             "public class A {}\n");
88
89         assertEqualsOjbDescriptorFile(
90             "<class-descriptor\n"+
91             " class=\"test.A\"\n"+
92             " proxy=\"SomeProxy\"\n"+
93             " table=\"A\"\n"+
94             ">\n"+
95             "</class-descriptor>",
96             runOjbXDoclet(OJB_DEST_FILE));
97         assertEqualsTorqueSchemaFile(
98             "<database name=\"ojbtest\">\n"+
99             " <table name=\"A\">\n"+
100             " </table>\n"+
101             "</database>",
102             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
103     }
104
105     // Test of proxy-prefetching-limit attribute with zero value
106
public void testProxyPrefetchingLimit1()
107     {
108         addClass(
109             "test.A",
110             "package test;\n"+
111             "/** @ojb.class proxy=\"dynamic\"\n" +
112             " * proxy-prefetching-limit=\"0\"\n"+
113             " */\n"+
114             "public class A {}\n");
115
116         assertEqualsOjbDescriptorFile(
117             "<class-descriptor\n"+
118             " class=\"test.A\"\n"+
119             " proxy=\"dynamic\"\n"+
120             " proxy-prefetching-limit=\"0\"\n"+
121             " table=\"A\"\n"+
122             ">\n"+
123             "</class-descriptor>",
124             runOjbXDoclet(OJB_DEST_FILE));
125         assertEqualsTorqueSchemaFile(
126             "<database name=\"ojbtest\">\n"+
127             " <table name=\"A\">\n"+
128             " </table>\n"+
129             "</database>",
130             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
131     }
132
133     // Test of proxy-prefetching-limit attribute with some value
134
public void testProxyPrefetchingLimit2()
135     {
136         addClass(
137             "test.A",
138             "package test;\n"+
139             "/** @ojb.class proxy=\"dynamic\"\n" +
140             " * proxy-prefetching-limit=\"10\"\n"+
141             " */\n"+
142             "public class A {}\n");
143
144         assertEqualsOjbDescriptorFile(
145             "<class-descriptor\n"+
146             " class=\"test.A\"\n"+
147             " proxy=\"dynamic\"\n"+
148             " proxy-prefetching-limit=\"10\"\n"+
149             " table=\"A\"\n"+
150             ">\n"+
151             "</class-descriptor>",
152             runOjbXDoclet(OJB_DEST_FILE));
153         assertEqualsTorqueSchemaFile(
154             "<database name=\"ojbtest\">\n"+
155             " <table name=\"A\">\n"+
156             " </table>\n"+
157             "</database>",
158             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
159     }
160
161     // Test of proxy-prefetching-limit attribute with non-numeric value
162
public void testProxyPrefetchingLimit3()
163     {
164         addClass(
165             "test.A",
166             "package test;\n"+
167             "/** @ojb.class proxy=\"dynamic\"\n" +
168             " * proxy-prefetching-limit=\"abc\"\n"+
169             " */\n"+
170             "public class A {}\n");
171
172         assertNull(runOjbXDoclet(OJB_DEST_FILE));
173         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
174     }
175
176     // Test of proxy-prefetching-limit attribute with illegal value
177
public void testProxyPrefetchingLimit4()
178     {
179         addClass(
180             "test.A",
181             "package test;\n"+
182             "/** @ojb.class proxy=\"dynamic\"\n" +
183             " * proxy-prefetching-limit=\"-2\"\n"+
184             " */\n"+
185             "public class A {}\n");
186
187         assertNull(runOjbXDoclet(OJB_DEST_FILE));
188         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
189     }
190 }
191
Popular Tags