From 7d0406e22f6ee8e59d91e2cc474434d7175cc9cc Mon Sep 17 00:00:00 2001 From: rschnekenbu Date: Fri, 29 Apr 2011 09:18:48 +0000 Subject: Move the plugin from incoming folder to its final destination folder --- .../.classpath | 7 + .../.project | 28 +++ .../.settings/org.eclipse.jdt.core.prefs | 8 + .../META-INF/MANIFEST.MF | 11 ++ .../about.html | 28 +++ .../build.properties | 10 + .../fragment.properties | 12 ++ .../fragment.xml | 15 ++ .../icons/debug.gif | Bin 0 -> 348 bytes .../model/Test1.extendedtypes | 15 ++ .../model/model.di | 17 ++ .../model/model.notation | 39 ++++ .../model/model.uml | 8 + .../org.eclipse.papyrus.extendedtypes.tests.launch | 40 ++++ .../eclipse/papyrus/extendedtypes/AllTests.java | 27 +++ .../ExtendedEditHelperAdviceTests.java | 214 +++++++++++++++++++++ .../extendedtypes/ExtendedTypesRegistryTests.java | 128 ++++++++++++ .../papyrus/extendedtypes/ITestConstants.java | 53 +++++ .../preferences/ExtendedTypesPreferencesTests.java | 103 ++++++++++ 19 files changed, 763 insertions(+) create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/.classpath create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/.project create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/.settings/org.eclipse.jdt.core.prefs create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/META-INF/MANIFEST.MF create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/about.html create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/build.properties create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/fragment.properties create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/fragment.xml create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/icons/debug.gif create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/Test1.extendedtypes create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/model.di create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/model.notation create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/model.uml create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/org.eclipse.papyrus.extendedtypes.tests.launch create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/AllTests.java create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/ExtendedEditHelperAdviceTests.java create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/ExtendedTypesRegistryTests.java create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/ITestConstants.java create mode 100644 tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/preferences/ExtendedTypesPreferencesTests.java (limited to 'tests') diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/.classpath b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/.classpath new file mode 100644 index 00000000000..2d1a4302f04 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/.project b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/.project new file mode 100644 index 00000000000..6488a57fe49 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/.project @@ -0,0 +1,28 @@ + + + org.eclipse.papyrus.extendedtypes.tests + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/.settings/org.eclipse.jdt.core.prefs b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..25668b8f4f0 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Fri Oct 29 11:46:50 CEST 2010 +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 diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..fc77f62103c --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %fragmentName +Bundle-SymbolicName: org.eclipse.papyrus.extendedtypes.tests;singleton:=true +Bundle-Version: 0.8.0.qualifier +Bundle-Vendor: %providerName +Fragment-Host: org.eclipse.papyrus.extendedtypes;bundle-version="0.8.0" +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Require-Bundle: org.junit, + org.eclipse.papyrus.uml.service.types;bundle-version="0.7.1" +Export-Package: org.eclipse.papyrus.extendedtypes diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/about.html b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/about.html new file mode 100644 index 00000000000..82d49bf5f81 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

June 5, 2007

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/build.properties b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/build.properties new file mode 100644 index 00000000000..8f2ae069083 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/build.properties @@ -0,0 +1,10 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + fragment.xml,\ + icons/,\ + model/,\ + org.eclipse.papyrus.extendedtypes.tests.launch,\ + fragment.properties,\ + about.html diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/fragment.properties b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/fragment.properties new file mode 100644 index 00000000000..51e0c9e75aa --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/fragment.properties @@ -0,0 +1,12 @@ +############################################################################### +# Copyright (c) 2010 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 +############################################################################### +fragmentName=Papyrus enhanced types metamodel plugin tests(Incubation) +providerName=Eclipse.org diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/fragment.xml b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/fragment.xml new file mode 100644 index 00000000000..474fd5681bb --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/fragment.xml @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/icons/debug.gif b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/icons/debug.gif new file mode 100644 index 00000000000..ac5431fa311 Binary files /dev/null and b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/icons/debug.gif differ diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/Test1.extendedtypes b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/Test1.extendedtypes new file mode 100644 index 00000000000..cea39dc66b8 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/Test1.extendedtypes @@ -0,0 +1,15 @@ + + + + + org.eclipse.papyrus.uml.Class + + + + org.eclipse.papyrus.uml.Class + + + + org.eclipse.papyrus.uml.Class + + diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/model.di b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/model.di new file mode 100644 index 00000000000..65f88a8052c --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/model.di @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/model.notation b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/model.notation new file mode 100644 index 00000000000..6780a566229 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/model.notation @@ -0,0 +1,39 @@ + + + + +
+ + +
+ + +
+ + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/model.uml b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/model.uml new file mode 100644 index 00000000000..acc9d86ef26 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/model/model.uml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/org.eclipse.papyrus.extendedtypes.tests.launch b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/org.eclipse.papyrus.extendedtypes.tests.launch new file mode 100644 index 00000000000..c293afa2eb1 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/org.eclipse.papyrus.extendedtypes.tests.launch @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/AllTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/AllTests.java new file mode 100644 index 00000000000..9da5797da12 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/AllTests.java @@ -0,0 +1,27 @@ +/***************************************************************************** + * Copyright (c) 2010 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.extendedtypes; + +import org.eclipse.papyrus.extendedtypes.preferences.ExtendedTypesPreferencesTests; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + + +/** + * All tests for this fragment + */ +@RunWith(Suite.class) +@SuiteClasses({ ExtendedTypesRegistryTests.class, ExtendedEditHelperAdviceTests.class, ExtendedTypesPreferencesTests.class }) +public class AllTests { + +} diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/ExtendedEditHelperAdviceTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/ExtendedEditHelperAdviceTests.java new file mode 100644 index 00000000000..70ef1958b9c --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/ExtendedEditHelperAdviceTests.java @@ -0,0 +1,214 @@ +/***************************************************************************** + * Copyright (c) 2010 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.extendedtypes; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.UMLPackage; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + + +/** + * Test class for extended edit helper advice + */ +public class ExtendedEditHelperAdviceTests implements ITestConstants { + + /** test class1 element type */ + private static IElementType class1ElementType; + + /** test class in package element type */ + private static IElementType classInPackageElementType; + + /** test class in model element type */ + private static IElementType classInModelElementType; + + /** class1 configuration element type */ + private static ExtendedElementTypeConfiguration class1ElementTypeConfiguration; + + /** class in package configuration element type */ + private static ExtendedElementTypeConfiguration classInPackageElementTypeConfiguration; + + /** class in model configuration element type */ + private static ExtendedElementTypeConfiguration classInModelElementTypeConfiguration; + + /** extended edit helper advice for class1 */ + private static ExtendedEditHelperAdvice extendedClass1EditHelperAdvice; + + /** extended edit helper advice for class in package */ + private static ExtendedEditHelperAdvice extendedClassInPackageEditHelperAdvice; + + /** extended edit helper advice for class in model */ + private static ExtendedEditHelperAdvice extendedClassInModelEditHelperAdvice; + + /** package with short name */ + private static org.eclipse.uml2.uml.Package shortNamePackage; + + /** package with long name */ + private static org.eclipse.uml2.uml.Package longNamePackage; + + /** model with short Name */ + private static Package shortNameModel; + + /** model with long name */ + private static Package longNameModel; + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + // create the configuration passes as argument + class1ElementType = ExtendedTypesRegistry.getInstance().getType(CLASS1_TEST_TYPE_ID); + assertNotNull("Class1 element type should not be null", class1ElementType); + classInPackageElementType = ExtendedTypesRegistry.getInstance().getType(CLASS_IN_PACKAGE_TEST_TYPE_ID); + assertNotNull("Class in package element type should not be null", classInPackageElementType); + classInModelElementType = ExtendedTypesRegistry.getInstance().getType(CLASS_IN_MODEL_TEST_TYPE_ID); + assertNotNull("Class in model element type should not be null", classInModelElementType); + + ExtendedElementTypeSet set = ExtendedTypesRegistry.getInstance().getExtendedElementTypeSet(TEST1_CONFIGURATION_SET_ID, TEST1_MODEL_PATH, org.eclipse.papyrus.extendedtypes.Activator.PLUGIN_ID); + assertNotNull("extended type set should not be null", set); + for(ExtendedElementTypeConfiguration configuration : set.getElementType()) { + if(CLASS1_TEST_TYPE_CONFIGURATION_ID.equals(configuration.getId())) { + class1ElementTypeConfiguration = configuration; + } else if(CLASS_IN_PACKAGE_TEST_TYPE_CONFIGURATION_ID.equals(configuration.getId())) { + classInPackageElementTypeConfiguration = configuration; + } else if(CLASS_IN_MODEL_TEST_TYPE_CONFIGURATION_ID.equals(configuration.getId())) { + classInModelElementTypeConfiguration = configuration; + } + } + assertNotNull("extended type configuration should not be null", class1ElementTypeConfiguration); + assertNotNull("extended type configuration should not be null", classInPackageElementTypeConfiguration); + assertNotNull("extended type configuration should not be null", classInModelElementTypeConfiguration); + extendedClass1EditHelperAdvice = new ExtendedEditHelperAdvice(); + extendedClassInPackageEditHelperAdvice = new ExtendedEditHelperAdvice(); + extendedClassInModelEditHelperAdvice = new ExtendedEditHelperAdvice(); + + // create Test Model + Model model1 = UMLFactory.eINSTANCE.createModel(); + model1.setName("Model1"); + shortNamePackage = model1.createNestedPackage("P"); + longNamePackage = model1.createNestedPackage("veryLongPackage"); + shortNameModel = model1.createNestedPackage("tinyM", UMLPackage.eINSTANCE.getModel()); + longNameModel = model1.createNestedPackage("veryLongModel", UMLPackage.eINSTANCE.getModel()); + + } + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + class1ElementType = null; + class1ElementTypeConfiguration = null; + extendedClass1EditHelperAdvice = null; + shortNamePackage = null; + longNamePackage = null; + shortNameModel = null; + longNameModel = null; + } + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test method for + * {@link org.eclipse.papyrus.extendedtypes.ExtendedEditHelperAdvice#ExtendedEditHelperAdvice(org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration)} + * . + */ + @Test + public final void testExtendedEditHelperAdvice() { + assertNotNull("edit helper advice should not be null", extendedClass1EditHelperAdvice); + } + + /** + * Test method for + * {@link org.eclipse.papyrus.extendedtypes.ExtendedEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)} + * . + */ + @Test + public final void testApproveRequestIEditCommandRequest() { + // get the request: create a class on the test packages + + // simple test: test if it the name of the container is long or not enough + CreateElementRequest inShortPackageCreateRequest = new CreateElementRequest(shortNamePackage, class1ElementType); + boolean resultShort = extendedClass1EditHelperAdvice.approveRequest(inShortPackageCreateRequest); + assertTrue("request should always be approved", resultShort); + + // simple test: test if it the name of the container is long or not enough + CreateElementRequest inLongPackageCreateRequest = new CreateElementRequest(longNamePackage, class1ElementType); + boolean resultLong = extendedClass1EditHelperAdvice.approveRequest(inLongPackageCreateRequest); + assertTrue("request should always be approved", resultLong); + + // advanced tests: 2 queries at the same time (test true&false; false&false, false&true, true&true) + // false & false + CreateElementRequest requestShortPackageModel = new CreateElementRequest(shortNamePackage, classInModelElementType); + boolean shortPackageModel = extendedClassInModelEditHelperAdvice.approveRequest(requestShortPackageModel); + assertTrue("request should always be approved", shortPackageModel); + + // true & false + CreateElementRequest requestLongPackageModel = new CreateElementRequest(longNamePackage, classInModelElementType); + boolean longPackageModel = extendedClassInModelEditHelperAdvice.approveRequest(requestLongPackageModel); + assertTrue("request should always be approved", longPackageModel); + + // false & true + CreateElementRequest requestShortPackagePackage = new CreateElementRequest(shortNamePackage, classInPackageElementType); + boolean shortPackagePackage = extendedClassInPackageEditHelperAdvice.approveRequest(requestShortPackagePackage); + assertTrue("request should always be approved", shortPackagePackage); + + // true & true + CreateElementRequest requestlongPackagePackage = new CreateElementRequest(longNamePackage, classInPackageElementType); + boolean longPackagePackage = extendedClassInPackageEditHelperAdvice.approveRequest(requestlongPackagePackage); + assertTrue("request should always be approved", longPackagePackage); + } + + /** + * Test method for + * {@link org.eclipse.papyrus.extendedtypes.ExtendedEditHelperAdvice#getBeforeCreateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest)} + * . + */ + @Test + public final void testGetBeforeCreateCommandCreateElementRequest() { + // not test here for now... + } + + /** + * Test method for + * {@link org.eclipse.papyrus.extendedtypes.ExtendedEditHelperAdvice#getAfterCreateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest)} + * . + */ + @Test + public final void testGetAfterCreateCommandCreateElementRequest() { + // test in {oep}.diagram.extendedtypes.uml.tests fragment + } + +} diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/ExtendedTypesRegistryTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/ExtendedTypesRegistryTests.java new file mode 100644 index 00000000000..1288c6321b9 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/ExtendedTypesRegistryTests.java @@ -0,0 +1,128 @@ +/***************************************************************************** + * Copyright (c) 2010 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.extendedtypes; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import junit.framework.Assert; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + + +/** + * Tests for {@link ExtendedTypesRegistry} + */ +public class ExtendedTypesRegistryTests implements ITestConstants { + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test method for {@link org.eclipse.papyrus.extendedtypes.ExtendedTypesRegistry#getInstance()}. + */ + @Test + public final void testGetInstance() { + Assert.assertNotNull("The singleton instance should not be null", ExtendedTypesRegistry.getInstance()); + } + + /** + * Test method for {@link org.eclipse.papyrus.extendedtypes.ExtendedTypesRegistry#loadExtendedTypeSets()}. + */ + @Test + public final void testLoadExtendedTypeSets() { + List result = ExtendedTypesRegistry.getInstance().loadExtendedTypeSets(); + + + assertNotNull("The list of extended type sets should not be null after loading", result); + assertTrue("The list of extended type sets should not be empty after loading", result.size() > 0); + + boolean found = false; + for(ExtendedElementTypeSet set : result) { + if(ExtendedTypeSetName_Test1.equals(set.getId())) { + found = true; + } + } + assertTrue("The list should contain Extended Type Set from Test1: " + ExtendedTypeSetName_Test1, found); + } + + /** + * Test method for {@link org.eclipse.papyrus.extendedtypes.ExtendedTypesRegistry#createResourceSet()}. + */ + @Test + public final void testCreateResourceSet() { + ResourceSet set = ExtendedTypesRegistry.getInstance().createResourceSet(); + assertNotNull("Resource set should not be null", set); + } + + /** + * Test method for {@link org.eclipse.papyrus.extendedtypes.ExtendedTypesRegistry#getExtendedElementTypeSet(java.lang.String, java.lang.String)}. + */ + @Test + public final void testGetExtendedElementTypeSet() { + ExtendedElementTypeSet set = ExtendedTypesRegistry.getInstance().getExtendedElementTypeSet(TEST1_CONFIGURATION_SET_ID, TEST1_MODEL_PATH, Activator.PLUGIN_ID); + assertNotNull("Element type model file set should be found", set); + + ExtendedElementTypeSet set2 = ExtendedTypesRegistry.getInstance().getExtendedElementTypeSet("null", NO_FILE, Activator.PLUGIN_ID); + assertNull("Element type model file set should not be found", set2); + } + + /** + * Test method for {@link org.eclipse.papyrus.extendedtypes.ExtendedTypesRegistry#getType(java.lang.String)}. + */ + @Test + public final void testGetType() { + IElementType classType = ExtendedTypesRegistry.getInstance().getType(UMLElementTypes.CLASS.getId()); + assertNotNull("element Type for class should be found", classType); + + IElementType extendedClassType = ExtendedTypesRegistry.getInstance().getType(CLASS1_TEST_TYPE_ID); + assertNotNull("element Type for class should be found", extendedClassType); + + IElementType noType = ExtendedTypesRegistry.getInstance().getType(NO_TYPE); + assertNull("element Type for class should not be found", noType); + } +} diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/ITestConstants.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/ITestConstants.java new file mode 100644 index 00000000000..0ccf3ceb232 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/ITestConstants.java @@ -0,0 +1,53 @@ +/***************************************************************************** + * Copyright (c) 2010 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.extendedtypes; + + +/** + * Constants for test classes + */ +public interface ITestConstants { + + /** element type id for test1::Class1 */ + public static final String CLASS1_TEST_TYPE_ID = "org.eclipse.papyrus.extendedtypes.tests.Class1"; + + /** element type id for test1::ClassInPackage */ + public static final String CLASS_IN_PACKAGE_TEST_TYPE_ID = "org.eclipse.papyrus.extendedtypes.tests.ClassInPackageOnly"; + + /** element type id for test1::ClassInModel */ + public static final String CLASS_IN_MODEL_TEST_TYPE_ID = "org.eclipse.papyrus.extendedtypes.tests.ClassInModelOnly"; + + + /** name of the extended type set in Test1 */ + public final static String ExtendedTypeSetName_Test1 = "org.eclipse.papyrus.extendedtypes.tests.test1"; + + /** path to a non existing file */ + public static final String NO_FILE = "no_file"; + + /** path to a right model file */ + public static final String TEST1_MODEL_PATH = "/model/Test1.extendedtypes"; + + /** identifier of the extende type set configuration */ + public static final String TEST1_CONFIGURATION_SET_ID = "org.eclipse.papyrus.extendedtypes.tests.test1"; + + /** no type identifier */ + public static final String NO_TYPE = "no_type"; + + /** configuration name for test1::Class1 */ + public static final String CLASS1_TEST_TYPE_CONFIGURATION_ID = "org.eclipse.papyrus.extendedtypes.tests.Class1"; + + /** configuration name for test1::Class1 */ + public static final String CLASS_IN_PACKAGE_TEST_TYPE_CONFIGURATION_ID = CLASS_IN_PACKAGE_TEST_TYPE_ID; + + /** configuration name for test1::Class1 */ + public static final String CLASS_IN_MODEL_TEST_TYPE_CONFIGURATION_ID = CLASS_IN_MODEL_TEST_TYPE_ID; +} diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/preferences/ExtendedTypesPreferencesTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/preferences/ExtendedTypesPreferencesTests.java new file mode 100644 index 00000000000..bf8c0743be5 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/extendedtypes/preferences/ExtendedTypesPreferencesTests.java @@ -0,0 +1,103 @@ +/***************************************************************************** + * Copyright (c) 2010 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.extendedtypes.preferences; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.eclipse.ui.IMemento; +import org.eclipse.ui.XMLMemento; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + + +/** + * Test class for {@link ExtendedTypesPreferences} + */ +public class ExtendedTypesPreferencesTests extends ExtendedTypesPreferences { + + /** id of the extended type set for tests */ + private final static String EXTENDED_TYPES_TEST_ID = "testExtendedTypes"; + + /** + * @throws java.lang.Exception + * exception thrown in case of issues + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + /** + * @throws java.lang.Exception + * exception thrown in case of issues + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + /** + * @throws java.lang.Exception + * exception thrown in case of issues + */ + @Before + public void setUp() throws Exception { + } + + /** + * @throws java.lang.Exception + * exception thrown in case of issues + */ + @After + public void tearDown() throws Exception { + } + + /** + * Test for local definitions of Palette in preferences + */ + @Test + public final void testLocalRedefinitions() { + // 1. saves the root memento + XMLMemento rootMemento = getLocalRedefinitions(); + IMemento[] extendedTypesRedefinitions = rootMemento.getChildren(EXTENDED_TYPES_REDEFINITION); + + int initialLength = extendedTypesRedefinitions.length; + + // 2. test add + // be sure not already existing + String path = getExtendedTypesRedefinition(EXTENDED_TYPES_TEST_ID); + assertNull("There should be no test extendedTypes yet", path); + + registerLocalRedefinition(EXTENDED_TYPES_TEST_ID, "testAdd.xml"); + + int newLength = initialLength + 1; + XMLMemento newMemento = getLocalRedefinitions(); + IMemento[] newPaletteRedefinitions = newMemento.getChildren(EXTENDED_TYPES_REDEFINITION); + assertTrue("There should be " + newLength + " elements, currently " + newPaletteRedefinitions.length, newLength == newPaletteRedefinitions.length); + String newPath = getExtendedTypesRedefinition(EXTENDED_TYPES_TEST_ID); + assertEquals("There should be a new path for the extendedTypes id", "testAdd.xml", newPath); + + // 3. test remove + unregisterLocalRedefinition(EXTENDED_TYPES_TEST_ID); + newMemento = getLocalRedefinitions(); + newPaletteRedefinitions = newMemento.getChildren(EXTENDED_TYPES_REDEFINITION); + assertTrue("There should be " + newLength + " elements", newPaletteRedefinitions.length == initialLength); + newPath = getExtendedTypesRedefinition(EXTENDED_TYPES_TEST_ID); + assertNull("There should be no path for the extendedTypes id", newPath); + + } +} -- cgit v1.2.3