Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2013-03-19 06:54:13 -0400
committercletavernie2013-03-19 06:54:13 -0400
commit9b8cdfda0176cdf961eb71a84449d36aacbf0d4b (patch)
tree2025784f407b7027e444b84d6bdafe02b050622e /tests/junit/plugins/core
parente26c184119f7aba03655949116f1df5ce6970be8 (diff)
downloadorg.eclipse.papyrus-9b8cdfda0176cdf961eb71a84449d36aacbf0d4b.tar.gz
org.eclipse.papyrus-9b8cdfda0176cdf961eb71a84449d36aacbf0d4b.tar.xz
org.eclipse.papyrus-9b8cdfda0176cdf961eb71a84449d36aacbf0d4b.zip
403708: New URI implementation encodes fragment separator when parsing a string
https://bugs.eclipse.org/bugs/show_bug.cgi?id=403708 Update the resourceloading tests to correctly encode EMF URIs Patch from Christian Damus
Diffstat (limited to 'tests/junit/plugins/core')
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/test/org/eclipse/papyrus/core/resourceloading/tests/testModel1/AbstractResourceLoadingTestModel1.java19
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/test/org/eclipse/papyrus/core/resourceloading/tests/testModel2/AbstractResourceLoadingTestModel2.java15
2 files changed, 19 insertions, 15 deletions
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/test/org/eclipse/papyrus/core/resourceloading/tests/testModel1/AbstractResourceLoadingTestModel1.java b/tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/test/org/eclipse/papyrus/core/resourceloading/tests/testModel1/AbstractResourceLoadingTestModel1.java
index 783262f7eeb..3b728d6b561 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/test/org/eclipse/papyrus/core/resourceloading/tests/testModel1/AbstractResourceLoadingTestModel1.java
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/test/org/eclipse/papyrus/core/resourceloading/tests/testModel1/AbstractResourceLoadingTestModel1.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
+ * Copyright (c) 2010, 2013 Atos Origin, CEA, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ * Christian W. Damus (CEA) - Work around regression in URI parsing in EMF 2.9
*
*****************************************************************************/
package org.eclipse.papyrus.core.resourceloading.tests.testModel1;
@@ -141,15 +142,15 @@ public abstract class AbstractResourceLoadingTestModel1 extends TestCase {
public void testGetObjectOfControlledResource() {
// test getting EObject of the specified URI
// level 0
- URI uriClass0 = URI.createPlatformResourceURI(RESOURCE_URI + "model1.uml#_SEFk0H04Ed-RG-XtCG9Nmw", false);
+ URI uriClass0 = URI.createPlatformResourceURI(RESOURCE_URI + "model1.uml", false).appendFragment("_SEFk0H04Ed-RG-XtCG9Nmw");
EObject eObject = modelSet.getEObject(uriClass0, true);
assertTestGetObjectOfControlledResource("Load object of the current resource: ", eObject, uriClass0);
// level 1
- URI uriClass1 = URI.createPlatformResourceURI(RESOURCE_URI + "Package0.uml#_nQhGUH04Ed-RG-XtCG9Nmw", false);
+ URI uriClass1 = URI.createPlatformResourceURI(RESOURCE_URI + "Package0.uml", false).appendFragment("_nQhGUH04Ed-RG-XtCG9Nmw");
EObject eObject2 = modelSet.getEObject(uriClass1, true);
assertTestGetObjectOfControlledResource("Load object in a controlled resource at level 1", eObject2, uriClass1);
// level 2
- URI uriClass2 = URI.createPlatformResourceURI(RESOURCE_URI + "Package1.uml#_sRCZ4H04Ed-RG-XtCG9Nmw", false);
+ URI uriClass2 = URI.createPlatformResourceURI(RESOURCE_URI + "Package1.uml", false).appendFragment("_sRCZ4H04Ed-RG-XtCG9Nmw");
EObject eObject3 = modelSet.getEObject(uriClass2, true);
assertTestGetObjectOfControlledResource("Load object in a controlled resource at level 2", eObject3, uriClass2);
}
@@ -188,15 +189,15 @@ public abstract class AbstractResourceLoadingTestModel1 extends TestCase {
public void testGetDiagramOfControlledResource() {
// get notation reference from di resource
// level 0
- URI uriNewDiagram = URI.createPlatformResourceURI(RESOURCE_URI + "model1.notation#_QtEHgH04Ed-RG-XtCG9Nmw", false);
+ URI uriNewDiagram = URI.createPlatformResourceURI(RESOURCE_URI + "model1.notation", false).appendFragment("_QtEHgH04Ed-RG-XtCG9Nmw");
EObject newDiagram = modelSet.getEObject(uriNewDiagram, true);
assertTestGetDiagramOfControlledResource("Load diagram in a controlled resource at level 2", newDiagram, uriNewDiagram);
// level 1
- URI uriDiagram0 = URI.createPlatformResourceURI(RESOURCE_URI + "Package0.notation#_mvutcH04Ed-RG-XtCG9Nmw", false);
+ URI uriDiagram0 = URI.createPlatformResourceURI(RESOURCE_URI + "Package0.notation", false).appendFragment("_mvutcH04Ed-RG-XtCG9Nmw");
EObject diagram0 = modelSet.getEObject(uriDiagram0, true);
assertTestGetDiagramOfControlledResource("Load diagram in a controlled resource at level 2", diagram0, uriDiagram0);
// level 2
- URI uriDiagram1 = URI.createPlatformResourceURI(RESOURCE_URI + "Package1.notation#_r1npMH04Ed-RG-XtCG9Nmw", false);
+ URI uriDiagram1 = URI.createPlatformResourceURI(RESOURCE_URI + "Package1.notation", false).appendFragment("_r1npMH04Ed-RG-XtCG9Nmw");
EObject diagram1 = modelSet.getEObject(uriDiagram1, true);
assertTestGetDiagramOfControlledResource("Load diagram in a controlled resource at level 2", diagram1, uriDiagram1);
}
@@ -230,7 +231,7 @@ public abstract class AbstractResourceLoadingTestModel1 extends TestCase {
* Gets a needed profile resource from the local project
*/
public void testGetObjectOfProfileResource() {
- URI uriPlatformProfile = URI.createPlatformResourceURI(RESOURCE_URI + "MyProfile.uml#_XkGiwB07Ed-QQ4mYkrb7Gg", false);
+ URI uriPlatformProfile = URI.createPlatformResourceURI(RESOURCE_URI + "MyProfile.uml", false).appendFragment("_XkGiwB07Ed-QQ4mYkrb7Gg");
System.err.println(uriPlatformProfile);
Resource resource = modelSet.getResource(uriPlatformProfile, true);
assertNotNull("Resource should not be null", resource);
@@ -257,7 +258,7 @@ public abstract class AbstractResourceLoadingTestModel1 extends TestCase {
* - try to get the property type from model1 resource to check the reference update
*/
public void testGetDanglingReferenceFromAControlledResource() {
- URI uriProperty0 = URI.createPlatformResourceURI(RESOURCE_URI + "model1.uml#_RHuPYIQsEd-SDs-So_GGkw", false);
+ URI uriProperty0 = URI.createPlatformResourceURI(RESOURCE_URI + "model1.uml", false).appendFragment("_RHuPYIQsEd-SDs-So_GGkw");
EObject property0 = modelSet.getEObject(uriProperty0, true);
if(property0 instanceof Property) {
Type type = ((Property)property0).getType();
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/test/org/eclipse/papyrus/core/resourceloading/tests/testModel2/AbstractResourceLoadingTestModel2.java b/tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/test/org/eclipse/papyrus/core/resourceloading/tests/testModel2/AbstractResourceLoadingTestModel2.java
index f8a27d9162e..1ff53e1aade 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/test/org/eclipse/papyrus/core/resourceloading/tests/testModel2/AbstractResourceLoadingTestModel2.java
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/test/org/eclipse/papyrus/core/resourceloading/tests/testModel2/AbstractResourceLoadingTestModel2.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
+ * Copyright (c) 2010, 2013 Atos Origin, CEA, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ * Christian W. Damus (CEA) - Work around regression in URI parsing in EMF 2.9
*
*****************************************************************************/
package org.eclipse.papyrus.core.resourceloading.tests.testModel2;
@@ -104,7 +105,9 @@ public abstract class AbstractResourceLoadingTestModel2 extends TestCase {
createFolder(project, INITIAL_PATH);
URL url = FileLocator.find(Platform.getBundle(ITestConstants.FRAGMENT_ID), new Path(INITIAL_PATH + res + s), null);
URL newFile = FileLocator.resolve(url);
- file.createLink(newFile.toURI(), IResource.REPLACE, monitor);
+
+ // encode the URI for spaces in the path
+ file.createLink(new URL(newFile.toString().replaceAll(" ", "%20")).toURI(), IResource.REPLACE, monitor);
}
}
}
@@ -133,7 +136,7 @@ public abstract class AbstractResourceLoadingTestModel2 extends TestCase {
* Gets an object (Class0) from a reference (type of property) to the high level resource (model1)
*/
public void testGetReferenceInControlledRessource() {
- URI uriProperty0 = URI.createPlatformResourceURI(RESOURCE_URI + "Package0.uml#_57LlkIRSEd-ZSb15jhF0Qw", false);
+ URI uriProperty0 = URI.createPlatformResourceURI(RESOURCE_URI + "Package0.uml", false).appendFragment("_57LlkIRSEd-ZSb15jhF0Qw");
EObject property0 = modelSet.getEObject(uriProperty0, true);
Type type = null;
if(property0 instanceof Property) {
@@ -141,7 +144,7 @@ public abstract class AbstractResourceLoadingTestModel2 extends TestCase {
assertTestGetDanglingReferenceFromParentResource("Get type from controlled resource is resolved", type);
}
- URI uriClass0 = URI.createPlatformResourceURI(RESOURCE_URI + "model1.uml#_1766sIRSEd-ZSb15jhF0Qw", false);
+ URI uriClass0 = URI.createPlatformResourceURI(RESOURCE_URI + "model1.uml", false).appendFragment("_1766sIRSEd-ZSb15jhF0Qw");
EObject class0 = modelSet.getEObject(uriClass0, true);
assertTestGetReferenceInControlledRessource("Type of property is resolved ? :", type, class0);
}
@@ -198,7 +201,7 @@ public abstract class AbstractResourceLoadingTestModel2 extends TestCase {
* Gets a figure (figure of Class0) contains in the high level resource (model1) from a diagram in controlled resource (Package0)
*/
public void testGetFigureInControlledRessource() {
- URI uriFigurePackage0 = URI.createPlatformResourceURI(RESOURCE_URI + "Package0.notation#_-ig9EIRSEd-ZSb15jhF0Qw", false);
+ URI uriFigurePackage0 = URI.createPlatformResourceURI(RESOURCE_URI + "Package0.notation", false).appendFragment("_-ig9EIRSEd-ZSb15jhF0Qw");
EObject figurePackage0 = modelSet.getEObject(uriFigurePackage0, true);
assertTestGetFigureInControlledRessource1("Get figure in Package0 resource", figurePackage0);
EObject element = null;
@@ -206,7 +209,7 @@ public abstract class AbstractResourceLoadingTestModel2 extends TestCase {
Node node = (Node)figurePackage0;
element = node.getElement();
}
- URI uriClass0 = URI.createPlatformResourceURI(RESOURCE_URI + "model1.uml#_1766sIRSEd-ZSb15jhF0Qw", false);
+ URI uriClass0 = URI.createPlatformResourceURI(RESOURCE_URI + "model1.uml", false).appendFragment("_1766sIRSEd-ZSb15jhF0Qw");
EObject class0 = modelSet.getEObject(uriClass0, true);
assertTestGetFigureInControlledRessource2("Load figure from high level resource", class0, element);
}

Back to the top