From f1e50d4d15c486a95453bb3ac690975a53eea011 Mon Sep 17 00:00:00 2001 From: "manuele.simi" Date: Fri, 19 Jan 2018 04:15:31 +0000 Subject: [PATCH] Add step2_Delete test case to delete a context. The sequential tests now are able to create and delete the test contexts. git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@162341 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../manager/webapp/context/RMContextTest.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/RMContextTest.java b/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/RMContextTest.java index d34c7e7..a53a4f7 100644 --- a/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/RMContextTest.java +++ b/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/RMContextTest.java @@ -115,13 +115,12 @@ public class RMContextTest extends JerseyTest { if (skipTest) return; Context newContext = new ContextImpl(context1Name, context1UUID); - System.out.println(newContext.getHeader().getUUID().toString()); try { System.out.print(ISMapper.marshal(newContext)); Response create = target("context").queryParam(RMContextPath.FORCE_RRURL_PARAM, RR).request() .post(Entity.entity(ISMapper.marshal(newContext), MediaType.APPLICATION_JSON + ";charset=UTF-8")); assertNotNull(create); - if (create.getStatusInfo() == Status.OK) { + if (create.getStatusInfo() == Status.CREATED) { String message = create.readEntity(String.class); System.out.println("RM says: " + message); }else { @@ -145,14 +144,14 @@ public class RMContextTest extends JerseyTest { public void step2_Delete() { if (skipTest) return; - Context newContext = new ContextImpl(context1Name); try { - Response create = target("context").request() - .post(Entity.entity(ISMapper.marshal(newContext), MediaType.APPLICATION_JSON + ";charset=UTF-8")); + Response create = target(RMContextPath.CONTEXT_ROOT).path(context1UUID.toString()) + .queryParam(RMContextPath.FORCE_RRURL_PARAM, RR) + .request().delete(); assertEquals("Unexpected returned code. Reason: " + create.getStatusInfo().getReasonPhrase(), - Status.BAD_REQUEST.getStatusCode(), create.getStatus()); - } catch (JsonProcessingException e) { - assertFalse("Failed to marshal the context.", false); + Status.OK.getStatusCode(), create.getStatus()); + } catch (Exception e) { + assertFalse("Failed to delete the context.", false); } } @@ -168,7 +167,7 @@ public class RMContextTest extends JerseyTest { Context newContext = new ContextImpl(context1Name); newContext.setParent(new ContextImpl("DoNotExist")); try { - Response create = target("context").request() + Response create = target(RMContextPath.CONTEXT_ROOT).request() .post(Entity.entity(ISMapper.marshal(newContext), MediaType.APPLICATION_JSON + ";charset=UTF-8")); assertEquals("Unexpected returned code. Reason: " + create.getStatusInfo().getReasonPhrase(), Status.BAD_REQUEST.getStatusCode(), create.getStatus());