Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/xmi/A.ecore8
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/xmi/B.ecore6
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AllTests.java4
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/AllInternalCoreTests.java30
-rw-r--r--tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/CDOUtilsTest.java139
5 files changed, 185 insertions, 2 deletions
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/xmi/A.ecore b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/xmi/A.ecore
new file mode 100644
index 00000000000..b5ef8ae8408
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/xmi/A.ecore
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="a" nsURI="http://www.eclipse.org/papyrus/test/2013/a" nsPrefix="a">
+ <eClassifiers xsi:type="ecore:EClass" name="A1" eSuperTypes="B.ecore#//B1 B.ecore#//B2"/>
+ <eClassifiers xsi:type="ecore:EClass" name="A2">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="a1" upperBound="-1" eType="#//A1"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/xmi/B.ecore b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/xmi/B.ecore
new file mode 100644
index 00000000000..0cf9cc7e559
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/resources/xmi/B.ecore
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="b" nsURI="http://www.eclipse.org/papyrus/test/2013/b" nsPrefix="b">
+ <eClassifiers xsi:type="ecore:EClass" name="B1"/>
+ <eClassifiers xsi:type="ecore:EClass" name="B2"/>
+</ecore:EPackage>
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AllTests.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AllTests.java
index 6d5865486f3..43633eba7dd 100644
--- a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AllTests.java
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/core/tests/AllTests.java
@@ -16,7 +16,7 @@ import org.eclipse.papyrus.cdo.core.util.tests.AllUtilTests;
import org.eclipse.papyrus.cdo.internal.core.exporter.tests.AllModelExportTests;
import org.eclipse.papyrus.cdo.internal.core.expressions.tests.AllExpressionsTests;
import org.eclipse.papyrus.cdo.internal.core.importer.tests.AllModelImportTests;
-import org.eclipse.papyrus.cdo.internal.core.tests.PapyrusRepositoryManagerTest;
+import org.eclipse.papyrus.cdo.internal.core.tests.AllInternalCoreTests;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@@ -26,7 +26,7 @@ import org.junit.runners.Suite.SuiteClasses;
*/
@RunWith(Suite.class)
@SuiteClasses({ AllUtilTests.class, AllExpressionsTests.class, //
-PapyrusRepositoryManagerTest.class, CDOAwareModelSetTest.class, //
+AllInternalCoreTests.class, CDOAwareModelSetTest.class, //
AllModelImportTests.class, AllModelExportTests.class })
public class AllTests {
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/AllInternalCoreTests.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/AllInternalCoreTests.java
new file mode 100644
index 00000000000..ff7c4a89a3c
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/AllInternalCoreTests.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.tests;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+
+/**
+ * This is the AllInternalCoreTests type. Enjoy.
+ */
+@RunWith(Suite.class)
+@SuiteClasses({ CDOUtilsTest.class, PapyrusRepositoryManagerTest.class })
+public class AllInternalCoreTests {
+
+ public AllInternalCoreTests() {
+ super();
+ }
+
+}
diff --git a/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/CDOUtilsTest.java b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/CDOUtilsTest.java
new file mode 100644
index 00000000000..ab9b621a79b
--- /dev/null
+++ b/tests/junit/extraplugins/cdo/org.eclipse.papyrus.cdo.core.tests/src/org/eclipse/papyrus/cdo/internal/core/tests/CDOUtilsTest.java
@@ -0,0 +1,139 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.tests;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.net.URL;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EContentsEList.FeatureListIterator;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.junit.Test;
+
+
+/**
+ * Selected unit tests for the {@link CDOUtils} class.
+ */
+public class CDOUtilsTest {
+
+ public CDOUtilsTest() {
+ super();
+ }
+
+ @Test
+ public void testIteratorScalarAttribute() throws Exception {
+ FeatureListIterator<String> sIter = CDOUtils.iterator(EcorePackage.Literals.ECLASS, EcorePackage.Literals.ENAMED_ELEMENT__NAME, false);
+
+ assertThat(sIter.hasNext(), is(true));
+ assertThat(sIter.nextIndex(), is(-1));
+ assertThat(sIter.next(), is(EcorePackage.Literals.ECLASS.getName()));
+
+ assertThat(sIter.hasPrevious(), is(true));
+ assertThat(sIter.previousIndex(), is(-1));
+ assertThat(sIter.previous(), is(EcorePackage.Literals.ECLASS.getName()));
+ }
+
+ @Test
+ public void testIteratorEmptyReference() throws Exception {
+ FeatureListIterator<String> sIter = CDOUtils.iterator(EcorePackage.eINSTANCE, EcorePackage.Literals.EPACKAGE__ESUPER_PACKAGE, false);
+
+ assertThat(sIter.hasNext(), is(false));
+ assertThat(sIter.nextIndex(), is(-1));
+ assertThat(sIter.hasPrevious(), is(false));
+ }
+
+ @Test
+ public void testIteratorReferenceResolving() throws Exception {
+ ResourceSet rset = new ResourceSetImpl();
+ Resource a = rset.getResource(getTestResourceURI("A.ecore"), true);
+
+ EClass a1 = (EClass)((EPackage)a.getContents().get(0)).getEClassifier("A1");
+ FeatureListIterator<EClass> sIter = CDOUtils.iterator(a1, EcorePackage.Literals.ECLASS__ESUPER_TYPES, true);
+
+ assertThat(sIter.hasNext(), is(true));
+ assertThat(sIter.nextIndex(), is(0));
+ assertThat(sIter.next().getName(), is("B1"));
+
+ assertThat(sIter.hasNext(), is(true));
+ assertThat(sIter.nextIndex(), is(1));
+ assertThat(sIter.next().getName(), is("B2"));
+
+ assertThat(sIter.hasNext(), is(false));
+ assertThat(sIter.nextIndex(), is(2));
+
+ assertThat(sIter.hasPrevious(), is(true));
+ assertThat(sIter.previousIndex(), is(1));
+ assertThat(sIter.previous().getName(), is("B2"));
+
+ assertThat(sIter.hasPrevious(), is(true));
+ assertThat(sIter.previousIndex(), is(0));
+ assertThat(sIter.previous().getName(), is("B1"));
+
+ assertThat(sIter.hasPrevious(), is(false));
+ }
+
+ @Test
+ public void testIteratorReferenceNonesolving() throws Exception {
+ ResourceSet rset = new ResourceSetImpl();
+ Resource a = rset.getResource(getTestResourceURI("A.ecore"), true);
+
+ EClass a1 = (EClass)((EPackage)a.getContents().get(0)).getEClassifier("A1");
+ FeatureListIterator<EClass> sIter = CDOUtils.iterator(a1, EcorePackage.Literals.ECLASS__ESUPER_TYPES, false);
+
+ assertThat(sIter.hasNext(), is(true));
+ assertThat(sIter.nextIndex(), is(0));
+ EClass next = sIter.next();
+ assertThat(next.eIsProxy(), is(true));
+ assertThat(EcoreUtil.getURI(next).fragment(), containsString("B1"));
+
+ assertThat(sIter.hasNext(), is(true));
+ next = sIter.next();
+ assertThat(next.eIsProxy(), is(true));
+ assertThat(EcoreUtil.getURI(next).fragment(), containsString("B2"));
+
+ assertThat(sIter.hasNext(), is(false));
+ assertThat(sIter.nextIndex(), is(2));
+
+ assertThat(sIter.hasPrevious(), is(true));
+ assertThat(sIter.previousIndex(), is(1));
+ EClass previous = sIter.previous();
+ assertThat(previous.eIsProxy(), is(true));
+ assertThat(EcoreUtil.getURI(previous).fragment(), containsString("B2"));
+
+ assertThat(sIter.hasPrevious(), is(true));
+ assertThat(sIter.previousIndex(), is(0));
+ previous = sIter.previous();
+ assertThat(previous.eIsProxy(), is(true));
+ assertThat(EcoreUtil.getURI(previous).fragment(), containsString("B1"));
+
+ assertThat(sIter.hasPrevious(), is(false));
+ }
+
+ //
+ // Test framework
+ //
+
+ URI getTestResourceURI(String name) {
+ URL result = getClass().getClassLoader().getResource("resources/xmi/" + name);
+ return URI.createURI(result.toExternalForm(), true);
+ }
+}

Back to the top