summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Padgett2011-11-08 15:59:48 (EST)
committer Michael Fiedler2011-11-11 13:13:20 (EST)
commit33d3c5949057f488e7d978b4fec3c13193c04601 (patch)
tree58b25d462ac344abb80533f2f236fe7918c77393
parent1eb1103e84a6ced8dbf52272009e2ff4b6ab3734 (diff)
downloadorg.eclipse.lyo.testsuite-33d3c5949057f488e7d978b4fec3c13193c04601.zip
org.eclipse.lyo.testsuite-33d3c5949057f488e7d978b4fec3c13193c04601.tar.gz
org.eclipse.lyo.testsuite-33d3c5949057f488e7d978b4fec3c13193c04601.tar.bz2
Bug 363223 - Test suite does not properly set base URI when reading
RDF/XML using Jena Conflicts: org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ChangeRequestRdfXmlTests.java org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogRdfXmlTests.java org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/SimplifiedQueryRdfXmlTests.java
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ChangeRequestRdfXmlTests.java499
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogRdfXmlTests.java410
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/SimplifiedQueryRdfXmlTests.java6
3 files changed, 453 insertions, 462 deletions
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ChangeRequestRdfXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ChangeRequestRdfXmlTests.java
index 3c5e69d..fb500cf 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ChangeRequestRdfXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ChangeRequestRdfXmlTests.java
@@ -13,260 +13,257 @@
*
* Steve Speicher - initial API and implementation
*******************************************************************************/
-package org.eclipse.lyo.testsuite.server.oslcv2tests;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeNotNull;
-import static org.junit.Assume.assumeTrue;
-
-import java.io.IOException;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPathException;
-import javax.xml.xpath.XPathExpressionException;
-
-
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.http.HttpResponse;
-import org.eclipse.lyo.testsuite.server.util.OSLCConstants;
-import org.eclipse.lyo.testsuite.server.util.OSLCUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-import org.xml.sax.SAXException;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.ModelFactory;
-import com.hp.hpl.jena.rdf.model.Property;
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.rdf.model.Selector;
-import com.hp.hpl.jena.rdf.model.SimpleSelector;
+package org.eclipse.lyo.testsuite.server.oslcv2tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeNotNull;
+import static org.junit.Assume.assumeTrue;
+
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathException;
+import javax.xml.xpath.XPathExpressionException;
+
+
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.http.HttpResponse;
+import org.eclipse.lyo.testsuite.server.util.OSLCConstants;
+import org.eclipse.lyo.testsuite.server.util.OSLCUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.xml.sax.SAXException;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.Selector;
+import com.hp.hpl.jena.rdf.model.SimpleSelector;
import com.hp.hpl.jena.rdf.model.StmtIterator;
-import com.hp.hpl.jena.vocabulary.RDF;
-
-
-/**
- * This class provides JUnit tests for the validation of a change request returned by accessing the change
- * request's URL directly. It runs the equality query from the properties file and grabs the first result
- * to test against, checking the relationship of elements in the XML representation of the change request.
- */
-@RunWith(Parameterized.class)
-public class ChangeRequestRdfXmlTests extends TestsBase {
- private HttpResponse response;
- private Model fRdfModel = ModelFactory.createDefaultModel();
- private Resource fResource = null;
-
- public ChangeRequestRdfXmlTests(String url) throws IOException, ParserConfigurationException, SAXException, XPathExpressionException
- {
- super(url);
- // If currentUrl is null, it means that the query didn't match any
- // records. This isn't exactly a failure, but there's nothing more we
- // can test.
- assumeNotNull(currentUrl);
- response = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl, basicCreds, OSLCConstants.CT_RDF,
- headers);
- // Some records in the system might not be accessible to this user. This
- // isn't a failure, but there's nothing more we can test.
- int sc = response.getStatusLine().getStatusCode();
- assumeTrue(sc != HttpStatus.SC_FORBIDDEN && sc != HttpStatus.SC_UNAUTHORIZED);
- // Make sure the request succeeded before continuing.
- assertEquals(HttpStatus.SC_OK, sc);
-
+
+
+/**
+ * This class provides JUnit tests for the validation of a change request returned by accessing the change
+ * request's URL directly. It runs the equality query from the properties file and grabs the first result
+ * to test against, checking the relationship of elements in the XML representation of the change request.
+ */
+@RunWith(Parameterized.class)
+public class ChangeRequestRdfXmlTests extends TestsBase {
+ private HttpResponse response;
+ private Model fRdfModel = ModelFactory.createDefaultModel();
+ private Resource fResource = null;
+
+ public ChangeRequestRdfXmlTests(String url) throws IOException, ParserConfigurationException, SAXException, XPathExpressionException
+ {
+ super(url);
+ // If currentUrl is null, it means that the query didn't match any
+ // records. This isn't exactly a failure, but there's nothing more we
+ // can test.
+ assumeNotNull(currentUrl);
+ response = OSLCUtils.getResponseFromUrl(setupBaseUrl, currentUrl, basicCreds, OSLCConstants.CT_RDF,
+ headers);
+ // Some records in the system might not be accessible to this user. This
+ // isn't a failure, but there's nothing more we can test.
+ int sc = response.getStatusLine().getStatusCode();
+ assumeTrue(sc != HttpStatus.SC_FORBIDDEN && sc != HttpStatus.SC_UNAUTHORIZED);
+ // Make sure the request succeeded before continuing.
+ assertEquals(HttpStatus.SC_OK, sc);
+
fRdfModel.read(response.getEntity().getContent(),
OSLCUtils.absoluteUrlFromRelative(setupBaseUrl, currentUrl),
OSLCConstants.JENA_RDF_XML);
-
-
- fResource = (Resource) fRdfModel.getResource(currentUrl);
+ fResource = (Resource) fRdfModel.getResource(currentUrl);
assumeTrue(fRdfModel.contains(fResource, RDF.type,
- fRdfModel.createResource(OSLCConstants.CM_CHANGE_REQUEST_TYPE)));
- }
-
- @Before
- public void setup() throws IOException, ParserConfigurationException, SAXException, XPathException
- {
- super.setup();
- }
-
- @Parameters
- public static Collection<Object[]> getAllDescriptionUrls() throws IOException
- {
- //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.
- ArrayList<String> serviceUrls = getServiceProviderURLsUsingRdfXml(setupProps.getProperty("baseUri"), onlyOnce);
- ArrayList<String> capabilityURLsUsingRdfXml = TestsBase.getCapabilityURLsUsingRdfXml(OSLCConstants.QUERY_BASE_PROP, serviceUrls, true);
- String where = setupProps.getProperty("changeRequestsWhere");
- if (where == null) {
- String queryProperty = setupProps.getProperty("queryEqualityProperty");
- String queryPropertyValue = setupProps.getProperty("queryEqualityValue");
- where = queryProperty + "=\"" + queryPropertyValue + "\"";
- }
-
- String additionalParameters = setupProps.getProperty("queryAdditionalParameters");
- String query = (additionalParameters.length() == 0) ? "?" : "?" + additionalParameters + "&";
- query = query + "oslc.where=" + URLEncoder.encode(where, "UTF-8") + "&oslc.pageSize=1";
-
- ArrayList<String> results = new ArrayList<String>();
+ fRdfModel.createResource(OSLCConstants.CM_CHANGE_REQUEST_TYPE)));
+ }
+
+ @Before
+ public void setup() throws IOException, ParserConfigurationException, SAXException, XPathException
+ {
+ super.setup();
+ }
+
+ @Parameters
+ public static Collection<Object[]> getAllDescriptionUrls() throws IOException
+ {
+ //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.
+ ArrayList<String> serviceUrls = getServiceProviderURLsUsingRdfXml(setupProps.getProperty("baseUri"), onlyOnce);
+ ArrayList<String> capabilityURLsUsingRdfXml = TestsBase.getCapabilityURLsUsingRdfXml(OSLCConstants.QUERY_BASE_PROP, serviceUrls, true);
+ String where = setupProps.getProperty("changeRequestsWhere");
+ if (where == null) {
+ String queryProperty = setupProps.getProperty("queryEqualityProperty");
+ String queryPropertyValue = setupProps.getProperty("queryEqualityValue");
+ where = queryProperty + "=\"" + queryPropertyValue + "\"";
+ }
+
+ String additionalParameters = setupProps.getProperty("queryAdditionalParameters");
+ 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,
- OSLCConstants.CT_RDF, headers);
- Model queryModel = ModelFactory.createDefaultModel();
- queryModel.read(resp.getEntity().getContent(), queryBaseUri, OSLCConstants.JENA_RDF_XML);
-
- Property member = queryModel.createProperty(OSLCConstants.RDFS_MEMBER);
- Resource queryBase = queryModel.getResource(queryBaseUri);
- Selector select = new SimpleSelector(queryBase, member, (RDFNode)null);
- StmtIterator statements = queryModel.listStatements(select);
- while (statements.hasNext()) {
- results.add(statements.nextStatement().getObject().toString());
- if (onlyOnce) return toCollection(results);
- }
- if (!results.isEmpty() && onlyOnce)
- break;
- }
- return toCollection(results);
- }
-
- protected StmtIterator getStatementsForProp(String propUri) {
- Property prop = fRdfModel.getProperty(propUri);
- Selector select = new SimpleSelector(fResource, prop, (RDFNode)null);
- return fRdfModel.listStatements(select);
- }
-
- @Test
- public void changeRequestHasOneTitle()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.DC_TITLE_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have 1 dc:title, found "+size, size == 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneDescription()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.DC_DESC_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 dc:description, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneIdentifier()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.DC_ID_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 dc:identifier, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneName()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.DC_NAME_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 dc:name, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneCreatedDate()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.DC_CREATED_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 dc:created, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneModifiedDate()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.DC_MODIFIED_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 dc:modified, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneDiscussion()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.DISCUSSION_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 oslc:discussion, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneInstanceShape()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.INST_SHAPE_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 oslc:instanceShape, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneCloseDate()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_CLOSE_DATE_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 oslc_cm:closeDate, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneStatus()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_STATUS_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 oslc_cm:status, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneClosedElement()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_CLOSED_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 oslc_cm:closed, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostInProgressElement()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_INPROGRESS_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 oslc_cm:inprogress, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneFixedElement()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_FIXED_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 oslc_cm:fixed, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneApprovedElement()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_APPROVED_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 oslc_cm:approved, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneReviewedElement()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_REVIEWED_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 oslc_cm:reviewed, found "+size, size <= 1);
- }
-
- @Test
- public void changeRequestHasAtMostOneVerifiedElement()
- {
- StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_VERIFIED_PROP);
- int size=listStatements.toList().size();
- assertTrue("Can have <=1 oslc_cm:verified, found "+size, size <= 1);
- }
-}
+ String queryUrl = OSLCUtils.addQueryStringToURL(queryBaseUri, query);
+ HttpResponse resp = OSLCUtils.getResponseFromUrl(setupBaseUrl, queryUrl, basicCreds,
+ OSLCConstants.CT_RDF, headers);
+ Model queryModel = ModelFactory.createDefaultModel();
+ queryModel.read(resp.getEntity().getContent(), queryBaseUri, OSLCConstants.JENA_RDF_XML);
+
+ Property member = queryModel.createProperty(OSLCConstants.RDFS_MEMBER);
+ Resource queryBase = queryModel.getResource(queryBaseUri);
+ Selector select = new SimpleSelector(queryBase, member, (RDFNode)null);
+ StmtIterator statements = queryModel.listStatements(select);
+ while (statements.hasNext()) {
+ results.add(statements.nextStatement().getObject().toString());
+ if (onlyOnce) return toCollection(results);
+ }
+ if (!results.isEmpty() && onlyOnce)
+ break;
+ }
+ return toCollection(results);
+ }
+
+ protected StmtIterator getStatementsForProp(String propUri) {
+ Property prop = fRdfModel.getProperty(propUri);
+ Selector select = new SimpleSelector(fResource, prop, (RDFNode)null);
+ return fRdfModel.listStatements(select);
+ }
+
+ @Test
+ public void changeRequestHasOneTitle()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.DC_TITLE_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have 1 dc:title, found "+size, size == 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneDescription()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.DC_DESC_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 dc:description, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneIdentifier()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.DC_ID_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 dc:identifier, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneName()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.DC_NAME_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 dc:name, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneCreatedDate()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.DC_CREATED_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 dc:created, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneModifiedDate()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.DC_MODIFIED_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 dc:modified, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneDiscussion()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.DISCUSSION_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 oslc:discussion, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneInstanceShape()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.INST_SHAPE_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 oslc:instanceShape, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneCloseDate()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_CLOSE_DATE_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 oslc_cm:closeDate, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneStatus()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_STATUS_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 oslc_cm:status, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneClosedElement()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_CLOSED_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 oslc_cm:closed, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostInProgressElement()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_INPROGRESS_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 oslc_cm:inprogress, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneFixedElement()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_FIXED_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 oslc_cm:fixed, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneApprovedElement()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_APPROVED_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 oslc_cm:approved, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneReviewedElement()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_REVIEWED_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 oslc_cm:reviewed, found "+size, size <= 1);
+ }
+
+ @Test
+ public void changeRequestHasAtMostOneVerifiedElement()
+ {
+ StmtIterator listStatements = getStatementsForProp(OSLCConstants.CM_VERIFIED_PROP);
+ int size=listStatements.toList().size();
+ assertTrue("Can have <=1 oslc_cm:verified, found "+size, size <= 1);
+ }
+}
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogRdfXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogRdfXmlTests.java
index 5ef11b8..8f1b539 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogRdfXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/oslcv2tests/ServiceProviderCatalogRdfXmlTests.java
@@ -13,8 +13,8 @@
*
* Steve Speicher - initial API and implementation
*******************************************************************************/
-package org.eclipse.lyo.testsuite.server.oslcv2tests;
-
+package org.eclipse.lyo.testsuite.server.oslcv2tests;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -48,212 +48,210 @@ import com.hp.hpl.jena.rdf.model.SimpleSelector;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.vocabulary.RDF;
-
-public class ServiceProviderCatalogRdfXmlTests extends
- ServiceProviderCatalogBaseTests {
-
- private Model rdfModel = ModelFactory.createDefaultModel();
- private Resource catalog = null;
-
- public ServiceProviderCatalogRdfXmlTests(String thisUrl) {
- super(thisUrl);
- fContentType = OSLCConstants.CT_RDF;
- }
-
- @Before
- public void setup() throws IOException
- {
- staticSetup();
-
- response = OSLCUtils.getResponseFromUrl(
- setupBaseUrl, currentUrl, basicCreds, OSLCConstants.CT_RDF, headers);
-
- assertEquals("Did not successfully retrieve catalog at: "
- + currentUrl, HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-
+
+public class ServiceProviderCatalogRdfXmlTests extends
+ ServiceProviderCatalogBaseTests {
+
+ private Model rdfModel = ModelFactory.createDefaultModel();
+ private Resource catalog = null;
+
+ public ServiceProviderCatalogRdfXmlTests(String thisUrl) {
+ super(thisUrl);
+ fContentType = OSLCConstants.CT_RDF;
+ }
+
+ @Before
+ public void setup() throws IOException
+ {
+ staticSetup();
+
+ response = OSLCUtils.getResponseFromUrl(
+ setupBaseUrl, currentUrl, basicCreds, OSLCConstants.CT_RDF, headers);
+
+ assertEquals("Did not successfully retrieve catalog at: "
+ + currentUrl, HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+
rdfModel.read(response.getEntity().getContent(),
OSLCUtils.absoluteUrlFromRelative(setupBaseUrl, currentUrl),
OSLCConstants.JENA_RDF_XML);
catalog = (Resource) rdfModel.getResource(currentUrl);
- assertTrue("Failed to read Catalog resource at URI: "+currentUrl,
- rdfModel.contains(catalog, RDF.type,
- rdfModel.createResource(OSLCConstants.SERVICE_PROVIDER_CATALOG_TYPE)));
- }
-
- @Parameters
- public static Collection<Object[]> getAllServiceProviderCatalogUrls() throws IOException, ParserConfigurationException, SAXException, XPathException
- {
- //Checks the ServiceProviderCatalog at the specified baseUrl of the REST service in order to grab all urls
- //to other ServiceProviders contained within it, recursively.
- Properties setupProps = SetupProperties.setup(null);
- Collection<Object[]> coll = getReferencedCatalogUrlsUsingRdfXml(setupProps.getProperty("baseUri"));
- return coll;
- }
-
- public static Collection<Object[]> getReferencedCatalogUrlsUsingRdfXml(String base) throws IOException, ParserConfigurationException, SAXException, XPathException
- {
- staticSetup();
- HttpResponse resp = OSLCUtils.getResponseFromUrl(base, base, basicCreds, OSLCConstants.CT_RDF, headers);
-
- assertEquals("Did not successfully retrieve catalog at: "+base, HttpStatus.SC_OK, resp.getStatusLine().getStatusCode());
-
- // ArrayList to contain the urls from all SPCs
- Collection<Object[]> data = new ArrayList<Object[]>();
- // Add ourself (base)
- data.add(new Object[] { base });
-
- Model rdfModel = ModelFactory.createDefaultModel();
- rdfModel.read(resp.getEntity().getContent(), base, OSLCConstants.JENA_RDF_XML);
-
- Property catPredicate = rdfModel.createProperty(OSLCConstants.SERVICE_PROVIDER_CATALOG_PROP);
- Selector select = new SimpleSelector(null, catPredicate, (RDFNode)null);
- StmtIterator listStatements = rdfModel.listStatements(select);
- while (listStatements.hasNext()) {
- data.add(new Object[] { listStatements.nextStatement().getObject().toString()} );
- }
-
- return data;
- }
-
- @Test
- public void baseUrlIsValid() throws IOException
- {
- //Get the status, make sure 200 OK
- assertTrue(response.getStatusLine().toString(), response.getStatusLine().getStatusCode() == HttpStatus.SC_OK);
-
- //Verify we got a response
- assertNotNull("Failed to locate Catalog resource at URI: "+setupBaseUrl, catalog);
- }
-
- @Test
- public void catalogRootIsRdfNamespaceDeclaration() throws XPathException
- {
- Property rdfType = rdfModel.getProperty(OSLCConstants.RDF_TYPE_PROP);
- assertNotNull(rdfType);
- Statement property = catalog.getProperty(rdfType);
- assertNotNull(property);
- assertEquals(OSLCConstants.SERVICE_PROVIDER_CATALOG_TYPE, property.getObject().toString());
- }
-
- @Test
- public void catalogRootAboutElementPointsToSelf() throws XPathException, IOException
- {
- assertEquals(setupBaseUrl, catalog.getURI());
- }
-
- @Test
- public void serviceProviderCatalogsHaveAtMostOneTitle() throws XPathException
- {
- Property dcTitle = rdfModel.createProperty(OSLCConstants.DC_TITLE_PROP);
- Property catPredicate = rdfModel.createProperty(OSLCConstants.SERVICE_PROVIDER_CATALOG_PROP);
- Selector select = new SimpleSelector(null, catPredicate, (RDFNode)null);
- StmtIterator listStatements = rdfModel.listStatements(select);
- if (!listStatements.hasNext())
- System.out.println("Catalog does not contain other catalogs");
- while (listStatements.hasNext()) {
- Resource cat = (Resource) listStatements.nextStatement().getObject();
- assertTrue(cat.listProperties(dcTitle).toList().size() <= 1);
- }
- }
- @Test
- public void serviceProviderCatalogHaveAtMostOneTitle() throws XPathException {
- Property dcTitle = rdfModel.createProperty(OSLCConstants.DC_TITLE_PROP);
- Selector select = new SimpleSelector(catalog, dcTitle, (RDFNode)null);
- StmtIterator listStatements = rdfModel.listStatements(select);
- assertTrue(listStatements.toList().size() <= 1);
- }
-
- /** Look for all oslc:ServiceProviders resources in catalog
- */
- protected StmtIterator getServiceProvidersFromModel() {
- Property spPredicate = rdfModel.createProperty(OSLCConstants.SERVICE_PROVIDER_PROP);
- Selector select = new SimpleSelector(null, spPredicate, (RDFNode)null);
- return rdfModel.listStatements(select);
- }
-
- @Test
- public void serviceProvidersHaveAtMostOneTitle() throws XPathException
- {
- Property dcTitle = rdfModel.createProperty(OSLCConstants.DC_TITLE_PROP);
- StmtIterator listStatements = getServiceProvidersFromModel();
- if (!listStatements.hasNext())
- System.out.println("Catalog does not contain ServiceProviders");
- while (listStatements.hasNext()) {
- Resource cat = (Resource) listStatements.nextStatement().getObject();
- assertTrue("ServiceProviders have at most 1 dc:title", cat.listProperties(dcTitle).toList().size() <= 1);
- }
- }
-
- @Test
- public void serviceProviderCatalogsHaveAtMostOnePublisher() throws XPathExpressionException
- {
- Property dcPublisher = rdfModel.createProperty(OSLCConstants.DC_PUBLISHER_PROP);
- Selector select = new SimpleSelector(catalog, dcPublisher, (RDFNode)null);
- StmtIterator listStatements = rdfModel.listStatements(select);
- assertTrue("ServiceProviderCatalogs have at most 1 oslc:publisher", listStatements.toList().size() <= 1);
- }
-
- @Test
- public void serviceProvidersHaveAtMostOnePublisher() throws XPathExpressionException
- {
- Property dcPublisher = rdfModel.createProperty(OSLCConstants.DC_PUBLISHER_PROP);
- StmtIterator listStatements = getServiceProvidersFromModel();
- if (!listStatements.hasNext())
- System.out.println("Catalog does not contain ServiceProviders");
- while (listStatements.hasNext()) {
- Resource cat = (Resource) listStatements.nextStatement().getObject();
- assertTrue("Service providers have at most 1 oslc:publisher", cat.listProperties(dcPublisher).toList().size() <= 1);
- }
- }
-
- @Test
- public void publisherElementsAreValid() throws XPathExpressionException
- {
- Property dcPublisher = rdfModel.createProperty(OSLCConstants.DC_PUBLISHER_PROP);
- Property dcTitle = rdfModel.createProperty(OSLCConstants.DC_TITLE_PROP);
- Selector select = new SimpleSelector(null, dcPublisher, (RDFNode)null);
- StmtIterator listStatements = rdfModel.listStatements(select);
- if (!listStatements.hasNext())
- System.out.println("Catalog does not contain any Publishers resources");
-
- while (listStatements.hasNext()) {
- Resource pub = (Resource) listStatements.nextStatement().getObject();
- rdfModel.listObjectsOfProperty(pub, dcTitle);
- }
- }
-
- /* TODO: Complete ServiceProviderCatalog validation tests for RDF/XML
-
- @Test
- public void serviceProviderCatalogsHaveAtMostOneOAuthElement() throws XPathExpressionException
- {
- }
-
- @Test
- public void serviceProvidersHaveAtMostOneOAuthElement() throws XPathExpressionException
- {
- }
-
- @Test
- public void oAuthElementsAreValid() throws XPathExpressionException
- {
- }
-
- @Test
- public void serviceProviderCatalogsHaveValidResourceUrl() throws XPathException, IOException
- {
- }
-
- @Test
- public void servicesProvidersHaveValidResourceUrl() throws XPathException, IOException
- {
- }
-
- @Test
- public void detailsElementsHaveValidResourceAttribute() throws IOException, XPathException
- {
- }
-
- */
-}
+ assertNotNull("Failed to read Catalog resource at URI: "+currentUrl, catalog);
+ }
+
+ @Parameters
+ public static Collection<Object[]> getAllServiceProviderCatalogUrls() throws IOException, ParserConfigurationException, SAXException, XPathException
+ {
+ //Checks the ServiceProviderCatalog at the specified baseUrl of the REST service in order to grab all urls
+ //to other ServiceProviders contained within it, recursively.
+ Properties setupProps = SetupProperties.setup(null);
+ Collection<Object[]> coll = getReferencedCatalogUrlsUsingRdfXml(setupProps.getProperty("baseUri"));
+ return coll;
+ }
+
+ public static Collection<Object[]> getReferencedCatalogUrlsUsingRdfXml(String base) throws IOException, ParserConfigurationException, SAXException, XPathException
+ {
+ staticSetup();
+ HttpResponse resp = OSLCUtils.getResponseFromUrl(base, base, basicCreds, OSLCConstants.CT_RDF, headers);
+
+ assertEquals("Did not successfully retrieve catalog at: "+base, HttpStatus.SC_OK, resp.getStatusLine().getStatusCode());
+
+ // ArrayList to contain the urls from all SPCs
+ Collection<Object[]> data = new ArrayList<Object[]>();
+ // Add ourself (base)
+ data.add(new Object[] { base });
+
+ Model rdfModel = ModelFactory.createDefaultModel();
+ rdfModel.read(resp.getEntity().getContent(), base, OSLCConstants.JENA_RDF_XML);
+
+ Property catPredicate = rdfModel.createProperty(OSLCConstants.SERVICE_PROVIDER_CATALOG_PROP);
+ Selector select = new SimpleSelector(null, catPredicate, (RDFNode)null);
+ StmtIterator listStatements = rdfModel.listStatements(select);
+ while (listStatements.hasNext()) {
+ data.add(new Object[] { listStatements.nextStatement().getObject().toString()} );
+ }
+
+ return data;
+ }
+
+ @Test
+ public void baseUrlIsValid() throws IOException
+ {
+ //Get the status, make sure 200 OK
+ assertTrue(response.getStatusLine().toString(), response.getStatusLine().getStatusCode() == HttpStatus.SC_OK);
+
+ //Verify we got a response
+ assertNotNull("Failed to locate Catalog resource at URI: "+setupBaseUrl, catalog);
+ }
+
+ @Test
+ public void catalogRootIsRdfNamespaceDeclaration() throws XPathException
+ {
+ Property rdfType = rdfModel.getProperty(OSLCConstants.RDF_TYPE_PROP);
+ assertNotNull(rdfType);
+ Statement property = catalog.getProperty(rdfType);
+ assertNotNull(property);
+ assertEquals(OSLCConstants.SERVICE_PROVIDER_CATALOG_TYPE, property.getObject().toString());
+ }
+
+ @Test
+ public void catalogRootAboutElementPointsToSelf() throws XPathException, IOException
+ {
+ assertEquals(setupBaseUrl, catalog.getURI());
+ }
+
+ @Test
+ public void serviceProviderCatalogsHaveAtMostOneTitle() throws XPathException
+ {
+ Property dcTitle = rdfModel.createProperty(OSLCConstants.DC_TITLE_PROP);
+ Property catPredicate = rdfModel.createProperty(OSLCConstants.SERVICE_PROVIDER_CATALOG_PROP);
+ Selector select = new SimpleSelector(null, catPredicate, (RDFNode)null);
+ StmtIterator listStatements = rdfModel.listStatements(select);
+ if (!listStatements.hasNext())
+ System.out.println("Catalog does not contain other catalogs");
+ while (listStatements.hasNext()) {
+ Resource cat = (Resource) listStatements.nextStatement().getObject();
+ assertTrue(cat.listProperties(dcTitle).toList().size() <= 1);
+ }
+ }
+ @Test
+ public void serviceProviderCatalogHaveAtMostOneTitle() throws XPathException {
+ Property dcTitle = rdfModel.createProperty(OSLCConstants.DC_TITLE_PROP);
+ Selector select = new SimpleSelector(catalog, dcTitle, (RDFNode)null);
+ StmtIterator listStatements = rdfModel.listStatements(select);
+ assertTrue(listStatements.toList().size() <= 1);
+ }
+
+ /** Look for all oslc:ServiceProviders resources in catalog
+ */
+ protected StmtIterator getServiceProvidersFromModel() {
+ Property spPredicate = rdfModel.createProperty(OSLCConstants.SERVICE_PROVIDER_PROP);
+ Selector select = new SimpleSelector(null, spPredicate, (RDFNode)null);
+ return rdfModel.listStatements(select);
+ }
+
+ @Test
+ public void serviceProvidersHaveAtMostOneTitle() throws XPathException
+ {
+ Property dcTitle = rdfModel.createProperty(OSLCConstants.DC_TITLE_PROP);
+ StmtIterator listStatements = getServiceProvidersFromModel();
+ if (!listStatements.hasNext())
+ System.out.println("Catalog does not contain ServiceProviders");
+ while (listStatements.hasNext()) {
+ Resource cat = (Resource) listStatements.nextStatement().getObject();
+ assertTrue("ServiceProviders have at most 1 dc:title", cat.listProperties(dcTitle).toList().size() <= 1);
+ }
+ }
+
+ @Test
+ public void serviceProviderCatalogsHaveAtMostOnePublisher() throws XPathExpressionException
+ {
+ Property dcPublisher = rdfModel.createProperty(OSLCConstants.DC_PUBLISHER_PROP);
+ Selector select = new SimpleSelector(catalog, dcPublisher, (RDFNode)null);
+ StmtIterator listStatements = rdfModel.listStatements(select);
+ assertTrue("ServiceProviderCatalogs have at most 1 oslc:publisher", listStatements.toList().size() <= 1);
+ }
+
+ @Test
+ public void serviceProvidersHaveAtMostOnePublisher() throws XPathExpressionException
+ {
+ Property dcPublisher = rdfModel.createProperty(OSLCConstants.DC_PUBLISHER_PROP);
+ StmtIterator listStatements = getServiceProvidersFromModel();
+ if (!listStatements.hasNext())
+ System.out.println("Catalog does not contain ServiceProviders");
+ while (listStatements.hasNext()) {
+ Resource cat = (Resource) listStatements.nextStatement().getObject();
+ assertTrue("Service providers have at most 1 oslc:publisher", cat.listProperties(dcPublisher).toList().size() <= 1);
+ }
+ }
+
+ @Test
+ public void publisherElementsAreValid() throws XPathExpressionException
+ {
+ Property dcPublisher = rdfModel.createProperty(OSLCConstants.DC_PUBLISHER_PROP);
+ Property dcTitle = rdfModel.createProperty(OSLCConstants.DC_TITLE_PROP);
+ Selector select = new SimpleSelector(null, dcPublisher, (RDFNode)null);
+ StmtIterator listStatements = rdfModel.listStatements(select);
+ if (!listStatements.hasNext())
+ System.out.println("Catalog does not contain any Publishers resources");
+
+ while (listStatements.hasNext()) {
+ Resource pub = (Resource) listStatements.nextStatement().getObject();
+ rdfModel.listObjectsOfProperty(pub, dcTitle);
+ }
+ }
+
+ /* TODO: Complete ServiceProviderCatalog validation tests for RDF/XML
+
+ @Test
+ public void serviceProviderCatalogsHaveAtMostOneOAuthElement() throws XPathExpressionException
+ {
+ }
+
+ @Test
+ public void serviceProvidersHaveAtMostOneOAuthElement() throws XPathExpressionException
+ {
+ }
+
+ @Test
+ public void oAuthElementsAreValid() throws XPathExpressionException
+ {
+ }
+
+ @Test
+ public void serviceProviderCatalogsHaveValidResourceUrl() throws XPathException, IOException
+ {
+ }
+
+ @Test
+ public void servicesProvidersHaveValidResourceUrl() throws XPathException, IOException
+ {
+ }
+
+ @Test
+ public void detailsElementsHaveValidResourceAttribute() throws IOException, XPathException
+ {
+ }
+
+ */
+}
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 1bef8a1..1494d6d 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
@@ -45,12 +45,9 @@ import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.jena.rdf.model.ResIterator;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;
-import com.hp.hpl.jena.vocabulary.RDF;
-import com.hp.hpl.jena.vocabulary.RDFS;
/**
* This class provides JUnit tests for the basic validation of query factories
@@ -86,9 +83,8 @@ public class SimplifiedQueryRdfXmlTests extends SimplifiedQueryBaseTests {
protected void validateNonEmptyResponse(String query)
throws IOException {
- String queryUrl = OSLCUtils.addQueryStringToURL(currentUrl, query);
HttpResponse response = OSLCUtils.getResponseFromUrl(setupBaseUrl,
- queryUrl, basicCreds, OSLCConstants.CT_RDF, headers);
+ currentUrl + query, basicCreds, OSLCConstants.CT_RDF, headers);
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
Model queryModel = ModelFactory.createDefaultModel();