summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Fiedler2011-10-24 17:00:57 (EDT)
committer Steve Speicher2011-10-24 17:00:57 (EDT)
commit1728bc910b31abcfa36e7900ca8cc3440d5224b7 (patch)
treea181e5c0b8ad7b062d40e6db971b1d68045fc2bc
parent398d434621e15f3e384b55ef54ccbca80b41f7e2 (diff)
downloadorg.eclipse.lyo.testsuite-1728bc910b31abcfa36e7900ca8cc3440d5224b7.zip
org.eclipse.lyo.testsuite-1728bc910b31abcfa36e7900ca8cc3440d5224b7.tar.gz
org.eclipse.lyo.testsuite-1728bc910b31abcfa36e7900ca8cc3440d5224b7.tar.bz2
Bug357387 Replace use of deprecated HttpEntity#consumeConent with
EntityUtils#consume
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/CreationAndUpdateTests.java36
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/OAuthTests.java9
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/QueryTests.java2
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/ServiceDescriptionTests.java8
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/ServiceProviderCatalogTests.java10
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ChangeRequestXmlTests.java2
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/CreationAndUpdateBaseTests.java26
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/OAuthTests.java9
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogBaseTests.java4
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogXmlTests.java4
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderRdfXmlTests.java4
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderXmlTests.java8
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/SimplifiedQueryRdfXmlTests.java3
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/TestsBase.java4
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/util/OSLCUtils.java5
15 files changed, 69 insertions, 65 deletions
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/CreationAndUpdateTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/CreationAndUpdateTests.java
index 2d50448..5d3362d 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/CreationAndUpdateTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/CreationAndUpdateTests.java
@@ -171,7 +171,7 @@ public class CreationAndUpdateTests {
OSLCConstants.CT_CR_XML, templatedDocument);
//Assert the response gave a 201 Created
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertEquals(HttpStatus.SC_CREATED, resp.getStatusLine().getStatusCode());
Header location = resp.getFirstHeader("Location");
//Assert that we were given a Location header pointing to the resource
@@ -181,7 +181,7 @@ public class CreationAndUpdateTests {
resp = OSLCUtils.deleteFromUrl(location.getValue(), basicCreds, "*/*");
if (resp.getEntity() != null)
{
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
}
@@ -194,7 +194,7 @@ public class CreationAndUpdateTests {
OSLCConstants.CT_CR_JSON, jsonDocument);
//Assert the response gave a 201 Created
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertEquals(HttpStatus.SC_CREATED, resp.getStatusLine().getStatusCode());
Header location = resp.getFirstHeader("Location");
@@ -205,7 +205,7 @@ public class CreationAndUpdateTests {
resp = OSLCUtils.deleteFromUrl(location.getValue(), basicCreds, "/*");
if (resp.getEntity() != null)
{
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
}
@@ -215,7 +215,7 @@ public class CreationAndUpdateTests {
//Issue post request using the provided template and an invalid contentType
HttpResponse resp = OSLCUtils.postDataToUrl(currentUrl, basicCreds, OSLCConstants.CT_CR_XML,
"weird/type", templatedDocument);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertEquals(HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE, resp.getStatusLine().getStatusCode());
}
@@ -225,7 +225,7 @@ public class CreationAndUpdateTests {
//Issue post request using the provided template and an invalid contentType
HttpResponse resp = OSLCUtils.postDataToUrl(currentUrl, basicCreds, OSLCConstants.CT_CR_XML,
OSLCConstants.CT_CR_XML, "notvalidxmldefect");
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertEquals(HttpStatus.SC_BAD_REQUEST, resp.getStatusLine().getStatusCode());
}
@@ -238,7 +238,7 @@ public class CreationAndUpdateTests {
OSLCConstants.CT_CR_XML, templatedDocument);
//Assert the response gave a 201 Created
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertEquals(HttpStatus.SC_CREATED, resp.getStatusLine().getStatusCode());
Header location = resp.getFirstHeader("Location");
//Assert that we were given a Location header pointing to the resource
@@ -248,7 +248,7 @@ public class CreationAndUpdateTests {
resp = OSLCUtils.putDataToUrl(location.getValue(), basicCreds, OSLCConstants.CT_CR_XML, OSLCConstants.CT_CR_XML, updateDocument);
if (resp.getEntity() != null)
{
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
//Assert that a proper PUT resulted in a 200 OK
assertEquals(HttpStatus.SC_OK, resp.getStatusLine().getStatusCode());
@@ -256,7 +256,7 @@ public class CreationAndUpdateTests {
//Clean up after the test by attempting to delete the created resource
resp = OSLCUtils.deleteFromUrl(location.getValue(), basicCreds, "*/*");
if (resp.getEntity() != null)
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
@Test
@@ -268,7 +268,7 @@ public class CreationAndUpdateTests {
OSLCConstants.CT_CR_JSON, jsonDocument);
//Assert the response gave a 201 Created
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertTrue(resp.getStatusLine().getStatusCode() == 201);
Header location = resp.getFirstHeader("Location");
@@ -279,7 +279,7 @@ public class CreationAndUpdateTests {
resp = OSLCUtils.putDataToUrl(location.getValue(), basicCreds, OSLCConstants.CT_CR_JSON, OSLCConstants.CT_CR_JSON, jsonUpdate);
if (resp.getEntity() != null)
{
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
//Assert that a proper PUT resulted in a 200 OK
assertTrue(resp.getStatusLine().getStatusCode() == 200);
@@ -287,7 +287,7 @@ public class CreationAndUpdateTests {
//Clean up after the test by attempting to delete the created resource
resp = OSLCUtils.deleteFromUrl(location.getValue(), basicCreds, "*/*");
if (resp.getEntity() != null)
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
@Test
@@ -299,7 +299,7 @@ public class CreationAndUpdateTests {
OSLCConstants.CT_CR_XML, templatedDocument);
//Assert the response gave a 201 Created
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertTrue(resp.getStatusLine().getStatusCode() == 201);
Header location = resp.getFirstHeader("Location");
//Assert that we were given a Location header pointing to the resource
@@ -309,7 +309,7 @@ public class CreationAndUpdateTests {
resp = OSLCUtils.putDataToUrl(location.getValue(), basicCreds, "*/*", OSLCConstants.CT_CR_XML, "NOTVALIDXML");
if (resp.getEntity() != null)
{
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
//Assert that an invalid PUT resulted in a 400 BAD REQUEST
assertTrue(resp.getStatusLine().getStatusCode() == 400);
@@ -317,7 +317,7 @@ public class CreationAndUpdateTests {
//Clean up after the test by attempting to delete the created resource
resp = OSLCUtils.deleteFromUrl(location.getValue(), basicCreds, "");
if (resp.getEntity() != null)
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
@Test
@@ -329,7 +329,7 @@ public class CreationAndUpdateTests {
OSLCConstants.CT_CR_XML, templatedDocument);
//Assert the response gave a 201 Created
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertTrue(resp.getStatusLine().getStatusCode() == 201);
Header location = resp.getFirstHeader("Location");
@@ -340,7 +340,7 @@ public class CreationAndUpdateTests {
resp = OSLCUtils.putDataToUrl(location.getValue(), basicCreds, "*/*", "text/html", updateDocument);
if (resp.getEntity() != null)
{
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
//Assert that an invalid PUT resulted in a 400 BAD REQUEST
assertTrue(resp.getStatusLine().getStatusCode() == 415);
@@ -348,6 +348,6 @@ public class CreationAndUpdateTests {
//Clean up after the test by attempting to delete the created resource
resp = OSLCUtils.deleteFromUrl(location.getValue(), basicCreds, "");
if (resp.getEntity() != null)
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
}
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/OAuthTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/OAuthTests.java
index f0efbb0..4447e2e 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/OAuthTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/OAuthTests.java
@@ -43,6 +43,7 @@ import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.http.HttpResponse;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.util.EntityUtils;
import org.eclipse.lyo.testsuite.server.util.OSLCConstants;
import org.eclipse.lyo.testsuite.server.util.OSLCUtils;
import org.eclipse.lyo.testsuite.server.util.SetupProperties;
@@ -125,12 +126,12 @@ public class OAuthTests {
//Get a response from the base URL to setup cookies (to prevent form redirection)
HttpResponse resp = OSLCUtils.getResponseFromUrl("", baseUrl, basicCreds,
OSLCConstants.CT_DISC_CAT_XML + ", " + OSLCConstants.CT_DISC_DESC_XML);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
//Post authorization using user credentials provided.
resp = OSLCUtils.postDataToUrl(provider.userAuthorizationURL + "?oauth_token=" + accessor.requestToken,
basicCreds, "", "application/x-www-form-urlencoded", postParameters +
"&oauth_token=" + accessor.requestToken);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
//Make sure the authorization did not return an error.
assertTrue(resp.getStatusLine().getStatusCode() < 400);
}
@@ -145,12 +146,12 @@ public class OAuthTests {
HttpResponse resp = OSLCUtils.getResponseFromUrl("", baseUrl, basicCreds,
OSLCConstants.CT_DISC_CAT_XML + ", " + OSLCConstants.CT_DISC_DESC_XML);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
resp = OSLCUtils.postDataToUrl(provider.userAuthorizationURL + "?oauth_token=" + accessor.requestToken,
basicCreds, "", "application/x-www-form-urlencoded", postParameters +
"&oauth_token=" + accessor.requestToken);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
//Provide authorization by the user
assertTrue(resp.getStatusLine().getStatusCode() < 400);
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/QueryTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/QueryTests.java
index e960ab3..c16ec00 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/QueryTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/QueryTests.java
@@ -328,7 +328,7 @@ public class QueryTests {
query = query + "oslc_cm.query=notrealthing" + URLEncoder.encode("=\"defect\"", "UTF-8");
HttpResponse resp = OSLCUtils.getResponseFromUrl(baseUrl, currentUrl + query, basicCreds,
"application/xml");
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
//Make sure we get a 400 (BAD REQUEST) for an invalid field
assertTrue(resp.getStatusLine().getStatusCode() == 400);
}
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/ServiceDescriptionTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/ServiceDescriptionTests.java
index 07a375c..b9e0040 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/ServiceDescriptionTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/ServiceDescriptionTests.java
@@ -113,7 +113,7 @@ public class ServiceDescriptionTests {
{
Collection<Object[]> data = new ArrayList<Object[]>();
data.add(new Object[] { base });
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
return data;
}
@@ -168,7 +168,7 @@ public class ServiceDescriptionTests {
{
HttpResponse resp = OSLCUtils.getResponseFromUrl(baseUrl, currentUrl, basicCreds, "application/svg+xml");
String respType = resp.getEntity().getContentType().getValue();
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertTrue(resp.getStatusLine().getStatusCode() == 406 || respType.contains("application/svg+xml"));
}
@@ -179,7 +179,7 @@ public class ServiceDescriptionTests {
HttpResponse resp = OSLCUtils.getResponseFromUrl(baseUrl, currentUrl, basicCreds,
OSLCConstants.CT_DISC_DESC_XML);
//Make sure the response to this URL was of valid type
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertTrue(resp.getEntity().getContentType().getValue().contains(OSLCConstants.CT_DISC_DESC_XML));
}
@@ -330,7 +330,7 @@ public class ServiceDescriptionTests {
//Perform HTTP GET request on the URL and verify it exists in some form
HttpResponse urlResponse = OSLCUtils.getResponseFromUrl(baseUrl, url, basicCreds, "*/*");
- urlResponse.getEntity().consumeContent();
+ EntityUtils.consume(urlResponse.getEntity());
assertFalse(urlResponse.getStatusLine().getStatusCode() == 404);
}
}
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/ServiceProviderCatalogTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/ServiceProviderCatalogTests.java
index d3fda7c..c9d6a30 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/ServiceProviderCatalogTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv1tests/ServiceProviderCatalogTests.java
@@ -112,7 +112,7 @@ public class ServiceProviderCatalogTests {
System.out.println("The content-type of a ServiceProviderCatalog should be "
+ OSLCConstants.CT_DISC_CAT_XML);
System.out.println("The content-type returned was " + resp.getEntity().getContentType());
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
return new ArrayList<Object[]>();
}
Document baseDoc = OSLCUtils.createXMLDocFromResponseBody(EntityUtils.toString(resp.getEntity()));
@@ -157,7 +157,7 @@ public class ServiceProviderCatalogTests {
{
HttpResponse resp = OSLCUtils.getResponseFromUrl(baseUrl, currentUrl, basicCreds, "application/svg+xml");
String respType = resp.getEntity().getContentType().getValue();
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertTrue(resp.getStatusLine().getStatusCode() == 406 || respType.contains("application/svg+xml"));
}
@@ -165,7 +165,7 @@ public class ServiceProviderCatalogTests {
public void contentTypeIsServiceProviderCatalog() throws IOException
{
HttpResponse resp = OSLCUtils.getResponseFromUrl(baseUrl, currentUrl, basicCreds, OSLCConstants.CT_DISC_CAT_XML);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
//Make sure the response to this URL was of valid type
assertTrue(resp.getEntity().getContentType().getValue().contains(OSLCConstants.CT_DISC_CAT_XML));
}
@@ -283,7 +283,7 @@ public class ServiceProviderCatalogTests {
assertFalse(url.isEmpty());
HttpResponse response = OSLCUtils.getResponseFromUrl(baseUrl, url, basicCreds, "*/*");
assertFalse(response.getStatusLine().getStatusCode() == 404);
- response.getEntity().consumeContent();
+ EntityUtils.consume(response.getEntity());
}
}
@@ -358,7 +358,7 @@ public class ServiceProviderCatalogTests {
assertNotNull(url);
HttpResponse resp = OSLCUtils.getResponseFromUrl(baseUrl, url, basicCreds, "*/*");
assertFalse(resp.getStatusLine().getStatusCode() == 404);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
}
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ChangeRequestXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ChangeRequestXmlTests.java
index a537b45..ab02195 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ChangeRequestXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ChangeRequestXmlTests.java
@@ -117,7 +117,7 @@ public class ChangeRequestXmlTests extends TestsBase {
HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, queryBase + query, basicCreds,
OSLCConstants.CT_XML, headers);
String respBody = EntityUtils.toString(resp.getEntity());
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertTrue("Received " +resp.getStatusLine(), (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK));
//Get XML Doc from response
Document doc = OSLCUtils.createXMLDocFromResponseBody(respBody);
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/CreationAndUpdateBaseTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/CreationAndUpdateBaseTests.java
index f88d0fa..b1634f5 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/CreationAndUpdateBaseTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/CreationAndUpdateBaseTests.java
@@ -96,7 +96,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
// contentType
HttpResponse resp = OSLCUtils.postDataToUrl(currentUrl, basicCreds,
"*/*", "weird/type", xmlCreateTemplate, headers);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertTrue(resp.getStatusLine().getStatusCode() == 415);
}
@@ -108,7 +108,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
// Assert the response gave a 201 Created
String responseBody = EntityUtils.toString(resp.getEntity());
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertEquals(responseBody, HttpStatus.SC_CREATED, resp.getStatusLine()
.getStatusCode());
Header location = resp.getFirstHeader("Location");
@@ -122,7 +122,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
// which is not a MUST according to the oslc cm spec
resp = OSLCUtils.deleteFromUrl(location.getValue(), basicCreds, "*/*");
if (resp.getEntity() != null) {
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
}
@@ -131,7 +131,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
// Issue post request using valid content type but invalid content
HttpResponse resp = OSLCUtils.postDataToUrl(currentUrl, basicCreds,
accept, accept, content, headers);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
// TODO: What is right sc forbidden?
assertFalse("Expecting error but received OK", HttpStatus.SC_OK == resp
.getStatusLine().getStatusCode());
@@ -143,7 +143,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
HttpResponse resp = OSLCUtils.postDataToUrl(currentUrl, basicCreds,
accept, contentType, newContent, headers);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertEquals(HttpStatus.SC_CREATED, resp.getStatusLine()
.getStatusCode());
Header location = resp.getFirstHeader("Location");
@@ -178,7 +178,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
contentType, updateContent, putHeaders);
String responseBody = EntityUtils.toString(resp.getEntity());
if (resp.getEntity() != null)
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
// Assert that a proper PUT resulted in a 200 OK
assertEquals("HTTP Response body: \n " + responseBody,
HttpStatus.SC_OK, resp.getStatusLine().getStatusCode());
@@ -188,7 +188,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
resp = OSLCUtils.deleteFromUrl(location.getValue(), basicCreds,
"*/*");
if (resp != null && resp.getEntity() != null)
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
}
@@ -200,7 +200,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
accept, contentType, content, headers);
// Assert the response gave a 201 Created
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertEquals(HttpStatus.SC_CREATED, resp.getStatusLine()
.getStatusCode());
Header location = resp.getFirstHeader("Location");
@@ -232,7 +232,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
resp = OSLCUtils.putDataToUrl(location.getValue(), basicCreds, accept,
contentType, invalidContent, putHeaders);
if (resp.getEntity() != null) {
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
// Assert that an invalid PUT resulted in a 400 BAD REQUEST
assertEquals(HttpStatus.SC_BAD_REQUEST, resp.getStatusLine()
@@ -243,7 +243,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
resp = OSLCUtils.deleteFromUrl(location.getValue(), basicCreds, "");
if (resp != null && resp.getEntity() != null)
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
protected void updateCreatedResourceWithBadType(String contentType,
@@ -253,7 +253,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
accept, contentType, createContent, headers);
// Assert the response gave a 201 Created
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertEquals(HttpStatus.SC_CREATED, resp.getStatusLine()
.getStatusCode());
Header location = resp.getFirstHeader("Location");
@@ -283,7 +283,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
resp = OSLCUtils.putDataToUrl(location.getValue(), basicCreds, "*/*",
badType, updateContent, putHeaders);
if (resp != null && resp.getEntity() != null)
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertEquals(HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE, resp.getStatusLine()
.getStatusCode());
@@ -293,7 +293,7 @@ public class CreationAndUpdateBaseTests extends TestsBase {
resp = OSLCUtils.deleteFromUrl(location.getValue(), basicCreds, "");
if (resp != null && resp.getEntity() != null)
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
}
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/OAuthTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/OAuthTests.java
index cd0a47d..6821c70 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/OAuthTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/OAuthTests.java
@@ -43,6 +43,7 @@ import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.http.HttpResponse;
+import org.apache.http.util.EntityUtils;
import org.eclipse.lyo.testsuite.server.util.OSLCConstants;
import org.eclipse.lyo.testsuite.server.util.OSLCUtils;
import org.eclipse.lyo.testsuite.server.util.SSLProtocolSocketFactory;
@@ -179,12 +180,12 @@ public class OAuthTests extends TestsBase {
// Get a response from the base URL to setup cookies (to prevent form redirection)
HttpResponse resp = OSLCUtils.getResponseFromUrl("", setupBaseUrl, basicCreds,
OSLCConstants.CT_XML);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
// Post authorization using user credentials provided.
resp = OSLCUtils.postDataToUrl(provider.userAuthorizationURL + "?oauth_token=" + accessor.requestToken,
basicCreds, "", "application/x-www-form-urlencoded", postParameters+
"&oauth_token=" + accessor.requestToken, headers);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
int statusCode = resp.getStatusLine().getStatusCode();
assertTrue("Request failed with status code: " + statusCode, statusCode < 400);
}
@@ -198,12 +199,12 @@ public class OAuthTests extends TestsBase {
HttpResponse resp = OSLCUtils.getResponseFromUrl("", setupBaseUrl, basicCreds,
OSLCConstants.CT_XML);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
resp = OSLCUtils.postDataToUrl(provider.userAuthorizationURL + "?oauth_token=" + accessor.requestToken,
basicCreds, "", "application/x-www-form-urlencoded", postParameters+
"&oauth_token=" + accessor.requestToken, headers);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
int sc = resp.getStatusLine().getStatusCode();
assertTrue(sc == HttpStatus.SC_OK || sc == HttpStatus.SC_CREATED);
try
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogBaseTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogBaseTests.java
index b7628ce..b9da4fe 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogBaseTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogBaseTests.java
@@ -64,7 +64,7 @@ public abstract class ServiceProviderCatalogBaseTests extends TestsBase {
if (resp.getEntity().getContentType() != null) {
respType = resp.getEntity().getContentType().getValue();
}
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertTrue("Expected 406 but received " + resp.getStatusLine()
+ " or Content-type='invalid/content-type' but received "
+ respType, resp.getStatusLine().getStatusCode() == 406
@@ -80,7 +80,7 @@ public abstract class ServiceProviderCatalogBaseTests extends TestsBase {
public void contentTypeIsSuggestedType() throws IOException {
HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl,
basicCreds, fContentType, headers);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
// Make sure the response to this URL was of valid type
String ct = resp.getEntity().getContentType().getValue();
assertTrue("Expected content-type \"" + fContentType + "\" received : "
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogXmlTests.java
index ae0d976..0d3ee68 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogXmlTests.java
@@ -462,7 +462,7 @@ public class ServiceProviderCatalogXmlTests extends
assertFalse(url.isEmpty());
HttpResponse response = OSLCUtils.getResponseFromUrl(setupBaseUrl, url,
basicCreds, "*/*");
- response.getEntity().consumeContent();
+ EntityUtils.consume(response.getEntity());
assertFalse(response.getStatusLine().getStatusCode() == 404);
}
}
@@ -486,7 +486,7 @@ public class ServiceProviderCatalogXmlTests extends
assertNotNull(url);
HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, url,
basicCreds, "*/*");
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertFalse(resp.getStatusLine().getStatusCode() == 404);
}
}
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderRdfXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderRdfXmlTests.java
index 251600b..b82bd1f 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderRdfXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderRdfXmlTests.java
@@ -145,7 +145,7 @@ public class ServiceProviderRdfXmlTests extends TestsBase {
HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl, basicCreds, "invalid/content-type",
headers);
String respType = (resp.getEntity().getContentType() == null) ? "" : resp.getEntity().getContentType().getValue();
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertTrue("Expected 406 but received "+resp.getStatusLine()+",Content-type='invalid/content-type' but received "+respType, resp.getStatusLine().getStatusCode() == 406 || respType.contains("invalid/content-type"));
}
@@ -156,7 +156,7 @@ public class ServiceProviderRdfXmlTests extends TestsBase {
HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl, basicCreds,
OSLCConstants.CT_XML, headers);
//Make sure the response to this URL was of valid type
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
String contentType = resp.getEntity().getContentType().getValue();
String contentTypeSplit[] = contentType.split(";");
contentType = contentTypeSplit[0];
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderXmlTests.java
index 1eea4e0..7e057e6 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderXmlTests.java
@@ -111,7 +111,7 @@ public class ServiceProviderXmlTests extends TestsBase {
HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl, basicCreds, "invalid/content-type",
headers);
String respType = (resp.getEntity().getContentType() == null) ? "" : resp.getEntity().getContentType().getValue();
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
assertTrue("Expected 406 but received "+resp.getStatusLine()+",Content-type='invalid/content-type' but received "+respType, resp.getStatusLine().getStatusCode() == 406 || respType.contains("application/svg+xml"));
}
@@ -122,7 +122,7 @@ public class ServiceProviderXmlTests extends TestsBase {
HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl, basicCreds,
OSLCConstants.CT_XML, headers);
//Make sure the response to this URL was of valid type
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
String contentType = resp.getEntity().getContentType().getValue();
String contentTypeSplit[] = contentType.split(";");
contentType = contentTypeSplit[0];
@@ -136,12 +136,12 @@ public class ServiceProviderXmlTests extends TestsBase {
HttpResponse baseResp = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl, basicCreds,
OSLCConstants.CT_XML, headers);
String baseRespValue = EntityUtils.toString(baseResp.getEntity());
- baseResp.getEntity().consumeContent();
+ EntityUtils.consume(baseResp.getEntity());
HttpResponse parameterResp = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl + "?oslc_cm:query", basicCreds,
OSLCConstants.CT_XML, headers);
String parameterRespValue = EntityUtils.toString(parameterResp.getEntity());
- parameterResp.getEntity().consumeContent();
+ EntityUtils.consume(parameterResp.getEntity());
assertTrue("Query response with and without did not return same response", baseRespValue.equals(parameterRespValue));
}
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/SimplifiedQueryRdfXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/SimplifiedQueryRdfXmlTests.java
index 30232f1..c54051b 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/SimplifiedQueryRdfXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/SimplifiedQueryRdfXmlTests.java
@@ -32,6 +32,7 @@ import javax.xml.xpath.XPathException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.http.HttpResponse;
+import org.apache.http.util.EntityUtils;
import org.eclipse.lyo.testsuite.server.util.OSLCConstants;
import org.eclipse.lyo.testsuite.server.util.OSLCUtils;
import org.eclipse.lyo.testsuite.server.util.SetupProperties;
@@ -90,7 +91,7 @@ public class SimplifiedQueryRdfXmlTests extends SimplifiedQueryBaseTests {
Model queryModel = ModelFactory.createDefaultModel();
queryModel.read(response.getEntity().getContent(), OSLCConstants.JENA_RDF_XML);
- response.getEntity().consumeContent();
+ EntityUtils.consume(response.getEntity());
Resource responseInfoRes = (Resource) queryModel.getResource(currentUrl + query);
assumeNotNull("Expended ResponseInfo/@rdf:about to equal request URL", responseInfoRes);
Resource resultsRes = (Resource) queryModel.getResource(currentUrl);
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/TestsBase.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/TestsBase.java
index c1d1e52..6cf5ed9 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/TestsBase.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/TestsBase.java
@@ -332,7 +332,7 @@ public class TestsBase {
// Used to hold RDF from doing service discovery
Model spModel = ModelFactory.createDefaultModel();
spModel.read(resp.getEntity().getContent(), OSLCConstants.JENA_RDF_XML);
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
// Get all the "inlined" definitions for Service Providers, namely
// all subjects whose rdf:type = oslc:ServiceProvider
@@ -441,7 +441,7 @@ public class TestsBase {
try {
resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, setupBaseUrl, null, "*/*");
if (resp.getEntity() != null) {
- resp.getEntity().consumeContent();
+ EntityUtils.consume(resp.getEntity());
}
// Post info to forms auth page
OSLCUtils.setupFormsAuth(formUri, userId, pw);
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/util/OSLCUtils.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/util/OSLCUtils.java
index d669e49..8acff98 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/util/OSLCUtils.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/util/OSLCUtils.java
@@ -51,6 +51,7 @@ import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.util.EntityUtils;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -126,7 +127,7 @@ public class OSLCUtils {
httpget.setHeader("Accept", acceptTypes);
httpget.setHeader("OSLC-Core-Version", "2.0");
HttpResponse response = httpclient.execute(httpget);
- response.getEntity().consumeContent();
+ EntityUtils.consume(response.getEntity());
if (response.containsHeader("OSLC-Core-Version") &&
response.getFirstHeader("OSLC-Core-Version").getValue().equals("2.0"))
@@ -296,6 +297,6 @@ public class OSLCUtils {
httppost.addHeader("OSLC-Core-Version", "2.0");
//Get the response and return it
HttpResponse response = httpclient.execute(httppost);
- response.getEntity().consumeContent();
+ EntityUtils.consume(response.getEntity());
}
}