Merge pull request #624 from aplowe/master

BaseRestClientExpectTest missing check on endpoints/methods
This commit is contained in:
Adrian Cole 2012-05-10 14:36:30 -07:00
commit c04d2ee7e4
6 changed files with 11 additions and 10 deletions

View File

@ -367,7 +367,8 @@ public abstract class BaseRestClientExpectTest<S> {
*/
public boolean httpRequestsAreEqual(HttpRequest a, HttpRequest b) {
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;
}
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: {
JsonParser parser = new JsonParser();
JsonElement payloadA = parser.parse(Strings2.toStringAndClose(a.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: {
return Objects.equal(a, b);

View File

@ -80,7 +80,7 @@ public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest {
@Test
public void testCloneMedia() {
URI cloneUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneMedia");
URI vdcURI = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
@ -105,7 +105,7 @@ public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest {
.build();
Media expected = cloneMedia();
assertEquals(client.getMediaClient().cloneMedia(cloneUri, params), expected);
assertEquals(client.getMediaClient().cloneMedia(vdcURI, params), expected);
}
@Test

View File

@ -394,7 +394,7 @@ public class VAppTemplateClientExpectTest extends VCloudDirectorAdminClientExpec
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata").acceptMedia(ANY).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/metadata.xml", METADATA).httpResponseBuilder().build(),
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/metadata").xmlFilePayload("/vapptemplate/metadata.xml", METADATA).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/metadata").xmlFilePayload("/vapptemplate/metadata.xml", METADATA).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/task/task.xml", TASK).httpResponseBuilder().build()
).getVAppTemplateClient();
@ -425,7 +425,7 @@ public class VAppTemplateClientExpectTest extends VCloudDirectorAdminClientExpec
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/metadata").xmlFilePayload("/vapptemplate/metadata.xml", METADATA).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/metadata").xmlFilePayload("/vapptemplate/metadata.xml", METADATA).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.getMetadataClient().mergeMetadata(uri, exampleMetadata());

View File

@ -53,7 +53,7 @@ public class AdminCatalogClientExpectTest extends VCloudDirectorAdminClientExpec
public void testCreateCatalog() {
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/catalogs")
.apiCommand("POST", "/admin/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/catalogs")
.xmlFilePayload("/catalog/admin/createCatalogSource.xml", VCloudDirectorMediaType.ADMIN_CATALOG)
.acceptMedia(VCloudDirectorMediaType.ADMIN_CATALOG)
.httpRequestBuilder().build(),

View File

@ -66,7 +66,7 @@ public class AdminNetworkClientExpectTest extends VCloudDirectorAdminClientExpec
public void testUpdateNetwork() {
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", "/admin/network/b466c0c5-8a5c-4335-b703-a2e2e6b5f3e1")
.apiCommand("PUT", "/admin/network/b466c0c5-8a5c-4335-b703-a2e2e6b5f3e1")
.xmlFilePayload("/network/admin/updateNetworkSource.xml", VCloudDirectorMediaType.ORG_NETWORK)
.acceptMedia(VCloudDirectorMediaType.TASK)
.httpRequestBuilder().build(),

View File

@ -52,7 +52,7 @@ public class UserClientExpectTest extends VCloudDirectorAdminClientExpectTest {
public void testCreateUser() {
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/catalogs")
.apiCommand("POST", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/users")
.xmlFilePayload("/user/createUserSource.xml", VCloudDirectorMediaType.USER)
.acceptMedia(VCloudDirectorMediaType.USER)
.httpRequestBuilder().build(),