diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo')
43 files changed, 6722 insertions, 6722 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnEMFTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnEMFTest.java index 2318382482..61a55ba4b5 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnEMFTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnEMFTest.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests; - -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnEMFEditorBot; - -/** - * @author Martin Fluegge - */ -public abstract class AbstractDawnEMFTest extends AbstractDawnUITest<DawnEMFEditorBot> -{ - @Override - protected void createBot() - { - setBot(new DawnEMFEditorBot()); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests;
+
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnEMFEditorBot;
+
+/**
+ * @author Martin Fluegge
+ */
+public abstract class AbstractDawnEMFTest extends AbstractDawnUITest<DawnEMFEditorBot>
+{
+ @Override
+ protected void createBot()
+ {
+ setBot(new DawnEMFEditorBot());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnGEFTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnGEFTest.java index 072e02ffdb..5c91e6b751 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnGEFTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnGEFTest.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests; - -import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot; - -/** - * @author Martin Fluegge - */ -public abstract class AbstractDawnGEFTest extends AbstractDawnUITest<SWTGefBot> -{ - @Override - protected void createBot() - { - setBot(new SWTGefBot()); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests;
+
+import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
+
+/**
+ * @author Martin Fluegge
+ */
+public abstract class AbstractDawnGEFTest extends AbstractDawnUITest<SWTGefBot>
+{
+ @Override
+ protected void createBot()
+ {
+ setBot(new SWTGefBot());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnTest.java index aac5043657..12f5c96fae 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnTest.java @@ -1,91 +1,91 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests; - -import org.eclipse.emf.cdo.dawn.resources.impl.DawnResourceFactoryImpl; -import org.eclipse.emf.cdo.dawn.tests.common.GMFTest; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.AbstractCDOTest; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.util.CommitException; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EPackage; -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.EcoreUtil; -import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; - -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.NotationPackage; - -import java.net.URL; - -/** - * @author Martin Fluegge - */ -public abstract class AbstractDawnTest extends AbstractCDOTest -{ - @Override - public void setUp() throws Exception - { - super.setUp(); - } - - protected ResourceSet createResourceSet() - { - ResourceSet dawnResourceSet = new ResourceSetImpl(); - dawnResourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("dawn", new DawnResourceFactoryImpl()); - return dawnResourceSet; - } - - protected void createCDOResourcesFromXMI(String resourceName, EPackage ePackage, CDOSession session) - throws CommitException - { - NotationPackage.eINSTANCE.getClass(); - String packageName = ePackage.getName(); - ResourceSet resourceSet = new ResourceSetImpl(); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() - .put(packageName + "_diagram", new XMIResourceFactoryImpl()); - - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(packageName, new XMIResourceFactoryImpl()); - - URL resourceURI = GMFTest.class.getResource(""); - String resourcePath = resourceURI.toString().substring(0, resourceURI.toString().lastIndexOf("/bin")); - - Resource emfResource = resourceSet.getResource( - URI.createURI(resourcePath + "/testdata/" + resourceName + "." + packageName), true); - Resource gmfResource = resourceSet.getResource( - URI.createURI(resourcePath + "/testdata/" + resourceName + "." + packageName + "_diagram"), true); - - EcoreUtil.resolveAll(emfResource); - EcoreUtil.resolveAll(gmfResource); - - Diagram notationalRoot = (Diagram)gmfResource.getContents().get(0); - - ResourceSet dawnResourceSet = new ResourceSetImpl(); - dawnResourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("dawn", new DawnResourceFactoryImpl()); - - CDOTransaction transaction = session.openTransaction(dawnResourceSet); - - CDOResource semanticResource = transaction.createResource("/" + resourceName + "." + packageName); - - URI createURI = URI.createURI("dawn://repo1/" + resourceName + "." + packageName + "_diagram"); - Resource notationalResource = dawnResourceSet.createResource(createURI); - - notationalResource.getContents().add(notationalRoot); - semanticResource.getContents().add(emfResource.getContents().get(0)); - transaction.commit(); - transaction.close(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests;
+
+import org.eclipse.emf.cdo.dawn.resources.impl.DawnResourceFactoryImpl;
+import org.eclipse.emf.cdo.dawn.tests.common.GMFTest;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EPackage;
+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.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+
+import java.net.URL;
+
+/**
+ * @author Martin Fluegge
+ */
+public abstract class AbstractDawnTest extends AbstractCDOTest
+{
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected ResourceSet createResourceSet()
+ {
+ ResourceSet dawnResourceSet = new ResourceSetImpl();
+ dawnResourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("dawn", new DawnResourceFactoryImpl());
+ return dawnResourceSet;
+ }
+
+ protected void createCDOResourcesFromXMI(String resourceName, EPackage ePackage, CDOSession session)
+ throws CommitException
+ {
+ NotationPackage.eINSTANCE.getClass();
+ String packageName = ePackage.getName();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
+ .put(packageName + "_diagram", new XMIResourceFactoryImpl());
+
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(packageName, new XMIResourceFactoryImpl());
+
+ URL resourceURI = GMFTest.class.getResource("");
+ String resourcePath = resourceURI.toString().substring(0, resourceURI.toString().lastIndexOf("/bin"));
+
+ Resource emfResource = resourceSet.getResource(
+ URI.createURI(resourcePath + "/testdata/" + resourceName + "." + packageName), true);
+ Resource gmfResource = resourceSet.getResource(
+ URI.createURI(resourcePath + "/testdata/" + resourceName + "." + packageName + "_diagram"), true);
+
+ EcoreUtil.resolveAll(emfResource);
+ EcoreUtil.resolveAll(gmfResource);
+
+ Diagram notationalRoot = (Diagram)gmfResource.getContents().get(0);
+
+ ResourceSet dawnResourceSet = new ResourceSetImpl();
+ dawnResourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("dawn", new DawnResourceFactoryImpl());
+
+ CDOTransaction transaction = session.openTransaction(dawnResourceSet);
+
+ CDOResource semanticResource = transaction.createResource("/" + resourceName + "." + packageName);
+
+ URI createURI = URI.createURI("dawn://repo1/" + resourceName + "." + packageName + "_diagram");
+ Resource notationalResource = dawnResourceSet.createResource(createURI);
+
+ notationalResource.getContents().add(notationalRoot);
+ semanticResource.getContents().add(emfResource.getContents().get(0));
+ transaction.commit();
+ transaction.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnUITest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnUITest.java index 891f89b231..b92d8b96f2 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnUITest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnUITest.java @@ -1,133 +1,133 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests; - -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil; -import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput; -import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.ui.AbstractCDOUITest; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.gmf.runtime.notation.Bounds; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; -import org.eclipse.swtbot.swt.finder.results.VoidResult; -import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - -import org.junit.Before; - -/** - * @author Martin Fluegge - */ -public abstract class AbstractDawnUITest<T extends SWTWorkbenchBot> extends AbstractCDOUITest<T> -{ - @Override - @Before - public void setUp() throws Exception - { - super.setUp(); - SWTBotPreferences.SCREENSHOTS_DIR = DawnTestPlatform.instance.getTestFolder(); - resetWorkbench(); - DawnSWTBotUtil.initTest(getBot()); - - // TODO Remove this line if bug 323788 is solved. - getBot().viewByTitle("CDO Sessions").close(); - } - - /** - * This method opens a DawnDiagramEditor specified by the given URI. It automatically finds the right editor by - * matching the "file extension". - */ - protected void openEditor(final String resourcePath) - { - UIThreadRunnable.syncExec(new VoidResult() - { - public void run() - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource resource = view.getResource(resourcePath); - - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) - { - IWorkbenchPage page = window.getActivePage(); - String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName()); - - try - { - DawnEditorInput editorInput = new DawnEditorInput(resource.getURI()); - - page.openEditor(editorInput, editorID); - } - catch (PartInitException e) - { - e.printStackTrace(); - } - } - } - }); - } - - protected boolean resourceExists(String resourcePath) - { - try - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource resource = view.getResource(resourcePath); - - return resource != null ? true : false; - } - catch (Exception ex) - { - return false; - } - } - - protected void createNode(String type, int xPosition, int yPosition, SWTGefBot bot, SWTBotGefEditor editor) - { - editor.activateTool(type); - editor.click(xPosition, yPosition); - } - - protected void createNodeWithLabel(String type, int xPosition, int yPosition, String labelText, SWTGefBot bot, - SWTBotGefEditor editor) - { - createNode(type, xPosition, yPosition, bot, editor); - typeTextToFocusedWidget(labelText, bot, true); - } - - protected void createEdge(String type, int fromXPosition, int fromYPosition, int toXPosition, int toYPosition, - SWTBotGefEditor editor) - { - editor.activateTool(type); - editor.drag(fromXPosition, fromYPosition, toXPosition, toYPosition); - } - - protected void createEdge(String type, Node nodeFrom, Node nodeTo, SWTBotGefEditor editor) - { - Bounds boundsA = (Bounds)nodeFrom.getLayoutConstraint(); - Bounds boundsB = (Bounds)nodeTo.getLayoutConstraint(); - createEdge(type, boundsA.getX(), boundsA.getY(), boundsB.getX(), boundsB.getY(), editor); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests;
+
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil;
+import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput;
+import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.ui.AbstractCDOUITest;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+import org.junit.Before;
+
+/**
+ * @author Martin Fluegge
+ */
+public abstract class AbstractDawnUITest<T extends SWTWorkbenchBot> extends AbstractCDOUITest<T>
+{
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ SWTBotPreferences.SCREENSHOTS_DIR = DawnTestPlatform.instance.getTestFolder();
+ resetWorkbench();
+ DawnSWTBotUtil.initTest(getBot());
+
+ // TODO Remove this line if bug 323788 is solved.
+ getBot().viewByTitle("CDO Sessions").close();
+ }
+
+ /**
+ * This method opens a DawnDiagramEditor specified by the given URI. It automatically finds the right editor by
+ * matching the "file extension".
+ */
+ protected void openEditor(final String resourcePath)
+ {
+ UIThreadRunnable.syncExec(new VoidResult()
+ {
+ public void run()
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource resource = view.getResource(resourcePath);
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null)
+ {
+ IWorkbenchPage page = window.getActivePage();
+ String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName());
+
+ try
+ {
+ DawnEditorInput editorInput = new DawnEditorInput(resource.getURI());
+
+ page.openEditor(editorInput, editorID);
+ }
+ catch (PartInitException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
+ }
+
+ protected boolean resourceExists(String resourcePath)
+ {
+ try
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource resource = view.getResource(resourcePath);
+
+ return resource != null ? true : false;
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+ }
+
+ protected void createNode(String type, int xPosition, int yPosition, SWTGefBot bot, SWTBotGefEditor editor)
+ {
+ editor.activateTool(type);
+ editor.click(xPosition, yPosition);
+ }
+
+ protected void createNodeWithLabel(String type, int xPosition, int yPosition, String labelText, SWTGefBot bot,
+ SWTBotGefEditor editor)
+ {
+ createNode(type, xPosition, yPosition, bot, editor);
+ typeTextToFocusedWidget(labelText, bot, true);
+ }
+
+ protected void createEdge(String type, int fromXPosition, int fromYPosition, int toXPosition, int toYPosition,
+ SWTBotGefEditor editor)
+ {
+ editor.activateTool(type);
+ editor.drag(fromXPosition, fromYPosition, toXPosition, toYPosition);
+ }
+
+ protected void createEdge(String type, Node nodeFrom, Node nodeTo, SWTBotGefEditor editor)
+ {
+ Bounds boundsA = (Bounds)nodeFrom.getLayoutConstraint();
+ Bounds boundsB = (Bounds)nodeTo.getLayoutConstraint();
+ createEdge(type, boundsA.getX(), boundsA.getY(), boundsB.getX(), boundsB.getY(), editor);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawn.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawn.java index f62e2f516a..9e351fe86f 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawn.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawn.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests; - -import org.eclipse.emf.cdo.dawn.tests.common.DawnCodeGenGMFFragmentTest; -import org.eclipse.emf.cdo.dawn.tests.common.DawnWrapperResourceTest; -import org.eclipse.emf.cdo.dawn.tests.common.GMFTest; -import org.eclipse.emf.cdo.dawn.tests.common.TestFrameworkTest; -import org.eclipse.emf.cdo.tests.AllTests; -import org.eclipse.emf.cdo.tests.config.IScenario; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; - -import java.util.List; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * This test suite should be executed as plain JUnit test. - * - * @author Martin Fluegge - */ -public class AllTestsDawn extends AllTests -{ - public static Test suite() - { - return new AllTestsDawn().getTestSuite(AllTests.class.getName()); - } - - @Override - protected void initConfigSuites(TestSuite parent) - { - addScenario(parent, COMBINED, MEM, JVM, NATIVE); - } - - @Override - protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario) - { - testClasses.add(TestFrameworkTest.class); - testClasses.add(GMFTest.class); - testClasses.add(DawnWrapperResourceTest.class); - testClasses.add(DawnCodeGenGMFFragmentTest.class); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests;
+
+import org.eclipse.emf.cdo.dawn.tests.common.DawnCodeGenGMFFragmentTest;
+import org.eclipse.emf.cdo.dawn.tests.common.DawnWrapperResourceTest;
+import org.eclipse.emf.cdo.dawn.tests.common.GMFTest;
+import org.eclipse.emf.cdo.dawn.tests.common.TestFrameworkTest;
+import org.eclipse.emf.cdo.tests.AllTests;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * This test suite should be executed as plain JUnit test.
+ *
+ * @author Martin Fluegge
+ */
+public class AllTestsDawn extends AllTests
+{
+ public static Test suite()
+ {
+ return new AllTestsDawn().getTestSuite(AllTests.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM, JVM, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ testClasses.add(TestFrameworkTest.class);
+ testClasses.add(GMFTest.class);
+ testClasses.add(DawnWrapperResourceTest.class);
+ testClasses.add(DawnCodeGenGMFFragmentTest.class);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUI.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUI.java index cff21f2213..93065ffb5f 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUI.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUI.java @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests; - -import org.eclipse.emf.cdo.dawn.tests.ui.emf.DawnBasicEMFUITest; -import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnBasicGMFUITest; -import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnCreationWizardTest; -import org.eclipse.emf.cdo.tests.AllTests; -import org.eclipse.emf.cdo.tests.config.IScenario; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; - -import java.util.List; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * This test suite should be executed as JUnit Plug-in test. - * - * @author Martin Fluegge - */ -public class AllTestsDawnUI extends AllTests -{ - public static Test suite() - { - return new AllTestsDawnUI().getTestSuite(AllTests.class.getName()); - } - - @Override - protected void initConfigSuites(TestSuite parent) - { - addScenario(parent, COMBINED, MEM, TCP, NATIVE); - } - - @Override - protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario) - { - testClasses.add(DawnCreationWizardTest.class); - testClasses.add(DawnBasicGMFUITest.class); - testClasses.add(DawnBasicEMFUITest.class); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests;
+
+import org.eclipse.emf.cdo.dawn.tests.ui.emf.DawnBasicEMFUITest;
+import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnBasicGMFUITest;
+import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnCreationWizardTest;
+import org.eclipse.emf.cdo.tests.AllTests;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * This test suite should be executed as JUnit Plug-in test.
+ *
+ * @author Martin Fluegge
+ */
+public class AllTestsDawnUI extends AllTests
+{
+ public static Test suite()
+ {
+ return new AllTestsDawnUI().getTestSuite(AllTests.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM, TCP, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ testClasses.add(DawnCreationWizardTest.class);
+ testClasses.add(DawnBasicGMFUITest.class);
+ testClasses.add(DawnBasicEMFUITest.class);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java index a2f618a9ec..f86b9248f2 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBotEMF.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBotEMF.java index a6fe3fee4c..ece7e56d61 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBotEMF.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBotEMF.java @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests; - -import org.eclipse.emf.cdo.dawn.tests.ui.emf.DawnEMFCreationWizardTest; -import org.eclipse.emf.cdo.dawn.tests.ui.emf.DawnEMFHandleEditorTest; -import org.eclipse.emf.cdo.dawn.tests.ui.emf.EMFEditorRollbackTest; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * This test suite should be executed as SWTBot test. - * - * @author Martin Fluegge - * @formatter:off - */ -@Deprecated -@RunWith(Suite.class) -@SuiteClasses({ - DawnEMFCreationWizardTest.class, - EMFEditorRollbackTest.class, - DawnEMFHandleEditorTest.class - }) - -public class AllTestsDawnUISWTBotEMF -{ -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests;
+
+import org.eclipse.emf.cdo.dawn.tests.ui.emf.DawnEMFCreationWizardTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.emf.DawnEMFHandleEditorTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.emf.EMFEditorRollbackTest;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * This test suite should be executed as SWTBot test.
+ *
+ * @author Martin Fluegge
+ * @formatter:off
+ */
+@Deprecated
+@RunWith(Suite.class)
+@SuiteClasses({
+ DawnEMFCreationWizardTest.class,
+ EMFEditorRollbackTest.class,
+ DawnEMFHandleEditorTest.class
+ })
+
+public class AllTestsDawnUISWTBotEMF
+{
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBotGMF.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBotGMF.java index 778cbe43bb..36bf9da3fb 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBotGMF.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBotGMF.java @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests; - -import org.eclipse.emf.cdo.dawn.tests.bugzillas.Bugzilla_321024_Test; -import org.eclipse.emf.cdo.dawn.tests.ui.DawnPreferencesTest; -import org.eclipse.emf.cdo.dawn.tests.ui.DawnProjectExplorerTest; -import org.eclipse.emf.cdo.dawn.tests.ui.gmf.ConflictTest; -import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnCreationWizardSWTBotTest; -import org.eclipse.emf.cdo.dawn.tests.ui.gmf.MultipleResourcesTest; -import org.eclipse.emf.cdo.dawn.tests.ui.gmf.RollbackTest; -import org.eclipse.emf.cdo.dawn.tests.ui.gmf.SimpleDiagramTest; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * This test suite should be executed as SWTBot test. - * - * @author Martin Fluegge - * @formatter:off - */ -@Deprecated -@RunWith(Suite.class) -@SuiteClasses({ - DawnPreferencesTest.class, - DawnCreationWizardSWTBotTest.class, - SimpleDiagramTest.class, - MultipleResourcesTest.class, - // MultipleResourcesDeletionTest.class, //excluded because of ui freeze - DawnProjectExplorerTest.class, - ConflictTest.class, - RollbackTest.class, - Bugzilla_321024_Test.class - }) - - -public class AllTestsDawnUISWTBotGMF -{ -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests;
+
+import org.eclipse.emf.cdo.dawn.tests.bugzillas.Bugzilla_321024_Test;
+import org.eclipse.emf.cdo.dawn.tests.ui.DawnPreferencesTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.DawnProjectExplorerTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.gmf.ConflictTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnCreationWizardSWTBotTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.gmf.MultipleResourcesTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.gmf.RollbackTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.gmf.SimpleDiagramTest;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * This test suite should be executed as SWTBot test.
+ *
+ * @author Martin Fluegge
+ * @formatter:off
+ */
+@Deprecated
+@RunWith(Suite.class)
+@SuiteClasses({
+ DawnPreferencesTest.class,
+ DawnCreationWizardSWTBotTest.class,
+ SimpleDiagramTest.class,
+ MultipleResourcesTest.class,
+ // MultipleResourcesDeletionTest.class, //excluded because of ui freeze
+ DawnProjectExplorerTest.class,
+ ConflictTest.class,
+ RollbackTest.class,
+ Bugzilla_321024_Test.class
+ })
+
+
+public class AllTestsDawnUISWTBotGMF
+{
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/DawnTestPlatform.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/DawnTestPlatform.java index 74aacebec5..524b8b1512 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/DawnTestPlatform.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/DawnTestPlatform.java @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests; - -import org.eclipse.net4j.util.om.OMPlatform; - -import java.io.File; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.Date; - -/** - * @author Martin Fluegge - */ -public class DawnTestPlatform -{ - public static DawnTestPlatform instance = new DawnTestPlatform(); - - private String tempTestFolder = ""; - - private String resourcesFolderName = "testdata"; - - public DawnTestPlatform() - { - tempTestFolder = OMPlatform.INSTANCE.getProperty("java.io.tmpdir") + "/dawntests/test_" + new Date().getTime(); - } - - public String getTestFolder() - { - return tempTestFolder; - } - - public File getTestResource(String path) throws URISyntaxException - { - File file = new File(getTestResourceURI(path)); - return file; - } - - public java.net.URI getTestResourceURI(String path) throws URISyntaxException - { - String testFolder = getBundlePathForClass(AbstractDawnTest.class); - - String separator = path.startsWith("/") ? "" : "/"; - - java.net.URI uri = new java.net.URI(testFolder + "/" + resourcesFolderName + separator + path); - return uri; - } - - public String getBundlePathForClass(Class<?> clazz) throws URISyntaxException - { - URL resourceURI = clazz.getResource(""); - return resourceURI.toString().substring(0, resourceURI.toString().lastIndexOf("/bin")); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests;
+
+import org.eclipse.net4j.util.om.OMPlatform;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Date;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnTestPlatform
+{
+ public static DawnTestPlatform instance = new DawnTestPlatform();
+
+ private String tempTestFolder = "";
+
+ private String resourcesFolderName = "testdata";
+
+ public DawnTestPlatform()
+ {
+ tempTestFolder = OMPlatform.INSTANCE.getProperty("java.io.tmpdir") + "/dawntests/test_" + new Date().getTime();
+ }
+
+ public String getTestFolder()
+ {
+ return tempTestFolder;
+ }
+
+ public File getTestResource(String path) throws URISyntaxException
+ {
+ File file = new File(getTestResourceURI(path));
+ return file;
+ }
+
+ public java.net.URI getTestResourceURI(String path) throws URISyntaxException
+ {
+ String testFolder = getBundlePathForClass(AbstractDawnTest.class);
+
+ String separator = path.startsWith("/") ? "" : "/";
+
+ java.net.URI uri = new java.net.URI(testFolder + "/" + resourcesFolderName + separator + path);
+ return uri;
+ }
+
+ public String getBundlePathForClass(Class<?> clazz) throws URISyntaxException
+ {
+ URL resourceURI = clazz.getResource("");
+ return resourceURI.toString().substring(0, resourceURI.toString().lastIndexOf("/bin"));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/TCPConfigStarter.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/TCPConfigStarter.java index 8bfa87bfd0..e592d63257 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/TCPConfigStarter.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/TCPConfigStarter.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests; - -import org.eclipse.emf.cdo.tests.AllConfigs; -import org.eclipse.emf.cdo.tests.InitialTest; -import org.eclipse.emf.cdo.tests.config.IScenario; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; - -import java.util.List; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * @author Martin Fluegge - */ -public class TCPConfigStarter extends AllConfigs -{ - public static Test suite() - { - return new TCPConfigStarter().getTestSuite(AllConfigs.class.getName()); - } - - @Override - protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario) - { - testClasses.add(InitialTest.class); - } - - @Override - protected void initConfigSuites(TestSuite parent) - { - addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests;
+
+import org.eclipse.emf.cdo.tests.AllConfigs;
+import org.eclipse.emf.cdo.tests.InitialTest;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Martin Fluegge
+ */
+public class TCPConfigStarter extends AllConfigs
+{
+ public static Test suite()
+ {
+ return new TCPConfigStarter().getTestSuite(AllConfigs.class.getName());
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ testClasses.add(InitialTest.class);
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_321024_Test.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_321024_Test.java index c14c0b188e..2d47e24d8f 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_321024_Test.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_321024_Test.java @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.bugzillas; - -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; - -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; - -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class Bugzilla_321024_Test extends AbstractDawnGEFTest -{ - @Test - public void testCreateNewDawnDiagramEmptySemanticResourceName() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram"); - getBot().button("Next >").click(); - getBot().button("Finish").click(); - - SWTBotGefEditor editor = getBot().gefEditor("default.acore_diagram"); - assertNotNull(editor); - editor.close(); - { - assertEquals(true, resourceExists("/default.acore")); - assertEquals(true, resourceExists("/default.acore_diagram")); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.bugzillas;
+
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class Bugzilla_321024_Test extends AbstractDawnGEFTest
+{
+ @Test
+ public void testCreateNewDawnDiagramEmptySemanticResourceName() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+ getBot().button("Next >").click();
+ getBot().button("Finish").click();
+
+ SWTBotGefEditor editor = getBot().gefEditor("default.acore_diagram");
+ assertNotNull(editor);
+ editor.close();
+ {
+ assertEquals(true, resourceExists("/default.acore"));
+ assertEquals(true, resourceExists("/default.acore_diagram"));
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_333187_Test.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_333187_Test.java index 096cc7e308..c6078c9399 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_333187_Test.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_333187_Test.java @@ -1,695 +1,695 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.bugzillas; - -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnEcoreTestUtil; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EAnnotation; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.impl.EDataTypeImpl; -import org.eclipse.emf.ecore.impl.EEnumImpl; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; - -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.List; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class Bugzilla_333187_Test extends AbstractDawnGEFTest -{ - private static final String DOMAIN_FILE_NAME = "Domain file name: "; - - @Test - public void testCreateNewEcoreToolsDiagram() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_GMF); - getBot().button("Next >").click(); - sleep(1000); - getBot().button("Finish").click(); - SWTBotGefEditor editor = getBot().gefEditor("default"); - assertNotNull(editor); - editor.close(); - { - assertEquals(true, resourceExists("/default.ecore")); - assertEquals(true, resourceExists("/default.ecorediag")); - } - } - - @Test - public void testCreateNewEcoreDiagramWrongResourceName() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_GMF); - getBot().button("Next >").click(); - sleep(6000); - shell = getBot().shell("New Ecore Diagram"); - shell.activate(); - - SWTBotText fileNameLabel = getBot().textWithLabel(DOMAIN_FILE_NAME); - fileNameLabel.setText(""); - - fileNameLabel.setFocus(); - fileNameLabel.typeText("x", 500); - assertEquals(false, getBot().button("Next >").isEnabled()); - getBot().button("Cancel").click(); - } - - @Test - public void testCreateNewEcoreDiagramChangeResourceName() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_GMF); - getBot().button("Next >").click(); - sleep(6000); - shell = getBot().shell("New Ecore Diagram"); - shell.activate(); - - SWTBotText fileNameLabel = getBot().textWithLabel(DOMAIN_FILE_NAME); - fileNameLabel.setText(""); - - fileNameLabel.setFocus(); - fileNameLabel.typeText("default2.ecore", 50); - - assertEquals(true, getBot().button("Finish").isEnabled()); - - getBot().button("Finish").click(); - SWTBotGefEditor editor = getBot().gefEditor("default2"); - assertNotNull(editor); - editor.close(); - { - assertEquals(true, resourceExists("/default2.ecore")); - assertEquals(true, resourceExists("/default2.ecorediag")); - } - } - - @Test - public void testCreateNewEcoreDiagramSetResourceInDialog() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_GMF); - getBot().button("Next >").click(); - - shell = getBot().shell("New Ecore Diagram"); - shell.activate(); - - getBot().button("Browse...").click(); - - // activate the selection window - // shell = getBot().shells()[3]; - // shell.activate(); - - SWTBotText fileNameLabel = getBot().textWithLabel("Resource name:"); - fileNameLabel.setText("test.ecore"); - getBot().button("OK").click(); - - SWTBotText fileSemanticNameLabel = getBot().textWithLabel(DOMAIN_FILE_NAME); - assertEquals("test.ecore", fileSemanticNameLabel.getText()); - - getBot().button("Finish").click(); - - SWTBotGefEditor editor = getBot().gefEditor("test"); - assertNotNull(editor); - editor.close(); - - { - assertEquals(true, resourceExists("/test.ecore")); - assertEquals(true, resourceExists("/test.ecorediag")); - } - } - - @Test - public void testCreateNewEcoreDiagramSetResourceInDialogAndSelectFolder() throws Exception - { - { - CDOSession session = openSession(); - ResourceSet resourceSet = new ResourceSetImpl(); - CDOTransaction transaction = session.openTransaction(resourceSet); - - final URI uri = URI.createURI("cdo:/folder/dummy"); - resourceSet.createResource(uri); - transaction.commit(); - } - - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_GMF); - getBot().button("Next >").click(); - - shell = getBot().shell("New Ecore Diagram"); - shell.activate(); - - getBot().button("Browse...").click(); - - SWTBotTree tree = getBot().tree(0); - selectFolder(tree.getAllItems(), "folder", false); - - SWTBotText fileNameLabel = getBot().textWithLabel("Resource name:"); - fileNameLabel.setText("test.ecore"); - getBot().button("OK").click(); - - SWTBotText resourcePathLabel = getBot().text(0); - assertEquals("cdo://repo1/folder/", resourcePathLabel.getText()); - - SWTBotText fileSemanticNameLabel = getBot().textWithLabel(DOMAIN_FILE_NAME); - assertEquals("test.ecore", fileSemanticNameLabel.getText()); - - getBot().button("Finish").click(); - SWTBotGefEditor editor = getBot().gefEditor("test"); - assertNotNull(editor); - editor.close(); - - { - assertEquals(true, resourceExists("/folder/test.ecore")); - assertEquals(true, resourceExists("/folder/test.ecorediag")); - } - } - - @Test - public void testCreateNewEcoreToolsDiagramAndAddElements() throws Exception - { - SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 250, 100, "B", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 150, 250, "C", getBot(), editor); - - editor.saveAndClose(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.ecorediag"); - CDOResource semanticResource = view.getResource("/default.ecore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - EPackage epackage = (EPackage)semanticResource.getContents().get(0); - - assertEquals(3, diagram.getChildren().size()); - assertEquals(3, epackage.getEClassifiers().size()); - - Character name = 'A'; - - for (EClassifier aClass : epackage.getEClassifiers()) - { - assertEquals(name.toString(), aClass.getName()); - name++; - } - } - } - - @Test - public void testCreateNewDawnDiagramAndAddElementsWithEdges() throws Exception - { - SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 250, 100, "B", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 150, 250, "C", getBot(), editor); - - createEdge(DawnEcoreTestUtil.E_REFERENCE, 100, 100, 250, 100, editor); - createEdge(DawnEcoreTestUtil.E_REFERENCE, 100, 100, 150, 250, editor); - - List<SWTBotGefEditPart> connectionEditParts = DawnEcoreTestUtil.getAllTargetConnections(editor); - - assertEquals(2, connectionEditParts.size()); - - editor.save(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.ecorediag"); - - CDOResource semanticResource = view.getResource("/default.ecore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - EPackage epackage = (EPackage)semanticResource.getContents().get(0); - - assertEquals(3, diagram.getChildren().size()); - assertEquals(3, epackage.getEClassifiers().size()); - - Character name = 'A'; - - for (EClassifier aClass : epackage.getEClassifiers()) - { - assertEquals(name.toString(), aClass.getName()); - name++; - } - view.close(); - } - } - - @Test - public void testEClassChangeName() throws Exception - { - SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor); - - editor.save(); - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource semanticResource = view.getResource("/default.ecore"); - - EPackage epackage = (EPackage)semanticResource.getContents().get(0); - - assertEquals(1, epackage.getEClassifiers().size()); - - EClassifier eClassifier = epackage.getEClassifiers().get(0); - - assertEquals("A", eClassifier.getName()); - - session.close(); - } - - typeTextToFocusedWidget("B", getBot(), true); - editor.save(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource semanticResource = view.getResource("/default.ecore"); - - EPackage epackage = (EPackage)semanticResource.getContents().get(0); - - assertEquals(1, epackage.getEClassifiers().size()); - - EClassifier eClassifier = epackage.getEClassifiers().get(0); - - assertEquals("B", eClassifier.getName()); - - session.close(); - } - } - - @Test - public void testEClassWithEAttributes() throws Exception - { - SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor); - - editor.save(); - - editor.activateTool(DawnEcoreTestUtil.E_ATTRIBUTE); - editor.click(100, 100); - typeTextToFocusedWidget("name", getBot(), true); - editor.save(); - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.ecorediag"); - CDOResource semanticResource = view.getResource("/default.ecore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - - EPackage epackage = (EPackage)semanticResource.getContents().get(0); - - EClass eClass = (EClass)epackage.getEClassifiers().get(0); - - assertEquals("A", eClass.getName()); - EList<EAttribute> eAttributes = eClass.getEAttributes(); - assertEquals(1, eAttributes.size()); - assertEquals("name", eAttributes.get(0).getName()); - } - } - - @Test - public void testEClassWithEOperation() throws Exception - { - SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor); - - editor.save(); - - editor.activateTool(DawnEcoreTestUtil.E_OPERATION); - editor.click(100, 100); - typeTextToFocusedWidget("operation", getBot(), true); - editor.save(); - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource semanticResource = view.getResource("/default.ecore"); - - EPackage epackage = (EPackage)semanticResource.getContents().get(0); - - EClass eClass = (EClass)epackage.getEClassifiers().get(0); - - assertEquals("A", eClass.getName()); - EList<EOperation> eOperations = eClass.getEOperations(); - assertEquals(1, eOperations.size()); - assertEquals("operation", eOperations.get(0).getName()); - } - } - - @Test - public void testDiagramWithInheritance() throws Exception - { - SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 250, 100, "B", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 150, 250, "C", getBot(), editor); - - createEdge(DawnEcoreTestUtil.INHERITANCE, 100, 100, 250, 100, editor); - createEdge(DawnEcoreTestUtil.INHERITANCE, 100, 100, 150, 250, editor); - - List<SWTBotGefEditPart> connectionEditParts = DawnEcoreTestUtil.getAllTargetConnections(editor); - - assertEquals(2, connectionEditParts.size()); - editor.save(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.ecorediag"); - - CDOResource semanticResource = view.getResource("/default.ecore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - EPackage epackage = (EPackage)semanticResource.getContents().get(0); - - assertEquals(3, diagram.getChildren().size()); - assertEquals(3, epackage.getEClassifiers().size()); - - EClass eClass1 = (EClass)epackage.getEClassifiers().get(0); - EClass eClass2 = (EClass)epackage.getEClassifiers().get(1); - EClass eClass3 = (EClass)epackage.getEClassifiers().get(2); - - assertEquals(eClass2, eClass1.getEAllSuperTypes().get(0)); - assertEquals(eClass3, eClass1.getEAllSuperTypes().get(1)); - - view.close(); - } - } - - @Test - public void testEDataType() throws Exception - { - SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnEcoreTestUtil.E_DATATYPE, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_DATATYPE, 250, 100, "B", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_DATATYPE, 150, 250, "C", getBot(), editor); - editor.saveAndClose(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.ecorediag"); - CDOResource semanticResource = view.getResource("/default.ecore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - EPackage epackage = (EPackage)semanticResource.getContents().get(0); - - assertEquals(3, diagram.getChildren().size()); - assertEquals(3, epackage.getEClassifiers().size()); - - Character name = 'A'; - - for (EClassifier eType : epackage.getEClassifiers()) - { - assertEquals(EDataTypeImpl.class, eType.getClass()); - assertEquals(name.toString(), eType.getName()); - name++; - } - } - } - - @Test - public void testEAnnotation() throws Exception - { - SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnEcoreTestUtil.E_ANNOTATION, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_ANNOTATION, 250, 100, "B", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_ANNOTATION, 150, 250, "C", getBot(), editor); - editor.saveAndClose(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.ecorediag"); - CDOResource semanticResource = view.getResource("/default.ecore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - EPackage epackage = (EPackage)semanticResource.getContents().get(0); - - assertEquals(3, diagram.getChildren().size()); - EList<EAnnotation> eAnnotations = epackage.getEAnnotations(); - assertEquals(3, eAnnotations.size()); - - Character name = 'A'; - - for (EAnnotation eAnnotation : eAnnotations) - { - assertEquals(name.toString(), eAnnotation.getSource()); - name++; - } - } - } - - @Test - public void testEENum() throws Exception - { - SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnEcoreTestUtil.E_ENUM, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_ENUM, 250, 100, "B", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_ENUM, 150, 250, "C", getBot(), editor); - editor.saveAndClose(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.ecorediag"); - CDOResource semanticResource = view.getResource("/default.ecore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - EPackage epackage = (EPackage)semanticResource.getContents().get(0); - - assertEquals(3, diagram.getChildren().size()); - assertEquals(3, epackage.getEClassifiers().size()); - - Character name = 'A'; - - for (EClassifier eEnum : epackage.getEClassifiers()) - { - assertEquals(EEnumImpl.class, eEnum.getClass()); - assertEquals(name.toString(), eEnum.getName()); - name++; - } - } - } - - @Test - public void testEPackage() throws Exception - { - SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnEcoreTestUtil.E_PACKAGE, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_PACKAGE, 250, 100, "B", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_PACKAGE, 150, 250, "C", getBot(), editor); - editor.saveAndClose(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.ecorediag"); - CDOResource semanticResource = view.getResource("/default.ecore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - - assertEquals(3, diagram.getChildren().size()); - EList<EObject> contents = semanticResource.getContents(); - assertEquals(1, contents.size()); - - EPackage ePackage = (EPackage)contents.get(0); - Character name = 'A'; - - for (EPackage eSubPackage : ePackage.getESubpackages()) - { - assertEquals(name.toString(), eSubPackage.getName()); - assertEquals(ePackage, eSubPackage.getESuperPackage()); - name++; - } - } - } - - @Test - public void testDiagramWithClassAndEAnnotations() throws Exception - { - SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_ANNOTATION, 250, 100, "B", getBot(), editor); - createNodeWithLabel(DawnEcoreTestUtil.E_ANNOTATION, 150, 250, "C", getBot(), editor); - - createEdge(DawnEcoreTestUtil.E_ANNOTATION_LINK, 250, 100, 100, 100, editor); - createEdge(DawnEcoreTestUtil.E_ANNOTATION_LINK, 150, 250, 100, 100, editor); - - List<SWTBotGefEditPart> connectionEditParts = DawnEcoreTestUtil.getAllTargetConnections(editor); - - assertEquals(2, connectionEditParts.size()); - editor.save(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.ecorediag"); - - CDOResource semanticResource = view.getResource("/default.ecore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - EPackage epackage = (EPackage)semanticResource.getContents().get(0); - - assertEquals(3, diagram.getChildren().size()); - assertEquals(1, epackage.getEClassifiers().size()); - - // EClass eClass1 = (EClass)epackage.getEClassifiers().get(0); - // EList<EAnnotation> eAnnotations = eClass1.getEAnnotations(); - // assertEquals(2, eAnnotations.size()); - // - // Character name = 'B'; - // - // for (EAnnotation annotation : eAnnotations) - // { - // assertEquals(name.toString(), annotation.getSource()); - // assertEquals(eClass1, annotation.getEModelElement()); - // name++; - // } - - view.close(); - } - } - - @Test - public void testEAnnotationWithDetailEntry() throws Exception - { - SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnEcoreTestUtil.E_ANNOTATION, 100, 100, "A", getBot(), editor); - editor.activateTool(DawnEcoreTestUtil.DETAILS_ENTRY); - editor.click(100, 100); - typeTextToFocusedWidget("name", getBot(), true); - editor.save(); - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.ecorediag"); - CDOResource semanticResource = view.getResource("/default.ecore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - - EPackage epackage = (EPackage)semanticResource.getContents().get(0); - - EAnnotation eAnnotation = epackage.getEAnnotations().get(0); - - assertEquals("A", eAnnotation.getSource()); - assertEquals(1, eAnnotation.getDetails().size()); - view.close(); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.bugzillas;
+
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnEcoreTestUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.impl.EDataTypeImpl;
+import org.eclipse.emf.ecore.impl.EEnumImpl;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class Bugzilla_333187_Test extends AbstractDawnGEFTest
+{
+ private static final String DOMAIN_FILE_NAME = "Domain file name: ";
+
+ @Test
+ public void testCreateNewEcoreToolsDiagram() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_GMF);
+ getBot().button("Next >").click();
+ sleep(1000);
+ getBot().button("Finish").click();
+ SWTBotGefEditor editor = getBot().gefEditor("default");
+ assertNotNull(editor);
+ editor.close();
+ {
+ assertEquals(true, resourceExists("/default.ecore"));
+ assertEquals(true, resourceExists("/default.ecorediag"));
+ }
+ }
+
+ @Test
+ public void testCreateNewEcoreDiagramWrongResourceName() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_GMF);
+ getBot().button("Next >").click();
+ sleep(6000);
+ shell = getBot().shell("New Ecore Diagram");
+ shell.activate();
+
+ SWTBotText fileNameLabel = getBot().textWithLabel(DOMAIN_FILE_NAME);
+ fileNameLabel.setText("");
+
+ fileNameLabel.setFocus();
+ fileNameLabel.typeText("x", 500);
+ assertEquals(false, getBot().button("Next >").isEnabled());
+ getBot().button("Cancel").click();
+ }
+
+ @Test
+ public void testCreateNewEcoreDiagramChangeResourceName() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_GMF);
+ getBot().button("Next >").click();
+ sleep(6000);
+ shell = getBot().shell("New Ecore Diagram");
+ shell.activate();
+
+ SWTBotText fileNameLabel = getBot().textWithLabel(DOMAIN_FILE_NAME);
+ fileNameLabel.setText("");
+
+ fileNameLabel.setFocus();
+ fileNameLabel.typeText("default2.ecore", 50);
+
+ assertEquals(true, getBot().button("Finish").isEnabled());
+
+ getBot().button("Finish").click();
+ SWTBotGefEditor editor = getBot().gefEditor("default2");
+ assertNotNull(editor);
+ editor.close();
+ {
+ assertEquals(true, resourceExists("/default2.ecore"));
+ assertEquals(true, resourceExists("/default2.ecorediag"));
+ }
+ }
+
+ @Test
+ public void testCreateNewEcoreDiagramSetResourceInDialog() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_GMF);
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New Ecore Diagram");
+ shell.activate();
+
+ getBot().button("Browse...").click();
+
+ // activate the selection window
+ // shell = getBot().shells()[3];
+ // shell.activate();
+
+ SWTBotText fileNameLabel = getBot().textWithLabel("Resource name:");
+ fileNameLabel.setText("test.ecore");
+ getBot().button("OK").click();
+
+ SWTBotText fileSemanticNameLabel = getBot().textWithLabel(DOMAIN_FILE_NAME);
+ assertEquals("test.ecore", fileSemanticNameLabel.getText());
+
+ getBot().button("Finish").click();
+
+ SWTBotGefEditor editor = getBot().gefEditor("test");
+ assertNotNull(editor);
+ editor.close();
+
+ {
+ assertEquals(true, resourceExists("/test.ecore"));
+ assertEquals(true, resourceExists("/test.ecorediag"));
+ }
+ }
+
+ @Test
+ public void testCreateNewEcoreDiagramSetResourceInDialogAndSelectFolder() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ final URI uri = URI.createURI("cdo:/folder/dummy");
+ resourceSet.createResource(uri);
+ transaction.commit();
+ }
+
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_GMF);
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New Ecore Diagram");
+ shell.activate();
+
+ getBot().button("Browse...").click();
+
+ SWTBotTree tree = getBot().tree(0);
+ selectFolder(tree.getAllItems(), "folder", false);
+
+ SWTBotText fileNameLabel = getBot().textWithLabel("Resource name:");
+ fileNameLabel.setText("test.ecore");
+ getBot().button("OK").click();
+
+ SWTBotText resourcePathLabel = getBot().text(0);
+ assertEquals("cdo://repo1/folder/", resourcePathLabel.getText());
+
+ SWTBotText fileSemanticNameLabel = getBot().textWithLabel(DOMAIN_FILE_NAME);
+ assertEquals("test.ecore", fileSemanticNameLabel.getText());
+
+ getBot().button("Finish").click();
+ SWTBotGefEditor editor = getBot().gefEditor("test");
+ assertNotNull(editor);
+ editor.close();
+
+ {
+ assertEquals(true, resourceExists("/folder/test.ecore"));
+ assertEquals(true, resourceExists("/folder/test.ecorediag"));
+ }
+ }
+
+ @Test
+ public void testCreateNewEcoreToolsDiagramAndAddElements() throws Exception
+ {
+ SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 250, 100, "B", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 150, 250, "C", getBot(), editor);
+
+ editor.saveAndClose();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.ecorediag");
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ EPackage epackage = (EPackage)semanticResource.getContents().get(0);
+
+ assertEquals(3, diagram.getChildren().size());
+ assertEquals(3, epackage.getEClassifiers().size());
+
+ Character name = 'A';
+
+ for (EClassifier aClass : epackage.getEClassifiers())
+ {
+ assertEquals(name.toString(), aClass.getName());
+ name++;
+ }
+ }
+ }
+
+ @Test
+ public void testCreateNewDawnDiagramAndAddElementsWithEdges() throws Exception
+ {
+ SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 250, 100, "B", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 150, 250, "C", getBot(), editor);
+
+ createEdge(DawnEcoreTestUtil.E_REFERENCE, 100, 100, 250, 100, editor);
+ createEdge(DawnEcoreTestUtil.E_REFERENCE, 100, 100, 150, 250, editor);
+
+ List<SWTBotGefEditPart> connectionEditParts = DawnEcoreTestUtil.getAllTargetConnections(editor);
+
+ assertEquals(2, connectionEditParts.size());
+
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.ecorediag");
+
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ EPackage epackage = (EPackage)semanticResource.getContents().get(0);
+
+ assertEquals(3, diagram.getChildren().size());
+ assertEquals(3, epackage.getEClassifiers().size());
+
+ Character name = 'A';
+
+ for (EClassifier aClass : epackage.getEClassifiers())
+ {
+ assertEquals(name.toString(), aClass.getName());
+ name++;
+ }
+ view.close();
+ }
+ }
+
+ @Test
+ public void testEClassChangeName() throws Exception
+ {
+ SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor);
+
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ EPackage epackage = (EPackage)semanticResource.getContents().get(0);
+
+ assertEquals(1, epackage.getEClassifiers().size());
+
+ EClassifier eClassifier = epackage.getEClassifiers().get(0);
+
+ assertEquals("A", eClassifier.getName());
+
+ session.close();
+ }
+
+ typeTextToFocusedWidget("B", getBot(), true);
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ EPackage epackage = (EPackage)semanticResource.getContents().get(0);
+
+ assertEquals(1, epackage.getEClassifiers().size());
+
+ EClassifier eClassifier = epackage.getEClassifiers().get(0);
+
+ assertEquals("B", eClassifier.getName());
+
+ session.close();
+ }
+ }
+
+ @Test
+ public void testEClassWithEAttributes() throws Exception
+ {
+ SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor);
+
+ editor.save();
+
+ editor.activateTool(DawnEcoreTestUtil.E_ATTRIBUTE);
+ editor.click(100, 100);
+ typeTextToFocusedWidget("name", getBot(), true);
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.ecorediag");
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+
+ EPackage epackage = (EPackage)semanticResource.getContents().get(0);
+
+ EClass eClass = (EClass)epackage.getEClassifiers().get(0);
+
+ assertEquals("A", eClass.getName());
+ EList<EAttribute> eAttributes = eClass.getEAttributes();
+ assertEquals(1, eAttributes.size());
+ assertEquals("name", eAttributes.get(0).getName());
+ }
+ }
+
+ @Test
+ public void testEClassWithEOperation() throws Exception
+ {
+ SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor);
+
+ editor.save();
+
+ editor.activateTool(DawnEcoreTestUtil.E_OPERATION);
+ editor.click(100, 100);
+ typeTextToFocusedWidget("operation", getBot(), true);
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ EPackage epackage = (EPackage)semanticResource.getContents().get(0);
+
+ EClass eClass = (EClass)epackage.getEClassifiers().get(0);
+
+ assertEquals("A", eClass.getName());
+ EList<EOperation> eOperations = eClass.getEOperations();
+ assertEquals(1, eOperations.size());
+ assertEquals("operation", eOperations.get(0).getName());
+ }
+ }
+
+ @Test
+ public void testDiagramWithInheritance() throws Exception
+ {
+ SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 250, 100, "B", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 150, 250, "C", getBot(), editor);
+
+ createEdge(DawnEcoreTestUtil.INHERITANCE, 100, 100, 250, 100, editor);
+ createEdge(DawnEcoreTestUtil.INHERITANCE, 100, 100, 150, 250, editor);
+
+ List<SWTBotGefEditPart> connectionEditParts = DawnEcoreTestUtil.getAllTargetConnections(editor);
+
+ assertEquals(2, connectionEditParts.size());
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.ecorediag");
+
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ EPackage epackage = (EPackage)semanticResource.getContents().get(0);
+
+ assertEquals(3, diagram.getChildren().size());
+ assertEquals(3, epackage.getEClassifiers().size());
+
+ EClass eClass1 = (EClass)epackage.getEClassifiers().get(0);
+ EClass eClass2 = (EClass)epackage.getEClassifiers().get(1);
+ EClass eClass3 = (EClass)epackage.getEClassifiers().get(2);
+
+ assertEquals(eClass2, eClass1.getEAllSuperTypes().get(0));
+ assertEquals(eClass3, eClass1.getEAllSuperTypes().get(1));
+
+ view.close();
+ }
+ }
+
+ @Test
+ public void testEDataType() throws Exception
+ {
+ SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnEcoreTestUtil.E_DATATYPE, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_DATATYPE, 250, 100, "B", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_DATATYPE, 150, 250, "C", getBot(), editor);
+ editor.saveAndClose();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.ecorediag");
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ EPackage epackage = (EPackage)semanticResource.getContents().get(0);
+
+ assertEquals(3, diagram.getChildren().size());
+ assertEquals(3, epackage.getEClassifiers().size());
+
+ Character name = 'A';
+
+ for (EClassifier eType : epackage.getEClassifiers())
+ {
+ assertEquals(EDataTypeImpl.class, eType.getClass());
+ assertEquals(name.toString(), eType.getName());
+ name++;
+ }
+ }
+ }
+
+ @Test
+ public void testEAnnotation() throws Exception
+ {
+ SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnEcoreTestUtil.E_ANNOTATION, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_ANNOTATION, 250, 100, "B", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_ANNOTATION, 150, 250, "C", getBot(), editor);
+ editor.saveAndClose();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.ecorediag");
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ EPackage epackage = (EPackage)semanticResource.getContents().get(0);
+
+ assertEquals(3, diagram.getChildren().size());
+ EList<EAnnotation> eAnnotations = epackage.getEAnnotations();
+ assertEquals(3, eAnnotations.size());
+
+ Character name = 'A';
+
+ for (EAnnotation eAnnotation : eAnnotations)
+ {
+ assertEquals(name.toString(), eAnnotation.getSource());
+ name++;
+ }
+ }
+ }
+
+ @Test
+ public void testEENum() throws Exception
+ {
+ SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnEcoreTestUtil.E_ENUM, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_ENUM, 250, 100, "B", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_ENUM, 150, 250, "C", getBot(), editor);
+ editor.saveAndClose();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.ecorediag");
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ EPackage epackage = (EPackage)semanticResource.getContents().get(0);
+
+ assertEquals(3, diagram.getChildren().size());
+ assertEquals(3, epackage.getEClassifiers().size());
+
+ Character name = 'A';
+
+ for (EClassifier eEnum : epackage.getEClassifiers())
+ {
+ assertEquals(EEnumImpl.class, eEnum.getClass());
+ assertEquals(name.toString(), eEnum.getName());
+ name++;
+ }
+ }
+ }
+
+ @Test
+ public void testEPackage() throws Exception
+ {
+ SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnEcoreTestUtil.E_PACKAGE, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_PACKAGE, 250, 100, "B", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_PACKAGE, 150, 250, "C", getBot(), editor);
+ editor.saveAndClose();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.ecorediag");
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+
+ assertEquals(3, diagram.getChildren().size());
+ EList<EObject> contents = semanticResource.getContents();
+ assertEquals(1, contents.size());
+
+ EPackage ePackage = (EPackage)contents.get(0);
+ Character name = 'A';
+
+ for (EPackage eSubPackage : ePackage.getESubpackages())
+ {
+ assertEquals(name.toString(), eSubPackage.getName());
+ assertEquals(ePackage, eSubPackage.getESuperPackage());
+ name++;
+ }
+ }
+ }
+
+ @Test
+ public void testDiagramWithClassAndEAnnotations() throws Exception
+ {
+ SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnEcoreTestUtil.E_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_ANNOTATION, 250, 100, "B", getBot(), editor);
+ createNodeWithLabel(DawnEcoreTestUtil.E_ANNOTATION, 150, 250, "C", getBot(), editor);
+
+ createEdge(DawnEcoreTestUtil.E_ANNOTATION_LINK, 250, 100, 100, 100, editor);
+ createEdge(DawnEcoreTestUtil.E_ANNOTATION_LINK, 150, 250, 100, 100, editor);
+
+ List<SWTBotGefEditPart> connectionEditParts = DawnEcoreTestUtil.getAllTargetConnections(editor);
+
+ assertEquals(2, connectionEditParts.size());
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.ecorediag");
+
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ EPackage epackage = (EPackage)semanticResource.getContents().get(0);
+
+ assertEquals(3, diagram.getChildren().size());
+ assertEquals(1, epackage.getEClassifiers().size());
+
+ // EClass eClass1 = (EClass)epackage.getEClassifiers().get(0);
+ // EList<EAnnotation> eAnnotations = eClass1.getEAnnotations();
+ // assertEquals(2, eAnnotations.size());
+ //
+ // Character name = 'B';
+ //
+ // for (EAnnotation annotation : eAnnotations)
+ // {
+ // assertEquals(name.toString(), annotation.getSource());
+ // assertEquals(eClass1, annotation.getEModelElement());
+ // name++;
+ // }
+
+ view.close();
+ }
+ }
+
+ @Test
+ public void testEAnnotationWithDetailEntry() throws Exception
+ {
+ SWTBotGefEditor editor = DawnEcoreTestUtil.openNewEcoreToolsEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnEcoreTestUtil.E_ANNOTATION, 100, 100, "A", getBot(), editor);
+ editor.activateTool(DawnEcoreTestUtil.DETAILS_ENTRY);
+ editor.click(100, 100);
+ typeTextToFocusedWidget("name", getBot(), true);
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.ecorediag");
+ CDOResource semanticResource = view.getResource("/default.ecore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+
+ EPackage epackage = (EPackage)semanticResource.getContents().get(0);
+
+ EAnnotation eAnnotation = epackage.getEAnnotations().get(0);
+
+ assertEquals("A", eAnnotation.getSource());
+ assertEquals(1, eAnnotation.getDetails().size());
+ view.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_333291_Test.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_333291_Test.java index a1dd84e5bf..7df8df686e 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_333291_Test.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_333291_Test.java @@ -1,142 +1,142 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.bugzillas; - -import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnEMFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnEMFEditorBot; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnEcoreTestUtil; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotEMFEditor; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil; -import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcoreFactory; - -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; - -import org.junit.Before; -import org.junit.runner.RunWith; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class Bugzilla_333291_Test extends AbstractDawnEMFTest -{ - @Override - @Before - public void setUp() throws Exception - { - setBot(new DawnEMFEditorBot()); - DawnSWTBotUtil.initTest(getBot()); - super.setUp(); - } - - public void testCreateNewDawnEcoreEditor() throws Exception - { - SWTBotEditor editor = DawnEcoreTestUtil.openNewEcoreEMFEditor("default.ecore", getBot()); - assertNotNull(editor); - editor.close(); - { - assertEquals(true, resourceExists("/default.ecore")); - } - } - - public void testOpenExistingResource() throws Exception - { - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource = transaction.createResource("/default.ecore"); - EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage(); - ePackage.setName("myPackage"); - ePackage.setNsPrefix("prefix"); - ePackage.setNsURI("http://testURI/2010"); - resource.getContents().add(ePackage); - - EClass aClass = EcoreFactory.eINSTANCE.createEClass(); - aClass.setName("MyClass"); - - ePackage.getEClassifiers().add(aClass); - - transaction.commit(); - transaction.close(); - session.close(); - } - - CDOConnectionUtil.instance.init(PreferenceConstants.getRepositoryName(), PreferenceConstants.getProtocol(), - PreferenceConstants.getServerName()); - CDOConnectionUtil.instance.openSession(); - DawnSWTBotEMFEditor editor = DawnEcoreTestUtil.openEcoreEMFEditor(URI.createURI("cdo://repo1/default.ecore"), - getBot()); - assertNotNull(editor); - SWTBotTree tree = editor.getSelectionPageTree(); - - sleep(1000); - - SWTBotTreeItem treeItem = tree.getTreeItem("cdo://repo1/default.ecore"); - treeItem.expand(); - - SWTBotTreeItem root = treeItem.getItems()[0]; - assertEquals("myPackage", root.getText()); - root.expand(); - - SWTBotTreeItem swtBotTreeItem1 = root.getItems()[0]; - assertEquals("MyClass", swtBotTreeItem1.getText()); - - editor.save(); - - editor.close(); - } - - public void testCreateNewPackage() throws Exception - { - DawnSWTBotEMFEditor editor = DawnEcoreTestUtil.openNewEcoreEMFEditor("default.ecore", getBot()); - assertNotNull(editor); - - SWTBotTree tree = editor.getSelectionPageTree(); - - selectFolder(tree.getAllItems(), "", true); - - editor.clickContextMenu(tree.widget, "EClass"); - editor.clickContextMenu(tree.widget, "EData Type"); - editor.clickContextMenu(tree.widget, "EAnnotation"); - editor.clickContextMenu(tree.widget, "EPackage"); - editor.save(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - CDOResource resource = view.getResource("/default.ecore"); - EPackage ePackage = (EPackage)resource.getContents().get(0); - - assertEquals(2, ePackage.getEClassifiers().size()); - assertEquals(1, ePackage.getESubpackages().size()); - } - - editor.close(); - { - assertEquals(true, resourceExists("/default.ecore")); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.bugzillas;
+
+import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnEMFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnEMFEditorBot;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnEcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotEMFEditor;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil;
+import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class Bugzilla_333291_Test extends AbstractDawnEMFTest
+{
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ setBot(new DawnEMFEditorBot());
+ DawnSWTBotUtil.initTest(getBot());
+ super.setUp();
+ }
+
+ public void testCreateNewDawnEcoreEditor() throws Exception
+ {
+ SWTBotEditor editor = DawnEcoreTestUtil.openNewEcoreEMFEditor("default.ecore", getBot());
+ assertNotNull(editor);
+ editor.close();
+ {
+ assertEquals(true, resourceExists("/default.ecore"));
+ }
+ }
+
+ public void testOpenExistingResource() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/default.ecore");
+ EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
+ ePackage.setName("myPackage");
+ ePackage.setNsPrefix("prefix");
+ ePackage.setNsURI("http://testURI/2010");
+ resource.getContents().add(ePackage);
+
+ EClass aClass = EcoreFactory.eINSTANCE.createEClass();
+ aClass.setName("MyClass");
+
+ ePackage.getEClassifiers().add(aClass);
+
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+
+ CDOConnectionUtil.instance.init(PreferenceConstants.getRepositoryName(), PreferenceConstants.getProtocol(),
+ PreferenceConstants.getServerName());
+ CDOConnectionUtil.instance.openSession();
+ DawnSWTBotEMFEditor editor = DawnEcoreTestUtil.openEcoreEMFEditor(URI.createURI("cdo://repo1/default.ecore"),
+ getBot());
+ assertNotNull(editor);
+ SWTBotTree tree = editor.getSelectionPageTree();
+
+ sleep(1000);
+
+ SWTBotTreeItem treeItem = tree.getTreeItem("cdo://repo1/default.ecore");
+ treeItem.expand();
+
+ SWTBotTreeItem root = treeItem.getItems()[0];
+ assertEquals("myPackage", root.getText());
+ root.expand();
+
+ SWTBotTreeItem swtBotTreeItem1 = root.getItems()[0];
+ assertEquals("MyClass", swtBotTreeItem1.getText());
+
+ editor.save();
+
+ editor.close();
+ }
+
+ public void testCreateNewPackage() throws Exception
+ {
+ DawnSWTBotEMFEditor editor = DawnEcoreTestUtil.openNewEcoreEMFEditor("default.ecore", getBot());
+ assertNotNull(editor);
+
+ SWTBotTree tree = editor.getSelectionPageTree();
+
+ selectFolder(tree.getAllItems(), "", true);
+
+ editor.clickContextMenu(tree.widget, "EClass");
+ editor.clickContextMenu(tree.widget, "EData Type");
+ editor.clickContextMenu(tree.widget, "EAnnotation");
+ editor.clickContextMenu(tree.widget, "EPackage");
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource("/default.ecore");
+ EPackage ePackage = (EPackage)resource.getContents().get(0);
+
+ assertEquals(2, ePackage.getEClassifiers().size());
+ assertEquals(1, ePackage.getESubpackages().size());
+ }
+
+ editor.close();
+ {
+ assertEquals(true, resourceExists("/default.ecore"));
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_345858_Test.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_345858_Test.java index f64fb55e72..f9b2fa748b 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_345858_Test.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bugzillas/Bugzilla_345858_Test.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.bugzillas; - -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; - -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; - -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class Bugzilla_345858_Test extends AbstractDawnGEFTest -{ - @Test - public void testCreateNewDawnDiagramEmptySemanticResourceName() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default0.acore_diagram", getBot()); - editor.close(); - sleep(1000); - - editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default1.acore_diagram", getBot()); - editor.close(); - sleep(1000); - - editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default2.acore_diagram", getBot()); - editor.close(); - sleep(1000); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.bugzillas;
+
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class Bugzilla_345858_Test extends AbstractDawnGEFTest
+{
+ @Test
+ public void testCreateNewDawnDiagramEmptySemanticResourceName() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default0.acore_diagram", getBot());
+ editor.close();
+ sleep(1000);
+
+ editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default1.acore_diagram", getBot());
+ editor.close();
+ sleep(1000);
+
+ editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default2.acore_diagram", getBot());
+ editor.close();
+ sleep(1000);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bundle/OM.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bundle/OM.java index 76e0a524b2..8d8a35d77c 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bundle/OM.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/bundle/OM.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.bundle; - -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.OMPlatform; -import org.eclipse.net4j.util.om.OSGiActivator; -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.trace.OMTracer; - -/** - * The <em>Operations & Maintenance</em> class of this bundle. - * - * @author Martin Fluegge - */ -public abstract class OM -{ - public static final String BUNDLE_ID = "org.eclipse.emf.cdo.dawn.tests"; //$NON-NLS-1$ - - public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); - - public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ - - public static final OMLogger LOG = BUNDLE.logger(); - - /** - * @author Martin Fluegge - */ - public static final class Activator extends OSGiActivator - { - public Activator() - { - super(BUNDLE); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.bundle;
+
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.OSGiActivator;
+import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.trace.OMTracer;
+
+/**
+ * The <em>Operations & Maintenance</em> class of this bundle.
+ *
+ * @author Martin Fluegge
+ */
+public abstract class OM
+{
+ public static final String BUNDLE_ID = "org.eclipse.emf.cdo.dawn.tests"; //$NON-NLS-1$
+
+ public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
+
+ public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ /**
+ * @author Martin Fluegge
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/DawnCodeGenGMFFragmentTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/DawnCodeGenGMFFragmentTest.java index 07f2aeb42f..e952c45060 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/DawnCodeGenGMFFragmentTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/DawnCodeGenGMFFragmentTest.java @@ -1,167 +1,167 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.common; - -import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.gmf.ui.creators.GMFFragmentCreator; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.DawnAcoreDiagramEditor; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnTest; -import org.eclipse.emf.cdo.dawn.tests.DawnTestPlatform; - -import org.eclipse.emf.mwe.core.WorkflowEngine; -import org.eclipse.emf.mwe.core.monitor.NullProgressMonitor; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.net.URI; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -/** - * @author Martin Fluegge - */ -public class DawnCodeGenGMFFragmentTest extends AbstractDawnTest -{ - public void testCodeGeneration() throws Exception - { - Map<String, ?> slotMap = new HashMap<String, Object>(); - - Map<String, String> properties = new HashMap<String, String>(); - File dawnGenFile = DawnTestPlatform.instance.getTestResource("/model/acore.dawngenmodel"); - - String ouputFolder = DawnTestPlatform.instance.getTestFolder(); - - properties.put("model", dawnGenFile.toURI().toString()); - properties.put("src-gen", ouputFolder); - - String workflowPath = getWorkflowPath("workflow/gmfFragmentGenerator.oaw");// FileLocator.toFileURL(workFlowURL).getFile(); - System.out.println(workflowPath); - - new WorkflowEngine().run(workflowPath, new NullProgressMonitor(), properties, slotMap); - - String outputFolder = DawnTestPlatform.instance.getTestFolder(); - String diagramFolder = ouputFolder + "/" + "src/org/eclipse/emf/cdo/dawn/examples/acore/diagram"; - - assertEquals(true, new File(outputFolder + "/META-INF/MANIFEST.MF").exists()); - assertEquals(true, new File(outputFolder + "/fragment.xml").exists()); - assertEquals(true, new File(outputFolder + "/build.properties").exists()); - - assertEquals(true, new File(diagramFolder + "/edit/").exists()); - assertEquals(true, new File(diagramFolder + "/edit/parts/DawnAcoreEditPartFactory.java").exists()); - assertEquals(true, new File(diagramFolder + "/edit/parts/DawnACoreRootEditPart.java").exists()); - assertEquals(true, new File(diagramFolder + "/edit/policies/DawnACoreRootCanonicalEditPolicy.java").exists()); - - assertEquals(true, new File(diagramFolder + "/part/").exists()); - assertEquals(true, new File(diagramFolder + "/part/DawnAcoreCreationWizard.java").exists()); - assertEquals(true, new File(diagramFolder + "/part/DawnAcoreDiagramEditor.java").exists()); - assertEquals(true, new File(diagramFolder + "/part/DawnAcoreDiagramEditorUtil.java").exists()); - assertEquals(true, new File(diagramFolder + "/part/DawnAcoreDocumentProvider.java").exists()); - - assertEquals(true, new File(diagramFolder + "/providers/").exists()); - assertEquals(true, new File(diagramFolder + "/providers/DawnAcoreEditPartProvider.java").exists()); - assertEquals(true, new File(diagramFolder + "/providers/DawnAcoreEditPolicyProvider.java").exists()); - - basicCompare(new File(new URI(DawnTestPlatform.instance.getBundlePathForClass(DawnAcoreDiagramEditor.class) - + ".dawn/src/")), new File(outputFolder + "/src")); - } - - /** - * check whether the generated folder contains the same files as the reference editor - * - * @throws IOException - */ - private void basicCompare(File reference, File expected) throws IOException - { - if (reference.getName().endsWith("CVS")) - { - return; - } - msg(reference + " <---> " + expected); - assertEquals(true, reference.exists()); - assertEquals(true, expected.exists()); - if (reference.isFile()) - { - // assertEquals(true, FileCompare.compare(reference, expected)); - if (!FileCompare.compare(reference, expected)) - { - fail("not equal: " + reference.getName()); - } - } - else if (reference.isDirectory()) - { - for (File child : reference.listFiles()) - { - basicCompare(child, new File(expected + "/" + child.getName())); - } - } - } - - private String getWorkflowPath(String subPath) - { - URL resource = GMFFragmentCreator.class.getResource(""); - - String packagePath = GMFFragmentCreator.class.getPackage().getName().replace(".", "/"); - System.out.println(packagePath); - String path = resource.toString().replace(packagePath, ""); - return path + subPath; - } - - private static class FileCompare - { - public static boolean compare(File reference, File expected) throws IOException - { - String referenceContent = FileCompare.getContent(reference); - String compareContent = FileCompare.getContent(expected); - - msg("REF.) " + referenceContent); - msg("EXP.) " + compareContent); - - return referenceContent.equals(compareContent); - } - - private static String getContent(File file) throws java.io.IOException - { - StringBuffer buffer = new StringBuffer(); - BufferedReader reader = new BufferedReader(new FileReader(file)); - String line = ""; - - while ((line = reader.readLine()) != null) - { - if (isValid(line.trim())) - { - buffer.append(replaceWhiteSpace(line)); - } - } - - reader.close(); - return buffer.toString(); - } - - private static Object replaceWhiteSpace(String line) - { - return line.replace(" ", "").replace("\t", ""); - } - - private static boolean isValid(String line) - { - if (line.contains("AcoreDiagramEditorPlugin.getInstance().logInfo") || line.equals("") || line.startsWith("*") - || line.equals("import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreDiagramEditorPlugin;") - | line.startsWith("/*") || line.startsWith("//") || line.contains("@")) - { - return false; - } - - return true; - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.common;
+
+import org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.gmf.ui.creators.GMFFragmentCreator;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.DawnAcoreDiagramEditor;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnTest;
+import org.eclipse.emf.cdo.dawn.tests.DawnTestPlatform;
+
+import org.eclipse.emf.mwe.core.WorkflowEngine;
+import org.eclipse.emf.mwe.core.monitor.NullProgressMonitor;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnCodeGenGMFFragmentTest extends AbstractDawnTest
+{
+ public void testCodeGeneration() throws Exception
+ {
+ Map<String, ?> slotMap = new HashMap<String, Object>();
+
+ Map<String, String> properties = new HashMap<String, String>();
+ File dawnGenFile = DawnTestPlatform.instance.getTestResource("/model/acore.dawngenmodel");
+
+ String ouputFolder = DawnTestPlatform.instance.getTestFolder();
+
+ properties.put("model", dawnGenFile.toURI().toString());
+ properties.put("src-gen", ouputFolder);
+
+ String workflowPath = getWorkflowPath("workflow/gmfFragmentGenerator.oaw");// FileLocator.toFileURL(workFlowURL).getFile();
+ System.out.println(workflowPath);
+
+ new WorkflowEngine().run(workflowPath, new NullProgressMonitor(), properties, slotMap);
+
+ String outputFolder = DawnTestPlatform.instance.getTestFolder();
+ String diagramFolder = ouputFolder + "/" + "src/org/eclipse/emf/cdo/dawn/examples/acore/diagram";
+
+ assertEquals(true, new File(outputFolder + "/META-INF/MANIFEST.MF").exists());
+ assertEquals(true, new File(outputFolder + "/fragment.xml").exists());
+ assertEquals(true, new File(outputFolder + "/build.properties").exists());
+
+ assertEquals(true, new File(diagramFolder + "/edit/").exists());
+ assertEquals(true, new File(diagramFolder + "/edit/parts/DawnAcoreEditPartFactory.java").exists());
+ assertEquals(true, new File(diagramFolder + "/edit/parts/DawnACoreRootEditPart.java").exists());
+ assertEquals(true, new File(diagramFolder + "/edit/policies/DawnACoreRootCanonicalEditPolicy.java").exists());
+
+ assertEquals(true, new File(diagramFolder + "/part/").exists());
+ assertEquals(true, new File(diagramFolder + "/part/DawnAcoreCreationWizard.java").exists());
+ assertEquals(true, new File(diagramFolder + "/part/DawnAcoreDiagramEditor.java").exists());
+ assertEquals(true, new File(diagramFolder + "/part/DawnAcoreDiagramEditorUtil.java").exists());
+ assertEquals(true, new File(diagramFolder + "/part/DawnAcoreDocumentProvider.java").exists());
+
+ assertEquals(true, new File(diagramFolder + "/providers/").exists());
+ assertEquals(true, new File(diagramFolder + "/providers/DawnAcoreEditPartProvider.java").exists());
+ assertEquals(true, new File(diagramFolder + "/providers/DawnAcoreEditPolicyProvider.java").exists());
+
+ basicCompare(new File(new URI(DawnTestPlatform.instance.getBundlePathForClass(DawnAcoreDiagramEditor.class)
+ + ".dawn/src/")), new File(outputFolder + "/src"));
+ }
+
+ /**
+ * check whether the generated folder contains the same files as the reference editor
+ *
+ * @throws IOException
+ */
+ private void basicCompare(File reference, File expected) throws IOException
+ {
+ if (reference.getName().endsWith("CVS"))
+ {
+ return;
+ }
+ msg(reference + " <---> " + expected);
+ assertEquals(true, reference.exists());
+ assertEquals(true, expected.exists());
+ if (reference.isFile())
+ {
+ // assertEquals(true, FileCompare.compare(reference, expected));
+ if (!FileCompare.compare(reference, expected))
+ {
+ fail("not equal: " + reference.getName());
+ }
+ }
+ else if (reference.isDirectory())
+ {
+ for (File child : reference.listFiles())
+ {
+ basicCompare(child, new File(expected + "/" + child.getName()));
+ }
+ }
+ }
+
+ private String getWorkflowPath(String subPath)
+ {
+ URL resource = GMFFragmentCreator.class.getResource("");
+
+ String packagePath = GMFFragmentCreator.class.getPackage().getName().replace(".", "/");
+ System.out.println(packagePath);
+ String path = resource.toString().replace(packagePath, "");
+ return path + subPath;
+ }
+
+ private static class FileCompare
+ {
+ public static boolean compare(File reference, File expected) throws IOException
+ {
+ String referenceContent = FileCompare.getContent(reference);
+ String compareContent = FileCompare.getContent(expected);
+
+ msg("REF.) " + referenceContent);
+ msg("EXP.) " + compareContent);
+
+ return referenceContent.equals(compareContent);
+ }
+
+ private static String getContent(File file) throws java.io.IOException
+ {
+ StringBuffer buffer = new StringBuffer();
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ String line = "";
+
+ while ((line = reader.readLine()) != null)
+ {
+ if (isValid(line.trim()))
+ {
+ buffer.append(replaceWhiteSpace(line));
+ }
+ }
+
+ reader.close();
+ return buffer.toString();
+ }
+
+ private static Object replaceWhiteSpace(String line)
+ {
+ return line.replace(" ", "").replace("\t", "");
+ }
+
+ private static boolean isValid(String line)
+ {
+ if (line.contains("AcoreDiagramEditorPlugin.getInstance().logInfo") || line.equals("") || line.startsWith("*")
+ || line.equals("import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreDiagramEditorPlugin;")
+ | line.startsWith("/*") || line.startsWith("//") || line.contains("@"))
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/DawnWrapperResourceTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/DawnWrapperResourceTest.java index 0c5264c6e0..f32edd019b 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/DawnWrapperResourceTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/DawnWrapperResourceTest.java @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.common; - -import org.eclipse.emf.cdo.dawn.resources.DawnWrapperResource; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnTest; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; - -import java.util.Collections; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -public class DawnWrapperResourceTest extends AbstractDawnTest -{ - public void testPostEventTransactionHandler() throws Exception - { - // TransactionalEditingDomain editingDomain = DawnGMFEditingDomainFactory.getInstance().createEditingDomain(); - CDOSession session = openSession(); - - ResourceSet resourceSet = createResourceSet(); - session.openTransaction(resourceSet); - resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("acore_diagram", new XMIResourceImpl()); - - Resource resource = resourceSet.createResource(URI.createURI("dawn://repo1/default10.acore_diagram")); - - assertInstanceOf(DawnWrapperResource.class, resource); - - resource.save(Collections.EMPTY_MAP); - - session.close(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.common;
+
+import org.eclipse.emf.cdo.dawn.resources.DawnWrapperResource;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnTest;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
+
+import java.util.Collections;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+public class DawnWrapperResourceTest extends AbstractDawnTest
+{
+ public void testPostEventTransactionHandler() throws Exception
+ {
+ // TransactionalEditingDomain editingDomain = DawnGMFEditingDomainFactory.getInstance().createEditingDomain();
+ CDOSession session = openSession();
+
+ ResourceSet resourceSet = createResourceSet();
+ session.openTransaction(resourceSet);
+ resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("acore_diagram", new XMIResourceImpl());
+
+ Resource resource = resourceSet.createResource(URI.createURI("dawn://repo1/default10.acore_diagram"));
+
+ assertInstanceOf(DawnWrapperResource.class, resource);
+
+ resource.save(Collections.EMPTY_MAP);
+
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/GMFTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/GMFTest.java index 258e311ceb..194986bd7e 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/GMFTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/GMFTest.java @@ -1,309 +1,309 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.common; - -import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot; -import org.eclipse.emf.cdo.dawn.examples.acore.AcorePackage; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.AbstractCDOTest; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.tests.mango.MangoValue; -import org.eclipse.emf.cdo.transaction.CDOTransaction; - -import org.eclipse.emf.common.util.URI; -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.xmi.impl.XMIResourceFactoryImpl; - -import org.eclipse.gmf.runtime.notation.Bounds; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.Edge; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.gmf.runtime.notation.NotationFactory; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.RelativeBendpoints; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; - -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -public class GMFTest extends AbstractCDOTest -{ - public void testDiagram() throws Exception - { - CDOSession session = openSession(); - { - CDOTransaction transaction = session.openTransaction(); - - CDOResource resource = transaction.createResource("/test1"); - Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); - - diagram.setName("MyDiagram"); - diagram.setVisible(true); - diagram.setMutable(false); - - resource.getContents().add(diagram); - - transaction.commit(); - } - - session.close(); - session = openSession(); - - { - CDOTransaction transaction = session.openTransaction(); - - CDOResource resource = transaction.getResource("/test1"); - - Diagram diagram = (Diagram)resource.getContents().get(0); - - assertEquals("MyDiagram", diagram.getName()); - assertEquals(true, diagram.isVisible()); - assertEquals(false, diagram.isMutable()); - } - } - - public void testSimpleNode() throws Exception - { - CDOSession session = openSession(); - { - CDOTransaction transaction = session.openTransaction(); - - CDOResource resource = transaction.createResource("/test1"); - Node node = createExampleNode(); - MangoValue mangoValue = getMangoFactory().createMangoValue(); - node.setElement(mangoValue); - - resource.getContents().add(node); - resource.getContents().add(mangoValue); - - transaction.commit(); - } - - session.close(); - session = openSession(); - - { - CDOTransaction transaction = session.openTransaction(); - - CDOResource resource = transaction.getResource("/test1"); - - Node node = (Node)resource.getContents().get(0); - - assertEquals(true, node.isVisible()); - assertEquals(false, node.isMutable()); - assertInstanceOf(Bounds.class, node.getLayoutConstraint()); - Bounds bounds = (Bounds)node.getLayoutConstraint(); - assertEquals(1503, bounds.getHeight()); - assertEquals(1979, bounds.getWidth()); - assertEquals(777, bounds.getX()); - assertEquals(888, bounds.getY()); - - assertInstanceOf(MangoValue.class, node.getElement()); - } - } - - private Node createExampleNode() - { - Node node = NotationFactory.eINSTANCE.createNode(); - Bounds bounds = NotationFactory.eINSTANCE.createBounds(); - bounds.setHeight(1503); - bounds.setWidth(1979); - bounds.setX(777); - bounds.setY(888); - - node.setVisible(true); - node.setMutable(false); - node.setLayoutConstraint(bounds); - return node; - } - - public void testSimpleEdge() throws Exception - { - CDOSession session = openSession(); - { - CDOTransaction transaction = session.openTransaction(); - - CDOResource resource = transaction.createResource("/test1"); - Edge edge = createExampleEdge(); - - resource.getContents().add(edge); - transaction.commit(); - } - session.close(); - session = openSession(); - { - CDOTransaction transaction = session.openTransaction(); - - CDOResource resource = transaction.getResource("/test1"); - - Edge edge = (Edge)resource.getContents().get(0); - - assertEquals(true, edge.isVisible()); - assertEquals(false, edge.isMutable()); - - assertEquals(10, ((RelativeBendpoints)edge.getBendpoints()).getPoints().size()); - for (int i = 0; i < 10; i++) - { - assertInstanceOf(RelativeBendpoint.class, ((RelativeBendpoints)edge.getBendpoints()).getPoints().get(i)); - } - } - } - - private Edge createExampleEdge() - { - Edge edge = NotationFactory.eINSTANCE.createEdge(); - - edge.setVisible(true); - edge.setMutable(false); - RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); - - edge.setBendpoints(bendpoints); - - List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(); - - for (int i = 0; i < 10; i++) - { - RelativeBendpoint bendPoint = new RelativeBendpoint(1, 2, 3, 4); - points.add(bendPoint); - } - - bendpoints.setPoints(points); - edge.setBendpoints(bendpoints); - return edge; - } - - public void testSimpleDiagramWithViews() throws Exception - { - CDOSession session = openSession(); - { - CDOTransaction transaction = session.openTransaction(); - - CDOResource resource = transaction.createResource("/test1"); - Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); - - diagram.setName("MyDiagram"); - int numberOfNodes = 10; - for (int i = 0; i < numberOfNodes; i++) - { - // Node node = createExampleNode(); - // nodes.add(node); - diagram.createChild(NotationPackage.eINSTANCE.getNode()); - } - - for (int i = 0; i < 5; i++) - { - Node nodeA = (Node)diagram.getChildren().get(i); - Node nodeB = (Node)diagram.getChildren().get(numberOfNodes - 1 - i); - - Edge edge = diagram.createEdge(NotationPackage.eINSTANCE.getEdge()); - - edge.setSource(nodeA); - edge.setTarget(nodeB); - System.out.println("break"); - } - - resource.getContents().add(diagram); - transaction.commit(); - } - - session.close(); - session = openSession(); - - { - CDOTransaction transaction = session.openTransaction(); - - CDOResource resource = transaction.getResource("/test1"); - - Diagram diagram = (Diagram)resource.getContents().get(0); - - assertEquals(true, diagram.isVisible()); - assertEquals(false, diagram.isMutable()); - - assertEquals(10, diagram.getChildren().size()); - assertEquals(5, diagram.getEdges().size()); - } - } - - public void testDiagramFromXMIResource() throws Exception - { - CDOSession session = openSession(); - { - ResourceSet resourceSet = new ResourceSetImpl(); - AcorePackage.eINSTANCE.eClass(); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() - .put("acore_diagram", new XMIResourceFactoryImpl()); - - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("acore", new XMIResourceFactoryImpl()); - - System.out.println(GMFTest.class.getResource(".")); - System.out.println(GMFTest.class.getResource("/")); - - URL resourceURI = GMFTest.class.getResource(""); - String resourcePath = resourceURI.toString().substring(0, resourceURI.toString().lastIndexOf("/bin")); - - System.out.println(resourcePath); - - // Resource emfResource = resourceSet.getResource(URI.createURI(resourcePath + "/testdata/simple.acore"), true); - Resource gmfResource = resourceSet.getResource(URI.createURI(resourcePath + "/testdata/simple.acore_diagram"), - true); - - Diagram diagram = (Diagram)gmfResource.getContents().get(0); - ACoreRoot classDiagram = (ACoreRoot)diagram.getElement(); - - for (Object o : diagram.getPersistedChildren()) - { - View view = (View)o; - System.out.println(view.getElement()); - } - - CDOTransaction transaction = session.openTransaction(); - - CDOResource resource = transaction.createResource("/test1"); - resource.getContents().add(classDiagram); - resource.getContents().add(diagram); - - transaction.commit(); - } - session.close(); - session = openSession(); - { - CDOTransaction transaction = session.openTransaction(); - - CDOResource resource = transaction.getResource("/test1"); - - Diagram reloadedDiagram = (Diagram)resource.getContents().get(1); - - assertInstanceOf(ACoreRoot.class, reloadedDiagram.getElement()); - assertEquals(true, reloadedDiagram.isVisible()); - assertEquals(false, reloadedDiagram.isMutable()); - - assertEquals(3, reloadedDiagram.getChildren().size()); - assertEquals(2, reloadedDiagram.getEdges().size()); - - for (Object o : reloadedDiagram.getEdges()) - { - Edge edge = (Edge)o; - RelativeBendpoints bendpoints = (RelativeBendpoints)edge.getBendpoints(); - assertNotNull(bendpoints); - assertEquals(true, bendpoints.getPoints().size() > 0); - } - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.common;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
+import org.eclipse.emf.cdo.dawn.examples.acore.AcorePackage;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.mango.MangoValue;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.URI;
+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.xmi.impl.XMIResourceFactoryImpl;
+
+import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+public class GMFTest extends AbstractCDOTest
+{
+ public void testDiagram() throws Exception
+ {
+ CDOSession session = openSession();
+ {
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource("/test1");
+ Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+
+ diagram.setName("MyDiagram");
+ diagram.setVisible(true);
+ diagram.setMutable(false);
+
+ resource.getContents().add(diagram);
+
+ transaction.commit();
+ }
+
+ session.close();
+ session = openSession();
+
+ {
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.getResource("/test1");
+
+ Diagram diagram = (Diagram)resource.getContents().get(0);
+
+ assertEquals("MyDiagram", diagram.getName());
+ assertEquals(true, diagram.isVisible());
+ assertEquals(false, diagram.isMutable());
+ }
+ }
+
+ public void testSimpleNode() throws Exception
+ {
+ CDOSession session = openSession();
+ {
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource("/test1");
+ Node node = createExampleNode();
+ MangoValue mangoValue = getMangoFactory().createMangoValue();
+ node.setElement(mangoValue);
+
+ resource.getContents().add(node);
+ resource.getContents().add(mangoValue);
+
+ transaction.commit();
+ }
+
+ session.close();
+ session = openSession();
+
+ {
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.getResource("/test1");
+
+ Node node = (Node)resource.getContents().get(0);
+
+ assertEquals(true, node.isVisible());
+ assertEquals(false, node.isMutable());
+ assertInstanceOf(Bounds.class, node.getLayoutConstraint());
+ Bounds bounds = (Bounds)node.getLayoutConstraint();
+ assertEquals(1503, bounds.getHeight());
+ assertEquals(1979, bounds.getWidth());
+ assertEquals(777, bounds.getX());
+ assertEquals(888, bounds.getY());
+
+ assertInstanceOf(MangoValue.class, node.getElement());
+ }
+ }
+
+ private Node createExampleNode()
+ {
+ Node node = NotationFactory.eINSTANCE.createNode();
+ Bounds bounds = NotationFactory.eINSTANCE.createBounds();
+ bounds.setHeight(1503);
+ bounds.setWidth(1979);
+ bounds.setX(777);
+ bounds.setY(888);
+
+ node.setVisible(true);
+ node.setMutable(false);
+ node.setLayoutConstraint(bounds);
+ return node;
+ }
+
+ public void testSimpleEdge() throws Exception
+ {
+ CDOSession session = openSession();
+ {
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource("/test1");
+ Edge edge = createExampleEdge();
+
+ resource.getContents().add(edge);
+ transaction.commit();
+ }
+ session.close();
+ session = openSession();
+ {
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.getResource("/test1");
+
+ Edge edge = (Edge)resource.getContents().get(0);
+
+ assertEquals(true, edge.isVisible());
+ assertEquals(false, edge.isMutable());
+
+ assertEquals(10, ((RelativeBendpoints)edge.getBendpoints()).getPoints().size());
+ for (int i = 0; i < 10; i++)
+ {
+ assertInstanceOf(RelativeBendpoint.class, ((RelativeBendpoints)edge.getBendpoints()).getPoints().get(i));
+ }
+ }
+ }
+
+ private Edge createExampleEdge()
+ {
+ Edge edge = NotationFactory.eINSTANCE.createEdge();
+
+ edge.setVisible(true);
+ edge.setMutable(false);
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+
+ edge.setBendpoints(bendpoints);
+
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>();
+
+ for (int i = 0; i < 10; i++)
+ {
+ RelativeBendpoint bendPoint = new RelativeBendpoint(1, 2, 3, 4);
+ points.add(bendPoint);
+ }
+
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ return edge;
+ }
+
+ public void testSimpleDiagramWithViews() throws Exception
+ {
+ CDOSession session = openSession();
+ {
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource("/test1");
+ Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+
+ diagram.setName("MyDiagram");
+ int numberOfNodes = 10;
+ for (int i = 0; i < numberOfNodes; i++)
+ {
+ // Node node = createExampleNode();
+ // nodes.add(node);
+ diagram.createChild(NotationPackage.eINSTANCE.getNode());
+ }
+
+ for (int i = 0; i < 5; i++)
+ {
+ Node nodeA = (Node)diagram.getChildren().get(i);
+ Node nodeB = (Node)diagram.getChildren().get(numberOfNodes - 1 - i);
+
+ Edge edge = diagram.createEdge(NotationPackage.eINSTANCE.getEdge());
+
+ edge.setSource(nodeA);
+ edge.setTarget(nodeB);
+ System.out.println("break");
+ }
+
+ resource.getContents().add(diagram);
+ transaction.commit();
+ }
+
+ session.close();
+ session = openSession();
+
+ {
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.getResource("/test1");
+
+ Diagram diagram = (Diagram)resource.getContents().get(0);
+
+ assertEquals(true, diagram.isVisible());
+ assertEquals(false, diagram.isMutable());
+
+ assertEquals(10, diagram.getChildren().size());
+ assertEquals(5, diagram.getEdges().size());
+ }
+ }
+
+ public void testDiagramFromXMIResource() throws Exception
+ {
+ CDOSession session = openSession();
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ AcorePackage.eINSTANCE.eClass();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
+ .put("acore_diagram", new XMIResourceFactoryImpl());
+
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("acore", new XMIResourceFactoryImpl());
+
+ System.out.println(GMFTest.class.getResource("."));
+ System.out.println(GMFTest.class.getResource("/"));
+
+ URL resourceURI = GMFTest.class.getResource("");
+ String resourcePath = resourceURI.toString().substring(0, resourceURI.toString().lastIndexOf("/bin"));
+
+ System.out.println(resourcePath);
+
+ // Resource emfResource = resourceSet.getResource(URI.createURI(resourcePath + "/testdata/simple.acore"), true);
+ Resource gmfResource = resourceSet.getResource(URI.createURI(resourcePath + "/testdata/simple.acore_diagram"),
+ true);
+
+ Diagram diagram = (Diagram)gmfResource.getContents().get(0);
+ ACoreRoot classDiagram = (ACoreRoot)diagram.getElement();
+
+ for (Object o : diagram.getPersistedChildren())
+ {
+ View view = (View)o;
+ System.out.println(view.getElement());
+ }
+
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource("/test1");
+ resource.getContents().add(classDiagram);
+ resource.getContents().add(diagram);
+
+ transaction.commit();
+ }
+ session.close();
+ session = openSession();
+ {
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.getResource("/test1");
+
+ Diagram reloadedDiagram = (Diagram)resource.getContents().get(1);
+
+ assertInstanceOf(ACoreRoot.class, reloadedDiagram.getElement());
+ assertEquals(true, reloadedDiagram.isVisible());
+ assertEquals(false, reloadedDiagram.isMutable());
+
+ assertEquals(3, reloadedDiagram.getChildren().size());
+ assertEquals(2, reloadedDiagram.getEdges().size());
+
+ for (Object o : reloadedDiagram.getEdges())
+ {
+ Edge edge = (Edge)o;
+ RelativeBendpoints bendpoints = (RelativeBendpoints)edge.getBendpoints();
+ assertNotNull(bendpoints);
+ assertEquals(true, bendpoints.getPoints().size() > 0);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/TestFrameworkTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/TestFrameworkTest.java index 3a08557325..69b63f4d90 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/TestFrameworkTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/common/TestFrameworkTest.java @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.common; - -import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot; -import org.eclipse.emf.cdo.dawn.examples.acore.AcorePackage; -import org.eclipse.emf.cdo.dawn.resources.DawnWrapperResource; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnTest; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.util.CommitException; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.ResourceSet; - -import org.eclipse.gmf.runtime.notation.Diagram; - -/** - * This test tests the test framework itself. - * - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -public class TestFrameworkTest extends AbstractDawnTest -{ - public void testResourceCreation() throws CommitException - { - CDOSession session = openSession(); - - createCDOResourcesFromXMI("simple", AcorePackage.eINSTANCE, session); - - ResourceSet resourceSet = createResourceSet(); - CDOTransaction transaction = session.openTransaction(resourceSet); - - CDOResource semanticResource = transaction.getResource("/simple.acore"); - - assertInstanceOf(CDOResource.class, semanticResource); - DawnWrapperResource notationalResource = (DawnWrapperResource)resourceSet.getResource( - URI.createURI("dawn://repo1/simple.acore_diagram"), true);// container.getNotationalResource(); - assertInstanceOf(DawnWrapperResource.class, notationalResource); - ACoreRoot acoreRoot = (ACoreRoot)semanticResource.getContents().get(0); - - assertEquals(3, acoreRoot.getClasses().size()); - assertEquals("A", acoreRoot.getClasses().get(0).getName()); - assertEquals("B", acoreRoot.getClasses().get(1).getName()); - assertEquals("C", acoreRoot.getClasses().get(2).getName()); - - Diagram diagram = (Diagram)notationalResource.getContents().get(0); - assertEquals(3, diagram.getChildren().size()); - assertEquals(2, diagram.getEdges().size()); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.common;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
+import org.eclipse.emf.cdo.dawn.examples.acore.AcorePackage;
+import org.eclipse.emf.cdo.dawn.resources.DawnWrapperResource;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnTest;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+
+/**
+ * This test tests the test framework itself.
+ *
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+public class TestFrameworkTest extends AbstractDawnTest
+{
+ public void testResourceCreation() throws CommitException
+ {
+ CDOSession session = openSession();
+
+ createCDOResourcesFromXMI("simple", AcorePackage.eINSTANCE, session);
+
+ ResourceSet resourceSet = createResourceSet();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ CDOResource semanticResource = transaction.getResource("/simple.acore");
+
+ assertInstanceOf(CDOResource.class, semanticResource);
+ DawnWrapperResource notationalResource = (DawnWrapperResource)resourceSet.getResource(
+ URI.createURI("dawn://repo1/simple.acore_diagram"), true);// container.getNotationalResource();
+ assertInstanceOf(DawnWrapperResource.class, notationalResource);
+ ACoreRoot acoreRoot = (ACoreRoot)semanticResource.getContents().get(0);
+
+ assertEquals(3, acoreRoot.getClasses().size());
+ assertEquals("A", acoreRoot.getClasses().get(0).getName());
+ assertEquals("B", acoreRoot.getClasses().get(1).getName());
+ assertEquals("C", acoreRoot.getClasses().get(2).getName());
+
+ Diagram diagram = (Diagram)notationalResource.getContents().get(0);
+ assertEquals(3, diagram.getChildren().size());
+ assertEquals(2, diagram.getEdges().size());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnCodeGenerationTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnCodeGenerationTest.java index 485cb5d2f3..79ee3aa6a8 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnCodeGenerationTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnCodeGenerationTest.java @@ -1,205 +1,205 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui; - -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnUITest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnCodeGenerationTestUtil; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class DawnCodeGenerationTest extends AbstractDawnUITest<SWTWorkbenchBot> -{ - private SWTBotView packageExplorer; - - @Override - @Before - public void setUp() throws Exception - { - super.setUp(); - prepare(); - } - - @Override - @After - public void tearDown() throws Exception - { - cleanup(); - super.tearDown(); - } - - private void cleanup() - { - deleteProject("org.eclipse.emf.cdo.dawn.examples.acore"); - } - - @Test - public void testCodeGenerationGMF() throws Exception - { - SWTBotView packageExplorer = DawnSWTBotUtil.openView(getBot(), "Java", "Package Explorer"); - packageExplorer.setFocus(); - - SWTBotTreeItem modelFolder = getBot().tree().expandNode("org.eclipse.emf.cdo.dawn.examples.acore", "model"); - - SWTBotTreeItem gmfgen = modelFolder.expandNode("acore.gmfgen"); - gmfgen.contextMenu("Generate Dawn GenModel").click(); - - sleep(5000); - - assertNotNull(modelFolder.getNode("acore.dawngenmodel")); - SWTBotTreeItem dawngenmodel_gmf = modelFolder.getNode("acore.dawngenmodel_gmf"); - assertNotNull(dawngenmodel_gmf); - - dawngenmodel_gmf.contextMenu("Generate Dawn GMF Fragment").click(); - - sleep(10000); - - IProject fragment = ResourcesPlugin.getWorkspace().getRoot() - .getProject("org.eclipse.emf.cdo.dawn.examples.acore.diagram.dawn"); - - assertNotNull(fragment); - String diagramFolder = "src/org/eclipse/emf/cdo/dawn/examples/acore/diagram"; - assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, "META-INF/MANIFEST.MF")); - assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, "/fragment.xml")); - assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, "/build.properties")); - - assertEquals(true, - DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/edit/parts/DawnAcoreEditPartFactory.java")); - assertEquals(true, - DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/edit/parts/DawnACoreRootEditPart.java")); - assertEquals( - true, - DawnCodeGenerationTestUtil.exists(fragment, diagramFolder - + "/edit/policies/DawnACoreRootCanonicalEditPolicy.java")); - - assertEquals(true, - DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/part/DawnAcoreCreationWizard.java")); - assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/part/DawnAcoreDiagramEditor.java")); - assertEquals(true, - DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/part/DawnAcoreDiagramEditorUtil.java")); - assertEquals(true, - DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/part/DawnAcoreDocumentProvider.java")); - - assertEquals(true, - DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/providers/DawnAcoreEditPartProvider.java")); - assertEquals(true, - DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/providers/DawnAcoreEditPolicyProvider.java")); - deleteProject("org.eclipse.emf.cdo.dawn.examples.acore.diagram.dawn"); - sleep(2000); - } - - @Test - public void testCodeGenerationEMF() throws Exception - { - packageExplorer = DawnSWTBotUtil.openView(getBot(), "Java", "Package Explorer"); - packageExplorer.setFocus(); - - SWTBotTreeItem modelFolder = getBot().tree().expandNode("org.eclipse.emf.cdo.dawn.examples.acore", "model"); - - SWTBotTreeItem gmfgen = modelFolder.expandNode("acore.genmodel"); - gmfgen.contextMenu("Generate Dawn GenModel").click(); - - IProject rootProject = ResourcesPlugin.getWorkspace().getRoot() - .getProject("org.eclipse.emf.cdo.dawn.examples.acore"); - - waitUntilExists(rootProject, "model/acore.dawngenmodel", 10000); - - assertEquals(true, DawnCodeGenerationTestUtil.exists(rootProject, "model/acore.dawngenmodel_emf")); - - modelFolder.setFocus(); - SWTBotTreeItem dawngenmodel_emf = modelFolder.getNode("acore.dawngenmodel_emf"); - - assertNotNull(dawngenmodel_emf); - - dawngenmodel_emf.contextMenu("Generate Dawn EMF Fragment").click(); - - sleep(10000); - - assertNotNull(modelFolder.getNode("acore.dawngenmodel")); - assertNotNull(modelFolder.getNode("acore.dawngenmodel_emf")); - - IProject fragment = ResourcesPlugin.getWorkspace().getRoot() - .getProject("org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn"); - - assertNotNull(fragment); - - assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, "META-INF/MANIFEST.MF")); - assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, "/fragment.xml")); - assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, "/build.properties")); - - String folder = "src/org/eclipse/emf/cdo/dawn/examples/acore/presentation/"; - - assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, folder + "DawnAcoreEditor.java")); - assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, folder + "DawnAcoreModelWizard.java")); - deleteProject("org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn"); - sleep(2000); - } - - private void waitUntilExists(IProject project, String path, int timeout) - { - while (timeout > 0) - { - if (DawnCodeGenerationTestUtil.exists(project, "model/acore.dawngenmodel")) - { - return; - } - sleep(1000); - timeout -= 1000; - } - throw new RuntimeException("Could not find " + path + " within " + timeout + " ms."); - } - - private SWTWorkbenchBot prepare() - { - SWTWorkbenchBot bot = getBot(); - - SWTBotView pluginsView = DawnSWTBotUtil.openView(bot, "Plug-in Development", "Plug-ins"); - - pluginsView.setFocus(); - - final SWTBotTree tree = bot.tree(); - final SWTBotTree plugin = tree.select("org.eclipse.emf.cdo.dawn.examples.acore (1.0.0.qualifier)"); - - DawnSWTBotUtil.findContextMenu(plugin, "Import As", "Source Project").click(); - - // wait here until the import has finished - sleep(10000); - return bot; - } - - private void deleteProject(String projectName) - { - SWTWorkbenchBot bot = getBot(); - SWTBotTreeItem project = bot.tree().expandNode(projectName); - project.contextMenu("Delete").click(); - bot.shell("Delete Resources").activate(); - bot.checkBox().select(); - bot.button("OK").click(); - sleep(2000); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui;
+
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnUITest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnCodeGenerationTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class DawnCodeGenerationTest extends AbstractDawnUITest<SWTWorkbenchBot>
+{
+ private SWTBotView packageExplorer;
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ prepare();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ cleanup();
+ super.tearDown();
+ }
+
+ private void cleanup()
+ {
+ deleteProject("org.eclipse.emf.cdo.dawn.examples.acore");
+ }
+
+ @Test
+ public void testCodeGenerationGMF() throws Exception
+ {
+ SWTBotView packageExplorer = DawnSWTBotUtil.openView(getBot(), "Java", "Package Explorer");
+ packageExplorer.setFocus();
+
+ SWTBotTreeItem modelFolder = getBot().tree().expandNode("org.eclipse.emf.cdo.dawn.examples.acore", "model");
+
+ SWTBotTreeItem gmfgen = modelFolder.expandNode("acore.gmfgen");
+ gmfgen.contextMenu("Generate Dawn GenModel").click();
+
+ sleep(5000);
+
+ assertNotNull(modelFolder.getNode("acore.dawngenmodel"));
+ SWTBotTreeItem dawngenmodel_gmf = modelFolder.getNode("acore.dawngenmodel_gmf");
+ assertNotNull(dawngenmodel_gmf);
+
+ dawngenmodel_gmf.contextMenu("Generate Dawn GMF Fragment").click();
+
+ sleep(10000);
+
+ IProject fragment = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject("org.eclipse.emf.cdo.dawn.examples.acore.diagram.dawn");
+
+ assertNotNull(fragment);
+ String diagramFolder = "src/org/eclipse/emf/cdo/dawn/examples/acore/diagram";
+ assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, "META-INF/MANIFEST.MF"));
+ assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, "/fragment.xml"));
+ assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, "/build.properties"));
+
+ assertEquals(true,
+ DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/edit/parts/DawnAcoreEditPartFactory.java"));
+ assertEquals(true,
+ DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/edit/parts/DawnACoreRootEditPart.java"));
+ assertEquals(
+ true,
+ DawnCodeGenerationTestUtil.exists(fragment, diagramFolder
+ + "/edit/policies/DawnACoreRootCanonicalEditPolicy.java"));
+
+ assertEquals(true,
+ DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/part/DawnAcoreCreationWizard.java"));
+ assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/part/DawnAcoreDiagramEditor.java"));
+ assertEquals(true,
+ DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/part/DawnAcoreDiagramEditorUtil.java"));
+ assertEquals(true,
+ DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/part/DawnAcoreDocumentProvider.java"));
+
+ assertEquals(true,
+ DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/providers/DawnAcoreEditPartProvider.java"));
+ assertEquals(true,
+ DawnCodeGenerationTestUtil.exists(fragment, diagramFolder + "/providers/DawnAcoreEditPolicyProvider.java"));
+ deleteProject("org.eclipse.emf.cdo.dawn.examples.acore.diagram.dawn");
+ sleep(2000);
+ }
+
+ @Test
+ public void testCodeGenerationEMF() throws Exception
+ {
+ packageExplorer = DawnSWTBotUtil.openView(getBot(), "Java", "Package Explorer");
+ packageExplorer.setFocus();
+
+ SWTBotTreeItem modelFolder = getBot().tree().expandNode("org.eclipse.emf.cdo.dawn.examples.acore", "model");
+
+ SWTBotTreeItem gmfgen = modelFolder.expandNode("acore.genmodel");
+ gmfgen.contextMenu("Generate Dawn GenModel").click();
+
+ IProject rootProject = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject("org.eclipse.emf.cdo.dawn.examples.acore");
+
+ waitUntilExists(rootProject, "model/acore.dawngenmodel", 10000);
+
+ assertEquals(true, DawnCodeGenerationTestUtil.exists(rootProject, "model/acore.dawngenmodel_emf"));
+
+ modelFolder.setFocus();
+ SWTBotTreeItem dawngenmodel_emf = modelFolder.getNode("acore.dawngenmodel_emf");
+
+ assertNotNull(dawngenmodel_emf);
+
+ dawngenmodel_emf.contextMenu("Generate Dawn EMF Fragment").click();
+
+ sleep(10000);
+
+ assertNotNull(modelFolder.getNode("acore.dawngenmodel"));
+ assertNotNull(modelFolder.getNode("acore.dawngenmodel_emf"));
+
+ IProject fragment = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject("org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn");
+
+ assertNotNull(fragment);
+
+ assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, "META-INF/MANIFEST.MF"));
+ assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, "/fragment.xml"));
+ assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, "/build.properties"));
+
+ String folder = "src/org/eclipse/emf/cdo/dawn/examples/acore/presentation/";
+
+ assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, folder + "DawnAcoreEditor.java"));
+ assertEquals(true, DawnCodeGenerationTestUtil.exists(fragment, folder + "DawnAcoreModelWizard.java"));
+ deleteProject("org.eclipse.emf.cdo.dawn.examples.acore.editor.dawn");
+ sleep(2000);
+ }
+
+ private void waitUntilExists(IProject project, String path, int timeout)
+ {
+ while (timeout > 0)
+ {
+ if (DawnCodeGenerationTestUtil.exists(project, "model/acore.dawngenmodel"))
+ {
+ return;
+ }
+ sleep(1000);
+ timeout -= 1000;
+ }
+ throw new RuntimeException("Could not find " + path + " within " + timeout + " ms.");
+ }
+
+ private SWTWorkbenchBot prepare()
+ {
+ SWTWorkbenchBot bot = getBot();
+
+ SWTBotView pluginsView = DawnSWTBotUtil.openView(bot, "Plug-in Development", "Plug-ins");
+
+ pluginsView.setFocus();
+
+ final SWTBotTree tree = bot.tree();
+ final SWTBotTree plugin = tree.select("org.eclipse.emf.cdo.dawn.examples.acore (1.0.0.qualifier)");
+
+ DawnSWTBotUtil.findContextMenu(plugin, "Import As", "Source Project").click();
+
+ // wait here until the import has finished
+ sleep(10000);
+ return bot;
+ }
+
+ private void deleteProject(String projectName)
+ {
+ SWTWorkbenchBot bot = getBot();
+ SWTBotTreeItem project = bot.tree().expandNode(projectName);
+ project.contextMenu("Delete").click();
+ bot.shell("Delete Resources").activate();
+ bot.checkBox().select();
+ bot.button("OK").click();
+ sleep(2000);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnPreferencesTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnPreferencesTest.java index efbfd05ab3..ef83a7e3b2 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnPreferencesTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnPreferencesTest.java @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui; - -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnUITest; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; - -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; - -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class DawnPreferencesTest extends AbstractDawnUITest<SWTWorkbenchBot> -{ - @Test - public void testOpenPreferencePage() throws Exception - { - getBot().menu("Window").menu("Preferences").click(); - SWTBotShell shell = getBot().shell("Preferences"); - shell.activate(); - - getBot().tree().select("Dawn Remote Preferences"); - - SWTBotText serverNameLabel = getBot().textWithLabel("server name:"); - SWTBotText serverPortLabel = getBot().textWithLabel("server port:"); - SWTBotText repositoryLabel = getBot().textWithLabel("repository:"); - SWTBotText fileNameLabel = getBot().textWithLabel("protocol:"); - - assertEquals("localhost", serverNameLabel.getText()); - assertEquals("2036", serverPortLabel.getText()); - assertEquals("repo1", repositoryLabel.getText()); - assertEquals("tcp", fileNameLabel.getText()); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui;
+
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnUITest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class DawnPreferencesTest extends AbstractDawnUITest<SWTWorkbenchBot>
+{
+ @Test
+ public void testOpenPreferencePage() throws Exception
+ {
+ getBot().menu("Window").menu("Preferences").click();
+ SWTBotShell shell = getBot().shell("Preferences");
+ shell.activate();
+
+ getBot().tree().select("Dawn Remote Preferences");
+
+ SWTBotText serverNameLabel = getBot().textWithLabel("server name:");
+ SWTBotText serverPortLabel = getBot().textWithLabel("server port:");
+ SWTBotText repositoryLabel = getBot().textWithLabel("repository:");
+ SWTBotText fileNameLabel = getBot().textWithLabel("protocol:");
+
+ assertEquals("localhost", serverNameLabel.getText());
+ assertEquals("2036", serverPortLabel.getText());
+ assertEquals("repo1", repositoryLabel.getText());
+ assertEquals("tcp", fileNameLabel.getText());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnProjectExplorerTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnProjectExplorerTest.java index 21fa354fd7..520259dd5c 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnProjectExplorerTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnProjectExplorerTest.java @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui; - -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnUITest; -import org.eclipse.emf.cdo.dawn.ui.views.DawnExplorer; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; - -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.ui.IViewPart; - -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class DawnProjectExplorerTest extends AbstractDawnUITest<SWTWorkbenchBot> -{ - @Test - public void testOpenDawnExplorer() throws Exception - { - getBot().menu("Window").menu("Show View").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("Show View"); - shell.activate(); - getBot().tree().expandNode("Dawn").select("Dawn Explorer"); - getBot().button("OK").click(); - - SWTBotView activeView = getBot().activeView(); - assertEquals("Dawn Explorer", activeView.getViewReference().getTitle()); - IViewPart view = activeView.getViewReference().getView(false); - assertInstanceOf(DawnExplorer.class, view); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui;
+
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnUITest;
+import org.eclipse.emf.cdo.dawn.ui.views.DawnExplorer;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.ui.IViewPart;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class DawnProjectExplorerTest extends AbstractDawnUITest<SWTWorkbenchBot>
+{
+ @Test
+ public void testOpenDawnExplorer() throws Exception
+ {
+ getBot().menu("Window").menu("Show View").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("Show View");
+ shell.activate();
+ getBot().tree().expandNode("Dawn").select("Dawn Explorer");
+ getBot().button("OK").click();
+
+ SWTBotView activeView = getBot().activeView();
+ assertEquals("Dawn Explorer", activeView.getViewReference().getTitle());
+ IViewPart view = activeView.getViewReference().getView(false);
+ assertInstanceOf(DawnExplorer.class, view);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/DawnBasicEMFUITest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/DawnBasicEMFUITest.java index a8450697db..788dece81d 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/DawnBasicEMFUITest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/DawnBasicEMFUITest.java @@ -1,101 +1,101 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.emf; - -import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot; -import org.eclipse.emf.cdo.dawn.examples.acore.AcoreFactory; -import org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreEditor; -import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput; -import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.AbstractCDOTest; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.util.CommitException; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - -/** - * @author Martin Fluegge - */ -public class DawnBasicEMFUITest extends AbstractCDOTest -{ - @Override - public void doSetUp() throws Exception - { - super.doSetUp(); - getRepositoryConfig().getRepositoryProperties().put("overrideUUID", ""); - } - - public void testGetEditorIdForDawnEditor() - { - final CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource = transaction.createResource("/test.acore"); - - String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName()); - assertEquals(DawnAcoreEditor.ID, editorID); - } - - public void testEditorInput() throws PartInitException - { - final CDOSession session = openSession(); - - CDOTransaction transaction = session.openTransaction(); - CDOResource resource = transaction.createResource("/sample/test.acore"); - - String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName()); - assertEquals(DawnAcoreEditor.ID, editorID); - DawnEditorInput editorInput = new DawnEditorInput(resource.getURI()); - editorInput.setResource(resource); - - assertEquals(resource, editorInput.getResource()); - assertEquals(resource.getPath(), editorInput.getResourcePath()); - assertEquals(transaction, editorInput.getView()); - assertEquals(resource.getURI(), editorInput.getURI()); - assertEquals(false, editorInput.isViewOwned()); - } - - public void testOpenEditor() throws PartInitException - { - final CDOSession session = openSession(); - - CDOTransaction transaction = session.openTransaction(); - CDOResource resource = transaction.createResource("/test.acore"); - - ACoreRoot aCoreRoot = AcoreFactory.eINSTANCE.createACoreRoot(); - - resource.getContents().add(aCoreRoot); - try - { - transaction.commit(); - } - catch (CommitException ex) - { - throw new RuntimeException(ex); - } - - String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName()); - assertEquals(DawnAcoreEditor.ID, editorID); - - DawnEditorInput editorInput = new DawnEditorInput(resource.getURI()); - - // TODO Test case fails because the ConnectionUtil is not initialized. Fake it here or use the DawnExplorer to open - // the editor. - IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite() - .getPage().openEditor(editorInput, editorID); - - sleep(5000); - assertInstanceOf(DawnAcoreEditor.class, editor); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.emf;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
+import org.eclipse.emf.cdo.dawn.examples.acore.AcoreFactory;
+import org.eclipse.emf.cdo.dawn.examples.acore.presentation.DawnAcoreEditor;
+import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput;
+import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnBasicEMFUITest extends AbstractCDOTest
+{
+ @Override
+ public void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ getRepositoryConfig().getRepositoryProperties().put("overrideUUID", "");
+ }
+
+ public void testGetEditorIdForDawnEditor()
+ {
+ final CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test.acore");
+
+ String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName());
+ assertEquals(DawnAcoreEditor.ID, editorID);
+ }
+
+ public void testEditorInput() throws PartInitException
+ {
+ final CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/sample/test.acore");
+
+ String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName());
+ assertEquals(DawnAcoreEditor.ID, editorID);
+ DawnEditorInput editorInput = new DawnEditorInput(resource.getURI());
+ editorInput.setResource(resource);
+
+ assertEquals(resource, editorInput.getResource());
+ assertEquals(resource.getPath(), editorInput.getResourcePath());
+ assertEquals(transaction, editorInput.getView());
+ assertEquals(resource.getURI(), editorInput.getURI());
+ assertEquals(false, editorInput.isViewOwned());
+ }
+
+ public void testOpenEditor() throws PartInitException
+ {
+ final CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test.acore");
+
+ ACoreRoot aCoreRoot = AcoreFactory.eINSTANCE.createACoreRoot();
+
+ resource.getContents().add(aCoreRoot);
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+
+ String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName());
+ assertEquals(DawnAcoreEditor.ID, editorID);
+
+ DawnEditorInput editorInput = new DawnEditorInput(resource.getURI());
+
+ // TODO Test case fails because the ConnectionUtil is not initialized. Fake it here or use the DawnExplorer to open
+ // the editor.
+ IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite()
+ .getPage().openEditor(editorInput, editorID);
+
+ sleep(5000);
+ assertInstanceOf(DawnAcoreEditor.class, editor);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/DawnEMFCreationWizardTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/DawnEMFCreationWizardTest.java index 51368fb162..e132686f27 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/DawnEMFCreationWizardTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/DawnEMFCreationWizardTest.java @@ -1,224 +1,224 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.emf; - -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnEMFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; - -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.keyboard.Keyboard; -import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory; -import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; -import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; - -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class DawnEMFCreationWizardTest extends AbstractDawnEMFTest -{ - private String resourceFieldLabel = org.eclipse.emf.cdo.dawn.ui.messages.Messages.DawnCreateNewResourceWizardPage_6; - - @Test - public void testCreateNewDawnAcoreEditor() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF); - getBot().button("Next >").click(); - getBot().button("Next >").click(); - - shell = getBot().shell("New"); - shell.activate(); - - SWTBotCombo comboBox = getBot().comboBox(0);// bot.ccomboBox(0); - comboBox.setFocus(); - comboBox.setSelection("ACore Root"); - - getBot().button("Finish").click(); - - sleep(500); - - SWTBotEditor editor = getBot().editorByTitle("default.acore"); - assertNotNull(editor); - editor.close(); - { - assertEquals(true, resourceExists("/default.acore")); - } - } - - @Test - public void testCreateNewDawnEditorSetName() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF); - getBot().button("Next >").click(); - - shell = getBot().shell("New"); - shell.activate(); - - SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel); - fileSemanticNameLabel.setText("test.acore"); - assertEquals("test.acore", fileSemanticNameLabel.getText()); - - getBot().button("Next >").click(); - - SWTBotCombo comboBox = getBot().comboBox(0);// bot.ccomboBox(0); - comboBox.setFocus(); - comboBox.setSelection("ACore Root"); - - getBot().button("Finish").click(); - - SWTBotEditor editor = getBot().editorByTitle("test.acore"); - assertNotNull(editor); - editor.close(); - } - - @Test - public void testCreateNewDawnEditorWrongResourceName() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF); - getBot().button("Next >").click(); - - shell = getBot().shell("New"); - shell.activate(); - - SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel); - SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; - Keyboard keyboard = KeyboardFactory.getDefaultKeyboard(fileSemanticNameLabel.widget, null); - fileSemanticNameLabel.setFocus(); - fileSemanticNameLabel.setText("x"); - // fileSemanticNameLabel.typeText("x", 500); - keyboard.pressShortcut(Keystrokes.BS); - - assertEquals(false, getBot().button("Next >").isEnabled()); - getBot().button("Cancel").click(); - } - - @Test - public void testCreateNewDawnEditorSelectFolder() throws Exception - { - { - CDOSession session = openSession(); - ResourceSet resourceSet = new ResourceSetImpl(); - CDOTransaction transaction = session.openTransaction(resourceSet); - - final URI uri = URI.createURI("cdo:/folder/dummy"); - resourceSet.createResource(uri); - transaction.commit(); - } - - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF); - getBot().button("Next >").click(); - - shell = getBot().shell("New"); - shell.activate(); - - SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel); - fileNameLabel.setText("test.acore"); - - SWTBotTree tree = getBot().tree(0); - - selectFolder(tree.getAllItems(), "folder", false); - - getBot().button("Next >").click(); - - SWTBotCombo comboBox = getBot().comboBox(0);// bot.ccomboBox(0); - comboBox.setFocus(); - comboBox.setSelection("ACore Root"); - - getBot().button("Finish").click(); - - SWTBotEditor editor = getBot().editorByTitle("test.acore"); - assertNotNull(editor); - editor.close(); - - { - assertEquals(true, resourceExists("/folder/test.acore")); - } - } - - @Test - public void testCreateNewDawnDiagramTypeFolder() throws Exception - { - { - CDOSession session = openSession(); - ResourceSet resourceSet = new ResourceSetImpl(); - CDOTransaction transaction = session.openTransaction(resourceSet); - - final URI uri = URI.createURI("cdo:/folder/dummy"); - resourceSet.createResource(uri); - transaction.commit(); - } - - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF); - getBot().button("Next >").click(); - - shell = getBot().shell("New"); - shell.activate(); - - SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel); - fileNameLabel.setText("test.acore"); - - SWTBotText folder = getBot().textWithLabel("Enter or select the parent folder: "); - folder.setText("/folder"); - SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; - - getBot().button("Next >").click(); - - SWTBotCombo comboBox = getBot().comboBox(0);// bot.ccomboBox(0); - comboBox.setFocus(); - comboBox.setSelection("ACore Root"); - - getBot().button("Finish").click(); - - SWTBotEditor editor = getBot().editorByTitle("test.acore"); - assertNotNull(editor); - editor.close(); - - { - assertEquals(true, resourceExists("/folder/test.acore")); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.emf;
+
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnEMFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.keyboard.Keyboard;
+import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory;
+import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class DawnEMFCreationWizardTest extends AbstractDawnEMFTest
+{
+ private String resourceFieldLabel = org.eclipse.emf.cdo.dawn.ui.messages.Messages.DawnCreateNewResourceWizardPage_6;
+
+ @Test
+ public void testCreateNewDawnAcoreEditor() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF);
+ getBot().button("Next >").click();
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New");
+ shell.activate();
+
+ SWTBotCombo comboBox = getBot().comboBox(0);// bot.ccomboBox(0);
+ comboBox.setFocus();
+ comboBox.setSelection("ACore Root");
+
+ getBot().button("Finish").click();
+
+ sleep(500);
+
+ SWTBotEditor editor = getBot().editorByTitle("default.acore");
+ assertNotNull(editor);
+ editor.close();
+ {
+ assertEquals(true, resourceExists("/default.acore"));
+ }
+ }
+
+ @Test
+ public void testCreateNewDawnEditorSetName() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF);
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New");
+ shell.activate();
+
+ SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ fileSemanticNameLabel.setText("test.acore");
+ assertEquals("test.acore", fileSemanticNameLabel.getText());
+
+ getBot().button("Next >").click();
+
+ SWTBotCombo comboBox = getBot().comboBox(0);// bot.ccomboBox(0);
+ comboBox.setFocus();
+ comboBox.setSelection("ACore Root");
+
+ getBot().button("Finish").click();
+
+ SWTBotEditor editor = getBot().editorByTitle("test.acore");
+ assertNotNull(editor);
+ editor.close();
+ }
+
+ @Test
+ public void testCreateNewDawnEditorWrongResourceName() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF);
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New");
+ shell.activate();
+
+ SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
+ Keyboard keyboard = KeyboardFactory.getDefaultKeyboard(fileSemanticNameLabel.widget, null);
+ fileSemanticNameLabel.setFocus();
+ fileSemanticNameLabel.setText("x");
+ // fileSemanticNameLabel.typeText("x", 500);
+ keyboard.pressShortcut(Keystrokes.BS);
+
+ assertEquals(false, getBot().button("Next >").isEnabled());
+ getBot().button("Cancel").click();
+ }
+
+ @Test
+ public void testCreateNewDawnEditorSelectFolder() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ final URI uri = URI.createURI("cdo:/folder/dummy");
+ resourceSet.createResource(uri);
+ transaction.commit();
+ }
+
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF);
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New");
+ shell.activate();
+
+ SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ fileNameLabel.setText("test.acore");
+
+ SWTBotTree tree = getBot().tree(0);
+
+ selectFolder(tree.getAllItems(), "folder", false);
+
+ getBot().button("Next >").click();
+
+ SWTBotCombo comboBox = getBot().comboBox(0);// bot.ccomboBox(0);
+ comboBox.setFocus();
+ comboBox.setSelection("ACore Root");
+
+ getBot().button("Finish").click();
+
+ SWTBotEditor editor = getBot().editorByTitle("test.acore");
+ assertNotNull(editor);
+ editor.close();
+
+ {
+ assertEquals(true, resourceExists("/folder/test.acore"));
+ }
+ }
+
+ @Test
+ public void testCreateNewDawnDiagramTypeFolder() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ final URI uri = URI.createURI("cdo:/folder/dummy");
+ resourceSet.createResource(uri);
+ transaction.commit();
+ }
+
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF);
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New");
+ shell.activate();
+
+ SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ fileNameLabel.setText("test.acore");
+
+ SWTBotText folder = getBot().textWithLabel("Enter or select the parent folder: ");
+ folder.setText("/folder");
+ SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
+
+ getBot().button("Next >").click();
+
+ SWTBotCombo comboBox = getBot().comboBox(0);// bot.ccomboBox(0);
+ comboBox.setFocus();
+ comboBox.setSelection("ACore Root");
+
+ getBot().button("Finish").click();
+
+ SWTBotEditor editor = getBot().editorByTitle("test.acore");
+ assertNotNull(editor);
+ editor.close();
+
+ {
+ assertEquals(true, resourceExists("/folder/test.acore"));
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/DawnEMFHandleEditorTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/DawnEMFHandleEditorTest.java index a8d199c3ae..0cc9bc5092 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/DawnEMFHandleEditorTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/DawnEMFHandleEditorTest.java @@ -1,127 +1,127 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.emf; - -import org.eclipse.emf.cdo.dawn.examples.acore.AClass; -import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot; -import org.eclipse.emf.cdo.dawn.examples.acore.AInterface; -import org.eclipse.emf.cdo.dawn.examples.acore.AcoreFactory; -import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnEMFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnEMFEditorBot; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotEMFEditor; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil; -import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class DawnEMFHandleEditorTest extends AbstractDawnEMFTest -{ - @Override - @Before - public void setUp() throws Exception - { - setBot(new DawnEMFEditorBot()); - DawnSWTBotUtil.initTest(getBot()); - super.setUp(); - } - - @Test - public void testOpenExistingResource() throws Exception - { - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource = transaction.createResource("/default.acore"); - ACoreRoot aCoreRoot = AcoreFactory.eINSTANCE.createACoreRoot(); - aCoreRoot.setTitle("root"); - resource.getContents().add(aCoreRoot); - AClass aClass = AcoreFactory.eINSTANCE.createAClass(); - aClass.setName("MyClass"); - - AInterface aInterface = AcoreFactory.eINSTANCE.createAInterface(); - aInterface.setName("MyInterface"); - - aCoreRoot.getClasses().add(aClass); - aCoreRoot.getInterfaces().add(aInterface); - transaction.commit(); - transaction.close(); - session.close(); - } - CDOConnectionUtil.instance.init(PreferenceConstants.getRepositoryName(), PreferenceConstants.getProtocol(), - PreferenceConstants.getServerName()); - CDOConnectionUtil.instance.openSession(); - DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openAcoreEMFEditor(URI.createURI("cdo://repo1/default.acore"), - getBot()); - assertNotNull(editor); - SWTBotTree tree = editor.getSelectionPageTree(); - - sleep(1000); - - SWTBotTreeItem treeItem = tree.getTreeItem("cdo://repo1/default.acore"); - treeItem.expand(); - - SWTBotTreeItem root = treeItem.getItems()[0]; - root.expand(); - - SWTBotTreeItem swtBotTreeItem1 = root.getItems()[0]; - assertEquals("AClass MyClass", swtBotTreeItem1.getText()); - SWTBotTreeItem swtBotTreeItem2 = root.getItems()[1]; - assertEquals("AInterface MyInterface", swtBotTreeItem2.getText()); - - editor.save(); - - editor.close(); - } - - @Test - public void testCreateNewElement() throws Exception - { - DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openNewAcoreEMFEditor("default.acore", getBot()); - assertNotNull(editor); - SWTBotTree tree = editor.getSelectionPageTree(); - - selectFolder(tree.getAllItems(), "ACore Root", false); - - editor.clickContextMenu(tree.widget, "AClass"); - editor.save(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - CDOResource resource = view.getResource("/default.acore"); - ACoreRoot aCoreRoot = (ACoreRoot)resource.getContents().get(0); - - assertEquals(1, aCoreRoot.getClasses().size()); - assertEquals(null, aCoreRoot.getClasses().get(0).getName()); - } - editor.close(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.emf;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
+import org.eclipse.emf.cdo.dawn.examples.acore.AInterface;
+import org.eclipse.emf.cdo.dawn.examples.acore.AcoreFactory;
+import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnEMFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnEMFEditorBot;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotEMFEditor;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil;
+import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class DawnEMFHandleEditorTest extends AbstractDawnEMFTest
+{
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ setBot(new DawnEMFEditorBot());
+ DawnSWTBotUtil.initTest(getBot());
+ super.setUp();
+ }
+
+ @Test
+ public void testOpenExistingResource() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/default.acore");
+ ACoreRoot aCoreRoot = AcoreFactory.eINSTANCE.createACoreRoot();
+ aCoreRoot.setTitle("root");
+ resource.getContents().add(aCoreRoot);
+ AClass aClass = AcoreFactory.eINSTANCE.createAClass();
+ aClass.setName("MyClass");
+
+ AInterface aInterface = AcoreFactory.eINSTANCE.createAInterface();
+ aInterface.setName("MyInterface");
+
+ aCoreRoot.getClasses().add(aClass);
+ aCoreRoot.getInterfaces().add(aInterface);
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+ CDOConnectionUtil.instance.init(PreferenceConstants.getRepositoryName(), PreferenceConstants.getProtocol(),
+ PreferenceConstants.getServerName());
+ CDOConnectionUtil.instance.openSession();
+ DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openAcoreEMFEditor(URI.createURI("cdo://repo1/default.acore"),
+ getBot());
+ assertNotNull(editor);
+ SWTBotTree tree = editor.getSelectionPageTree();
+
+ sleep(1000);
+
+ SWTBotTreeItem treeItem = tree.getTreeItem("cdo://repo1/default.acore");
+ treeItem.expand();
+
+ SWTBotTreeItem root = treeItem.getItems()[0];
+ root.expand();
+
+ SWTBotTreeItem swtBotTreeItem1 = root.getItems()[0];
+ assertEquals("AClass MyClass", swtBotTreeItem1.getText());
+ SWTBotTreeItem swtBotTreeItem2 = root.getItems()[1];
+ assertEquals("AInterface MyInterface", swtBotTreeItem2.getText());
+
+ editor.save();
+
+ editor.close();
+ }
+
+ @Test
+ public void testCreateNewElement() throws Exception
+ {
+ DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openNewAcoreEMFEditor("default.acore", getBot());
+ assertNotNull(editor);
+ SWTBotTree tree = editor.getSelectionPageTree();
+
+ selectFolder(tree.getAllItems(), "ACore Root", false);
+
+ editor.clickContextMenu(tree.widget, "AClass");
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource("/default.acore");
+ ACoreRoot aCoreRoot = (ACoreRoot)resource.getContents().get(0);
+
+ assertEquals(1, aCoreRoot.getClasses().size());
+ assertEquals(null, aCoreRoot.getClasses().get(0).getName());
+ }
+ editor.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFEditorRollbackTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFEditorRollbackTest.java index 0d4780ad25..4865eeb932 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFEditorRollbackTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFEditorRollbackTest.java @@ -1,74 +1,74 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.emf; - -import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; -import org.eclipse.emf.cdo.dawn.examples.acore.AClass; -import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnEMFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotEMFEditor; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; - -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; - -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class EMFEditorRollbackTest extends AbstractDawnEMFTest -{ - @Test - public void testGMFAClassConflictMove() throws Exception - { - DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openNewAcoreEMFEditor("default.acore", getBot()); - assertNotNull(editor); - SWTBotTree tree = editor.getSelectionPageTree(); - - selectFolder(tree.getAllItems(), "ACore Root", false); - - editor.clickContextMenu(tree.widget, "AClass"); - editor.save(); - // selectFolder(tree.getAllItems(), "AClass", false); - - IDawnEditor dawnEditor = (IDawnEditor)editor.getReference().getEditor(false); - - CDOResource resource = dawnEditor.getDawnEditorSupport().getView().getResource("/default.acore"); - AClass aClass = ((ACoreRoot)resource.getContents().get(0)).getClasses().get(0); - aClass.setName("BClass"); - - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore"); - AClass aClass2 = ((ACoreRoot)resource2.getContents().get(0)).getClasses().get(0); - aClass2.setName("CClass"); - transaction.commit(); - } - sleep(500); - assertEquals(true, aClass.cdoConflict()); - editor.clickContextMenu(tree.widget, "Solve Conflict"); - - getBot().button("yes").click(); - assertEquals(false, aClass.cdoConflict()); - assertEquals("CClass", aClass.getName()); - editor.close(); - - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.emf;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnEMFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotEMFEditor;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class EMFEditorRollbackTest extends AbstractDawnEMFTest
+{
+ @Test
+ public void testGMFAClassConflictMove() throws Exception
+ {
+ DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openNewAcoreEMFEditor("default.acore", getBot());
+ assertNotNull(editor);
+ SWTBotTree tree = editor.getSelectionPageTree();
+
+ selectFolder(tree.getAllItems(), "ACore Root", false);
+
+ editor.clickContextMenu(tree.widget, "AClass");
+ editor.save();
+ // selectFolder(tree.getAllItems(), "AClass", false);
+
+ IDawnEditor dawnEditor = (IDawnEditor)editor.getReference().getEditor(false);
+
+ CDOResource resource = dawnEditor.getDawnEditorSupport().getView().getResource("/default.acore");
+ AClass aClass = ((ACoreRoot)resource.getContents().get(0)).getClasses().get(0);
+ aClass.setName("BClass");
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore");
+ AClass aClass2 = ((ACoreRoot)resource2.getContents().get(0)).getClasses().get(0);
+ aClass2.setName("CClass");
+ transaction.commit();
+ }
+ sleep(500);
+ assertEquals(true, aClass.cdoConflict());
+ editor.clickContextMenu(tree.widget, "Solve Conflict");
+
+ getBot().button("yes").click();
+ assertEquals(false, aClass.cdoConflict());
+ assertEquals("CClass", aClass.getName());
+ editor.close();
+
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFLockingTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFLockingTest.java index 41cc717f88..285386a399 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFLockingTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFLockingTest.java @@ -1,113 +1,113 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.emf; - -import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; -import org.eclipse.emf.cdo.dawn.examples.acore.AClass; -import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnEMFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotEMFEditor; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; - -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; - -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class EMFLockingTest extends AbstractDawnEMFTest -{ - @Test - public void testAClassLockRemotely() throws Exception - { - DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openNewAcoreEMFEditor("default.acore", getBot()); - assertNotNull(editor); - SWTBotTree tree = editor.getSelectionPageTree(); - - selectFolder(tree.getAllItems(), "ACore Root", false); - - editor.clickContextMenu(tree.widget, "AClass"); - editor.save(); - - IDawnEditor dawnEditor = (IDawnEditor)editor.getReference().getEditor(false); - CDOResource resource = dawnEditor.getDawnEditorSupport().getView().getResource("/default.acore"); - AClass aClass = ((ACoreRoot)resource.getContents().get(0)).getClasses().get(0); - aClass.setName("BClass"); - - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore"); - AClass aClass2 = ((ACoreRoot)resource2.getContents().get(0)).getClasses().get(0); - aClass2.cdoWriteLock().lock(); - } - - sleep(500); - - assertEquals(true, aClass.cdoWriteLock().isLockedByOthers()); - - // SWTBotTreeItem treeItem = selectFolder(tree.getAllItems(), "BClass", false); - // assertEquals(DawnColorConstants.COLOR_LOCKED_REMOTELY, treeItem.foregroundColor()); - - editor.close(); - } - - @Test - public void testAClassLockLocally() throws Exception - { - DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openNewAcoreEMFEditor("default.acore", getBot()); - assertNotNull(editor); - SWTBotTree tree = editor.getSelectionPageTree(); - - selectFolder(tree.getAllItems(), "ACore Root", false); - - editor.clickContextMenu(tree.widget, "AClass"); - editor.save(); - - selectFolder(tree.getAllItems(), "AClass", false); - - editor.clickContextMenu(tree.widget, "Lock"); - sleep(500); - - IDawnEditor dawnEditor = (IDawnEditor)editor.getReference().getEditor(false); - CDOResource resource = dawnEditor.getDawnEditorSupport().getView().getResource("/default.acore"); - AClass aClass = ((ACoreRoot)resource.getContents().get(0)).getClasses().get(0); - assertEquals(true, aClass.cdoWriteLock().isLocked()); - - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore"); - AClass aClass2 = ((ACoreRoot)resource2.getContents().get(0)).getClasses().get(0); - assertEquals(true, aClass2.cdoWriteLock().isLockedByOthers()); - - sleep(500); - - editor.clickContextMenu(tree.widget, "Unlock"); - sleep(500); - - assertEquals(false, aClass.cdoWriteLock().isLocked()); - assertEquals(false, aClass2.cdoWriteLock().isLockedByOthers()); - - // SWTBotTreeItem treeItem = selectFolder(tree.getAllItems(), "AClass", false); - // assertEquals(DawnColorConstants.COLOR_LOCKED_LOCALLY, treeItem.foregroundColor()); - - editor.close(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.emf;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnEMFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotEMFEditor;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class EMFLockingTest extends AbstractDawnEMFTest
+{
+ @Test
+ public void testAClassLockRemotely() throws Exception
+ {
+ DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openNewAcoreEMFEditor("default.acore", getBot());
+ assertNotNull(editor);
+ SWTBotTree tree = editor.getSelectionPageTree();
+
+ selectFolder(tree.getAllItems(), "ACore Root", false);
+
+ editor.clickContextMenu(tree.widget, "AClass");
+ editor.save();
+
+ IDawnEditor dawnEditor = (IDawnEditor)editor.getReference().getEditor(false);
+ CDOResource resource = dawnEditor.getDawnEditorSupport().getView().getResource("/default.acore");
+ AClass aClass = ((ACoreRoot)resource.getContents().get(0)).getClasses().get(0);
+ aClass.setName("BClass");
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore");
+ AClass aClass2 = ((ACoreRoot)resource2.getContents().get(0)).getClasses().get(0);
+ aClass2.cdoWriteLock().lock();
+ }
+
+ sleep(500);
+
+ assertEquals(true, aClass.cdoWriteLock().isLockedByOthers());
+
+ // SWTBotTreeItem treeItem = selectFolder(tree.getAllItems(), "BClass", false);
+ // assertEquals(DawnColorConstants.COLOR_LOCKED_REMOTELY, treeItem.foregroundColor());
+
+ editor.close();
+ }
+
+ @Test
+ public void testAClassLockLocally() throws Exception
+ {
+ DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openNewAcoreEMFEditor("default.acore", getBot());
+ assertNotNull(editor);
+ SWTBotTree tree = editor.getSelectionPageTree();
+
+ selectFolder(tree.getAllItems(), "ACore Root", false);
+
+ editor.clickContextMenu(tree.widget, "AClass");
+ editor.save();
+
+ selectFolder(tree.getAllItems(), "AClass", false);
+
+ editor.clickContextMenu(tree.widget, "Lock");
+ sleep(500);
+
+ IDawnEditor dawnEditor = (IDawnEditor)editor.getReference().getEditor(false);
+ CDOResource resource = dawnEditor.getDawnEditorSupport().getView().getResource("/default.acore");
+ AClass aClass = ((ACoreRoot)resource.getContents().get(0)).getClasses().get(0);
+ assertEquals(true, aClass.cdoWriteLock().isLocked());
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore");
+ AClass aClass2 = ((ACoreRoot)resource2.getContents().get(0)).getClasses().get(0);
+ assertEquals(true, aClass2.cdoWriteLock().isLockedByOthers());
+
+ sleep(500);
+
+ editor.clickContextMenu(tree.widget, "Unlock");
+ sleep(500);
+
+ assertEquals(false, aClass.cdoWriteLock().isLocked());
+ assertEquals(false, aClass2.cdoWriteLock().isLockedByOthers());
+
+ // SWTBotTreeItem treeItem = selectFolder(tree.getAllItems(), "AClass", false);
+ // assertEquals(DawnColorConstants.COLOR_LOCKED_LOCALLY, treeItem.foregroundColor());
+
+ editor.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/ConflictTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/ConflictTest.java index c44cc7a0c6..10fff544f9 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/ConflictTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/ConflictTest.java @@ -1,200 +1,200 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.gmf; - -import org.eclipse.emf.cdo.dawn.examples.acore.AClass; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; - -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; - -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.Edge; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.List; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class ConflictTest extends AbstractDawnGEFTest -{ - @Test - public void testAClassConflictMove() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - editor.save(); - - editor.drag(100, 100, 200, 200); - - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - assertEquals(1, diagram.getChildren().size()); - - Node nodeA = (Node)diagram.getChildren().get(0); - - DawnSWTBotUtil.moveNodeRemotely(nodeA, 200, 300); - - transaction.commit(); - } - sleep(500); - - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - SWTBotGefEditPart classBEditpart = aClassEditParts.get(0); - - assertEquals(true, DawnAcoreTestUtil.showsConflict(classBEditpart.part())); - } - - @Test - public void testAClassConflictbyRemoteNameChange() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - editor.save(); - - SWTBotGefEditPart swtBotGefEditPart = DawnAcoreTestUtil.getAClassEditParts(editor).get(0); - final Node node = (Node)swtBotGefEditPart.part().getModel(); - - EditingDomain editingDomain = ((IEditingDomainProvider)node.eResource().getResourceSet()).getEditingDomain(); - - editingDomain.getCommandStack().execute(new RecordingCommand((TransactionalEditingDomain)editingDomain) - { - @Override - protected void doExecute() - { - ((AClass)node.getElement()).setName("myName"); - } - }); - - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - assertEquals(1, diagram.getChildren().size()); - - Node nodeA = (Node)diagram.getChildren().get(0); - AClass aClass = (AClass)nodeA.getElement(); - aClass.setName("newName"); - - transaction.commit(); - } - sleep(500); - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - SWTBotGefEditPart classBEditpart = aClassEditParts.get(0); - - assertEquals(true, DawnAcoreTestUtil.showsConflict(classBEditpart.part())); - } - - @Test - public void testAInterfaceConflictMove() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 100, 100, "A", getBot(), editor); - editor.save(); - - editor.drag(100, 100, 200, 200); - - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - assertEquals(1, diagram.getChildren().size()); - - Node nodeA = (Node)diagram.getChildren().get(0); - - DawnSWTBotUtil.moveNodeRemotely(nodeA, 200, 300); - - transaction.commit(); - } - sleep(500); - List<SWTBotGefEditPart> interfaceEditParts = DawnAcoreTestUtil.getAInterfaceEditParts(editor); - SWTBotGefEditPart interfaceEditpart = interfaceEditParts.get(0); - - assertEquals(true, DawnAcoreTestUtil.showsConflict(interfaceEditpart.part())); - } - - @Test - public void testAAssociationConflict() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor); - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - - Node nodeA = (Node)aClassEditParts.get(0).part().getModel(); - Node nodeB = (Node)aClassEditParts.get(1).part().getModel(); - - createEdge(DawnAcoreTestUtil.CONNECTION_ASSOCIATION, nodeA, nodeB, editor); - editor.save(); - - List<SWTBotGefEditPart> aClassAssociationsEditParts = DawnAcoreTestUtil.getAClassAssociationsEditParts(editor); - - DawnSWTBotUtil.addBendPoint((Edge)aClassAssociationsEditParts.get(0).part().getModel(), 0, 100, -100, 0); - - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - try - { - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - Diagram diagram = (Diagram)resource2.getContents().get(0); - - Edge edge = (Edge)diagram.getEdges().get(0); - DawnSWTBotUtil.addBendPoint(edge, 0, 100, -100, 0); - - transaction.commit(); - } - catch (Exception ex) - { - throw new RuntimeException(ex); - } - finally - { - transaction.close(); - } - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.gmf;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class ConflictTest extends AbstractDawnGEFTest
+{
+ @Test
+ public void testAClassConflictMove() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ editor.save();
+
+ editor.drag(100, 100, 200, 200);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+
+ DawnSWTBotUtil.moveNodeRemotely(nodeA, 200, 300);
+
+ transaction.commit();
+ }
+ sleep(500);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+
+ assertEquals(true, DawnAcoreTestUtil.showsConflict(classBEditpart.part()));
+ }
+
+ @Test
+ public void testAClassConflictbyRemoteNameChange() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ editor.save();
+
+ SWTBotGefEditPart swtBotGefEditPart = DawnAcoreTestUtil.getAClassEditParts(editor).get(0);
+ final Node node = (Node)swtBotGefEditPart.part().getModel();
+
+ EditingDomain editingDomain = ((IEditingDomainProvider)node.eResource().getResourceSet()).getEditingDomain();
+
+ editingDomain.getCommandStack().execute(new RecordingCommand((TransactionalEditingDomain)editingDomain)
+ {
+ @Override
+ protected void doExecute()
+ {
+ ((AClass)node.getElement()).setName("myName");
+ }
+ });
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ AClass aClass = (AClass)nodeA.getElement();
+ aClass.setName("newName");
+
+ transaction.commit();
+ }
+ sleep(500);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+
+ assertEquals(true, DawnAcoreTestUtil.showsConflict(classBEditpart.part()));
+ }
+
+ @Test
+ public void testAInterfaceConflictMove() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 100, 100, "A", getBot(), editor);
+ editor.save();
+
+ editor.drag(100, 100, 200, 200);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+
+ DawnSWTBotUtil.moveNodeRemotely(nodeA, 200, 300);
+
+ transaction.commit();
+ }
+ sleep(500);
+ List<SWTBotGefEditPart> interfaceEditParts = DawnAcoreTestUtil.getAInterfaceEditParts(editor);
+ SWTBotGefEditPart interfaceEditpart = interfaceEditParts.get(0);
+
+ assertEquals(true, DawnAcoreTestUtil.showsConflict(interfaceEditpart.part()));
+ }
+
+ @Test
+ public void testAAssociationConflict() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aClassEditParts.get(1).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_ASSOCIATION, nodeA, nodeB, editor);
+ editor.save();
+
+ List<SWTBotGefEditPart> aClassAssociationsEditParts = DawnAcoreTestUtil.getAClassAssociationsEditParts(editor);
+
+ DawnSWTBotUtil.addBendPoint((Edge)aClassAssociationsEditParts.get(0).part().getModel(), 0, 100, -100, 0);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ try
+ {
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Edge edge = (Edge)diagram.getEdges().get(0);
+ DawnSWTBotUtil.addBendPoint(edge, 0, 100, -100, 0);
+
+ transaction.commit();
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ finally
+ {
+ transaction.close();
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/DawnBasicGMFUITest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/DawnBasicGMFUITest.java index 6593caa37d..241e373b8a 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/DawnBasicGMFUITest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/DawnBasicGMFUITest.java @@ -1,91 +1,91 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.gmf; - -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.DawnAcoreDiagramEditor; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.DawnAcoreDiagramEditorUtil; -import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput; -import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.AbstractCDOTest; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -public class DawnBasicGMFUITest extends AbstractCDOTest -{ - @Override - public void doSetUp() throws Exception - { - super.doSetUp(); - getRepositoryConfig().getRepositoryProperties().put("overrideUUID", ""); - } - - public void testGetEditorIdForDawnEditor() - { - final CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource = transaction.createResource("/test.acore_diagram"); //$NON-NLS-1$ - - String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName()); - assertEquals(DawnAcoreDiagramEditor.ID, editorID); - } - - public void testEditorInput() throws PartInitException - { - final CDOSession session = openSession(); - - CDOTransaction transaction = session.openTransaction(); - CDOResource resource = transaction.createResource("/sample/test.acore_diagram"); //$NON-NLS-1$ - - String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName()); - assertEquals(DawnAcoreDiagramEditor.ID, editorID); - DawnEditorInput editorInput = new DawnEditorInput(resource.getURI()); - editorInput.setResource(resource); - - assertEquals(resource, editorInput.getResource()); - assertEquals(resource.getPath(), editorInput.getResourcePath()); - assertEquals(transaction, editorInput.getView()); - assertEquals(resource.getURI(), editorInput.getURI()); - assertEquals(false, editorInput.isViewOwned()); - } - - public void testOpenEditor() throws PartInitException - { - final CDOSession session = openSession(); - DawnAcoreDiagramEditorUtil.createDiagram(URI.createURI("dawn://repo1//test.acore_diagram"), - URI.createURI("cdo://repo1/test.acore"), new NullProgressMonitor()); - - CDOTransaction transaction = session.openTransaction(); - CDOResource resource = transaction.createResource("/test.acore_diagram"); - - String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName()); - assertEquals(DawnAcoreDiagramEditor.ID, editorID); - - DawnEditorInput editorInput = new DawnEditorInput(resource.getURI()); - - IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite() - .getPage().openEditor(editorInput, editorID); - - assertInstanceOf(DawnAcoreDiagramEditor.class, editor); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.gmf;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.DawnAcoreDiagramEditor;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.DawnAcoreDiagramEditorUtil;
+import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput;
+import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+public class DawnBasicGMFUITest extends AbstractCDOTest
+{
+ @Override
+ public void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ getRepositoryConfig().getRepositoryProperties().put("overrideUUID", "");
+ }
+
+ public void testGetEditorIdForDawnEditor()
+ {
+ final CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test.acore_diagram"); //$NON-NLS-1$
+
+ String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName());
+ assertEquals(DawnAcoreDiagramEditor.ID, editorID);
+ }
+
+ public void testEditorInput() throws PartInitException
+ {
+ final CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/sample/test.acore_diagram"); //$NON-NLS-1$
+
+ String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName());
+ assertEquals(DawnAcoreDiagramEditor.ID, editorID);
+ DawnEditorInput editorInput = new DawnEditorInput(resource.getURI());
+ editorInput.setResource(resource);
+
+ assertEquals(resource, editorInput.getResource());
+ assertEquals(resource.getPath(), editorInput.getResourcePath());
+ assertEquals(transaction, editorInput.getView());
+ assertEquals(resource.getURI(), editorInput.getURI());
+ assertEquals(false, editorInput.isViewOwned());
+ }
+
+ public void testOpenEditor() throws PartInitException
+ {
+ final CDOSession session = openSession();
+ DawnAcoreDiagramEditorUtil.createDiagram(URI.createURI("dawn://repo1//test.acore_diagram"),
+ URI.createURI("cdo://repo1/test.acore"), new NullProgressMonitor());
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test.acore_diagram");
+
+ String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName());
+ assertEquals(DawnAcoreDiagramEditor.ID, editorID);
+
+ DawnEditorInput editorInput = new DawnEditorInput(resource.getURI());
+
+ IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite()
+ .getPage().openEditor(editorInput, editorID);
+
+ assertInstanceOf(DawnAcoreDiagramEditor.class, editor);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/DawnCreationWizardSWTBotTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/DawnCreationWizardSWTBotTest.java index 4d4bedcaeb..8441be690b 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/DawnCreationWizardSWTBotTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/DawnCreationWizardSWTBotTest.java @@ -1,349 +1,349 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.gmf; - -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; - -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.keyboard.Keyboard; -import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory; -import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; -import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; - -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class DawnCreationWizardSWTBotTest extends AbstractDawnGEFTest -{ - private String resourceFieldLabel = org.eclipse.emf.cdo.dawn.ui.messages.Messages.DawnCreateNewResourceWizardPage_6; - - @Test - public void testCreateNewDawnDiagram() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram"); - getBot().button("Next >").click(); - getBot().button("Finish").click(); - - SWTBotGefEditor editor = getBot().gefEditor("default.acore_diagram"); - assertNotNull(editor); - editor.close(); - { - assertEquals(true, resourceExists("/default.acore")); - assertEquals(true, resourceExists("/default.acore_diagram")); - } - } - - @Test - public void testCreateNewDawnDiagramBothPages() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram"); - - getBot().button("Next >").click(); - getBot().button("Next >").click(); - getBot().button("Finish").click(); - - SWTBotGefEditor editor = getBot().gefEditor("default.acore_diagram"); - assertNotNull(editor); - editor.close(); - - { - assertEquals(true, resourceExists("/default.acore")); - assertEquals(true, resourceExists("/default.acore_diagram")); - } - } - - @Test - public void testCreateNewDawnDiagramBothPagesSetName() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram"); - getBot().button("Next >").click(); - - shell = getBot().shell("New Acore Diagram"); - shell.activate(); - - SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel); - fileNameLabel.setText("test.acore_diagram"); - - getBot().button("Next >").click(); - - SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel); - assertEquals("test.acore", fileSemanticNameLabel.getText()); - - getBot().button("Finish").click(); - - SWTBotGefEditor editor = getBot().gefEditor("test.acore_diagram"); - assertNotNull(editor); - editor.close(); - } - - @Test - public void testCreateNewDawnDiagramBothPagesSetDifferenNames() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram"); - getBot().button("Next >").click(); - - shell = getBot().shell("New Acore Diagram"); - shell.activate(); - - SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel); - fileNameLabel.setText("notational.acore_diagram"); - - getBot().button("Next >").click(); - - SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel); - assertEquals("notational.acore", fileSemanticNameLabel.getText()); - - fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel); - fileSemanticNameLabel.setText("semantic.acore"); - - fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel); - assertEquals("semantic.acore", fileSemanticNameLabel.getText()); - - getBot().button("Finish").click(); - - SWTBotGefEditor editor = getBot().gefEditor("notational.acore_diagram"); - assertNotNull(editor); - editor.close(); - - { - assertEquals(true, resourceExists("/semantic.acore")); - assertEquals(true, resourceExists("/notational.acore_diagram")); - } - } - - @Test - public void testCreateNewDawnDiagramEmptyNotationalResourceName() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram"); - getBot().button("Next >").click(); - - shell = getBot().shell("New Acore Diagram"); - shell.activate(); - - SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel); - fileNameLabel.setText(""); - - Keyboard keyboard = KeyboardFactory.getDefaultKeyboard(fileNameLabel.widget, null); - fileNameLabel.setFocus(); - fileNameLabel.typeText("x", 500); - keyboard.pressShortcut(Keystrokes.BS); - assertEquals(false, getBot().button("Next >").isEnabled()); - getBot().button("Cancel").click(); - } - - @Test - public void testCreateNewDawnDiagramEmptySemanticResourceName() throws Exception - { - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram"); - getBot().button("Next >").click(); - - shell = getBot().shell("New Acore Diagram"); - shell.activate(); - - SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel); - fileNameLabel.setText("notational.acore_diagram"); - - getBot().button("Next >").click(); - - SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel); - SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; - Keyboard keyboard = KeyboardFactory.getDefaultKeyboard(fileSemanticNameLabel.widget, null); - fileSemanticNameLabel.setFocus(); - fileSemanticNameLabel.typeText("x", 500); - - keyboard.pressShortcut(Keystrokes.BS); - assertEquals(false, getBot().button("Next >").isEnabled()); - getBot().button("Cancel").click(); - } - - @Test - public void testCreateNewDawnDiagramSelectFolder() throws Exception - { - { - CDOSession session = openSession(); - ResourceSet resourceSet = new ResourceSetImpl(); - CDOTransaction transaction = session.openTransaction(resourceSet); - - final URI uri = URI.createURI("cdo:/folder/dummy"); - resourceSet.createResource(uri); - transaction.commit(); - } - - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram"); - getBot().button("Next >").click(); - - shell = getBot().shell("New Acore Diagram"); - shell.activate(); - - SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel); - fileNameLabel.setText("test.acore_diagram"); - - SWTBotTree tree = getBot().tree(0); - - selectFolder(tree.getAllItems(), "folder", false); - getBot().button("Next >").click(); - - SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel); - assertEquals("test.acore", fileSemanticNameLabel.getText()); - - getBot().button("Finish").click(); - - SWTBotGefEditor editor = getBot().gefEditor("test.acore_diagram"); - assertNotNull(editor); - editor.close(); - - { - assertEquals(true, resourceExists("/folder/test.acore")); - assertEquals(true, resourceExists("/folder/test.acore_diagram")); - } - } - - @Test - public void testCreateNewDawnDiagramTypeFolder() throws Exception - { - { - CDOSession session = openSession(); - ResourceSet resourceSet = new ResourceSetImpl(); - CDOTransaction transaction = session.openTransaction(resourceSet); - - final URI uri = URI.createURI("cdo:/folder/dummy"); - resourceSet.createResource(uri); - transaction.commit(); - } - - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram"); - getBot().button("Next >").click(); - - shell = getBot().shell("New Acore Diagram"); - shell.activate(); - - SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel); - fileNameLabel.setText("test.acore_diagram"); - - SWTBotText folder = getBot().textWithLabel("Enter or select the parent folder: "); - folder.setText("/folder"); - SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; - - getBot().button("Next >").click(); - - SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel); - assertEquals("test.acore", fileSemanticNameLabel.getText()); - - getBot().button("Finish").click(); - - SWTBotGefEditor editor = getBot().gefEditor("test.acore_diagram"); - assertNotNull(editor); - editor.close(); - - { - assertEquals(true, resourceExists("/folder/test.acore")); - assertEquals(true, resourceExists("/folder/test.acore_diagram")); - } - } - - @Test - public void testCreateNewDawnDiagramSelectDifferentFolders() throws Exception - { - { - CDOSession session = openSession(); - ResourceSet resourceSet = new ResourceSetImpl(); - CDOTransaction transaction = session.openTransaction(resourceSet); - - resourceSet.createResource(URI.createURI("cdo:/folder1/dummy")); - resourceSet.createResource(URI.createURI("cdo:/folder2/dummy")); - - transaction.commit(); - } - - getBot().menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = getBot().shell("New"); - shell.activate(); - getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram"); - getBot().button("Next >").click(); - - shell = getBot().shell("New Acore Diagram"); - shell.activate(); - - SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel); - fileNameLabel.setText("test.acore_diagram"); - - SWTBotTree tree = getBot().tree(0); - - selectFolder(tree.getAllItems(), "folder1", false); - getBot().button("Next >").click(); - - SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel); - assertEquals("test.acore", fileSemanticNameLabel.getText()); - - tree = getBot().tree(0); - selectFolder(tree.getAllItems(), "folder2", false); - - getBot().button("Finish").click(); - - SWTBotGefEditor editor = getBot().gefEditor("test.acore_diagram"); - assertNotNull(editor); - editor.close(); - - { - assertEquals(true, resourceExists("/folder1/test.acore_diagram")); - assertEquals(true, resourceExists("/folder2/test.acore")); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.gmf;
+
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.keyboard.Keyboard;
+import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory;
+import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class DawnCreationWizardSWTBotTest extends AbstractDawnGEFTest
+{
+ private String resourceFieldLabel = org.eclipse.emf.cdo.dawn.ui.messages.Messages.DawnCreateNewResourceWizardPage_6;
+
+ @Test
+ public void testCreateNewDawnDiagram() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+ getBot().button("Next >").click();
+ getBot().button("Finish").click();
+
+ SWTBotGefEditor editor = getBot().gefEditor("default.acore_diagram");
+ assertNotNull(editor);
+ editor.close();
+ {
+ assertEquals(true, resourceExists("/default.acore"));
+ assertEquals(true, resourceExists("/default.acore_diagram"));
+ }
+ }
+
+ @Test
+ public void testCreateNewDawnDiagramBothPages() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+
+ getBot().button("Next >").click();
+ getBot().button("Next >").click();
+ getBot().button("Finish").click();
+
+ SWTBotGefEditor editor = getBot().gefEditor("default.acore_diagram");
+ assertNotNull(editor);
+ editor.close();
+
+ {
+ assertEquals(true, resourceExists("/default.acore"));
+ assertEquals(true, resourceExists("/default.acore_diagram"));
+ }
+ }
+
+ @Test
+ public void testCreateNewDawnDiagramBothPagesSetName() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New Acore Diagram");
+ shell.activate();
+
+ SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ fileNameLabel.setText("test.acore_diagram");
+
+ getBot().button("Next >").click();
+
+ SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ assertEquals("test.acore", fileSemanticNameLabel.getText());
+
+ getBot().button("Finish").click();
+
+ SWTBotGefEditor editor = getBot().gefEditor("test.acore_diagram");
+ assertNotNull(editor);
+ editor.close();
+ }
+
+ @Test
+ public void testCreateNewDawnDiagramBothPagesSetDifferenNames() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New Acore Diagram");
+ shell.activate();
+
+ SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ fileNameLabel.setText("notational.acore_diagram");
+
+ getBot().button("Next >").click();
+
+ SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ assertEquals("notational.acore", fileSemanticNameLabel.getText());
+
+ fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ fileSemanticNameLabel.setText("semantic.acore");
+
+ fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ assertEquals("semantic.acore", fileSemanticNameLabel.getText());
+
+ getBot().button("Finish").click();
+
+ SWTBotGefEditor editor = getBot().gefEditor("notational.acore_diagram");
+ assertNotNull(editor);
+ editor.close();
+
+ {
+ assertEquals(true, resourceExists("/semantic.acore"));
+ assertEquals(true, resourceExists("/notational.acore_diagram"));
+ }
+ }
+
+ @Test
+ public void testCreateNewDawnDiagramEmptyNotationalResourceName() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New Acore Diagram");
+ shell.activate();
+
+ SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ fileNameLabel.setText("");
+
+ Keyboard keyboard = KeyboardFactory.getDefaultKeyboard(fileNameLabel.widget, null);
+ fileNameLabel.setFocus();
+ fileNameLabel.typeText("x", 500);
+ keyboard.pressShortcut(Keystrokes.BS);
+ assertEquals(false, getBot().button("Next >").isEnabled());
+ getBot().button("Cancel").click();
+ }
+
+ @Test
+ public void testCreateNewDawnDiagramEmptySemanticResourceName() throws Exception
+ {
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New Acore Diagram");
+ shell.activate();
+
+ SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ fileNameLabel.setText("notational.acore_diagram");
+
+ getBot().button("Next >").click();
+
+ SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
+ Keyboard keyboard = KeyboardFactory.getDefaultKeyboard(fileSemanticNameLabel.widget, null);
+ fileSemanticNameLabel.setFocus();
+ fileSemanticNameLabel.typeText("x", 500);
+
+ keyboard.pressShortcut(Keystrokes.BS);
+ assertEquals(false, getBot().button("Next >").isEnabled());
+ getBot().button("Cancel").click();
+ }
+
+ @Test
+ public void testCreateNewDawnDiagramSelectFolder() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ final URI uri = URI.createURI("cdo:/folder/dummy");
+ resourceSet.createResource(uri);
+ transaction.commit();
+ }
+
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New Acore Diagram");
+ shell.activate();
+
+ SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ fileNameLabel.setText("test.acore_diagram");
+
+ SWTBotTree tree = getBot().tree(0);
+
+ selectFolder(tree.getAllItems(), "folder", false);
+ getBot().button("Next >").click();
+
+ SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ assertEquals("test.acore", fileSemanticNameLabel.getText());
+
+ getBot().button("Finish").click();
+
+ SWTBotGefEditor editor = getBot().gefEditor("test.acore_diagram");
+ assertNotNull(editor);
+ editor.close();
+
+ {
+ assertEquals(true, resourceExists("/folder/test.acore"));
+ assertEquals(true, resourceExists("/folder/test.acore_diagram"));
+ }
+ }
+
+ @Test
+ public void testCreateNewDawnDiagramTypeFolder() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ final URI uri = URI.createURI("cdo:/folder/dummy");
+ resourceSet.createResource(uri);
+ transaction.commit();
+ }
+
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New Acore Diagram");
+ shell.activate();
+
+ SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ fileNameLabel.setText("test.acore_diagram");
+
+ SWTBotText folder = getBot().textWithLabel("Enter or select the parent folder: ");
+ folder.setText("/folder");
+ SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
+
+ getBot().button("Next >").click();
+
+ SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ assertEquals("test.acore", fileSemanticNameLabel.getText());
+
+ getBot().button("Finish").click();
+
+ SWTBotGefEditor editor = getBot().gefEditor("test.acore_diagram");
+ assertNotNull(editor);
+ editor.close();
+
+ {
+ assertEquals(true, resourceExists("/folder/test.acore"));
+ assertEquals(true, resourceExists("/folder/test.acore_diagram"));
+ }
+ }
+
+ @Test
+ public void testCreateNewDawnDiagramSelectDifferentFolders() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ resourceSet.createResource(URI.createURI("cdo:/folder1/dummy"));
+ resourceSet.createResource(URI.createURI("cdo:/folder2/dummy"));
+
+ transaction.commit();
+ }
+
+ getBot().menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = getBot().shell("New");
+ shell.activate();
+ getBot().tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+ getBot().button("Next >").click();
+
+ shell = getBot().shell("New Acore Diagram");
+ shell.activate();
+
+ SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ fileNameLabel.setText("test.acore_diagram");
+
+ SWTBotTree tree = getBot().tree(0);
+
+ selectFolder(tree.getAllItems(), "folder1", false);
+ getBot().button("Next >").click();
+
+ SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel);
+ assertEquals("test.acore", fileSemanticNameLabel.getText());
+
+ tree = getBot().tree(0);
+ selectFolder(tree.getAllItems(), "folder2", false);
+
+ getBot().button("Finish").click();
+
+ SWTBotGefEditor editor = getBot().gefEditor("test.acore_diagram");
+ assertNotNull(editor);
+ editor.close();
+
+ {
+ assertEquals(true, resourceExists("/folder1/test.acore_diagram"));
+ assertEquals(true, resourceExists("/folder2/test.acore"));
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/DawnCreationWizardTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/DawnCreationWizardTest.java index 6d9819081d..1892918c4f 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/DawnCreationWizardTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/DawnCreationWizardTest.java @@ -1,331 +1,331 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.gmf; - -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.DawnAcoreCreationWizard; -import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper; -import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite.ResourceChooserValidator; -import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewDiagramResourceWizardPage; -import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewResourceWizardPage; -import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.AbstractCDOTest; -import org.eclipse.emf.cdo.transaction.CDOTransaction; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; - -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Text; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -/** - * @author Martin Fluegge - */ -public class DawnCreationWizardTest extends AbstractCDOTest -{ - public void testCreationWizardSetWrongDiagramName() throws Exception - { - CDOSession session = openSession(); - CDOConnectionUtil.instance.openView(session); - - DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard(); - - WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard); - dialog.create(); - - IWizardPage[] pages = creationWizard.getPages(); - - DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0]; - dawnDiagramModelFilePage.setVisible(true); - assertNotNull(dawnDiagramModelFilePage); - assertInstanceOf(DawnCreateNewResourceWizardPage.class, dawnDiagramModelFilePage); - assertEquals(true, dawnDiagramModelFilePage.isPageComplete()); - assertEquals("", dawnDiagramModelFilePage.getResourcePath()); - assertEquals("default", dawnDiagramModelFilePage.getResourceNamePrefix()); - assertEquals("dawn://repo1//default.acore_diagram", dawnDiagramModelFilePage.getURI().toString()); - - callValidatePage(dawnDiagramModelFilePage); - assertEquals(true, dawnDiagramModelFilePage.isPageComplete()); - - dawnDiagramModelFilePage.setResourceNamePrefix(""); - callValidatePage(dawnDiagramModelFilePage); - assertEquals(false, dawnDiagramModelFilePage.isPageComplete()); - - dawnDiagramModelFilePage.setResourceNamePrefix("myDiagram"); - callValidatePage(dawnDiagramModelFilePage); - assertEquals(true, dawnDiagramModelFilePage.isPageComplete()); - } - - public void testCreationWizardSetWrongSemanticNameWarn_Default() throws Exception - { - CDOSession session = openSession(); - CDOConnectionUtil.instance.openView(session); - - DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard(); - WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard); - dialog.create(); - - IWizardPage[] pages = creationWizard.getPages(); - - DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0]; - DawnCreateNewResourceWizardPage dawnDomainModelFilePage = (DawnCreateNewResourceWizardPage)dawnDiagramModelFilePage - .getNextPage(); - - dawnDomainModelFilePage.setVisible(true); - - callValidatePage(dawnDomainModelFilePage); - assertEquals(true, dawnDomainModelFilePage.isPageComplete()); - - dawnDomainModelFilePage.setResourceNamePrefix(""); - callValidatePage(dawnDomainModelFilePage); - assertEquals("", getResourceText(dawnDomainModelFilePage).getText()); - assertEquals(true, dawnDomainModelFilePage.isPageComplete()); - - dawnDomainModelFilePage.setResourceNamePrefix("something.acore"); - callValidatePage(dawnDomainModelFilePage); - assertEquals(true, dawnDomainModelFilePage.isPageComplete()); - - assertEquals("something.acore", dawnDomainModelFilePage.getDefaultName()); - } - - public void testCreationWizardSetWrongSemanticNameError() throws Exception - { - CDOSession session = openSession(); - CDOConnectionUtil.instance.openView(session); - - DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard(); - WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard); - dialog.create(); - - IWizardPage[] pages = creationWizard.getPages(); - - DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0]; - DawnCreateNewResourceWizardPage dawnDomainModelFilePage = (DawnCreateNewResourceWizardPage)dawnDiagramModelFilePage - .getNextPage(); - - dawnDomainModelFilePage.setVisible(true); - dawnDomainModelFilePage.setResourceValidationType(ResourceChooserValidator.VALIDATION_ERROR); - - assertEquals(ResourceChooserValidator.VALIDATION_ERROR, dawnDiagramModelFilePage.getResourceValidationType()); - - dawnDomainModelFilePage.setResourceNamePrefix(""); - callValidatePage(dawnDomainModelFilePage); - - assertEquals("", getResourceText(dawnDomainModelFilePage).getText()); - assertEquals(false, dawnDomainModelFilePage.isPageComplete()); - } - - public void testCreationWizardCreateAutomaticName() throws Exception - { - { - CDOSession session = openSession(); - ResourceSet resourceSet = new ResourceSetImpl(); - CDOTransaction transaction = session.openTransaction(resourceSet); - - transaction.createResource("/default.acore_diagram"); - transaction.commit(); - transaction.close(); - } - - DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard(); - WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard); - dialog.create(); - - IWizardPage[] pages = creationWizard.getPages(); - - DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0]; - dawnDiagramModelFilePage.setCreateAutomaticResourceName(true); - dawnDiagramModelFilePage.setVisible(true); - - assertEquals("default2.acore_diagram", getResourceText(dawnDiagramModelFilePage).getText()); - } - - public void testCreationWizardSetExistingResourceError() throws Exception - { - { - CDOSession session = openSession(); - ResourceSet resourceSet = new ResourceSetImpl(); - CDOTransaction transaction = session.openTransaction(resourceSet); - - transaction.createResource("/default5.acore_diagram"); - transaction.commit(); - transaction.close(); - } - - DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard(); - WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard); - dialog.create(); - - IWizardPage[] pages = creationWizard.getPages(); - - DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0]; - dawnDiagramModelFilePage.setVisible(true); - dawnDiagramModelFilePage.setResourceValidationType(ResourceChooserValidator.VALIDATION_ERROR); - assertEquals(ResourceChooserValidator.VALIDATION_ERROR, dawnDiagramModelFilePage.getResourceValidationType()); - - dawnDiagramModelFilePage.setResourceNamePrefix("default5.acore_diagram"); - assertEquals("default5.acore_diagram", getResourceText(dawnDiagramModelFilePage).getText()); - callValidatePage(dawnDiagramModelFilePage); - assertEquals(false, dawnDiagramModelFilePage.isPageComplete()); - assertEquals("A resource with the same name already exists!", dawnDiagramModelFilePage.getErrorMessage()); - } - - public void testCreationWizardSetExistingResourceWarn() throws Exception - { - { - CDOSession session = openSession(); - ResourceSet resourceSet = new ResourceSetImpl(); - CDOTransaction transaction = session.openTransaction(resourceSet); - - transaction.createResource("/default5.acore_diagram"); - transaction.commit(); - transaction.close(); - } - - DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard(); - WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard); - dialog.create(); - - IWizardPage[] pages = creationWizard.getPages(); - - DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0]; - dawnDiagramModelFilePage.setVisible(true); - dawnDiagramModelFilePage.setResourceValidationType(ResourceChooserValidator.VALIDATION_WARN); - assertEquals(ResourceChooserValidator.VALIDATION_WARN, dawnDiagramModelFilePage.getResourceValidationType()); - - dawnDiagramModelFilePage.setResourceNamePrefix("default5.acore_diagram"); - assertEquals("default5.acore_diagram", getResourceText(dawnDiagramModelFilePage).getText()); - callValidatePage(dawnDiagramModelFilePage); - assertEquals(true, dawnDiagramModelFilePage.isPageComplete()); - assertEquals("A resource with the same name already exists!", dawnDiagramModelFilePage.getMessage()); - } - - public void testCreationWizardSetExistingResourceNone() throws Exception - { - { - CDOSession session = openSession(); - ResourceSet resourceSet = new ResourceSetImpl(); - CDOTransaction transaction = session.openTransaction(resourceSet); - - transaction.createResource("/default5.acore_diagram"); - transaction.commit(); - transaction.close(); - } - - DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard(); - WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard); - dialog.create(); - - IWizardPage[] pages = creationWizard.getPages(); - - DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0]; - dawnDiagramModelFilePage.setVisible(true); - dawnDiagramModelFilePage.setResourceValidationType(ResourceChooserValidator.VALIDATION_NONE); - assertEquals(ResourceChooserValidator.VALIDATION_NONE, dawnDiagramModelFilePage.getResourceValidationType()); - - dawnDiagramModelFilePage.setResourceNamePrefix("default5.acore_diagram"); - assertEquals("default5.acore_diagram", getResourceText(dawnDiagramModelFilePage).getText()); - callValidatePage(dawnDiagramModelFilePage); - assertEquals(true, dawnDiagramModelFilePage.isPageComplete()); - assertEquals(null, dawnDiagramModelFilePage.getErrorMessage()); - } - - public void testCreationWizardCreateResources() throws Exception - { - { - CDOSession session = openSession(); - ResourceSet resourceSet = new ResourceSetImpl(); - session.openTransaction(resourceSet); - - final URI uri = URI.createURI("cdo:/folder/dummy"); - resourceSet.createResource(uri); - } - - DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard(); - - WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard); - dialog.create(); - - IWizardPage[] pages = creationWizard.getPages(); - - DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0]; - dawnDiagramModelFilePage.setVisible(true); - assertNotNull(dawnDiagramModelFilePage); - assertInstanceOf(DawnCreateNewResourceWizardPage.class, dawnDiagramModelFilePage); - assertEquals(true, dawnDiagramModelFilePage.isPageComplete()); - assertEquals("", dawnDiagramModelFilePage.getResourcePath()); - assertEquals("default", dawnDiagramModelFilePage.getResourceNamePrefix()); - assertEquals("dawn://repo1//default.acore_diagram", dawnDiagramModelFilePage.getURI().toString()); - - // TODO create a folder here first - // set the resource path as a user would do - dawnDiagramModelFilePage.setResourcePath("/folder"); - assertEquals("/folder/", dawnDiagramModelFilePage.getResourcePath()); - assertEquals("dawn://repo1//folder//default.acore_diagram", dawnDiagramModelFilePage.getURI().toString()); - - callValidatePage(dawnDiagramModelFilePage); - assertEquals(true, dawnDiagramModelFilePage.isPageComplete()); - - DawnCreateNewResourceWizardPage dawnDomainModelFilePage = (DawnCreateNewResourceWizardPage)dawnDiagramModelFilePage - .getNextPage(); - dawnDiagramModelFilePage.setVisible(false); - dawnDomainModelFilePage.setVisible(true); - - callValidatePage(dawnDomainModelFilePage); - assertEquals(true, dawnDomainModelFilePage.isPageComplete()); - assertNotNull(dawnDomainModelFilePage); - assertInstanceOf(DawnCreateNewResourceWizardPage.class, dawnDomainModelFilePage); - assertEquals("default.acore", dawnDomainModelFilePage.getDefaultName()); - assertEquals("cdo://repo1/folder/default.acore", dawnDomainModelFilePage.getURI().toString()); - - boolean performFinish = creationWizard.performFinish(); - assertEquals(true, performFinish); - - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource semanticResource = transaction.getResource("/folder/default.acore"); - - CDOResource diagramResource = transaction.getResource("/folder/default.acore_diagram"); - assertNotNull(diagramResource); - Diagram diagramRoot = (Diagram)diagramResource.getContents().get(0); - assertEquals(semanticResource.getContents().get(0), diagramRoot.getElement()); - transaction.close(); - } - // cleanup - DawnEditorHelper.getActiveEditor().getSite().getPage().closeAllEditors(false); - } - - private void callValidatePage(DawnCreateNewResourceWizardPage page) throws Exception - { - Class<DawnCreateNewResourceWizardPage> clazz = DawnCreateNewResourceWizardPage.class; - java.lang.Class<Object>[] parameterType = null; - Method method = clazz.getDeclaredMethod("validatePage", parameterType); - method.setAccessible(true); - Object[] args = null; - method.invoke(page, args); - } - - private Text getResourceText(DawnCreateNewResourceWizardPage dawnDomainModelFilePage) throws Exception - { - Class<DawnCreateNewResourceWizardPage> clazz = DawnCreateNewResourceWizardPage.class; - Field field = clazz.getDeclaredField("resourceText"); - field.setAccessible(true); - return (Text)field.get(dawnDomainModelFilePage); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.gmf;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.DawnAcoreCreationWizard;
+import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper;
+import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite.ResourceChooserValidator;
+import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewDiagramResourceWizardPage;
+import org.eclipse.emf.cdo.dawn.ui.wizards.DawnCreateNewResourceWizardPage;
+import org.eclipse.emf.cdo.dawn.util.connection.CDOConnectionUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Text;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnCreationWizardTest extends AbstractCDOTest
+{
+ public void testCreationWizardSetWrongDiagramName() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOConnectionUtil.instance.openView(session);
+
+ DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard();
+
+ WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard);
+ dialog.create();
+
+ IWizardPage[] pages = creationWizard.getPages();
+
+ DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0];
+ dawnDiagramModelFilePage.setVisible(true);
+ assertNotNull(dawnDiagramModelFilePage);
+ assertInstanceOf(DawnCreateNewResourceWizardPage.class, dawnDiagramModelFilePage);
+ assertEquals(true, dawnDiagramModelFilePage.isPageComplete());
+ assertEquals("", dawnDiagramModelFilePage.getResourcePath());
+ assertEquals("default", dawnDiagramModelFilePage.getResourceNamePrefix());
+ assertEquals("dawn://repo1//default.acore_diagram", dawnDiagramModelFilePage.getURI().toString());
+
+ callValidatePage(dawnDiagramModelFilePage);
+ assertEquals(true, dawnDiagramModelFilePage.isPageComplete());
+
+ dawnDiagramModelFilePage.setResourceNamePrefix("");
+ callValidatePage(dawnDiagramModelFilePage);
+ assertEquals(false, dawnDiagramModelFilePage.isPageComplete());
+
+ dawnDiagramModelFilePage.setResourceNamePrefix("myDiagram");
+ callValidatePage(dawnDiagramModelFilePage);
+ assertEquals(true, dawnDiagramModelFilePage.isPageComplete());
+ }
+
+ public void testCreationWizardSetWrongSemanticNameWarn_Default() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOConnectionUtil.instance.openView(session);
+
+ DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard();
+ WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard);
+ dialog.create();
+
+ IWizardPage[] pages = creationWizard.getPages();
+
+ DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0];
+ DawnCreateNewResourceWizardPage dawnDomainModelFilePage = (DawnCreateNewResourceWizardPage)dawnDiagramModelFilePage
+ .getNextPage();
+
+ dawnDomainModelFilePage.setVisible(true);
+
+ callValidatePage(dawnDomainModelFilePage);
+ assertEquals(true, dawnDomainModelFilePage.isPageComplete());
+
+ dawnDomainModelFilePage.setResourceNamePrefix("");
+ callValidatePage(dawnDomainModelFilePage);
+ assertEquals("", getResourceText(dawnDomainModelFilePage).getText());
+ assertEquals(true, dawnDomainModelFilePage.isPageComplete());
+
+ dawnDomainModelFilePage.setResourceNamePrefix("something.acore");
+ callValidatePage(dawnDomainModelFilePage);
+ assertEquals(true, dawnDomainModelFilePage.isPageComplete());
+
+ assertEquals("something.acore", dawnDomainModelFilePage.getDefaultName());
+ }
+
+ public void testCreationWizardSetWrongSemanticNameError() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOConnectionUtil.instance.openView(session);
+
+ DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard();
+ WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard);
+ dialog.create();
+
+ IWizardPage[] pages = creationWizard.getPages();
+
+ DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0];
+ DawnCreateNewResourceWizardPage dawnDomainModelFilePage = (DawnCreateNewResourceWizardPage)dawnDiagramModelFilePage
+ .getNextPage();
+
+ dawnDomainModelFilePage.setVisible(true);
+ dawnDomainModelFilePage.setResourceValidationType(ResourceChooserValidator.VALIDATION_ERROR);
+
+ assertEquals(ResourceChooserValidator.VALIDATION_ERROR, dawnDiagramModelFilePage.getResourceValidationType());
+
+ dawnDomainModelFilePage.setResourceNamePrefix("");
+ callValidatePage(dawnDomainModelFilePage);
+
+ assertEquals("", getResourceText(dawnDomainModelFilePage).getText());
+ assertEquals(false, dawnDomainModelFilePage.isPageComplete());
+ }
+
+ public void testCreationWizardCreateAutomaticName() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ transaction.createResource("/default.acore_diagram");
+ transaction.commit();
+ transaction.close();
+ }
+
+ DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard();
+ WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard);
+ dialog.create();
+
+ IWizardPage[] pages = creationWizard.getPages();
+
+ DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0];
+ dawnDiagramModelFilePage.setCreateAutomaticResourceName(true);
+ dawnDiagramModelFilePage.setVisible(true);
+
+ assertEquals("default2.acore_diagram", getResourceText(dawnDiagramModelFilePage).getText());
+ }
+
+ public void testCreationWizardSetExistingResourceError() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ transaction.createResource("/default5.acore_diagram");
+ transaction.commit();
+ transaction.close();
+ }
+
+ DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard();
+ WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard);
+ dialog.create();
+
+ IWizardPage[] pages = creationWizard.getPages();
+
+ DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0];
+ dawnDiagramModelFilePage.setVisible(true);
+ dawnDiagramModelFilePage.setResourceValidationType(ResourceChooserValidator.VALIDATION_ERROR);
+ assertEquals(ResourceChooserValidator.VALIDATION_ERROR, dawnDiagramModelFilePage.getResourceValidationType());
+
+ dawnDiagramModelFilePage.setResourceNamePrefix("default5.acore_diagram");
+ assertEquals("default5.acore_diagram", getResourceText(dawnDiagramModelFilePage).getText());
+ callValidatePage(dawnDiagramModelFilePage);
+ assertEquals(false, dawnDiagramModelFilePage.isPageComplete());
+ assertEquals("A resource with the same name already exists!", dawnDiagramModelFilePage.getErrorMessage());
+ }
+
+ public void testCreationWizardSetExistingResourceWarn() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ transaction.createResource("/default5.acore_diagram");
+ transaction.commit();
+ transaction.close();
+ }
+
+ DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard();
+ WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard);
+ dialog.create();
+
+ IWizardPage[] pages = creationWizard.getPages();
+
+ DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0];
+ dawnDiagramModelFilePage.setVisible(true);
+ dawnDiagramModelFilePage.setResourceValidationType(ResourceChooserValidator.VALIDATION_WARN);
+ assertEquals(ResourceChooserValidator.VALIDATION_WARN, dawnDiagramModelFilePage.getResourceValidationType());
+
+ dawnDiagramModelFilePage.setResourceNamePrefix("default5.acore_diagram");
+ assertEquals("default5.acore_diagram", getResourceText(dawnDiagramModelFilePage).getText());
+ callValidatePage(dawnDiagramModelFilePage);
+ assertEquals(true, dawnDiagramModelFilePage.isPageComplete());
+ assertEquals("A resource with the same name already exists!", dawnDiagramModelFilePage.getMessage());
+ }
+
+ public void testCreationWizardSetExistingResourceNone() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ transaction.createResource("/default5.acore_diagram");
+ transaction.commit();
+ transaction.close();
+ }
+
+ DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard();
+ WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard);
+ dialog.create();
+
+ IWizardPage[] pages = creationWizard.getPages();
+
+ DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0];
+ dawnDiagramModelFilePage.setVisible(true);
+ dawnDiagramModelFilePage.setResourceValidationType(ResourceChooserValidator.VALIDATION_NONE);
+ assertEquals(ResourceChooserValidator.VALIDATION_NONE, dawnDiagramModelFilePage.getResourceValidationType());
+
+ dawnDiagramModelFilePage.setResourceNamePrefix("default5.acore_diagram");
+ assertEquals("default5.acore_diagram", getResourceText(dawnDiagramModelFilePage).getText());
+ callValidatePage(dawnDiagramModelFilePage);
+ assertEquals(true, dawnDiagramModelFilePage.isPageComplete());
+ assertEquals(null, dawnDiagramModelFilePage.getErrorMessage());
+ }
+
+ public void testCreationWizardCreateResources() throws Exception
+ {
+ {
+ CDOSession session = openSession();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ session.openTransaction(resourceSet);
+
+ final URI uri = URI.createURI("cdo:/folder/dummy");
+ resourceSet.createResource(uri);
+ }
+
+ DawnAcoreCreationWizard creationWizard = new DawnAcoreCreationWizard();
+
+ WizardDialog dialog = new WizardDialog(DawnEditorHelper.getActiveShell(), creationWizard);
+ dialog.create();
+
+ IWizardPage[] pages = creationWizard.getPages();
+
+ DawnCreateNewDiagramResourceWizardPage dawnDiagramModelFilePage = (DawnCreateNewDiagramResourceWizardPage)pages[0];
+ dawnDiagramModelFilePage.setVisible(true);
+ assertNotNull(dawnDiagramModelFilePage);
+ assertInstanceOf(DawnCreateNewResourceWizardPage.class, dawnDiagramModelFilePage);
+ assertEquals(true, dawnDiagramModelFilePage.isPageComplete());
+ assertEquals("", dawnDiagramModelFilePage.getResourcePath());
+ assertEquals("default", dawnDiagramModelFilePage.getResourceNamePrefix());
+ assertEquals("dawn://repo1//default.acore_diagram", dawnDiagramModelFilePage.getURI().toString());
+
+ // TODO create a folder here first
+ // set the resource path as a user would do
+ dawnDiagramModelFilePage.setResourcePath("/folder");
+ assertEquals("/folder/", dawnDiagramModelFilePage.getResourcePath());
+ assertEquals("dawn://repo1//folder//default.acore_diagram", dawnDiagramModelFilePage.getURI().toString());
+
+ callValidatePage(dawnDiagramModelFilePage);
+ assertEquals(true, dawnDiagramModelFilePage.isPageComplete());
+
+ DawnCreateNewResourceWizardPage dawnDomainModelFilePage = (DawnCreateNewResourceWizardPage)dawnDiagramModelFilePage
+ .getNextPage();
+ dawnDiagramModelFilePage.setVisible(false);
+ dawnDomainModelFilePage.setVisible(true);
+
+ callValidatePage(dawnDomainModelFilePage);
+ assertEquals(true, dawnDomainModelFilePage.isPageComplete());
+ assertNotNull(dawnDomainModelFilePage);
+ assertInstanceOf(DawnCreateNewResourceWizardPage.class, dawnDomainModelFilePage);
+ assertEquals("default.acore", dawnDomainModelFilePage.getDefaultName());
+ assertEquals("cdo://repo1/folder/default.acore", dawnDomainModelFilePage.getURI().toString());
+
+ boolean performFinish = creationWizard.performFinish();
+ assertEquals(true, performFinish);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource semanticResource = transaction.getResource("/folder/default.acore");
+
+ CDOResource diagramResource = transaction.getResource("/folder/default.acore_diagram");
+ assertNotNull(diagramResource);
+ Diagram diagramRoot = (Diagram)diagramResource.getContents().get(0);
+ assertEquals(semanticResource.getContents().get(0), diagramRoot.getElement());
+ transaction.close();
+ }
+ // cleanup
+ DawnEditorHelper.getActiveEditor().getSite().getPage().closeAllEditors(false);
+ }
+
+ private void callValidatePage(DawnCreateNewResourceWizardPage page) throws Exception
+ {
+ Class<DawnCreateNewResourceWizardPage> clazz = DawnCreateNewResourceWizardPage.class;
+ java.lang.Class<Object>[] parameterType = null;
+ Method method = clazz.getDeclaredMethod("validatePage", parameterType);
+ method.setAccessible(true);
+ Object[] args = null;
+ method.invoke(page, args);
+ }
+
+ private Text getResourceText(DawnCreateNewResourceWizardPage dawnDomainModelFilePage) throws Exception
+ {
+ Class<DawnCreateNewResourceWizardPage> clazz = DawnCreateNewResourceWizardPage.class;
+ Field field = clazz.getDeclaredField("resourceText");
+ field.setAccessible(true);
+ return (Text)field.get(dawnDomainModelFilePage);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/GMFLockingTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/GMFLockingTest.java index 9a2e9cf655..153ec2e21e 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/GMFLockingTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/GMFLockingTest.java @@ -1,128 +1,128 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.gmf; - -import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil; -import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.util.CDOUtil; - -import org.eclipse.gef.EditPart; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.ui.IEditorPart; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class GMFLockingTest extends AbstractDawnGEFTest -{ - @Test - public void testAClassLockRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - editor.save(); - - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - assertEquals(1, diagram.getChildren().size()); - - Node nodeA = (Node)diagram.getChildren().get(0); - - CDOUtil.getCDOObject(nodeA).cdoWriteLock().lock(); - } - sleep(500); - - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - SWTBotGefEditPart classBEditpart = aClassEditParts.get(0); - - assertEquals(true, DawnAcoreTestUtil.showsLock(classBEditpart.part(), DawnColorConstants.COLOR_LOCKED_REMOTELY)); - } - - @Test - public void testAClassLockLocally() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - editor.save(); - - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - SWTBotGefEditPart classBEditpart = aClassEditParts.get(0); - EditPart part = classBEditpart.part(); - - List<Object> toBeLocked = new ArrayList<Object>(); - toBeLocked.add(part); - - IEditorPart editorPart = editor.getReference().getEditor(false); - ((IDawnEditor)editorPart).getDawnEditorSupport().lockObjects(toBeLocked); - - assertEquals(true, DawnAcoreTestUtil.showsLock(part, DawnColorConstants.COLOR_LOCKED_LOCALLY)); - } - - @Test - public void testAClassUnlockRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - editor.save(); - - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - assertEquals(1, diagram.getChildren().size()); - - Node nodeA = (Node)diagram.getChildren().get(0); - - CDOUtil.getCDOObject(nodeA).cdoWriteLock().lock(); - - sleep(500); - - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - SWTBotGefEditPart classBEditpart = aClassEditParts.get(0); - - assertEquals(true, DawnAcoreTestUtil.showsLock(classBEditpart.part(), DawnColorConstants.COLOR_LOCKED_REMOTELY)); - - CDOUtil.getCDOObject(nodeA).cdoWriteLock().unlock(); - - assertEquals(true, DawnAcoreTestUtil.showsNoLock(classBEditpart.part())); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.gmf;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.ui.IEditorPart;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class GMFLockingTest extends AbstractDawnGEFTest
+{
+ @Test
+ public void testAClassLockRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+
+ CDOUtil.getCDOObject(nodeA).cdoWriteLock().lock();
+ }
+ sleep(500);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+
+ assertEquals(true, DawnAcoreTestUtil.showsLock(classBEditpart.part(), DawnColorConstants.COLOR_LOCKED_REMOTELY));
+ }
+
+ @Test
+ public void testAClassLockLocally() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ editor.save();
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+ EditPart part = classBEditpart.part();
+
+ List<Object> toBeLocked = new ArrayList<Object>();
+ toBeLocked.add(part);
+
+ IEditorPart editorPart = editor.getReference().getEditor(false);
+ ((IDawnEditor)editorPart).getDawnEditorSupport().lockObjects(toBeLocked);
+
+ assertEquals(true, DawnAcoreTestUtil.showsLock(part, DawnColorConstants.COLOR_LOCKED_LOCALLY));
+ }
+
+ @Test
+ public void testAClassUnlockRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ editor.save();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+
+ CDOUtil.getCDOObject(nodeA).cdoWriteLock().lock();
+
+ sleep(500);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+
+ assertEquals(true, DawnAcoreTestUtil.showsLock(classBEditpart.part(), DawnColorConstants.COLOR_LOCKED_REMOTELY));
+
+ CDOUtil.getCDOObject(nodeA).cdoWriteLock().unlock();
+
+ assertEquals(true, DawnAcoreTestUtil.showsNoLock(classBEditpart.part()));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/MultipleResourcesDeletionTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/MultipleResourcesDeletionTest.java index bf4e06bde9..7a8a9c7af2 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/MultipleResourcesDeletionTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/MultipleResourcesDeletionTest.java @@ -1,311 +1,311 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.gmf; - -import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.util.CommitException; - -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.gef.EditPart; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.Edge; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; - -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.List; - -/** - * @author Martin Fluegge - */ -@RunWith(SWTBotJunit4ClassRunner.class) -public class MultipleResourcesDeletionTest extends AbstractDawnGEFTest -{ - private static SWTGefBot bot; - - @BeforeClass - public static void beforeClass() throws Exception - { - bot = new SWTGefBot(); - DawnSWTBotUtil.initTest(bot); - } - - @Override - @Before - public void setUp() throws Exception - { - super.setUp(); - bot.viewByTitle("CDO Sessions").close(); - } - - @Override - @After - public void tearDown() throws Exception - { - // closeAllEditors(); - super.tearDown(); - } - - // @Test - public void testDeleteAClassRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor); - editor.save(); - - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - Node nodeA = (Node)diagram.getChildren().get(0); - EObject aClass = nodeA.getElement(); - - diagram.removeChild(nodeA); - ((ACoreRoot)diagram.getElement()).getClasses().remove(aClass); - - transaction.commit(); - DawnAcoreTestUtil.sleep(1000); - } - - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - assertEquals(0, aClassEditParts.size()); - Diagram diagram = (Diagram)editor.mainEditPart().part().getModel(); - ACoreRoot aCoreRoot = (ACoreRoot)diagram.getElement(); - - assertEquals(0, aCoreRoot.getClasses().size()); - editor.close(); - } - - // @Test - public void testDeleteAInterfaceRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot); - - createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 100, 100, "A", bot, editor); - editor.save(); - - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - Node nodeA = (Node)diagram.getChildren().get(0); - EObject element = nodeA.getElement(); - - diagram.removeChild(nodeA); - ((ACoreRoot)diagram.getElement()).getInterfaces().remove(element); - - transaction.commit(); - sleep(1000); - } - - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - assertEquals(0, aClassEditParts.size()); - Diagram diagram = (Diagram)editor.mainEditPart().part().getModel(); - ACoreRoot aCoreRoot = (ACoreRoot)diagram.getElement(); - - assertEquals(0, aCoreRoot.getInterfaces().size()); - editor.close(); - } - - @Test - public void testDeleteAssociationConnectionRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor); - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - - Node nodeA = (Node)aClassEditParts.get(0).part().getModel(); - Node nodeB = (Node)aClassEditParts.get(1).part().getModel(); - - createEdge(DawnAcoreTestUtil.CONNECTION_ASSOCIATION, nodeA, nodeB, editor); - editor.save(); - - deleteEdge(); - - List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part()); - assertEquals(0, connectionEditParts.size()); - sleep(1000); - } - - @SuppressWarnings("unchecked") - private List<Edge> getAllConnections(EditPart part) - { - Diagram diagram = (Diagram)part.getModel(); - return diagram.getEdges(); - } - - @Test - public void testDeleteCompositionConnectionRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor); - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - - Node nodeA = (Node)aClassEditParts.get(0).part().getModel(); - Node nodeB = (Node)aClassEditParts.get(1).part().getModel(); - - createEdge(DawnAcoreTestUtil.CONNECTION_COMPOSITION, nodeA, nodeB, editor); - editor.save(); - - deleteEdge(); - - List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part()); - assertEquals(0, connectionEditParts.size()); - } - - @Test - public void testDeleteInheritanceConnectionRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor); - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - - Node nodeA = (Node)aClassEditParts.get(0).part().getModel(); - Node nodeB = (Node)aClassEditParts.get(1).part().getModel(); - - createEdge(DawnAcoreTestUtil.CONNECTION_IHERITS, nodeA, nodeB, editor); - editor.save(); - - deleteEdge(); - - List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part()); - assertEquals(0, connectionEditParts.size()); - } - - @Test - public void testDeleteImplementsConnectionRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor); - createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 200, 200, "B", bot, editor); - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - List<SWTBotGefEditPart> aInterfaceEditParts = DawnAcoreTestUtil.getAInterfaceEditParts(editor); - - Node nodeA = (Node)aClassEditParts.get(0).part().getModel(); - Node nodeB = (Node)aInterfaceEditParts.get(0).part().getModel(); - - createEdge(DawnAcoreTestUtil.CONNECTION_IMPLEMENTS, nodeA, nodeB, editor); - editor.save(); - - deleteEdge(); - - List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part()); - assertEquals(0, connectionEditParts.size()); - } - - @Test - public void testDeleteAggregationConnectionRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor); - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - - Node nodeA = (Node)aClassEditParts.get(0).part().getModel(); - Node nodeB = (Node)aClassEditParts.get(1).part().getModel(); - - createEdge(DawnAcoreTestUtil.CONNECTION_AGGREGATION, nodeA, nodeB, editor); - editor.save(); - - deleteEdge(); - - List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part()); - assertEquals(0, connectionEditParts.size()); - } - - private void deleteEdge() throws CommitException - { - { - CDOSession session = openSession("repo1"); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - Edge edge = (Edge)diagram.getEdges().get(0); - edge.setSource(null); - edge.setTarget(null); - diagram.removeEdge(edge); - transaction.commit(); - - sleep(1000); - } - } - /** - * left for future reference - */ - // private class EdgeDeletionThread extends Thread - // { - // private final CountDownLatch cdl; - // - // public EdgeDeletionThread(CountDownLatch cdl) - // { - // this.cdl = cdl; - // setDaemon(true); - // } - // - // @Override - // public void run() - // { - // CDOSession session = openSession(); - // CDOTransaction transaction = session.openTransaction(); - // CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - // - // Diagram diagram = (Diagram)resource2.getContents().get(0); - // - // Edge edge = (Edge)diagram.getEdges().get(0); - // diagram.removeEdge(edge); - // try - // { - // transaction.commit(); - // } - // catch (CommitException ex) - // { - // throw new RuntimeException(ex); - // } - // finally - // { - // transaction.close(); - // cdl.countDown(); - // } - // } - // } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.gmf;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class MultipleResourcesDeletionTest extends AbstractDawnGEFTest
+{
+ private static SWTGefBot bot;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception
+ {
+ bot = new SWTGefBot();
+ DawnSWTBotUtil.initTest(bot);
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ bot.viewByTitle("CDO Sessions").close();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ // closeAllEditors();
+ super.tearDown();
+ }
+
+ // @Test
+ public void testDeleteAClassRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ EObject aClass = nodeA.getElement();
+
+ diagram.removeChild(nodeA);
+ ((ACoreRoot)diagram.getElement()).getClasses().remove(aClass);
+
+ transaction.commit();
+ DawnAcoreTestUtil.sleep(1000);
+ }
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ assertEquals(0, aClassEditParts.size());
+ Diagram diagram = (Diagram)editor.mainEditPart().part().getModel();
+ ACoreRoot aCoreRoot = (ACoreRoot)diagram.getElement();
+
+ assertEquals(0, aCoreRoot.getClasses().size());
+ editor.close();
+ }
+
+ // @Test
+ public void testDeleteAInterfaceRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 100, 100, "A", bot, editor);
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ EObject element = nodeA.getElement();
+
+ diagram.removeChild(nodeA);
+ ((ACoreRoot)diagram.getElement()).getInterfaces().remove(element);
+
+ transaction.commit();
+ sleep(1000);
+ }
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ assertEquals(0, aClassEditParts.size());
+ Diagram diagram = (Diagram)editor.mainEditPart().part().getModel();
+ ACoreRoot aCoreRoot = (ACoreRoot)diagram.getElement();
+
+ assertEquals(0, aCoreRoot.getInterfaces().size());
+ editor.close();
+ }
+
+ @Test
+ public void testDeleteAssociationConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aClassEditParts.get(1).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_ASSOCIATION, nodeA, nodeB, editor);
+ editor.save();
+
+ deleteEdge();
+
+ List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part());
+ assertEquals(0, connectionEditParts.size());
+ sleep(1000);
+ }
+
+ @SuppressWarnings("unchecked")
+ private List<Edge> getAllConnections(EditPart part)
+ {
+ Diagram diagram = (Diagram)part.getModel();
+ return diagram.getEdges();
+ }
+
+ @Test
+ public void testDeleteCompositionConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aClassEditParts.get(1).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_COMPOSITION, nodeA, nodeB, editor);
+ editor.save();
+
+ deleteEdge();
+
+ List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part());
+ assertEquals(0, connectionEditParts.size());
+ }
+
+ @Test
+ public void testDeleteInheritanceConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aClassEditParts.get(1).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_IHERITS, nodeA, nodeB, editor);
+ editor.save();
+
+ deleteEdge();
+
+ List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part());
+ assertEquals(0, connectionEditParts.size());
+ }
+
+ @Test
+ public void testDeleteImplementsConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 200, 200, "B", bot, editor);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ List<SWTBotGefEditPart> aInterfaceEditParts = DawnAcoreTestUtil.getAInterfaceEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aInterfaceEditParts.get(0).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_IMPLEMENTS, nodeA, nodeB, editor);
+ editor.save();
+
+ deleteEdge();
+
+ List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part());
+ assertEquals(0, connectionEditParts.size());
+ }
+
+ @Test
+ public void testDeleteAggregationConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aClassEditParts.get(1).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_AGGREGATION, nodeA, nodeB, editor);
+ editor.save();
+
+ deleteEdge();
+
+ List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part());
+ assertEquals(0, connectionEditParts.size());
+ }
+
+ private void deleteEdge() throws CommitException
+ {
+ {
+ CDOSession session = openSession("repo1");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Edge edge = (Edge)diagram.getEdges().get(0);
+ edge.setSource(null);
+ edge.setTarget(null);
+ diagram.removeEdge(edge);
+ transaction.commit();
+
+ sleep(1000);
+ }
+ }
+ /**
+ * left for future reference
+ */
+ // private class EdgeDeletionThread extends Thread
+ // {
+ // private final CountDownLatch cdl;
+ //
+ // public EdgeDeletionThread(CountDownLatch cdl)
+ // {
+ // this.cdl = cdl;
+ // setDaemon(true);
+ // }
+ //
+ // @Override
+ // public void run()
+ // {
+ // CDOSession session = openSession();
+ // CDOTransaction transaction = session.openTransaction();
+ // CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+ //
+ // Diagram diagram = (Diagram)resource2.getContents().get(0);
+ //
+ // Edge edge = (Edge)diagram.getEdges().get(0);
+ // diagram.removeEdge(edge);
+ // try
+ // {
+ // transaction.commit();
+ // }
+ // catch (CommitException ex)
+ // {
+ // throw new RuntimeException(ex);
+ // }
+ // finally
+ // {
+ // transaction.close();
+ // cdl.countDown();
+ // }
+ // }
+ // }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/MultipleResourcesTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/MultipleResourcesTest.java index 966259fbb8..e1e1caca79 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/MultipleResourcesTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/MultipleResourcesTest.java @@ -1,498 +1,498 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.gmf; - -import org.eclipse.emf.cdo.dawn.examples.acore.AClass; -import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot; -import org.eclipse.emf.cdo.dawn.examples.acore.AcoreFactory; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassAggregationsEditPart; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassAssociationsEditPart; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassCompositionsEditPart; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassImplementedInterfacesEditPart; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassSubClassesEditPart; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; - -import org.eclipse.emf.ecore.util.EcoreUtil; - -import org.eclipse.gef.EditPart; -import org.eclipse.gmf.runtime.notation.Bounds; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.Edge; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.gmf.runtime.notation.NotationFactory; -import org.eclipse.gmf.runtime.notation.RelativeBendpoints; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class MultipleResourcesTest extends AbstractDawnGEFTest -{ - @Test - public void testRemotelyRenameAClass() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - - editor.save(); - - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 250, 100, "B", getBot(), editor); - - editor.save(); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - assertEquals(2, diagram.getChildren().size()); - - View nodeB = (View)diagram.getChildren().get(1); - - AClass classB = (AClass)nodeB.getElement(); - - assertEquals("B", classB.getName()); - - classB.setName("C"); - transaction.commit(); - - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - SWTBotGefEditPart classBEditpart = aClassEditParts.get(1); - AClass editorClassB = (AClass)((View)classBEditpart.part().getModel()).getElement(); - assertEquals("C", editorClassB.getName()); - } - - @Test - public void testRemotelyMoveNode() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - - editor.save(); - - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - assertEquals(1, diagram.getChildren().size()); - - Node nodeA = (Node)diagram.getChildren().get(0); - - Bounds bounds = (Bounds)nodeA.getLayoutConstraint(); - bounds.setHeight(40); - bounds.setWidth(30); - bounds.setX(200); - bounds.setY(250); - - transaction.commit(); - - sleep(500); - - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - SWTBotGefEditPart classBEditpart = aClassEditParts.get(0); - Node editorNodeA = (Node)classBEditpart.part().getModel(); - Bounds editorBounds = (Bounds)editorNodeA.getLayoutConstraint(); - - assertEquals(bounds.getX(), editorBounds.getX()); - assertEquals(bounds.getY(), editorBounds.getY()); - assertEquals(bounds.getWidth(), editorBounds.getWidth()); - assertEquals(bounds.getHeight(), editorBounds.getHeight()); - } - - @Test - public void testCreateNodeRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - editor.save(); - - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - ACoreRoot aCoreRoot = (ACoreRoot)diagram.getElement(); - - AClass newAClass = AcoreFactory.eINSTANCE.createAClass(); - newAClass.setName("A-Team"); - - aCoreRoot.getClasses().add(newAClass); - - Node newNode = DawnAcoreTestUtil.createNewAClassRemote(diagram, newAClass); - - newNode.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - Bounds bounds = (Bounds)newNode.getLayoutConstraint(); - bounds.setHeight(40); - bounds.setWidth(30); - bounds.setX(200); - bounds.setY(250); - - newNode.setElement(newAClass); - - assertEquals(1, diagram.getChildren().size()); - assertEquals(1, aCoreRoot.getClasses().size()); - - transaction.commit(); - - sleep(1000); - - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - - assertEquals(1, aClassEditParts.size()); - - SWTBotGefEditPart classBEditpart = aClassEditParts.get(0); - Node editorNewNode = (Node)classBEditpart.part().getModel(); - AClass editorNewAclass = (AClass)editorNewNode.getElement(); - - assertEquals("A-Team", editorNewAclass.getName()); - Bounds editorBounds = (Bounds)editorNewNode.getLayoutConstraint(); - - assertEquals(bounds.getX(), editorBounds.getX()); - assertEquals(bounds.getY(), editorBounds.getY()); - assertEquals(bounds.getWidth(), editorBounds.getWidth()); - assertEquals(bounds.getHeight(), editorBounds.getHeight()); - - } - - @Test - public void testAddNodeRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - - editor.save(); - - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - Node newNode = EcoreUtil.copy((Node)diagram.getChildren().get(0));// diagram.createChild(NotationPackage.eINSTANCE.getNode()); - - newNode.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - Bounds bounds = (Bounds)newNode.getLayoutConstraint(); - bounds.setHeight(40); - bounds.setWidth(30); - bounds.setX(200); - bounds.setY(250); - - AClass newAClass = AcoreFactory.eINSTANCE.createAClass(); - newAClass.setName("A-Team"); - newNode.setElement(newAClass); - - ACoreRoot aCoreRoot = (ACoreRoot)diagram.getElement(); - aCoreRoot.getClasses().add(newAClass); - - diagram.insertChild(newNode); - assertEquals(2, diagram.getChildren().size()); - assertEquals(2, aCoreRoot.getClasses().size()); - - transaction.commit(); - - sleep(1000); - - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - - assertEquals(2, aClassEditParts.size()); - - SWTBotGefEditPart classBEditpart = aClassEditParts.get(1); - Node editorNewNode = (Node)classBEditpart.part().getModel(); - AClass editorNewAclass = (AClass)editorNewNode.getElement(); - - assertEquals("A-Team", editorNewAclass.getName()); - Bounds editorBounds = (Bounds)editorNewNode.getLayoutConstraint(); - - assertEquals(bounds.getX(), editorBounds.getX()); - assertEquals(bounds.getY(), editorBounds.getY()); - assertEquals(bounds.getWidth(), editorBounds.getWidth()); - assertEquals(bounds.getHeight(), editorBounds.getHeight()); - } - - @Test - public void testModifyConnectionRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor); - - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - - Node nodeA = (Node)aClassEditParts.get(0).part().getModel(); - Node nodeB = (Node)aClassEditParts.get(1).part().getModel(); - - createEdge(DawnAcoreTestUtil.CONNECTION_ASSOCIATION, nodeA, nodeB, editor); - editor.save(); - - { - List<SWTBotGefEditPart> aaClassAssociationsEditParts = DawnAcoreTestUtil.getAClassAssociationsEditParts(editor); - assertEquals(1, aaClassAssociationsEditParts.size()); - EditPart part = aaClassAssociationsEditParts.get(0).part(); - Edge editorEdge = (Edge)part.getModel(); - assertEquals(2, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size()); - } - - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - List<?> edges = diagram.getEdges(); - assertEquals(1, edges.size()); - - Edge edge = (Edge)edges.get(0); - - RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0); - - RelativeBendpoints relativeBendpoints = (RelativeBendpoints)edge.getBendpoints(); - - @SuppressWarnings("unchecked") - List<RelativeBendpoint> points = relativeBendpoints.getPoints(); - List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(points); - newBendPoints.add(1, relativeBendpoint); - relativeBendpoints.setPoints(newBendPoints); - - transaction.commit(); - sleep(1000); - } - - List<SWTBotGefEditPart> aaClassAssociationsEditParts = DawnAcoreTestUtil.getAClassAssociationsEditParts(editor); - assertEquals(1, aaClassAssociationsEditParts.size()); - EditPart part = aaClassAssociationsEditParts.get(0).part(); - Edge editorEdge = (Edge)part.getModel(); - assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size()); - } - - @Test - public void testCreateAssociationConnectionRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor); - - editor.save(); - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - Node nodeA = (Node)diagram.getChildren().get(0); - Node nodeB = (Node)diagram.getChildren().get(1); - - List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(); - - RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0); - newBendPoints.add(relativeBendpoint); - - Edge edge = DawnAcoreTestUtil.createNewAssociationRemote(nodeA, nodeB, newBendPoints); - - assertNotNull(edge); - transaction.commit(); - sleep(1000); - } - List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor); - assertEquals(1, connectionEditParts.size()); - EditPart part = connectionEditParts.get(0).part(); - assertInstanceOf(AClassAssociationsEditPart.class, part); - assertInstanceOf(Edge.class, part.getModel()); - Edge editorEdge = (Edge)part.getModel(); - assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size()); - } - - @Test - public void testCreateAggregationConnectionRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor); - editor.save(); - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - Node nodeA = (Node)diagram.getChildren().get(0); - Node nodeB = (Node)diagram.getChildren().get(1); - - List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(); - - RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0); - newBendPoints.add(relativeBendpoint); - - Edge edge = DawnAcoreTestUtil.createNewAggregationRemote(nodeA, nodeB, newBendPoints); - - assertNotNull(edge); - transaction.commit(); - sleep(1000); - } - List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor); - assertEquals(1, connectionEditParts.size()); - EditPart part = connectionEditParts.get(0).part(); - assertInstanceOf(AClassAggregationsEditPart.class, part); - assertInstanceOf(Edge.class, part.getModel()); - Edge editorEdge = (Edge)part.getModel(); - assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size()); - } - - @Test - public void testCreateCompositionConnectionRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor); - - editor.save(); - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - Node nodeA = (Node)diagram.getChildren().get(0); - Node nodeB = (Node)diagram.getChildren().get(1); - - List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(); - - RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0); - newBendPoints.add(relativeBendpoint); - - Edge edge = DawnAcoreTestUtil.createNewCompositionRemote(nodeA, nodeB, newBendPoints); - - assertNotNull(edge); - transaction.commit(); - sleep(1000); - } - List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor); - assertEquals(1, connectionEditParts.size()); - EditPart part = connectionEditParts.get(0).part(); - assertInstanceOf(AClassCompositionsEditPart.class, part); - assertInstanceOf(Edge.class, part.getModel()); - Edge editorEdge = (Edge)part.getModel(); - assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size()); - } - - @Test - public void testCreateInheritanceConnectionRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor); - - editor.save(); - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - Node nodeA = (Node)diagram.getChildren().get(0); - Node nodeB = (Node)diagram.getChildren().get(1); - - List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(); - - RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0); - newBendPoints.add(relativeBendpoint); - - Edge edge = DawnAcoreTestUtil.createNewInheritanceRelationRemote(nodeA, nodeB, newBendPoints); - - assertNotNull(edge); - transaction.commit(); - sleep(1000); - } - List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor); - assertEquals(1, connectionEditParts.size()); - EditPart part = connectionEditParts.get(0).part(); - assertInstanceOf(AClassSubClassesEditPart.class, part); - assertInstanceOf(Edge.class, part.getModel()); - Edge editorEdge = (Edge)part.getModel(); - assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size()); - } - - @Test - public void testCreateImplementsConnectionRemotely() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - - createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor); - - editor.save(); - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - Node nodeA = (Node)diagram.getChildren().get(0); - Node nodeB = (Node)diagram.getChildren().get(1); - - List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(); - - RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0); - newBendPoints.add(relativeBendpoint); - - Edge edge = DawnAcoreTestUtil.createNewImplementsRelationRemote(nodeA, nodeB, newBendPoints); - - assertNotNull(edge); - transaction.commit(); - sleep(1000); - } - List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor); - assertEquals(1, connectionEditParts.size()); - EditPart part = connectionEditParts.get(0).part(); - assertInstanceOf(AClassImplementedInterfacesEditPart.class, part); - assertInstanceOf(Edge.class, part.getModel()); - Edge editorEdge = (Edge)part.getModel(); - assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size()); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.gmf;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
+import org.eclipse.emf.cdo.dawn.examples.acore.AcoreFactory;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassAggregationsEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassAssociationsEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassCompositionsEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassImplementedInterfacesEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassSubClassesEditPart;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class MultipleResourcesTest extends AbstractDawnGEFTest
+{
+ @Test
+ public void testRemotelyRenameAClass() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+
+ editor.save();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 250, 100, "B", getBot(), editor);
+
+ editor.save();
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(2, diagram.getChildren().size());
+
+ View nodeB = (View)diagram.getChildren().get(1);
+
+ AClass classB = (AClass)nodeB.getElement();
+
+ assertEquals("B", classB.getName());
+
+ classB.setName("C");
+ transaction.commit();
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(1);
+ AClass editorClassB = (AClass)((View)classBEditpart.part().getModel()).getElement();
+ assertEquals("C", editorClassB.getName());
+ }
+
+ @Test
+ public void testRemotelyMoveNode() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+
+ editor.save();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+
+ Bounds bounds = (Bounds)nodeA.getLayoutConstraint();
+ bounds.setHeight(40);
+ bounds.setWidth(30);
+ bounds.setX(200);
+ bounds.setY(250);
+
+ transaction.commit();
+
+ sleep(500);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+ Node editorNodeA = (Node)classBEditpart.part().getModel();
+ Bounds editorBounds = (Bounds)editorNodeA.getLayoutConstraint();
+
+ assertEquals(bounds.getX(), editorBounds.getX());
+ assertEquals(bounds.getY(), editorBounds.getY());
+ assertEquals(bounds.getWidth(), editorBounds.getWidth());
+ assertEquals(bounds.getHeight(), editorBounds.getHeight());
+ }
+
+ @Test
+ public void testCreateNodeRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+ editor.save();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ ACoreRoot aCoreRoot = (ACoreRoot)diagram.getElement();
+
+ AClass newAClass = AcoreFactory.eINSTANCE.createAClass();
+ newAClass.setName("A-Team");
+
+ aCoreRoot.getClasses().add(newAClass);
+
+ Node newNode = DawnAcoreTestUtil.createNewAClassRemote(diagram, newAClass);
+
+ newNode.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ Bounds bounds = (Bounds)newNode.getLayoutConstraint();
+ bounds.setHeight(40);
+ bounds.setWidth(30);
+ bounds.setX(200);
+ bounds.setY(250);
+
+ newNode.setElement(newAClass);
+
+ assertEquals(1, diagram.getChildren().size());
+ assertEquals(1, aCoreRoot.getClasses().size());
+
+ transaction.commit();
+
+ sleep(1000);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ assertEquals(1, aClassEditParts.size());
+
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+ Node editorNewNode = (Node)classBEditpart.part().getModel();
+ AClass editorNewAclass = (AClass)editorNewNode.getElement();
+
+ assertEquals("A-Team", editorNewAclass.getName());
+ Bounds editorBounds = (Bounds)editorNewNode.getLayoutConstraint();
+
+ assertEquals(bounds.getX(), editorBounds.getX());
+ assertEquals(bounds.getY(), editorBounds.getY());
+ assertEquals(bounds.getWidth(), editorBounds.getWidth());
+ assertEquals(bounds.getHeight(), editorBounds.getHeight());
+
+ }
+
+ @Test
+ public void testAddNodeRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+
+ editor.save();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node newNode = EcoreUtil.copy((Node)diagram.getChildren().get(0));// diagram.createChild(NotationPackage.eINSTANCE.getNode());
+
+ newNode.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ Bounds bounds = (Bounds)newNode.getLayoutConstraint();
+ bounds.setHeight(40);
+ bounds.setWidth(30);
+ bounds.setX(200);
+ bounds.setY(250);
+
+ AClass newAClass = AcoreFactory.eINSTANCE.createAClass();
+ newAClass.setName("A-Team");
+ newNode.setElement(newAClass);
+
+ ACoreRoot aCoreRoot = (ACoreRoot)diagram.getElement();
+ aCoreRoot.getClasses().add(newAClass);
+
+ diagram.insertChild(newNode);
+ assertEquals(2, diagram.getChildren().size());
+ assertEquals(2, aCoreRoot.getClasses().size());
+
+ transaction.commit();
+
+ sleep(1000);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ assertEquals(2, aClassEditParts.size());
+
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(1);
+ Node editorNewNode = (Node)classBEditpart.part().getModel();
+ AClass editorNewAclass = (AClass)editorNewNode.getElement();
+
+ assertEquals("A-Team", editorNewAclass.getName());
+ Bounds editorBounds = (Bounds)editorNewNode.getLayoutConstraint();
+
+ assertEquals(bounds.getX(), editorBounds.getX());
+ assertEquals(bounds.getY(), editorBounds.getY());
+ assertEquals(bounds.getWidth(), editorBounds.getWidth());
+ assertEquals(bounds.getHeight(), editorBounds.getHeight());
+ }
+
+ @Test
+ public void testModifyConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aClassEditParts.get(1).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_ASSOCIATION, nodeA, nodeB, editor);
+ editor.save();
+
+ {
+ List<SWTBotGefEditPart> aaClassAssociationsEditParts = DawnAcoreTestUtil.getAClassAssociationsEditParts(editor);
+ assertEquals(1, aaClassAssociationsEditParts.size());
+ EditPart part = aaClassAssociationsEditParts.get(0).part();
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(2, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
+ }
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+ List<?> edges = diagram.getEdges();
+ assertEquals(1, edges.size());
+
+ Edge edge = (Edge)edges.get(0);
+
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0);
+
+ RelativeBendpoints relativeBendpoints = (RelativeBendpoints)edge.getBendpoints();
+
+ @SuppressWarnings("unchecked")
+ List<RelativeBendpoint> points = relativeBendpoints.getPoints();
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(points);
+ newBendPoints.add(1, relativeBendpoint);
+ relativeBendpoints.setPoints(newBendPoints);
+
+ transaction.commit();
+ sleep(1000);
+ }
+
+ List<SWTBotGefEditPart> aaClassAssociationsEditParts = DawnAcoreTestUtil.getAClassAssociationsEditParts(editor);
+ assertEquals(1, aaClassAssociationsEditParts.size());
+ EditPart part = aaClassAssociationsEditParts.get(0).part();
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
+ }
+
+ @Test
+ public void testCreateAssociationConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor);
+
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ Node nodeB = (Node)diagram.getChildren().get(1);
+
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>();
+
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0);
+ newBendPoints.add(relativeBendpoint);
+
+ Edge edge = DawnAcoreTestUtil.createNewAssociationRemote(nodeA, nodeB, newBendPoints);
+
+ assertNotNull(edge);
+ transaction.commit();
+ sleep(1000);
+ }
+ List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor);
+ assertEquals(1, connectionEditParts.size());
+ EditPart part = connectionEditParts.get(0).part();
+ assertInstanceOf(AClassAssociationsEditPart.class, part);
+ assertInstanceOf(Edge.class, part.getModel());
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
+ }
+
+ @Test
+ public void testCreateAggregationConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor);
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ Node nodeB = (Node)diagram.getChildren().get(1);
+
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>();
+
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0);
+ newBendPoints.add(relativeBendpoint);
+
+ Edge edge = DawnAcoreTestUtil.createNewAggregationRemote(nodeA, nodeB, newBendPoints);
+
+ assertNotNull(edge);
+ transaction.commit();
+ sleep(1000);
+ }
+ List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor);
+ assertEquals(1, connectionEditParts.size());
+ EditPart part = connectionEditParts.get(0).part();
+ assertInstanceOf(AClassAggregationsEditPart.class, part);
+ assertInstanceOf(Edge.class, part.getModel());
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
+ }
+
+ @Test
+ public void testCreateCompositionConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor);
+
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ Node nodeB = (Node)diagram.getChildren().get(1);
+
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>();
+
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0);
+ newBendPoints.add(relativeBendpoint);
+
+ Edge edge = DawnAcoreTestUtil.createNewCompositionRemote(nodeA, nodeB, newBendPoints);
+
+ assertNotNull(edge);
+ transaction.commit();
+ sleep(1000);
+ }
+ List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor);
+ assertEquals(1, connectionEditParts.size());
+ EditPart part = connectionEditParts.get(0).part();
+ assertInstanceOf(AClassCompositionsEditPart.class, part);
+ assertInstanceOf(Edge.class, part.getModel());
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
+ }
+
+ @Test
+ public void testCreateInheritanceConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor);
+
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ Node nodeB = (Node)diagram.getChildren().get(1);
+
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>();
+
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0);
+ newBendPoints.add(relativeBendpoint);
+
+ Edge edge = DawnAcoreTestUtil.createNewInheritanceRelationRemote(nodeA, nodeB, newBendPoints);
+
+ assertNotNull(edge);
+ transaction.commit();
+ sleep(1000);
+ }
+ List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor);
+ assertEquals(1, connectionEditParts.size());
+ EditPart part = connectionEditParts.get(0).part();
+ assertInstanceOf(AClassSubClassesEditPart.class, part);
+ assertInstanceOf(Edge.class, part.getModel());
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
+ }
+
+ @Test
+ public void testCreateImplementsConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", getBot(), editor);
+
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ Node nodeB = (Node)diagram.getChildren().get(1);
+
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>();
+
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0);
+ newBendPoints.add(relativeBendpoint);
+
+ Edge edge = DawnAcoreTestUtil.createNewImplementsRelationRemote(nodeA, nodeB, newBendPoints);
+
+ assertNotNull(edge);
+ transaction.commit();
+ sleep(1000);
+ }
+ List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor);
+ assertEquals(1, connectionEditParts.size());
+ EditPart part = connectionEditParts.get(0).part();
+ assertInstanceOf(AClassImplementedInterfacesEditPart.class, part);
+ assertInstanceOf(Edge.class, part.getModel());
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/RollbackTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/RollbackTest.java index 221221716f..362781195f 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/RollbackTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/RollbackTest.java @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.gmf; - -import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.transaction.CDOTransaction; - -import org.eclipse.gef.EditPart; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.List; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class RollbackTest extends AbstractDawnGEFTest -{ - @Test - public void testGMFAClassConflictMove() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - editor.save(); - - editor.drag(100, 100, 200, 200); - - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource2 = transaction.getResource("/default.acore_diagram"); - - Diagram diagram = (Diagram)resource2.getContents().get(0); - - assertEquals(1, diagram.getChildren().size()); - - Node nodeA = (Node)diagram.getChildren().get(0); - - DawnSWTBotUtil.moveNodeRemotely(nodeA, 200, 300); - - transaction.commit(); - } - sleep(500); - - List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor); - SWTBotGefEditPart classBEditpart = aClassEditParts.get(0); - - assertEquals(true, DawnAcoreTestUtil.showsConflict(classBEditpart.part())); - editor.clickContextMenu("Solve Conflict"); - - getBot().button("yes").click(); - - assertEquals(false, ((IDawnEditor)editor.getReference().getEditor(false)).getView().hasConflict()); - - EditPart part = DawnAcoreTestUtil.getAClassEditParts(editor).get(0).part(); - - assertEquals(true, DawnSWTBotUtil.checkNodePosition((Node)part.getModel(), 200, 300)); - - editor.save(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.gmf;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class RollbackTest extends AbstractDawnGEFTest
+{
+ @Test
+ public void testGMFAClassConflictMove() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ editor.save();
+
+ editor.drag(100, 100, 200, 200);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+
+ DawnSWTBotUtil.moveNodeRemotely(nodeA, 200, 300);
+
+ transaction.commit();
+ }
+ sleep(500);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+
+ assertEquals(true, DawnAcoreTestUtil.showsConflict(classBEditpart.part()));
+ editor.clickContextMenu("Solve Conflict");
+
+ getBot().button("yes").click();
+
+ assertEquals(false, ((IDawnEditor)editor.getReference().getEditor(false)).getView().hasConflict());
+
+ EditPart part = DawnAcoreTestUtil.getAClassEditParts(editor).get(0).part();
+
+ assertEquals(true, DawnSWTBotUtil.checkNodePosition((Node)part.getModel(), 200, 300));
+
+ editor.save();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/SimpleDiagramTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/SimpleDiagramTest.java index 6cf7f78ed0..d2e93fcea1 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/SimpleDiagramTest.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/SimpleDiagramTest.java @@ -1,361 +1,361 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.gmf; - -import org.eclipse.emf.cdo.dawn.examples.acore.AAttribute; -import org.eclipse.emf.cdo.dawn.examples.acore.AClass; -import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot; -import org.eclipse.emf.cdo.dawn.examples.acore.AInterface; -import org.eclipse.emf.cdo.dawn.examples.acore.AOperation; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart; -import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest; -import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher; - -import org.hamcrest.Description; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Martin Fluegge - */ -@CleanRepositoriesBefore -@RunWith(SWTBotJunit4ClassRunner.class) -public class SimpleDiagramTest extends AbstractDawnGEFTest -{ - @Test - public void testCreateNewDawnDiagramAndAddElements() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 250, 100, "B", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 150, 250, "C", getBot(), editor); - - editor.saveAndClose(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.acore_diagram"); - CDOResource semanticResource = view.getResource("/default.acore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - ACoreRoot semanticRoot = (ACoreRoot)semanticResource.getContents().get(0); - - assertEquals(3, diagram.getChildren().size()); - assertEquals(3, semanticRoot.getClasses().size()); - - Character name = 'A'; - - for (AClass aClass : semanticRoot.getClasses()) - { - assertEquals(name.toString(), aClass.getName()); - name++; - } - } - } - - @Test - public void testCreateNewDawnDiagramAndAddElementsWithEdges() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 250, 100, "B", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 150, 250, "C", getBot(), editor); - - createEdge(DawnAcoreTestUtil.CONNECTION_IHERITS, 100, 100, 250, 100, editor); - createEdge(DawnAcoreTestUtil.CONNECTION_IHERITS, 100, 100, 150, 250, editor); - - List<SWTBotGefEditPart> connectionEditParts = getAllConnections(editor); - - assertEquals(2, connectionEditParts.size()); - - editor.save(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.acore_diagram"); - - CDOResource semanticResource = view.getResource("/default.acore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - ACoreRoot semanticRoot = (ACoreRoot)semanticResource.getContents().get(0); - - assertEquals(3, diagram.getChildren().size()); - assertEquals(3, semanticRoot.getClasses().size()); - - Character name = 'A'; - - for (AClass aClass : semanticRoot.getClasses()) - { - assertEquals(name.toString(), aClass.getName()); - name++; - } - view.close(); - } - - // for (SWTBotGefEditPart ep : connectionEditParts) - // { - // ConnectionEditPart connectionEditPart = (ConnectionEditPart)ep.part(); - // Connection connection = (Connection)connectionEditPart.getFigure(); - // - // Point midpoint = connection.getPoints().getMidpoint().getCopy(); - // - // editor.click(midpoint.x, midpoint.y); - // editor.drag(midpoint.x, midpoint.y, 0, 20); - // } - // editor.save(); - // editor.close(); - } - - @Test - public void testAClassWithAttributes() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - - editor.activateTool(DawnAcoreTestUtil.A_ATTRIBUTE); - editor.click(100, 100); - - typeTextToFocusedWidget("public foo:int", getBot(), true); - editor.save(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.acore_diagram"); - - CDOResource semanticResource = view.getResource("/default.acore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - ACoreRoot semanticRoot = (ACoreRoot)semanticResource.getContents().get(0); - - assertEquals(1, diagram.getChildren().size()); - - AClass aClass = semanticRoot.getClasses().get(0); - - assertEquals(1, aClass.getAttributes().size()); - - AAttribute aAttribute = aClass.getAttributes().get(0); - - assertEquals("public", aAttribute.getAccessright().toString()); - assertEquals("int", aAttribute.getDataType().toString()); - assertEquals("foo", aAttribute.getName()); - } - } - - @Test - public void testAClassWithOperations() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - - editor.activateTool(DawnAcoreTestUtil.A_OPERATION); - editor.click(100, 100); - - typeTextToFocusedWidget("public foo():int", getBot(), true); - editor.save(); - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.acore_diagram"); - - CDOResource semanticResource = view.getResource("/default.acore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - ACoreRoot semanticRoot = (ACoreRoot)semanticResource.getContents().get(0); - - assertEquals(1, diagram.getChildren().size()); - - AClass aClass = semanticRoot.getClasses().get(0); - - assertEquals(1, aClass.getOperations().size()); - - AOperation aOperation = aClass.getOperations().get(0); - assertEquals("foo", aOperation.getName()); - assertEquals("public", aOperation.getAccessright().toString()); - assertEquals("int", aOperation.getDataType().toString()); - } - } - - @Test - public void testAInterfaceWithOperations() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 100, 100, "A", getBot(), editor); - - editor.activateTool(DawnAcoreTestUtil.A_OPERATION); - editor.click(100, 100); - - typeTextToFocusedWidget("public foo():int", getBot(), true); - - editor.save(); - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.acore_diagram"); - - CDOResource semanticResource = view.getResource("/default.acore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - ACoreRoot semanticRoot = (ACoreRoot)semanticResource.getContents().get(0); - - assertEquals(1, diagram.getChildren().size()); - - AInterface aInterface = semanticRoot.getInterfaces().get(0); - - AOperation aOperation = aInterface.getOperations().get(0); - assertEquals("foo", aOperation.getName()); - assertEquals("public", aOperation.getAccessright().toString()); - assertEquals("int", aOperation.getDataType().toString()); - } - } - - @Test - public void testConnections() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 300, 100, "B", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 300, "C", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 300, 300, "D", getBot(), editor); - createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 200, 200, "Interface", getBot(), editor); - - createEdge(DawnAcoreTestUtil.CONNECTION_IHERITS, 100, 100, 300, 100, editor); - createEdge(DawnAcoreTestUtil.CONNECTION_ASSOCIATION, 310, 110, 310, 310, editor); - createEdge(DawnAcoreTestUtil.CONNECTION_COMPOSITION, 300, 300, 100, 300, editor); - createEdge(DawnAcoreTestUtil.CONNECTION_AGGREGATION, 100, 300, 100, 100, editor); - createEdge(DawnAcoreTestUtil.CONNECTION_IMPLEMENTS, 100, 100, 200, 200, editor); - - List<SWTBotGefEditPart> connectionEditParts = getAllConnections(editor); - - assertEquals(5, connectionEditParts.size()); - - editor.save(); - - { - CDOSession session = openSession(); - CDOView view = session.openView(); - - CDOResource diagramResource = view.getResource("/default.acore_diagram"); - - CDOResource semanticResource = view.getResource("/default.acore"); - - assertNotNull(diagramResource); - assertNotNull(semanticResource); - Diagram diagram = (Diagram)diagramResource.getContents().get(0); - ACoreRoot semanticRoot = (ACoreRoot)semanticResource.getContents().get(0); - - assertEquals(5, diagram.getChildren().size()); - assertEquals(4, semanticRoot.getClasses().size()); - assertEquals(1, semanticRoot.getInterfaces().size()); - - AClass A = semanticRoot.getClasses().get(0); - AClass B = semanticRoot.getClasses().get(1); - AClass C = semanticRoot.getClasses().get(2); - AClass D = semanticRoot.getClasses().get(3); - - // A - EList<AInterface> implementedInterfaces = A.getImplementedInterfaces(); - assertEquals(1, implementedInterfaces.size()); - assertEquals(implementedInterfaces.get(0), semanticRoot.getInterfaces().get(0)); - assertEquals(1, A.getSubClasses().size()); - assertEquals(B, A.getSubClasses().get(0)); - - // B - assertEquals(1, B.getAssociations().size()); - assertEquals(D, B.getAssociations().get(0)); - - // C - assertEquals(1, C.getAggregations().size()); - assertEquals(A, C.getAggregations().get(0)); - - // D - assertEquals(1, D.getCompositions().size()); - assertEquals(C, D.getCompositions().get(0)); - view.close(); - } - - editor.close(); - } - - @Test - public void testExceptionOnClose() throws Exception - { - SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot()); - assertNotNull(editor); - editor.close(); - } - - private List<SWTBotGefEditPart> getAllConnections(final SWTBotGefEditor editor) - { - List<SWTBotGefEditPart> aClassEditParts = editor.editParts(new AbstractMatcher<AClassEditPart>() - { - @Override - protected boolean doMatch(Object item) - { - if (item instanceof AClassEditPart) - { - return true; - } - return false; - } - - public void describeTo(Description description) - { - } - }); - - List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>(); - for (SWTBotGefEditPart editPart : aClassEditParts) - { - ret.addAll(editPart.sourceConnections()); - } - - return ret; - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.gmf;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AAttribute;
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
+import org.eclipse.emf.cdo.dawn.examples.acore.AInterface;
+import org.eclipse.emf.cdo.dawn.examples.acore.AOperation;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher;
+
+import org.hamcrest.Description;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class SimpleDiagramTest extends AbstractDawnGEFTest
+{
+ @Test
+ public void testCreateNewDawnDiagramAndAddElements() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 250, 100, "B", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 150, 250, "C", getBot(), editor);
+
+ editor.saveAndClose();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.acore_diagram");
+ CDOResource semanticResource = view.getResource("/default.acore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ ACoreRoot semanticRoot = (ACoreRoot)semanticResource.getContents().get(0);
+
+ assertEquals(3, diagram.getChildren().size());
+ assertEquals(3, semanticRoot.getClasses().size());
+
+ Character name = 'A';
+
+ for (AClass aClass : semanticRoot.getClasses())
+ {
+ assertEquals(name.toString(), aClass.getName());
+ name++;
+ }
+ }
+ }
+
+ @Test
+ public void testCreateNewDawnDiagramAndAddElementsWithEdges() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 250, 100, "B", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 150, 250, "C", getBot(), editor);
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_IHERITS, 100, 100, 250, 100, editor);
+ createEdge(DawnAcoreTestUtil.CONNECTION_IHERITS, 100, 100, 150, 250, editor);
+
+ List<SWTBotGefEditPart> connectionEditParts = getAllConnections(editor);
+
+ assertEquals(2, connectionEditParts.size());
+
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.acore_diagram");
+
+ CDOResource semanticResource = view.getResource("/default.acore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ ACoreRoot semanticRoot = (ACoreRoot)semanticResource.getContents().get(0);
+
+ assertEquals(3, diagram.getChildren().size());
+ assertEquals(3, semanticRoot.getClasses().size());
+
+ Character name = 'A';
+
+ for (AClass aClass : semanticRoot.getClasses())
+ {
+ assertEquals(name.toString(), aClass.getName());
+ name++;
+ }
+ view.close();
+ }
+
+ // for (SWTBotGefEditPart ep : connectionEditParts)
+ // {
+ // ConnectionEditPart connectionEditPart = (ConnectionEditPart)ep.part();
+ // Connection connection = (Connection)connectionEditPart.getFigure();
+ //
+ // Point midpoint = connection.getPoints().getMidpoint().getCopy();
+ //
+ // editor.click(midpoint.x, midpoint.y);
+ // editor.drag(midpoint.x, midpoint.y, 0, 20);
+ // }
+ // editor.save();
+ // editor.close();
+ }
+
+ @Test
+ public void testAClassWithAttributes() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+
+ editor.activateTool(DawnAcoreTestUtil.A_ATTRIBUTE);
+ editor.click(100, 100);
+
+ typeTextToFocusedWidget("public foo:int", getBot(), true);
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.acore_diagram");
+
+ CDOResource semanticResource = view.getResource("/default.acore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ ACoreRoot semanticRoot = (ACoreRoot)semanticResource.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ AClass aClass = semanticRoot.getClasses().get(0);
+
+ assertEquals(1, aClass.getAttributes().size());
+
+ AAttribute aAttribute = aClass.getAttributes().get(0);
+
+ assertEquals("public", aAttribute.getAccessright().toString());
+ assertEquals("int", aAttribute.getDataType().toString());
+ assertEquals("foo", aAttribute.getName());
+ }
+ }
+
+ @Test
+ public void testAClassWithOperations() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+
+ editor.activateTool(DawnAcoreTestUtil.A_OPERATION);
+ editor.click(100, 100);
+
+ typeTextToFocusedWidget("public foo():int", getBot(), true);
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.acore_diagram");
+
+ CDOResource semanticResource = view.getResource("/default.acore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ ACoreRoot semanticRoot = (ACoreRoot)semanticResource.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ AClass aClass = semanticRoot.getClasses().get(0);
+
+ assertEquals(1, aClass.getOperations().size());
+
+ AOperation aOperation = aClass.getOperations().get(0);
+ assertEquals("foo", aOperation.getName());
+ assertEquals("public", aOperation.getAccessright().toString());
+ assertEquals("int", aOperation.getDataType().toString());
+ }
+ }
+
+ @Test
+ public void testAInterfaceWithOperations() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 100, 100, "A", getBot(), editor);
+
+ editor.activateTool(DawnAcoreTestUtil.A_OPERATION);
+ editor.click(100, 100);
+
+ typeTextToFocusedWidget("public foo():int", getBot(), true);
+
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.acore_diagram");
+
+ CDOResource semanticResource = view.getResource("/default.acore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ ACoreRoot semanticRoot = (ACoreRoot)semanticResource.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ AInterface aInterface = semanticRoot.getInterfaces().get(0);
+
+ AOperation aOperation = aInterface.getOperations().get(0);
+ assertEquals("foo", aOperation.getName());
+ assertEquals("public", aOperation.getAccessright().toString());
+ assertEquals("int", aOperation.getDataType().toString());
+ }
+ }
+
+ @Test
+ public void testConnections() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 300, 100, "B", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 300, "C", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 300, 300, "D", getBot(), editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 200, 200, "Interface", getBot(), editor);
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_IHERITS, 100, 100, 300, 100, editor);
+ createEdge(DawnAcoreTestUtil.CONNECTION_ASSOCIATION, 310, 110, 310, 310, editor);
+ createEdge(DawnAcoreTestUtil.CONNECTION_COMPOSITION, 300, 300, 100, 300, editor);
+ createEdge(DawnAcoreTestUtil.CONNECTION_AGGREGATION, 100, 300, 100, 100, editor);
+ createEdge(DawnAcoreTestUtil.CONNECTION_IMPLEMENTS, 100, 100, 200, 200, editor);
+
+ List<SWTBotGefEditPart> connectionEditParts = getAllConnections(editor);
+
+ assertEquals(5, connectionEditParts.size());
+
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+
+ CDOResource diagramResource = view.getResource("/default.acore_diagram");
+
+ CDOResource semanticResource = view.getResource("/default.acore");
+
+ assertNotNull(diagramResource);
+ assertNotNull(semanticResource);
+ Diagram diagram = (Diagram)diagramResource.getContents().get(0);
+ ACoreRoot semanticRoot = (ACoreRoot)semanticResource.getContents().get(0);
+
+ assertEquals(5, diagram.getChildren().size());
+ assertEquals(4, semanticRoot.getClasses().size());
+ assertEquals(1, semanticRoot.getInterfaces().size());
+
+ AClass A = semanticRoot.getClasses().get(0);
+ AClass B = semanticRoot.getClasses().get(1);
+ AClass C = semanticRoot.getClasses().get(2);
+ AClass D = semanticRoot.getClasses().get(3);
+
+ // A
+ EList<AInterface> implementedInterfaces = A.getImplementedInterfaces();
+ assertEquals(1, implementedInterfaces.size());
+ assertEquals(implementedInterfaces.get(0), semanticRoot.getInterfaces().get(0));
+ assertEquals(1, A.getSubClasses().size());
+ assertEquals(B, A.getSubClasses().get(0));
+
+ // B
+ assertEquals(1, B.getAssociations().size());
+ assertEquals(D, B.getAssociations().get(0));
+
+ // C
+ assertEquals(1, C.getAggregations().size());
+ assertEquals(A, C.getAggregations().get(0));
+
+ // D
+ assertEquals(1, D.getCompositions().size());
+ assertEquals(C, D.getCompositions().get(0));
+ view.close();
+ }
+
+ editor.close();
+ }
+
+ @Test
+ public void testExceptionOnClose() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+ editor.close();
+ }
+
+ private List<SWTBotGefEditPart> getAllConnections(final SWTBotGefEditor editor)
+ {
+ List<SWTBotGefEditPart> aClassEditParts = editor.editParts(new AbstractMatcher<AClassEditPart>()
+ {
+ @Override
+ protected boolean doMatch(Object item)
+ {
+ if (item instanceof AClassEditPart)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public void describeTo(Description description)
+ {
+ }
+ });
+
+ List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>();
+ for (SWTBotGefEditPart editPart : aClassEditParts)
+ {
+ ret.addAll(editPart.sourceConnections());
+ }
+
+ return ret;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java index eec251bc78..356575b86e 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java @@ -1,310 +1,310 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.util; - -import org.eclipse.emf.cdo.dawn.examples.acore.AClass; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassAggregationsEditPart; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassAssociationsEditPart; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassCompositionsEditPart; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassImplementedInterfacesEditPart; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassSubClassesEditPart; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AInterfaceEditPart; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreViewProvider; -import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants; -import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput; -import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.Edge; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; -import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher; -import org.eclipse.swtbot.swt.finder.results.VoidResult; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - -import org.hamcrest.Description; - -import java.util.List; - -/** - * @author Martin Fluegge - */ -public class DawnAcoreTestUtil -{ - public static final String A_CLASS = "AClass"; - - public static final String A_INTERFACE = "AInterface"; - - public static final String A_ATTRIBUTE = "AAttribute"; - - public static final String A_OPERATION = "AOperation"; - - public static final String CONNECTION_IHERITS = "inherits"; - - public static final String CONNECTION_IMPLEMENTS = "implements"; - - public static final String CONNECTION_ASSOCIATION = "association"; - - public static final String CONNECTION_AGGREGATION = "aggregation"; - - public static final String CONNECTION_COMPOSITION = "composition"; - - public static final String CREATION_WIZARD_NAME_GMF = "Dawn Acore Diagram"; - - public static final String CREATION_WIZARD_NAME_EMF = "Dawn Acore Model"; - - private static IViewProvider viewProvider = new AcoreViewProvider(); - - private static String resourceFieldLabel = org.eclipse.emf.cdo.dawn.ui.messages.Messages.DawnCreateNewResourceWizardPage_6; - - public static SWTBotGefEditor openNewAcoreGMFEditor(String diagramResourceName, SWTGefBot bot) - { - return openNewAcoreGMFEditor(diagramResourceName, diagramResourceName.replace("_diagram", ""), bot); - } - - public static SWTBotGefEditor openNewAcoreGMFEditor(String diagramResourceName, String semanticResource, SWTGefBot bot) - { - bot.menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = bot.shell("New"); - shell.activate(); - bot.tree().expandNode("Dawn Examples").select("Dawn Acore Diagram"); - bot.button("Next >").click(); - - shell.activate(); - - SWTBotText fileNameLabel = bot.textWithLabel(resourceFieldLabel); - fileNameLabel.setText(diagramResourceName); - - bot.button("Next >").click(); - - SWTBotText fileSemanticNameLabel = bot.textWithLabel(resourceFieldLabel); - - fileSemanticNameLabel = bot.textWithLabel(resourceFieldLabel); - fileSemanticNameLabel.setText(semanticResource); - - fileSemanticNameLabel = bot.textWithLabel(resourceFieldLabel); - - bot.button("Finish").click(); - - SWTBotGefEditor editor = bot.gefEditor(diagramResourceName); - return editor; - } - - public static DawnSWTBotEMFEditor openAcoreEMFEditor(URI resourceURI, DawnEMFEditorBot bot) - { - String resourceName = resourceURI.lastSegment(); - final String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resourceName); - - final DawnEditorInput editorInput = new DawnEditorInput(resourceURI); - - UIThreadRunnable.asyncExec(new VoidResult() - { - public void run() - { - try - { - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().getPage() - .openEditor(editorInput, editorID); - } - catch (PartInitException ex) - { - throw new RuntimeException(ex); - } - } - }); - - return bot.emfEditor(resourceName); - } - - public static DawnSWTBotEMFEditor openNewAcoreEMFEditor(String resourceName, DawnEMFEditorBot bot) - { - bot.menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = bot.shell("New"); - shell.activate(); - bot.tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF); - bot.button("Next >").click(); - - shell = bot.shell("New"); - shell.activate(); - - SWTBotText fileSemanticNameLabel = bot.textWithLabel(resourceFieldLabel); - fileSemanticNameLabel.setText(resourceName); - - bot.button("Next >").click(); - - SWTBotCombo comboBox = bot.comboBox(0);// bot.ccomboBox(0); - comboBox.setFocus(); - comboBox.setSelection("ACore Root"); - - bot.button("Finish").click(); - - return bot.emfEditor(resourceName); - } - - public static List<SWTBotGefEditPart> getAClassEditParts(SWTBotGefEditor editor) - { - List<SWTBotGefEditPart> editParts = editor.editParts(new AbstractMatcher<AClassEditPart>() - { - @Override - protected boolean doMatch(Object item) - { - return item instanceof AClassEditPart; - } - - public void describeTo(Description description) - { - } - }); - return editParts; - } - - public static List<SWTBotGefEditPart> getAInterfaceEditParts(SWTBotGefEditor editor) - { - List<SWTBotGefEditPart> editParts = editor.editParts(new AbstractMatcher<AInterfaceEditPart>() - { - @Override - protected boolean doMatch(Object item) - { - return item instanceof AInterfaceEditPart; - } - - public void describeTo(Description description) - { - } - }); - return editParts; - } - - public static List<SWTBotGefEditPart> getAClassAssociationsEditParts(SWTBotGefEditor editor) - { - List<SWTBotGefEditPart> editParts = getAClassEditParts(editor); - return DawnSWTBotUtil.getConnectionEditParts(editor, AClassAssociationsEditPart.class, editParts); - } - - public static Node createNewAClassRemote(Diagram diagram, AClass newAClass) - { - String type = AcoreVisualIDRegistry.getType(AClassEditPart.VISUAL_ID); - return DawnSWTBotUtil.createNewNodeRemote(diagram, newAClass, type); - } - - // public static Edge createNewAssociationRemote(Node source, Node target) - // { - // String type = AcoreVisualIDRegistry.getType(AClassAssociationsEditPart.VISUAL_ID); - // Edge newEdge = DawnSWTBotUtil.createEdgeRemote(source, target, type); - // return newEdge; - // } - - public static Edge createNewAssociationRemote(Node source, Node target, List<RelativeBendpoint> bendpoints) - { - String type = AcoreVisualIDRegistry.getType(AClassAssociationsEditPart.VISUAL_ID); - return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassAssociations_4003, bendpoints, - viewProvider); - } - - public static Edge createNewImplementsRelationRemote(Node source, Node target, List<RelativeBendpoint> bendpoints) - { - String type = AcoreVisualIDRegistry.getType(AClassImplementedInterfacesEditPart.VISUAL_ID); - return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassImplementedInterfaces_4002, - bendpoints, viewProvider); - } - - public static Edge createNewInheritanceRelationRemote(Node source, Node target, List<RelativeBendpoint> bendpoints) - { - String type = AcoreVisualIDRegistry.getType(AClassSubClassesEditPart.VISUAL_ID); - return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassSubClasses_4001, bendpoints, - viewProvider); - } - - public static Edge createNewCompositionRemote(Node source, Node target, List<RelativeBendpoint> bendpoints) - { - String type = AcoreVisualIDRegistry.getType(AClassCompositionsEditPart.VISUAL_ID); - return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassCompositions_4005, bendpoints, - viewProvider); - } - - public static Edge createNewAggregationRemote(Node source, Node target, List<RelativeBendpoint> bendpoints) - { - String type = AcoreVisualIDRegistry.getType(AClassAggregationsEditPart.VISUAL_ID); - return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassAggregations_4004, bendpoints, - viewProvider); - } - - public static void sleep(int seconds) - { - try - { - Thread.sleep(seconds); - } - catch (InterruptedException ex) - { - throw new RuntimeException(ex); - } - } - - public static boolean showsConflict(EditPart editPart) - { - if (editPart instanceof AClassEditPart || editPart instanceof AInterfaceEditPart) - { - GraphicalEditPart e = (GraphicalEditPart)editPart; - - IFigure figure = e.getFigure(); - return ((LineBorder)figure.getBorder()).getColor().equals(DawnColorConstants.COLOR_DELETE_CONFLICT); - } - return false; - } - - public static Object showsLock(EditPart editPart, Color lockColor) - { - if (editPart instanceof AClassEditPart || editPart instanceof AInterfaceEditPart) - { - GraphicalEditPart e = (GraphicalEditPart)editPart; - - IFigure figure = e.getFigure(); - return ((LineBorder)figure.getBorder()).getColor().equals(lockColor); - } - return false; - } - - public static Object showsNoLock(EditPart editPart) - { - if (editPart instanceof AClassEditPart || editPart instanceof AInterfaceEditPart) - { - GraphicalEditPart e = (GraphicalEditPart)editPart; - - IFigure figure = e.getFigure(); - Color color = ((LineBorder)figure.getBorder()).getColor(); - return !(color.equals(DawnColorConstants.COLOR_LOCKED_REMOTELY) && color - .equals(DawnColorConstants.COLOR_LOCKED_LOCALLY)); - } - return false; - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.util;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassAggregationsEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassAssociationsEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassCompositionsEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassImplementedInterfacesEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassSubClassesEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AInterfaceEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreViewProvider;
+import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
+import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput;
+import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.LineBorder;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+import org.hamcrest.Description;
+
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnAcoreTestUtil
+{
+ public static final String A_CLASS = "AClass";
+
+ public static final String A_INTERFACE = "AInterface";
+
+ public static final String A_ATTRIBUTE = "AAttribute";
+
+ public static final String A_OPERATION = "AOperation";
+
+ public static final String CONNECTION_IHERITS = "inherits";
+
+ public static final String CONNECTION_IMPLEMENTS = "implements";
+
+ public static final String CONNECTION_ASSOCIATION = "association";
+
+ public static final String CONNECTION_AGGREGATION = "aggregation";
+
+ public static final String CONNECTION_COMPOSITION = "composition";
+
+ public static final String CREATION_WIZARD_NAME_GMF = "Dawn Acore Diagram";
+
+ public static final String CREATION_WIZARD_NAME_EMF = "Dawn Acore Model";
+
+ private static IViewProvider viewProvider = new AcoreViewProvider();
+
+ private static String resourceFieldLabel = org.eclipse.emf.cdo.dawn.ui.messages.Messages.DawnCreateNewResourceWizardPage_6;
+
+ public static SWTBotGefEditor openNewAcoreGMFEditor(String diagramResourceName, SWTGefBot bot)
+ {
+ return openNewAcoreGMFEditor(diagramResourceName, diagramResourceName.replace("_diagram", ""), bot);
+ }
+
+ public static SWTBotGefEditor openNewAcoreGMFEditor(String diagramResourceName, String semanticResource, SWTGefBot bot)
+ {
+ bot.menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = bot.shell("New");
+ shell.activate();
+ bot.tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+ bot.button("Next >").click();
+
+ shell.activate();
+
+ SWTBotText fileNameLabel = bot.textWithLabel(resourceFieldLabel);
+ fileNameLabel.setText(diagramResourceName);
+
+ bot.button("Next >").click();
+
+ SWTBotText fileSemanticNameLabel = bot.textWithLabel(resourceFieldLabel);
+
+ fileSemanticNameLabel = bot.textWithLabel(resourceFieldLabel);
+ fileSemanticNameLabel.setText(semanticResource);
+
+ fileSemanticNameLabel = bot.textWithLabel(resourceFieldLabel);
+
+ bot.button("Finish").click();
+
+ SWTBotGefEditor editor = bot.gefEditor(diagramResourceName);
+ return editor;
+ }
+
+ public static DawnSWTBotEMFEditor openAcoreEMFEditor(URI resourceURI, DawnEMFEditorBot bot)
+ {
+ String resourceName = resourceURI.lastSegment();
+ final String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resourceName);
+
+ final DawnEditorInput editorInput = new DawnEditorInput(resourceURI);
+
+ UIThreadRunnable.asyncExec(new VoidResult()
+ {
+ public void run()
+ {
+ try
+ {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().getPage()
+ .openEditor(editorInput, editorID);
+ }
+ catch (PartInitException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+ });
+
+ return bot.emfEditor(resourceName);
+ }
+
+ public static DawnSWTBotEMFEditor openNewAcoreEMFEditor(String resourceName, DawnEMFEditorBot bot)
+ {
+ bot.menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = bot.shell("New");
+ shell.activate();
+ bot.tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF);
+ bot.button("Next >").click();
+
+ shell = bot.shell("New");
+ shell.activate();
+
+ SWTBotText fileSemanticNameLabel = bot.textWithLabel(resourceFieldLabel);
+ fileSemanticNameLabel.setText(resourceName);
+
+ bot.button("Next >").click();
+
+ SWTBotCombo comboBox = bot.comboBox(0);// bot.ccomboBox(0);
+ comboBox.setFocus();
+ comboBox.setSelection("ACore Root");
+
+ bot.button("Finish").click();
+
+ return bot.emfEditor(resourceName);
+ }
+
+ public static List<SWTBotGefEditPart> getAClassEditParts(SWTBotGefEditor editor)
+ {
+ List<SWTBotGefEditPart> editParts = editor.editParts(new AbstractMatcher<AClassEditPart>()
+ {
+ @Override
+ protected boolean doMatch(Object item)
+ {
+ return item instanceof AClassEditPart;
+ }
+
+ public void describeTo(Description description)
+ {
+ }
+ });
+ return editParts;
+ }
+
+ public static List<SWTBotGefEditPart> getAInterfaceEditParts(SWTBotGefEditor editor)
+ {
+ List<SWTBotGefEditPart> editParts = editor.editParts(new AbstractMatcher<AInterfaceEditPart>()
+ {
+ @Override
+ protected boolean doMatch(Object item)
+ {
+ return item instanceof AInterfaceEditPart;
+ }
+
+ public void describeTo(Description description)
+ {
+ }
+ });
+ return editParts;
+ }
+
+ public static List<SWTBotGefEditPart> getAClassAssociationsEditParts(SWTBotGefEditor editor)
+ {
+ List<SWTBotGefEditPart> editParts = getAClassEditParts(editor);
+ return DawnSWTBotUtil.getConnectionEditParts(editor, AClassAssociationsEditPart.class, editParts);
+ }
+
+ public static Node createNewAClassRemote(Diagram diagram, AClass newAClass)
+ {
+ String type = AcoreVisualIDRegistry.getType(AClassEditPart.VISUAL_ID);
+ return DawnSWTBotUtil.createNewNodeRemote(diagram, newAClass, type);
+ }
+
+ // public static Edge createNewAssociationRemote(Node source, Node target)
+ // {
+ // String type = AcoreVisualIDRegistry.getType(AClassAssociationsEditPart.VISUAL_ID);
+ // Edge newEdge = DawnSWTBotUtil.createEdgeRemote(source, target, type);
+ // return newEdge;
+ // }
+
+ public static Edge createNewAssociationRemote(Node source, Node target, List<RelativeBendpoint> bendpoints)
+ {
+ String type = AcoreVisualIDRegistry.getType(AClassAssociationsEditPart.VISUAL_ID);
+ return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassAssociations_4003, bendpoints,
+ viewProvider);
+ }
+
+ public static Edge createNewImplementsRelationRemote(Node source, Node target, List<RelativeBendpoint> bendpoints)
+ {
+ String type = AcoreVisualIDRegistry.getType(AClassImplementedInterfacesEditPart.VISUAL_ID);
+ return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassImplementedInterfaces_4002,
+ bendpoints, viewProvider);
+ }
+
+ public static Edge createNewInheritanceRelationRemote(Node source, Node target, List<RelativeBendpoint> bendpoints)
+ {
+ String type = AcoreVisualIDRegistry.getType(AClassSubClassesEditPart.VISUAL_ID);
+ return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassSubClasses_4001, bendpoints,
+ viewProvider);
+ }
+
+ public static Edge createNewCompositionRemote(Node source, Node target, List<RelativeBendpoint> bendpoints)
+ {
+ String type = AcoreVisualIDRegistry.getType(AClassCompositionsEditPart.VISUAL_ID);
+ return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassCompositions_4005, bendpoints,
+ viewProvider);
+ }
+
+ public static Edge createNewAggregationRemote(Node source, Node target, List<RelativeBendpoint> bendpoints)
+ {
+ String type = AcoreVisualIDRegistry.getType(AClassAggregationsEditPart.VISUAL_ID);
+ return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassAggregations_4004, bendpoints,
+ viewProvider);
+ }
+
+ public static void sleep(int seconds)
+ {
+ try
+ {
+ Thread.sleep(seconds);
+ }
+ catch (InterruptedException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public static boolean showsConflict(EditPart editPart)
+ {
+ if (editPart instanceof AClassEditPart || editPart instanceof AInterfaceEditPart)
+ {
+ GraphicalEditPart e = (GraphicalEditPart)editPart;
+
+ IFigure figure = e.getFigure();
+ return ((LineBorder)figure.getBorder()).getColor().equals(DawnColorConstants.COLOR_DELETE_CONFLICT);
+ }
+ return false;
+ }
+
+ public static Object showsLock(EditPart editPart, Color lockColor)
+ {
+ if (editPart instanceof AClassEditPart || editPart instanceof AInterfaceEditPart)
+ {
+ GraphicalEditPart e = (GraphicalEditPart)editPart;
+
+ IFigure figure = e.getFigure();
+ return ((LineBorder)figure.getBorder()).getColor().equals(lockColor);
+ }
+ return false;
+ }
+
+ public static Object showsNoLock(EditPart editPart)
+ {
+ if (editPart instanceof AClassEditPart || editPart instanceof AInterfaceEditPart)
+ {
+ GraphicalEditPart e = (GraphicalEditPart)editPart;
+
+ IFigure figure = e.getFigure();
+ Color color = ((LineBorder)figure.getBorder()).getColor();
+ return !(color.equals(DawnColorConstants.COLOR_LOCKED_REMOTELY) && color
+ .equals(DawnColorConstants.COLOR_LOCKED_LOCALLY));
+ }
+ return false;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnCodeGenerationTestUtil.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnCodeGenerationTestUtil.java index 5502f2053d..13de8471af 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnCodeGenerationTestUtil.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnCodeGenerationTestUtil.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEMFEditorBot.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEMFEditorBot.java index 05ec4f8996..99173ee1f3 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEMFEditorBot.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEMFEditorBot.java @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.util; - -import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName; -import static org.eclipse.swtbot.eclipse.finder.waits.Conditions.waitForEditor; -import static org.hamcrest.Matchers.allOf; - -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.eclipse.finder.waits.WaitForEditor; -import org.eclipse.swtbot.eclipse.gef.finder.matchers.IsInstanceOf; -import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; -import org.eclipse.ui.IEditorReference; - -import org.hamcrest.Matcher; - -/** - * @author Martin Fluegge - */ -public class DawnEMFEditorBot extends SWTWorkbenchBot -{ - public DawnSWTBotEMFEditor emfEditor(String fileName) throws WidgetNotFoundException - { - return emfEditor(fileName, 0); - } - - @SuppressWarnings("unchecked") - public DawnSWTBotEMFEditor emfEditor(String fileName, int index) throws WidgetNotFoundException - { - Matcher<IEditorReference> withPartName = withPartName(fileName); - Matcher<IEditorReference> matcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName); - WaitForEditor waitForEditor = waitForEditor(matcher); - waitUntilWidgetAppears(waitForEditor); - return createEditor(waitForEditor.get(index), this); - } - - protected DawnSWTBotEMFEditor createEditor(final IEditorReference reference, final SWTWorkbenchBot bot) - { - return new DawnSWTBotEMFEditor(reference, bot); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.util;
+
+import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName;
+import static org.eclipse.swtbot.eclipse.finder.waits.Conditions.waitForEditor;
+import static org.hamcrest.Matchers.allOf;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.waits.WaitForEditor;
+import org.eclipse.swtbot.eclipse.gef.finder.matchers.IsInstanceOf;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.ui.IEditorReference;
+
+import org.hamcrest.Matcher;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnEMFEditorBot extends SWTWorkbenchBot
+{
+ public DawnSWTBotEMFEditor emfEditor(String fileName) throws WidgetNotFoundException
+ {
+ return emfEditor(fileName, 0);
+ }
+
+ @SuppressWarnings("unchecked")
+ public DawnSWTBotEMFEditor emfEditor(String fileName, int index) throws WidgetNotFoundException
+ {
+ Matcher<IEditorReference> withPartName = withPartName(fileName);
+ Matcher<IEditorReference> matcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName);
+ WaitForEditor waitForEditor = waitForEditor(matcher);
+ waitUntilWidgetAppears(waitForEditor);
+ return createEditor(waitForEditor.get(index), this);
+ }
+
+ protected DawnSWTBotEMFEditor createEditor(final IEditorReference reference, final SWTWorkbenchBot bot)
+ {
+ return new DawnSWTBotEMFEditor(reference, bot);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEcoreTestUtil.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEcoreTestUtil.java index 4fd68fd53d..ef437c13a0 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEcoreTestUtil.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEcoreTestUtil.java @@ -1,271 +1,271 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.util; - -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AInterfaceEditPart; -import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants; -import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput; -import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecoretools.diagram.edit.parts.EClassEditPart; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; -import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher; -import org.eclipse.swtbot.swt.finder.results.VoidResult; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - -import org.hamcrest.Description; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Martin Fluegge - */ -public class DawnEcoreTestUtil -{ - public static final String CREATION_WIZARD_NAME_GMF = "Dawn Ecore Diagram"; - - public static final String CREATION_WIZARD_NAME_EMF = "Dawn Ecore Model"; - - public static final String E_CLASS = "EClass"; - - public static final String E_REFERENCE = "EReference"; - - public static final String E_ATTRIBUTE = "EAttribute"; - - public static final String E_OPERATION = "EOperation"; - - public static final String INHERITANCE = "Inheritance"; - - public static final String E_DATATYPE = "EDataType"; - - public static final String E_PACKAGE = "EPackage"; - - public static final String E_ANNOTATION = "EAnnotation"; - - public static final String E_ENUM = "EEnum"; - - public static final String E_ANNOTATION_LINK = "EAnnotation link"; - - public static final String DETAILS_ENTRY = "Details Entry"; - - private static String resourceFieldLabel = org.eclipse.emf.cdo.dawn.ui.messages.Messages.DawnCreateNewResourceWizardPage_6; - - public static SWTBotGefEditor openNewEcoreToolsEditor(String diagramResourceName, SWTGefBot bot) - { - bot.menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = bot.shell("New"); - shell.activate(); - bot.tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_GMF); - bot.button("Next >").click(); - bot.button("Finish").click(); - SWTBotGefEditor editor = bot.gefEditor("default"); - return editor; - } - - public static DawnSWTBotEMFEditor openEcoreEMFEditor(URI resourceURI, DawnEMFEditorBot bot) - { - String resourceName = resourceURI.lastSegment(); - final String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resourceName); - - final DawnEditorInput editorInput = new DawnEditorInput(resourceURI); - - UIThreadRunnable.asyncExec(new VoidResult() - { - public void run() - { - try - { - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().getPage() - .openEditor(editorInput, editorID); - } - catch (PartInitException ex) - { - throw new RuntimeException(ex); - } - } - }); - - return bot.emfEditor(resourceName); - } - - public static DawnSWTBotEMFEditor openNewEcoreEMFEditor(String resourceName, DawnEMFEditorBot bot) - { - bot.menu("File").menu("New").menu("Other...").click(); - - SWTBotShell shell = bot.shell("New"); - shell.activate(); - bot.tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_EMF); - bot.button("Next >").click(); - - shell = bot.shell("New"); - shell.activate(); - - SWTBotText fileSemanticNameLabel = bot.textWithLabel(resourceFieldLabel); - fileSemanticNameLabel.setText(resourceName); - - bot.button("Next >").click(); - - SWTBotCombo comboBox = bot.comboBox(0);// bot.ccomboBox(0); - comboBox.setFocus(); - comboBox.setSelection("EPackage"); - - bot.button("Finish").click(); - - return bot.emfEditor(resourceName); - } - - // public static List<SWTBotGefEditPart> getEClassEditParts(SWTBotGefEditor editor) - // { - // List<SWTBotGefEditPart> editParts = editor.editParts(new AbstractMatcher<EClassEditPart>() - // { - // @Override - // protected boolean doMatch(Object item) - // { - // return item instanceof AClassEditPart; - // } - // - // public void describeTo(Description description) - // { - // } - // }); - // return editParts; - // } - - public static void sleep(int seconds) - { - try - { - Thread.sleep(seconds); - } - catch (InterruptedException ex) - { - throw new RuntimeException(ex); - } - } - - public static boolean showsConflict(EditPart editPart) - { - if (editPart instanceof AClassEditPart || editPart instanceof AInterfaceEditPart) - { - GraphicalEditPart e = (GraphicalEditPart)editPart; - - IFigure figure = e.getFigure(); - return ((LineBorder)figure.getBorder()).getColor().equals(DawnColorConstants.COLOR_DELETE_CONFLICT); - } - return false; - } - - public static List<SWTBotGefEditPart> getAllConnections(final SWTBotGefEditor editor) - { - List<SWTBotGefEditPart> aClassEditParts = editor.editParts(new AbstractMatcher<AClassEditPart>() - { - @Override - protected boolean doMatch(Object item) - { - if (item instanceof EClassEditPart) - { - return true; - } - return false; - } - - public void describeTo(Description description) - { - } - }); - - List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>(); - for (SWTBotGefEditPart editPart : aClassEditParts) - { - ret.addAll(editPart.sourceConnections()); - } - - for (SWTBotGefEditPart editPart : aClassEditParts) - { - ret.addAll(editPart.targetConnections()); - } - - return ret; - } - - public static List<SWTBotGefEditPart> getAllSourceConnections(final SWTBotGefEditor editor) - { - List<SWTBotGefEditPart> aClassEditParts = editor.editParts(new AbstractMatcher<AClassEditPart>() - { - @Override - protected boolean doMatch(Object item) - { - if (item instanceof EClassEditPart) - { - return true; - } - return false; - } - - public void describeTo(Description description) - { - } - }); - - List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>(); - for (SWTBotGefEditPart editPart : aClassEditParts) - { - ret.addAll(editPart.sourceConnections()); - } - - return ret; - } - - public static List<SWTBotGefEditPart> getAllTargetConnections(final SWTBotGefEditor editor) - { - List<SWTBotGefEditPart> aClassEditParts = editor.editParts(new AbstractMatcher<AClassEditPart>() - { - @Override - protected boolean doMatch(Object item) - { - if (item instanceof EClassEditPart) - { - return true; - } - return false; - } - - public void describeTo(Description description) - { - } - }); - - List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>(); - - for (SWTBotGefEditPart editPart : aClassEditParts) - { - ret.addAll(editPart.targetConnections()); - } - - return ret; - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.util;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AInterfaceEditPart;
+import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
+import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput;
+import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecoretools.diagram.edit.parts.EClassEditPart;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.LineBorder;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+import org.hamcrest.Description;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnEcoreTestUtil
+{
+ public static final String CREATION_WIZARD_NAME_GMF = "Dawn Ecore Diagram";
+
+ public static final String CREATION_WIZARD_NAME_EMF = "Dawn Ecore Model";
+
+ public static final String E_CLASS = "EClass";
+
+ public static final String E_REFERENCE = "EReference";
+
+ public static final String E_ATTRIBUTE = "EAttribute";
+
+ public static final String E_OPERATION = "EOperation";
+
+ public static final String INHERITANCE = "Inheritance";
+
+ public static final String E_DATATYPE = "EDataType";
+
+ public static final String E_PACKAGE = "EPackage";
+
+ public static final String E_ANNOTATION = "EAnnotation";
+
+ public static final String E_ENUM = "EEnum";
+
+ public static final String E_ANNOTATION_LINK = "EAnnotation link";
+
+ public static final String DETAILS_ENTRY = "Details Entry";
+
+ private static String resourceFieldLabel = org.eclipse.emf.cdo.dawn.ui.messages.Messages.DawnCreateNewResourceWizardPage_6;
+
+ public static SWTBotGefEditor openNewEcoreToolsEditor(String diagramResourceName, SWTGefBot bot)
+ {
+ bot.menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = bot.shell("New");
+ shell.activate();
+ bot.tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_GMF);
+ bot.button("Next >").click();
+ bot.button("Finish").click();
+ SWTBotGefEditor editor = bot.gefEditor("default");
+ return editor;
+ }
+
+ public static DawnSWTBotEMFEditor openEcoreEMFEditor(URI resourceURI, DawnEMFEditorBot bot)
+ {
+ String resourceName = resourceURI.lastSegment();
+ final String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resourceName);
+
+ final DawnEditorInput editorInput = new DawnEditorInput(resourceURI);
+
+ UIThreadRunnable.asyncExec(new VoidResult()
+ {
+ public void run()
+ {
+ try
+ {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().getPage()
+ .openEditor(editorInput, editorID);
+ }
+ catch (PartInitException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+ });
+
+ return bot.emfEditor(resourceName);
+ }
+
+ public static DawnSWTBotEMFEditor openNewEcoreEMFEditor(String resourceName, DawnEMFEditorBot bot)
+ {
+ bot.menu("File").menu("New").menu("Other...").click();
+
+ SWTBotShell shell = bot.shell("New");
+ shell.activate();
+ bot.tree().expandNode("Dawn Examples").select(DawnEcoreTestUtil.CREATION_WIZARD_NAME_EMF);
+ bot.button("Next >").click();
+
+ shell = bot.shell("New");
+ shell.activate();
+
+ SWTBotText fileSemanticNameLabel = bot.textWithLabel(resourceFieldLabel);
+ fileSemanticNameLabel.setText(resourceName);
+
+ bot.button("Next >").click();
+
+ SWTBotCombo comboBox = bot.comboBox(0);// bot.ccomboBox(0);
+ comboBox.setFocus();
+ comboBox.setSelection("EPackage");
+
+ bot.button("Finish").click();
+
+ return bot.emfEditor(resourceName);
+ }
+
+ // public static List<SWTBotGefEditPart> getEClassEditParts(SWTBotGefEditor editor)
+ // {
+ // List<SWTBotGefEditPart> editParts = editor.editParts(new AbstractMatcher<EClassEditPart>()
+ // {
+ // @Override
+ // protected boolean doMatch(Object item)
+ // {
+ // return item instanceof AClassEditPart;
+ // }
+ //
+ // public void describeTo(Description description)
+ // {
+ // }
+ // });
+ // return editParts;
+ // }
+
+ public static void sleep(int seconds)
+ {
+ try
+ {
+ Thread.sleep(seconds);
+ }
+ catch (InterruptedException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public static boolean showsConflict(EditPart editPart)
+ {
+ if (editPart instanceof AClassEditPart || editPart instanceof AInterfaceEditPart)
+ {
+ GraphicalEditPart e = (GraphicalEditPart)editPart;
+
+ IFigure figure = e.getFigure();
+ return ((LineBorder)figure.getBorder()).getColor().equals(DawnColorConstants.COLOR_DELETE_CONFLICT);
+ }
+ return false;
+ }
+
+ public static List<SWTBotGefEditPart> getAllConnections(final SWTBotGefEditor editor)
+ {
+ List<SWTBotGefEditPart> aClassEditParts = editor.editParts(new AbstractMatcher<AClassEditPart>()
+ {
+ @Override
+ protected boolean doMatch(Object item)
+ {
+ if (item instanceof EClassEditPart)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public void describeTo(Description description)
+ {
+ }
+ });
+
+ List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>();
+ for (SWTBotGefEditPart editPart : aClassEditParts)
+ {
+ ret.addAll(editPart.sourceConnections());
+ }
+
+ for (SWTBotGefEditPart editPart : aClassEditParts)
+ {
+ ret.addAll(editPart.targetConnections());
+ }
+
+ return ret;
+ }
+
+ public static List<SWTBotGefEditPart> getAllSourceConnections(final SWTBotGefEditor editor)
+ {
+ List<SWTBotGefEditPart> aClassEditParts = editor.editParts(new AbstractMatcher<AClassEditPart>()
+ {
+ @Override
+ protected boolean doMatch(Object item)
+ {
+ if (item instanceof EClassEditPart)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public void describeTo(Description description)
+ {
+ }
+ });
+
+ List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>();
+ for (SWTBotGefEditPart editPart : aClassEditParts)
+ {
+ ret.addAll(editPart.sourceConnections());
+ }
+
+ return ret;
+ }
+
+ public static List<SWTBotGefEditPart> getAllTargetConnections(final SWTBotGefEditor editor)
+ {
+ List<SWTBotGefEditPart> aClassEditParts = editor.editParts(new AbstractMatcher<AClassEditPart>()
+ {
+ @Override
+ protected boolean doMatch(Object item)
+ {
+ if (item instanceof EClassEditPart)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public void describeTo(Description description)
+ {
+ }
+ });
+
+ List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>();
+
+ for (SWTBotGefEditPart editPart : aClassEditParts)
+ {
+ ret.addAll(editPart.targetConnections());
+ }
+
+ return ret;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotEMFEditor.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotEMFEditor.java index a07a0678f2..0ac6701dfa 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotEMFEditor.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotEMFEditor.java @@ -1,260 +1,260 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.util; - -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefContextMenu; -import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.part.MultiPageEditorPart; - -import org.hamcrest.SelfDescribing; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * @author Martin Fluegge - */ -public class DawnSWTBotEMFEditor extends SWTBotEditor -{ - public DawnSWTBotEMFEditor(IEditorReference editorReference, SWTWorkbenchBot bot) throws WidgetNotFoundException - { - super(editorReference, bot); - } - - public DawnSWTBotEMFEditor(IEditorReference editorReference, SWTWorkbenchBot bot, SelfDescribing description) - { - super(editorReference, bot, description); - } - - /** - * return the tree of the EMF editor - */ - public SWTBotTree getSelectionPageTree() - { - MultiPageEditorPart editor = (MultiPageEditorPart)getReference().getEditor(false); - SWTBotTree swtBotTree = null; - try - { - setActivePage(editor, 0); - - TreeViewer viewer = (TreeViewer)getCurrentViewer(); - swtBotTree = new SWTBotTree(viewer.getTree()); - } - catch (Exception ex) - { - throw new RuntimeException(ex); - } - - return swtBotTree; - } - - public void setActivePage(int i) - { - MultiPageEditorPart editor = (MultiPageEditorPart)getReference().getEditor(false); - try - { - setActivePage(editor, i); - } - catch (Exception ex) - { - throw new RuntimeException(ex); - } - } - - public DawnSWTBotEMFEditor clickContextMenu(Control control, String text) throws WidgetNotFoundException - { - new SWTBotGefContextMenu(control, text).click(); - return this; - } - - protected Object getSelectedPage(final MultiPageEditorPart editor) - { - Object ret = null; - - RunnableWithResult runnable = new RunnableWithResult(ret) - { - @Override - public void run() - { - result = editor.getSelectedPage(); - } - }; - editor.getSite().getShell().getDisplay().syncExec(runnable); - - return runnable.getResult(); - } - - public Viewer getCurrentViewer() - { - final MultiPageEditorPart editor = (MultiPageEditorPart)getReference().getEditor(false); - - IEditorPart ret = null; - - RunnableWithResult runnable = new RunnableWithResult(ret) - { - - @Override - public void run() - { - try - { - Class<?>[] parameterTypes = new Class[0]; - Method method = getMethod(editor, "getViewer", parameterTypes); - method.setAccessible(true); - Object[] params = new Object[0]; - result = method.invoke(editor, params); - } - catch (Exception ex) - { - throw new RuntimeException(ex); - } - } - }; - - editor.getSite().getShell().getDisplay().syncExec(runnable); - return (Viewer)runnable.getResult(); - } - - protected IEditorPart getActiveEditor() - { - final MultiPageEditorPart editor = (MultiPageEditorPart)getReference().getEditor(false); - - IEditorPart ret = null; - - RunnableWithResult runnable = new RunnableWithResult(ret) - { - @Override - public void run() - { - try - { - Class<?>[] parameterTypes = new Class[0]; - - Class<?> superClass = getSuperClass(editor.getClass(), MultiPageEditorPart.class); - - Method method = superClass.getDeclaredMethod("getActiveEditor", parameterTypes); - method.setAccessible(true); - Object[] params = new Object[0]; - result = method.invoke(editor, params); - } - catch (Exception ex) - { - throw new RuntimeException(ex); - } - } - }; - - editor.getSite().getShell().getDisplay().syncExec(runnable); - return (IEditorPart)runnable.getResult(); - } - - protected void setActivePage(final MultiPageEditorPart editor, final int i) throws SecurityException, - NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException - { - editor.getSite().getShell().getDisplay().syncExec(new Runnable() - { - public void run() - { - try - { - Class<?>[] parameterTypes = new Class[1]; - parameterTypes[0] = int.class; - - Class<?> superClass = getSuperClass(editor.getClass(), MultiPageEditorPart.class); - - Method method = superClass.getDeclaredMethod("setActivePage", parameterTypes); - - boolean accessible = method.isAccessible(); - method.setAccessible(true); - - Object[] params = new Object[1]; - params[0] = i; - method.invoke(editor, params); - method.setAccessible(accessible); - } - catch (Exception ex) - { - throw new RuntimeException(ex); - } - } - }); - } - - private Class<?> getSuperClass(Class<?> a, Class<?> b) - { - Class<?> ret = a; - while (ret != b && ret != Object.class) - { - ret = ret.getSuperclass(); - } - return ret; - } - - protected abstract class RunnableWithResult implements Runnable - { - protected Object result; - - public RunnableWithResult(Object result) - { - this.result = result; - } - - public abstract void run(); - - public Object getResult() - { - return result; - } - } - - private Method getMethod(final MultiPageEditorPart editor, String methodName, Class<?>[] parameterTypes) - throws NoSuchMethodException - { - Method method = null; - Class<?> clazz = editor.getClass(); - while (method == null && clazz != Object.class) - { - try - { - method = clazz.getDeclaredMethod(methodName, parameterTypes); - } - catch (NoSuchMethodException ex) - { - clazz = clazz.getSuperclass(); - } - } - return method; - } - - public void setText(final SWTBotTreeItem item, final String text) - { - MultiPageEditorPart editor = (MultiPageEditorPart)getReference().getEditor(false); - Display display = editor.getEditorSite().getShell().getDisplay(); - - display.asyncExec(new Runnable() - { - public void run() - { - item.widget.setData(text); - } - }); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.util;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefContextMenu;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.part.MultiPageEditorPart;
+
+import org.hamcrest.SelfDescribing;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnSWTBotEMFEditor extends SWTBotEditor
+{
+ public DawnSWTBotEMFEditor(IEditorReference editorReference, SWTWorkbenchBot bot) throws WidgetNotFoundException
+ {
+ super(editorReference, bot);
+ }
+
+ public DawnSWTBotEMFEditor(IEditorReference editorReference, SWTWorkbenchBot bot, SelfDescribing description)
+ {
+ super(editorReference, bot, description);
+ }
+
+ /**
+ * return the tree of the EMF editor
+ */
+ public SWTBotTree getSelectionPageTree()
+ {
+ MultiPageEditorPart editor = (MultiPageEditorPart)getReference().getEditor(false);
+ SWTBotTree swtBotTree = null;
+ try
+ {
+ setActivePage(editor, 0);
+
+ TreeViewer viewer = (TreeViewer)getCurrentViewer();
+ swtBotTree = new SWTBotTree(viewer.getTree());
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+
+ return swtBotTree;
+ }
+
+ public void setActivePage(int i)
+ {
+ MultiPageEditorPart editor = (MultiPageEditorPart)getReference().getEditor(false);
+ try
+ {
+ setActivePage(editor, i);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public DawnSWTBotEMFEditor clickContextMenu(Control control, String text) throws WidgetNotFoundException
+ {
+ new SWTBotGefContextMenu(control, text).click();
+ return this;
+ }
+
+ protected Object getSelectedPage(final MultiPageEditorPart editor)
+ {
+ Object ret = null;
+
+ RunnableWithResult runnable = new RunnableWithResult(ret)
+ {
+ @Override
+ public void run()
+ {
+ result = editor.getSelectedPage();
+ }
+ };
+ editor.getSite().getShell().getDisplay().syncExec(runnable);
+
+ return runnable.getResult();
+ }
+
+ public Viewer getCurrentViewer()
+ {
+ final MultiPageEditorPart editor = (MultiPageEditorPart)getReference().getEditor(false);
+
+ IEditorPart ret = null;
+
+ RunnableWithResult runnable = new RunnableWithResult(ret)
+ {
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ Class<?>[] parameterTypes = new Class[0];
+ Method method = getMethod(editor, "getViewer", parameterTypes);
+ method.setAccessible(true);
+ Object[] params = new Object[0];
+ result = method.invoke(editor, params);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+ };
+
+ editor.getSite().getShell().getDisplay().syncExec(runnable);
+ return (Viewer)runnable.getResult();
+ }
+
+ protected IEditorPart getActiveEditor()
+ {
+ final MultiPageEditorPart editor = (MultiPageEditorPart)getReference().getEditor(false);
+
+ IEditorPart ret = null;
+
+ RunnableWithResult runnable = new RunnableWithResult(ret)
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ Class<?>[] parameterTypes = new Class[0];
+
+ Class<?> superClass = getSuperClass(editor.getClass(), MultiPageEditorPart.class);
+
+ Method method = superClass.getDeclaredMethod("getActiveEditor", parameterTypes);
+ method.setAccessible(true);
+ Object[] params = new Object[0];
+ result = method.invoke(editor, params);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+ };
+
+ editor.getSite().getShell().getDisplay().syncExec(runnable);
+ return (IEditorPart)runnable.getResult();
+ }
+
+ protected void setActivePage(final MultiPageEditorPart editor, final int i) throws SecurityException,
+ NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
+ {
+ editor.getSite().getShell().getDisplay().syncExec(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ Class<?>[] parameterTypes = new Class[1];
+ parameterTypes[0] = int.class;
+
+ Class<?> superClass = getSuperClass(editor.getClass(), MultiPageEditorPart.class);
+
+ Method method = superClass.getDeclaredMethod("setActivePage", parameterTypes);
+
+ boolean accessible = method.isAccessible();
+ method.setAccessible(true);
+
+ Object[] params = new Object[1];
+ params[0] = i;
+ method.invoke(editor, params);
+ method.setAccessible(accessible);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+ });
+ }
+
+ private Class<?> getSuperClass(Class<?> a, Class<?> b)
+ {
+ Class<?> ret = a;
+ while (ret != b && ret != Object.class)
+ {
+ ret = ret.getSuperclass();
+ }
+ return ret;
+ }
+
+ protected abstract class RunnableWithResult implements Runnable
+ {
+ protected Object result;
+
+ public RunnableWithResult(Object result)
+ {
+ this.result = result;
+ }
+
+ public abstract void run();
+
+ public Object getResult()
+ {
+ return result;
+ }
+ }
+
+ private Method getMethod(final MultiPageEditorPart editor, String methodName, Class<?>[] parameterTypes)
+ throws NoSuchMethodException
+ {
+ Method method = null;
+ Class<?> clazz = editor.getClass();
+ while (method == null && clazz != Object.class)
+ {
+ try
+ {
+ method = clazz.getDeclaredMethod(methodName, parameterTypes);
+ }
+ catch (NoSuchMethodException ex)
+ {
+ clazz = clazz.getSuperclass();
+ }
+ }
+ return method;
+ }
+
+ public void setText(final SWTBotTreeItem item, final String text)
+ {
+ MultiPageEditorPart editor = (MultiPageEditorPart)getReference().getEditor(false);
+ Display display = editor.getEditorSite().getShell().getDisplay();
+
+ display.asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ item.widget.setData(text);
+ }
+ });
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotUtil.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotUtil.java index 3962a44edc..974b8a96e1 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotUtil.java +++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotUtil.java @@ -1,405 +1,405 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.tests.ui.util; - -import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic; -import static org.hamcrest.Matchers.allOf; -import static org.hamcrest.Matchers.instanceOf; - -import org.eclipse.emf.cdo.dawn.examples.acore.AClass; -import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart; -import org.eclipse.emf.cdo.dawn.gmf.synchronize.DawnConflictHelper; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; - -import org.eclipse.gef.EditPart; -import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; -import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider; -import org.eclipse.gmf.runtime.diagram.core.services.ViewService; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.notation.Bounds; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.Edge; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.gmf.runtime.notation.RelativeBendpoints; -import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefConnectionEditPart; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; -import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; -import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; -import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; -import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher; -import org.eclipse.swtbot.swt.finder.results.WidgetResult; -import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; - -import org.hamcrest.Description; -import org.hamcrest.Matcher; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * @author Martin Fluegge - */ -public class DawnSWTBotUtil -{ - private static final String LABEL_OK = "OK"; - - private static final String LABEL_OTHERS = "Other..."; - - private static final String LABEL_WINDOW = "Window"; - - private static final String LABEL_SHOW_VIEW = "Show View"; - - public static void initTest(SWTWorkbenchBot bot) - { - closeWelcomePage(bot); - } - - public static void closeWelcomePage(SWTWorkbenchBot bot) - { - try - { - bot.viewByTitle("Welcome").close(); - } - catch (WidgetNotFoundException ex) - { - // We can ignore this because it it thrown when the widget cannot be found which can be the case if another test - // already closed the welcome screen. - } - } - - public static void setConnectorType(SWTWorkbenchBot bot, String serverName, String serverPort, String repository, - String protocol) - { - bot.menu(LABEL_WINDOW).menu("Preferences").click(); - SWTBotShell shell = bot.shell("Preferences"); - shell.activate(); - - bot.tree().select("Dawn Remote Preferences"); - - SWTBotText serverNameLabel = bot.textWithLabel("server name:"); - SWTBotText serverPortLabel = bot.textWithLabel("server port:"); - SWTBotText repositoryLabel = bot.textWithLabel("repository:"); - SWTBotText fileNameLabel = bot.textWithLabel("protocol:"); - - serverNameLabel.setText(serverName); - serverPortLabel.setText(serverPort); - repositoryLabel.setText(repository); - fileNameLabel.setText(protocol); - bot.button(LABEL_OK).click(); - } - - public static List<SWTBotGefEditPart> getAllEditParts(SWTBotGefEditor editor) - { - List<SWTBotGefEditPart> editParts = editor.editParts(new AbstractMatcher<EditPart>() - { - @Override - protected boolean doMatch(Object item) - { - return item instanceof AClassEditPart; - } - - public void describeTo(Description description) - { - } - }); - return editParts; - } - - public static List<SWTBotGefEditPart> getConnectionEditParts(SWTBotGefEditor editor, Class<? extends EditPart> clazz) - { - List<SWTBotGefEditPart> editParts = getAllEditParts(editor); - return getConnectionEditParts(editor, clazz, editParts); - } - - public static List<SWTBotGefEditPart> getConnectionEditParts(SWTBotGefEditor editor, Class<? extends EditPart> clazz, - List<SWTBotGefEditPart> editParts) - { - - List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>(); - for (SWTBotGefEditPart editPart : editParts) - { - - for (SWTBotGefConnectionEditPart sourceConnection : editPart.sourceConnections()) - { - if (clazz.isInstance(sourceConnection.part())) - { - ret.add(sourceConnection); - } - } - } - return ret; - } - - static Object monitor = new Object(); - - /** - * returns all ConnectionEditparts from teh given editor - */ - public static List<SWTBotGefEditPart> getAllConnections(final SWTBotGefEditor editor) - { - AbstractMatcher<EditPart> matcher = new AbstractMatcher<EditPart>() - { - @Override - protected boolean doMatch(Object item) - { - return true; - } - - public void describeTo(Description description) - { - } - }; - List<SWTBotGefEditPart> aClassEditParts = editor.editParts(matcher); - - List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>(); - - for (SWTBotGefEditPart editPart : aClassEditParts) - { - ret.addAll(editPart.sourceConnections()); - } - return ret; - } - - public static Node createNewNodeRemote(Diagram diagram, AClass newAClass, String type) - { - Node newNode = ViewService.createNode(diagram, newAClass, type, PreferencesHint.USE_DEFAULTS); - return newNode; - } - - public static Edge createEdgeRemote(Node source, Node target, String type, IElementType elementType, - List<RelativeBendpoint> bendpoints, IViewProvider viewProvider) - { - Edge edge = viewProvider.createEdge(elementType, source.getDiagram(), type, ViewUtil.APPEND, true, - PreferencesHint.USE_DEFAULTS); - - edge.setTarget(target); - edge.setSource(source); - - RelativeBendpoints exitingBendpoints = (RelativeBendpoints)edge.getBendpoints(); - @SuppressWarnings("unchecked") - List<RelativeBendpoint> points = exitingBendpoints.getPoints(); - List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(points); - newBendPoints.addAll(1, bendpoints); - exitingBendpoints.setPoints(newBendPoints); - - return edge; - } - - public static void addBendPoint(Edge edge, int sourceX, int sourceY, int targetX, int targetY) - { - List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(); - RelativeBendpoint relativeBendpoint = new RelativeBendpoint(sourceX, sourceY, targetX, targetY); - newBendPoints.add(relativeBendpoint); - DawnSWTBotUtil.addBendpoints(edge, newBendPoints); - } - - public static void addBendpoints(final Edge edge, final List<RelativeBendpoint> bendpoints) - { - ResourceSet resourceSet = edge.eResource().getResourceSet(); - - if (resourceSet instanceof IEditingDomainProvider) - { - EditingDomain editingDomain = ((IEditingDomainProvider)resourceSet).getEditingDomain(); - - editingDomain.getCommandStack().execute(new RecordingCommand((TransactionalEditingDomain)editingDomain) - { - @Override - protected void doExecute() - { - DawnSWTBotUtil.addBendPointsInternal(edge, bendpoints); - } - }); - } - else - { - addBendPointsInternal(edge, bendpoints); - } - } - - private static void addBendPointsInternal(final Edge edge, final List<RelativeBendpoint> bendpoints) - { - RelativeBendpoints exitingBendpoints = (RelativeBendpoints)edge.getBendpoints(); - @SuppressWarnings("unchecked") - List<RelativeBendpoint> points = exitingBendpoints.getPoints(); - List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(points); - newBendPoints.addAll(1, bendpoints); - exitingBendpoints.setPoints(newBendPoints); - } - - public static Object showsConflict(EditPart editPart) - { - return DawnConflictHelper.isConflicted((EObject)editPart.getModel()); - } - - public static void moveNodeRemotely(Node nodeA, int x, int y) - { - Bounds bounds = (Bounds)nodeA.getLayoutConstraint(); - bounds.setX(x); - bounds.setY(y); - } - - public static void resizeNodeRemotely(Node nodeA, int height, int width) - { - Bounds bounds = (Bounds)nodeA.getLayoutConstraint(); - bounds.setHeight(height); - bounds.setWidth(width); - } - - public static boolean checkNodePosition(Node node, int x, int y) - { - boolean ret = true; - Bounds bounds = (Bounds)node.getLayoutConstraint(); - ret = bounds.getX() == x && ret; - ret = bounds.getY() == y && ret; - - return ret; - } - - public static boolean checkNodeSize(Node node, int height, int width) - { - boolean ret = true; - Bounds bounds = (Bounds)node.getLayoutConstraint(); - ret = bounds.getHeight() == height && ret; - ret = bounds.getWidth() == width && ret; - - return ret; - } - - public static boolean checkNodePosistionAndSize(Node node, int x, int y, int height, int width) - { - boolean ret = true; - ret = checkNodePosition(node, x, y) && ret; - ret = checkNodeSize(node, height, width) && ret; - - return ret; - } - - public static SWTBotView openView(SWTWorkbenchBot bot, String categoryName, String viewName) - { - bot.menu(LABEL_WINDOW).menu(LABEL_SHOW_VIEW).menu(LABEL_OTHERS).click(); - - SWTBotShell shell = bot.shell(LABEL_SHOW_VIEW); - shell.activate(); - bot.tree().expandNode(categoryName).select(viewName); - bot.button(LABEL_OK).click(); - - return bot.activeView(); - } - - @SuppressWarnings("unchecked") - public static SWTBotMenu findContextMenu(final AbstractSWTBot<?> bot, final String... texts) - { - final Matcher<?>[] matchers = new Matcher<?>[texts.length]; - for (int i = 0; i < texts.length; i++) - { - matchers[i] = allOf(instanceOf(MenuItem.class), withMnemonic(texts[i])); - } - - final MenuItem menuItem = UIThreadRunnable.syncExec(new WidgetResult<MenuItem>() - { - public MenuItem run() - { - MenuItem menuItem = null; - Control control = (Control)bot.widget; - Menu menu = control.getMenu(); - for (int i = 0; i < matchers.length; i++) - { - menuItem = show(menu, matchers[i]); - if (menuItem != null) - { - menu = menuItem.getMenu(); - } - } - - return menuItem; - } - }); - if (menuItem == null) - { - throw new WidgetNotFoundException("Could not find menu: " + Arrays.asList(texts)); - } - - return new SWTBotMenu(menuItem); - } - - private static MenuItem show(final Menu menu, final Matcher<?> matcher) - { - if (menu != null) - { - menu.notifyListeners(SWT.Show, new Event()); - MenuItem[] items = menu.getItems(); - for (final MenuItem menuItem : items) - { - if (matcher.matches(menuItem)) - { - return menuItem; - } - } - menu.notifyListeners(SWT.Hide, new Event()); - } - return null; - } - - public static void setAutomaticBuild(SWTWorkbenchBot bot, boolean enabled) - { - SWTBotMenu menu = bot.menu("Project").menu("Build Automatically"); - // if(menu.isEnabled()&&enabled) - { - menu.click(); - } - } - - // public static Edge createEdgeRemote(Node source, Node target, String type) - // { - // Edge newEdge = ViewService.createEdge(source, target, type, PreferencesHint.USE_DEFAULTS); - // - // return newEdge; - // } - // - // public static Edge createEdgeRemote(Node source, Node target, EObject model, String type) - // { - // Edge newEdge = ViewService.createEdge(source, target, model, type, PreferencesHint.USE_DEFAULTS); - // return newEdge; - // } - // - // public static Edge createEdgeRemote(Node source, Node target, String type, List<RelativeBendpoint> bendPoints) - // { - // Edge edge = createEdgeRemote(source, target, type); - // RelativeBendpoints exitingBendpoints = (RelativeBendpoints)edge.getBendpoints(); - // - // @SuppressWarnings("unchecked") - // List<RelativeBendpoint> points = exitingBendpoints.getPoints(); - // List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(points); - // newBendPoints.addAll(1, bendPoints); - // exitingBendpoints.setPoints(newBendPoints); - // - // return edge; - // } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui.util;
+
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.instanceOf;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart;
+import org.eclipse.emf.cdo.dawn.gmf.synchronize.DawnConflictHelper;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
+import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefConnectionEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher;
+import org.eclipse.swtbot.swt.finder.results.WidgetResult;
+import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnSWTBotUtil
+{
+ private static final String LABEL_OK = "OK";
+
+ private static final String LABEL_OTHERS = "Other...";
+
+ private static final String LABEL_WINDOW = "Window";
+
+ private static final String LABEL_SHOW_VIEW = "Show View";
+
+ public static void initTest(SWTWorkbenchBot bot)
+ {
+ closeWelcomePage(bot);
+ }
+
+ public static void closeWelcomePage(SWTWorkbenchBot bot)
+ {
+ try
+ {
+ bot.viewByTitle("Welcome").close();
+ }
+ catch (WidgetNotFoundException ex)
+ {
+ // We can ignore this because it it thrown when the widget cannot be found which can be the case if another test
+ // already closed the welcome screen.
+ }
+ }
+
+ public static void setConnectorType(SWTWorkbenchBot bot, String serverName, String serverPort, String repository,
+ String protocol)
+ {
+ bot.menu(LABEL_WINDOW).menu("Preferences").click();
+ SWTBotShell shell = bot.shell("Preferences");
+ shell.activate();
+
+ bot.tree().select("Dawn Remote Preferences");
+
+ SWTBotText serverNameLabel = bot.textWithLabel("server name:");
+ SWTBotText serverPortLabel = bot.textWithLabel("server port:");
+ SWTBotText repositoryLabel = bot.textWithLabel("repository:");
+ SWTBotText fileNameLabel = bot.textWithLabel("protocol:");
+
+ serverNameLabel.setText(serverName);
+ serverPortLabel.setText(serverPort);
+ repositoryLabel.setText(repository);
+ fileNameLabel.setText(protocol);
+ bot.button(LABEL_OK).click();
+ }
+
+ public static List<SWTBotGefEditPart> getAllEditParts(SWTBotGefEditor editor)
+ {
+ List<SWTBotGefEditPart> editParts = editor.editParts(new AbstractMatcher<EditPart>()
+ {
+ @Override
+ protected boolean doMatch(Object item)
+ {
+ return item instanceof AClassEditPart;
+ }
+
+ public void describeTo(Description description)
+ {
+ }
+ });
+ return editParts;
+ }
+
+ public static List<SWTBotGefEditPart> getConnectionEditParts(SWTBotGefEditor editor, Class<? extends EditPart> clazz)
+ {
+ List<SWTBotGefEditPart> editParts = getAllEditParts(editor);
+ return getConnectionEditParts(editor, clazz, editParts);
+ }
+
+ public static List<SWTBotGefEditPart> getConnectionEditParts(SWTBotGefEditor editor, Class<? extends EditPart> clazz,
+ List<SWTBotGefEditPart> editParts)
+ {
+
+ List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>();
+ for (SWTBotGefEditPart editPart : editParts)
+ {
+
+ for (SWTBotGefConnectionEditPart sourceConnection : editPart.sourceConnections())
+ {
+ if (clazz.isInstance(sourceConnection.part()))
+ {
+ ret.add(sourceConnection);
+ }
+ }
+ }
+ return ret;
+ }
+
+ static Object monitor = new Object();
+
+ /**
+ * returns all ConnectionEditparts from teh given editor
+ */
+ public static List<SWTBotGefEditPart> getAllConnections(final SWTBotGefEditor editor)
+ {
+ AbstractMatcher<EditPart> matcher = new AbstractMatcher<EditPart>()
+ {
+ @Override
+ protected boolean doMatch(Object item)
+ {
+ return true;
+ }
+
+ public void describeTo(Description description)
+ {
+ }
+ };
+ List<SWTBotGefEditPart> aClassEditParts = editor.editParts(matcher);
+
+ List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>();
+
+ for (SWTBotGefEditPart editPart : aClassEditParts)
+ {
+ ret.addAll(editPart.sourceConnections());
+ }
+ return ret;
+ }
+
+ public static Node createNewNodeRemote(Diagram diagram, AClass newAClass, String type)
+ {
+ Node newNode = ViewService.createNode(diagram, newAClass, type, PreferencesHint.USE_DEFAULTS);
+ return newNode;
+ }
+
+ public static Edge createEdgeRemote(Node source, Node target, String type, IElementType elementType,
+ List<RelativeBendpoint> bendpoints, IViewProvider viewProvider)
+ {
+ Edge edge = viewProvider.createEdge(elementType, source.getDiagram(), type, ViewUtil.APPEND, true,
+ PreferencesHint.USE_DEFAULTS);
+
+ edge.setTarget(target);
+ edge.setSource(source);
+
+ RelativeBendpoints exitingBendpoints = (RelativeBendpoints)edge.getBendpoints();
+ @SuppressWarnings("unchecked")
+ List<RelativeBendpoint> points = exitingBendpoints.getPoints();
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(points);
+ newBendPoints.addAll(1, bendpoints);
+ exitingBendpoints.setPoints(newBendPoints);
+
+ return edge;
+ }
+
+ public static void addBendPoint(Edge edge, int sourceX, int sourceY, int targetX, int targetY)
+ {
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>();
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(sourceX, sourceY, targetX, targetY);
+ newBendPoints.add(relativeBendpoint);
+ DawnSWTBotUtil.addBendpoints(edge, newBendPoints);
+ }
+
+ public static void addBendpoints(final Edge edge, final List<RelativeBendpoint> bendpoints)
+ {
+ ResourceSet resourceSet = edge.eResource().getResourceSet();
+
+ if (resourceSet instanceof IEditingDomainProvider)
+ {
+ EditingDomain editingDomain = ((IEditingDomainProvider)resourceSet).getEditingDomain();
+
+ editingDomain.getCommandStack().execute(new RecordingCommand((TransactionalEditingDomain)editingDomain)
+ {
+ @Override
+ protected void doExecute()
+ {
+ DawnSWTBotUtil.addBendPointsInternal(edge, bendpoints);
+ }
+ });
+ }
+ else
+ {
+ addBendPointsInternal(edge, bendpoints);
+ }
+ }
+
+ private static void addBendPointsInternal(final Edge edge, final List<RelativeBendpoint> bendpoints)
+ {
+ RelativeBendpoints exitingBendpoints = (RelativeBendpoints)edge.getBendpoints();
+ @SuppressWarnings("unchecked")
+ List<RelativeBendpoint> points = exitingBendpoints.getPoints();
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(points);
+ newBendPoints.addAll(1, bendpoints);
+ exitingBendpoints.setPoints(newBendPoints);
+ }
+
+ public static Object showsConflict(EditPart editPart)
+ {
+ return DawnConflictHelper.isConflicted((EObject)editPart.getModel());
+ }
+
+ public static void moveNodeRemotely(Node nodeA, int x, int y)
+ {
+ Bounds bounds = (Bounds)nodeA.getLayoutConstraint();
+ bounds.setX(x);
+ bounds.setY(y);
+ }
+
+ public static void resizeNodeRemotely(Node nodeA, int height, int width)
+ {
+ Bounds bounds = (Bounds)nodeA.getLayoutConstraint();
+ bounds.setHeight(height);
+ bounds.setWidth(width);
+ }
+
+ public static boolean checkNodePosition(Node node, int x, int y)
+ {
+ boolean ret = true;
+ Bounds bounds = (Bounds)node.getLayoutConstraint();
+ ret = bounds.getX() == x && ret;
+ ret = bounds.getY() == y && ret;
+
+ return ret;
+ }
+
+ public static boolean checkNodeSize(Node node, int height, int width)
+ {
+ boolean ret = true;
+ Bounds bounds = (Bounds)node.getLayoutConstraint();
+ ret = bounds.getHeight() == height && ret;
+ ret = bounds.getWidth() == width && ret;
+
+ return ret;
+ }
+
+ public static boolean checkNodePosistionAndSize(Node node, int x, int y, int height, int width)
+ {
+ boolean ret = true;
+ ret = checkNodePosition(node, x, y) && ret;
+ ret = checkNodeSize(node, height, width) && ret;
+
+ return ret;
+ }
+
+ public static SWTBotView openView(SWTWorkbenchBot bot, String categoryName, String viewName)
+ {
+ bot.menu(LABEL_WINDOW).menu(LABEL_SHOW_VIEW).menu(LABEL_OTHERS).click();
+
+ SWTBotShell shell = bot.shell(LABEL_SHOW_VIEW);
+ shell.activate();
+ bot.tree().expandNode(categoryName).select(viewName);
+ bot.button(LABEL_OK).click();
+
+ return bot.activeView();
+ }
+
+ @SuppressWarnings("unchecked")
+ public static SWTBotMenu findContextMenu(final AbstractSWTBot<?> bot, final String... texts)
+ {
+ final Matcher<?>[] matchers = new Matcher<?>[texts.length];
+ for (int i = 0; i < texts.length; i++)
+ {
+ matchers[i] = allOf(instanceOf(MenuItem.class), withMnemonic(texts[i]));
+ }
+
+ final MenuItem menuItem = UIThreadRunnable.syncExec(new WidgetResult<MenuItem>()
+ {
+ public MenuItem run()
+ {
+ MenuItem menuItem = null;
+ Control control = (Control)bot.widget;
+ Menu menu = control.getMenu();
+ for (int i = 0; i < matchers.length; i++)
+ {
+ menuItem = show(menu, matchers[i]);
+ if (menuItem != null)
+ {
+ menu = menuItem.getMenu();
+ }
+ }
+
+ return menuItem;
+ }
+ });
+ if (menuItem == null)
+ {
+ throw new WidgetNotFoundException("Could not find menu: " + Arrays.asList(texts));
+ }
+
+ return new SWTBotMenu(menuItem);
+ }
+
+ private static MenuItem show(final Menu menu, final Matcher<?> matcher)
+ {
+ if (menu != null)
+ {
+ menu.notifyListeners(SWT.Show, new Event());
+ MenuItem[] items = menu.getItems();
+ for (final MenuItem menuItem : items)
+ {
+ if (matcher.matches(menuItem))
+ {
+ return menuItem;
+ }
+ }
+ menu.notifyListeners(SWT.Hide, new Event());
+ }
+ return null;
+ }
+
+ public static void setAutomaticBuild(SWTWorkbenchBot bot, boolean enabled)
+ {
+ SWTBotMenu menu = bot.menu("Project").menu("Build Automatically");
+ // if(menu.isEnabled()&&enabled)
+ {
+ menu.click();
+ }
+ }
+
+ // public static Edge createEdgeRemote(Node source, Node target, String type)
+ // {
+ // Edge newEdge = ViewService.createEdge(source, target, type, PreferencesHint.USE_DEFAULTS);
+ //
+ // return newEdge;
+ // }
+ //
+ // public static Edge createEdgeRemote(Node source, Node target, EObject model, String type)
+ // {
+ // Edge newEdge = ViewService.createEdge(source, target, model, type, PreferencesHint.USE_DEFAULTS);
+ // return newEdge;
+ // }
+ //
+ // public static Edge createEdgeRemote(Node source, Node target, String type, List<RelativeBendpoint> bendPoints)
+ // {
+ // Edge edge = createEdgeRemote(source, target, type);
+ // RelativeBendpoints exitingBendpoints = (RelativeBendpoints)edge.getBendpoints();
+ //
+ // @SuppressWarnings("unchecked")
+ // List<RelativeBendpoint> points = exitingBendpoints.getPoints();
+ // List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(points);
+ // newBendPoints.addAll(1, bendPoints);
+ // exitingBendpoints.setPoints(newBendPoints);
+ //
+ // return edge;
+ // }
+}
|