Author: vyemialyanchyk
Date: 2009-04-09 09:22:12 -0400 (Thu, 09 Apr 2009)
New Revision: 14632
Added:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/.classpath
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/.cvsignore
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/.project
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/META-INF/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/META-INF/MANIFEST.MF
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/build.properties
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/plugin.properties
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/veditor/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/veditor/editors/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/veditor/editors/model/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/veditor/editors/model/test/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/veditor/editors/model/test/OrmDiagramTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/veditor/test/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/veditor/test/VisualEditorTestPlugin.java
Log:
JBIDE-4148 & JBIDE-4138 - unit test for OrmDiagram save & load
Added: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/.classpath
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/.classpath
(rev 0)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/.classpath 2009-04-09
13:22:12 UTC (rev 14632)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins">
+ <accessrules>
+ <accessrule kind="accessible" pattern="**/internal/**"/>
+ </accessrules>
+ </classpathentry>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/.cvsignore
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/.cvsignore
(rev 0)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/.cvsignore 2009-04-09
13:22:12 UTC (rev 14632)
@@ -0,0 +1,2 @@
+bin
+.settings
Added: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/.project
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/.project
(rev 0)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/.project 2009-04-09
13:22:12 UTC (rev 14632)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.hibernate.ui.veditor.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/META-INF/MANIFEST.MF
(rev 0)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/META-INF/MANIFEST.MF 2009-04-09
13:22:12 UTC (rev 14632)
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name.0
+Bundle-SymbolicName: org.jboss.tools.hibernate.ui.veditor.test
+Bundle-Version: 1.0.0
+Require-Bundle: org.junit;bundle-version="3.8.2",
+ org.eclipse.wst.common.project.facet.ui;bundle-version="1.3.0",
+ org.eclipse.jdt.core,
+ org.hibernate.eclipse.console.test,
+ org.jboss.tools.hibernate.ui.veditor,
+ org.hibernate.eclipse
+Bundle-ActivationPolicy: lazy
+Export-Package: org.jboss.tools.hibernate.ui.veditor.test
+Bundle-Activator: org.jboss.tools.hibernate.ui.veditor.test.VisualEditorTestPlugin
+Bundle-ClassPath: org.jboss.tools.hibernate.ui.veditor.test.jar
+Bundle-Vendor: %Bundle-Vendor.0
+Bundle-Localization: plugin
+Import-Package: org.eclipse.core.resources
Added:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/build.properties
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/build.properties
(rev 0)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/build.properties 2009-04-09
13:22:12 UTC (rev 14632)
@@ -0,0 +1,11 @@
+bin.includes = META-INF/,\
+ org.jboss.tools.hibernate.ui.veditor.test.jar,\
+ plugin.properties
+jars.compile.order = org.jboss.tools.hibernate.ui.veditor.test.jar
+source.org.jboss.tools.hibernate.ui.veditor.test.jar = src/
+output.org.jboss.tools.hibernate.ui.veditor.test.jar = bin/
+src.includes = src/,\
+ build.properties,\
+ META-INF/,\
+ .project,\
+ .classpath
Added:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/plugin.properties
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/plugin.properties
(rev 0)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/plugin.properties 2009-04-09
13:22:12 UTC (rev 14632)
@@ -0,0 +1,3 @@
+#Properties file for org.jboss.tools.hibernate.ui.veditor.test
+Bundle-Vendor.0 = JBoss, a division of Red Hat
+Bundle-Name.0 = Visual Editor Test Plug-in
\ No newline at end of file
Added:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/veditor/editors/model/test/OrmDiagramTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/veditor/editors/model/test/OrmDiagramTest.java
(rev 0)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/veditor/editors/model/test/OrmDiagramTest.java 2009-04-09
13:22:12 UTC (rev 14632)
@@ -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.veditor.editors.model.test;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.mapping.RootClass;
+import org.jboss.tools.hibernate.ui.veditor.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 consoleConfiguration =
context.mock(ConsoleConfiguration.class);
+ final Configuration configuration = context.mock(Configuration.class);
+ final RootClass ioe = context.mock(RootClass.class);
+ final IJavaProject javaProject = context.mock(IJavaProject.class);
+ final List<Object> emptyList = new ArrayList<Object>();
+ final Iterator<Object> emptyListIterator = emptyList.iterator();
+ final IProject project = context.mock(IProject.class);
+
+ context.checking(new Expectations() {
+ {
+ oneOf(consoleConfiguration).getConfiguration();
+ will(returnValue(configuration));
+
+ 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(javaProject).getProject();
+ will(returnValue(project));
+
+ allowing(project).getLocation();
+ will(returnValue(Path.fromOSString(""))); //$NON-NLS-1$
+
+ allowing(ioe).getClassName();
+ will(returnValue("ClassName")); //$NON-NLS-1$
+
+ allowing(consoleConfiguration).getName();
+ will(returnValue("CCName")); //$NON-NLS-1$
+
+ allowing(ioe).getEntityName();
+ will(returnValue("")); //$NON-NLS-1$
+ }
+ });
+ final OrmDiagram ormDiagram = new OrmDiagram(consoleConfiguration, ioe, javaProject);
+ ormDiagram.save();
+ // 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/veditor/test/VisualEditorTestPlugin.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/veditor/test/VisualEditorTestPlugin.java
(rev 0)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.veditor.test/src/org/jboss/tools/hibernate/ui/veditor/test/VisualEditorTestPlugin.java 2009-04-09
13:22:12 UTC (rev 14632)
@@ -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.veditor.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 VisualEditorTestPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID =
"org.jboss.tools.hibernate.ui.veditor.test"; //$NON-NLS-1$
+
+ // The shared instance
+ private static VisualEditorTestPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public VisualEditorTestPlugin() {
+ }
+
+ /*
+ * (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 VisualEditorTestPlugin getDefault() {
+ return plugin;
+ }
+
+ private static void setPlugin(VisualEditorTestPlugin plugin) {
+ VisualEditorTestPlugin.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));
+ }
+ }
+
+}