summaryrefslogtreecommitdiff
path: root/qpid/java/systests/src/main
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/main
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/main')
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java20
1 files changed, 17 insertions, 3 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