commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject [01/11] [lang] add testChar and testDate Cases into JsonToStringStyleTest
Date Fri, 01 May 2015 21:56:57 GMT
Repository: commons-lang
Updated Branches:
  refs/heads/master 1cf8af4b2 -> 4a882e76d


add testChar and testDate Cases into JsonToStringStyleTest


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/cf42ae52
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/cf42ae52
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/cf42ae52

Branch: refs/heads/master
Commit: cf42ae522e12e9b412e1a1f008ea73cfd86a5979
Parents: 102b75c
Author: Jack <792626757@qq.com>
Authored: Wed Apr 29 11:02:08 2015 +0800
Committer: Jack <792626757@qq.com>
Committed: Wed Apr 29 11:02:08 2015 +0800

----------------------------------------------------------------------
 .../lang3/builder/JsonToStringStyleTest.java    | 33 ++++++++++++++++++++
 1 file changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/cf42ae52/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java
index 530e679..261acae 100644
--- a/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java
@@ -90,6 +90,39 @@ public class JsonToStringStyleTest {
         assertEquals("{\"a\":\"hello\",\"b\":\"world\"}", new ToStringBuilder(base)
                 .appendSuper("{\"a\":\"hello\"}").append("b", "world").toString());
     }
+    
+    @Test
+    public void testChar() {
+    
+        try {
+            new ToStringBuilder(base).append('A').toString();
+            fail("Should have generated UnsupportedOperationException");
+        } catch (UnsupportedOperationException e) {
+        }
+        
+        assertEquals("{\"a\":\"A\"}", new ToStringBuilder(base).append("a", 'A')
+                .toString());
+        assertEquals("{\"a\":\"A\",\"b\":\"B\"}", new ToStringBuilder(base).append("a", 'A').append("b",
'B')
+                .toString());
+    }
+    
+    @Test
+    public void testDate() {
+        
+        final Date now = new Date();
+        final Date after_now = new Date(System.currentTimeMillis() + 1);
+        
+        try {
+            new ToStringBuilder(base).append(now).toString();
+            fail("Should have generated UnsupportedOperationException");
+        } catch (UnsupportedOperationException e) {
+        }
+        
+        assertEquals("{\"now\":\"" + now.toString() +"\"}", new ToStringBuilder(base).append("now",
now)
+                .toString());
+        assertEquals("{\"now\":\"" + now.toString() +"\",\"after\":\"" + after_now.toString()
+ "\"}", new ToStringBuilder(base).append("now", now).append("after", after_now)
+                .toString());
+    }
 
     @Test
     public void testObject() {


Mime
View raw message