- Revision
- 1083
- Author
- rfscholte
- Date
- 2011-02-27 07:26:40 -0600 (Sun, 27 Feb 2011)
Log Message
Use generics for JavaMethodTest
Modified Paths
- trunk/qdox/src/test/com/thoughtworks/qdox/model/DefaultJavaMethodTest.java
- trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java
Diff
Modified: trunk/qdox/src/test/com/thoughtworks/qdox/model/DefaultJavaMethodTest.java (1082 => 1083)
--- trunk/qdox/src/test/com/thoughtworks/qdox/model/DefaultJavaMethodTest.java 2011-02-27 13:20:30 UTC (rev 1082) +++ trunk/qdox/src/test/com/thoughtworks/qdox/model/DefaultJavaMethodTest.java 2011-02-27 13:26:40 UTC (rev 1083) @@ -3,7 +3,7 @@ import java.util.List; public class DefaultJavaMethodTest - extends JavaMethodTest + extends JavaMethodTest<DefaultJavaMethod> { public DefaultJavaMethodTest( String s ) @@ -21,12 +21,12 @@ return new DefaultJavaClass( fullname ); } - public JavaMethod newJavaMethod() + public DefaultJavaMethod newJavaMethod() { return new DefaultJavaMethod(); } - public JavaMethod newJavaMethod( Type returns, String name ) + public DefaultJavaMethod newJavaMethod( Type returns, String name ) { return new DefaultJavaMethod( returns, name ); } @@ -56,34 +56,34 @@ return new Type( fullname, dimensions ); } - public void setExceptions( JavaMethod method, List<Type> exceptions ) + public void setExceptions( DefaultJavaMethod method, List<Type> exceptions ) { - ((AbstractBaseMethod) method).setExceptions( exceptions ); + method.setExceptions( exceptions ); } - public void setComment( JavaMethod method, String comment ) + public void setComment( DefaultJavaMethod method, String comment ) { - ((AbstractBaseMethod) method).setComment( comment ); + method.setComment( comment ); } - public void setConstructor( JavaMethod method, boolean isConstructor ) + public void setConstructor( DefaultJavaMethod method, boolean isConstructor ) { - ((DefaultJavaMethod) method).setConstructor( isConstructor ); + method.setConstructor( isConstructor ); } - public void setName( JavaMethod method, String name ) + public void setName( DefaultJavaMethod method, String name ) { - ((AbstractBaseMethod) method).setName( name ); + method.setName( name ); } - public void setModifiers( JavaMethod method, List<String> modifiers ) + public void setModifiers( DefaultJavaMethod method, List<String> modifiers ) { - ((AbstractBaseMethod) method).setModifiers( modifiers ); + method.setModifiers( modifiers ); } - public void setReturns( JavaMethod method, Type type ) + public void setReturns( DefaultJavaMethod method, Type type ) { - ((DefaultJavaMethod) method).setReturns( type ); + method.setReturns( type ); } public void addClass( JavaSource source, JavaClass clazz ) @@ -104,8 +104,8 @@ ((DefaultJavaParameter) parameter).setParentMethod( method ); } - public void setSourceCode( JavaMethod method, String code ) + public void setSourceCode( DefaultJavaMethod method, String code ) { - ((AbstractBaseMethod) method).setSourceCode( code ); + method.setSourceCode( code ); } }
Modified: trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java (1082 => 1083)
--- trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java 2011-02-27 13:20:30 UTC (rev 1082) +++ trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java 2011-02-27 13:26:40 UTC (rev 1083) @@ -9,33 +9,37 @@ import com.thoughtworks.qdox.library.ClassLibrary; import com.thoughtworks.qdox.library.ClassNameLibrary; -public abstract class JavaMethodTest extends TestCase { +public abstract class JavaMethodTest<M extends JavaMethod> extends TestCase { - private JavaMethod mth; + private M mth; private JavaSource source; private JavaClass clazz; public JavaMethodTest(String s) { super(s); } + + //constructors + public abstract M newJavaMethod(); + public abstract M newJavaMethod(Type returns, String name); + + //setters + public abstract void setExceptions(M method, List<Type> exceptions); + public abstract void setComment(M method, String comment); + public abstract void setConstructor(M method, boolean isConstructor); + public abstract void setName(M method, String name); + public abstract void setModifiers(M method, List<String> modifiers); + public abstract void setReturns(M method, Type type); + public abstract void setSourceCode(M method, String code); public abstract JavaClass newJavaClass(); public abstract JavaClass newJavaClass(String fullname); - public abstract JavaMethod newJavaMethod(); - public abstract JavaMethod newJavaMethod(Type returns, String name); public abstract JavaParameter newJavaParameter(Type type, String name); public abstract JavaParameter newJavaParameter(Type type, String name, boolean varArgs); public abstract JavaSource newJavaSource(ClassLibrary classLibrary ); public abstract Type newType(String fullname); public abstract Type newType(String fullname, int dimensions); - public abstract void setExceptions(JavaMethod method, List<Type> exceptions); - public abstract void setComment(JavaMethod method, String comment); - public abstract void setConstructor(JavaMethod method, boolean isConstructor); - public abstract void setName(JavaMethod method, String name); - public abstract void setModifiers(JavaMethod method, List<String> modifiers); - public abstract void setReturns(JavaMethod method, Type type); - public abstract void setSourceCode(JavaMethod method, String code); public abstract void addClass(JavaSource source, JavaClass clazz); public abstract void addMethod(JavaClass clazz, JavaMethod method); @@ -199,27 +203,27 @@ setName(mth, "thing"); setReturns(mth, newType("void")); - JavaMethod m2 = newJavaMethod(); + M m2 = newJavaMethod(); setName(m2, "thing"); setReturns(m2, newType("void")); - JavaMethod m3 = newJavaMethod(); + M m3 = newJavaMethod(); setName(m3, "thingy"); setReturns(m3, newType("void")); - JavaMethod m4 = newJavaMethod(); + M m4 = newJavaMethod(); setName(m4, "thing"); setReturns(m4, newType("int")); - JavaMethod c1 = newJavaMethod(); + M c1 = newJavaMethod(); setName(c1, "thing"); setConstructor(c1, true); - JavaMethod c2 = newJavaMethod(); + M c2 = newJavaMethod(); setName(c2, "Thong"); setConstructor(c2, true); - JavaMethod c3 = newJavaMethod(); + M c3 = newJavaMethod(); setName(c3, "Thong"); setConstructor(c3, true); @@ -240,27 +244,27 @@ addParameter(mth, newJavaParameter(newType("X", 3), "")); setReturns(mth, newType("void")); - JavaMethod m2 = newJavaMethod(); + M m2 = newJavaMethod(); setName(m2, "thing"); addParameter(m2, newJavaParameter(newType("int", 1), "blah")); addParameter(m2, newJavaParameter(newType("java.lang.String", 2), "anotherName")); addParameter(m2, newJavaParameter(newType("X", 3), "blah")); setReturns(m2, newType("void")); - JavaMethod m3 = newJavaMethod(); + M m3 = newJavaMethod(); setName(m3, "thing"); addParameter(m3, newJavaParameter(newType("int", 1), "blah")); addParameter(m3, newJavaParameter(newType("java.lang.String", 2), "thing")); setReturns(m3, newType("void")); - JavaMethod m4 = newJavaMethod(); + M m4 = newJavaMethod(); setName(m4, "thing"); addParameter(m4, newJavaParameter(newType("int", 1), "blah")); addParameter(m4, newJavaParameter(newType("java.lang.String", 2), "thing")); addParameter(m4, newJavaParameter(newType("TTTTTTTT", 3), "blah")); //name setReturns(m4, newType("void")); - JavaMethod m5 = newJavaMethod(); + M m5 = newJavaMethod(); setName(m5, "thing"); addParameter(m5, newJavaParameter(newType("int", 1), "blah")); addParameter(m5, newJavaParameter(newType("java.lang.String", 2), "thing")); @@ -281,24 +285,24 @@ addParameter(mth, newJavaParameter(newType("X", 3), "")); setReturns(mth, newType("void")); - JavaMethod m2 = newJavaMethod(); + M m2 = newJavaMethod(); setName(m2, "thing"); addParameter(m2, newJavaParameter(newType("int", 1), "blah")); addParameter(m2, newJavaParameter(newType("java.lang.String", 2), "anotherName")); addParameter(m2, newJavaParameter(newType("X", 3), "blah")); setReturns(m2, newType("void")); - JavaMethod m3 = newJavaMethod(); + M m3 = newJavaMethod(); setName(m3, "thing"); addParameter(m3, newJavaParameter(newType("int", 1), "blah")); addParameter(m3, newJavaParameter(newType("java.lang.String", 2), "thing")); setReturns(m3, newType("void")); - JavaMethod c1 = newJavaMethod(); + M c1 = newJavaMethod(); setName(c1, "Thong"); setConstructor(c1, true); - JavaMethod c2 = newJavaMethod(); + M c2 = newJavaMethod(); setName(c2, "Thong"); setConstructor(c2, true); @@ -379,7 +383,7 @@ public void testToString() throws Exception { JavaClass cls = newJavaClass("java.lang.Object"); - JavaMethod mthd = newJavaMethod(newType("boolean"),"equals"); + M mthd = newJavaMethod(newType("boolean"),"equals"); addMethod(cls, mthd); setModifiers(mthd, Arrays.asList(new String[]{"public"})); addParameter(mthd, newJavaParameter(newType("java.lang.Object"), null)); @@ -388,21 +392,21 @@ public void testConstructorToString() throws Exception { JavaClass cls = newJavaClass("a.b.Executor"); - JavaMethod constructor = newJavaMethod(null,"Executor"); + M constructor = newJavaMethod(null,"Executor"); setConstructor( constructor, true ); addMethod(cls, constructor); assertEquals("a.b.Executor()", constructor.toString()); } public void testConstructorReturnType() throws Exception { - JavaMethod constructor = newJavaMethod(null,"Executor"); + M constructor = newJavaMethod(null,"Executor"); setConstructor( constructor, true ); assertEquals(null, constructor.getReturnType()); } public void testConstructorParameterTypes() throws Exception { JavaClass cls = newJavaClass("a.b.Executor"); - JavaMethod constructor = newJavaMethod(null,"Executor"); + M constructor = newJavaMethod(null,"Executor"); addParameter( constructor, newJavaParameter( newType("a.b.C"), "param" ) ); setConstructor( constructor, true ); addMethod(cls, constructor);
To unsubscribe from this list please visit:
