aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Eck II2012-07-17 10:40:12 (EDT)
committerTim Eck II2012-07-17 10:40:12 (EDT)
commit0c02220f9cbfc5c48000d44e217be06171088d4f (patch)
tree1c4bc51bd0263ae977b9ec7a9cadc187429445e5
parentebd66ccdd823dd91330b5c0fd0ddaa4abf2b964c (diff)
downloadorg.eclipse.lyo.testsuite-0c02220f9cbfc5c48000d44e217be06171088d4f.zip
org.eclipse.lyo.testsuite-0c02220f9cbfc5c48000d44e217be06171088d4f.tar.gz
org.eclipse.lyo.testsuite-0c02220f9cbfc5c48000d44e217be06171088d4f.tar.bz2
I added changes to fix problems outlined in the bug number below.refs/changes/13/6813/1
Bug 385321 https://bugs.eclipse.org/bugs/show_bug.cgi?id=385321
-rw-r--r--org.eclipse.lyo.testsuite.server/config/rio-asset/json/create.json19
-rw-r--r--org.eclipse.lyo.testsuite.server/config/rio-asset/json/createArtifact.json16
-rw-r--r--org.eclipse.lyo.testsuite.server/config/rio-asset/json/createCategory.json22
-rw-r--r--org.eclipse.lyo.testsuite.server/config/rio-asset/json/createRelationship.json26
-rw-r--r--org.eclipse.lyo.testsuite.server/config/rio-asset/json/update.json19
-rw-r--r--org.eclipse.lyo.testsuite.server/config/rio-asset/setup.properties51
-rw-r--r--org.eclipse.lyo.testsuite.server/config/rio-asset/testArtifact.txt1
-rw-r--r--org.eclipse.lyo.testsuite.server/config/rio-asset/xml/create.xml15
-rw-r--r--org.eclipse.lyo.testsuite.server/config/rio-asset/xml/createArtifact.xml13
-rw-r--r--org.eclipse.lyo.testsuite.server/config/rio-asset/xml/createCategory.xml17
-rw-r--r--org.eclipse.lyo.testsuite.server/config/rio-asset/xml/createRelationship.xml19
-rw-r--r--org.eclipse.lyo.testsuite.server/config/rio-asset/xml/update.xml16
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/GetAndUpdateRdfXmlTests.java2
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/GetAndUpdateXmlTests.java2
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/UsageCaseRdfXmlTests.java36
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/UsageCaseXmlTests.java2
-rw-r--r--org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/util/OSLCUtils.java24
17 files changed, 279 insertions, 21 deletions
diff --git a/org.eclipse.lyo.testsuite.server/config/rio-asset/json/create.json b/org.eclipse.lyo.testsuite.server/config/rio-asset/json/create.json
new file mode 100644
index 0000000..d1a8d54
--- /dev/null
+++ b/org.eclipse.lyo.testsuite.server/config/rio-asset/json/create.json
@@ -0,0 +1,19 @@
+{
+ "prefixes" : {
+ "oslc": "http://open-services.net/ns/core#",
+ "rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+ "dcterms" : "http://purl.org/dc/terms/",
+ "oslc_asset" : "http://open-services.net/ns/asset#",
+ "ram_asset" : "http://jazz.net/xmlns/prod/ram/2.0/"
+ },
+ "oslc_asset:version" : "1.0",
+ "rdf:type": {
+ "rdf:resource" : "http://localhost:8080/ram.ws/internal/types/classif/assetTypesSchema.xmi#documentation"
+ },
+ "community":
+ {
+ "resource":"http://localhost:8080/ram.ws/internal/communities/1001"
+ },
+ "dcterms:abstract" : "OSLCv2 Creation test case",
+ "dcterms:title" : "Created Asset"
+}
diff --git a/org.eclipse.lyo.testsuite.server/config/rio-asset/json/createArtifact.json b/org.eclipse.lyo.testsuite.server/config/rio-asset/json/createArtifact.json
new file mode 100644
index 0000000..c85d30f
--- /dev/null
+++ b/org.eclipse.lyo.testsuite.server/config/rio-asset/json/createArtifact.json
@@ -0,0 +1,16 @@
+{
+ "prefixes" : {
+ "oslc": "http://open-services.net/ns/core#",
+ "rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+ "dcterms" : "http://purl.org/dc/terms/"
+ },
+ "dcterms:title" : "Build help documentation",
+ "oslc:label" : "documentation",
+ "oslc_asset:content" : {
+ "rdf:resource" : "http://help.example.com"
+ },
+ "dcterms:format" : "text/html",
+ "rdf:type" : {
+ "rdf:resource" : "http://open-services.net/ns/asset#Artifact"
+ }
+}
diff --git a/org.eclipse.lyo.testsuite.server/config/rio-asset/json/createCategory.json b/org.eclipse.lyo.testsuite.server/config/rio-asset/json/createCategory.json
new file mode 100644
index 0000000..dddcd39
--- /dev/null
+++ b/org.eclipse.lyo.testsuite.server/config/rio-asset/json/createCategory.json
@@ -0,0 +1,22 @@
+{
+ "prefixes" : {
+ "oslc": "http://open-services.net/ns/core#",
+ "rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+ "dcterms" : "http://purl.org/dc/terms/",
+ "oslc_asset" : "http://open-services.net/ns/asset#",
+ "ram_asset" : "http://jazz.net/xmlns/prod/ram/2.0/"
+ },
+ "oslc_asset:version" : "1.0",
+ "rdf:type": {
+ "rdf:resource" : "http://localhost:8080/ram.ws/internal/types/classif/assetTypesSchema.xmi#documentation"
+ },
+ "oslc_asset:categorization" : {
+ "rdf:resource" : "http://localhost:8080/ram.ws/internal/communities/1001"
+ },
+ "community":
+ {
+ "resource":"http://localhost:8080/ram.ws/internal/communities/1001"
+ },
+ "dcterms:abstract" : "OSLCv2 Creation test case",
+ "dcterms:title" : "OSLCv2 asset testing"
+}
diff --git a/org.eclipse.lyo.testsuite.server/config/rio-asset/json/createRelationship.json b/org.eclipse.lyo.testsuite.server/config/rio-asset/json/createRelationship.json
new file mode 100644
index 0000000..07ea0f2
--- /dev/null
+++ b/org.eclipse.lyo.testsuite.server/config/rio-asset/json/createRelationship.json
@@ -0,0 +1,26 @@
+{
+ "prefixes" : {
+ "oslc": "http://open-services.net/ns/core#",
+ "rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+ "dcterms" : "http://purl.org/dc/terms/",
+ "oslc_asset" : "http://open-services.net/ns/asset#",
+ "ram_asset" : "http://jazz.net/xmlns/prod/ram/2.0/"
+ },
+ "oslc_asset:version" : "1.0",
+ "rdf:type": {
+ "rdf:resource" : "http://localhost:8080/ram.ws/internal/types/classif/assetTypesSchema.xmi#documentation"
+ },
+ "dcterms:relation" : {
+ "rdf:ID" : "relationship1",
+ "rdf:resource" : "%s",
+ "oslc_asset:relationshipType" : {
+ "rdf:resource" : "http://localhost:8080/ram.ws/internal/relationshipTypes/documentation"
+ }
+ },
+ "community":
+ {
+ "resource":"http://localhost:8080/ram.ws/internal/communities/1001"
+ },
+ "dcterms:abstract" : "OSLCv2 Creation test case",
+ "dcterms:title" : "OSLCv2 asset testing"
+}
diff --git a/org.eclipse.lyo.testsuite.server/config/rio-asset/json/update.json b/org.eclipse.lyo.testsuite.server/config/rio-asset/json/update.json
new file mode 100644
index 0000000..966ddb0
--- /dev/null
+++ b/org.eclipse.lyo.testsuite.server/config/rio-asset/json/update.json
@@ -0,0 +1,19 @@
+{
+ "prefixes" : {
+ "oslc": "http://open-services.net/ns/core#",
+ "rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+ "dcterms" : "http://purl.org/dc/terms/",
+ "oslc_asset" : "http://open-services.net/ns/asset#",
+ "ram_asset" : "http://jazz.net/xmlns/prod/ram/2.0/"
+ },
+ "oslc_asset:version" : "1.0",
+ "rdf:type": {
+ "rdf:resource" : "http://localhost:8080/ram.ws/internal/types/classif/assetTypesSchema.xmi#documentation"
+ },
+ "community":
+ {
+ "resource":"http://localhost:8080/ram.ws/internal/communities/1001"
+ },
+ "dcterms:abstract" : "OSLCv2 Creation test case",
+ "dcterms:title" : "Updated Asset"
+}
diff --git a/org.eclipse.lyo.testsuite.server/config/rio-asset/setup.properties b/org.eclipse.lyo.testsuite.server/config/rio-asset/setup.properties
new file mode 100644
index 0000000..06d7564
--- /dev/null
+++ b/org.eclipse.lyo.testsuite.server/config/rio-asset/setup.properties
@@ -0,0 +1,51 @@
+##GENERAL PROPERTIES##
+#The location of the top level ServiceProviderCatalog or Service Description Document
+baseUri=http://localhost:8080/ram.ws/oslc/servicesCatalog
+#Implementation name (for identification purposes)
+implName=rio-asset Dev
+#The authentication style (currently supports only BASIC, FORM and OAUTH)
+authMethod=BASIC
+
+#The authentication credentials
+userId=admin
+pw=admin
+
+testVersions=http://open-services.net/ns/asset#
+
+##QUERY PROPERTIES##
+#The query parameter that should be used to test equality
+queryEqualityProperty=dcterms:title
+#The parameter value used with the parameter to test equality (record with this value should exist in the system)
+queryEqualityValue=Customer Care Web Application
+#The query parameter that should be used to test equality
+queryComparisonProperty=dcterms:modified
+#The parameter value used with the parameter to test comparisons (should split the results into two non-empty sets)
+queryComparisonValue=2010-08-16T20:16:03.578Z
+#Additional non-OSLC parameters that need to be included to run queries
+queryAdditionalParameters=
+#A value to test full text search against (should return a non-empty record list)
+fullTextSearchTerm=This asset was created
+
+##CREATION AND UPDATION PROPERTIES##
+#Location of properly formatted xml/rdf which will be used to create an asset
+createTemplateArtifactXmlFile=config/rio-asset/xml/createArtifact.xml
+createTemplateArtifactJsonFile=config/rio-asset/json/createArtifact.json
+
+#Location of properly formatted xml which will be used to update a record.
+createTemplateXmlFile=config/rio-asset/xml/create.xml
+updateTemplateXmlFile=config/rio-asset/xml/update.xml
+
+createTemplateJsonFile=config/rio-asset/json/create.json
+updateTemplateJsonFile=config/rio-asset/json/create.json
+
+createWithCategoryTemplateXmlFile=config/rio-asset/xml/createCategory.xml
+createWithCategoryTemplateJsonFile=config/rio-asset/json/createCategory.json
+
+createWithRelationshipTemplateXmlFile=config/rio-asset/xml/createRelationship.xml
+createWithRelationshipTemplateJsonFile=config/rio-asset/json/createRelationship.json
+
+artifactFile=config/rio-asset/testArtifact.txt
+artifactContentType=text/plain
+#This is the base service url used by jena to read/write models
+baseUrl=http://localhost:8080/ram
+useThisServiceProvider=http://localhost:8080/ram.ws/oslc/assetServices
diff --git a/org.eclipse.lyo.testsuite.server/config/rio-asset/testArtifact.txt b/org.eclipse.lyo.testsuite.server/config/rio-asset/testArtifact.txt
new file mode 100644
index 0000000..87c8686
--- /dev/null
+++ b/org.eclipse.lyo.testsuite.server/config/rio-asset/testArtifact.txt
@@ -0,0 +1 @@
+This is to be used as a test artifact. The text here really doesn't matter so you can replace this text with whatever you want.
diff --git a/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/create.xml b/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/create.xml
new file mode 100644
index 0000000..d85db1a
--- /dev/null
+++ b/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/create.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dcterms="http://purl.org/dc/terms/"
+ xmlns:oslc="http://open-services.net/ns/core#"
+ xmlns:oslc_asset="http://open-services.net/ns/asset#"
+ xmlns:ram_asset="http://jazz.net/xmlns/prod/ram/2.0/">
+ <oslc_asset:Asset>
+ <rdf:type rdf:resource="http://open-services.net/ns/asset#Asset"/>
+ <dcterms:type rdf:resource="http://localhost:8080/ram.ws/internal/types/classif/assetTypesSchema.xmi#documentation"/>
+ <dcterms:title>Create asset</dcterms:title>
+ <oslc_asset:version>1.0</oslc_asset:version>
+ <dcterms:abstract>This asset was created</dcterms:abstract>
+ <ram_asset:community rdf:resource="http://localhost:8080/ram.ws/internal/communities/1001"/>
+ </oslc_asset:Asset>
+</rdf:RDF>
diff --git a/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/createArtifact.xml b/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/createArtifact.xml
new file mode 100644
index 0000000..4b11b04
--- /dev/null
+++ b/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/createArtifact.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dcterms="http://purl.org/dc/terms/"
+ xmlns:oslc="http://open-services.net/ns/core#"
+ xmlns:oslc_asset="http://open-services.net/ns/asset#">
+ <oslc_asset:Artifact>
+ <rdf:type rdf:resource="http://open-services.net/ns/asset#Artifact"/>
+ <dcterms:title>Build help documentation</dcterms:title>
+ <oslc:label>documentation</oslc:label>
+ <oslc_asset:content rdf:resource="http://help.example.com"/>
+ <dcterms:format>text/html</dcterms:format>
+ </oslc_asset:Artifact>
+</rdf:RDF>
diff --git a/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/createCategory.xml b/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/createCategory.xml
new file mode 100644
index 0000000..730a7d6
--- /dev/null
+++ b/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/createCategory.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dcterms="http://purl.org/dc/terms/"
+ xmlns:oslc="http://open-services.net/ns/core#"
+ xmlns:oslc_asset="http://open-services.net/ns/asset#"
+ xmlns:ram_asset="http://jazz.net/xmlns/prod/ram/2.0/">
+ <oslc_asset:Asset>
+ <rdf:type rdf:resource="http://open-services.net/ns/asset#Asset"/>
+ <dcterms:type rdf:resource="http://localhost:8080/ram.ws/internal/types/classif/assetTypesSchema.xmi#documentation"/>
+ <dcterms:title>asset with category</dcterms:title>
+ <oslc_asset:version>1.0</oslc_asset:version>
+ <dcterms:abstract>OSLCv2 Creation test case</dcterms:abstract>
+ <ram_asset:community rdf:resource="http://localhost:8080/ram.ws/internal/communities/1001"/>
+ <oslc_asset:categorization rdf:resource="http://localhost:8080/ram.ws/internal/categories/classif/software_development.xmi#open_source"/>
+ </oslc_asset:Asset>
+
+</rdf:RDF>
diff --git a/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/createRelationship.xml b/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/createRelationship.xml
new file mode 100644
index 0000000..0ea65ce
--- /dev/null
+++ b/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/createRelationship.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dcterms="http://purl.org/dc/terms/"
+ xmlns:oslc="http://open-services.net/ns/core#"
+ xmlns:oslc_asset="http://open-services.net/ns/asset#"
+ xmlns:ram_asset="http://jazz.net/xmlns/prod/ram/2.0/">
+ <oslc_asset:Asset>
+ <rdf:type rdf:resource="http://open-services.net/ns/asset#Asset"/>
+ <dcterms:type rdf:resource="http://localhost:8080/ram.ws/internal/types/classif/assetTypesSchema.xmi#documentation"/>
+ <dcterms:title>Asset with relation</dcterms:title>
+ <oslc_asset:version>1.0</oslc_asset:version>
+ <dcterms:abstract>Related asset test</dcterms:abstract>
+ <dcterms:relation rdf:ID="relationship1" rdf:resource="%s"/>
+ <ram_asset:community rdf:resource="http://localhost:8080/ram.ws/internal/communities/1001"/>
+ </oslc_asset:Asset>
+ <rdf:Description rdf:about="#relationship1">
+ <oslc_asset:relationshipType rdf:resource="http://localhost:8080/ram.ws/internal/relationshipTypes/documentation"/>
+ </rdf:Description>
+</rdf:RDF>
diff --git a/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/update.xml b/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/update.xml
new file mode 100644
index 0000000..376a2ad
--- /dev/null
+++ b/org.eclipse.lyo.testsuite.server/config/rio-asset/xml/update.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dcterms="http://purl.org/dc/terms/"
+ xmlns:oslc="http://open-services.net/ns/core#"
+ xmlns:oslc_asset="http://open-services.net/ns/asset#"
+ xmlns:ram_asset="http://jazz.net/xmlns/prod/ram/2.0/">
+ <oslc_asset:Asset>
+ <rdf:type rdf:resource="http://open-services.net/ns/asset#Asset"/>
+ <dcterms:type rdf:resource="http://localhost:8080/ram.ws/internal/types/classif/assetTypesSchema.xmi#documentation"/>
+ <dcterms:title>Updated asset</dcterms:title>
+ <oslc_asset:version>1.0</oslc_asset:version>
+ <dcterms:abstract>This asset was created</dcterms:abstract>
+ <ram_asset:revisionCount>1</ram_asset:revisionCount>
+ <ram_asset:community rdf:resource="http://localhost:8080/ram.ws/internal/communities/1001"/>
+ </oslc_asset:Asset>
+</rdf:RDF>
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/GetAndUpdateRdfXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/GetAndUpdateRdfXmlTests.java
index 96b98fd..78575d3 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/GetAndUpdateRdfXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/GetAndUpdateRdfXmlTests.java
@@ -103,7 +103,7 @@ public class GetAndUpdateRdfXmlTests extends GetAndUpdateBase {
String artifact = OSLCUtils.readFileByNameAsString(fileName);
HttpResponse resp = OSLCUtils.postDataToUrl(artifactFactory, basicCreds,
- OSLCConstants.CT_RDF, OSLCConstants.CT_RDF, artifact, header);
+ OSLCConstants.CT_RDF, null, artifact, header);
EntityUtils.consume(resp.getEntity());
assertTrue("Expected: " + HttpStatus.SC_CREATED + ", received: " + resp.getStatusLine().getStatusCode(),
HttpStatus.SC_CREATED == resp.getStatusLine().getStatusCode());
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/GetAndUpdateXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/GetAndUpdateXmlTests.java
index 484eb55..fadb791 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/GetAndUpdateXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/GetAndUpdateXmlTests.java
@@ -104,7 +104,7 @@ public class GetAndUpdateXmlTests extends GetAndUpdateBase {
HttpResponse response = OSLCUtils.postDataToUrl(artifactFactory, basicCreds,
OSLCConstants.CT_XML, OSLCConstants.CT_XML, artifact, header);
EntityUtils.consume(response.getEntity());
- assertTrue("Expected "+HttpStatus.SC_OK + ", received " + response.getStatusLine().getStatusCode(),
+ assertTrue("Expected "+HttpStatus.SC_CREATED + ", received " + response.getStatusLine().getStatusCode(),
response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED);
}
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/UsageCaseRdfXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/UsageCaseRdfXmlTests.java
index ee87f87..7fb9390 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/UsageCaseRdfXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/UsageCaseRdfXmlTests.java
@@ -120,7 +120,7 @@ public class UsageCaseRdfXmlTests extends UsageCaseBase {
String artifact = OSLCUtils.readFileByNameAsString(fileName);
resp = OSLCUtils.postDataToUrl(artifactFactory, basicCreds,
- OSLCConstants.CT_RDF, OSLCConstants.CT_RDF, artifact, header);
+ OSLCConstants.CT_RDF, null, artifact, header);
EntityUtils.consume(resp.getEntity());
assertTrue("Expected: " + HttpStatus.SC_CREATED + ", received: " + resp.getStatusLine().getStatusCode(),
HttpStatus.SC_CREATED == resp.getStatusLine().getStatusCode());
@@ -135,15 +135,14 @@ public class UsageCaseRdfXmlTests extends UsageCaseBase {
// TODO make this so that if the label is not there it is added
Property artifactProp = model.getProperty(OSLCConstants.ASSET_ARTIFACT_PROP);
String labelValue = "this subject has been changed";
+
Selector selectArtifact = new SimpleSelector(null, artifactProp, (RDFNode)null);
StmtIterator artifactStatements = model.listStatements(selectArtifact);
List<Statement> statementList = artifactStatements.toList();
for(int i = 0; i < statementList.size(); i++) {
- Statement statement = statementList.get(i);
- Selector selectChildren = new SimpleSelector(statement.getObject().asResource() , null, (RDFNode)null);
- StmtIterator childrenStatements = model.listStatements(selectChildren);
+ Statement artifactStatement = statementList.get(i);
Property prop = model.createProperty(OSLCConstants.LABEL_PROP);
- setPropertyValue(childrenStatements.nextStatement(), prop, labelValue);
+ setPropertyValue(artifactStatement.getResource(), prop, labelValue);
}
ByteArrayOutputStream output = new ByteArrayOutputStream();
@@ -161,16 +160,14 @@ public class UsageCaseRdfXmlTests extends UsageCaseBase {
artifactStatements = model.listStatements(selectArtifact);
statementList = artifactStatements.toList();
for(int i = 0; i < statementList.size(); i++) {
- Statement statement = statementList.get(i);
- Selector selectChildren = new SimpleSelector(statement.getObject().asResource() , null, (RDFNode)null);
- StmtIterator childrenStatements = model.listStatements(selectChildren);
- Statement childStatement = childrenStatements.nextStatement();
+ Statement artifactStatement = statementList.get(i);
Property prop = model.createProperty(OSLCConstants.LABEL_PROP);
- StmtIterator statements = childStatement.getResource().listProperties(prop);
- assertTrue("No label was found", statements.hasNext());
- Statement label = statements.nextStatement();
- assertEquals("Label was not set", labelValue, label.getObject().toString());
+ setPropertyValue(artifactStatement.getResource(), prop, labelValue);
+ StmtIterator statements = artifactStatement.getResource().listProperties(prop);
+ assertTrue("No label property was found", statements.hasNext());
+ assertEquals(labelValue, statements.next().getObject().toString());
}
+
}
private Model runQuery() throws IOException, ParserConfigurationException, SAXException {
@@ -242,17 +239,22 @@ public class UsageCaseRdfXmlTests extends UsageCaseBase {
return null;
}
- private void setPropertyValue(Statement statement, Property property, String newValue) {
- StmtIterator statements = statement.getResource().listProperties(property);
+ private void setPropertyValue(Resource resource, Property property, String newValue) {
+ StmtIterator statements = resource.listProperties(property);
ArrayList<Statement> statementList = new ArrayList<Statement>();
// Converts the iterator into an array list so that the statement(s) can be modified
+
+ boolean propFound = statements.hasNext();
while(statements.hasNext()) {
statementList.add(statements.nextStatement());
}
-
for(int i = 0; i < statementList.size(); i++) {
- statement = statementList.get(i);
+ Statement statement = statementList.get(i);
statement.changeObject(newValue);
}
+
+ if(!propFound) {
+ resource.addProperty(property, newValue);
+ }
}
}
diff --git a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/UsageCaseXmlTests.java b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/UsageCaseXmlTests.java
index 07a5f4e..1e5001e 100644
--- a/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/UsageCaseXmlTests.java
+++ b/org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/oslcv2/asset/UsageCaseXmlTests.java
@@ -126,7 +126,7 @@ public class UsageCaseXmlTests extends UsageCaseBase {
String labelValue = "this value was changed";
if(label == null) {
label = document.createElement("oslc:label");
- label.setNodeValue(labelValue);
+ label.setTextContent(labelValue);
artifactNode.appendChild(label);
} else {
label.setTextContent(labelValue);
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 67e3589..16ef183 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
@@ -47,7 +47,9 @@ import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
import org.apache.http.Header;
+import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
+import org.apache.http.ProtocolException;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.client.ClientProtocolException;
@@ -62,6 +64,7 @@ import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.DefaultRedirectStrategy;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.util.EntityUtils;
import org.junit.Assert;
@@ -137,7 +140,26 @@ public class OSLCUtils {
setupLazySSLSupport(httpclient);
if (creds != null) {
httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);
- }
+ }
+
+ httpclient.setRedirectStrategy(new DefaultRedirectStrategy() {
+ @Override
+ public boolean isRedirected(HttpRequest request, HttpResponse response, org.apache.http.protocol.HttpContext context) {
+ boolean isRedirect=false;
+ try {
+ isRedirect = super.isRedirected(request, response, context);
+ } catch (ProtocolException e) {
+ e.printStackTrace();
+ }
+ if (!isRedirect) {
+ int responseCode = response.getStatusLine().getStatusCode();
+ if (responseCode == 301 || responseCode == 302) {
+ return true;
+ }
+ }
+ return isRedirect;
+ }
+ });
}
return httpclient;
}