1 package xdoclet.util.predicates;
2
3 import java.io.File;
4
5 import junit.framework.TestCase;
6
7 import xjavadoc.SourceClass;
8 import xjavadoc.XJavaDoc;
9 import xjavadoc.XTagFactory;
10
11 /***
12 * Test for {@link ReflectionPredicate}.
13 *
14 * @version $Revision: 1.2 $
15 * @author <a href="mailto:mbo@jcs.be">Mathias Bogaert</a>
16 */
17 public class ReflectionPredicateTest extends TestCase {
18 public void testReflectionPredicateBoundaries() {
19 // fucked up tests
20 try {
21 new ReflectionPredicate(null);
22 fail("new ReflectionPredicate(null) does not throw IllegalArgumentException");
23 }
24 catch (IllegalArgumentException e) {
25 // good
26 }
27
28 try {
29 new ReflectionPredicate("");
30 new ReflectionPredicate(" ");
31 fail("new ReflectionPredicate(\"\") does not throw IllegalArgumentException");
32 }
33 catch (IllegalArgumentException e) {
34 // good
35 }
36 }
37
38 public void testBasicReflectionPrediate() {
39 ReflectionPredicate lIsNotAbstractPredicate = new ReflectionPredicate("!isAbstract");
40 ReflectionPredicate lIsNotInnerPredicate = new ReflectionPredicate("!isInner");
41 ReflectionPredicate lIsPublicPredicate = new ReflectionPredicate("isPublic");
42 // Create a Source Code Class to be tested later
43 SourceClass lTestClass = new SourceClass(
44 new XJavaDoc(),
45 new File("src/testdata/util/SimpleTestClass.java"),
46 new XTagFactory()
47 );
48 // Start Testing Simple Test Class
49 assertTrue("SimpleTestClass is not abstract", lIsNotAbstractPredicate.evaluate(lTestClass));
50 assertTrue("SimpleTestClass is not inner", lIsNotInnerPredicate.evaluate(lTestClass));
51 assertTrue("SimpleTestClass is public", lIsPublicPredicate.evaluate(lTestClass));
52 // Create a Abstract Source Code Class to be tested later
53 SourceClass lAsbstractTestClass = new SourceClass(
54 new XJavaDoc(),
55 new File("src/testdata/util/AbstractSimpleTestClass.java"),
56 new XTagFactory()
57 );
58 // Start Testing Abstract Simple Test Class
59 assertFalse("AbstractSimpleTestClass is abstract", lIsNotAbstractPredicate.evaluate(lAsbstractTestClass));
60 assertTrue("AbstractSimpleTestClass is not inner", lIsNotInnerPredicate.evaluate(lAsbstractTestClass));
61 assertTrue("AbstractSimpleTestClass is public", lIsPublicPredicate.evaluate(lAsbstractTestClass));
62 // Create an abstact, private inner class
63 SourceClass lInnerTestClass = new SourceClass(
64 lTestClass,
65 new XTagFactory()
66 );
67 // Start Testing Private Abstract Inner Class Class
68 assertFalse("PrivateAbstractInnerClass is inner", lIsNotInnerPredicate.evaluate(lInnerTestClass));
69 assertFalse("PrivateAbstractInnerClass is not public", lIsPublicPredicate.evaluate(lInnerTestClass));
70 //AS FIXME: Marked the inner class as abstract will fail this test (an abstract private inner class
71 //AS maybe does not make sense but XJavaDoc accepts it but the test fails, so something is wrong
72 //AS assertFalse("PrivateAbstractInnerClass is abstract", lIsNotAbstractPredicate.evaluate(lInnerTestClass));
73 }
74 }
This page was automatically generated by Maven