Author: vyemialyanchyk
Date: 2011-02-03 07:16:49 -0500 (Thu, 03 Feb 2011)
New Revision: 28965
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Address.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Company.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Customer.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Address.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Company.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Customer.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/BaseTestSetCase.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/CheckConsoleConfigTest.java
Removed:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/dom4j-1.6.1.jar
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/ejb3-persistence.jar
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/hibernate3.jar
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Address.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Company.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Customer.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Person.java
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Customer.hbm.xml
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Customer.hbm.xml
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsAnnotations.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsJpa.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingDiagramTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenSourceFileTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/ConfigurableTestProject.java
Log:
https://issues.jboss.org/browse/JBIDE-8147 - update junit tests -> check Hibernate
Configuration & code refactoring
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/dom4j-1.6.1.jar
===================================================================
(Binary files differ)
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/ejb3-persistence.jar
===================================================================
(Binary files differ)
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/hibernate3.jar
===================================================================
(Binary files differ)
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Address.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Address.java 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Address.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -1,18 +0,0 @@
-package mapping.dynamicentity;
-
-/**
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole
</a>
- */
-public interface Address {
- public Long getId();
- public void setId(Long id);
-
- public String getStreet();
- public void setStreet(String street);
-
- public String getCity();
- public void setCity(String city);
-
- public String getPostalCode();
- public void setPostalCode(String postalCode);
-}
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Company.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Company.java 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Company.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -1,11 +0,0 @@
-package mapping.dynamicentity;
-
-/**
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole
</a>
- */
-public interface Company {
- public Long getId();
- public void setId(Long id);
- public String getName();
- public void setName(String name);
-}
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Customer.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Customer.java 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Customer.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -1,9 +0,0 @@
-package mapping.dynamicentity;
-
-/**
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole
</a>
- */
-public interface Customer extends Person {
- public Company getCompany();
- public void setCompany(Company company);
-}
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Person.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Person.java 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Person.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -1,17 +0,0 @@
-package mapping.dynamicentity;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole
</a>
- */
-public interface Person {
- public Long getId();
- public void setId(Long id);
- public String getName();
- public void setName(String name);
- public Address getAddress();
- public void setAddress(Address address);
- public Set getFamily();
- public void setFamily(Set family);
-}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Address.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Address.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Address.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -0,0 +1,18 @@
+package mapping.dynamicentity.interceptor;
+
+/**
+ * @author <a href="mailto:steve@hibernate.org">Steve Ebersole
</a>
+ */
+public interface Address {
+ public Long getId();
+ public void setId(Long id);
+
+ public String getStreet();
+ public void setStreet(String street);
+
+ public String getCity();
+ public void setCity(String city);
+
+ public String getPostalCode();
+ public void setPostalCode(String postalCode);
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Company.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Company.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Company.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -0,0 +1,11 @@
+package mapping.dynamicentity.interceptor;
+
+/**
+ * @author <a href="mailto:steve@hibernate.org">Steve Ebersole
</a>
+ */
+public interface Company {
+ public Long getId();
+ public void setId(Long id);
+ public String getName();
+ public void setName(String name);
+}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Customer.hbm.xml
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Customer.hbm.xml 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Customer.hbm.xml 2011-02-03
12:16:49 UTC (rev 28965)
@@ -3,7 +3,7 @@
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping package="mapping.dynamicentity">
+<hibernate-mapping package="mapping.dynamicentity.interceptor">
<!--
Mapping the Customer and Company interfaces. Our custom Interceptor
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Customer.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Customer.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Customer.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -0,0 +1,9 @@
+package mapping.dynamicentity.interceptor;
+
+/**
+ * @author <a href="mailto:steve@hibernate.org">Steve Ebersole
</a>
+ */
+public interface Customer extends Person {
+ public Company getCompany();
+ public void setCompany(Company company);
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Person.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Person.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/interceptor/Person.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -0,0 +1,17 @@
+package mapping.dynamicentity.interceptor;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:steve@hibernate.org">Steve Ebersole
</a>
+ */
+public interface Person {
+ public Long getId();
+ public void setId(Long id);
+ public String getName();
+ public void setName(String name);
+ public Address getAddress();
+ public void setAddress(Address address);
+ public Set getFamily();
+ public void setFamily(Set family);
+}
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Address.java
(from rev 28039,
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Address.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Address.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Address.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -0,0 +1,18 @@
+package mapping.dynamicentity.tuplizer;
+
+/**
+ * @author <a href="mailto:steve@hibernate.org">Steve Ebersole
</a>
+ */
+public interface Address {
+ public Long getId();
+ public void setId(Long id);
+
+ public String getStreet();
+ public void setStreet(String street);
+
+ public String getCity();
+ public void setCity(String city);
+
+ public String getPostalCode();
+ public void setPostalCode(String postalCode);
+}
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Company.java
(from rev 28039,
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Company.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Company.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Company.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -0,0 +1,11 @@
+package mapping.dynamicentity.tuplizer;
+
+/**
+ * @author <a href="mailto:steve@hibernate.org">Steve Ebersole
</a>
+ */
+public interface Company {
+ public Long getId();
+ public void setId(Long id);
+ public String getName();
+ public void setName(String name);
+}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Customer.hbm.xml
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Customer.hbm.xml 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Customer.hbm.xml 2011-02-03
12:16:49 UTC (rev 28965)
@@ -3,7 +3,7 @@
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping package="mapping.dynamicentity">
+<hibernate-mapping package="mapping.dynamicentity.tuplizer">
<!--
Mapping the Customer and Company interfaces. Our custom Interceptor
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Customer.java
(from rev 28039,
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Customer.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Customer.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Customer.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -0,0 +1,9 @@
+package mapping.dynamicentity.tuplizer;
+
+/**
+ * @author <a href="mailto:steve@hibernate.org">Steve Ebersole
</a>
+ */
+public interface Customer extends Person {
+ public Company getCompany();
+ public void setCompany(Company company);
+}
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Person.java
(from rev 28039,
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/Person.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Person.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/mapping/dynamicentity/tuplizer/Person.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -0,0 +1,17 @@
+package mapping.dynamicentity.tuplizer;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:steve@hibernate.org">Steve Ebersole
</a>
+ */
+public interface Person {
+ public Long getId();
+ public void setId(Long id);
+ public String getName();
+ public void setName(String name);
+ public Address getAddress();
+ public void setAddress(Address address);
+ public Set getFamily();
+ public void setFamily(Set family);
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/BaseTestSetCase.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/BaseTestSetCase.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/BaseTestSetCase.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.hibernate.eclipse.console.test.mappingproject;
+
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.hibernate.InvalidMappingException;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
+import org.hibernate.console.execution.ExecutionContext;
+import org.hibernate.eclipse.console.test.ConsoleTestMessages;
+import org.hibernate.eclipse.console.workbench.ConfigurationWorkbenchAdapter;
+import org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter;
+import org.hibernate.eclipse.console.workbench.PersistentClassWorkbenchAdapter;
+import org.hibernate.eclipse.console.workbench.PropertyWorkbenchAdapter;
+
+import junit.framework.TestCase;
+
+/**
+ * @author vy (vyemialyanchyk(a)gmail.com)
+ */
+public class BaseTestSetCase extends TestCase {
+
+ protected int openEditors = 0;
+
+ protected String consoleConfigName = null;
+
+ protected IPackageFragment testPackage = null;
+
+ final static protected ConsoleConfigurationWorkbenchAdapter ccWorkbenchAdapter = new
ConsoleConfigurationWorkbenchAdapter();
+
+ final static protected ConfigurationWorkbenchAdapter configWorkbenchAdapter = new
ConfigurationWorkbenchAdapter();
+
+ final static protected PersistentClassWorkbenchAdapter pcWorkbenchAdapter = new
PersistentClassWorkbenchAdapter();
+
+ final static protected PropertyWorkbenchAdapter propertyWorkbenchAdapter = new
PropertyWorkbenchAdapter();
+
+ public BaseTestSetCase() {
+ }
+
+ public BaseTestSetCase(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ }
+
+ protected void tearDown() throws Exception {
+ consoleConfigName = null;
+ testPackage = null;
+ closeAllEditors();
+ }
+
+ public Object[] getPersistenceClasses(boolean resetCC) {
+ final ConsoleConfiguration consCFG = getConsoleConfig();
+ if (resetCC) {
+ consCFG.reset();
+ consCFG.build();
+ }
+ assertTrue(consCFG.hasConfiguration());
+ if (resetCC) {
+ consCFG.execute(new ExecutionContext.Command() {
+ public Object execute() {
+ if (consCFG.hasConfiguration()) {
+ consCFG.getConfiguration().buildMappings();
+ }
+ return consCFG;
+ }
+ });
+ }
+ Object[] configs = null;
+ Object[] persClasses = null;
+ try {
+ configs = ccWorkbenchAdapter.getChildren(consCFG);
+ assertNotNull(configs);
+ assertEquals(3, configs.length);
+ assertTrue(configs[0] instanceof Configuration);
+ persClasses = configWorkbenchAdapter.getChildren(configs[0]);
+ } catch (InvalidMappingException ex) {
+ String out =
NLS.bind(ConsoleTestMessages.OpenMappingDiagramTest_mapping_diagrams_for_package_cannot_be_opened,
+ new Object[] { testPackage.getElementName(), ex.getMessage() });
+ fail(out);
+ }
+ return persClasses;
+ }
+
+ public ConsoleConfiguration getConsoleConfig() {
+ KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
+ final ConsoleConfiguration consCFG = knownConfigurations.find(consoleConfigName);
+ assertNotNull(consCFG);
+ return consCFG;
+ }
+
+ public String getConsoleConfigName() {
+ return consoleConfigName;
+ }
+
+ public void setConsoleConfigName(String consoleConfigName) {
+ this.consoleConfigName = consoleConfigName;
+ }
+
+ public IPackageFragment getTestPackage() {
+ return testPackage;
+ }
+
+ public void setTestPackage(IPackageFragment testPackage) {
+ this.testPackage = testPackage;
+ }
+
+ protected void closeAllEditors() {
+ final IWorkbenchWindow workbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (workbenchWindow != null) {
+ final IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
+ if (workbenchPage != null) {
+ openEditors += workbenchPage.getEditorReferences().length;
+ workbenchPage.closeAllEditors(false);
+ }
+ }
+ // clean up event queue to avoid "memory leak",
+ // this is necessary to fix
https://jira.jboss.org/jira/browse/JBIDE-4824
+ while (Display.getCurrent().readAndDispatch());
+ }
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/CheckConsoleConfigTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/CheckConsoleConfigTest.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/CheckConsoleConfigTest.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.hibernate.eclipse.console.test.mappingproject;
+
+import org.hibernate.mapping.PersistentClass;
+
+/**
+ * @author vy (vyemialyanchyk(a)gmail.com)
+ */
+public class CheckConsoleConfigTest extends BaseTestSetCase {
+
+ public CheckConsoleConfigTest() {
+ }
+
+ public CheckConsoleConfigTest(String name) {
+ super(name);
+ }
+
+ public void testCheckConsoleConfiguration() {
+ Object[] persClasses = getPersistenceClasses(true);
+ assertTrue(persClasses.length > 0);
+ for (int i = 0; i < persClasses.length; i++) {
+ assertTrue(persClasses[i] instanceof PersistentClass);
+ }
+ }
+}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -13,21 +13,17 @@
import java.io.File;
import java.io.PrintWriter;
-import junit.framework.TestCase;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.PackageFragmentRoot;
import org.eclipse.osgi.util.NLS;
import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.KnownConfigurations;
import org.hibernate.console.execution.ExecutionContext;
import org.hibernate.eclipse.console.test.ConsoleTestMessages;
import org.hibernate.eclipse.console.test.project.ConfigurableTestProject;
@@ -42,11 +38,7 @@
*
*/
@SuppressWarnings("restriction")
-public class HbmExportExceptionTest extends TestCase {
-
- protected String consoleConfigName = null;
-
- protected IPackageFragment testPackage = null;
+public class HbmExportExceptionTest extends BaseTestSetCase {
protected ConfigurableTestProject testProject = null;
@@ -56,39 +48,22 @@
public HbmExportExceptionTest(String name) {
super(name);
}
-
- protected void setUp() throws Exception {
- }
protected void tearDown() throws Exception {
testProject = null;
- consoleConfigName = null;
- testPackage = null;
+ super.tearDown();
}
public void testHbmExportExceptionTest() throws Exception {
try {
- KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
- final ConsoleConfiguration consCFG = knownConfigurations.find(consoleConfigName);
- assertNotNull(consCFG);
- consCFG.reset();
- consCFG.build();
- assertTrue(consCFG.hasConfiguration());
- consCFG.execute( new ExecutionContext.Command() {
+ Object[] persClassesInit = getPersistenceClasses(false);
- public Object execute() {
- if(consCFG.hasConfiguration()) {
- consCFG.getConfiguration().buildMappings();
- }
- return consCFG;
- }
- } );
+ final ConsoleConfiguration consCFG = getConsoleConfig();
Configuration config = consCFG.getConfiguration();
-
//delete old hbm files
- assertNotNull( testPackage );
+ assertNotNull(testPackage);
int nDeleted = 0;
- if (testPackage.getNonJavaResources().length > 0){
+ if (testPackage.getNonJavaResources().length > 0) {
Object[] ress = testPackage.getNonJavaResources();
for (int i = 0; i < ress.length; i++) {
if (ress[i] instanceof IFile){
@@ -103,9 +78,8 @@
HibernateMappingGlobalSettings hmgs = new HibernateMappingGlobalSettings();
-
HibernateMappingExporter hce = new HibernateMappingExporter(config,
- getSrcFolder());
+ getSrcFolder());
hce.setGlobalSettings(hmgs);
try {
@@ -119,19 +93,17 @@
ConsoleConfigUtils.customizeCfgXmlForPack(testPackage);
assertNotNull(consCFG);
consCFG.reset();
-
- consCFG.build();
- assertTrue(consCFG.hasConfiguration());
- consCFG.execute( new ExecutionContext.Command() {
-
- public Object execute() {
- if(consCFG.hasConfiguration()) {
- consCFG.getConfiguration().buildMappings();
- }
- return consCFG;
+ consCFG.build();
+ assertTrue(consCFG.hasConfiguration());
+ consCFG.execute(new ExecutionContext.Command() {
+ public Object execute() {
+ if(consCFG.hasConfiguration()) {
+ consCFG.getConfiguration().buildMappings();
}
- } );
- config = consCFG.getConfiguration();
+ return consCFG;
+ }
+ });
+ config = consCFG.getConfiguration();
} catch (CoreException e) {
String out =
NLS.bind(ConsoleTestMessages.UpdateConfigurationTest_error_customising_file_for_package,
new Object[] { ConsoleConfigUtils.CFG_FILE_NAME, testPackage.getPath(),
e.getMessage() } );
@@ -141,11 +113,13 @@
throw (Exception)e.getCause();
}
//
+ Object[] persClassesReInit = getPersistenceClasses(false);
+ //
int nCreated = 0;
- if (testPackage.getNonJavaResources().length > 0){
+ if (testPackage.getNonJavaResources().length > 0) {
Object[] ress = testPackage.getNonJavaResources();
for (int i = 0; i < ress.length; i++) {
- if (ress[i] instanceof IFile){
+ if (ress[i] instanceof IFile) {
IFile res = (IFile)ress[i];
if (res.getName().endsWith(".hbm.xml")) { //$NON-NLS-1$
nCreated++;
@@ -154,7 +128,10 @@
}
}
//
- assert(nDeleted <= nCreated);
+ assertTrue(persClassesInit.length == persClassesReInit.length);
+ assertTrue(nCreated > 0);
+ assertTrue(nDeleted >= 0 && persClassesInit.length > 0);
+ assertTrue(nCreated <= persClassesInit.length);
} catch (Exception e){
String newMessage = "\nPackage " + testPackage.getElementName() +
":"; //$NON-NLS-1$ //$NON-NLS-2$
throw new WripperException(newMessage, e);
@@ -173,22 +150,6 @@
return packageFragmentRoot.getResource().getLocation().toFile();
}
- public String getConsoleConfigName() {
- return consoleConfigName;
- }
-
- public void setConsoleConfigName(String consoleConfigName) {
- this.consoleConfigName = consoleConfigName;
- }
-
- public IPackageFragment getTestPackage() {
- return testPackage;
- }
-
- public void setTestPackage(IPackageFragment testPackage) {
- this.testPackage = testPackage;
- }
-
public ConfigurableTestProject getTestProject() {
return testProject;
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsAnnotations.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsAnnotations.java 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsAnnotations.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -43,7 +43,7 @@
projName, File.separator + projName + File.separator + annotationsMarkerCfgXml);
}
- static final String annotationsMarkerStr = TestProject.SRC_FOLDER + File.separator +
"annotations"; //$NON-NLS-1$
+ public static final String annotationsMarkerStr = TestProject.SRC_FOLDER +
File.separator + "annotations"; //$NON-NLS-1$
public static final FileFilter filterFoldersAnnotations = new FileFilter() {
public boolean accept(File f) {
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsJpa.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsJpa.java 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsJpa.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -35,8 +35,8 @@
testProject.getIProject().getName(), "PetClinic"); //$NON-NLS-1$
}
- static final String jpaMarkerStr = TestProject.SRC_FOLDER + File.separator +
"jpa"; //$NON-NLS-1$
- static final String jpaMarkerMetaInf = TestProject.SRC_FOLDER + File.separator +
"meta-inf"; //$NON-NLS-1$
+ public static final String jpaMarkerStr = TestProject.SRC_FOLDER + File.separator +
"jpa"; //$NON-NLS-1$
+ public static final String jpaMarkerMetaInf = TestProject.SRC_FOLDER + File.separator +
"meta-inf"; //$NON-NLS-1$
public static final FileFilter filterFoldersJpa = new FileFilter() {
public boolean accept(File f) {
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingDiagramTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingDiagramTest.java 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingDiagramTest.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -10,24 +10,12 @@
******************************************************************************/
package org.hibernate.eclipse.console.test.mappingproject;
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.hibernate.InvalidMappingException;
-import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.KnownConfigurations;
import org.hibernate.eclipse.console.test.ConsoleTestMessages;
import org.hibernate.eclipse.console.test.utils.Utils;
-import org.hibernate.eclipse.console.workbench.ConfigurationWorkbenchAdapter;
-import org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter;
import org.hibernate.mapping.PersistentClass;
import org.jboss.tools.hibernate.ui.view.OpenDiagramActionDelegate;
@@ -35,99 +23,38 @@
* @author Dmitry Geraskov
*
*/
-public class OpenMappingDiagramTest extends TestCase {
+public class OpenMappingDiagramTest extends BaseTestSetCase {
- protected String consoleConfigName = null;
-
- protected IPackageFragment testPackage = null;
-
- protected int openEditors = 0;
-
public OpenMappingDiagramTest() {
}
public OpenMappingDiagramTest(String name) {
super(name);
}
-
- protected void setUp() throws Exception {
- }
- protected void tearDown() throws Exception {
- consoleConfigName = null;
- testPackage = null;
- closeAllEditors();
- }
-
public void testOpenMappingDiagram() {
- KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
- final ConsoleConfiguration consCFG = knownConfigurations.find(consoleConfigName);
- assertNotNull(consCFG);
- consCFG.reset();
- Object[] configs = null;
- Object[] persClasses = null;
- try {
- configs = new ConsoleConfigurationWorkbenchAdapter().getChildren(consCFG);
- assertTrue(configs[0] instanceof Configuration);
- persClasses = new ConfigurationWorkbenchAdapter().getChildren(configs[0]);
- } catch (InvalidMappingException ex){
- String out =
NLS.bind(ConsoleTestMessages.OpenMappingDiagramTest_mapping_diagrams_for_package_cannot_be_opened,
- new Object[]{testPackage.getElementName(), ex.getMessage()});
- fail(out);
- }
+ final Object[] persClasses = getPersistenceClasses(false);
+ final ConsoleConfiguration consCFG = getConsoleConfig();
+ for (int i = 0; i < persClasses.length; i++) {
+ assertTrue(persClasses[i] instanceof PersistentClass);
+ PersistentClass persClass = (PersistentClass) persClasses[i];
- if (persClasses.length > 0){
- for (int i = 0; i < persClasses.length; i++) {
- assertTrue(persClasses[i] instanceof PersistentClass);
- PersistentClass persClass = (PersistentClass) persClasses[i];
-
- IEditorPart editor = null;
- Throwable ex = null;
- try {
- editor = new OpenDiagramActionDelegate().openEditor(persClass, consCFG);
- } catch (PartInitException e) {
- ex = e;
- }
- if (ex == null ) {
- ex = Utils.getExceptionIfItOccured(editor);
- }
- if (ex != null) {
- String out =
NLS.bind(ConsoleTestMessages.OpenMappingDiagramTest_mapping_diagram_for_not_opened,
- new Object[]{persClass.getClassName(), ex.getMessage()});
- fail(out);
- }
+ IEditorPart editor = null;
+ Throwable ex = null;
+ try {
+ editor = new OpenDiagramActionDelegate().openEditor(persClass, consCFG);
+ } catch (PartInitException e) {
+ ex = e;
}
+ if (ex == null ) {
+ ex = Utils.getExceptionIfItOccured(editor);
+ }
+ if (ex != null) {
+ String out =
NLS.bind(ConsoleTestMessages.OpenMappingDiagramTest_mapping_diagram_for_not_opened,
+ new Object[]{persClass.getClassName(), ex.getMessage()});
+ fail(out);
+ }
}
//close all editors
}
-
- public String getConsoleConfigName() {
- return consoleConfigName;
- }
-
- public void setConsoleConfigName(String consoleConfigName) {
- this.consoleConfigName = consoleConfigName;
- }
-
- public IPackageFragment getTestPackage() {
- return testPackage;
- }
-
- public void setTestPackage(IPackageFragment testPackage) {
- this.testPackage = testPackage;
- }
-
- protected void closeAllEditors() {
- final IWorkbenchWindow workbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (workbenchWindow != null) {
- final IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
- if (workbenchPage != null) {
- openEditors += workbenchPage.getEditorReferences().length;
- workbenchPage.closeAllEditors(false);
- }
- }
- // clean up event queue to avoid "memory leak",
- // this is necessary to fix
https://jira.jboss.org/jira/browse/JBIDE-4824
- while (Display.getCurrent().readAndDispatch());
- }
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -12,28 +12,14 @@
import java.io.FileNotFoundException;
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.hibernate.InvalidMappingException;
-import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.KnownConfigurations;
import org.hibernate.eclipse.console.actions.OpenMappingAction;
import org.hibernate.eclipse.console.test.ConsoleTestMessages;
import org.hibernate.eclipse.console.test.utils.Utils;
-import org.hibernate.eclipse.console.workbench.ConfigurationWorkbenchAdapter;
-import org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter;
-import org.hibernate.eclipse.console.workbench.PersistentClassWorkbenchAdapter;
-import org.hibernate.eclipse.console.workbench.PropertyWorkbenchAdapter;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
@@ -41,71 +27,40 @@
* @author Dmitry Geraskov
*
*/
-public class OpenMappingFileTest extends TestCase {
+public class OpenMappingFileTest extends BaseTestSetCase {
- protected String consoleConfigName = null;
-
- protected IPackageFragment testPackage = null;
-
- protected int openEditors = 0;
-
public OpenMappingFileTest() {
}
public OpenMappingFileTest(String name) {
super(name);
}
-
- protected void setUp() throws Exception {
- }
- protected void tearDown() throws Exception {
- consoleConfigName = null;
- testPackage = null;
- closeAllEditors();
- }
-
public void testOpenMappingFileTest() {
- KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
- final ConsoleConfiguration consCFG = knownConfigurations.find(consoleConfigName);
- assertNotNull(consCFG);
- consCFG.reset();
- Object[] configs = null;
- Object[] persClasses = null;
- Object[] props = null;
- try {
- configs = new ConsoleConfigurationWorkbenchAdapter().getChildren(consCFG);
- assertTrue(configs[0] instanceof Configuration);
- persClasses = new ConfigurationWorkbenchAdapter().getChildren(configs[0]);
- } catch (InvalidMappingException ex){
- String out =
NLS.bind(ConsoleTestMessages.OpenMappingFileTest_mapping_files_for_package_cannot_be_opened,
- new Object[]{testPackage.getElementName(), ex.getMessage()});
- fail(out);
- }
- if (persClasses.length > 0) {
- final String testClass = "class"; //$NON-NLS-1$
- for (int i = 0; i < persClasses.length; i++) {
- assertTrue(persClasses[i] instanceof PersistentClass);
- PersistentClass persClass = (PersistentClass) persClasses[i];
- openTest(persClass, consCFG);
- props = new PersistentClassWorkbenchAdapter().getChildren(persClass);
- for (int j = 0; j < props.length; j++) {
- if (props[j].getClass() != Property.class) {
+ final Object[] persClasses = getPersistenceClasses(false);
+ final ConsoleConfiguration consCFG = getConsoleConfig();
+ final String testClass = "class"; //$NON-NLS-1$
+ for (int i = 0; i < persClasses.length; i++) {
+ assertTrue(persClasses[i] instanceof PersistentClass);
+ PersistentClass persClass = (PersistentClass) persClasses[i];
+ openTest(persClass, consCFG);
+ Object[] props = pcWorkbenchAdapter.getChildren(persClass);
+ for (int j = 0; j < props.length; j++) {
+ if (props[j].getClass() != Property.class) {
+ continue;
+ }
+ openTest(props[j], consCFG);
+ Object[] compProperties = propertyWorkbenchAdapter.getChildren(props[j]);
+ for (int k = 0; k < compProperties.length; k++) {
+ //test Composite properties
+ if (compProperties[k].getClass() != Property.class) {
continue;
}
- openTest(props[j], consCFG);
- Object[] compProperties = new PropertyWorkbenchAdapter().getChildren(props[j]);
- for (int k = 0; k < compProperties.length; k++) {
- //test Composite properties
- if (compProperties[k].getClass() != Property.class) {
- continue;
- }
- final Property prop = (Property)compProperties[k];
- if (testClass.equals(prop.getNodeName()) || testClass.equals(prop.getName())) {
- continue;
- }
- openPropertyTest((Property)compProperties[k], (Property) props[j], consCFG);
+ final Property prop = (Property)compProperties[k];
+ if (testClass.equals(prop.getNodeName()) || testClass.equals(prop.getName())) {
+ continue;
}
+ openPropertyTest((Property)compProperties[k], (Property) props[j], consCFG);
}
}
}
@@ -123,7 +78,7 @@
new Object[]{compositeProperty.getNodeName(), testPackage.getElementName()});
fail(out);
}
- Object[] compProperties = new
PropertyWorkbenchAdapter().getChildren(compositeProperty);
+ Object[] compProperties = propertyWorkbenchAdapter.getChildren(compositeProperty);
for (int k = 0; k < compProperties.length; k++) {
//test Composite properties
assertTrue(compProperties[k] instanceof Property);
@@ -174,34 +129,4 @@
fail(out);
}
}
-
- public String getConsoleConfigName() {
- return consoleConfigName;
- }
-
- public void setConsoleConfigName(String consoleConfigName) {
- this.consoleConfigName = consoleConfigName;
- }
-
- public IPackageFragment getTestPackage() {
- return testPackage;
- }
-
- public void setTestPackage(IPackageFragment testPackage) {
- this.testPackage = testPackage;
- }
-
- protected void closeAllEditors() {
- final IWorkbenchWindow workbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (workbenchWindow != null) {
- final IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
- if (workbenchPage != null) {
- openEditors += workbenchPage.getEditorReferences().length;
- workbenchPage.closeAllEditors(false);
- }
- }
- // clean up event queue to avoid "memory leak",
- // this is necessary to fix
https://jira.jboss.org/jira/browse/JBIDE-4824
- while (Display.getCurrent().readAndDispatch());
- }
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenSourceFileTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenSourceFileTest.java 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenSourceFileTest.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -12,28 +12,14 @@
import java.io.FileNotFoundException;
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.hibernate.InvalidMappingException;
-import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.KnownConfigurations;
import org.hibernate.eclipse.console.actions.OpenSourceAction;
import org.hibernate.eclipse.console.test.ConsoleTestMessages;
import org.hibernate.eclipse.console.test.utils.Utils;
-import org.hibernate.eclipse.console.workbench.ConfigurationWorkbenchAdapter;
-import org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter;
-import org.hibernate.eclipse.console.workbench.PersistentClassWorkbenchAdapter;
-import org.hibernate.eclipse.console.workbench.PropertyWorkbenchAdapter;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
@@ -42,75 +28,44 @@
* @author Dmitry Geraskov
*
*/
-public class OpenSourceFileTest extends TestCase {
+public class OpenSourceFileTest extends BaseTestSetCase {
- protected String consoleConfigName = null;
-
- protected IPackageFragment testPackage = null;
-
- protected int openEditors = 0;
-
public OpenSourceFileTest() {
}
public OpenSourceFileTest(String name) {
super(name);
}
-
- protected void setUp() throws Exception {
- }
- protected void tearDown() throws Exception {
- consoleConfigName = null;
- testPackage = null;
- closeAllEditors();
- }
-
public void testOpenSourceFileTest() {
//fail("test fail");
- KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
- final ConsoleConfiguration consCFG = knownConfigurations.find(consoleConfigName);
- assertNotNull(consCFG);
- consCFG.reset();
- Object[] configs = null;
- Object[] persClasses = null;
- Object[] fields = null;
- try {
- configs = new ConsoleConfigurationWorkbenchAdapter().getChildren(consCFG);
- assertTrue(configs[0] instanceof Configuration);
- persClasses = new ConfigurationWorkbenchAdapter().getChildren(configs[0]);
- } catch (InvalidMappingException ex) {
- String out =
NLS.bind(ConsoleTestMessages.OpenSourceFileTest_source_files_for_package_cannot_be_opened,
- testPackage.getElementName(), ex.getMessage());
- fail(out);
- }
- if (persClasses.length > 0) {
- for (int i = 0; i < persClasses.length; i++) {
- assertTrue(persClasses[0] instanceof PersistentClass);
- PersistentClass persClass = (PersistentClass) persClasses[i];
- String fullyQualifiedName = persClass.getClassName();
- // test PersistentClasses
- openTest(persClass, consCFG, fullyQualifiedName);
- fields = new PersistentClassWorkbenchAdapter().getChildren(persClass);
- for (int j = 0; j < fields.length; j++) {
- if (fields[j].getClass() != Property.class) {
- continue;
- }
- fullyQualifiedName = persClass.getClassName();
- // test Properties
- openTest(fields[j], consCFG, fullyQualifiedName);
- if (fields[j] instanceof Property
- && ((Property)fields[j]).isComposite()) {
- fullyQualifiedName =((Component)((Property)
fields[j]).getValue()).getComponentClassName();
+ final Object[] persClasses = getPersistenceClasses(false);
+ final ConsoleConfiguration consCFG = getConsoleConfig();
+ for (int i = 0; i < persClasses.length; i++) {
+ assertTrue(persClasses[i] instanceof PersistentClass);
+ PersistentClass persClass = (PersistentClass) persClasses[i];
+ String fullyQualifiedName = persClass.getClassName();
+ // test PersistentClasses
+ openTest(persClass, consCFG, fullyQualifiedName);
+ Object[] fields = pcWorkbenchAdapter.getChildren(persClass);
+ for (int j = 0; j < fields.length; j++) {
+ if (fields[j].getClass() != Property.class) {
+ continue;
+ }
+ fullyQualifiedName = persClass.getClassName();
+ // test Properties
+ openTest(fields[j], consCFG, fullyQualifiedName);
+ if (fields[j] instanceof Property
+ && ((Property)fields[j]).isComposite()) {
+ fullyQualifiedName =((Component)((Property)
fields[j]).getValue()).getComponentClassName();
- Object[] compProperties = new PropertyWorkbenchAdapter().getChildren(fields[j]);
- for (int k = 0; k < compProperties.length; k++) {
- if (compProperties[k].getClass() != Property.class) {
- continue;
- }
- //test Composite properties
- openTest(compProperties[k], consCFG, fullyQualifiedName);
+ Object[] compProperties = propertyWorkbenchAdapter.getChildren(fields[j]);
+ for (int k = 0; k < compProperties.length; k++) {
+ if (compProperties[k].getClass() != Property.class) {
+ continue;
}
+ //test Composite properties
+ openTest(compProperties[k], consCFG, fullyQualifiedName);
}
}
}
@@ -139,41 +94,13 @@
} catch (FileNotFoundException e) {
ex = e;
}
- if (ex == null ) ex = Utils.getExceptionIfItOccured(editor);
+ if (ex == null ) {
+ ex = Utils.getExceptionIfItOccured(editor);
+ }
if (ex != null) {
String out =
NLS.bind(ConsoleTestMessages.OpenSourceFileTest_mapping_file_for_not_opened,
fullyQualifiedName/*.getClassName()*/, ex.getMessage());
fail(out);
}
}
-
- public String getConsoleConfigName() {
- return consoleConfigName;
- }
-
- public void setConsoleConfigName(String consoleConfigName) {
- this.consoleConfigName = consoleConfigName;
- }
-
- public IPackageFragment getTestPackage() {
- return testPackage;
- }
-
- public void setTestPackage(IPackageFragment testPackage) {
- this.testPackage = testPackage;
- }
-
- protected void closeAllEditors() {
- final IWorkbenchWindow workbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (workbenchWindow != null) {
- final IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
- if (workbenchPage != null) {
- openEditors += workbenchPage.getEditorReferences().length;
- workbenchPage.closeAllEditors(false);
- }
- }
- // clean up event queue to avoid "memory leak",
- // this is necessary to fix
https://jira.jboss.org/jira/browse/JBIDE-4824
- while (Display.getCurrent().readAndDispatch());
- }
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -47,7 +47,13 @@
test4.setConsoleConfigName(consoleConfigName);
test4.setTestPackage(testPackage);
/**/
+ CheckConsoleConfigTest test0 = new
CheckConsoleConfigTest("testCheckConsoleConfiguration"); //$NON-NLS-1$
+ test0.setConsoleConfigName(consoleConfigName);
+ test0.setTestPackage(testPackage);
//
+ // CheckConsoleConfigTest should be a first test in the suite array,
+ // cause it build Hibernate Console Configuration for testing
+ suite.addTest(test0);
/**/
suite.addTest(test4);
suite.addTest(test2);
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/ConfigurableTestProject.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/ConfigurableTestProject.java 2011-02-03
12:10:12 UTC (rev 28964)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/ConfigurableTestProject.java 2011-02-03
12:16:49 UTC (rev 28965)
@@ -13,17 +13,24 @@
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.eclipse.HibernatePlugin;
+import org.hibernate.eclipse.console.test.ConsoleTestMessages;
import org.hibernate.eclipse.console.test.mappingproject.Customization;
+import org.hibernate.eclipse.console.test.mappingproject.MappingTestsAnnotations;
+import org.hibernate.eclipse.console.test.mappingproject.MappingTestsJpa;
import org.hibernate.eclipse.console.test.utils.FilesTransfer;
/**
@@ -35,6 +42,7 @@
public static final String RESOURCE_SRC_PATH =
"res/project/src/".replaceAll("//", File.separator); //$NON-NLS-1$
//$NON-NLS-2$
public static final String RESOURCE_LIB_PATH =
"res/project/lib/".replaceAll("//", File.separator); //$NON-NLS-1$
//$NON-NLS-2$
+ public static final String HIBERNATE_PLUGIN_LIB_PATH = "lib"; //$NON-NLS-1$
protected ArrayList<String> foldersList = new ArrayList<String>();
@@ -53,6 +61,9 @@
long startCopyLibs = System.currentTimeMillis();
final File libFolder = getFolder(RESOURCE_LIB_PATH);
List<IPath> libs = copyLibs(libFolder);
+ final File libFolderHibernatePlugin =
getHibernatePluginFolder(HIBERNATE_PLUGIN_LIB_PATH);
+ List<IPath> libsHibernatePlugin = copyLibs(libFolderHibernatePlugin);
+ libs.addAll(libsHibernatePlugin);
long startBuild = System.currentTimeMillis();
generateClassPath(libs, sourcePackageFragment);
fullBuild();
@@ -64,6 +75,18 @@
System.out.println("build: " + ( ( stopBuild - startBuild ) / 1000 ));
//$NON-NLS-1$
}
}
+
+ protected File getHibernatePluginFolder(String path) throws IOException {
+ URL entry = HibernatePlugin.getDefault().getBundle().getEntry(path);
+ URL resProject = FileLocator.resolve(entry);
+ String resolvePath = FileLocator.resolve(resProject).getFile();
+ File folder = new File(resolvePath);
+ if (!folder.exists()) {
+ String out = NLS.bind(ConsoleTestMessages.MappingTestProject_folder_not_found, path);
+ throw new RuntimeException(out);
+ }
+ return folder;
+ }
public void restartTestFolders() {
activePackage = -1;
@@ -119,8 +142,17 @@
return true;
}
+ public static final FileFilter filterFoldersOnlyCore = new FileFilter() {
+ public boolean accept(File f) {
+ return f.exists() && f.isDirectory() && !f.isHidden() &&
+ (!f.getAbsolutePath().toLowerCase().contains(MappingTestsAnnotations.annotationsMarkerStr))
&&
+ (!f.getAbsolutePath().toLowerCase().contains(MappingTestsJpa.jpaMarkerStr))
&&
+ (!f.getAbsolutePath().toLowerCase().contains(MappingTestsJpa.jpaMarkerMetaInf));
+ }
+ };
+
public boolean createTestFoldersList() {
- return createTestFoldersList(FilesTransfer.filterFilesJava,
FilesTransfer.filterFolders);
+ return createTestFoldersList(FilesTransfer.filterFilesJava, filterFoldersOnlyCore);
}
public boolean useAllSources() {