KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > test > views > ViewCreationTest


1 /*
2  * Copyright 2002 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: ViewCreationTest.java,v 1.3 2003/10/18 22:05:17 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.test.views;
12
13 import com.triactive.jdo.test.*;
14 import javax.jdo.JDOFatalUserException;
15
16
17 /**
18  * Tests the creation of views when auto-create tables is on.
19  *
20  * @author <a HREF="mailto:pierreg0@users.sourceforge.net">Kelly Grizzle</a>
21  * @version $Revision: 1.3 $
22  */

23
24 public class ViewCreationTest extends PersistenceTestCase
25 {
26
27     /**
28      * Used by the JUnit framework to construct tests. Normally, programmers
29      * would never explicitly use this constructor.
30      *
31      * @param name Name of the <tt>TestCase</tt>.
32      */

33
34     public ViewCreationTest(String JavaDoc name)
35     {
36         super(name);
37     }
38
39
40     protected void setUp() throws Exception JavaDoc
41     {
42         super.setUp();
43
44         schemaMgr.dropTablesFor(new Class JavaDoc[]
45             {
46                 DependentView.class,
47                 ReliedOnView.class
48             }
49         );
50
51         addClassesToSchema(new Class JavaDoc[] { Widget.class });
52     }
53
54
55     /**
56      * Test creating views with the dependent view created first.
57      */

58     public void testCreatingDependentFirst()
59         throws Exception JavaDoc
60     {
61         addClassesToSchema(new Class JavaDoc[]
62             {
63                 DependentView.class,
64                 ReliedOnView.class
65             }
66         );
67     }
68
69
70     /**
71      * Test creating views with the relied on view created first.
72      */

73     public void testCreatingReliedOnFirst()
74         throws Exception JavaDoc
75     {
76         addClassesToSchema(new Class JavaDoc[]
77             {
78                 ReliedOnView.class,
79                 DependentView.class
80             }
81         );
82     }
83
84
85     /**
86      * Test that creating views with circular dependencies fails.
87      */

88     public void testCircularViewDependencies()
89     {
90         /*
91          * Try creating with one view. Others should be pulled in through reference.
92          */

93         try
94         {
95             addClassesToSchema(new Class JavaDoc[]
96                 {
97                     CircularReferenceView1.class
98                 }
99             );
100             fail("Creating a view with a circular dependency should have thrown exception.");
101         }
102         catch (JDOFatalUserException e) { /* Ignore */ }
103
104         try
105         {
106             addClassesToSchema(new Class JavaDoc[]
107                 {
108                     CircularReferenceView2.class
109                 }
110             );
111             fail("Creating a view with a circular dependency should have thrown exception.");
112         }
113         catch (JDOFatalUserException e) { /* Ignore */ }
114
115         try
116         {
117             addClassesToSchema(new Class JavaDoc[]
118                 {
119                     CircularReferenceView3.class
120                 }
121             );
122             fail("Creating a view with a circular dependency should have thrown exception.");
123         }
124         catch (JDOFatalUserException e) { /* Ignore */ }
125
126
127         /*
128          * Try creating with two views. Other should be pulled in through reference.
129          */

130         try
131         {
132             addClassesToSchema(new Class JavaDoc[]
133                 {
134                     CircularReferenceView1.class,
135                     CircularReferenceView2.class
136                 }
137             );
138             fail("Creating a view with a circular dependency should have thrown exception.");
139         }
140         catch (JDOFatalUserException e) { /* Ignore */ }
141         try
142         {
143             addClassesToSchema(new Class JavaDoc[]
144                 {
145                     CircularReferenceView2.class,
146                     CircularReferenceView1.class
147                 }
148             );
149             fail("Creating a view with a circular dependency should have thrown exception.");
150         }
151         catch (JDOFatalUserException e) { /* Ignore */ }
152
153         try
154         {
155             addClassesToSchema(new Class JavaDoc[]
156                 {
157                     CircularReferenceView1.class,
158                     CircularReferenceView3.class
159                 }
160             );
161             fail("Creating a view with a circular dependency should have thrown exception.");
162         }
163         catch (JDOFatalUserException e) { /* Ignore */ }
164         try
165         {
166             addClassesToSchema(new Class JavaDoc[]
167                 {
168                     CircularReferenceView3.class,
169                     CircularReferenceView1.class
170                 }
171             );
172             fail("Creating a view with a circular dependency should have thrown exception.");
173         }
174         catch (JDOFatalUserException e) { /* Ignore */ }
175
176         try
177         {
178             addClassesToSchema(new Class JavaDoc[]
179                 {
180                     CircularReferenceView2.class,
181                     CircularReferenceView3.class
182                 }
183             );
184             fail("Creating a view with a circular dependency should have thrown exception.");
185         }
186         catch (JDOFatalUserException e) { /* Ignore */ }
187         try
188         {
189             addClassesToSchema(new Class JavaDoc[]
190                 {
191                     CircularReferenceView3.class,
192                     CircularReferenceView2.class
193                 }
194             );
195             fail("Creating a view with a circular dependency should have thrown exception.");
196         }
197         catch (JDOFatalUserException e) { /* Ignore */ }
198
199
200         /*
201          * Try creating with three views.
202          */

203         try
204         {
205             addClassesToSchema(new Class JavaDoc[]
206                 {
207                     CircularReferenceView1.class,
208                     CircularReferenceView2.class,
209                     CircularReferenceView3.class
210                 }
211             );
212             fail("Creating a view with a circular dependency should have thrown exception.");
213         }
214         catch (JDOFatalUserException e) { /* Ignore */ }
215
216         try
217         {
218             addClassesToSchema(new Class JavaDoc[]
219                 {
220                     CircularReferenceView1.class,
221                     CircularReferenceView3.class,
222                     CircularReferenceView2.class
223                 }
224             );
225             fail("Creating a view with a circular dependency should have thrown exception.");
226         }
227         catch (JDOFatalUserException e) { /* Ignore */ }
228
229         try
230         {
231             addClassesToSchema(new Class JavaDoc[]
232                 {
233                     CircularReferenceView2.class,
234                     CircularReferenceView1.class,
235                     CircularReferenceView3.class
236                 }
237             );
238             fail("Creating a view with a circular dependency should have thrown exception.");
239         }
240         catch (JDOFatalUserException e) { /* Ignore */ }
241
242         try
243         {
244             addClassesToSchema(new Class JavaDoc[]
245                 {
246                     CircularReferenceView2.class,
247                     CircularReferenceView3.class,
248                     CircularReferenceView1.class
249                 }
250             );
251             fail("Creating a view with a circular dependency should have thrown exception.");
252         }
253         catch (JDOFatalUserException e) { /* Ignore */ }
254
255         try
256         {
257             addClassesToSchema(new Class JavaDoc[]
258                 {
259                     CircularReferenceView3.class,
260                     CircularReferenceView1.class,
261                     CircularReferenceView2.class
262                 }
263             );
264             fail("Creating a view with a circular dependency should have thrown exception.");
265         }
266         catch (JDOFatalUserException e) { /* Ignore */ }
267
268         try
269         {
270             addClassesToSchema(new Class JavaDoc[]
271                 {
272                     CircularReferenceView3.class,
273                     CircularReferenceView2.class,
274                     CircularReferenceView1.class
275                 }
276             );
277             fail("Creating a view with a circular dependency should have thrown exception.");
278         }
279         catch (JDOFatalUserException e) { /* Ignore */ }
280     }
281 }
282
Popular Tags