velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r507769 - /velocity/tools/trunk/src/test/org/apache/velocity/tools/test/whitebox/GenericToolsTests.java
Date Thu, 15 Feb 2007 01:24:31 GMT
Author: nbubna
Date: Wed Feb 14 17:24:31 2007
New Revision: 507769

URL: http://svn.apache.org/viewvc?view=rev&rev=507769
Log:
add assertStringEquals() so we needn't always call toString() on results

Modified:
    velocity/tools/trunk/src/test/org/apache/velocity/tools/test/whitebox/GenericToolsTests.java

Modified: velocity/tools/trunk/src/test/org/apache/velocity/tools/test/whitebox/GenericToolsTests.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/test/org/apache/velocity/tools/test/whitebox/GenericToolsTests.java?view=diff&rev=507769&r1=507768&r2=507769
==============================================================================
--- velocity/tools/trunk/src/test/org/apache/velocity/tools/test/whitebox/GenericToolsTests.java
(original)
+++ velocity/tools/trunk/src/test/org/apache/velocity/tools/test/whitebox/GenericToolsTests.java
Wed Feb 14 17:24:31 2007
@@ -63,20 +63,24 @@
         assertNotNull(alternatorTool);
         /* test automatic alternator */
         Alternator auto = alternatorTool.auto(new String[] {"red","blue","yellow"});
-        assertEquals("red",auto.getCurrent());
-        assertEquals("red",auto.getNext());
-        assertEquals("blue",auto.toString());
-        assertEquals("yellow",auto.toString());
-        assertEquals("red",auto.toString());
+        assertStringEquals("red", auto.getCurrent());
+        assertStringEquals("red", auto.getNext());
+        assertStringEquals("blue", auto);
+        assertStringEquals("yellow", auto);
+        assertStringEquals("red", auto);
         /* test manual alternator (use 'make()' and not 'manual()' since we define the default
to be manual in toolbox.xml*/
          Alternator manual = alternatorTool.make(new String[] {"red","blue","yellow"});
-        assertEquals("red",manual.toString());
-        assertEquals("red",manual.toString());
+        assertStringEquals("red", manual);
+        assertStringEquals("red", manual);
         manual.shift();
-        assertEquals("blue",manual.toString());
+        assertStringEquals("blue", manual);
         manual.shift();
         manual.shift();
-        assertEquals("red",manual.toString());
+        assertStringEquals("red", manual);
+    }
+
+    protected void assertStringEquals(String expected, Object testThis) {
+        assertEquals(expected, String.valueOf(testThis));
     }
 
     public @Test void testDateTool() { /* TODO still incomplete */
@@ -148,26 +152,26 @@
         assertNotNull(textTool);
 
         ResourceTool.Key foo = textTool.get("foo");
-        assertEquals("bar", foo.toString());
+        assertStringEquals("bar", foo);
 
         ResourceTool.Key frenchFoo = foo.locale(Locale.FRENCH);
-        assertEquals("barre", frenchFoo.toString());
+        assertStringEquals("barre", frenchFoo);
 
         ResourceTool.Key otherFoo = foo.bundle("resources2");
-        assertEquals("woogie", otherFoo.toString());
+        assertStringEquals("woogie", otherFoo);
 
         ResourceTool.Key helloWhoever = textTool.get("hello").get("whoever");
-        assertEquals("Hello {0}!", helloWhoever.toString());
+        assertStringEquals("Hello {0}!", helloWhoever);
 
         ResourceTool.Key helloWorld = helloWhoever.insert(textTool.get("world"));
-        assertEquals("Hello World!", helloWorld.toString());
+        assertStringEquals("Hello World!", helloWorld);
 
         ResourceTool.Key halfFrenchHelloWorld = helloWorld.locale(Locale.FRENCH);
-        assertEquals("Bonjour World!", halfFrenchHelloWorld.toString());
+        assertStringEquals("Bonjour World!", halfFrenchHelloWorld);
 
         ResourceTool.Key frenchTool = textTool.locale(Locale.FRENCH);
         ResourceTool.Key frenchHelloWorld =
             frenchTool.get("hello.whoever").insert(frenchTool.get("world"));
-        assertEquals("Bonjour Monde!", frenchHelloWorld.toString());
+        assertStringEquals("Bonjour Monde!", frenchHelloWorld);
     }
 }



Mime
View raw message