Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2010-02-12 00:39:06 -0500
committerrelves2010-02-12 00:39:06 -0500
commit58d9432f7793dbbdf1c5e4dc367607e523e44af2 (patch)
treed3160e6dfc4ac746310b58237b501b01de538d9d /org.eclipse.mylyn.oslc.tests
parent6ac7d3509ded0f23ab1ca34b3503a05bbedb7f8b (diff)
downloadorg.eclipse.mylyn.tasks-58d9432f7793dbbdf1c5e4dc367607e523e44af2.tar.gz
org.eclipse.mylyn.tasks-58d9432f7793dbbdf1c5e4dc367607e523e44af2.tar.xz
org.eclipse.mylyn.tasks-58d9432f7793dbbdf1c5e4dc367607e523e44af2.zip
NEW - bug 302672: [oslc] create unit test against RTC Rational Team Concert's OSLC api
https://bugs.eclipse.org/bugs/show_bug.cgi?id=302672
Diffstat (limited to 'org.eclipse.mylyn.oslc.tests')
-rw-r--r--org.eclipse.mylyn.oslc.tests/.classpath6
-rw-r--r--org.eclipse.mylyn.oslc.tests/.settings/org.eclipse.jdt.core.prefs4
-rw-r--r--org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/RtcOlscTest.java117
-rw-r--r--org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/SimpleQueryTest.java2
4 files changed, 126 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.oslc.tests/.classpath b/org.eclipse.mylyn.oslc.tests/.classpath
index 64c5e31b7..e961e71e1 100644
--- a/org.eclipse.mylyn.oslc.tests/.classpath
+++ b/org.eclipse.mylyn.oslc.tests/.classpath
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
+ <accessrules>
+ <accessrule kind="accessible" pattern="org/eclipse/mylyn/internal/oslc/**"/>
+ </accessrules>
+ </classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.mylyn.oslc.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.mylyn.oslc.tests/.settings/org.eclipse.jdt.core.prefs
index 0b3b1ffa1..6d31702ce 100644
--- a/org.eclipse.mylyn.oslc.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.mylyn.oslc.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Wed Nov 25 13:43:10 PST 2009
+#Fri Feb 12 00:11:35 EST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
@@ -8,6 +8,8 @@ org.eclipse.jdt.core.codeComplete.localPrefixes=
org.eclipse.jdt.core.codeComplete.localSuffixes=
org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
diff --git a/org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/RtcOlscTest.java b/org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/RtcOlscTest.java
new file mode 100644
index 000000000..cf3568b2a
--- /dev/null
+++ b/org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/RtcOlscTest.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.oslc.cm.tests;
+
+import java.net.URLEncoder;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.mylyn.commons.net.AbstractWebLocation;
+import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
+import org.eclipse.mylyn.internal.oslc.core.OslcServiceDescriptor;
+import org.eclipse.mylyn.internal.oslc.core.OslcServiceProvider;
+import org.eclipse.mylyn.internal.oslc.core.client.AbstractOslcClient;
+import org.eclipse.mylyn.internal.oslc.core.cm.AbstractChangeRequest;
+import org.eclipse.mylyn.tasks.core.RepositoryResponse;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.TaskRepositoryLocationFactory;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+
+/**
+ * Holds tests that exercise the Mylyn OSLC library against Rational Team Concert (RTC) OSLC api
+ * <ul>
+ * <li>To be run against a new RTC instance with BASIC auth enabled. BASE_URL need to be update.</li>
+ * <li>A workitem exists with title "my first work item"</li>
+ * </ul>
+ *
+ * @author Robert Elves
+ */
+public class RtcOlscTest extends TestCase {
+ private TaskRepository repository;
+
+ private AbstractWebLocation location;
+
+ private AbstractOslcClient client;
+
+ private static final String BASE_URL = "https://172.16.166.130:9443/jazz/oslc/workitems/catalog";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.repository = new TaskRepository("rtc", BASE_URL);
+ this.repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("ADMIN", "ADMIN"),
+ false);
+ this.location = new TaskRepositoryLocationFactory().createWebLocation(repository);
+ this.client = new AbstractOslcClient(location, new OslcServiceDescriptor(BASE_URL)) {
+
+ @Override
+ public RepositoryResponse putTaskData(TaskData taskData, Set<TaskAttribute> oldValues,
+ IProgressMonitor monitor) throws CoreException {
+ // ignore
+ return null;
+ }
+
+ @Override
+ public String getUserAgent() {
+ // ignore
+ return null;
+ }
+
+ @Override
+ public TaskData getTaskData(String encodedTaskId, TaskAttributeMapper mapper, IProgressMonitor monitor)
+ throws CoreException {
+ // ignore
+ return null;
+ }
+
+ @Override
+ protected AbstractChangeRequest createChangeRequest(String id, String title) {
+ return new AbstractChangeRequest(id, title) {
+ };
+ }
+ };
+ }
+
+ /**
+ * Service Discovery
+ */
+ public void testServiceCatalogParsing() throws Exception {
+ List<OslcServiceProvider> services = client.getAvailableServices(BASE_URL, null);
+ assertEquals(1, services.size());
+ OslcServiceProvider desc = services.get(0);
+ OslcServiceDescriptor serviceDescriptor = client.getServiceDescriptor(desc, null);
+ assertTrue(serviceDescriptor.getSimpleQueryUrl().endsWith("/workitems"));
+ }
+
+ /**
+ * Simple Query for ChangeRequests
+ */
+ public void testSimpleQuery() throws Exception {
+ List<OslcServiceProvider> services = client.getAvailableServices(BASE_URL, null);
+ OslcServiceProvider desc = services.get(0);
+ OslcServiceDescriptor serviceDescriptor = client.getServiceDescriptor(desc, null);
+ Collection<AbstractChangeRequest> result = client.performQuery(serviceDescriptor.getSimpleQueryUrl()
+ + "?oslc_cm.query=" + URLEncoder.encode("dc:title=\"my first work item\"", "UTF-8"), null);
+ assertEquals(1, result.size());
+ AbstractChangeRequest request = result.iterator().next();
+ request.getTitle().equals("my first work item");
+
+ }
+}
diff --git a/org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/SimpleQueryTest.java b/org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/SimpleQueryTest.java
index b1c7f9cb3..7b482b4b6 100644
--- a/org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/SimpleQueryTest.java
+++ b/org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/SimpleQueryTest.java
@@ -90,7 +90,7 @@ public class SimpleQueryTest extends TestCase {
}
public void testParseQueryResponse() throws Exception {
- File file = CommonTestUtil.getFile(ServiceDiscoveryTest.class, "xml/query-response.xml");
+ File file = CommonTestUtil.getFile(SimpleQueryTest.class, "xml/query-response.xml");
FileInputStream inStream = new FileInputStream(file);
ArrayList<AbstractChangeRequest> list = new ArrayList<AbstractChangeRequest>();
client.parseQueryResponse(inStream, list, new NullProgressMonitor());

Back to the top