aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuhong Yin2012-09-04 10:01:44 (EDT)
committerMichael Fiedler2012-09-09 13:59:25 (EDT)
commitf05b1226fa507000336805c4d3a05a1cc5384c8b (patch)
treef9847971cabb22b76fd712e938d608a75cb3d326
parent37b23c6e085b9df6e5b26889e1f57ab047489bc8 (diff)
downloadorg.eclipse.lyo.testsuite-f05b1226fa507000336805c4d3a05a1cc5384c8b.zip
org.eclipse.lyo.testsuite-f05b1226fa507000336805c4d3a05a1cc5384c8b.tar.gz
org.eclipse.lyo.testsuite-f05b1226fa507000336805c4d3a05a1cc5384c8b.tar.bz2
Bug 386787 - lyo test suite should not expect etag or last-modified ifrefs/changes/87/7587/2
the response body for POST is empty Change-Id: Id1061f17b90e572d418eda29c473b28166fac4ff
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CoreResourceRdfXmlTests.java9
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CoreResourceXmlTests.java6
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CreationAndUpdateBaseTests.java79
3 files changed, 74 insertions, 20 deletions
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CoreResourceRdfXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CoreResourceRdfXmlTests.java
index 144bddf..7e2155e 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CoreResourceRdfXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CoreResourceRdfXmlTests.java
@@ -96,6 +96,14 @@ public abstract class CoreResourceRdfXmlTests extends TestsBase {
@Parameters
protected static Collection<Object[]> getAllDescriptionUrls(String eval) throws IOException
{
+ ArrayList<String> results = new ArrayList<String>();
+
+ String useThisCR = setupProps.getProperty("useThisChangeRequest");
+ if ( useThisCR != null ) {
+ results.add(useThisCR);
+ return toCollection(results);
+ }
+
//Checks the ServiceProviderCatalog at the specified baseUrl of the REST service in order to grab all urls
//to other ServiceProvidersCatalogs contained within it, recursively, in order to find the URLs of all
//query factories of the REST service.
@@ -120,7 +128,6 @@ public abstract class CoreResourceRdfXmlTests extends TestsBase {
String query = (additionalParameters.length() == 0) ? "?" : "?" + additionalParameters + "&";
query = query + "oslc.where=" + URLEncoder.encode(where, "UTF-8") + "&oslc.pageSize=1";
- ArrayList<String> results = new ArrayList<String>();
for (String queryBaseUri : capabilityURLsUsingRdfXml) {
String queryUrl = OSLCUtils.addQueryStringToURL(queryBaseUri, query);
HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, queryUrl, basicCreds,
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CoreResourceXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CoreResourceXmlTests.java
index b009cc9..94abdb7 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CoreResourceXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CoreResourceXmlTests.java
@@ -95,6 +95,12 @@ public abstract class CoreResourceXmlTests extends TestsBase {
{
ArrayList<String> results = new ArrayList<String>();
+ String useThisCR = setupProps.getProperty("useThisChangeRequest");
+ if ( useThisCR != null ) {
+ results.add(useThisCR);
+ return toCollection(results);
+ }
+
//Checks the ServiceProviderCatalog at the specified baseUrl of the REST service in order to grab all urls
//to other ServiceProvidersCatalogs contained within it, recursively, in order to find the URLs of all
//query factories of the REST service.
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CreationAndUpdateBaseTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CreationAndUpdateBaseTests.java
index 74ffcf8..0ce628c 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CreationAndUpdateBaseTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/CreationAndUpdateBaseTests.java
@@ -140,28 +140,50 @@ public class CreationAndUpdateBaseTests extends TestsBase {
protected void createResourceAndUpdateIt(String contentType, String accept,
String newContent, String updateContent) throws IOException {
HttpResponse resp = createResource(contentType, accept, newContent);
+
Header location = getRequiredLocationHeader(resp);
+ assertTrue("Location("+location+")"+" must not be null", location != null);
+
+ // check whether a POST response body is empty (which is allowed)
+ Header contentLength = resp.getFirstHeader("Content-Length");
+ boolean hasPayLoad = true;
+ if ( contentLength != null ) {
+ String len = contentLength.getValue().toString();
+ if ( len.equalsIgnoreCase("0") ) {
+ hasPayLoad = false;
+ }
+ }
+
+ Header eTag = resp.getFirstHeader("ETag");
+ Header lastModified = resp.getFirstHeader("Last-Modified");
+ int size = headers.length;
+ Header[] putHeaders = new Header[size+2];
+
+ int i=0;
+ for( ; i<size; i++){
+ putHeaders[i] = headers[i];
+ }
+
+ if ( hasPayLoad ) {
+ // then fail, because we expect at least one, if not both
+ assertTrue("ETag("+eTag+") or Last-Modified("+lastModified+") must not be null", eTag != null || lastModified != null ) ;
+ }
- Header eTag = resp.getFirstHeader("ETag");
- Header lastModified = resp.getFirstHeader("Last-Modified");
-
- // then fail, because we expect at least one, if not both
- assertTrue("ETag("+eTag+") and Last-Modified("+lastModified+") must not be null", eTag != null || lastModified != null ) ;
- int size = headers.length;
- if( eTag != null ) size++;
- if( lastModified != null ) size++;
- Header[] putHeaders = new Header[size];
- int i=0;
- for(;i<headers.length;i++){
- putHeaders[i] = headers[i];
- }
if( eTag != null ) {
putHeaders[i++] = new BasicHeader("If-Match", eTag.getValue());
- }
+ }
+ else {
+ putHeaders[i++] = new BasicHeader("bogus1", "bogus1");
+ }
+
if( lastModified != null ) {
putHeaders[i++] = new BasicHeader("If-Unmodified-Since", lastModified.getValue());
}
-
+ else {
+ putHeaders[i++] = new BasicHeader("bogus1", "bogus1");
+ }
+
+
// Now, go to the url of the new change request and update it.
// We may need to add something to update URL to match the template
String updateUrl = location.getValue();
@@ -252,7 +274,8 @@ public class CreationAndUpdateBaseTests extends TestsBase {
}
// Now, go to the url of the new change request and update it.
- resp = OSLCUtils.putDataToUrl(location.getValue(), basicCreds, "*/*",
+ //resp = OSLCUtils.putDataToUrl(location.getValue(), basicCreds, "*/*",
+ resp = OSLCUtils.putDataToUrl(location.getValue(), basicCreds, "application/xml",
badType, updateContent, putHeaders);
if (resp != null && resp.getEntity() != null)
EntityUtils.consume(resp.getEntity());
@@ -293,20 +316,38 @@ public class CreationAndUpdateBaseTests extends TestsBase {
protected void updateCreatedResourceWithFailedPrecondition(String contentType,
String accept, String createContent, String updateContent) throws IOException {
+
HttpResponse resp = createResource(contentType, accept, createContent);
+
Header location = getRequiredLocationHeader(resp);
+ assertTrue("Location("+location+")"+" must not be null", location != null);
+
+ // check whether a POST response body is empty (which is allowed)
+ Header contentLength = resp.getFirstHeader("Content-Length");
+ boolean hasPayLoad = true;
+ if ( contentLength != null ) {
+ String len = contentLength.getValue().toString();
+ if ( len.equalsIgnoreCase("0") ) {
+ hasPayLoad = false;
+ }
+ }
+
Header eTag = resp.getFirstHeader("ETag");
Header lastModified = resp.getFirstHeader("Last-Modified");
- assertTrue("Either ETag("+eTag+") or Last-Modified("+lastModified+") must not be null", eTag != null || lastModified != null ) ;
+ if ( hasPayLoad ) {
+ assertTrue("Either ETag("+eTag+") or Last-Modified("+lastModified+") must not be null", eTag != null || lastModified != null ) ;
+ }
- int size = headers.length + 1;
+ int size = headers.length + 1;
+
Header[] putHeaders = new Header[size];
int i=0;
for(;i<headers.length;i++){
putHeaders[i] = headers[i];
}
- if( eTag != null ) {
+
+ if ( !hasPayLoad || eTag != null ) {
putHeaders[i++] = new BasicHeader("If-Match", "Bogus");
} else if( lastModified != null ) {
putHeaders[i++] = new BasicHeader("If-Unmodified-Since", "Tue, 15 Nov 1994 12:45:26 GMT");