mirror of https://github.com/apache/jclouds.git
Simplifying BaseRestClientExpectTest's comparison of non-payload requests
This commit is contained in:
parent
588a7c38ad
commit
f3dc23f578
|
@ -367,12 +367,15 @@ public abstract class BaseRestClientExpectTest<S> {
|
||||||
*/
|
*/
|
||||||
public boolean httpRequestsAreEqual(HttpRequest a, HttpRequest b) {
|
public boolean httpRequestsAreEqual(HttpRequest a, HttpRequest b) {
|
||||||
try {
|
try {
|
||||||
|
if (a == null || b == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (a.getPayload() == null || b.getPayload() == null) {
|
||||||
|
return Objects.equal(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
switch (compareHttpRequestAsType(a)) {
|
switch (compareHttpRequestAsType(a)) {
|
||||||
case XML: {
|
case XML: {
|
||||||
if (a == null || b == null || a.getPayload() == null || b.getPayload() == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Diff diff = XMLUnit.compareXML(Strings2.toStringAndClose(a.getPayload().getInput()), Strings2
|
Diff diff = XMLUnit.compareXML(Strings2.toStringAndClose(a.getPayload().getInput()), Strings2
|
||||||
.toStringAndClose(b.getPayload().getInput()));
|
.toStringAndClose(b.getPayload().getInput()));
|
||||||
|
|
||||||
|
@ -405,9 +408,6 @@ public abstract class BaseRestClientExpectTest<S> {
|
||||||
return diff.identical() && Objects.equal(a.getHeaders(), b.getHeaders());
|
return diff.identical() && Objects.equal(a.getHeaders(), b.getHeaders());
|
||||||
}
|
}
|
||||||
case JSON: {
|
case JSON: {
|
||||||
if (a == null || b == null || a.getPayload() == null || b.getPayload() == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
JsonElement payloadA = parser.parse(Strings2.toStringAndClose(a.getPayload().getInput()));
|
JsonElement payloadA = parser.parse(Strings2.toStringAndClose(a.getPayload().getInput()));
|
||||||
JsonElement payloadB = parser.parse(Strings2.toStringAndClose(b.getPayload().getInput()));
|
JsonElement payloadB = parser.parse(Strings2.toStringAndClose(b.getPayload().getInput()));
|
||||||
|
|
Loading…
Reference in New Issue