001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.kuali.core.datadictionary;
018:
019: import org.apache.commons.beanutils.ConversionException;
020: import org.apache.log4j.Level;
021: import org.junit.Before;
022: import org.junit.Test;
023: import org.kuali.core.datadictionary.exception.ClassValidationException;
024: import org.kuali.core.datadictionary.exception.DuplicateEntryException;
025: import org.kuali.rice.KNSServiceLocator;
026: import org.kuali.test.KNSTestBase;
027: import org.kuali.test.KNSWithTestSpringContext;
028:
029: /**
030: * This class is used to test the DataDictionaryBuilder Maintenance Document
031: * object.
032: *
033: *
034: */
035: @KNSWithTestSpringContext
036: public class DataDictionaryBuilder_MaintenanceDocumentTest extends
037: KNSTestBase {
038:
039: DataDictionaryBuilder builder = null;
040:
041: @Before
042: public void setUp() throws Exception {
043: super .setUp();
044:
045: builder = new DataDictionaryBuilder(KNSServiceLocator
046: .getValidationCompletionUtils());
047:
048: // quieten things down a bit
049: setLogLevel("org.apache.commons.digester", Level.FATAL);
050: setLogLevel("org.kuali.bo.datadictionary.XmlErrorHandler",
051: Level.FATAL);
052: }
053:
054: @Test
055: public final void testDataDictionaryBuilder_maintenanceDocument_blankBusinessObjectClass() {
056: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
057: + "md/BlankBusinessObjectClass.xml";
058:
059: boolean failedAsExpected = false;
060:
061: try {
062: builder.addUniqueEntries(INPUT_FILE, true);
063: builder.parseBO("BlankBusinessObjectClass", true);
064: } catch (DataDictionaryException e) {
065: failedAsExpected = true;
066: }
067:
068: assertTrue(failedAsExpected);
069: }
070:
071: @Test
072: public final void testDataDictionaryBuilder_maintenanceDocument_blankFieldName() {
073: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
074: + "md/BlankFieldName.xml";
075:
076: boolean failedAsExpected = false;
077:
078: try {
079: builder.addUniqueEntries(INPUT_FILE, true);
080: builder.parseBO("BlankFieldName", true);
081: } catch (DataDictionaryException e) {
082: failedAsExpected = true;
083: }
084:
085: assertTrue(failedAsExpected);
086: }
087:
088: @Test
089: public final void testDataDictionaryBuilder_maintenanceDocument_blankMaintainableClass() {
090: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
091: + "md/BlankMaintainableClass.xml";
092:
093: boolean failedAsExpected = false;
094:
095: try {
096: builder.addUniqueEntries(INPUT_FILE, true);
097: builder.parseBO("BlankMaintainableClass", true);
098: } catch (DataDictionaryException e) {
099: failedAsExpected = true;
100: }
101:
102: assertTrue(failedAsExpected);
103: }
104:
105: @Test
106: public final void testDataDictionaryBuilder_maintenanceDocument_blankSectionTitle() {
107: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
108: + "md/BlankSectionTitle.xml";
109:
110: boolean failedAsExpected = false;
111:
112: try {
113: builder.addUniqueEntries(INPUT_FILE, true);
114: builder.parseBO("BlankSectionTitle", true);
115: } catch (DataDictionaryException e) {
116: failedAsExpected = true;
117: }
118:
119: assertTrue(failedAsExpected);
120: }
121:
122: @Test
123: public final void testDataDictionaryBuilder_maintenanceDocument_duplicateFieldName() {
124: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
125: + "md/DuplicateFieldName.xml";
126:
127: boolean failedAsExpected = false;
128:
129: try {
130: builder.addUniqueEntries(INPUT_FILE, true);
131: builder.parseBO("DuplicateFieldName", true);
132: } catch (DataDictionaryException e) {
133: if (DataDictionaryUtils.saxCause(e) instanceof DuplicateEntryException) {
134: failedAsExpected = true;
135: }
136: }
137:
138: assertTrue(failedAsExpected);
139: }
140:
141: @Test
142: public final void testDataDictionaryBuilder_maintenanceDocument_duplicateSectionTitle() {
143: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
144: + "md/DuplicateSectionTitle.xml";
145:
146: boolean failedAsExpected = false;
147:
148: try {
149: builder.addUniqueEntries(INPUT_FILE, true);
150: builder.parseBO("DuplicateSectionTitle", true);
151: } catch (DataDictionaryException e) {
152: if (DataDictionaryUtils.saxCause(e) instanceof DuplicateEntryException) {
153: failedAsExpected = true;
154: }
155: }
156:
157: assertTrue(failedAsExpected);
158: }
159:
160: @Test
161: public final void testDataDictionaryBuilder_maintenanceDocument_invalid() {
162: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
163: + "md/InvalidMaintenanceDocument.xml";
164:
165: boolean failedAsExpected = false;
166:
167: try {
168: builder.addUniqueEntries(INPUT_FILE, true);
169: builder.parseBO("InvalidMaintenanceDocument", true);
170: } catch (DataDictionaryException e) {
171: if (DataDictionaryUtils.saxCause(e) instanceof IllegalStateException) {
172: failedAsExpected = true;
173: } else {
174: throw e;
175: }
176: }
177:
178: assertTrue(failedAsExpected);
179: }
180:
181: @Test
182: public final void testDataDictionaryBuilder_maintenanceDocument_invalidBusinessObjectClass() {
183: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
184: + "md/InvalidBusinessObjectClass.xml";
185:
186: boolean failedAsExpected = false;
187:
188: try {
189: builder.addUniqueEntries(INPUT_FILE, true);
190: builder.parseBO("InvalidBusinessObjectClass", true);
191: } catch (DataDictionaryException e) {
192: if (DataDictionaryUtils.saxCause(e) instanceof ClassValidationException) {
193: failedAsExpected = true;
194: }
195: }
196:
197: assertTrue(failedAsExpected);
198: }
199:
200: @Test
201: public final void testDataDictionaryBuilder_maintenanceDocument_invalidMaintainableClass() {
202: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
203: + "md/InvalidMaintainableClass.xml";
204:
205: boolean failedAsExpected = false;
206:
207: try {
208: builder.addUniqueEntries(INPUT_FILE, true);
209: builder.parseBO("InvalidMaintainableClass", true);
210: } catch (DataDictionaryException e) {
211: if (DataDictionaryUtils.saxCause(e) instanceof ClassValidationException) {
212: failedAsExpected = true;
213: }
214: }
215:
216: assertTrue(failedAsExpected);
217: }
218:
219: @Test
220: public final void testDataDictionaryBuilder_maintenanceDocument_unknownBusinessObjectClass() {
221: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
222: + "md/UnknownBusinessObjectClass.xml";
223:
224: boolean failedAsExpected = false;
225:
226: try {
227: builder.addUniqueEntries(INPUT_FILE, true);
228: builder.parseBO("UnknownBusinessObjectClass", true);
229: } catch (DataDictionaryException e) {
230: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
231: failedAsExpected = true;
232: }
233: }
234:
235: assertTrue(failedAsExpected);
236: }
237:
238: @Test
239: public final void testDataDictionaryBuilder_maintenanceDocument_unknownMaintainableClass() {
240: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
241: + "md/UnknownMaintainableClass.xml";
242:
243: boolean failedAsExpected = false;
244:
245: try {
246: builder.addUniqueEntries(INPUT_FILE, true);
247: builder.parseBO("UnknownMaintainableClass", true);
248: } catch (DataDictionaryException e) {
249: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
250: failedAsExpected = true;
251: }
252: }
253:
254: assertTrue(failedAsExpected);
255: }
256:
257: @Test
258: public final void testDataDictionaryBuilder_maintenanceDocument_MCBlankCollectionName() {
259: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
260: + "md/MCBlankCollectionName.xml";
261:
262: boolean failedAsExpected = false;
263:
264: try {
265: builder.addUniqueEntries(INPUT_FILE, true);
266: builder.parseBO("MCBlankCollectionName", true);
267: } catch (DataDictionaryException e) {
268: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
269: failedAsExpected = true;
270: }
271: }
272:
273: assertTrue(failedAsExpected);
274: }
275:
276: @Test
277: public final void testDataDictionaryBuilder_maintenanceDocument_MCBlankBusinessObjectClass() {
278: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
279: + "md/MCBlankBusinessObjectClass.xml";
280:
281: boolean failedAsExpected = false;
282:
283: try {
284: builder.addUniqueEntries(INPUT_FILE, true);
285: builder.parseBO("MCBlankBusinessObjectClass", true);
286: } catch (DataDictionaryException e) {
287: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
288: failedAsExpected = true;
289: }
290: }
291:
292: assertTrue(failedAsExpected);
293: }
294:
295: @Test
296: public final void testDataDictionaryBuilder_maintenanceDocument_MCBlankFieldName() {
297: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
298: + "md/MCBlankFieldName.xml";
299:
300: boolean failedAsExpected = false;
301:
302: try {
303: builder.addUniqueEntries(INPUT_FILE, true);
304: builder.parseBO("MCBlankFieldName", true);
305: } catch (DataDictionaryException e) {
306: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
307: failedAsExpected = true;
308: }
309: }
310:
311: assertTrue(failedAsExpected);
312: }
313:
314: @Test
315: public final void testDataDictionaryBuilder_maintenanceDocument_MCDuplicateCollectionName() {
316: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
317: + "md/MCDuplicateCollectionName.xml";
318:
319: boolean failedAsExpected = false;
320:
321: try {
322: builder.addUniqueEntries(INPUT_FILE, true);
323: builder.parseBO("MCDuplicateCollectionName", true);
324: } catch (DataDictionaryException e) {
325: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
326: failedAsExpected = true;
327: }
328: }
329:
330: assertTrue(failedAsExpected);
331: }
332:
333: @Test
334: public final void testDataDictionaryBuilder_maintenanceDocument_MCInvalidBusinessObjectClass() {
335: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
336: + "md/MCInvalidBusinessObjectClass.xml";
337:
338: boolean failedAsExpected = false;
339:
340: try {
341: builder.addUniqueEntries(INPUT_FILE, true);
342: builder.parseBO("MCInvalidBusinessObjectClass", true);
343: } catch (DataDictionaryException e) {
344: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
345: failedAsExpected = true;
346: }
347: }
348:
349: assertTrue(failedAsExpected);
350: }
351:
352: @Test
353: public final void testDataDictionaryBuilder_maintenanceDocument_MCMissingFields() {
354: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
355: + "md/MCMissingFields.xml";
356:
357: boolean failedAsExpected = false;
358:
359: try {
360: builder.addUniqueEntries(INPUT_FILE, true);
361: builder.parseBO("MCMissingFields", true);
362: } catch (DataDictionaryException e) {
363: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
364: failedAsExpected = true;
365: }
366: }
367:
368: assertTrue(failedAsExpected);
369: }
370:
371: @Test
372: public final void testDataDictionaryBuilder_maintenanceDocument_MCUnknownBusinessObjectClass() {
373: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
374: + "md/MCUnknownBusinessObjectClass.xml";
375:
376: boolean failedAsExpected = false;
377:
378: try {
379: builder.addUniqueEntries(INPUT_FILE, true);
380: builder.parseBO("MCUnknownBusinessObjectClass", true);
381: } catch (DataDictionaryException e) {
382: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
383: failedAsExpected = true;
384: }
385: }
386:
387: assertTrue(failedAsExpected);
388: }
389:
390: @Test
391: public final void testDataDictionaryBuilder_maintenanceDocument_MCUnknownField() {
392: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
393: + "md/MCUnknownField.xml";
394:
395: boolean failedAsExpected = false;
396:
397: try {
398: builder.addUniqueEntries(INPUT_FILE, true);
399: builder.parseBO("MCUnknownField", true);
400: } catch (DataDictionaryException e) {
401: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
402: failedAsExpected = true;
403: }
404: }
405:
406: assertTrue(failedAsExpected);
407: }
408:
409: @Test
410: public final void testDataDictionaryBuilder_maintenanceDocument_MCInvalidField() {
411: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
412: + "md/MCInvalidField.xml";
413:
414: boolean failedAsExpected = false;
415:
416: try {
417: builder.addUniqueEntries(INPUT_FILE, true);
418: builder.parseBO("MCInvalidField", true);
419: } catch (DataDictionaryException e) {
420: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
421: failedAsExpected = true;
422: }
423: }
424:
425: assertTrue(failedAsExpected);
426: }
427:
428: @Test
429: public final void testDataDictionaryBuilder_maintenanceDocument_businessRulesClass_blank() {
430: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
431: + "md/BRBlank.xml";
432:
433: boolean failedAsExpected = false;
434:
435: try {
436: builder.addUniqueEntries(INPUT_FILE, true);
437: builder.parseBO("BRBlank", true);
438: } catch (DataDictionaryException e) {
439: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
440: failedAsExpected = true;
441: }
442: }
443:
444: assertTrue(failedAsExpected);
445: }
446:
447: @Test
448: public final void testDataDictionaryBuilder_maintenanceDocument_businessRulesClass_invalid() {
449: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
450: + "md/BRInvalid.xml";
451:
452: boolean failedAsExpected = false;
453:
454: try {
455: builder.addUniqueEntries(INPUT_FILE, true);
456: builder.parseBO("BRInvalid", true);
457: } catch (DataDictionaryException e) {
458: if (DataDictionaryUtils.saxCause(e) instanceof ClassValidationException) {
459: failedAsExpected = true;
460: }
461: }
462:
463: assertTrue(failedAsExpected);
464: }
465:
466: @Test
467: public final void testDataDictionaryBuilder_maintenanceDocument_authorization_blankAction() {
468: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
469: + "md/AuthBlankAction.xml";
470:
471: boolean failedAsExpected = false;
472:
473: try {
474: builder.addUniqueEntries(INPUT_FILE, true);
475: builder.parseBO("AuthBlankAction", true);
476: } catch (DataDictionaryException e) {
477: if (DataDictionaryUtils.saxCause(e) instanceof IllegalArgumentException) {
478: failedAsExpected = true;
479: }
480: }
481:
482: assertTrue(failedAsExpected);
483: }
484:
485: @Test
486: public final void testDataDictionaryBuilder_maintenanceDocument_authorization_blankWorkgroup() {
487: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
488: + "md/AuthBlankWorkgroup.xml";
489:
490: boolean failedAsExpected = false;
491:
492: try {
493: builder.addUniqueEntries(INPUT_FILE, true);
494: builder.parseBO("AuthBlankWorkgroup", true);
495: } catch (DataDictionaryException e) {
496: if (DataDictionaryUtils.saxCause(e) instanceof IllegalArgumentException) {
497: failedAsExpected = true;
498: }
499: }
500:
501: assertTrue(failedAsExpected);
502: }
503:
504: @Test
505: public final void testDataDictionaryBuilder_maintenanceDocument_authorization_emptyAuthorization() {
506: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
507: + "md/AuthEmptyAuthorization.xml";
508:
509: boolean failedAsExpected = false;
510:
511: try {
512: builder.addUniqueEntries(INPUT_FILE, true);
513: builder.parseBO("AuthEmptyAuthorization", true);
514: } catch (DataDictionaryException e) {
515: if (DataDictionaryUtils.saxCaused(e)) {
516: failedAsExpected = true;
517: }
518: }
519:
520: assertTrue(failedAsExpected);
521: }
522:
523: @Test
524: public final void testDataDictionaryBuilder_maintenanceDocument_authorization_emptyAuthorizationsSection() {
525: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
526: + "md/AuthEmptyAuthorizationsSection.xml";
527:
528: boolean failedAsExpected = false;
529:
530: try {
531: builder.addUniqueEntries(INPUT_FILE, true);
532: builder.parseBO("AuthEmptyAuthorizationsSection", true);
533: } catch (DataDictionaryException e) {
534: if (DataDictionaryUtils.saxCaused(e)) {
535: failedAsExpected = true;
536: }
537: }
538:
539: assertTrue(failedAsExpected);
540: }
541:
542: @Test
543: public final void testDataDictionaryBuilder_maintenanceDocument_authorization_emptyWorkgroupsList() {
544: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
545: + "md/AuthEmptyWorkgroupsList.xml";
546:
547: boolean failedAsExpected = false;
548:
549: try {
550: builder.addUniqueEntries(INPUT_FILE, true);
551: builder.parseBO("AuthEmptyWorkgroupsList", true);
552: } catch (DataDictionaryException e) {
553: if (DataDictionaryUtils.saxCaused(e)) {
554: failedAsExpected = true;
555: }
556: }
557:
558: assertTrue(failedAsExpected);
559: }
560:
561: @Test
562: public final void testDataDictionaryBuilder_maintenanceDocument_authorization_missingAction() {
563: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
564: + "md/AuthMissingAction.xml";
565:
566: boolean failedAsExpected = false;
567:
568: try {
569: builder.addUniqueEntries(INPUT_FILE, true);
570: builder.parseBO("AuthMissingAction", true);
571: } catch (DataDictionaryException e) {
572: if (DataDictionaryUtils.saxCaused(e)) {
573: failedAsExpected = true;
574: }
575: }
576:
577: assertTrue(failedAsExpected);
578: }
579:
580: @Test
581: public final void testDataDictionaryBuilder_maintenanceDocument_authorization_missingAuthorizationsSection() {
582: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
583: + "md/AuthMissingAuthorizationsSection.xml";
584:
585: boolean failedAsExpected = false;
586:
587: try {
588: builder.addUniqueEntries(INPUT_FILE, true);
589: builder.parseBO("AuthMissingAuthorizationsSection", true);
590: } catch (DataDictionaryException e) {
591: if (DataDictionaryUtils.saxCaused(e)) {
592: failedAsExpected = true;
593: }
594: }
595:
596: assertTrue(failedAsExpected);
597: }
598:
599: @Test
600: public final void testDataDictionaryBuilder_maintenanceDocument_documentAuthorizer_missingAuthorizerClass() {
601: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
602: + "md/DocAuthMissing.xml";
603:
604: boolean failedAsExpected = false;
605:
606: try {
607: builder.addUniqueEntries(INPUT_FILE, true);
608: builder.parseBO("DocAuthMissing", true);
609: } catch (DataDictionaryException e) {
610: if (DataDictionaryUtils.saxCaused(e)) {
611: failedAsExpected = true;
612: }
613: }
614:
615: assertTrue(failedAsExpected);
616: }
617:
618: @Test
619: public final void testDataDictionaryBuilder_maintenanceDocument_documentAuthorizer_blankAuthorizerClass() {
620: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
621: + "md/DocAuthBlank.xml";
622:
623: boolean failedAsExpected = false;
624:
625: try {
626: builder.addUniqueEntries(INPUT_FILE, true);
627: builder.parseBO("DocAuthBlank", true);
628: } catch (DataDictionaryException e) {
629: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
630: failedAsExpected = true;
631: }
632: }
633:
634: assertTrue(failedAsExpected);
635: }
636:
637: @Test
638: public final void testDataDictionaryBuilder_maintenanceDocument_documentAuthorizer_unknownAuthorizerClass() {
639: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
640: + "md/DocAuthUnknown.xml";
641:
642: boolean failedAsExpected = false;
643:
644: try {
645: builder.addUniqueEntries(INPUT_FILE, true);
646: builder.parseBO("DocAuthUnknown", true);
647: } catch (DataDictionaryException e) {
648: if (DataDictionaryUtils.saxCause(e) instanceof ConversionException) {
649: failedAsExpected = true;
650: }
651: }
652:
653: assertTrue(failedAsExpected);
654: }
655:
656: @Test
657: public final void testDataDictionaryBuilder_maintenanceDocument_documentAuthorizer_invalidAuthorizerClass() {
658: String INPUT_FILE = DataDictionaryBuilderTest.TESTPACKAGE_INVALID
659: + "md/DocAuthInvalid.xml";
660:
661: boolean failedAsExpected = false;
662:
663: try {
664: builder.addUniqueEntries(INPUT_FILE, true);
665: builder.parseDocument("DocAuthInvalid", true);
666: } catch (DataDictionaryException e) {
667: if (DataDictionaryUtils.saxCause(e) instanceof ClassValidationException) {
668: failedAsExpected = true;
669: }
670: }
671:
672: assertTrue(failedAsExpected);
673: }
674: }
|