Skip to content

Commit

Permalink
NEW - bug 281711: produce Java API for OSLC CM 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
relves committed Nov 25, 2009
1 parent 173d400 commit d469b09
Show file tree
Hide file tree
Showing 11 changed files with 518 additions and 0 deletions.
7 changes: 7 additions & 0 deletions org.eclipse.mylyn.oslc.tests/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?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="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
28 changes: 28 additions & 0 deletions org.eclipse.mylyn.oslc.tests/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.mylyn.oslc.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Fri May 15 07:55:19 PDT 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
15 changes: 15 additions & 0 deletions org.eclipse.mylyn.oslc.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tests
Bundle-SymbolicName: org.eclipse.mylyn.oslc.tests
Bundle-Version: 1.0.0.qualifier
Require-Bundle: org.eclipse.core.runtime,
org.junit,
org.eclipse.mylyn.commons.core;bundle-version="3.2.0",
org.eclipse.mylyn.tasks.core;bundle-version="3.2.0",
org.eclipse.mylyn.commons.net;bundle-version="3.2.0",
org.jdom;bundle-version="1.0.0",
org.eclipse.mylyn.commons.tests;bundle-version="0.0.0",
org.eclipse.mylyn.oslc.cm.ui;bundle-version="3.2.0",
org.eclipse.mylyn.oslc.core;bundle-version="3.2.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
14 changes: 14 additions & 0 deletions org.eclipse.mylyn.oslc.tests/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
###############################################################################
# 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
###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
Original file line number Diff line number Diff line change
@@ -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());
}



}
Original file line number Diff line number Diff line change
@@ -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());
}

}
98 changes: 98 additions & 0 deletions org.eclipse.mylyn.oslc.tests/xml/change-request.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<oslc_cm:Collection xmlns:rtc_cm="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/"
xmlns:oslc_disc="http://open-services.net/xmlns/discovery/1.0/"
xmlns:dc="http://purl.org/dc/terms/" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
xmlns:jp="http://jazz.net/xmlns/prod/jazz/presentation/1.0/" xmlns:jd="http://jazz.net/xmlns/prod/jazz/discovery/1.0/"
xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/" xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/"
oslc_cm:totalCount="1">
<oslc_cm:ChangeRequest
rdf:resource="https://mylyn.eclipse.org:9443/jazz/resource/itemOid/com.ibm.team.workitem.WorkItem/_PL7SELcNEd67as-op4LhuA">
<rtc_cm:filedAgainst
rdf:resource="https://mylyn.eclipse.org:9443/jazz/resource/itemOid/com.ibm.team.workitem.Category/_S3KqMbcMEd67as-op4LhuA" />
<rtc_cm:correctedEstimate />
<dc:created>2009-10-12T08:58:20.496Z</dc:created>
<dc:creator
rdf:resource="https://mylyn.eclipse.org:9443/jazz/oslc/users/_KGRY4CFWEdq-WY5y7lROQw" />
<dc:description>test description</dc:description>
<rtc_cm:due />
<rtc_cm:estimate />
<rtc_cm:foundIn />
<dc:identifier>10</dc:identifier>
<rtc_cm:comments
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:comments" />
<oslc_cm:priority
rdf:resource="https://mylyn.eclipse.org:9443/jazz/oslc/enumerations/_RysVcLcMEd67as-op4LhuA/priority/priority.literal.l02" />
<rtc_cm:resolution />
<oslc_cm:severity
rdf:resource="https://mylyn.eclipse.org:9443/jazz/oslc/enumerations/_RysVcLcMEd67as-op4LhuA/severity/severity.literal.l3" />
<rtc_cm:state
rdf:resource="https://mylyn.eclipse.org:9443/jazz/oslc/workflows/_RysVcLcMEd67as-op4LhuA/states/com.ibm.team.workitem.defectWorkflow/1" />
<rtc_cm:subscribers
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:subscribers" />
<dc:subject />
<dc:modified>2009-10-12T08:58:20.588Z</dc:modified>
<rtc_cm:modifiedBy
rdf:resource="https://mylyn.eclipse.org:9443/jazz/oslc/users/_KGRY4CFWEdq-WY5y7lROQw" />
<rtc_cm:ownedBy
rdf:resource="https://mylyn.eclipse.org:9443/jazz/oslc/users/_KGRY4CFWEdq-WY5y7lROQw" />
<rtc_cm:projectArea
rdf:resource="https://mylyn.eclipse.org:9443/jazz/oslc/projectareas/_RysVcLcMEd67as-op4LhuA" />
<rtc_cm:resolved />
<rtc_cm:resolvedBy
rdf:resource="https://mylyn.eclipse.org:9443/jazz/oslc/users/_YNh4MOlsEdq4xpiOKg5hvA" />
<rtc_cm:startDate />
<dc:title>test bug</dc:title>
<rtc_cm:plannedFor
rdf:resource="https://mylyn.eclipse.org:9443/jazz/oslc/iterations/_R4c_MrcMEd67as-op4LhuA" />
<rtc_cm:timeSpent />
<dc:type
rdf:resource="https://mylyn.eclipse.org:9443/jazz/oslc/types/_RysVcLcMEd67as-op4LhuA/defect" />
<rtc_cm:teamArea
rdf:resource="https://mylyn.eclipse.org:9443/jazz/oslc/teamareas/_S0voULcMEd67as-op4LhuA" />
<rtc_cm:com.ibm.team.connector.ccbridge.common.act2wi.s
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.connector.ccbridge.common.act2wi.s" />
<rtc_cm:com.ibm.team.build.linktype.includedWorkItems.com.ibm.team.build.common.link.includedInBuilds
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.build.linktype.includedWorkItems.com.ibm.team.build.common.link.includedInBuilds" />
<calm:blocksTestExecutionRecord
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/calm:blocksTestExecutionRecord" />
<rtc_cm:com.ibm.team.workitem.linktype.textualReference.textuallyReferenced
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.workitem.linktype.textualReference.textuallyReferenced" />
<calm:implementsRequirement
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/calm:implementsRequirement" />
<calm:testedByTestCase
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/calm:testedByTestCase" />
<rtc_cm:com.ibm.team.workitem.linktype.attachment.attachment
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.workitem.linktype.attachment.attachment" />
<rtc_cm:com.ibm.team.workitem.linktype.relatedartifact.relatedArtifact
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.workitem.linktype.relatedartifact.relatedArtifact" />
<rtc_cm:com.ibm.team.build.linktype.reportedWorkItems.com.ibm.team.build.common.link.reportedAgainstBuilds
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.build.linktype.reportedWorkItems.com.ibm.team.build.common.link.reportedAgainstBuilds" />
<rtc_cm:com.ibm.team.workitem.linktype.relatedworkitem.related
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.workitem.linktype.relatedworkitem.related" />
<rtc_cm:com.ibm.team.scm.svn.linkType.workItem.s
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.scm.svn.linkType.workItem.s" />
<oslc_cm:relatedChangeManagement
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/oslc_cm:relatedChangeManagement" />
<rtc_cm:com.ibm.team.workitem.linktype.copiedworkitem.copies
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.workitem.linktype.copiedworkitem.copies" />
<rtc_cm:com.ibm.team.workitem.linktype.copiedworkitem.copiedFrom
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.workitem.linktype.copiedworkitem.copiedFrom" />
<rtc_cm:com.ibm.team.workitem.linktype.blocksworkitem.blocks
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.workitem.linktype.blocksworkitem.blocks" />
<rtc_cm:com.ibm.team.workitem.linktype.blocksworkitem.dependsOn
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.workitem.linktype.blocksworkitem.dependsOn" />
<rtc_cm:com.ibm.team.workitem.linktype.duplicateworkitem.duplicates
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.workitem.linktype.duplicateworkitem.duplicates" />
<rtc_cm:com.ibm.team.workitem.linktype.duplicateworkitem.duplicateOf
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.workitem.linktype.duplicateworkitem.duplicateOf" />
<rtc_cm:com.ibm.team.filesystem.workitems.change_set.com.ibm.team.scm.ChangeSet
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.filesystem.workitems.change_set.com.ibm.team.scm.ChangeSet" />
<calm:affectsExecutionResult
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/calm:affectsExecutionResult" />
<rtc_cm:com.ibm.team.workitem.linktype.parentworkitem.parent
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.workitem.linktype.parentworkitem.parent" />
<rtc_cm:com.ibm.team.workitem.linktype.parentworkitem.children
oslc_cm:collref="https://mylyn.eclipse.org:9443/jazz/oslc/workitems/_PL7SELcNEd67as-op4LhuA/rtc_cm:com.ibm.team.workitem.linktype.parentworkitem.children" />
</oslc_cm:ChangeRequest>
</oslc_cm:Collection>
Loading

0 comments on commit d469b09

Please sign in to comment.