summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuhong Yin2012-02-13 12:34:08 (EST)
committer Michael Fiedler2012-02-14 12:35:13 (EST)
commitf38533ae0d2c8bdc3fbe4ccc3160e2c05bbb1648 (patch)
treec1baa83fce0a0cd0757f745e330e24ef8cda41fd
parent6f47d1c1a2bbf34ea8ca76aef84a171888b0af0e (diff)
downloadorg.eclipse.lyo.testsuite-f38533ae0d2c8bdc3fbe4ccc3160e2c05bbb1648.zip
org.eclipse.lyo.testsuite-f38533ae0d2c8bdc3fbe4ccc3160e2c05bbb1648.tar.gz
org.eclipse.lyo.testsuite-f38533ae0d2c8bdc3fbe4ccc3160e2c05bbb1648.tar.bz2
Bug 370444 - Rename contentTypeIsCMServiceDescription method and change
the folder structure for compliance tool
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderRdfXmlTests.java34
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderXmlTests.java37
2 files changed, 51 insertions, 20 deletions
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 bfdaad5..a7a6ce4 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation.
+ * Copyright (c) 2011, 2012 IBM Corporation.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -12,6 +12,7 @@
* Contributors:
*
* Steve Speicher - initial API and implementation
+ * Yuhong Yin
*******************************************************************************/
package org.eclipse.lyo.testsuite.server.oslcv2tests;
@@ -132,8 +133,7 @@ public class ServiceProviderRdfXmlTests extends TestsBase {
@Test
public void typeIsServiceProvider() throws XPathException
- {
- // RDFUtils.printModel(fRdfModel);
+ {
Property rdfType = fRdfModel.createProperty(OSLCConstants.RDF_TYPE_PROP);
StmtIterator iter = fServiceProvider.listProperties(rdfType);
boolean matches = false;
@@ -159,29 +159,30 @@ public class ServiceProviderRdfXmlTests extends TestsBase {
@Test
- public void contentTypeIsCMServiceDescription() throws IOException
+ public void responseContentTypeIsXML() throws IOException
{
HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl, basicCreds,
- OSLCConstants.CT_XML, headers);
+ fContentType, headers);
//Make sure the response to this URL was of valid type
EntityUtils.consume(resp.getEntity());
String contentType = resp.getEntity().getContentType().getValue();
String contentTypeSplit[] = contentType.split(";");
contentType = contentTypeSplit[0];
- // TODO: Should we make sure that this is an exact match?
- assertTrue(contentType.endsWith("xml"));
+ assertTrue(contentType.equalsIgnoreCase("application/xml") ||
+ contentType.equalsIgnoreCase("application/rdf+xml") ||
+ contentType.equalsIgnoreCase("text/xml"));
}
@Test
public void misplacedParametersDoNotEffectResponse() throws IOException
{
HttpResponse baseResp = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl, basicCreds,
- OSLCConstants.CT_XML, headers);
+ fContentType, headers);
String baseRespValue = EntityUtils.toString(baseResp.getEntity());
String modifiedUrl = OSLCUtils.addParameterToURL(currentUrl, "oslc.where", "dcterms:identifier=\"1\"");
HttpResponse parameterResp = OSLCUtils.getResponseFromUrl(setupBaseUrl, modifiedUrl, basicCreds,
- OSLCConstants.CT_XML, headers);
+ fContentType, headers);
String parameterRespValue = EntityUtils.toString(parameterResp.getEntity());
assertTrue("Query response with and without did not return same response", baseRespValue.equals(parameterRespValue));
@@ -201,7 +202,20 @@ public class ServiceProviderRdfXmlTests extends TestsBase {
List<?> lst = fServiceProvider.listProperties(service).toList();
assertTrue(lst.size() >= 1);
}
-
+
+ @Test
+ public void invalidOslcPropertiesGivesConflict() throws IOException
+ {
+ String paramterUrl = OSLCUtils.addParameterToURL(currentUrl, "oslc.properties", "dcterms:identifier=\"non-exist\"");
+ HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, paramterUrl, basicCreds,
+ fContentType, headers);
+
+ String respType = (resp.getEntity().getContentType() == null) ? "" : resp.getEntity().getContentType().getValue();
+ EntityUtils.consume(resp.getEntity());
+ assertTrue("Expected 409 but received "+resp.getStatusLine()+",Content-type='invalid/content-type' but received "+respType, resp.getStatusLine().getStatusCode() == 409);
+
+ }
+
/* TODO: Complete ServiceProvider RDF/XML test validation
@Test
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 97328bc..48e5514 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation.
+ * Copyright (c) 2011, 2012 IBM Corporation.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -12,6 +12,7 @@
* Contributors:
*
* Steve Speicher - initial API and implementation
+ * Yuhong Yin
*******************************************************************************/
package org.eclipse.lyo.testsuite.server.oslcv2tests;
@@ -55,7 +56,8 @@ import org.xml.sax.SAXException;
@RunWith(Parameterized.class)
public class ServiceProviderXmlTests extends TestsBase {
- private HttpResponse response;
+ private HttpResponse response;
+ private String fContentType = OSLCConstants.CT_XML;
private String responseBody;
private Document doc;
@@ -69,7 +71,7 @@ public class ServiceProviderXmlTests extends TestsBase {
{
super.setup();
response = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl, basicCreds,
- OSLCConstants.CT_XML, headers);
+ fContentType, headers);
responseBody = EntityUtils.toString(response.getEntity());
//Get XML Doc from response
doc = OSLCUtils.createXMLDocFromResponseBody(responseBody);
@@ -117,30 +119,32 @@ public class ServiceProviderXmlTests extends TestsBase {
@Test
- public void contentTypeIsCMServiceDescription() throws IOException
+ public void responseContentTypeIsXML() throws IOException
{
HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl, basicCreds,
- OSLCConstants.CT_XML, headers);
+ fContentType, headers);
//Make sure the response to this URL was of valid type
EntityUtils.consume(resp.getEntity());
String contentType = resp.getEntity().getContentType().getValue();
String contentTypeSplit[] = contentType.split(";");
- contentType = contentTypeSplit[0];
- // TODO: Should we make sure that this is an exact match?
- assertTrue(contentType.endsWith("xml"));
+ contentType = contentTypeSplit[0];
+
+ assertTrue(contentType.equalsIgnoreCase("application/xml") ||
+ contentType.equalsIgnoreCase("application/rdf+xml") ||
+ contentType.equalsIgnoreCase("text/xml"));
}
@Test
public void misplacedParametersDoNotEffectResponse() throws IOException
{
HttpResponse baseResp = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl, basicCreds,
- OSLCConstants.CT_XML, headers);
+ fContentType, headers);
String baseRespValue = EntityUtils.toString(baseResp.getEntity());
EntityUtils.consume(baseResp.getEntity());
String modifiedUrl = OSLCUtils.addParameterToURL(currentUrl, "oslc.where", "dcterms:identifier=\"1\"");
HttpResponse parameterResp = OSLCUtils.getResponseFromUrl(setupBaseUrl, modifiedUrl, basicCreds,
- OSLCConstants.CT_XML, headers);
+ fContentType, headers);
String parameterRespValue = EntityUtils.toString(parameterResp.getEntity());
EntityUtils.consume(parameterResp.getEntity());
@@ -519,5 +523,18 @@ public class ServiceProviderXmlTests extends TestsBase {
assertTrue(numHintWidth <= 1);
assertTrue(numHintHeight <= 1);
}
+ }
+
+ @Test
+ public void invalidOslcPropertiesGivesConflict() throws IOException
+ {
+ String paramterUrl = OSLCUtils.addParameterToURL(currentUrl, "oslc.properties", "dcterms:identifier=\"non-exist\"");
+ HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, paramterUrl, basicCreds,
+ fContentType, headers);
+
+ String respType = (resp.getEntity().getContentType() == null) ? "" : resp.getEntity().getContentType().getValue();
+ EntityUtils.consume(resp.getEntity());
+ assertTrue("Expected 409 but received "+resp.getStatusLine()+",Content-type='invalid/content-type' but received "+respType, resp.getStatusLine().getStatusCode() == 409);
+
}
}