From f3dc23f57860aecff91d69732ad4f23e923b6d23 Mon Sep 17 00:00:00 2001 From: Adam Lowe Date: Fri, 27 Apr 2012 16:35:22 +0100 Subject: [PATCH] Simplifying BaseRestClientExpectTest's comparison of non-payload requests --- .../rest/internal/BaseRestClientExpectTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java index 8e77a564be..f4ab26c2c8 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java @@ -367,12 +367,15 @@ public abstract class BaseRestClientExpectTest { */ public boolean httpRequestsAreEqual(HttpRequest a, HttpRequest b) { try { + if (a == null || b == null) { + return false; + } + if (a.getPayload() == null || b.getPayload() == null) { + return Objects.equal(a, b); + } + switch (compareHttpRequestAsType(a)) { 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 .toStringAndClose(b.getPayload().getInput())); @@ -404,10 +407,7 @@ public abstract class BaseRestClientExpectTest { return diff.identical() && Objects.equal(a.getHeaders(), b.getHeaders()); } - case JSON: { - if (a == null || b == null || a.getPayload() == null || b.getPayload() == null) { - return false; - } + case JSON: { JsonParser parser = new JsonParser(); JsonElement payloadA = parser.parse(Strings2.toStringAndClose(a.getPayload().getInput())); JsonElement payloadB = parser.parse(Strings2.toStringAndClose(b.getPayload().getInput()));