diff options
author | Christian W. Damus | 2014-02-17 15:24:18 +0000 |
---|---|---|
committer | Christian W. Damus | 2014-02-17 15:24:18 +0000 |
commit | fabfcd1ea165f9240a7717137fc3d354b1e36922 (patch) | |
tree | dba2c40dae1764dc29f18b9f608a48069920d183 /tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra | |
parent | 2deb3d461ab42c1770909276362ad2c24c8d2e13 (diff) | |
parent | 2979cdeec7dc2095c030aa58753afc1db9c54ce4 (diff) | |
download | org.eclipse.papyrus-fabfcd1ea165f9240a7717137fc3d354b1e36922.tar.gz org.eclipse.papyrus-fabfcd1ea165f9240a7717137fc3d354b1e36922.tar.xz org.eclipse.papyrus-fabfcd1ea165f9240a7717137fc3d354b1e36922.zip |
Merge branch 'refs/heads/master' into bugs/402525-widgets
Conflicts:
tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF
tests/junit/plugins/core/org.eclipse.papyrus.tests/test/org/eclipse/papyrus/tests/AllTests.java
Diffstat (limited to 'tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra')
9 files changed, 526 insertions, 530 deletions
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedEditHelperAdviceTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedEditHelperAdviceTests.java deleted file mode 100644 index 2e1300cb9f6..00000000000 --- a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedEditHelperAdviceTests.java +++ /dev/null @@ -1,218 +0,0 @@ -/*****************************************************************************
- * 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.infra.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.papyrus.infra.extendedtypes.ExtendedEditHelperAdvice;
-import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration;
-import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet;
-import org.eclipse.papyrus.infra.extendedtypes.ExtendedTypesRegistry;
-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.infra.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.infra.extendedtypes.ExtendedEditHelperAdvice#ExtendedEditHelperAdvice(org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration)}
- * .
- */
- @Test
- public final void testExtendedEditHelperAdvice() {
- assertNotNull("edit helper advice should not be null", extendedClass1EditHelperAdvice);
- }
-
- /**
- * Test method for
- * {@link org.eclipse.papyrus.infra.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.infra.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.infra.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/infra/extendedtypes/ExtendedTypesRegistryTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedTypesRegistryTests.java deleted file mode 100644 index 1bc78e0d106..00000000000 --- a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedTypesRegistryTests.java +++ /dev/null @@ -1,128 +0,0 @@ -/*****************************************************************************
- * 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.infra.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.infra.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.infra.extendedtypes.ExtendedTypesRegistry#loadExtendedTypeSets()}.
- */
- @Test
- public final void testLoadExtendedTypeSets() {
- List<ExtendedElementTypeSet> 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.infra.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.infra.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.infra.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/infra/extendedtypes/ITestConstants.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/ITestConstants.java deleted file mode 100644 index 5a12b52ceb7..00000000000 --- a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/ITestConstants.java +++ /dev/null @@ -1,53 +0,0 @@ -/*****************************************************************************
- * 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.infra.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.infra.extendedtypes.tests.Class1";
-
- /** element type id for test1::ClassInPackage */
- public static final String CLASS_IN_PACKAGE_TEST_TYPE_ID = "org.eclipse.papyrus.infra.extendedtypes.tests.ClassInPackageOnly";
-
- /** element type id for test1::ClassInModel */
- public static final String CLASS_IN_MODEL_TEST_TYPE_ID = "org.eclipse.papyrus.infra.extendedtypes.tests.ClassInModelOnly";
-
-
- /** name of the extended type set in Test1 */
- public final static String ExtendedTypeSetName_Test1 = "org.eclipse.papyrus.infra.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.infra.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.infra.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/infra/extendedtypes/preferences/ExtendedTypesPreferencesTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/preferences/ExtendedTypesPreferencesTests.java deleted file mode 100644 index e8f25397ccf..00000000000 --- a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/preferences/ExtendedTypesPreferencesTests.java +++ /dev/null @@ -1,104 +0,0 @@ -/*****************************************************************************
- * 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.infra.extendedtypes.preferences;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.papyrus.infra.extendedtypes.preferences.ExtendedTypesPreferences;
-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);
-
- }
-}
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/tests/Activator.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/tests/Activator.java new file mode 100644 index 00000000000..6c7df711a20 --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/tests/Activator.java @@ -0,0 +1,50 @@ +package org.eclipse.papyrus.infra.extendedtypes.tests; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.extendedtypes.tests"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/AllTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/tests/AllTests.java index 00b90d48b4b..d29666206a8 100644 --- a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/AllTests.java +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/tests/AllTests.java @@ -1,27 +1,26 @@ -/*****************************************************************************
- * 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.infra.extendedtypes;
-
-import org.eclipse.papyrus.infra.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 {
-
-}
+/***************************************************************************** + * 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.infra.extendedtypes.tests; + +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, }) +public class AllTests { + +} diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/tests/ExtendedEditHelperAdviceTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/tests/ExtendedEditHelperAdviceTests.java new file mode 100644 index 00000000000..382c670411e --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/tests/ExtendedEditHelperAdviceTests.java @@ -0,0 +1,200 @@ +/***************************************************************************** + * 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.infra.extendedtypes.tests; + + + +/** + * 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.infra.extendedtypes.tests.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.infra.extendedtypes.tests.ExtendedEditHelperAdvice#ExtendedEditHelperAdvice(org.eclipse.papyrus.infra.extendedtypes.tests.ExtendedElementTypeConfiguration)} +// * . +// */ +// @Test +// public final void testExtendedEditHelperAdvice() { +// assertNotNull("edit helper advice should not be null", extendedClass1EditHelperAdvice); +// } +// +// /** +// * Test method for +// * {@link org.eclipse.papyrus.infra.extendedtypes.tests.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.infra.extendedtypes.tests.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.infra.extendedtypes.tests.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/infra/extendedtypes/tests/ExtendedTypesRegistryTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/tests/ExtendedTypesRegistryTests.java new file mode 100644 index 00000000000..8e9d00df06c --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/tests/ExtendedTypesRegistryTests.java @@ -0,0 +1,225 @@ +/***************************************************************************** + * 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.infra.extendedtypes.tests; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.ModelUtils; +import org.eclipse.papyrus.infra.core.resource.NotFoundException; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSetRegistry; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedTypeRegistryService; +import org.eclipse.papyrus.junit.utils.EditorUtils; +import org.eclipse.papyrus.junit.utils.PapyrusProjectUtils; +import org.eclipse.papyrus.junit.utils.ProjectUtils; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.papyrus.uml.tools.model.UmlUtils; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.PartInitException; +import org.eclipse.uml2.uml.Activity; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Model; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Tests for {@link ExtendedTypesRegistry} + */ +public class ExtendedTypesRegistryTests implements ITestConstants { + + private static IProject createProject; + + private static IFile copyPapyrusModel; + + private static IMultiDiagramEditor openPapyrusEditor; + + private static ModelSet modelset; + + private static UmlModel umlIModel; + + private static Model rootModel; + + private static Activity testActivity; + + private static TransactionalEditingDomain transactionalEditingDomain; + + private static Class testClass; + + private static Activity testActivityWithNode; + + /** + * Init test class + */ + @BeforeClass + public static void initCreateElementTest() { + + // create Project + try { + createProject = ProjectUtils.createProject("ExtendedTypes"); + } catch (CoreException e) { + fail(e.getMessage()); + } + + // import test model + try { + copyPapyrusModel = PapyrusProjectUtils.copyPapyrusModel(createProject, Platform.getBundle("org.eclipse.papyrus.infra.extendedtypes.tests"), "/model/", "model"); + } catch (CoreException e) { + fail(e.getMessage()); + } catch (IOException e) { + fail(e.getMessage()); + } + + // open project + Display.getDefault().syncExec(new Runnable() { + + public void run() { + try { + openPapyrusEditor = EditorUtils.openPapyrusEditor(copyPapyrusModel); + } catch (PartInitException e) { + fail(e.getMessage()); + } + } + }); + + transactionalEditingDomain = (TransactionalEditingDomain)openPapyrusEditor.getAdapter(TransactionalEditingDomain.class); + assertTrue("Impossible to init editing domain", transactionalEditingDomain instanceof TransactionalEditingDomain); + + // retrieve UML model from this editor + try { + modelset = ModelUtils.getModelSetChecked(openPapyrusEditor.getServicesRegistry()); + umlIModel = UmlUtils.getUmlModel(modelset); + rootModel = (Model)umlIModel.lookupRoot(); + + Assert.assertNotNull("root model should not be null", rootModel); + + } catch (ServiceException e) { + fail(e.getMessage()); + } catch (NotFoundException e) { + fail(e.getMessage()); + } catch (ClassCastException e) { + fail(e.getMessage()); + } + try { + initExistingElements(); + } catch (Exception e) { + fail(e.getMessage()); + } + + } + + /** + * Init fields corresponding to element in the test model + */ + private static void initExistingElements() 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 ExtendedElementTypeSetRegistry#getInstance()} + */ + @Test + @Ignore + public final void testGetInstance() { + ExtendedTypeRegistryService service = null; + try { + service = openPapyrusEditor.getServicesRegistry().getService(ExtendedTypeRegistryService.class); + } catch (ServiceException e) { + fail(e.getMessage()); + } + Assert.assertNotNull("Extended type service should not be null", service); + + // retrieve registry from this service + Assert.assertNotNull("Extended type registry singleton should not be null", service.getExtendedElementTypeSetRegistry()); + } + + + /** + * Test method for {@link org.eclipse.papyrus.infra.extendedtypes.tests.ExtendedTypesRegistry#createResourceSet()}. + */ + @Test + @Ignore + public final void testGetTypeRegisteredInplugin() { + // check standard class + IElementType classType = ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Class"); + Assert.assertNotNull("Element type should be registered", classType); + + IElementType restrictedClassType = ElementTypeRegistry.getInstance().getType(CLASS_ONLY_IN_MODEL_ID); + Assert.assertNotNull("Element type should be registered", restrictedClassType); + } + +// /** +// * Test method for {@link org.eclipse.papyrus.infra.extendedtypes.tests.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.infra.extendedtypes.tests.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/infra/extendedtypes/tests/ITestConstants.java b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/tests/ITestConstants.java new file mode 100644 index 00000000000..fbdc4c829ab --- /dev/null +++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/src/org/eclipse/papyrus/infra/extendedtypes/tests/ITestConstants.java @@ -0,0 +1,25 @@ +/***************************************************************************** + * 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.infra.extendedtypes.tests; + + +/** + * Constants for test classes + */ +public interface ITestConstants { + + public final static String CLASS_ONLY_IN_MODEL_ID = "org.eclipse.papyrus.infra.extendedtypes.tests.classonlyinmodel"; //$NON-NLS-1$ + /** name of the extended type set in Test1 */ + public final static String ExtendedTypeSetName_Test1 = "org.eclipse.papyrus.infra.extendedtypes.tests.tests.test1"; + + +} |