This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new cd0cdab  Tests.
cd0cdab is described below

commit cd0cdab3d57caa7f03c4a75dc2b9704af5369f44
Author: JamesBognar <[email protected]>
AuthorDate: Thu Apr 9 10:26:22 2020 -0400

    Tests.
---
 .../java/org/apache/juneau/ComboRoundTripTest.java |   2 +-
 .../juneau/SerializerPropertiesComboTest.java      |  84 ++++++++++++++--
 .../apache/juneau/rest/client2/RestClientTest.java | 112 +++++++++++++++------
 3 files changed, 160 insertions(+), 38 deletions(-)

diff --git 
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboRoundTripTest.java
 
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboRoundTripTest.java
index 0b43c8a..d96f555 100644
--- 
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboRoundTripTest.java
+++ 
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboRoundTripTest.java
@@ -208,7 +208,7 @@ public abstract class ComboRoundTripTest {
 
                        boolean isRdf = s instanceof RdfSerializer;
 
-                       if ((isRdf && SKIP_RDF_TESTS) || expected.isEmpty() || 
! runTestsSet.contains(testName) ) {
+                       if ((isRdf && SKIP_RDF_TESTS) || 
"SKIP".equals(expected) || ! runTestsSet.contains(testName) ) {
                                System.err.println(comboInput.label + "/" + 
testName + " for "+s.getClass().getSimpleName()+" skipped.");  // NOT DEBUG
                                return;
                        }
diff --git 
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/SerializerPropertiesComboTest.java
 
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/SerializerPropertiesComboTest.java
index d489607..0fe0272 100644
--- 
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/SerializerPropertiesComboTest.java
+++ 
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/SerializerPropertiesComboTest.java
@@ -28,16 +28,26 @@ import org.junit.runners.*;
 public class SerializerPropertiesComboTest extends ComboRoundTripTest {
 
        @Bean(typeName="BwT")
-       public static class BeanWithType {
+       public static class T0 {
                public int f;
 
-               public static BeanWithType create() {
-                       BeanWithType l = new BeanWithType();
+               public static T0 create() {
+                       T0 l = new T0();
                        l.f = 1;
                        return l;
                }
        }
 
+       public static class T5 {
+               public List<String> f1 = AList.of();
+               public String[] f2 = new String[0];
+       }
+
+       public static class T6 {
+               public Map<String,String> f1 = AMap.of();
+               public OMap f2 = OMap.of();
+       }
+
        @Parameterized.Parameters
        public static Collection<Object[]> getParameters() {
                return Arrays.asList(new Object[][] {
@@ -45,7 +55,7 @@ public class SerializerPropertiesComboTest extends 
ComboRoundTripTest {
                                new ComboInput<>(
                                        "SERIALIZER_addBeanTypes",
                                        OMap.class,
-                                       OMap.of("a", BeanWithType.create()),
+                                       OMap.of("a", T0.create()),
                                        /* Json */              
"{a:{_type:'BwT',f:1}}",
                                        /* JsonT */             
"{a:{t:'BwT',f:1}}",
                                        /* JsonR */             "{\n\ta: 
{\n\t\t_type: 'BwT',\n\t\tf: 1\n\t}\n}",
@@ -68,13 +78,13 @@ public class SerializerPropertiesComboTest extends 
ComboRoundTripTest {
                                        /* RdfXmlT */   
"<rdf:RDF>\n<rdf:Description>\n<jp:a 
rdf:parseType='Resource'>\n<jp:t>BwT</jp:t>\n<jp:f>1</jp:f>\n</jp:a>\n</rdf:Description>\n</rdf:RDF>\n",
                                        /* RdfXmlR */   "<rdf:RDF>\n  
<rdf:Description>\n    <jp:a rdf:parseType='Resource'>\n      
<jp:_type>BwT</jp:_type>\n      <jp:f>1</jp:f>\n    </jp:a>\n  
</rdf:Description>\n</rdf:RDF>\n"
                                )
-                               .properties(OMap.of(SERIALIZER_addBeanTypes, 
true, BEAN_beanDictionary, BeanWithType.class))
+                               .properties(OMap.of(SERIALIZER_addBeanTypes, 
true, BEAN_beanDictionary, T0.class))
                        },
                        {       /* 1 */
                                new ComboInput<>(
                                        "SERIALIZER_addRootType",
-                                       BeanWithType.class,
-                                       BeanWithType.create(),
+                                       T0.class,
+                                       T0.create(),
                                        /* Json */              
"{_type:'BwT',f:1}",
                                        /* JsonT */             "{t:'BwT',f:1}",
                                        /* JsonR */             "{\n\t_type: 
'BwT',\n\tf: 1\n}",
@@ -97,7 +107,7 @@ public class SerializerPropertiesComboTest extends 
ComboRoundTripTest {
                                        /* RdfXmlT */   
"<rdf:RDF>\n<rdf:Description>\n<jp:t>BwT</jp:t>\n<jp:f>1</jp:f>\n</rdf:Description>\n</rdf:RDF>\n",
                                        /* RdfXmlR */   "<rdf:RDF>\n  
<rdf:Description>\n    <jp:_type>BwT</jp:_type>\n    <jp:f>1</jp:f>\n  
</rdf:Description>\n</rdf:RDF>\n"
                                )
-                               .properties(OMap.of(SERIALIZER_addRootType, 
true, BEAN_beanDictionary, BeanWithType.class))
+                               .properties(OMap.of(SERIALIZER_addRootType, 
true, BEAN_beanDictionary, T0.class))
                        },
                        {       /* 2 */
                                new ComboInput<>(
@@ -186,6 +196,64 @@ public class SerializerPropertiesComboTest extends 
ComboRoundTripTest {
                                )
                                .properties(OMap.of(SERIALIZER_sortMaps, true))
                        },
+                       {       /* 5 */
+                               new ComboInput<>(
+                                       "SERIALIZER_trimEmptyCollections",
+                                       T5.class,
+                                       new T5(),
+                                       /* Json */              "{}",
+                                       /* JsonT */             "{}",
+                                       /* JsonR */             "{\n}",
+                                       /* Xml */               "<object/>",
+                                       /* XmlT */              "<object/>",
+                                       /* XmlR */              "<object/>\n",
+                                       /* XmlNs */             "<object/>",
+                                       /* Html */              
"<table></table>",
+                                       /* HtmlT */             
"<table></table>",
+                                       /* HtmlR */             
"<table>\n</table>\n",
+                                       /* Uon */               "()",
+                                       /* UonT */              "()",
+                                       /* UonR */              "(\n)",
+                                       /* UrlEnc */    "",
+                                       /* UrlEncT */   "",
+                                       /* UrlEncR */   "",
+                                       /* MsgPack */   "82A2663190A2663290",
+                                       /* MsgPackT */  "82A2663190A2663290",
+                                       /* RdfXml */    
"<rdf:RDF>\n</rdf:RDF>\n",
+                                       /* RdfXmlT */   
"<rdf:RDF>\n</rdf:RDF>\n",
+                                       /* RdfXmlR */   
"<rdf:RDF>\n</rdf:RDF>\n"
+                               )
+                               
.properties(OMap.of(SERIALIZER_trimEmptyCollections, true))
+                       },
+                       {       /* 6 */
+                               new ComboInput<>(
+                                       "SERIALIZER_trimEmptyMaps",
+                                       T6.class,
+                                       new T6(),
+                                       /* Json */              "{}",
+                                       /* JsonT */             "{}",
+                                       /* JsonR */             "{\n}",
+                                       /* Xml */               "<object/>",
+                                       /* XmlT */              "<object/>",
+                                       /* XmlR */              "<object/>\n",
+                                       /* XmlNs */             "<object/>",
+                                       /* Html */              
"<table></table>",
+                                       /* HtmlT */             
"<table></table>",
+                                       /* HtmlR */             
"<table>\n</table>\n",
+                                       /* Uon */               "()",
+                                       /* UonT */              "()",
+                                       /* UonR */              "(\n)",
+                                       /* UrlEnc */    "",
+                                       /* UrlEncT */   "",
+                                       /* UrlEncR */   "",
+                                       /* MsgPack */   "82A2663180A2663280",
+                                       /* MsgPackT */  "82A2663180A2663280",
+                                       /* RdfXml */    
"<rdf:RDF>\n</rdf:RDF>\n",
+                                       /* RdfXmlT */   
"<rdf:RDF>\n</rdf:RDF>\n",
+                                       /* RdfXmlR */   
"<rdf:RDF>\n</rdf:RDF>\n"
+                               )
+                               .properties(OMap.of(SERIALIZER_trimEmptyMaps, 
true))
+                       },
                });
        }
 
diff --git 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClientTest.java
 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClientTest.java
index 1e7da40..9aa5ce4 100644
--- 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClientTest.java
+++ 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClientTest.java
@@ -2278,14 +2278,14 @@ public class RestClientTest {
 
        @Test
        public void l12_serializer_sortCollections() throws Exception {
-               String[] s = new String[]{"c","a","b"};
+               String[] x = new String[]{"c","a","b"};
 
                MockRestClient
                        .create(A.class)
                        .simpleJson()
                        .sortCollections(true)
                        .build()
-                       .post("/echoBody", s)
+                       .post("/echoBody", x)
                        .run()
                        .getBody().assertValue("['a','b','c']");
 
@@ -2294,7 +2294,7 @@ public class RestClientTest {
                        .simpleJson()
                        .sortCollections()
                        .build()
-                       .post("/echoBody", s)
+                       .post("/echoBody", x)
                        .run()
                        .getBody().assertValue("['a','b','c']");
 
@@ -2303,21 +2303,21 @@ public class RestClientTest {
                        .simpleJson()
                        .sortCollections(false)
                        .build()
-                       .post("/echoBody", s)
+                       .post("/echoBody", x)
                        .run()
                        .getBody().assertValue("['c','a','b']");
        }
 
        @Test
        public void l14_serializer_sortMapsBoolean() throws Exception {
-               AMap<String,Integer> m = AMap.of("c", 3, "a", 1, "b", 2);
+               AMap<String,Integer> x = AMap.of("c", 3, "a", 1, "b", 2);
 
                MockRestClient
                        .create(A.class)
                        .simpleJson()
                        .sortMaps(true)
                        .build()
-                       .post("/echoBody", m)
+                       .post("/echoBody", x)
                        .run()
                        .getBody().assertValue("{a:1,b:2,c:3}");
 
@@ -2326,7 +2326,7 @@ public class RestClientTest {
                        .simpleJson()
                        .sortMaps()
                        .build()
-                       .post("/echoBody", m)
+                       .post("/echoBody", x)
                        .run()
                        .getBody().assertValue("{a:1,b:2,c:3}");
 
@@ -2335,32 +2335,86 @@ public class RestClientTest {
                        .simpleJson()
                        .sortMaps(false)
                        .build()
-                       .post("/echoBody", m)
+                       .post("/echoBody", x)
                        .run()
                        .getBody().assertValue("{c:3,a:1,b:2}");
        }
-//     public RestClientBuilder sortMaps(boolean value) {
 
-//     @Test
-//     public void l15_serializer_sortMaps() throws Exception { fail(); }
-////   public RestClientBuilder sortMaps() {
-//
-//     @Test
-//     public void l16_serializer_trimEmptyCollectionsBoolean() throws 
Exception { fail(); }
-////   public RestClientBuilder trimEmptyCollections(boolean value) {
-//
-//     @Test
-//     public void l17_serializer_trimEmptyCollections() throws Exception { 
fail(); }
-////   public RestClientBuilder trimEmptyCollections() {
-//
-//     @Test
-//     public void l18_serializer_trimEmptyMapsBoolean() throws Exception { 
fail(); }
-////   public RestClientBuilder trimEmptyMaps(boolean value) {
-//
-//     @Test
-//     public void l19_serializer_trimEmptyMaps() throws Exception { fail(); }
-////   public RestClientBuilder trimEmptyMaps() {
-//
+       public static class L16 {
+               public List<String> f1 = AList.of();
+               public String[] f2 = new String[0];
+       }
+
+       @Test
+       public void l16_serializer_trimEmptyCollections() throws Exception {
+               L16 x = new L16();
+
+               MockRestClient
+                       .create(A.class)
+                       .simpleJson()
+                       .trimEmptyCollections(true)
+                       .build()
+                       .post("/echoBody", x)
+                       .run()
+                       .getBody().assertValue("{}");
+
+               MockRestClient
+                       .create(A.class)
+                       .simpleJson()
+                       .trimEmptyCollections()
+                       .build()
+                       .post("/echoBody", x)
+                       .run()
+                       .getBody().assertValue("{}");
+
+               MockRestClient
+                       .create(A.class)
+                       .simpleJson()
+                       .trimEmptyCollections(false)
+                       .build()
+                       .post("/echoBody", x)
+                       .run()
+                       .getBody().assertValue("{f1:[],f2:[]}");
+       }
+
+       public static class L18 {
+               public Map<String,String> f1 = AMap.of();
+               public OMap f2 = OMap.of();
+       }
+
+       @Test
+       public void l18_serializer_trimEmptyMaps() throws Exception {
+               L18 x = new L18();
+
+               MockRestClient
+                       .create(A.class)
+                       .simpleJson()
+                       .trimEmptyMaps(true)
+                       .build()
+                       .post("/echoBody", x)
+                       .run()
+                       .getBody().assertValue("{}");
+
+               MockRestClient
+                       .create(A.class)
+                       .simpleJson()
+                       .trimEmptyMaps()
+                       .build()
+                       .post("/echoBody", x)
+                       .run()
+                       .getBody().assertValue("{}");
+
+               MockRestClient
+                       .create(A.class)
+                       .simpleJson()
+                       .trimEmptyMaps(false)
+                       .build()
+                       .post("/echoBody", x)
+                       .run()
+                       .getBody().assertValue("{f1:{},f2:{}}");
+
+       }
+
 //     @Test
 //     public void l20_serializer_trimNullPropertiesBoolean() throws Exception 
{ fail(); }
 ////   public RestClientBuilder trimNullProperties(boolean value) {

Reply via email to