summaryrefslogtreecommitdiff
path: root/qpid/java/systests/src
diff options
context:
space:
mode:
authorAlex Rudyy <orudyy@apache.org>2015-03-13 21:48:51 +0000
committerAlex Rudyy <orudyy@apache.org>2015-03-13 21:48:51 +0000
commitea42a108d6a5ecfdca0da86084efab2065494b23 (patch)
tree476624b781dfaf7920602f8c7d42c4691e83345b /qpid/java/systests/src
parent24f6d1a9f55cf025c183b353da5feebed39d9d79 (diff)
downloadqpid-python-ea42a108d6a5ecfdca0da86084efab2065494b23.tar.gz
QPID-6438: Set Location header for REST create requests
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1666591 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/systests/src')
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java20
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java20
2 files changed, 33 insertions, 7 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java
index db89f39953..6e2d3b901b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java
@@ -502,8 +502,12 @@ public class RestTestHelper
}
}
- public int submitRequest(String url, String method, Map<String, Object> attributes) throws IOException,
- JsonGenerationException, JsonMappingException
+ public int submitRequest(String url, String method, Map<String, Object> attributes) throws IOException
+ {
+ return submitRequest(url, method, attributes, null);
+ }
+
+ public int submitRequest(String url, String method, Map<String, Object> attributes, Map<String, List<String>> responseHeadersToCapture) throws IOException
{
HttpURLConnection connection = openManagementConnection(url, method);
if (attributes != null)
@@ -511,6 +515,10 @@ public class RestTestHelper
writeJsonRequest(connection, attributes);
}
int responseCode = connection.getResponseCode();
+ if (responseHeadersToCapture!= null)
+ {
+ responseHeadersToCapture.putAll(connection.getHeaderFields());
+ }
connection.disconnect();
return responseCode;
}
@@ -522,8 +530,14 @@ public class RestTestHelper
public void submitRequest(String url, String method, Map<String, Object> attributes, int expectedResponseCode) throws IOException
{
- int responseCode = submitRequest(url, method, attributes);
+ Map<String, List<String>> headers = new HashMap<>();
+ int responseCode = submitRequest(url, method, attributes, headers);
Assert.assertEquals("Unexpected response code from " + method + " " + url , expectedResponseCode, responseCode);
+ if (expectedResponseCode == 201)
+ {
+ List<String> location = headers.get("Location");
+ Assert.assertTrue("Location is not returned by REST create request", location != null && location.size() == 1);
+ }
}
public void submitRequest(String url, String method, int expectedResponseCode) throws IOException
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java
index 15be0c8196..69d8f0f4f7 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java
@@ -43,6 +43,7 @@ import org.apache.qpid.server.virtualhost.AbstractVirtualHost;
import org.apache.qpid.server.virtualhost.derby.DerbyVirtualHostImpl;
import org.apache.qpid.server.virtualhostnode.JsonVirtualHostNodeImpl;
import org.apache.qpid.test.utils.TestBrokerConfiguration;
+import org.junit.Assert;
public class VirtualHostRestTest extends QpidRestTestCase
{
@@ -635,10 +636,21 @@ public class VirtualHostRestTest extends QpidRestTestCase
{
url += "/" + hostName;
}
- getRestTestHelper().submitRequest(url,
- method,
- virtualhostData,
- statusCode);
+
+ Map<String,List<String>> headers = new HashMap<>();
+ int responseCode = getRestTestHelper().submitRequest(url, method, virtualhostData, headers );
+ Assert.assertEquals("Unexpected response code from " + method + " " + url, statusCode, responseCode);
+ if (statusCode == 201)
+ {
+ List<String> location = headers.get("Location");
+ assertTrue("Location is not returned by REST create request", location != null && location.size() == 1);
+ String expectedLocation = getRestTestHelper().getManagementURL() + RestTestHelper.API_BASE + url;
+ if (useParentURI)
+ {
+ expectedLocation += "/" + hostName;
+ }
+ assertEquals("Unexpected location", expectedLocation, location.get(0));
+ }
return virtualhostData;
}