Removed all mention of www.example.org from tests 26/91026/3
authorJohnKeeney <John.Keeney@est.tech>
Tue, 9 Jul 2019 12:32:41 +0000 (12:32 +0000)
committerJohnKeeney <John.Keeney@est.tech>
Tue, 9 Jul 2019 12:32:41 +0000 (12:32 +0000)
Replaced those tests with test using a local/temp webserver to exercise
the RestManager
Updated with Jim/Pam's suggestions.
Updated following SONAR changed to policy/common

Change-Id: Ia2551fbcafd2cd30d74a881237b003216e8caec7
Issue-ID: POLICY-1665
Signed-off-by: JohnKeeney <John.Keeney@est.tech>
models-interactions/model-impl/rest/pom.xml
models-interactions/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java
models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/GetTest.java [deleted file]
models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/HttpDeleteWithBodyTest.java
models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/PostTest.java [deleted file]
models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/PutTest.java [deleted file]
models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java [new file with mode: 0644]

index a37c7ac..ca15b0b 100644 (file)
   <artifactId>rest</artifactId>
 
   <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>com.google.code.gson</groupId>
       <artifactId>gson</artifactId>
       <artifactId>httpclient</artifactId>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.onap.policy.common</groupId>
+      <artifactId>policy-endpoints</artifactId>
+      <version>${policy.common.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
     <build>
index f19ed78..2ee47a9 100644 (file)
@@ -27,6 +27,7 @@ import java.util.Map.Entry;
 import javax.xml.bind.DatatypeConverter;
 import org.apache.http.HttpHeaders;
 import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPut;
@@ -124,7 +125,8 @@ public class RestManager {
     }
 
     /**
-     * Perform REST Delete.
+     * Perform REST Delete. <br/>
+     * <i>Note: Many REST endpoints will return a 400 error for delete requests with a non-empty body</i>
      *
      * @param url         the url
      * @param username    the user name
@@ -138,8 +140,8 @@ public class RestManager {
                                         String contentType, String body) {
         HttpDeleteWithBody delete = new HttpDeleteWithBody(url);
         addHeaders(delete, username, password, headers);
-        delete.addHeader("Content-Type", contentType);
         if (body != null && !body.isEmpty()) {
+            delete.addHeader("Content-Type", contentType);
             try {
                 StringEntity input = new StringEntity(body);
                 input.setContentType(contentType);
@@ -152,6 +154,21 @@ public class RestManager {
         return sendRequest(delete);
     }
 
+    /**
+     * Perform REST Delete.
+     *
+     * @param url         the url
+     * @param username    the user name
+     * @param password    the password
+     * @param headers     any headers
+     * @return the response status code and the body
+     */
+    public Pair<Integer, String> delete(String url, String username, String password, Map<String, String> headers) {
+        HttpDelete delete = new HttpDelete(url);
+        addHeaders(delete, username, password, headers);
+        return sendRequest(delete);
+    }
+
     /**
      * Send REST request.
      *
diff --git a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/GetTest.java b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/GetTest.java
deleted file mode 100644 (file)
index a14d869..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * rest
- * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.rest;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.onap.policy.rest.RestManager.Pair;
-
-public class GetTest {
-
-    @Test(expected = NullPointerException.class)
-    public void testUrlNull() {
-        RestManager mgr = new RestManager();
-        mgr.get(null, "user", null, null);
-    }
-
-    @Test
-    public void testUsernameNull() {
-        RestManager mgr = new RestManager();
-
-        Pair<Integer, String> result = mgr.get("http://www.example.org", null, null, null);
-        assertEquals((Integer)200, result.first);
-        assertTrue(result.second != null);
-        assertTrue(result.second.length() > 0);
-    }
-
-    @Test
-    public void testUsernameEmpty() {
-        RestManager mgr = new RestManager();
-
-        Pair<Integer, String> result = mgr.get("http://www.example.org", "", null, null);
-        assertEquals((Integer)200, result.first);
-        assertTrue(result.second != null);
-        assertTrue(result.second.length() > 0);
-    }
-
-    @Test
-    public void testUrlExampleOrg() {
-        RestManager mgr = new RestManager();
-
-        Pair<Integer, String> result = mgr.get("http://www.example.org", "user", null, null);
-        assertEquals((Integer)200, result.first);
-        assertTrue(result.second != null);
-        assertTrue(result.second.length() > 0);
-    }
-}
index 2a114f5..cfdc859 100644 (file)
@@ -27,11 +27,12 @@ import org.junit.Test;
 
 public class HttpDeleteWithBodyTest {
 
+    private static final String NO_URI = "BlahBlah";
+
     @Test
     public void getMethod() {
-        String url = "http://www.example.org";
-        HttpDeleteWithBody deleteWithBody = new HttpDeleteWithBody(url);
+        HttpDeleteWithBody deleteWithBody = new HttpDeleteWithBody(NO_URI);
         assertEquals("DELETE", deleteWithBody.getMethod());
-        assertEquals(url, deleteWithBody.getURI().toString());
+        assertEquals(NO_URI, deleteWithBody.getURI().toString());
     }
 }
\ No newline at end of file
diff --git a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/PostTest.java b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/PostTest.java
deleted file mode 100644 (file)
index 9cda5f0..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * rest
- * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.rest;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-import org.onap.policy.rest.RestManager.Pair;
-
-public class PostTest {
-
-    @Test
-    public void testUsernameNull() {
-        RestManager mgr = new RestManager();
-        Pair<Integer, String> result = mgr.post("http://www.example.org", null, null, null, null, null);
-        assertEquals(null, result);
-    }
-
-    @Test
-    public void testUsernameEmpty() {
-        RestManager mgr = new RestManager();
-        Pair<Integer, String> result = mgr.post("http://www.example.org", "", null, null, null, null);
-        assertEquals(null, result);
-    }
-
-    @Test
-    public void testBodyNull() {
-        RestManager mgr = new RestManager();
-        Pair<Integer, String> result = mgr.post("http://www.example.org", "user", null, null, null, null);
-        assertEquals(null, result);
-    }
-}
diff --git a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/PutTest.java b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/PutTest.java
deleted file mode 100644 (file)
index 3c72205..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * rest
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.rest;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-import org.onap.policy.rest.RestManager.Pair;
-
-public class PutTest {
-
-    @Test
-    public void testUsernameNull() {
-        RestManager mgr = new RestManager();
-        Pair<Integer, String> result = mgr.put("http://www.example.org", null, null, null, null, null);
-        assertEquals(null, result);
-    }
-
-    @Test
-    public void testUsernameEmpty() {
-        RestManager mgr = new RestManager();
-        Pair<Integer, String> result = mgr.put("http://www.example.org", "", null, null, null, null);
-        assertEquals(null, result);
-    }
-
-    @Test
-    public void testBodyNull() {
-        RestManager mgr = new RestManager();
-        Pair<Integer, String> result = mgr.put("http://www.example.org", "user", null, null, null, null);
-        assertEquals(null, result);
-    }
-}
-
diff --git a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java
new file mode 100644 (file)
index 0000000..903ec2f
--- /dev/null
@@ -0,0 +1,390 @@
+/*
+ * ============LICENSE_START=======================================================
+ * rest
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
+import org.onap.policy.common.utils.network.NetworkUtil;
+import org.onap.policy.rest.RestManager.Pair;
+
+@Path("RestTest")
+public class RestTest {
+
+
+    private static final String NAME_PARAM = "Bob";
+    private static final String AGE_PARAM = "10";
+    private static final String PAYLOAD = "At last! ";
+    private static final String RETURN_STRING = "Hello There ";
+    private static final String EXPECT_STRING = RETURN_STRING + NAME_PARAM + " aged " + AGE_PARAM;
+
+    private static final String LOCALHOST = "localhost";
+    private static final String BASE = "base";
+
+    private static int port;
+    private static String baseUri;
+    private static String getUri;
+    private static String deleteUri;
+    private static String putUri;
+    private static String putUriBlank;
+    private static String postUri;
+    private static String postUriBlank;
+
+    private static HttpServletServer server;
+
+    /**
+     * Sets server endpoint for the tests.
+     */
+    @BeforeClass
+    public static void setUp() throws Exception {
+
+        port = NetworkUtil.allocPort();
+        baseUri = "http://" + LOCALHOST + ":" + port + "/" + BASE + "/";
+        getUri = baseUri + "RestTest/GetHello/" + NAME_PARAM + "?age=" + AGE_PARAM;
+        deleteUri = baseUri + "RestTest/DeleteHello/" + NAME_PARAM + "?age=" + AGE_PARAM;
+        putUri = baseUri + "RestTest/PutHello/" + NAME_PARAM + "?age=" + AGE_PARAM;
+        putUriBlank = baseUri + "RestTest/PutBlank";
+        postUri = baseUri + "RestTest/PostHello/" + NAME_PARAM + "?age=" + AGE_PARAM;
+        postUriBlank = baseUri + "RestTest/PostBlank";
+
+        server = HttpServletServerFactoryInstance.getServerFactory()
+            .build("RestTest", LOCALHOST, port, "/" + BASE, false, true);
+        server.addServletClass("/*", RestTest.class.getName());
+        server.waitedStart(5000);
+
+    }
+
+    /**
+     * Tear down server endpoint for the tests.
+     *
+     * @throws Exception if there is a problem
+     */
+    @AfterClass
+    public static void tearDown() throws Exception {
+        HttpServletServerFactoryInstance.getServerFactory().destroy();
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testGetUrlNull() {
+        RestManager mgr = new RestManager();
+        mgr.get(null, "user", null, null);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testPutUrlNull() {
+        RestManager mgr = new RestManager();
+        mgr.put(null, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testPostUrlNull() {
+        RestManager mgr = new RestManager();
+        mgr.post(null, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testDeleteUrlNull() {
+        RestManager mgr = new RestManager();
+        mgr.delete(null, "user", null, null, null, null);
+    }
+
+    @Test
+    public void testUsernameNull() {
+        RestManager mgr = new RestManager();
+
+        Pair<Integer, String> result = mgr.get(getUri, null, null, null);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("GOT: " + EXPECT_STRING, result.second);
+
+        result = mgr.delete(deleteUri, null, null, null, null, null);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("DELETE: " + EXPECT_STRING, result.second);
+
+        result = mgr.delete(deleteUri, null, null, null);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("DELETE: " + EXPECT_STRING, result.second);
+
+        result = mgr.put(putUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.second);
+
+        result = mgr.put(putUriBlank, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.second);
+
+        result = mgr.post(postUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.second);
+
+        result = mgr.post(postUriBlank, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.second);
+    }
+
+    @Test
+    public void testUsernameEmpty() {
+        RestManager mgr = new RestManager();
+
+        Pair<Integer, String> result = mgr.get(getUri, "", null, null);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("GOT: " + EXPECT_STRING, result.second);
+
+        result = mgr.delete(deleteUri, "", null, null, null, null);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("DELETE: " + EXPECT_STRING, result.second);
+
+        result = mgr.put(putUri, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.second);
+
+        result = mgr.put(putUriBlank, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.second);
+
+        result = mgr.post(postUri, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.second);
+
+        result = mgr.post(postUriBlank, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.second);
+    }
+
+    @Test
+    public void testGoodUrl() {
+        RestManager mgr = new RestManager();
+
+        Pair<Integer, String> result = mgr.get(getUri, "user", null, null);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("GOT: " + EXPECT_STRING, result.second);
+
+        result = mgr.delete(deleteUri, "user", null, null, null, null);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("DELETE: " + EXPECT_STRING, result.second);
+
+        result = mgr.put(putUri, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.second);
+
+        result = mgr.put(putUriBlank, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.second);
+
+        result = mgr.post(postUri, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.second);
+
+        result = mgr.post(postUriBlank, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.second);
+    }
+
+    @Test
+    public void testNoUrlParamUrl() {
+        RestManager mgr = new RestManager();
+
+        Pair<Integer, String> result = mgr.get(baseUri + "RestTest/GetHello/", null, null, null);
+        assertEquals((Integer)404, result.first);
+
+        result = mgr.delete(baseUri + "RestTest/DeleteHello/", null, null, null, null, null);
+        assertEquals((Integer)404, result.first);
+
+        result = mgr.put(baseUri + "RestTest/PutHello/", null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)404, result.first);
+
+        result = mgr.post(baseUri + "RestTest/PostHello/", null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)404, result.first);
+    }
+
+    @Test
+    public void testNoQueryParamUrl() {
+        RestManager mgr = new RestManager();
+
+        Pair<Integer, String> result = mgr.get(baseUri + "RestTest/GetHello/" + NAME_PARAM, null, null, null);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("GOT: " + RETURN_STRING + NAME_PARAM + " aged 90", result.second);
+
+        result = mgr.delete(baseUri + "RestTest/DeleteHello/" + NAME_PARAM, null, null, null, null, null);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("DELETE: " + RETURN_STRING + NAME_PARAM + " aged 90", result.second);
+
+        result = mgr.put(baseUri + "RestTest/PutHello/" + NAME_PARAM, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("PUT: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.second);
+
+        result = mgr.post(baseUri + "RestTest/PostHello/" + NAME_PARAM, null, null,
+            null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)200, result.first);
+        assertTrue(result.second != null);
+        assertTrue(result.second.length() > 0);
+        assertEquals("POST: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.second);
+    }
+
+    @Test
+    public void testBadUrl() {
+        RestManager mgr = new RestManager();
+
+        Pair<Integer, String> result = mgr.get(baseUri + "NonExistant/URL/", null, null, null);
+        assertEquals((Integer)404, result.first);
+
+        result = mgr.delete(baseUri + "NonExistant/URL/", null, null, null, null, null);
+        assertEquals((Integer)404, result.first);
+
+        result = mgr.put(baseUri + "NonExistant/URL/", null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)404, result.first);
+
+        result = mgr.post(baseUri + "NonExistant/URL/", null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)404, result.first);
+    }
+
+    @Test
+    public void testWrongUrl() {
+        RestManager mgr = new RestManager();
+
+        Pair<Integer, String> result = mgr.get(deleteUri, null, null, null);
+        assertEquals((Integer)405, result.first);
+
+        result = mgr.delete(getUri, null, null, null, null, null);
+        assertEquals((Integer)405, result.first);
+
+        result = mgr.delete(getUri, null, null, null);
+        assertEquals((Integer)405, result.first);
+
+        result = mgr.put(getUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)405, result.first);
+
+        result = mgr.post(getUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
+        assertEquals((Integer)405, result.first);
+    }
+
+    @GET
+    @Path("/GetHello/{name}")
+    @Produces(MediaType.TEXT_PLAIN)
+    public String getIt( @PathParam("name") String name, @DefaultValue("90") @QueryParam("age") String age) {
+        return "GOT: " + RETURN_STRING + name + " aged " + age;
+    }
+
+    @DELETE
+    @Path("/DeleteHello/{name}")
+    @Produces(MediaType.TEXT_PLAIN)
+    public String deleteIt( @PathParam("name") String name, @DefaultValue("90") @QueryParam("age") String age) {
+        return "DELETE: " + RETURN_STRING + name + " aged " + age;
+    }
+
+    @PUT
+    @Path("/PutHello/{name}")
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String putBlank(
+        String payload,
+        @PathParam("name") String name,
+        @DefaultValue("90") @QueryParam("age") String age) {
+
+        return "PUT: " + payload + RETURN_STRING + name + " aged " + age;
+    }
+
+    @PUT
+    @Path("/PutBlank")
+    @Produces(MediaType.TEXT_PLAIN)
+    public String putIt( String payload) {
+        return "PUT: " + payload + RETURN_STRING;
+    }
+
+    @POST
+    @Path("/PostHello/{name}")
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String postIt(
+        String payload,
+        @PathParam("name") String name,
+        @DefaultValue("90") @QueryParam("age") String age) {
+
+        return "POST: " + payload + RETURN_STRING + name + " aged " + age;
+    }
+
+    @POST
+    @Path("/PostBlank")
+    @Produces(MediaType.TEXT_PLAIN)
+    public String postBlank( String payload) {
+        return "POST: " + payload + RETURN_STRING;
+    }
+}