ggregory 2004/07/26 14:39:21 Modified: lang/src/test/org/apache/commons/lang/builder ToStringBuilderTest.java Log: Added testSelfInstanceVarReflectionObjectCycle to replicate an example in http://issues.apache.org/bugzilla/show_bug.cgi?id=19331. This is a bit redundant with other tests, but insures the given example is handled. Revision Changes Path 1.16 +25 -1 jakarta-commons/lang/src/test/org/apache/commons/lang/builder/ToStringBuilderTest.java Index: ToStringBuilderTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/builder/ToStringBuilderTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- ToStringBuilderTest.java 1 Jul 2004 17:58:09 -0000 1.15 +++ ToStringBuilderTest.java 26 Jul 2004 21:39:21 -0000 1.16 @@ -475,6 +475,18 @@ } } + private static class SelfInstanceVarReflectionTestFixture { + private SelfInstanceVarReflectionTestFixture typeIsSelf; + + public SelfInstanceVarReflectionTestFixture() { + this.typeIsSelf = this; + } + + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + } + /** * Test an Object pointing to itself, the simplest test. * @@ -485,6 +497,18 @@ simple.o = simple; assertTrue(ReflectionToStringBuilder.getRegistry().isEmpty()); assertEquals(this.toBaseString(simple) + "[o=" + this.toBaseString(simple) + "]", simple.toString()); + this.validateEmptyReflectionRegistry(); + } + + /** + * Test a class that defines an ivar pointing to itself. + * + * @throws Exception + */ + public void testSelfInstanceVarReflectionObjectCycle() throws Exception { + SelfInstanceVarReflectionTestFixture test = new SelfInstanceVarReflectionTestFixture(); + assertTrue(ReflectionToStringBuilder.getRegistry().isEmpty()); + assertEquals(this.toBaseString(test) + "[typeIsSelf=" + this.toBaseString(test) + "]", test.toString()); this.validateEmptyReflectionRegistry(); } --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org