aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Terry2013-08-01 13:26:33 (EDT)
committerSamuel Padgett2013-08-02 13:25:47 (EDT)
commit9c7ed585c30cb16269dcfc81afef41718f06be47 (patch)
tree491bbcf83b26b4bb917dce11e0f7532debdb520c
parent2335083be55b66ff87771dfa9fbca3625c1bd819 (diff)
downloadorg.eclipse.lyo.rio-9c7ed585c30cb16269dcfc81afef41718f06be47.zip
org.eclipse.lyo.rio-9c7ed585c30cb16269dcfc81afef41718f06be47.tar.gz
org.eclipse.lyo.rio-9c7ed585c30cb16269dcfc81afef41718f06be47.tar.bz2
[414232] Refactor RIO TRS tests to make use of the TRS testsuite testrefs/changes/48/15048/2
infrastructure Change-Id: I030be68ec3dc37b311bd8dfe975c46210b3d2ec3 Signed-off-by: David Terry <dgterry@us.ibm.com> Also-by: Samuel Padgett <spadgett@us.ibm.com>
-rw-r--r--org.eclipse.lyo.rio.trs.tests/pom.xml159
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/ChangeLogCreationTest.java16
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/ChangeLogUpdationTest.java16
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/EasySSLClient.java104
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/FetchException.java36
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/FetchUtil.java139
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/HttpErrorHandler.java63
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/HttpResponseUtil.java61
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/ITRSVocabulary.java166
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/InvalidRDFResourceException.java40
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/InvalidTRSException.java36
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/Messages.java56
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/ModelUtil.java200
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/RDFModelResponseHandler.java130
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/SendException.java37
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/SendUtil.java162
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/TestCore.java112
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/messages.properties49
-rw-r--r--org.eclipse.lyo.rio.trs.tests/src/main/resources/config.properties19
19 files changed, 91 insertions, 1510 deletions
diff --git a/org.eclipse.lyo.rio.trs.tests/pom.xml b/org.eclipse.lyo.rio.trs.tests/pom.xml
index 7779aa6..c7962bb 100644
--- a/org.eclipse.lyo.rio.trs.tests/pom.xml
+++ b/org.eclipse.lyo.rio.trs.tests/pom.xml
@@ -1,102 +1,81 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.eclipse.lyo</groupId>
- <version>2.0.0-SNAPSHOT</version>
- <name>TRS Reference Application Test Suite</name>
- <artifactId>org.eclipse.lyo.rio.trs.tests</artifactId>
- <description>A set of junit tests to validate that various aspects of the reference application's change log are functioning properly.</description>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.eclipse.lyo</groupId>
+ <version>2.0.0-SNAPSHOT</version>
+ <name>TRS Reference Application Test Suite</name>
+ <artifactId>org.eclipse.lyo.rio.trs.tests</artifactId>
+ <description>A set of junit tests to validate that various aspects of the reference application's change log are functioning properly.</description>
- <repositories>
+ <repositories>
<repository>
<id>oauth</id>
<url>http://oauth.googlecode.com/svn/code/maven</url>
</repository>
</repositories>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.1</version>
- </dependency>
- <dependency>
- <groupId>net.oauth.core</groupId>
- <artifactId>oauth-consumer</artifactId>
- <version>20090617</version>
- <scope>compile</scope>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.lyo</groupId>
+ <artifactId>org.eclipse.lyo.testsuite.trs</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>[4.1.2,)</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.lyo</groupId>
- <artifactId>oslc-trs</artifactId>
- <version>[2.0-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jena</groupId>
- <artifactId>jena-arq</artifactId>
- <version>2.9.1</version>
- </dependency>
- </dependencies>
+ </dependencies>
- <build>
- <finalName>${project.artifactId}</finalName>
- <outputDirectory>target/classes</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include> **/*.properties</include>
- <include> **/*.index</include>
- <include> **/resources</include>
- </includes>
- </resource>
- </resources>
- <plugins>
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <outputDirectory>target/classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include> **/*.properties</include>
+ <include> **/*.index</include>
+ <include> **/resources</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
- <!-- Compiler Plugin -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
-
- <!-- Source Jar Plugin -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <!-- Javadoc Plugin -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
+ <!-- Compiler Plugin -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ <!-- Source Jar Plugin -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Javadoc Plugin -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
</project> \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/ChangeLogCreationTest.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/ChangeLogCreationTest.java
index 6fd1132..26c3ea1 100644
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/ChangeLogCreationTest.java
+++ b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/ChangeLogCreationTest.java
@@ -30,14 +30,14 @@ import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.DefaultedHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.SyncBasicHttpContext;
-import org.eclipse.lyo.rio.trs.tests.utils.EasySSLClient;
-import org.eclipse.lyo.rio.trs.tests.utils.FetchException;
-import org.eclipse.lyo.rio.trs.tests.utils.ITRSVocabulary;
-import org.eclipse.lyo.rio.trs.tests.utils.InvalidTRSException;
-import org.eclipse.lyo.rio.trs.tests.utils.Messages;
-import org.eclipse.lyo.rio.trs.tests.utils.SendException;
-import org.eclipse.lyo.rio.trs.tests.utils.SendUtil;
-import org.eclipse.lyo.rio.trs.tests.utils.TestCore;
+import org.eclipse.lyo.testsuite.server.trsutils.EasySSLClient;
+import org.eclipse.lyo.testsuite.server.trsutils.FetchException;
+import org.eclipse.lyo.testsuite.server.trsutils.ITRSVocabulary;
+import org.eclipse.lyo.testsuite.server.trsutils.InvalidTRSException;
+import org.eclipse.lyo.testsuite.server.trsutils.Messages;
+import org.eclipse.lyo.testsuite.server.trsutils.SendException;
+import org.eclipse.lyo.testsuite.server.trsutils.SendUtil;
+import org.eclipse.lyo.testsuite.server.trsutils.TestCore;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/ChangeLogUpdationTest.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/ChangeLogUpdationTest.java
index 0965299..f03c4f0 100644
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/ChangeLogUpdationTest.java
+++ b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/ChangeLogUpdationTest.java
@@ -31,14 +31,14 @@ import org.apache.http.protocol.DefaultedHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.SyncBasicHttpContext;
import org.eclipse.lyo.core.trs.HttpConstants;
-import org.eclipse.lyo.rio.trs.tests.utils.EasySSLClient;
-import org.eclipse.lyo.rio.trs.tests.utils.FetchException;
-import org.eclipse.lyo.rio.trs.tests.utils.ITRSVocabulary;
-import org.eclipse.lyo.rio.trs.tests.utils.InvalidTRSException;
-import org.eclipse.lyo.rio.trs.tests.utils.Messages;
-import org.eclipse.lyo.rio.trs.tests.utils.SendException;
-import org.eclipse.lyo.rio.trs.tests.utils.SendUtil;
-import org.eclipse.lyo.rio.trs.tests.utils.TestCore;
+import org.eclipse.lyo.testsuite.server.trsutils.EasySSLClient;
+import org.eclipse.lyo.testsuite.server.trsutils.FetchException;
+import org.eclipse.lyo.testsuite.server.trsutils.ITRSVocabulary;
+import org.eclipse.lyo.testsuite.server.trsutils.InvalidTRSException;
+import org.eclipse.lyo.testsuite.server.trsutils.Messages;
+import org.eclipse.lyo.testsuite.server.trsutils.SendException;
+import org.eclipse.lyo.testsuite.server.trsutils.SendUtil;
+import org.eclipse.lyo.testsuite.server.trsutils.TestCore;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/EasySSLClient.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/EasySSLClient.java
deleted file mode 100644
index a4416a2..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/EasySSLClient.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong - Initial implementation
- *******************************************************************************/
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-import java.security.KeyManagementException;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.conn.ssl.TrustStrategy;
-import org.apache.http.impl.client.BasicCookieStore;
-import org.apache.http.impl.client.DefaultHttpClient;
-
-public class EasySSLClient {
- private DefaultHttpClient httpClient;
-
- public EasySSLClient() throws Exception
- {
- httpClient = new DefaultHttpClient();
- initCookiePolicy();
- initSSLPolicy();
- }
-
- void initCookiePolicy() {
- httpClient.setCookieStore(new BasicCookieStore());
- }
-
- void initSSLPolicy() throws Exception {
- Scheme http1 = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
- Scheme http2 = new Scheme("http", 8080, PlainSocketFactory.getSocketFactory());
- Scheme http3 = new Scheme("http", 8082, PlainSocketFactory.getSocketFactory());
- Scheme http4 = new Scheme("http", 9080, PlainSocketFactory.getSocketFactory());
- Scheme http5 = new Scheme("http", 9081, PlainSocketFactory.getSocketFactory());
-
- SSLSocketFactory sf = null;
-
- try {
- sf = getEasySSLSocketFactory();
- } catch (Exception e) {
- e.printStackTrace();
- throw new Exception("Unable to initialize SSL HttpClient");
- }
-
- Scheme https1 = new Scheme("https", 443, sf);
- Scheme https2 = new Scheme("https", 8443, sf);
- Scheme https3 = new Scheme("https", 9443, sf);
- Scheme https4 = new Scheme("https", 9444, sf);
-
- SchemeRegistry schemeRegistry = httpClient.getConnectionManager().getSchemeRegistry();
-
- schemeRegistry.register(http1);
- schemeRegistry.register(http2);
- schemeRegistry.register(http3);
- schemeRegistry.register(http4);
- schemeRegistry.register(http5);
- schemeRegistry.register(https1);
- schemeRegistry.register(https2);
- schemeRegistry.register(https3);
- schemeRegistry.register(https4);
- }
-
- private SSLSocketFactory getEasySSLSocketFactory()
- throws KeyManagementException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException
- {
- TrustStrategy trustStrategy = new TrustStrategy() {
- @Override
- public boolean isTrusted(X509Certificate[] x509Certificates,
- String s) throws CertificateException {
- return true; // Accept Self-Signed Certs
- }
- };
-
- SSLSocketFactory sslSocketFactory = null;
-
- //Bypass check for hostname verification
- sslSocketFactory =
- new SSLSocketFactory(trustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
-
- return sslSocketFactory;
- }
-
- public DefaultHttpClient getClient() {
- return this.httpClient;
- }
-}
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/FetchException.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/FetchException.java
deleted file mode 100644
index 019eb2f..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/FetchException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong, Sujeet Mishra - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-/**
- * A exception that is thrown when fetching a resource encounters an exception
- */
-public class FetchException extends Exception {
- private static final long serialVersionUID = -5064491774183615219L;
-
- public FetchException(String message) {
- super(message);
- }
-
- public FetchException(Throwable th) {
- super(th);
- }
-
- public FetchException(String message, Throwable th) {
- super(message, th);
- }
-}
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/FetchUtil.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/FetchUtil.java
deleted file mode 100644
index 2294f7a..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/FetchUtil.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong, Sujeet Mishra - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-import java.io.IOException;
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.Properties;
-
-import javax.ws.rs.HttpMethod;
-
-import net.oauth.OAuthAccessor;
-import net.oauth.OAuthConsumer;
-import net.oauth.OAuthException;
-import net.oauth.OAuthMessage;
-import net.oauth.OAuthServiceProvider;
-
-import org.apache.http.HttpStatus;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.HttpResponseException;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.protocol.HttpContext;
-import org.eclipse.lyo.core.trs.HttpConstants;
-
-import com.hp.hpl.jena.rdf.model.Model;
-
-/**
- * A class that provides a utility methods to fetch HTTP resources as well as
- * process fetch responses
- */
-public class FetchUtil {
- /**
- * Fetches a resource. In case of success, this method
- * returns an instance of the {@link Model}.
- *
- * @param uri
- * resource uri to fetch
- * @param httpClient
- * client used to fetch the resource
- * @param httpContext
- * http context to use for the call
- * @param acceptType
- * value to use in the accept header
- * @throws InterruptedException
- * if the thread is interrupted
- * @throws FetchException
- * if an error occurs while fetching the resource.
- * @throws IOException
- * if an error occurs while updating the retryable error
- * information into the error handler
- */
- public static Model fetchResource(String uri, HttpClient httpClient, HttpContext httpContext, String acceptType)
- throws InterruptedException, FetchException
- {
- if (uri == null)
- throw new IllegalArgumentException(
- Messages.getServerString("fetch.util.uri.null")); //$NON-NLS-1$
- if (httpClient == null)
- throw new IllegalArgumentException(
- Messages.getServerString("fetch.util.httpclient.null")); //$NON-NLS-1$
-
- Model model = null;
-
- try {
- new URL(uri); // Make sure URL is valid
-
- HttpGet get = new HttpGet(uri);
-
- get.setHeader(HttpConstants.ACCEPT, acceptType);
-
- // Caches must revalidate with origin server. This is to prevent a cache
- // from serving stale data. We may still get a cached response if the
- // origin server responds to the revalidation with a 304.
- // See Unspecified end-to-end revalidation:
- // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.4
- get.addHeader(HttpConstants.CACHE_CONTROL, "max-age=0"); //$NON-NLS-1$
-
- try {
- model = httpClient.execute(get, new RDFModelResponseHandler(uri), httpContext);
- } catch (HttpResponseException e1) {
- if (e1.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
- // If authentication is required attempt OAuth authentication.
- // This uses two legged OAuth which requires a functional
- // user be already configured on the resource server.
- Properties prop = TestCore.getConfigPropertiesInstance();
- String consumerKey = prop.getProperty("consumerKey");
- String consumerSecret = prop.getProperty("consumerSecret");
- String authorizationTokenURL = prop.getProperty("OAuthURL");
- String oAuthRealm = prop.getProperty("OAuthRealm");
-
- // Using the information from the config.properties file
- // construct the authentication header to use in our GET request
- OAuthServiceProvider provider = new OAuthServiceProvider(null, authorizationTokenURL, null);
- OAuthConsumer consumer = new OAuthConsumer("",consumerKey,consumerSecret,provider);
- OAuthAccessor accessor = new OAuthAccessor(consumer);
- accessor.accessToken = "";
-
- try {
- OAuthMessage message = accessor.newRequestMessage(HttpMethod.GET, prop.getProperty("configTrsEndpoint"), null);
- String authHeader = message.getAuthorizationHeader(oAuthRealm);
- get.setHeader("Authorization",authHeader);
- get.setHeader("OSLC-Core-Version", "2.0");
-
- model = httpClient.execute(get, new RDFModelResponseHandler(uri), httpContext);
- } catch (OAuthException e) {
- TestCore.terminateTest(Messages.getServerString("fetch.util.authentication.failure"), e);
- }
- }
- }
- } catch (Exception e) {
- String uriLocation = Messages.getServerString("fetch.util.uri.unidentifiable"); //$NON-NLS-1$
-
- if(uri != null && !uri.isEmpty())
- {
- uriLocation = uri;
- }
-
- throw new FetchException(MessageFormat.format(
- Messages.getServerString("fetch.util.retrieve.error"), //$NON-NLS-1$
- uriLocation));
- }
-
- return model;
- }
-}
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/HttpErrorHandler.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/HttpErrorHandler.java
deleted file mode 100644
index 1b88801..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/HttpErrorHandler.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong, Sujeet Mishra - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-import java.io.IOException;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpResponseException;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
-
-
-public class HttpErrorHandler {
-
- /**
- * Handle a possible HTTP error response.
- *
- * @param response
- * The HTTP response to handle; must not be <code>null</code>
- * @throws HttpResponseException
- * if the response status code maps to an exception class
- */
- public static void responseToException(HttpResponse response)
- throws HttpResponseException
- {
- if (response == null)
- throw new IllegalArgumentException(
- Messages.getServerString("http.error.handler.null.argument")); //$NON-NLS-1$
-
- Integer status = Integer.valueOf(response.getStatusLine().getStatusCode());
-
- //Create detail message from response status line and body
- String reasonPhrase = response.getStatusLine().getReasonPhrase();
-
- StringBuilder message = new StringBuilder(reasonPhrase == null ? "" : reasonPhrase); //$NON-NLS-1$
-
- if (response.getEntity() != null) {
- try {
- String body = EntityUtils.toString(response.getEntity(), HTTP.UTF_8);
- if (body != null && body.length() != 0) {
- message.append('\n');
- message.append(body);
- }
- } catch (IOException e) { } // ignore, since the original error needs to be reported
- }
-
- throw new HttpResponseException(status, message.toString());
- }
-}
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/HttpResponseUtil.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/HttpResponseUtil.java
deleted file mode 100644
index 8c9023a..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/HttpResponseUtil.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong, Sujeet Mishra - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-
-
-public class HttpResponseUtil {
- /**
- * Marks an HTTP response as final and disposes of any system resources
- * referenced by the response.
- * <p>
- * Clients should aggressively call this method as soon as they no longer need the response to
- * reduce contention over possibly scarce system resources.
- * </p>
- * <p>
- * Clients should <strong>not</strong> attempt to access the HTTP response after calling this
- * method.
- * </p>
- * @param response the HTTP response to finalize
- */
- public static void finalize(final HttpResponse response) {
- if (response == null)
- return;
- HttpEntity entity = response.getEntity();
- try {
- if (entity != null) {
- InputStream is = entity.getContent();
- if (is != null) {
- is.close();
- }
- }
- } catch (IOException e) { /* ignored */
- }
- }
-
- private HttpResponseUtil() {
- super();
- throw new UnsupportedOperationException(
- Messages.getServerString("http.response.util.no.instance")); //$NON-NLS-1$
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/ITRSVocabulary.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/ITRSVocabulary.java
deleted file mode 100644
index 55cb62d..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/ITRSVocabulary.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong, Sujeet Mishra - Initial implementation
- * David Terry - Add fields for TRS 2.0 compliance
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-import com.hp.hpl.jena.rdf.model.Property;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.rdf.model.ResourceFactory;
-
-/**
- * An API to access the vocabulary of the TRS Protocol.
- * The following namespaces are supported: {@link #TEMPORARILY_SUPPORTED} and {@link #LATEST}
- */
-public interface ITRSVocabulary {
-
- // Local names
- public static final String TRS_PROVIDER_LOCALNAME = "TrackedResourceSetProvider"; //$NON-NLS-1$
- public static final String TRS_RES_LOCALNAME = "TrackedResourceSet"; //$NON-NLS-1$
- public static final String TRS_PROP_LOCALNAME = "trackedResourceSet"; //$NON-NLS-1$
- public static final String BASE_LOCALNAME = "base"; //$NON-NLS-1$
- public static final String CUTOFFEVENT_LOCALNAME = "cutoffEvent"; //$NON-NLS-1$
- public static final String NEXT_LOCALNAME = "nextPage"; //$NON-NLS-1$
- public static final String CHANGELOG_LOCALNAME = "changeLog"; //$NON-NLS-1$
- public static final String CHANGE_LOCALNAME = "change"; //$NON-NLS-1$
- public static final String CHANGED_LOCALNAME = "changed"; //$NON-NLS-1$
- public static final String ORDER_LOCALNAME = "order"; //$NON-NLS-1$
- public static final String PREVIOUS_LOCALNAME = "previous"; //$NON-NLS-1$
- public static final String TRSURI_LOCALNAME = "TrackedResourceSetUri"; //$NON-NLS-1$
- public static final String CREATION_LOCALNAME = "Creation"; //$NON-NLS-1$
- public static final String MODIFICATION_LOCALNAME = "Modification"; //$NON-NLS-1$
- public static final String DELETION_LOCALNAME = "Deletion"; //$NON-NLS-1$
- public static final String CONTAINER_LOCALNAME = "Container"; //$NON-NLS-1$
- public static final String PAGE_LOCALNAME = "Page"; //$NON-NLS-1$
- public static final String PAGE_OF_LOCALNAME = "pageOf"; //$NON-NLS-1$
-
- /**
- * The namespace of the vocabulary as a string
- */
- public static final String NS = "http://open-services.net/ns/core/trs#"; //$NON-NLS-1$
-
- /**
- * Get a specific vocabulary within the TRS provider as a string
- */
- public static final String TRS_PROVIDER_URI = NS + TRS_PROVIDER_LOCALNAME;
-
- /**
- * Get a specific vocabulary within the TRS property as a string
- */
- public static final String TRS_PROP_URI = NS + TRS_PROP_LOCALNAME;
-
- /**
- * The resource for the TRS namespace
- */
- public static final Resource NAMESPACE = ResourceFactory.createResource(NS);
-
- /**
- * The property for the base predicate in a TRS
- */
- public static final Property BASE_PROPERTY = ResourceFactory.createProperty(NS, BASE_LOCALNAME);
-
- /**
- * The property for the cut off event predicate in a TRS
- */
- public static final Property CUTOFFEVENT_PROPERTY = ResourceFactory.createProperty(NS,
- CUTOFFEVENT_LOCALNAME);
-
- /**
- * The property for a change log predicate within a tracked resource set
- */
- public static final Property CHANGELOG_PROPERTY = ResourceFactory.createProperty(NS,
- CHANGELOG_LOCALNAME);
-
- /**
- * The property for the change predicate in a TRS
- */
- public static final Property CHANGE_PROPERTY = ResourceFactory.createProperty(NS,
- CHANGE_LOCALNAME);
-
- /**
- * The property for the changes predicate of a change log entry
- */
- public static final Property CHANGED_PROPERTY = ResourceFactory.createProperty(NS,
- CHANGED_LOCALNAME);
-
- /**
- * The property for the order predicate of a change log entry
- */
- public static final Property ORDER_PROPERTY = ResourceFactory.createProperty(NS,
- ORDER_LOCALNAME);
-
- /**
- * The property for the previous predicate in a TRS or base resource
- */
- public static final Property PREVIOUS_PROPERTY = ResourceFactory.createProperty(NS,
- PREVIOUS_LOCALNAME);
-
- /**
- * The resource for the set of tracked resources
- */
- public static final Resource TRS_RESOURCE = ResourceFactory.createResource(NS
- + TRS_RES_LOCALNAME);
-
- /**
- * The resource for the creation change log type
- */
- public static final Resource CREATION_RESOURCE = ResourceFactory.createResource(NS
- + CREATION_LOCALNAME);
-
- /**
- * The resource for the modification change log type
- */
- public static final Resource MODIFICATION_RESOURCE = ResourceFactory.createResource(NS
- + MODIFICATION_LOCALNAME);
-
- /**
- * The resource for the deletion change log type
- */
- public static final Resource DELETION_RESOURCE = ResourceFactory.createResource(NS
- + DELETION_LOCALNAME);
-
- // LDP related namespace, resources, and properties
- /**
- * Namespace for the Linked Data Platform
- */
- public static final String LDP_NS = "http://www.w3.org/ns/ldp#"; //$NON-NLS-1$
-
- /**
- * The Container resource type used by the base resource
- */
- public static final Resource CONTAINER_RESOURCE = ResourceFactory.createResource(LDP_NS
- + CONTAINER_LOCALNAME);
-
- /**
- * The Page resource type used by the base resource to reference the next
- * page in the base sequence.
- */
- public static final Resource PAGE_RESOURCE = ResourceFactory.createResource(LDP_NS
- + PAGE_LOCALNAME);
-
- /**
- * A reference back to the aggregate container this page belongs to
- */
- public static final Property PAGE_OF_RESOURCE = ResourceFactory.createProperty(LDP_NS
- + PAGE_OF_LOCALNAME);
-
- /**
- * The property for the next page resource in a base resource
- */
- public static final Property NEXT_PAGE_PROPERTY = ResourceFactory.createProperty(LDP_NS,
- NEXT_LOCALNAME);
-
-} \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/InvalidRDFResourceException.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/InvalidRDFResourceException.java
deleted file mode 100644
index be82d3a..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/InvalidRDFResourceException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong, Sujeet Mishra - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-import org.apache.http.client.ClientProtocolException;
-
-public class InvalidRDFResourceException extends ClientProtocolException {
- private static final long serialVersionUID = 1L;
-
- public InvalidRDFResourceException() {
- super();
- }
-
- public InvalidRDFResourceException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidRDFResourceException(String message) {
- super(message);
- }
-
- public InvalidRDFResourceException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/InvalidTRSException.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/InvalidTRSException.java
deleted file mode 100644
index 68d867d..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/InvalidTRSException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong, Sujeet Mishra - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-/**
- * A exception that is thrown when an invalid TRS, TRS Base or Change Log segment is encountered.
- */
-public class InvalidTRSException extends Exception {
- private static final long serialVersionUID = -5064491774183615219L;
-
- public InvalidTRSException(String message) {
- super(message);
- }
-
- public InvalidTRSException(Throwable th) {
- super(th);
- }
-
- public InvalidTRSException(String message, Throwable th) {
- super(message, th);
- }
-}
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/Messages.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/Messages.java
deleted file mode 100644
index 76fdbd5..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/Messages.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong, Sujeet Mishra - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class Messages {
- private static final String BUNDLE_NAME = "org.eclipse.lyo.testsuite.server.trsutils.messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
- .getBundle(Messages.BUNDLE_NAME);
-
- private Messages() {
- // DO Nothing
- }
-
- public static String getServerString(String key) {
- try {
- return Messages.RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- Messages.checkForWrongKey(key);
- return '!' + key + '!';
- }
- }
-
- private static void checkForWrongKey(String key) {
- String prefix = "_NoId."; //$NON-NLS-1$
- boolean prefixExists = key.startsWith(prefix);
- String newKey = prefixExists == true ? key.substring(prefix.length()) : prefix + key;
- try {
- Messages.RESOURCE_BUNDLE.getString(newKey);
- String error =
- String.format(
- "The message key \"%s\" is wrong. It should be \"%s\".", key, newKey); //$NON-NLS-1$
- System.err.println(error);
- throw new RuntimeException(error);
- } catch (MissingResourceException e) {
- // No-op
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/ModelUtil.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/ModelUtil.java
deleted file mode 100644
index 601598d..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/ModelUtil.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong, Sujeet Mishra - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.HashSet;
-
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.ModelFactory;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.shared.JenaException;
-import com.hp.hpl.jena.util.FileUtils;
-import com.hp.hpl.jena.vocabulary.DC;
-import com.hp.hpl.jena.vocabulary.DCTerms;
-import com.hp.hpl.jena.vocabulary.RDFS;
-
-public class ModelUtil {
- /**
- * @param bytes
- * Serialized RDF/XML model
- * @return Deserialized RDF model
- * @throws JenaException
- */
- static public Model deserializeModel(byte[] bytes) throws JenaException {
- if (bytes == null)
- throw new IllegalArgumentException(
- Messages.getServerString("model.util.bytes.null")); //$NON-NLS-1$
-
- return deserializeModel(new ByteArrayInputStream(bytes));
- }
-
- /**
- * @param bytes
- * Serialized RDF/XML model
- * @param lang
- * See
- * {@link com.hp.hpl.jena.rdf.model.Model#read(java.io.InputStream, String, String)}
- * @return Deserialized RDF model
- * @throws JenaException
- */
- static public Model deserializeModel(byte[] bytes, String lang) throws JenaException {
- if (bytes == null)
- throw new IllegalArgumentException(
- Messages.getServerString("model.util.bytes.null")); //$NON-NLS-1$
-
- return deserializeModel(new ByteArrayInputStream(bytes), lang);
- }
-
- /**
- * @param in
- * Serialized RDF/XML model
- * @return Deserialized RDF model
- * @throws JenaException
- */
- static public Model deserializeModel(InputStream in) throws JenaException {
- return deserializeModel(in, null);
- }
-
- /**
- * @param in
- * Serialized RDF model
- * @param lang
- * See
- * {@link com.hp.hpl.jena.rdf.model.Model#read(java.io.InputStream, String, String)}
- * @return Deserialized RDF model
- * @throws JenaException
- */
- static public Model deserializeModel(InputStream in, String lang) throws JenaException {
- if (in == null)
- throw new IllegalArgumentException(
- Messages.getServerString("model.util.inputstream.null")); //$NON-NLS-1$
-
- Model model = ModelUtil.createDefaultModel();
-
- try {
- model.read(in, null, lang);
- } catch (Throwable t) {
- // Temp ignore - TODO ignore empty stream specifically
- return model;
- }
-
- return model;
- }
-
- /**
- * @param model
- * Input model
- * @return Serialized RDF/XML model
- * @throws JenaException
- */
- static public byte[] serializeModel(Model model) throws JenaException {
- return serializeModel(model, (String) null);
- }
-
- /**
- * @param model
- * Input Model
- * @param lang
- * See
- * {@link com.hp.hpl.jena.rdf.model.Model#read(java.io.InputStream, String, String)}
- * @return Serialized model
- * @throws JenaException
- */
- static public byte[] serializeModel(Model model, String lang) throws JenaException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- serializeModel(model, lang, out);
- return out.toByteArray();
- }
-
- /**
- * @param model
- * Input model
- * @param out
- * Serialized RDF/XML model
- * @throws JenaException
- */
- static public void serializeModel(Model model, OutputStream out) throws JenaException {
- serializeModel(model, null, out);
- }
-
- /**
- * @param model
- * Input Model
- * @param lang
- * See
- * {@link com.hp.hpl.jena.rdf.model.Model#read(java.io.InputStream, String, String)}
- * @param out
- * Serialized model
- * @throws JenaException
- */
- static public void serializeModel(Model model, String lang, OutputStream out)
- throws JenaException {
- if (model == null)
- throw new IllegalArgumentException(
- Messages.getServerString("model.util.model.null")); //$NON-NLS-1$
- if (out == null)
- throw new IllegalArgumentException(
- Messages.getServerString("model.util.outputstream.null")); //$NON-NLS-1$
- // Avoid 'WARN com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter - Namespace prefix 'j.1' is
- // reserved by Jena.'
- for (String prefix : new HashSet<String>(model.getNsPrefixMap().keySet())) {
- model.removeNsPrefix(prefix);
- }
- model.write(out, lang);
- }
-
- public static Model getLocalModel(String path) {
- InputStream in = ModelUtil.class.getResourceAsStream(path);
- Model model = ModelUtil.createDefaultModel();
- model.read(in, null, FileUtils.guessLang(path, FileUtils.langXML));
- return model;
- }
-
- public static String getVocabularyTitle(Model vocabulary, String uri) {
- Resource nsResource = vocabulary.createResource(uri);
- if (nsResource.hasProperty(DCTerms.title)) {
- return nsResource.getProperty(DCTerms.title).getString();
- } else if (nsResource.hasProperty(DC.title)) {
- return nsResource.getProperty(DC.title).getString();
- } else if (nsResource.hasProperty(RDFS.label))
- return nsResource.getProperty(RDFS.label).getString();
- return null;
- }
-
- /*
- * This is a utility method to workaround WAS classloading issues with jena
- */
- public static Model createDefaultModel() {
- Model model = null;
- // save the current thread class loader (TCCL)
- ClassLoader ctxClassloader = Thread.currentThread().getContextClassLoader();
- try {
- // Get the java class loader to allow jena to use xml/xerces dependencies
- Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
- model = ModelFactory.createDefaultModel();
- } finally {
- // put it back the way it was
- Thread.currentThread().setContextClassLoader(ctxClassloader);
- }
- return model;
- }
-}
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/RDFModelResponseHandler.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/RDFModelResponseHandler.java
deleted file mode 100644
index d339f28..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/RDFModelResponseHandler.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong, Sujeet Mishra - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.text.MessageFormat;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
-import org.eclipse.lyo.core.trs.HttpConstants;
-import org.openjena.riot.ContentType;
-import org.openjena.riot.Lang;
-import org.openjena.riot.WebContent;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.ResourceFactory;
-
-public class RDFModelResponseHandler implements ResponseHandler<Model> {
- final Node base;
-
- protected int statusCode = 0;
- protected String reason = null;
-
- public RDFModelResponseHandler(Node base) {
- this.base = base;
- }
-
- public RDFModelResponseHandler(String base) {
- this(ResourceFactory.createResource(base).asNode());
- }
-
- @Override
- public Model handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
- statusCode = response.getStatusLine().getStatusCode();
- reason = response.getStatusLine().getReasonPhrase();
- Model model = ModelUtil.createDefaultModel();
- HttpEntity entity = response.getEntity();
- try {
- if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
- HttpErrorHandler.responseToException(response);
- }
-
- if (entity == null)
-
- throw new InvalidRDFResourceException(
- MessageFormat.format(
- Messages.getServerString("rdf.model.response.helper.missing.rdf"), //$NON-NLS-1$
- base.getURI()));
-
- String rdfFormat = null;
- final Header contentTypeHeader = response.getFirstHeader(HttpConstants.CONTENT_TYPE);
- if (contentTypeHeader != null) {
- final ContentType contentType = ContentType.parse(contentTypeHeader.getValue());
- if (contentType != null) {
- Lang lang = WebContent.contentTypeToLang(contentType.getContentType());
- if (lang != null) {
- rdfFormat = lang.getName();
- } else if (HttpConstants.CT_TEXT_XML.equals(contentType.getContentType())) {
- rdfFormat = Lang.RDFXML.getName(); // attempt RDF
- // parsing anyway
- }
- }
- }
-
- if (rdfFormat == null)
- throw new ClientProtocolException(
- MessageFormat.format(
- Messages.getServerString("rdf.model.response.helper.bad.content.type"), //$NON-NLS-1$
- base.getURI()));
-
- String content = EntityUtils.toString(entity, HTTP.UTF_8);
- try {
- model.read(new StringReader(content), base.getURI(), rdfFormat);
- } catch (Exception e) {
- if (e.getMessage().contains("Interrupt") //$NON-NLS-1$
- || Thread.currentThread().isInterrupted()) {
- Thread.currentThread().interrupt();
- throw (IOException) new IOException().initCause(e);
- }
-
- throw new InvalidRDFResourceException(
- MessageFormat.format(
- Messages.getServerString("rdf.model.response.helper.unparseable.rdf"), //$NON-NLS-1$
- base.getURI(),
- content), e);
- }
-
- HttpResponseUtil.finalize(response);
- } finally {
- try {
- if (entity != null) {
- EntityUtils.consume(entity);
- }
- } catch (IOException e) {
- // ignore
- }
- }
- return model;
- }
-
- public int getStatusCode() {
- return statusCode;
- }
-
- public String getReasonPhrase() {
- return reason;
- }
-} \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/SendException.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/SendException.java
deleted file mode 100644
index cb60350..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/SendException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong, Sujeet Mishra - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-/**
- * A exception that is thrown when creating/updating a resource encounters an exception
- */
-public class SendException extends Exception {
-
- private static final long serialVersionUID = -7111348864477190261L;
-
- public SendException(String message) {
- super(message);
- }
-
- public SendException(Throwable th) {
- super(th);
- }
-
- public SendException(String message, Throwable th) {
- super(message, th);
- }
-}
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/SendUtil.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/SendUtil.java
deleted file mode 100644
index 706abde..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/SendUtil.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Sujeet Mishra - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-import java.io.IOException;
-import java.net.URL;
-import java.text.MessageFormat;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.EntityUtils;
-import org.eclipse.lyo.core.trs.HttpConstants;
-
-/**
- * This Class contains methods to send data to the server
- * in the form of HTTP POST or HTTP PUT calls
- */
-public class SendUtil {
-
- /**
- *
- * @param uri resource uri for creation factory
- * @param httpClient client used to post to the uri
- * @param httpContext http context to use for the call
- * @param contentType content type to be used in the creation
- * @param content content to be used in the creation
- * @throws SendException if an error occurs in posting to the uri
- */
- public static String createResource(String uri, HttpClient httpClient, HttpContext httpContext, String contentType, String content) throws SendException
- {
- String createdResourceUri="";
- if (uri == null)
- throw new IllegalArgumentException(
- Messages.getServerString("send.util.uri.null")); //$NON-NLS-1$
- if (httpClient == null)
- throw new IllegalArgumentException(
- Messages.getServerString("send.util.httpclient.null")); //$NON-NLS-1$
- try {
- new URL(uri); // Make sure URL is valid
-
- HttpPost post = new HttpPost(uri);
- StringEntity entity = new StringEntity(content);
- post.setEntity(entity);
- post.setHeader(HttpConstants.ACCEPT, HttpConstants.CT_APPLICATION_RDF_XML);//$NON-NLS-1$
- post.addHeader(HttpConstants.CONTENT_TYPE, contentType);
- post.addHeader(HttpConstants.CACHE_CONTROL, "max-age=0"); //$NON-NLS-1$
- HttpResponse resp = httpClient.execute(post);
-
- try {
- if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_CREATED) {
- HttpErrorHandler.responseToException(resp);
- }
- createdResourceUri=resp.getFirstHeader(HttpConstants.LOCATION).getValue();
- HttpResponseUtil.finalize(resp);
- }finally {
- try {
- if (entity != null) {
- EntityUtils.consume(entity);
- }
- } catch (IOException e) {
- // ignore
- }
- }
-
-
- } catch (Exception e) {
- String uriLocation = Messages.getServerString("send.util.uri.unidentifiable"); //$NON-NLS-1$
-
- if(uri != null && !uri.isEmpty())
- {
- uriLocation = uri;
- }
- throw new SendException(MessageFormat.format(
- Messages.getServerString("send.util.retrieve.error"), //$NON-NLS-1$
- uriLocation));
- }
-
- return createdResourceUri;
- }
-
-
- /**
- *
- * @param uri resource uri for update
- * @param httpClient client used to put data to the uri
- * @param httpContext http context to use for the call
- * @param content content to be used in the updation
- * @throws SendException if an error occurs in putting data to the uri
- */
-
- public static boolean updateResource(String uri, HttpClient httpClient, HttpContext httpContext,String contentType, String content) throws SendException
- {
- boolean resourceUpdated=false;
- if (uri == null)
- throw new IllegalArgumentException(
- Messages.getServerString("send.util.uri.null")); //$NON-NLS-1$
- if (httpClient == null)
- throw new IllegalArgumentException(
- Messages.getServerString("send.util.httpclient.null")); //$NON-NLS-1$
- try {
- new URL(uri); // Make sure URL is valid
-
- HttpPut put = new HttpPut(uri);
- StringEntity entity = new StringEntity(content);
- put.setEntity(entity);
- put.setHeader(HttpConstants.ACCEPT, HttpConstants.CT_APPLICATION_RDF_XML);
- put.addHeader(HttpConstants.CONTENT_TYPE, contentType);
- put.addHeader(HttpConstants.CACHE_CONTROL, "max-age=0"); //$NON-NLS-1$
- HttpResponse resp = httpClient.execute(put);
-
- try {
- if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
- HttpErrorHandler.responseToException(resp);
- }
- resourceUpdated=true;
- HttpResponseUtil.finalize(resp);
- }finally {
- try {
- if (entity != null) {
- EntityUtils.consume(entity);
- }
- } catch (IOException e) {
- // ignore
- }
- }
-
-
- } catch (Exception e) {
- String uriLocation = Messages.getServerString("send.util.uri.unidentifiable"); //$NON-NLS-1$
-
- if(uri != null && !uri.isEmpty())
- {
- uriLocation = uri;
- }
- throw new SendException(MessageFormat.format(
- Messages.getServerString("send.util.retrieve.error"), //$NON-NLS-1$
- uriLocation));
- }
-
- return resourceUpdated;
- }
-
-}
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/TestCore.java b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/TestCore.java
deleted file mode 100644
index 75cb5fd..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/TestCore.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- *
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *
- * Joseph Leong, Sujeet Mishra - Initial implementation
- *******************************************************************************/
-
-package org.eclipse.lyo.rio.trs.tests.utils;
-
-import static org.eclipse.lyo.core.trs.TRSConstants.FileSep;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Properties;
-import java.util.Scanner;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.protocol.HttpContext;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Property;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.rdf.model.Statement;
-import com.hp.hpl.jena.rdf.model.StmtIterator;
-
-public class TestCore {
-
- protected static final String RESOURCES =
- "src" + FileSep + "main" + FileSep + "resources";
- private static final String CONFIG_PROPERTIES =
- RESOURCES + FileSep + "config.properties";
-
- protected static void printResource(Resource resource) {
- for(Statement stmt : resource.listProperties().toList()) {
- System.out.println(stmt.getSubject().getLocalName() + " " + stmt.getPredicate().getLocalName() + " " + stmt.getObject().toString());
- }
- }
-
- protected static Resource getResource(String uri, HttpClient httpClient, HttpContext httpContext, String acceptType)
- throws InterruptedException, FetchException
- {
- Model model = FetchUtil.fetchResource(uri, httpClient, httpContext, acceptType);
-
- return model.createResource(uri);
- }
-
- protected static Properties getConfigPropertiesInstance()
- throws FileNotFoundException, IOException
- {
- Properties prop = new Properties();
-
- prop.load(new FileInputStream(CONFIG_PROPERTIES));
-
- return prop;
- }
-
- protected static void terminateTest(String addlMsg, Exception e) {
- String errorMsg = Messages.getServerString("tests.core.error");
-
- if(addlMsg != null) {
- errorMsg += addlMsg;
- }
-
- System.out.println(errorMsg);
- e.printStackTrace();
-
- System.exit(1);
- }
-
- protected StmtIterator getStatementsForProp(Resource res, Property prop) {
- return res.listProperties(prop);
- }
-
- /**
- * This method is used to read the contents
- * of a file as a String
- * @param f
- * @return
- */
- protected static String readFileAsString(File f) {
-
- StringBuilder stringBuilder = new StringBuilder();
- Scanner scanner = null;
- try {
- scanner = new Scanner(f);
- } catch (FileNotFoundException e) {
- return null;
- }
-
- try {
- while (scanner.hasNextLine()) {
- stringBuilder.append(scanner.nextLine() + "\n");
- }
- } finally {
- scanner.close();
- }
- return stringBuilder.toString();
- }
-}
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/messages.properties b/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/messages.properties
deleted file mode 100644
index 5236838..0000000
--- a/org.eclipse.lyo.rio.trs.tests/src/main/java/org/eclipse/lyo/rio/trs/tests/utils/messages.properties
+++ /dev/null
@@ -1,49 +0,0 @@
-###############################################################################
- # Copyright (c) 2013 IBM Corporation.
- #
- # All rights reserved. This program and the accompanying materials
- # are made available under the terms of the Eclipse Public License v1.0
- # and Eclipse Distribution License v. 1.0 which accompanies this distribution.
- #
- # The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- # and the Eclipse Distribution License is available at
- # http://www.eclipse.org/org/documents/edl-v10.php.
- #
- # Contributors:
- #
- # Joseph Leong, Sujeet Mishra - Initial implementation
- ###############################################################################
-model.util.bytes.null = bytes must not be null
-model.util.model.null = model must not be null
-model.util.inputstream.null = InputStream must not be null
-model.util.outputstream.null = OutputStream must not be null
-
-fetch.util.authentication.failure = Tests were not authorized to access TRS resource and fallback OAuth authentication failed.
-fetch.util.uri.null = Argument uri must not be null
-fetch.util.httpclient.null = Argument httpClient must not be null
-fetch.util.uri.unidentifiable = Unable to identify URI Location
-fetch.util.retrieve.error = Unable to Fetch/Parse Resource: {0}
-
-send.util.uri.null = Argument uri must not be null
-send.util.httpclient.null = Argument httpClient must not be null
-send.util.uri.unidentifiable = Unable to identify URI Location
-send.util.retrieve.error = Unable to Fetch/Parse Resource: {0}
-
-tests.general.config.properties.missing = Config Properties File Not Found
-tests.general.config.properties.unreadable = Unable to Read Configuration Properties File
-tests.general.trs.fetch.error = Unable to Fetch and Parse TRS Resource
-tests.general.trs.send.error = Unable to create or update the resource
-tests.general.error = Test Failed for Unexpected Reason: {0}
-tests.core.error = Unrecoverable error: Cannot perform prerequisite setup before tests. Exiting.
-
-rdf.model.response.helper.missing.rdf = Missing RDF content for {0}
-rdf.model.response.helper.bad.content.type = Bad Content-Type header for URL: {0}
-rdf.model.response.helper.unparseable.rdf = Unable to parse RDF for {0}: {1}
-
-http.error.handler.null.argument = The response argument must not be null
-
-http.response.util.no.instance = Instance creation is not supported
-
-validators.invalid.trs.changed.property = Invalid trs:changed property
-validators.invalid.trs.change.property = Invalid trs:change property
-validators.missing.trs.change.property = Missing trs:change property \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs.tests/src/main/resources/config.properties b/org.eclipse.lyo.rio.trs.tests/src/main/resources/config.properties
index 1d16c4d..5846944 100644
--- a/org.eclipse.lyo.rio.trs.tests/src/main/resources/config.properties
+++ b/org.eclipse.lyo.rio.trs.tests/src/main/resources/config.properties
@@ -1,5 +1,10 @@
##TRS service configuration Parameters##
+#IMPORTANT! These tests depend upon the org.eclipse.lyo.testsuite.trs project.
+#Please refer to its src/main/resource/config.properties for additional
+#properties that control authentication and other REST properties not directly
+#related to these change log tests.
+
#Accept Type for obtaining a REST resource.
acceptType = text/turtle
@@ -20,16 +25,4 @@ configResContentFile =
#Media/Content type to be used for the Update
configUpdateContentType = application/rdf+xml
#Content to be posted to the resource for Update
-configResUpdateFile = resourceUpdateContent.xml
-
-#OAuth consumer key. Often generated by and shared with the resource server
-consumerKey = key
-
-#OAuth consumer secret shared with the resource server
-consumerSecret = secret
-
-#Name of the OAuth Realm
-OAuthRealm = Jazz
-
-#OAuth Authentication URL
-OAuthURL = https://localhost:9443/ccm/oauth-authorize \ No newline at end of file
+configResUpdateFile = resourceUpdateContent.xml \ No newline at end of file