Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2009-11-25 20:47:23 +0000
committerrelves2009-11-25 20:47:23 +0000
commitd469b0916eb6f214434380c7ca663de0c95a6009 (patch)
tree2c0da00fdec07a4d15b23e98b77983e0148c7c1c /org.eclipse.mylyn.oslc.tests/src
parent173d40086f013b834908cb3a828bb78547af243c (diff)
downloadorg.eclipse.mylyn.tasks-d469b0916eb6f214434380c7ca663de0c95a6009.tar.gz
org.eclipse.mylyn.tasks-d469b0916eb6f214434380c7ca663de0c95a6009.tar.xz
org.eclipse.mylyn.tasks-d469b0916eb6f214434380c7ca663de0c95a6009.zip
NEW - bug 281711: produce Java API for OSLC CM 1.0
https://bugs.eclipse.org/bugs/show_bug.cgi?id=281711
Diffstat (limited to 'org.eclipse.mylyn.oslc.tests/src')
-rw-r--r--org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/ServiceDiscoveryTest.java110
-rw-r--r--org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/SimpleQueryTest.java75
2 files changed, 185 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/ServiceDiscoveryTest.java b/org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/ServiceDiscoveryTest.java
new file mode 100644
index 000000000..b75156563
--- /dev/null
+++ b/org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/ServiceDiscoveryTest.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+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.commons.tests.support.CommonTestUtil;
+import org.eclipse.mylyn.internal.oslc.cm.ui.OslcClient;
+import org.eclipse.mylyn.internal.oslc.core.OslcCreationDialogDescriptor;
+import org.eclipse.mylyn.internal.oslc.core.OslcSelectionDialogDescriptor;
+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.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.TaskRepositoryLocationFactory;
+
+/**
+ * @author Robert Elves
+ */
+public class ServiceDiscoveryTest extends TestCase {
+ private TaskRepository repository;
+ private AbstractWebLocation location;
+ private AbstractOslcClient client;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.repository = new TaskRepository("myoslcconnetorkind"
+ ,
+ "http://mylyn.eclipse.org/oslc/cqrest");
+ this.repository.setCredentials(AuthenticationType.REPOSITORY,
+ new AuthenticationCredentials("xxx", "xxx"), false);
+ this.location = new TaskRepositoryLocationFactory()
+ .createWebLocation(repository);
+ this.client = new OslcClient(location,
+ new OslcServiceDescriptor("http://mylyn.eclipse.org/oslc/cqrest"));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+
+ public void testServiceCatalogParsing() throws IOException, CoreException {
+ File file = CommonTestUtil.getFile(ServiceDiscoveryTest.class, "xml/service-provider-catalog.xml");
+ FileInputStream inStream = new FileInputStream(file);
+ ArrayList list = new ArrayList();
+ client.parseServices(inStream, list, new NullProgressMonitor());
+ assertEquals(1, list.size());
+ OslcServiceProvider desc = (OslcServiceProvider)list.get(0);
+ assertEquals("http://mylyn.eclipse.org/oslc/cqrest/repo/7.0.0/db/SAMPL", desc.getUrl());
+ }
+
+ public void testServiceDescriptorParsing() throws IOException, CoreException {
+ File file = CommonTestUtil.getFile(ServiceDiscoveryTest.class, "xml/service-descriptor.xml");
+ FileInputStream inStream = new FileInputStream(file);
+ ArrayList list = new ArrayList();
+ OslcServiceDescriptor desc = new OslcServiceDescriptor("http://mylyn.eclipse.org/oslc/cqrest/repo/7.0.0/db/SAMPL");
+ client.parseServiceDescriptor(inStream, desc, new NullProgressMonitor());
+
+ assertEquals("RCM/CQ OSLC CM Service Description Document", desc.getTitle());
+ assertEquals("Rational Change Management/ClearQuest OSLC CM Services available for 7.0.0/SAMPL.", desc.getDescription());
+
+ // ServiceHome
+ assertEquals("Change Requests", desc.getHome().getTitle());
+ assertEquals("http://mylyn.eclipse.org/cqweb/restapi/7.0.0/SAMPL?format=html", desc.getHome().getUrl());
+
+ // Creation Dialogs
+ OslcCreationDialogDescriptor creationDialog = desc.getDefaultCreationDialog();
+ assertEquals("New Defect - IBM Rational ClearQuest", creationDialog.getTitle());
+ assertEquals("http://mylyn.eclipse.org/oslc/cqrest/repo/7.0.0/db/SAMPL/record-type/16777224/creationDialog?dc%3Atype=Defect", creationDialog.getUrl());
+
+ // Factory
+ assertEquals("Unattended location for the creation of ClearQuest Records", desc.getDefaultFactory().getTitle());
+ assertEquals("http://mylyn.eclipse.org/oslc/cqrest/repo/7.0.0/db/SAMPL/record", desc.getDefaultFactory().getUrl());
+
+ // Selection Dialogs
+
+ assertTrue(desc.getSelectionDialogs().size() > 0);
+ OslcSelectionDialogDescriptor selectionDialog = desc.getDefaultSelectionDialog();
+ assertNotNull(selectionDialog);
+ assertEquals("640px", selectionDialog.getHintWidth());
+ assertEquals("540px", selectionDialog.getHintHeight());
+ assertEquals("Choose ClearQuest Record - IBM Rational ClearQuest", selectionDialog.getTitle());
+ assertEquals("ClearQuest Record", selectionDialog.getLabel());
+ assertEquals("http://mylyn.eclipse.org/cqweb/chooseRecord.cq?type=cq.repo.cq-rectype%3A16777224%407.0.0%2FSAMPL&restrictType=false", selectionDialog.getUrl());
+ }
+
+
+
+}
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
new file mode 100644
index 000000000..a5bcecec1
--- /dev/null
+++ b/org.eclipse.mylyn.oslc.tests/src/org/eclipse/mylyn/oslc/cm/tests/SimpleQueryTest.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.io.File;
+import java.io.FileInputStream;
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+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.commons.tests.support.CommonTestUtil;
+import org.eclipse.mylyn.internal.oslc.cm.ui.OslcClient;
+import org.eclipse.mylyn.internal.oslc.core.IOslcCoreConstants;
+import org.eclipse.mylyn.internal.oslc.core.OslcServiceDescriptor;
+import org.eclipse.mylyn.internal.oslc.core.client.AbstractOslcClient;
+import org.eclipse.mylyn.internal.oslc.core.cm.AbstractChangeRequest;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.TaskRepositoryLocationFactory;
+
+/**
+ * @author Robert Elves
+ */
+public class SimpleQueryTest extends TestCase {
+ private TaskRepository repository;
+ private AbstractWebLocation location;
+ private AbstractOslcClient client;
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.repository = new TaskRepository(
+ IOslcCoreConstants.ID_PLUGIN,
+ "http://mylyn.eclipse.org/oslc/cqrest");
+ this.repository.setCredentials(AuthenticationType.REPOSITORY,
+ new AuthenticationCredentials("xxx", "xxx"), false);
+ this.location = new TaskRepositoryLocationFactory()
+ .createWebLocation(repository);
+ this.client = new OslcClient(location,
+ new OslcServiceDescriptor("http://mylyn.eclipse.org/oslc/cqrest"));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+
+ public void testParseQueryResponse() throws Exception {
+ File file = CommonTestUtil.getFile(ServiceDiscoveryTest.class, "xml/query-response.xml");
+ FileInputStream inStream = new FileInputStream(file);
+ ArrayList list = new ArrayList();
+ client.parseQueryResponse(inStream, list, new NullProgressMonitor());
+ assertEquals(1, list.size());
+ AbstractChangeRequest desc = (AbstractChangeRequest)list.get(0);
+ assertEquals("test bug", desc.getTitle());
+ assertEquals("10", desc.getIdentifier());
+ assertEquals("", desc.getType()); // rdf:resource
+ assertEquals("test description", desc.getDescription());
+ assertEquals("", desc.getSubject());
+ assertEquals("", desc.getCreator()); // rdf:resource
+ assertEquals("2009-10-12T08:58:20.588Z", desc.getModified());
+ }
+
+}

Back to the top