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 c4d093d JUNEAU-216
c4d093d is described below
commit c4d093d6114385453d338769360242e43b8a9fc3
Author: JamesBognar <[email protected]>
AuthorDate: Mon Apr 6 11:34:34 2020 -0400
JUNEAU-216
BEANTRAVERSE_initialDepth not setting indentation correctly on first
line.
---
.../test/java/org/apache/juneau/ComboInput.java | 36 ++++++++++
.../java/org/apache/juneau/ComboRoundTripTest.java | 57 +++++++++++++---
.../java/org/apache/juneau/ComboSerializeTest.java | 19 +++++-
.../juneau/serializer/BeanTraverseComboTest.java | 78 ++++++++++++++++++++++
.../org/apache/juneau/internal/ThrowableUtils.java | 16 +++++
.../apache/juneau/json/JsonSerializerSession.java | 4 +-
.../apache/juneau/uon/UonSerializerSession.java | 4 +-
.../urlencoding/UrlEncodingSerializerSession.java | 2 +-
.../juneau/rest/client2/RestClientBuilderTest.java | 69 +++++++++----------
.../juneau/rest/client2/RestResponseBody.java | 10 ++-
10 files changed, 242 insertions(+), 53 deletions(-)
diff --git
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboInput.java
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboInput.java
index f72c2f1..6fae122 100644
---
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboInput.java
+++
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboInput.java
@@ -14,6 +14,8 @@ package org.apache.juneau;
import java.lang.reflect.*;
+import org.apache.juneau.collections.*;
+
/**
* Represents the input to a ComboTest.
* @param <T>
@@ -22,10 +24,22 @@ public class ComboInput<T> {
final String label;
private final T in;
+ private OMap properties;
+ private String exceptionMsg;
final Type type;
final String json, jsonT, jsonR, xml, xmlT, xmlR, xmlNs, html, htmlT,
htmlR, uon, uonT, uonR, urlEncoding,
urlEncodingT, urlEncodingR, msgPack, msgPackT, rdfXml, rdfXmlT,
rdfXmlR;
+ public ComboInput<T> properties(OMap properties) {
+ this.properties = properties;
+ return this;
+ }
+
+ public ComboInput<T> exceptionMsg(String exceptionMsg) {
+ this.exceptionMsg = exceptionMsg;
+ return this;
+ }
+
public ComboInput(
String label,
Type type,
@@ -55,6 +69,7 @@ public class ComboInput<T> {
this.label = label;
this.type = type;
this.in = in;
+ this.properties = null;
this.json = json;
this.jsonT = jsonT;
this.jsonR = jsonR;
@@ -88,6 +103,20 @@ public class ComboInput<T> {
}
/**
+ * Returns the serializer or parser properties.
+ */
+ public OMap getProperties() throws Exception {
+ return properties;
+ }
+
+ /**
+ * Returns the expected exception message if an exception occurs.
+ */
+ public String exceptionMsg() throws Exception {
+ return exceptionMsg;
+ }
+
+ /**
* Override this method if you want to do a post-parse verification on
the object.
* <p>
* Note that a Function would be preferred here, but it's not available
in Java 6.
@@ -95,4 +124,11 @@ public class ComboInput<T> {
* @param o The object returned by the parser.
*/
public void verify(T o) {}
+
+ /**
+ * Returns the expected exception message if an exception occurs.
+ */
+ public String getExceptionMsg() {
+ return exceptionMsg;
+ }
}
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 4478731..683adb2 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
@@ -13,9 +13,11 @@
package org.apache.juneau;
import static org.junit.Assert.*;
+import static org.apache.juneau.internal.ThrowableUtils.*;
import java.util.*;
+import org.apache.juneau.collections.*;
import org.apache.juneau.html.*;
import org.apache.juneau.jena.*;
import org.apache.juneau.json.*;
@@ -147,6 +149,11 @@ public abstract class ComboRoundTripTest {
try {
s = getSerializer(s);
+ OMap properties = comboInput.getProperties();
+ if (properties != null) {
+ s = s.builder().add(properties).build();
+ }
+
boolean isRdf = s instanceof RdfSerializer;
if ((isRdf && SKIP_RDF_TESTS) || expected.isEmpty() ||
! runTestsSet.contains(testName) ) {
@@ -175,10 +182,16 @@ public abstract class ComboRoundTripTest {
TestUtils.assertEquals(expected, r, "{0}/{1}
parse-normal failed", comboInput.label, testName);
} catch (AssertionError e) {
- throw e;
+ if (comboInput.getExceptionMsg() == null)
+ throw e;
+ assertExceptionContainsMessage(e,
comboInput.getExceptionMsg());
} catch (Exception e) {
- e.printStackTrace();
- throw new AssertionError(comboInput.label + "/" +
testName + " failed. exception=" + e.getLocalizedMessage());
+ if (comboInput.getExceptionMsg() == null) {
+ e.printStackTrace();
+ throw new AssertionError(comboInput.label + "/"
+ testName + " failed. exception=" + e.getLocalizedMessage());
+
+ }
+ assertExceptionContainsMessage(e,
comboInput.getExceptionMsg());
}
}
@@ -187,6 +200,12 @@ public abstract class ComboRoundTripTest {
s = getSerializer(s);
p = getParser(p);
+ OMap properties = comboInput.getProperties();
+ if (properties != null) {
+ s = s.builder().add(properties).build();
+ p = p.builder().add(properties).build();
+ }
+
boolean isRdf = s instanceof RdfSerializer;
if ((isRdf && SKIP_RDF_TESTS) || expected.isEmpty() ||
! runTestsSet.contains(testName) ) {
@@ -207,9 +226,15 @@ public abstract class ComboRoundTripTest {
TestUtils.assertEquals(expected, r, "{0}/{1}
parse-normal failed", comboInput.label, testName);
} catch (AssertionError e) {
- throw e;
- } catch (Exception e) {
- throw new Exception(comboInput.label + "/" + testName +
" failed.", e);
+ if (comboInput.getExceptionMsg() == null)
+ throw e;
+ assertExceptionContainsMessage(e,
comboInput.getExceptionMsg());
+ } catch (Throwable e) {
+ if (comboInput.getExceptionMsg() == null) {
+ e.printStackTrace();
+ throw new AssertionError(comboInput.label + "/"
+ testName + " failed. exception=" + e.getLocalizedMessage());
+ }
+ assertExceptionContainsMessage(e,
comboInput.getExceptionMsg());
}
}
@@ -223,9 +248,15 @@ public abstract class ComboRoundTripTest {
comboInput.verify(o);
} catch (AssertionError e) {
- throw e;
+ if (comboInput.getExceptionMsg() == null)
+ throw e;
+ assertExceptionContainsMessage(e,
comboInput.getExceptionMsg());
} catch (Exception e) {
- throw new Exception(comboInput.label + "/" + testName +
" failed.", e);
+ if (comboInput.getExceptionMsg() == null) {
+ e.printStackTrace();
+ throw new AssertionError(comboInput.label + "/"
+ testName + " failed. exception=" + e.getLocalizedMessage());
+ }
+ assertExceptionContainsMessage(e,
comboInput.getExceptionMsg());
}
}
@@ -241,9 +272,15 @@ public abstract class ComboRoundTripTest {
r = sJson.serialize(o);
assertEquals(comboInput.label + "/" + testName + "
parse-normal failed on JSON equivalency", expected, r);
} catch (AssertionError e) {
- throw e;
+ if (comboInput.getExceptionMsg() == null)
+ throw e;
+ assertExceptionContainsMessage(e,
comboInput.getExceptionMsg());
} catch (Exception e) {
- throw new Exception(comboInput.label + "/" + testName +
" failed.", e);
+ if (comboInput.getExceptionMsg() == null) {
+ e.printStackTrace();
+ throw new AssertionError(comboInput.label + "/"
+ testName + " failed. exception=" + e.getLocalizedMessage());
+ }
+ assertExceptionContainsMessage(e,
comboInput.getExceptionMsg());
}
}
diff --git
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboSerializeTest.java
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboSerializeTest.java
index 646d253..06bd237 100644
---
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboSerializeTest.java
+++
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboSerializeTest.java
@@ -12,8 +12,11 @@
//
***************************************************************************************************************************
package org.apache.juneau;
+import static org.apache.juneau.internal.ThrowableUtils.*;
+
import java.util.*;
+import org.apache.juneau.collections.*;
import org.apache.juneau.html.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.jena.*;
@@ -112,6 +115,11 @@ public abstract class ComboSerializeTest {
try {
s = getSerializer(s);
+ OMap properties = comboInput.getProperties();
+ if (properties != null) {
+ s = s.builder().add(properties).build();
+ }
+
boolean isRdf = s instanceof RdfSerializer;
if ((isRdf && SKIP_RDF_TESTS) ||
expected.equals("SKIP") || ! runTestsSet.contains(testName) ) {
@@ -143,10 +151,15 @@ public abstract class ComboSerializeTest {
TestUtils.assertEquals(expected, r, "{0}/{1}
serialize-normal failed", comboInput.label, testName);
} catch (AssertionError e) {
- throw e;
+ if (comboInput.getExceptionMsg() == null)
+ throw e;
+ assertExceptionContainsMessage(e,
comboInput.getExceptionMsg());
} catch (Exception e) {
- e.printStackTrace();
- throw new AssertionError(comboInput.label + "/" +
testName + " failed. exception=" + e.getLocalizedMessage());
+ if (comboInput.getExceptionMsg() == null) {
+ e.printStackTrace();
+ throw new AssertionError(comboInput.label + "/"
+ testName + " failed. exception=" + e.getLocalizedMessage());
+ }
+ assertExceptionContainsMessage(e,
comboInput.getExceptionMsg());
}
}
diff --git
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/serializer/BeanTraverseComboTest.java
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/serializer/BeanTraverseComboTest.java
new file mode 100644
index 0000000..4d02819
--- /dev/null
+++
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/serializer/BeanTraverseComboTest.java
@@ -0,0 +1,78 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.serializer;
+
+import static org.apache.juneau.BeanTraverseContext.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.collections.*;
+import org.junit.runner.*;
+import org.junit.runners.*;
+
+/**
+ * Exhaustive serialization tests for BeanTraverseContext properties.
+ */
+@RunWith(Parameterized.class)
+@SuppressWarnings({})
+public class BeanTraverseComboTest extends ComboRoundTripTest {
+
+ public static class Bean {
+ public int f;
+
+ public static Bean create() {
+ Bean b = new Bean();
+ b.f = 1;
+ return b;
+ }
+ }
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> getParameters() {
+ return Arrays.asList(new Object[][] {
+ { /* 0 */
+ new ComboInput<>(
+ "TestInitialDepth",
+ Bean.class,
+ Bean.create(),
+ /* Json */ "{f:1}",
+ /* JsonT */ "{f:1}",
+ /* JsonR */
"\t\t{\n\t\t\tf: 1\n\t\t}",
+ /* Xml */
"<object><f>1</f></object>",
+ /* XmlT */
"<object><f>1</f></object>",
+ /* XmlR */
"\t\t<object>\n\t\t\t<f>1</f>\n\t\t</object>\n",
+ /* XmlNs */
"<object><f>1</f></object>",
+ /* Html */
"<table><tr><td>f</td><td>1</td></tr></table>",
+ /* HtmlT */
"<table><tr><td>f</td><td>1</td></tr></table>",
+ /* HtmlR */
"\t\t\t\t<table>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>f</td>\n\t\t\t\t\t\t<td>1</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n",
+ /* Uon */ "(f=1)",
+ /* UonT */ "(f=1)",
+ /* UonR */
"\t\t(\n\t\t\tf=1\n\t\t)",
+ /* UrlEnc */ "f=1",
+ /* UrlEncT */ "f=1",
+ /* UrlEncR */ "\t\tf=1",
+ /* MsgPack */ "81A16601",
+ /* MsgPackT */ "81A16601",
+ /* RdfXml */
"<rdf:RDF>\n<rdf:Description>\n<jp:f>1</jp:f>\n</rdf:Description>\n</rdf:RDF>\n",
+ /* RdfXmlT */
"<rdf:RDF>\n<rdf:Description>\n<jp:f>1</jp:f>\n</rdf:Description>\n</rdf:RDF>\n",
+ /* RdfXmlR */ "<rdf:RDF>\n
<rdf:Description>\n <jp:f>1</jp:f>\n </rdf:Description>\n</rdf:RDF>\n"
+ )
+ .properties(OMap.of(BEANTRAVERSE_initialDepth,
2))
+ },
+ });
+ }
+
+ public BeanTraverseComboTest(ComboInput<?> comboInput) {
+ super(comboInput);
+ }
+}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ThrowableUtils.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ThrowableUtils.java
index 6cf147a..c3adf5f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ThrowableUtils.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ThrowableUtils.java
@@ -81,4 +81,20 @@ public class ThrowableUtils {
if (Thread.currentThread().getId() != threadId)
throw new BasicIllegalArgumentException(msg, args);
}
+
+ /**
+ * Throws an assertion error if the specified throwable or throwable
causes do not contain the specified message string.
+ *
+ * @param t The throwable to check.
+ * @param msg The message text to check for.
+ * @throws AssertionError Assertion failed.
+ */
+ public static void assertExceptionContainsMessage(Throwable t, String
msg) throws AssertionError {
+ while (t != null) {
+ if (t.getMessage() != null &&
t.getMessage().contains(msg))
+ return;
+ t = t.getCause();
+ }
+ throw new BasicAssertionError(t, "Throwable did not contain the
expected message. Message=[{0}]", msg);
+ }
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
index 61329cd..3327eb4 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
@@ -51,7 +51,7 @@ public class JsonSerializerSession extends
WriterSerializerSession {
@Override /* SerializerSesssion */
protected void doSerialize(SerializerPipe out, Object o) throws
IOException, SerializeException {
- serializeAnything(getJsonWriter(out), o,
getExpectedRootType(o), "root", null);
+ serializeAnything(getJsonWriter(out).i(getInitialDepth()), o,
getExpectedRootType(o), "root", null);
}
/**
@@ -66,7 +66,7 @@ public class JsonSerializerSession extends
WriterSerializerSession {
*/
protected String serializeJson(Object o) throws Exception {
StringWriter sw = new StringWriter();
- serializeAnything(getJsonWriter(createPipe(sw)), o,
getExpectedRootType(o), "root", null);
+
serializeAnything(getJsonWriter(createPipe(sw)).i(getInitialDepth()), o,
getExpectedRootType(o), "root", null);
return sw.toString();
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
index 881eeb2..040d994 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
@@ -73,7 +73,7 @@ public class UonSerializerSession extends
WriterSerializerSession implements Htt
@Override /* Serializer */
protected void doSerialize(SerializerPipe out, Object o) throws
IOException, SerializeException {
- serializeAnything(getUonWriter(out), o, getExpectedRootType(o),
"root", null);
+ serializeAnything(getUonWriter(out).i(getInitialDepth()), o,
getExpectedRootType(o), "root", null);
}
/**
@@ -284,7 +284,7 @@ public class UonSerializerSession extends
WriterSerializerSession implements Htt
}
}
StringWriter w = new StringWriter();
- serializeAnything(getUonWriter(w), value,
getExpectedRootType(value), "root", null);
+ serializeAnything(getUonWriter(w).i(getInitialDepth()),
value, getExpectedRootType(value), "root", null);
return w.toString();
} catch (Exception e) {
throw new RuntimeException(e);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
index cc2f9ad..02333f5 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
@@ -85,7 +85,7 @@ public class UrlEncodingSerializerSession extends
UonSerializerSession {
@Override /* SerializerSession */
protected void doSerialize(SerializerPipe out, Object o) throws
IOException, SerializeException {
- serializeAnything(getUonWriter(out), o);
+ serializeAnything(getUonWriter(out).i(getInitialDepth()), o);
}
/*
diff --git
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClientBuilderTest.java
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClientBuilderTest.java
index 72798fc..462b438 100644
---
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClientBuilderTest.java
+++
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClientBuilderTest.java
@@ -2237,14 +2237,6 @@ public class RestClientBuilderTest {
// Serializer properties
//-----------------------------------------------------------------------------------------------------------------
- @Rest
- public static class L extends BasicRest {
- @RestMethod(path="/")
- public Reader post(org.apache.juneau.rest.RestRequest req)
throws IOException {
- return req.getBody().getReader();
- }
- }
-
public static class L1 {
public Object f1;
@@ -2269,59 +2261,59 @@ public class RestClientBuilderTest {
@Test
public void l01a_serializer_addBeanTypes() throws Exception {
RestClient rc = MockRestClient
- .create(L.class)
+ .create(A.class)
.simpleJson()
.addBeanTypes(true)
.build();
- rc.post("",
L1.create()).run().getBody().assertValue("{f1:{_type:'L',f2:1}}");
+ rc.post("/echoBody",
L1.create()).run().getBody().assertValue("{f1:{_type:'L',f2:1}}");
rc = MockRestClient
- .create(L.class)
+ .create(A.class)
.simpleJson()
.addBeanTypes(false)
.build();
- rc.post("",
L1.create()).run().getBody().assertValue("{f1:{f2:1}}");
+ rc.post("/echoBody",
L1.create()).run().getBody().assertValue("{f1:{f2:1}}");
rc = MockRestClient
- .create(L.class)
+ .create(A.class)
.simpleJson()
.addBeanTypes()
.build();
- rc.post("",
L1.create()).run().getBody().assertValue("{f1:{_type:'L',f2:1}}");
+ rc.post("/echoBody",
L1.create()).run().getBody().assertValue("{f1:{_type:'L',f2:1}}");
}
@Test
public void l03_serializer_addRootType() throws Exception {
RestClient rc = MockRestClient
- .create(L.class)
+ .create(A.class)
.simpleJson()
.addRootType(true)
.build();
- rc.post("", L2.create()).run().getBody().assertValue("{f2:1}");
+ rc.post("/echoBody",
L2.create()).run().getBody().assertValue("{f2:1}");
rc = MockRestClient
- .create(L.class)
+ .create(A.class)
.simpleJson()
.addBeanTypes()
.addRootType(false)
.build();
- rc.post("", L2.create()).run().getBody().assertValue("{f2:1}");
+ rc.post("/echoBody",
L2.create()).run().getBody().assertValue("{f2:1}");
rc = MockRestClient
- .create(L.class)
+ .create(A.class)
.simpleJson()
.addBeanTypes()
.addRootType(true)
.build();
- rc.post("",
L2.create()).run().getBody().assertValue("{_type:'L',f2:1}");
+ rc.post("/echoBody",
L2.create()).run().getBody().assertValue("{_type:'L',f2:1}");
rc = MockRestClient
- .create(L.class)
+ .create(A.class)
.simpleJson()
.addBeanTypes()
.addRootType()
.build();
- rc.post("",
L2.create()).run().getBody().assertValue("{_type:'L',f2:1}");
+ rc.post("/echoBody",
L2.create()).run().getBody().assertValue("{_type:'L',f2:1}");
}
@Test
@@ -2330,23 +2322,23 @@ public class RestClientBuilderTest {
l1.f1 = l1;
RestClient rc = MockRestClient
- .create(L.class)
+ .create(A.class)
.simpleJson()
.detectRecursions()
.build();
try {
- rc.post("", l1).run();
+ rc.post("/echoBody", l1).run();
} catch (RestCallException e) {
assertTrue(e.getCause().getCause().getMessage().startsWith("Recursion
occurred"));
}
rc = MockRestClient
- .create(L.class)
+ .create(A.class)
.simpleJson()
.detectRecursions(true)
.build();
try {
- rc.post("", l1).run();
+ rc.post("/echoBody", l1).run();
} catch (RestCallException e) {
assertTrue(e.getCause().getCause().getMessage().startsWith("Recursion
occurred"));
}
@@ -2358,24 +2350,33 @@ public class RestClientBuilderTest {
l1.f1 = l1;
RestClient rc = MockRestClient
- .create(L.class)
+ .create(A.class)
.simpleJson()
.ignoreRecursions()
.build();
- rc.post("", l1).run().getBody().assertValue("{}");
+ rc.post("/echoBody", l1).run().getBody().assertValue("{}");
rc = MockRestClient
- .create(L.class)
+ .create(A.class)
.simpleJson()
.ignoreRecursions(true)
.build();
- rc.post("", l1).run().getBody().assertValue("{}");
+ rc.post("/echoBody", l1).run().getBody().assertValue("{}");
}
-// @Test
-// public void l09_serializer_initialDepth() throws Exception { fail(); }
-//// public RestClientBuilder initialDepth(int value) {
-//
+ @Test
+ public void l09_serializer_initialDepth() throws Exception {
+ RestClient rc = MockRestClient
+ .create(A.class)
+ .simpleJson()
+ .initialDepth(2)
+ .ws()
+ .build();
+ rc.post("/echoBody",
bean).run().getBody().assertValue("\t\t{\n\t\t\tf: 1\n\t\t}");
+ }
+
+// public RestClientBuilder initialDepth(int value) {
+
// @Test
// public void l10_serializer_listenerSClass() throws Exception { fail(); }
//// public RestClientBuilder listenerS(Class<? extends SerializerListener>
value) {
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponseBody.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponseBody.java
index 5472c3e..723b662 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponseBody.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponseBody.java
@@ -1547,8 +1547,16 @@ public class RestResponseBody implements HttpEntity {
*/
public RestResponse assertValue(String value) throws RestCallException,
AssertionError {
String text = asString();
- if (! StringUtils.isEquals(value, text))
+ if (! StringUtils.isEquals(value, text)) {
+ if (value != null && value.startsWith("x")) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Response did not have the expected
value for body.");
+ sb.append("\nExpected:
[").append(value.replaceAll("\\\\", "\\\\\\\\").replaceAll("\n",
"\\\\n").replaceAll("\t", "\\\\t")).append("]");
+ sb.append("\nActual :
[").append(text.replaceAll("\\\\", "\\\\\\\\").replaceAll("\n",
"\\\\n").replaceAll("\t", "\\\\t")).append("]");
+ System.err.println(sb);
+ }
throw new BasicAssertionError("Response did not have
the expected value for body.\n\tExpected=[{0}]\n\tActual=[{1}]", value, text);
+ }
return response;
}