Author: dgeraskov
Date: 2007-12-11 03:54:31 -0500 (Tue, 11 Dec 2007)
New Revision: 5235
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/OpenMappingTests.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Address.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Customer.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Employee.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Person.hbm.xml
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/hibernate.cfg.xml
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsolePluginAllTests.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1412
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsolePluginAllTests.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsolePluginAllTests.java 2007-12-10
22:49:57 UTC (rev 5234)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsolePluginAllTests.java 2007-12-11
08:54:31 UTC (rev 5235)
@@ -1,7 +1,6 @@
package org.hibernate.eclipse.console.test;
import java.io.IOException;
-import java.util.Properties;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -17,6 +16,7 @@
suite.addTestSuite( PerspectiveTest.class );
suite.addTestSuite( ConsoleConfigurationTest.class );
suite.addTestSuite( JavaFormattingTest.class );
+ suite.addTestSuite( OpenMappingTests.class );
// core tests
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/OpenMappingTests.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/OpenMappingTests.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/OpenMappingTests.java 2007-12-11
08:54:31 UTC (rev 5235)
@@ -0,0 +1,74 @@
+package org.hibernate.eclipse.console.test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.FindReplaceDocumentAdapter;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.eclipse.console.actions.OpenMappingAction;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+
+/**
+ * @author Dmitry Geraskov
+ */
+
+public class OpenMappingTests extends TestCase{
+
+ public static final String MAPPING_PACKAGE =
"src/org/hibernate/eclipse/console/test/mapping/";
+ public static final String HIBERATE_CFG_FILE = "hibernate.cfg.xml";
+ public static final String PERSON_CFG_FILE = "Person.hbm.xml";
+
+ public void testParceComplexProcess() {
+ IPath path_hib = new Path(MAPPING_PACKAGE+HIBERATE_CFG_FILE);
+ IPath path_pers = new Path(MAPPING_PACKAGE+PERSON_CFG_FILE);
+ File file_hib = path_hib.toFile();
+ File file_pers = path_pers.toFile();
+ if (!file_hib.exists()) {
+ fail("File "+HIBERATE_CFG_FILE+" not found!");
+ }
+ if (!file_pers.exists()) {
+ fail("File "+PERSON_CFG_FILE+" not found!");
+ }
+ try {
+ Configuration config = new Configuration();
+ config.configure(file_hib);
+
+ FileReader reader = new FileReader(file_pers);
+ BufferedReader in = new BufferedReader(reader);
+ String s, text = "";
+ while ((s = in.readLine()) != null) {
+ text += s + '\n';
+ }
+ Document document = new Document(text);
+ FindReplaceDocumentAdapter findAdapter = new FindReplaceDocumentAdapter(document);
+
+ Iterator classMappings = config.getClassMappings();
+ while (classMappings.hasNext()) {
+ Object element = classMappings.next();
+ if (element instanceof PersistentClass) {
+ PersistentClass type = (PersistentClass)element;
+ assertNotNull(OpenMappingAction.findSelection(type, findAdapter));
+ Iterator properties = type.getPropertyIterator();
+ while (properties.hasNext()) {
+ Property prop = (Property) properties.next();
+ assertNotNull(OpenMappingAction.findSelection(prop, findAdapter));
+ }
+ }
+ }
+ } catch (FileNotFoundException e) {
+ fail("FileNotFoundException: "+ e.getMessage());
+ } catch (IOException e) {
+ fail("IOException: "+ e.getMessage());
+ }
+ }
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/OpenMappingTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Address.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Address.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Address.java 2007-12-11
08:54:31 UTC (rev 5235)
@@ -0,0 +1,11 @@
+//$Id$
+package org.hibernate.eclipse.console.test.mapping;
+
+/**
+ * @author Gavin King
+ */
+public class Address {
+ public String address;
+ public String zip;
+ public String country;
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Address.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Customer.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Customer.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Customer.java 2007-12-11
08:54:31 UTC (rev 5235)
@@ -0,0 +1,35 @@
+//$Id$
+package org.hibernate.eclipse.console.test.mapping;
+
+/**
+ * @author Gavin King
+ */
+public class Customer extends Person {
+ private Employee salesperson;
+ private String comments;
+
+ /**
+ * @return Returns the salesperson.
+ */
+ public Employee getSalesperson() {
+ return salesperson;
+ }
+ /**
+ * @param salesperson The salesperson to set.
+ */
+ public void setSalesperson(Employee salesperson) {
+ this.salesperson = salesperson;
+ }
+ /**
+ * @return Returns the comments.
+ */
+ public String getComments() {
+ return comments;
+ }
+ /**
+ * @param comments The comments to set.
+ */
+ public void setComments(String comments) {
+ this.comments = comments;
+ }
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Customer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Employee.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Employee.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Employee.java 2007-12-11
08:54:31 UTC (rev 5235)
@@ -0,0 +1,49 @@
+//$Id$
+package org.hibernate.eclipse.console.test.mapping;
+
+import java.math.BigDecimal;
+
+/**
+ * @author Gavin King
+ */
+public class Employee extends Person {
+ private String title;
+ private BigDecimal salary;
+ private Employee manager;
+ /**
+ * @return Returns the title.
+ */
+ public String getTitle() {
+ return title;
+ }
+ /**
+ * @param title The title to set.
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ /**
+ * @return Returns the manager.
+ */
+ public Employee getManager() {
+ return manager;
+ }
+ /**
+ * @param manager The manager to set.
+ */
+ public void setManager(Employee manager) {
+ this.manager = manager;
+ }
+ /**
+ * @return Returns the salary.
+ */
+ public BigDecimal getSalary() {
+ return salary;
+ }
+ /**
+ * @param salary The salary to set.
+ */
+ public void setSalary(BigDecimal salary) {
+ this.salary = salary;
+ }
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Employee.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Person.hbm.xml
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Person.hbm.xml
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Person.hbm.xml 2007-12-11
08:54:31 UTC (rev 5235)
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates content-based discrimination for the
+ table-per-hierarchy mapping strategy, using a formula
+ discriminator.
+
+-->
+
+<hibernate-mapping
+ package="org.hibernate.eclipse.console.test.mapping"
+ default-access="field">
+
+ <class name="Person"
+ discriminator-value="P">
+
+ <id name="id"
+ column="person_id"
+ unsaved-value="0">
+ <generator class="native"/>
+ </id>
+
+
+ <discriminator
+ type="character"
+ formula="case when title is not null then 'E' when salesperson is not
null then 'C' else 'P' end"/>
+
+ <property name="name"
+ not-null="true"
+ length="80"/>
+
+ <property name="sex"
+ not-null="true"
+ update="false"/>
+
+ <component name="address">
+ <property name="address"/>
+ <property name="zip"/>
+ <property name="country"/>
+ </component>
+
+ <subclass name="Employee"
+ discriminator-value="E">
+ <property name="title"
+ length="20"/>
+ <property name="salary"
+ length="0"/>
+ <many-to-one name="manager"/>
+ </subclass>
+
+ <subclass name="Customer"
+ discriminator-value="C">
+ <property name="comments"/>
+ <many-to-one name="salesperson"/>
+ </subclass>
+
+ </class>
+
+
+</hibernate-mapping>
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Person.hbm.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Person.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Person.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Person.java 2007-12-11
08:54:31 UTC (rev 5235)
@@ -0,0 +1,70 @@
+//$Id$
+package org.hibernate.eclipse.console.test.mapping;
+
+
+/**
+ * @author Gavin King
+ */
+public class Person {
+ private long id;
+ private String name;
+ private char sex;
+ private Address address = new Address();
+ /**
+ * @return Returns the address.
+ */
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(String string) {
+ this.address.address = string;
+ }
+
+ public void setZip(String string) {
+ this.address.zip = string;
+ }
+
+ public void setCountry(String string) {
+ this.address.country = string;
+ }
+
+
+ /**
+ * @return Returns the sex.
+ */
+ public char getSex() {
+ return sex;
+ }
+ /**
+ * @param sex The sex to set.
+ */
+ public void setSex(char sex) {
+ this.sex = sex;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the identity.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param identity The identity to set.
+ */
+ public void setName(String identity) {
+ this.name = identity;
+ }
+
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/Person.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/hibernate.cfg.xml
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/hibernate.cfg.xml
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/hibernate.cfg.xml 2007-12-11
08:54:31 UTC (rev 5235)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE hibernate-configuration PUBLIC
+"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+<hibernate-configuration>
+ <session-factory>
+ <property
name="hibernate.bytecode.use_reflection_optimizer">false</property>
+ <property
name="hibernate.connection.driver_class">org.postgresql.Driver</property>
+ <property
name="hibernate.connection.password">postgres</property>
+ <property
name="hibernate.connection.url">jdbc:postgresql:postgres</property>
+ <property
name="hibernate.connection.username">postgres</property>
+ <property
name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
+
+ <mapping
resource="org\hibernate\eclipse\console\test\mapping\Person.hbm.xml" />
+
+ </session-factory>
+
+
+</hibernate-configuration>
+
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mapping/hibernate.cfg.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native