- Revision
- 1442
- Author
- rfscholte
- Date
- 2011-10-23 16:15:13 -0500 (Sun, 23 Oct 2011)
Log Message
Add tests for modifiers
Modified Paths
- trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaClassTest.java
- trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaConstructorTest.java
- trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaFieldTest.java
- trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaMethodTest.java
Diff
Modified: trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaClassTest.java (1441 => 1442)
--- trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaClassTest.java 2011-10-23 20:42:53 UTC (rev 1441) +++ trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaClassTest.java 2011-10-23 21:15:13 UTC (rev 1442) @@ -409,14 +409,54 @@ assertEquals(expected, cls.getCodeBlock()); } - public void testIsPublic() { - setName(cls, "MyClass"); - assertTrue(!cls.isPublic()); + public void testIsPublic() + { + assertTrue( !cls.isPublic() ); - setModifiers(cls, Arrays.asList(new String[]{"public"})); - assertTrue(cls.isPublic()); + setModifiers( cls, Arrays.asList( new String[] { "public" } ) ); + assertTrue( cls.isPublic() ); } + public void testIsProtected() + { + assertTrue( !cls.isProtected() ); + + setModifiers( cls, Arrays.asList( new String[] { "protected" } ) ); + assertTrue( cls.isProtected() ); + } + + public void testIsPrivate() + { + assertTrue( !cls.isPrivate() ); + + setModifiers( cls, Arrays.asList( new String[] { "private" } ) ); + assertTrue( cls.isPrivate() ); + } + + public void testIsAbstract() + { + assertTrue( !cls.isAbstract() ); + + setModifiers( cls, Arrays.asList( new String[] { "abstract" } ) ); + assertTrue( cls.isAbstract() ); + } + + public void testIsFinal() + { + assertTrue( !cls.isFinal() ); + + setModifiers( cls, Arrays.asList( new String[] { "final" } ) ); + assertTrue( cls.isFinal() ); + } + + public void testIsStatic() + { + assertTrue( !cls.isStatic() ); + + setModifiers( cls, Arrays.asList( new String[] { "static" } ) ); + assertTrue( cls.isStatic() ); + } + public void testQualifiedType() throws Exception { setPackage(src, newJavaPackage("com.thoughtworks.qdox"));
Modified: trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaConstructorTest.java (1441 => 1442)
--- trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaConstructorTest.java 2011-10-23 20:42:53 UTC (rev 1441) +++ trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaConstructorTest.java 2011-10-23 21:15:13 UTC (rev 1442) @@ -96,4 +96,114 @@ assertEquals( c2, c3 ); assertThat( c3, not(c4) ); } -} + + @Test + public void testIsPublic() + { + D cstr = newJavaConstructor( "Constructor" ); + assertTrue( !cstr.isPublic() ); + + setModifiers( cstr, Arrays.asList( new String[] { "public" } ) ); + assertTrue( cstr.isPublic() ); + } + + @Test + public void testIsProtected() + { + D cstr = newJavaConstructor( "Constructor" ); + assertTrue( !cstr.isProtected() ); + + setModifiers( cstr, Arrays.asList( new String[] { "protected" } ) ); + assertTrue( cstr.isProtected() ); + } + + @Test + public void testIsPrivate() + { + D cstr = newJavaConstructor( "Constructor" ); + assertTrue( !cstr.isPrivate() ); + + setModifiers( cstr, Arrays.asList( new String[] { "private" } ) ); + assertTrue( cstr.isPrivate() ); + } + + @Test + public void testIsAbstract() + { + D cstr = newJavaConstructor( "Constructor" ); + assertTrue( !cstr.isAbstract() ); + + setModifiers( cstr, Arrays.asList( new String[] { "abstract" } ) ); + assertTrue( cstr.isAbstract() ); + } + + @Test + public void testIsFinal() + { + D cstr = newJavaConstructor( "Constructor" ); + assertTrue( !cstr.isFinal() ); + + setModifiers( cstr, Arrays.asList( new String[] { "final" } ) ); + assertTrue( cstr.isFinal() ); + } + + @Test + public void testIsNavite() + { + D cstr = newJavaConstructor( "Constructor" ); + assertTrue( !cstr.isNative() ); + + setModifiers( cstr, Arrays.asList( new String[] { "native" } ) ); + assertTrue( cstr.isNative() ); + } + + @Test + public void testIsStatic() + { + D cstr = newJavaConstructor( "Constructor" ); + assertTrue( !cstr.isStatic() ); + + setModifiers( cstr, Arrays.asList( new String[] { "static" } ) ); + assertTrue( cstr.isStatic() ); + } + + @Test + public void testIsStrict() + { + D cstr = newJavaConstructor( "Constructor" ); + assertTrue( !cstr.isStrictfp() ); + + setModifiers( cstr, Arrays.asList( new String[] { "strictfp" } ) ); + assertTrue( cstr.isStrictfp() ); + } + + @Test + public void testIsSynchronized() + { + D cstr = newJavaConstructor( "Constructor" ); + assertTrue( !cstr.isSynchronized() ); + + setModifiers( cstr, Arrays.asList( new String[] { "synchronized" } ) ); + assertTrue( cstr.isSynchronized() ); + } + + @Test + public void testIsTransient() + { + D cstr = newJavaConstructor( "Constructor" ); + assertTrue( !cstr.isTransient() ); + + setModifiers( cstr, Arrays.asList( new String[] { "transient" } ) ); + assertTrue( cstr.isTransient() ); + } + + @Test + public void testIsVolatile() + { + D cstr = newJavaConstructor( "Constructor" ); + assertTrue( !cstr.isVolatile() ); + + setModifiers( cstr, Arrays.asList( new String[] { "volatile" } ) ); + assertTrue( cstr.isVolatile() ); + } +} \ No newline at end of file
Modified: trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaFieldTest.java (1441 => 1442)
--- trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaFieldTest.java 2011-10-23 20:42:53 UTC (rev 1441) +++ trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaFieldTest.java 2011-10-23 21:15:13 UTC (rev 1442) @@ -1,5 +1,6 @@ package com.thoughtworks.qdox.model; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.*; import java.util.Arrays; @@ -146,4 +147,103 @@ setDeclaringClass( fld, cls ); assertEquals("private int java.io.FileDescriptor.fd", fld.toString()); } -} + + public void testIsPublic() + { + F fld = newJavaField(); + assertTrue( !fld.isPublic() ); + + setModifiers( fld, Arrays.asList( new String[] { "public" } ) ); + assertTrue( fld.isPublic() ); + } + + public void testIsProtected() + { + F fld = newJavaField(); + assertTrue( !fld.isProtected() ); + + setModifiers( fld, Arrays.asList( new String[] { "protected" } ) ); + assertTrue( fld.isProtected() ); + } + + public void testIsPrivate() + { + F fld = newJavaField(); + assertTrue( !fld.isPrivate() ); + + setModifiers( fld, Arrays.asList( new String[] { "private" } ) ); + assertTrue( fld.isPrivate() ); + } + + public void testIsAbstract() + { + F fld = newJavaField(); + assertTrue( !fld.isAbstract() ); + + setModifiers( fld, Arrays.asList( new String[] { "abstract" } ) ); + assertTrue( fld.isAbstract() ); + } + + public void testIsFinal() + { + F fld = newJavaField(); + assertTrue( !fld.isFinal() ); + + setModifiers( fld, Arrays.asList( new String[] { "final" } ) ); + assertTrue( fld.isFinal() ); + } + + public void testIsNavite() + { + F fld = newJavaField(); + assertTrue( !fld.isNative() ); + + setModifiers( fld, Arrays.asList( new String[] { "native" } ) ); + assertTrue( fld.isNative() ); + } + + public void testIsStatic() + { + F fld = newJavaField(); + assertTrue( !fld.isStatic() ); + + setModifiers( fld, Arrays.asList( new String[] { "static" } ) ); + assertTrue( fld.isStatic() ); + } + + public void testIsStrict() + { + F fld = newJavaField(); + assertTrue( !fld.isStrictfp() ); + + setModifiers( fld, Arrays.asList( new String[] { "strictfp" } ) ); + assertTrue( fld.isStrictfp() ); + } + + public void testIsSynchronized() + { + F fld = newJavaField(); + assertTrue( !fld.isSynchronized() ); + + setModifiers( fld, Arrays.asList( new String[] { "synchronized" } ) ); + assertTrue( fld.isSynchronized() ); + } + + public void testIsTransient() + { + F fld = newJavaField(); + assertTrue( !fld.isTransient() ); + + setModifiers( fld, Arrays.asList( new String[] { "transient" } ) ); + assertTrue( fld.isTransient() ); + } + + public void testIsVolatile() + { + F fld = newJavaField(); + assertTrue( !fld.isVolatile() ); + + setModifiers( fld, Arrays.asList( new String[] { "volatile" } ) ); + assertTrue( fld.isVolatile() ); + } +} \ No newline at end of file
Modified: trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaMethodTest.java (1441 => 1442)
--- trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaMethodTest.java 2011-10-23 20:42:53 UTC (rev 1441) +++ trunk/qdox/src/test/java/com/thoughtworks/qdox/model/JavaMethodTest.java 2011-10-23 21:15:13 UTC (rev 1442) @@ -14,8 +14,6 @@ import com.thoughtworks.qdox.model.impl.DefaultJavaType; -import junit.framework.TestCase; - public abstract class JavaMethodTest<M extends JavaMethod> { private M mth; @@ -428,4 +426,103 @@ setParameters(mthd, Collections.singletonList( newJavaParameter(newType("java.lang.Object"), null) )); assertEquals("public boolean java.lang.Object.equals(java.lang.Object)", mthd.toString()); } + + @Test + public void testIsPublic() + { + assertTrue( !mth.isPublic() ); + + setModifiers( mth, Arrays.asList( new String[] { "public" } ) ); + assertTrue( mth.isPublic() ); + } + + @Test + public void testIsProtected() + { + assertTrue( !mth.isProtected() ); + + setModifiers( mth, Arrays.asList( new String[] { "protected" } ) ); + assertTrue( mth.isProtected() ); + } + + @Test + public void testIsPrivate() + { + assertTrue( !mth.isPrivate() ); + + setModifiers( mth, Arrays.asList( new String[] { "private" } ) ); + assertTrue( mth.isPrivate() ); + } + + @Test + public void testIsAbstract() + { + assertTrue( !mth.isAbstract() ); + + setModifiers( mth, Arrays.asList( new String[] { "abstract" } ) ); + assertTrue( mth.isAbstract() ); + } + + @Test + public void testIsFinal() + { + assertTrue( !mth.isFinal() ); + + setModifiers( mth, Arrays.asList( new String[] { "final" } ) ); + assertTrue( mth.isFinal() ); + } + + @Test + public void testIsNavite() + { + assertTrue( !mth.isNative() ); + + setModifiers( mth, Arrays.asList( new String[] { "native" } ) ); + assertTrue( mth.isNative() ); + } + + @Test + public void testIsStatic() + { + assertTrue( !mth.isStatic() ); + + setModifiers( mth, Arrays.asList( new String[] { "static" } ) ); + assertTrue( mth.isStatic() ); + } + + @Test + public void testIsStrict() + { + assertTrue( !mth.isStrictfp() ); + + setModifiers( mth, Arrays.asList( new String[] { "strictfp" } ) ); + assertTrue( mth.isStrictfp() ); + } + + @Test + public void testIsSynchronized() + { + assertTrue( !mth.isSynchronized() ); + + setModifiers( mth, Arrays.asList( new String[] { "synchronized" } ) ); + assertTrue( mth.isSynchronized() ); + } + + @Test + public void testIsTransient() + { + assertTrue( !mth.isTransient() ); + + setModifiers( mth, Arrays.asList( new String[] { "transient" } ) ); + assertTrue( mth.isTransient() ); + } + + @Test + public void testIsVolatile() + { + assertTrue( !mth.isVolatile() ); + + setModifiers( mth, Arrays.asList( new String[] { "volatile" } ) ); + assertTrue( mth.isVolatile() ); + } } \ No newline at end of file
To unsubscribe from this list please visit:
