Adding requestLine check to ensure all HttpRequestComparisonTypes compare endpoints and methods

This commit is contained in:
Adam Lowe 2012-05-10 15:21:48 +01:00
parent 8163b6ee64
commit f11518fa1e
1 changed files with 4 additions and 3 deletions

View File

@ -367,7 +367,8 @@ 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) { if (a == null || b == null || !Objects.equal(a.getRequestLine(), b.getRequestLine())
|| !Objects.equal(a.getHeaders(), b.getHeaders())) {
return false; return false;
} }
if (a.getPayload() == null || b.getPayload() == null) { if (a.getPayload() == null || b.getPayload() == null) {
@ -405,13 +406,13 @@ public abstract class BaseRestClientExpectTest<S> {
} }
}); });
return diff.identical() && Objects.equal(a.getHeaders(), b.getHeaders()); return diff.identical();
} }
case JSON: { case JSON: {
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()));
return Objects.equal(payloadA, payloadB) && Objects.equal(a.getHeaders(), b.getHeaders()); return Objects.equal(payloadA, payloadB);
} }
default: { default: {
return Objects.equal(a, b); return Objects.equal(a, b);