Author: fguillaume
Date: Wed Jan 6 16:35:42 2010
New Revision: 896515
URL: http://svn.apache.org/viewvc?rev=896515&view=rev
Log:
CMIS-59: make TCK more lenient with HTTP return codes
Modified:
incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java
incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java
Modified:
incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java?rev=896515&r1=896514&r2=896515&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java
Wed Jan 6 16:35:42 2010
@@ -389,12 +389,26 @@
* Execute Request
*
* @param req
- * @param expectedStatus
+ * @param expectedStatus the expected status, or -1 if ignored
* @param asUser
* @return response
* @throws IOException
*/
public Response executeRequest(Request req, int expectedStatus) throws
IOException {
+ return executeRequest(req, expectedStatus, expectedStatus);
+ }
+
+ /**
+ * Execute Request
+ *
+ * @param req
+ * @param expectedStatusMin the minimum expected status
+ * @param expectedStatusMax the maximum expected status
+ * @param asUser
+ * @return response
+ * @throws IOException
+ */
+ public Response executeRequest(Request req, int expectedStatusMin, int
expectedStatusMax) throws IOException {
if (traceConnection) {
messageWriter.trace("Request: " + req.getMethod() + " " +
req.getFullUri()
+ (req.getBody() == null ? "" : "\n" + new
String(req.getBody(), req.getEncoding())));
@@ -407,8 +421,19 @@
+ req.getFullUri() + (res.getContentAsString() == null ?
"" : "\n" + res.getContentAsString()));
}
- if (expectedStatus > -1)
- Assert.assertEquals("Request status for " + req.getFullUri(),
expectedStatus, res.getStatus());
+ if (expectedStatusMin > -1) {
+ int status = res.getStatus();
+ if (expectedStatusMin == expectedStatusMax) {
+ Assert.assertEquals("Request status for " + req.getFullUri(),
+ expectedStatusMin, status);
+ } else {
+ Assert.assertTrue("Request status for " + req.getFullUri()
+ + " was " + status + " but must be between "
+ + expectedStatusMin + " and " + expectedStatusMax,
+ expectedStatusMin <= status
+ && status <= expectedStatusMax);
+ }
+ }
if (validate) {
Validator mimetypeValidator = null;
Modified:
incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java?rev=896515&r1=896514&r2=896515&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/ContentStreamTest.java
Wed Jan 6 16:35:42 2010
@@ -55,7 +55,7 @@
Link editMediaLink = document.getEditMediaLink();
Assert.assertNotNull(editMediaLink);
Request putReq = new PutRequest(editMediaLink.getHref().toString(),
UPDATED_CONTENT, CMISConstants.MIMETYPE_TEXT);
- Response res = client.executeRequest(putReq, 200);
+ Response res = client.executeRequest(putReq, 200, 201);
Assert.assertNotNull(res);
// retrieve updated content
@@ -82,9 +82,9 @@
// retrieve document (ensure still exists)
client.getEntry(document.getSelfLink().getHref());
-
+
// attempt to retrieve deleted content (ensure does not exist)
- client.executeRequest(new
GetRequest(document.getContentSrc().toString()), 404);
+ client.executeRequest(new
GetRequest(document.getContentSrc().toString()), 404, 409);
}
}