Author: vyemialyanchyk
Date: 2009-07-02 14:56:47 -0400 (Thu, 02 Jul 2009)
New Revision: 16361
Added:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/ExportImageActionTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/model/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/model/test/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/model/test/OrmDiagramTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/test/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/test/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/test/UiTestPlugin.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4524 - rename veditor plugin
Added:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/ExportImageActionTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/ExportImageActionTest.java
(rev 0)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/test/ExportImageActionTest.java 2009-07-02
18:56:47 UTC (rev 16361)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.actions.test;
+
+import java.io.File;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.SWTGraphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
+import org.jboss.tools.hibernate.ui.diagram.editors.actions.ExportImageAction;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.lib.legacy.ClassImposteriser;
+
+import junit.framework.TestCase;
+
+/**
+ * for ExportImageAction class functionality test
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ExportImageActionTest extends TestCase {
+
+ public Mockery context = new Mockery() {
+ {
+ setImposteriser(ClassImposteriser.INSTANCE);
+ }
+ };
+
+ public void testAction() {
+
+ final DiagramViewer editor = context.mock(DiagramViewer.class);;
+ final FileDialog saveDialog = context.mock(FileDialog.class);;
+ final GraphicalViewer graphicalViewer = context.mock(GraphicalViewer.class);;
+ final ScalableFreeformRootEditPart scalableFreeformRootEditPart =
context.mock(ScalableFreeformRootEditPart.class);;
+ final IFigure figure = context.mock(IFigure.class);;
+ final Control control = context.mock(Control.class);;
+ final Display display = context.mock(Display.class);;
+ final Rectangle rectangle = new Rectangle(0, 0, 20, 10);
+ final String filePath = "test.jpg"; //$NON-NLS-1$
+
+ context.checking(new Expectations() {
+ {
+ allowing(saveDialog).setFilterExtensions(ExportImageAction.dialogFilterExtensions);
+ allowing(saveDialog).setFilterNames(ExportImageAction.dialogFilterNames);
+
+ oneOf(saveDialog).open();
+ will(returnValue(filePath));
+
+ allowing(editor).getEditPartViewer();
+ will(returnValue(graphicalViewer));
+
+ allowing(graphicalViewer).getRootEditPart();
+ will(returnValue(scalableFreeformRootEditPart));
+
+ allowing(scalableFreeformRootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
+ will(returnValue(figure));
+
+ allowing(graphicalViewer).getControl();
+ will(returnValue(control));
+
+ allowing(control).getDisplay();
+ will(returnValue(display));
+
+ allowing(figure).getBounds();
+ will(returnValue(rectangle));
+
+ allowing(display).internal_new_GC(null);
+ will(returnValue(0));
+
+ allowing(display).internal_dispose_GC(0, null);
+
+ oneOf(figure).paint(with(any(SWTGraphics.class)));
+
+ allowing(display).isDisposed();
+ will(returnValue(true));
+ }
+ });
+ final ExportImageAction exportImageAction = new ExportImageAction(editor);
+ exportImageAction.setSaveDialog(saveDialog);
+ exportImageAction.run();
+ // test is the file created
+ File file = new File(filePath);
+ assertTrue(file.exists() && file.isFile());
+ //
+ boolean res = file.delete();
+ assertTrue(res);
+ // GENERAL TEST:
+ // check for all expectations
+ context.assertIsSatisfied();
+
+ }
+
+
+}
Added:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/model/test/OrmDiagramTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/model/test/OrmDiagramTest.java
(rev 0)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/diagram/editors/model/test/OrmDiagramTest.java 2009-07-02
18:56:47 UTC (rev 16361)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.diagram.editors.model.test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.mapping.RootClass;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.OrmDiagram;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.lib.legacy.ClassImposteriser;
+
+import junit.framework.TestCase;
+
+/**
+ * for OrmDiagram class functionality test
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class OrmDiagramTest extends TestCase {
+
+ public Mockery context = new Mockery() {
+ {
+ setImposteriser(ClassImposteriser.INSTANCE);
+ }
+ };
+
+ public void testLoadAndSave() {
+
+ final ConsoleConfiguration consoleConfig = context.mock(ConsoleConfiguration.class);
+ final RootClass ioe = context.mock(RootClass.class);
+ final List<Object> emptyList = new ArrayList<Object>();
+ final Iterator<Object> emptyListIterator = emptyList.iterator();
+
+ context.checking(new Expectations() {
+ {
+ oneOf(ioe).getEntityName();
+ will(returnValue("testEntityName")); //$NON-NLS-1$
+
+ oneOf(ioe).getEntityName();
+ will(returnValue("")); //$NON-NLS-1$
+
+ oneOf(ioe).getEntityName();
+ will(returnValue("")); //$NON-NLS-1$
+
+ oneOf(ioe).getIdentifierProperty();
+ will(returnValue(null));
+
+ oneOf(ioe).getIdentifier();
+ will(returnValue(null));
+
+ oneOf(ioe).getPropertyIterator();
+ will(returnValue(emptyListIterator));
+
+ oneOf(ioe).getTable();
+ will(returnValue(null));
+
+ oneOf(ioe).getSubclassIterator();
+ will(returnValue(emptyListIterator));
+
+ oneOf(ioe).getIdentifier();
+ will(returnValue(null));
+
+ oneOf(ioe).getJoinIterator();
+ will(returnValue(emptyListIterator));
+
+ allowing(ioe).getNodeName();
+ will(returnValue("NodeName")); //$NON-NLS-1$
+
+ allowing(ioe).getClassName();
+ will(returnValue("ClassName")); //$NON-NLS-1$
+
+ allowing(consoleConfig).getName();
+ will(returnValue("CCName")); //$NON-NLS-1$
+
+ allowing(ioe).getEntityName();
+ will(returnValue("")); //$NON-NLS-1$
+ }
+ });
+ final OrmDiagram ormDiagram = new OrmDiagram(consoleConfig, ioe);
+ ormDiagram.save();
+ // test is the folder created
+ File folder = new File(ormDiagram.getStoreFolderPath().toOSString());
+ assertTrue(folder.exists() && folder.isDirectory());
+ // test is the file created
+ File file = new File(ormDiagram.getStoreFilePath().toOSString());
+ assertTrue(file.exists() && file.isFile());
+ //
+ boolean res = file.delete();
+ assertTrue(res);
+ //
+ res = folder.delete();
+ assertTrue(res);
+ // GENERAL TEST:
+ // check for all expectations
+ context.assertIsSatisfied();
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/test/UiTestPlugin.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/test/UiTestPlugin.java
(rev 0)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/test/UiTestPlugin.java 2009-07-02
18:56:47 UTC (rev 16361)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class UiTestPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.hibernate.ui.test";
//$NON-NLS-1$
+
+ // The shared instance
+ private static UiTestPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public UiTestPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ setPlugin(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
+ */
+ public void stop(BundleContext context) throws Exception {
+ setPlugin(null);
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static UiTestPlugin getDefault() {
+ return plugin;
+ }
+
+ private static void setPlugin(UiTestPlugin plugin) {
+ UiTestPlugin.plugin = plugin;
+ }
+
+ public File getFileInPlugin(IPath path) throws CoreException {
+ try {
+ URL installURL = new URL(getBundle().getEntry("/"), path.toString());
//$NON-NLS-1$
+ URL localURL = FileLocator.toFileURL(installURL);
+ return new File(localURL.getFile());
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, getBundle()
+ .getSymbolicName(), IStatus.ERROR, e.getMessage(), e));
+ }
+ }
+
+}