Author: vyemialyanchyk
Date: 2009-06-15 12:02:13 -0400 (Mon, 15 Jun 2009)
New Revision: 15956
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/ejb3-persistence.jar
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/META-INF/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/META-INF/orm.xml
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/META-INF/persistence.xml
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/BaseEntity.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/BaseSuperclass.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Clinic.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/NamedEntity.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Owner.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Pet.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/PetType.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Specialty.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/SuperOffspring.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/TestIdClass.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Vet.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Vets.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Visit.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsBase.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsCore.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsJpa.java
Removed:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateAllMappingTests.java
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/mappingproject/OpenMappingFileTest.java
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/utils/ConsoleConfigUtils.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/utils/FilesTransfer.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4366 - junits for "Open Mapping File"
for orm.xml
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/ejb3-persistence.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/ejb3-persistence.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/META-INF/orm.xml
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/META-INF/orm.xml
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/META-INF/orm.xml 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
+ version="1.0">
+
+ <persistence-unit-metadata>
+ <xml-mapping-metadata-complete/>
+ <persistence-unit-defaults>
+ <access>PROPERTY</access>
+ </persistence-unit-defaults>
+ </persistence-unit-metadata>
+
+ <package>jpa.springframework.samples.petclinic</package>
+
+ <mapped-superclass class="BaseSuperclass" access="FIELD">
+ <attributes>
+ <embedded-id name="embeddedId">
+ </embedded-id>
+ <!-- id name="simpleId">
+ <generated-value strategy="IDENTITY"/>
+ </id-->
+ </attributes>
+ </mapped-superclass>
+
+ <mapped-superclass class="BaseEntity">
+ <attributes>
+ <id name="id">
+ <generated-value strategy="IDENTITY"/>
+ </id>
+ <transient name="new"/>
+ </attributes>
+ </mapped-superclass>
+
+ <mapped-superclass class="NamedEntity">
+ <attributes>
+ <basic name="name">
+ <column name="NAME"/>
+ </basic>
+ </attributes>
+ </mapped-superclass>
+
+ <mapped-superclass class="Person">
+ <attributes>
+ <basic name="firstName">
+ <column name="FIRST_NAME"/>
+ </basic>
+ <basic name="lastName">
+ <column name="LAST_NAME"/>
+ </basic>
+ </attributes>
+ </mapped-superclass>
+
+ <entity class="TestIdClass" access="FIELD">
+ <attributes>
+ <!-- id name="id">
+ <generated-value strategy="IDENTITY"/>
+ </id-->
+ <embedded-id name="id">
+ </embedded-id>
+ </attributes>
+ </entity>
+
+ <entity class="SuperOffspring" access="FIELD">
+ <table name="SUPEROFFSPRING"/>
+ <attributes>
+ <basic name="justProperty">
+ <column name="JUSTPROPERTY"/>
+ </basic>
+ </attributes>
+ </entity>
+
+ <entity class="Vet">
+ <table name="VETS"/>
+ <attributes>
+ <many-to-many name="specialtiesInternal"
target-entity="Specialty" fetch="EAGER">
+ <join-table name="VET_SPECIALTIES">
+ <join-column name="VET_ID"/>
+ <inverse-join-column name="SPECIALTY_ID"/>
+ </join-table>
+ </many-to-many>
+ <transient name="specialties"/>
+ <transient name="nrOfSpecialties"/>
+ </attributes>
+ </entity>
+
+ <entity class="Specialty">
+ <table name="SPECIALTIES"/>
+ </entity>
+
+ <entity class="Owner">
+ <table name="OWNERS"/>
+ <attributes>
+ <basic name="address"/>
+ <basic name="city"/>
+ <basic name="telephone"/>
+ <one-to-many name="petsInternal" target-entity="Pet"
mapped-by="owner" fetch="EAGER">
+ <cascade>
+ <cascade-all/>
+ </cascade>
+ </one-to-many>
+ <transient name="pets"/>
+ </attributes>
+ </entity>
+
+ <entity class="Pet">
+ <table name="PETS"/>
+ <attributes>
+ <basic name="birthDate">
+ <column name="BIRTH_DATE"/>
+ <temporal>DATE</temporal>
+ </basic>
+ <many-to-one name="owner" fetch="EAGER">
+ <cascade>
+ <cascade-all/>
+ </cascade>
+ </many-to-one>
+ <many-to-one name="type" fetch="EAGER">
+ <cascade>
+ <cascade-all/>
+ </cascade>
+ </many-to-one>
+ <one-to-many name="visitsInternal" target-entity="Visit"
mapped-by="pet" fetch="EAGER">
+ <cascade>
+ <cascade-all/>
+ </cascade>
+ </one-to-many>
+ <transient name="visits"/>
+ </attributes>
+ </entity>
+
+ <entity class="PetType">
+ <table name="TYPES"/>
+ </entity>
+
+ <entity class="Visit">
+ <table name="VISITS"/>
+ <attributes>
+ <basic name="date">
+ <column name="VISIT_DATE"/>
+ <temporal>DATE</temporal>
+ </basic>
+ <many-to-one name="pet" fetch="EAGER">
+ <cascade>
+ <cascade-all/>
+ </cascade>
+ </many-to-one>
+ </attributes>
+ </entity>
+
+</entity-mappings>
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/META-INF/persistence.xml
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/META-INF/persistence.xml
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/META-INF/persistence.xml 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,16 @@
+<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+
+ <persistence-unit name="PetClinic"
transaction-type="RESOURCE_LOCAL">
+
+ <!-- Explicitly define mapping file path, else Hibernate won't find the default
-->
+ <mapping-file>META-INF/orm.xml</mapping-file>
+
+ <!-- Prevent annotation scanning. In this app we are purely driven by orm.xml
-->
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+
+ </persistence-unit>
+
+</persistence>
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/BaseEntity.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/BaseEntity.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/BaseEntity.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,27 @@
+package jpa.springframework.samples.petclinic;
+
+/**
+ * Simple JavaBean domain object with an id property.
+ * Used as a base class for objects needing this property.
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ */
+public class BaseEntity {
+
+ private Integer id;
+
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public boolean isNew() {
+ return (this.id == null);
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/BaseSuperclass.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/BaseSuperclass.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/BaseSuperclass.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,30 @@
+package jpa.springframework.samples.petclinic;
+
+import javax.persistence.EmbeddedId;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+
+@MappedSuperclass
+public class BaseSuperclass {
+
+ @EmbeddedId
+ protected Object embeddedId;
+ //@Id
+ //protected Integer simpleId;
+
+ public Object getTestId() {
+ return embeddedId;
+ }
+
+ public void setTestId(Object embeddedId) {
+ this.embeddedId = embeddedId;
+ }
+
+ //public Integer getSimpleId() {
+ // return simpleId;
+ //}
+
+ //public void setSimpleId(Integer simpleId) {
+ // this.simpleId = simpleId;
+ //}
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Clinic.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Clinic.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Clinic.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,82 @@
+package jpa.springframework.samples.petclinic;
+
+import java.util.Collection;
+
+import org.springframework.dao.DataAccessException;
+
+/**
+ * The high-level PetClinic business interface.
+ *
+ * <p>This is basically a data access object.
+ * PetClinic doesn't have a dedicated business facade.
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ * @author Sam Brannen
+ */
+public interface Clinic {
+
+ /**
+ * Retrieve all <code>Vet</code>s from the data store.
+ * @return a <code>Collection</code> of <code>Vet</code>s
+ */
+ Collection<Vet> getVets() throws DataAccessException;
+
+ /**
+ * Retrieve all <code>PetType</code>s from the data store.
+ * @return a <code>Collection</code> of <code>PetType</code>s
+ */
+ Collection<PetType> getPetTypes() throws DataAccessException;
+
+ /**
+ * Retrieve <code>Owner</code>s from the data store by last name,
+ * returning all owners whose last name <i>starts</i> with the given name.
+ * @param lastName Value to search for
+ * @return a <code>Collection</code> of matching
<code>Owner</code>s
+ * (or an empty <code>Collection</code> if none found)
+ */
+ Collection<Owner> findOwners(String lastName) throws DataAccessException;
+
+ /**
+ * Retrieve an <code>Owner</code> from the data store by id.
+ * @param id the id to search for
+ * @return the <code>Owner</code> if found
+ * @throws org.springframework.dao.DataRetrievalFailureException if not found
+ */
+ Owner loadOwner(int id) throws DataAccessException;
+
+ /**
+ * Retrieve a <code>Pet</code> from the data store by id.
+ * @param id the id to search for
+ * @return the <code>Pet</code> if found
+ * @throws org.springframework.dao.DataRetrievalFailureException if not found
+ */
+ Pet loadPet(int id) throws DataAccessException;
+
+ /**
+ * Save an <code>Owner</code> to the data store, either inserting or
updating it.
+ * @param owner the <code>Owner</code> to save
+ * @see BaseEntity#isNew
+ */
+ void storeOwner(Owner owner) throws DataAccessException;
+
+ /**
+ * Save a <code>Pet</code> to the data store, either inserting or updating
it.
+ * @param pet the <code>Pet</code> to save
+ * @see BaseEntity#isNew
+ */
+ void storePet(Pet pet) throws DataAccessException;
+
+ /**
+ * Save a <code>Visit</code> to the data store, either inserting or updating
it.
+ * @param visit the <code>Visit</code> to save
+ * @see BaseEntity#isNew
+ */
+ void storeVisit(Visit visit) throws DataAccessException;
+
+ /**
+ * Deletes a <code>Pet</code> from the data store.
+ */
+ void deletePet(int id) throws DataAccessException;
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/NamedEntity.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/NamedEntity.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/NamedEntity.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,28 @@
+package jpa.springframework.samples.petclinic;
+
+/**
+ * Simple JavaBean domain object adds a name property to
<code>BaseEntity</code>.
+ * Used as a base class for objects needing these properties.
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ */
+public class NamedEntity extends BaseEntity {
+
+ private String name;
+
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public String toString() {
+ return this.getName();
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Owner.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Owner.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Owner.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,127 @@
+package jpa.springframework.samples.petclinic;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+import org.springframework.core.style.ToStringCreator;
+
+/**
+ * Simple JavaBean domain object representing an owner.
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ * @author Sam Brannen
+ */
+public class Owner extends Person {
+
+ private String address;
+
+ private String city;
+
+ private String telephone;
+
+ private Set<Pet> pets;
+
+
+ public String getAddress() {
+ return this.address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getCity() {
+ return this.city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getTelephone() {
+ return this.telephone;
+ }
+
+ public void setTelephone(String telephone) {
+ this.telephone = telephone;
+ }
+
+ protected void setPetsInternal(Set<Pet> pets) {
+ this.pets = pets;
+ }
+
+ protected Set<Pet> getPetsInternal() {
+ if (this.pets == null) {
+ this.pets = new HashSet<Pet>();
+ }
+ return this.pets;
+ }
+
+ public List<Pet> getPets() {
+ List<Pet> sortedPets = new ArrayList<Pet>(getPetsInternal());
+ PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true,
true));
+ return Collections.unmodifiableList(sortedPets);
+ }
+
+ public void addPet(Pet pet) {
+ getPetsInternal().add(pet);
+ pet.setOwner(this);
+ }
+
+ /**
+ * Return the Pet with the given name, or null if none found for this Owner.
+ *
+ * @param name to test
+ * @return true if pet name is already in use
+ */
+ public Pet getPet(String name) {
+ return getPet(name, false);
+ }
+
+ /**
+ * Return the Pet with the given name, or null if none found for this Owner.
+ *
+ * @param name to test
+ * @return true if pet name is already in use
+ */
+ public Pet getPet(String name, boolean ignoreNew) {
+ name = name.toLowerCase();
+ for (Pet pet : getPetsInternal()) {
+ if (!ignoreNew || !pet.isNew()) {
+ String compName = pet.getName();
+ compName = compName.toLowerCase();
+ if (compName.equals(name)) {
+ return pet;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringCreator(this)
+
+ .append("id", this.getId())
+
+ .append("new", this.isNew())
+
+ .append("lastName", this.getLastName())
+
+ .append("firstName", this.getFirstName())
+
+ .append("address", this.address)
+
+ .append("city", this.city)
+
+ .append("telephone", this.telephone)
+
+ .toString();
+ }
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Person.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Person.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Person.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,32 @@
+package jpa.springframework.samples.petclinic;
+
+/**
+ * Simple JavaBean domain object representing an person.
+ *
+ * @author Ken Krebs
+ */
+public class Person extends BaseEntity {
+
+ private String firstName;
+
+ private String lastName;
+
+ public String getFirstName() {
+ return this.firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return this.lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Pet.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Pet.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Pet.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,87 @@
+package jpa.springframework.samples.petclinic;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+
+/**
+ * Simple JavaBean business object representing a pet.
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ * @author Sam Brannen
+ */
+public class Pet extends NamedEntity {
+
+ private Date birthDate;
+
+ private PetType type;
+
+ private Owner owner;
+
+ private Set<Visit> visits;
+
+ private Date testSuperDate;
+
+
+ public Date getTestSuperDate22222() {
+ return testSuperDate;
+ }
+
+ public void setTestSuperDate11111(Date testSuperDate) {
+ this.testSuperDate = testSuperDate;
+ }
+
+ public void setBirthDate(Date birthDate) {
+ this.birthDate = birthDate;
+ }
+
+ public Date getBirthDate() {
+ return this.birthDate;
+ }
+
+ public void setType(PetType type) {
+ this.type = type;
+ }
+
+ public PetType getType() {
+ return this.type;
+ }
+
+ protected void setOwner(Owner owner) {
+ this.owner = owner;
+ }
+
+ public Owner getOwner() {
+ return this.owner;
+ }
+
+ protected void setVisitsInternal(Set<Visit> visits) {
+ this.visits = visits;
+ }
+
+ protected Set<Visit> getVisitsInternal() {
+ if (this.visits == null) {
+ this.visits = new HashSet<Visit>();
+ }
+ return this.visits;
+ }
+
+ public List<Visit> getVisits() {
+ List<Visit> sortedVisits = new ArrayList<Visit>(getVisitsInternal());
+ PropertyComparator.sort(sortedVisits, new MutableSortDefinition("date",
false, false));
+ return Collections.unmodifiableList(sortedVisits);
+ }
+
+ public void addVisit(Visit visit) {
+ getVisitsInternal().add(visit);
+ visit.setPet(this);
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/PetType.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/PetType.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/PetType.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,8 @@
+package jpa.springframework.samples.petclinic;
+
+/**
+ * @author Juergen Hoeller
+ */
+public class PetType extends NamedEntity {
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Specialty.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Specialty.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Specialty.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,10 @@
+package jpa.springframework.samples.petclinic;
+
+/**
+ * Models a {@link Vet Vet's} specialty (for example, dentistry).
+ *
+ * @author Juergen Hoeller
+ */
+public class Specialty extends NamedEntity {
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/SuperOffspring.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/SuperOffspring.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/SuperOffspring.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,16 @@
+package jpa.springframework.samples.petclinic;
+
+import javax.persistence.Id;
+
+public class SuperOffspring extends BaseSuperclass {
+
+ private Integer justProperty;
+
+ public void setJustProperty(Integer justProperty) {
+ this.justProperty = justProperty;
+ }
+
+ public Integer getJustProperty() {
+ return justProperty;
+ }
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/TestIdClass.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/TestIdClass.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/TestIdClass.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,24 @@
+package jpa.springframework.samples.petclinic;
+
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class TestIdClass {
+
+ //@Id
+ //protected Integer id;
+ @EmbeddedId
+ protected Object id;
+
+ //public Integer getId() {
+ public Object getId() {
+ return id;
+ }
+
+ //public void setId(Integer id) {
+ public void setId(Object id) {
+ this.id = id;
+ }
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Vet.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Vet.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Vet.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,52 @@
+package jpa.springframework.samples.petclinic;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+
+/**
+ * Simple JavaBean domain object representing a veterinarian.
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ * @author Sam Brannen
+ * @author Arjen Poutsma
+ */
+public class Vet extends Person {
+
+ private Set<Specialty> specialties;
+
+
+ protected void setSpecialtiesInternal(Set<Specialty> specialties) {
+ this.specialties = specialties;
+ }
+
+ protected Set<Specialty> getSpecialtiesInternal() {
+ if (this.specialties == null) {
+ this.specialties = new HashSet<Specialty>();
+ }
+ return this.specialties;
+ }
+
+ @XmlElement
+ public List<Specialty> getSpecialties() {
+ List<Specialty> sortedSpecs = new
ArrayList<Specialty>(getSpecialtiesInternal());
+ PropertyComparator.sort(sortedSpecs, new MutableSortDefinition("name", true,
true));
+ return Collections.unmodifiableList(sortedSpecs);
+ }
+
+ public int getNrOfSpecialties() {
+ return getSpecialtiesInternal().size();
+ }
+
+ public void addSpecialty(Specialty specialty) {
+ getSpecialtiesInternal().add(specialty);
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Vets.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Vets.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Vets.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jpa.springframework.samples.petclinic;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * Simple JavaBean domain object representing a list of veterinarians. Mostly here to be
used for the 'vets'
+ * {@link org.springframework.web.servlet.view.xml.MarshallingView}.
+ *
+ * @author Arjen Poutsma
+ */
+@XmlRootElement
+public class Vets {
+
+ private List<Vet> vets;
+
+ @XmlElement
+ public List<Vet> getVetList() {
+ if (vets == null) {
+ vets = new ArrayList<Vet>();
+ }
+ return vets;
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Visit.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Visit.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/src/jpa/springframework/samples/petclinic/Visit.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,70 @@
+package jpa.springframework.samples.petclinic;
+
+import java.util.Date;
+
+/**
+ * Simple JavaBean domain object representing a visit.
+ *
+ * @author Ken Krebs
+ */
+public class Visit extends BaseEntity {
+
+ /** Holds value of property date. */
+ private Date date;
+
+ /** Holds value of property description. */
+ private String description;
+
+ /** Holds value of property pet. */
+ private Pet pet;
+
+
+ /** Creates a new instance of Visit for the current date */
+ public Visit() {
+ this.date = new Date();
+ }
+
+
+ /** Getter for property date.
+ * @return Value of property date.
+ */
+ public Date getDate() {
+ return this.date;
+ }
+
+ /** Setter for property date.
+ * @param date New value of property date.
+ */
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ /** Getter for property description.
+ * @return Value of property description.
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /** Setter for property description.
+ * @param description New value of property description.
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /** Getter for property pet.
+ * @return Value of property pet.
+ */
+ public Pet getPet() {
+ return this.pet;
+ }
+
+ /** Setter for property pet.
+ * @param pet New value of property pet.
+ */
+ public void setPet(Pet pet) {
+ this.pet = pet;
+ }
+
+}
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 2009-06-15
15:57:28 UTC (rev 15955)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/ConsolePluginAllTests.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -2,7 +2,8 @@
import java.io.IOException;
-import org.hibernate.eclipse.console.test.mappingproject.HibernateAllMappingTests;
+import org.hibernate.eclipse.console.test.mappingproject.MappingTestsCore;
+import org.hibernate.eclipse.console.test.mappingproject.MappingTestsJpa;
import org.hibernate.eclipse.console.views.test.QueryPageViewerTest;
import org.hibernate.eclipse.hqleditor.preferences.HQLEditorPreferencePageTest;
import org.hibernate.eclipse.mapper.HBMInfoExtractorTest;
@@ -16,14 +17,15 @@
TestSuite suite = new TestSuite(
ConsoleTestMessages.ConsolePluginAllTests_test_for );
- suite.addTestSuite( KnownConfigurationsTest.class );
- suite.addTestSuite( QueryParametersTest.class );
- suite.addTestSuite( PerspectiveTest.class );
- suite.addTestSuite( ConsoleConfigurationTest.class );
- suite.addTestSuite( JavaFormattingTest.class );
- suite.addTestSuite( RefactoringTest.class );
+ suite.addTestSuite(KnownConfigurationsTest.class);
+ suite.addTestSuite(QueryParametersTest.class);
+ suite.addTestSuite(PerspectiveTest.class);
+ suite.addTestSuite(ConsoleConfigurationTest.class);
+ suite.addTestSuite(JavaFormattingTest.class);
+ suite.addTestSuite(RefactoringTest.class);
- suite.addTestSuite( HibernateAllMappingTests.class );
+ suite.addTestSuite(MappingTestsCore.class);
+ suite.addTestSuite(MappingTestsJpa.class);
suite.addTestSuite(HQLEditorPreferencePageTest.class);
suite.addTestSuite(QueryPageViewerTest.class);
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateAllMappingTests.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateAllMappingTests.java 2009-06-15
15:57:28 UTC (rev 15955)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateAllMappingTests.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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 java.io.File;
-import java.io.IOException;
-import java.util.regex.Pattern;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.internal.core.PackageFragmentRoot;
-import org.eclipse.jdt.ui.IPackagesViewPart;
-import org.eclipse.jdt.ui.JavaUI;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.hibernate.eclipse.console.HibernateConsolePerspectiveFactory;
-import org.hibernate.eclipse.console.test.ConsoleTestMessages;
-import org.hibernate.eclipse.console.test.project.ConfigurableTestProject;
-import org.hibernate.eclipse.console.test.project.TestProject;
-import org.hibernate.eclipse.console.test.utils.ConsoleConfigUtils;
-import org.hibernate.eclipse.console.utils.ProjectUtils;
-
-/**
- *
- */
-@SuppressWarnings("restriction")
-public class HibernateAllMappingTests extends TestCase {
-
- protected String consoleConfigName = null;
-
- protected IPackageFragment testPackage = null;
-
- protected ConfigurableTestProject testProject = null;
-
- protected TestResult result = null;
-
- protected int executions = 0;
-
- public HibernateAllMappingTests(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- testProject = new ConfigurableTestProject("JUnitTestProj"); //$NON-NLS-1$
- consoleConfigName = testProject.getIProject().getName();
- testPackage = null;
-
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setPerspective(
- PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId("org.eclipse.ui.resourcePerspective"));
//$NON-NLS-1$
-
- IPackagesViewPart packageExplorer = null;
- try {
- packageExplorer = (IPackagesViewPart) PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().showView(JavaUI.ID_PACKAGES);
- } catch (PartInitException e) {
- throw new RuntimeException(e);
- }
-
- packageExplorer.selectAndReveal(testProject.getIJavaProject());
-
- PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().setPerspective(
- PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(HibernateConsolePerspectiveFactory.ID_CONSOLE_PERSPECTIVE));
-
- IPath cfgFilePath = new Path(testProject.getIProject().getName() + File.separator +
- TestProject.SRC_FOLDER + File.separator + ConsoleConfigUtils.CFG_FILE_NAME);
- ConsoleConfigUtils.createConsoleConfig(consoleConfigName,
- cfgFilePath, testProject.getIProject().getName());
- ProjectUtils.toggleHibernateOnProject(testProject.getIProject(), true,
consoleConfigName);
- testProject.fullBuild();
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#run(junit.framework.TestResult)
- */
- @Override
- public void run(TestResult result) {
- this.result = result;
- super.run(result);
- }
-
- public void tearDown() throws Exception {
- ProjectUtils.toggleHibernateOnProject(testProject.getIProject(), false,
consoleConfigName);
- ConsoleConfigUtils.deleteConsoleConfig(consoleConfigName);
- testProject.deleteIProject(false);
- testProject = null;
- consoleConfigName = null;
- testPackage = null;
- super.tearDown();
- }
-
- /**
- * Inspect all it's packages of the current testProject and
- * execute all tests from TestSet, considering one test package as active.
- * @throws CoreException
- */
- public void allTestsRunForProject() throws CoreException {
- testProject.fullBuild();
- IPackageFragmentRoot[] roots =
testProject.getIJavaProject().getAllPackageFragmentRoots();
- for (int i = 0; i < roots.length; i++) {
- if (roots[i].getClass() != PackageFragmentRoot.class) {
- continue;
- }
- PackageFragmentRoot packageFragmentRoot = (PackageFragmentRoot) roots[i];
- IJavaElement[] els = packageFragmentRoot.getChildren();
- for (int j = 0; j < els.length; j++) {
- IJavaElement javaElement = els[j];
- if (!(javaElement instanceof IPackageFragment)) {
- continue;
- }
- testPackage = (IPackageFragment)javaElement;
- // use packages only with compilation units
- if (testPackage.getCompilationUnits().length == 0) {
- continue;
- }
- if (Customization.U_TEST_PACKS_PATTERN) {
- if (!Pattern.matches(Customization.TEST_PACKS_PATTERN,
javaElement.getElementName())) {
- continue;
- }
- }
-
- long st_pack_time = System.currentTimeMillis();
- int prev_failCount = result.failureCount();
- int prev_errCount = result.errorCount();
-
- TestSuite suite = TestSet.createTestSuite(consoleConfigName, testPackage,
testProject);
-
- customizeCfgXml(testPackage);
- //==============================
- //run all tests for package
- //suite.run(result);
- for (int k = 0; k < suite.testCount(); k++) {
- Test test = suite.testAt(k);
- test.run(result);
- }
- closeAllEditors();
- //==============================
- executions++;
- if (Customization.USE_CONSOLE_OUTPUT) {
- System.out.print(result.errorCount() - prev_errCount +
ConsoleTestMessages.HibernateAllMappingTests_errors + " \t"); //$NON-NLS-1$
- System.out.print(result.failureCount() - prev_failCount +
ConsoleTestMessages.HibernateAllMappingTests_fails + "\t"); //$NON-NLS-1$
- long period = System.currentTimeMillis() - st_pack_time;
- String time = period / 1000 + "." + (period % 1000) / 100; //$NON-NLS-1$
- System.out.println( time +ConsoleTestMessages.HibernateAllMappingTests_seconds +
- " {" + javaElement.getElementName() + "}");
//$NON-NLS-1$//$NON-NLS-2$
- }
-
- if (Customization.STOP_AFTER_MISSING_PACK) {
- if (result.failureCount() > prev_failCount) {
- break;
- }
- }
- prev_failCount = result.failureCount();
- prev_errCount = result.errorCount();
- }
- }
- }
-
- public void testEachPackWithTestSet() throws CoreException, IOException {
- long start_time = System.currentTimeMillis();
- // 1) ---
- // here we use one BIG project configuration for testing - time consuming thing
- //boolean useAllRes = testProject.useAllSources();
- //assertTrue(useAllRes);
- // 1) ---
- // 2) +++
- // here we use many SMALL projects configurations for testing.
- // this case is essential better for run time.
- boolean createListRes = testProject.createTestFoldersList();
- assertTrue(createListRes);
- // 2) +++
- testProject.restartTestFolders();
- executions = 0;
- while (testProject.setupNextTestFolder()) {
- allTestsRunForProject();
- }
- if (Customization.USE_CONSOLE_OUTPUT) {
- System.out.println("=====================================================");
//$NON-NLS-1$
- System.out.print(result.errorCount() +
ConsoleTestMessages.HibernateAllMappingTests_errors + " \t"); //$NON-NLS-1$
- System.out.print(result.failureCount() +
ConsoleTestMessages.HibernateAllMappingTests_fails + "\t"); //$NON-NLS-1$
- System.out.print((System.currentTimeMillis() - start_time) / 1000 +
ConsoleTestMessages.HibernateAllMappingTests_seconds + "\t" ); //$NON-NLS-1$
- System.out.println(executions +
ConsoleTestMessages.HibernateAllMappingTests_packages_tested );
- }
- }
-
- protected void customizeCfgXml(IPackageFragment pack) {
- assertNotNull(pack);
- try {
- ConsoleConfigUtils.customizeCfgXmlForPack(pack);
- } catch (CoreException e) {
- String out =
NLS.bind(ConsoleTestMessages.UpdateConfigurationTest_error_customising_file_for_package,
- new Object[] { ConsoleConfigUtils.CFG_FILE_NAME, pack.getPath(), e.getMessage() }
);
- fail(out);
- }
- }
-
- protected void closeAllEditors() {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
- }
-
- 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;
- }
-
- public void setTestProject(ConfigurableTestProject testProject) {
- this.testProject = testProject;
- }
-}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsBase.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsBase.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsBase.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,201 @@
+package org.hibernate.eclipse.console.test.mappingproject;
+
+import java.io.IOException;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.internal.core.PackageFragmentRoot;
+import org.eclipse.jdt.ui.IPackagesViewPart;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.hibernate.eclipse.console.HibernateConsolePerspectiveFactory;
+import org.hibernate.eclipse.console.test.ConsoleTestMessages;
+import org.hibernate.eclipse.console.test.project.ConfigurableTestProject;
+import org.hibernate.eclipse.console.test.utils.ConsoleConfigUtils;
+import org.hibernate.eclipse.console.utils.ProjectUtils;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+@SuppressWarnings("restriction")
+public abstract class MappingTestsBase extends TestCase {
+
+ protected String consoleConfigName = null;
+
+ protected IPackageFragment testPackage = null;
+
+ protected ConfigurableTestProject testProject = null;
+
+ protected TestResult result = null;
+
+ protected int executions = 0;
+
+ public MappingTestsBase(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ testProject = new ConfigurableTestProject("JUnitTestProj"); //$NON-NLS-1$
+ consoleConfigName = testProject.getIProject().getName();
+ testPackage = null;
+
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setPerspective(
+ PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId("org.eclipse.ui.resourcePerspective"));
//$NON-NLS-1$
+
+ IPackagesViewPart packageExplorer = null;
+ try {
+ packageExplorer = (IPackagesViewPart) PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().showView(JavaUI.ID_PACKAGES);
+ } catch (PartInitException e) {
+ throw new RuntimeException(e);
+ }
+
+ packageExplorer.selectAndReveal(testProject.getIJavaProject());
+
+ PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().setPerspective(
+ PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(HibernateConsolePerspectiveFactory.ID_CONSOLE_PERSPECTIVE));
+
+ setUpConsoleConfig();
+
+ ProjectUtils.toggleHibernateOnProject(testProject.getIProject(), true,
consoleConfigName);
+ testProject.fullBuild();
+ }
+
+ abstract protected void setUpConsoleConfig() throws Exception;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#run(junit.framework.TestResult)
+ */
+ @Override
+ public void run(TestResult result) {
+ this.result = result;
+ super.run(result);
+ }
+
+ public void tearDown() throws Exception {
+ ProjectUtils.toggleHibernateOnProject(testProject.getIProject(), false,
consoleConfigName);
+ ConsoleConfigUtils.deleteConsoleConfig(consoleConfigName);
+ testProject.deleteIProject(false);
+ testProject = null;
+ consoleConfigName = null;
+ testPackage = null;
+ super.tearDown();
+ }
+
+ /**
+ * Inspect all it's packages of the current testProject and
+ * execute all tests from TestSet, considering one test package as active.
+ * @throws CoreException
+ */
+ public void allTestsRunForProject() throws CoreException {
+ testProject.fullBuild();
+ IPackageFragmentRoot[] roots =
testProject.getIJavaProject().getAllPackageFragmentRoots();
+ for (int i = 0; i < roots.length; i++) {
+ if (roots[i].getClass() != PackageFragmentRoot.class) {
+ continue;
+ }
+ PackageFragmentRoot packageFragmentRoot = (PackageFragmentRoot) roots[i];
+ IJavaElement[] els = packageFragmentRoot.getChildren();
+ for (int j = 0; j < els.length; j++) {
+ IJavaElement javaElement = els[j];
+ if (!(javaElement instanceof IPackageFragment)) {
+ continue;
+ }
+ testPackage = (IPackageFragment)javaElement;
+ // use packages only with compilation units
+ if (testPackage.getCompilationUnits().length == 0) {
+ continue;
+ }
+ if (Customization.U_TEST_PACKS_PATTERN) {
+ if (!Pattern.matches(Customization.TEST_PACKS_PATTERN,
javaElement.getElementName())) {
+ continue;
+ }
+ }
+
+ long st_pack_time = System.currentTimeMillis();
+ int prev_failCount = result.failureCount();
+ int prev_errCount = result.errorCount();
+
+ TestSuite suite = TestSet.createTestSuite(consoleConfigName, testPackage,
testProject);
+
+ customizeCfgXml(testPackage);
+ //==============================
+ //run all tests for package
+ //suite.run(result);
+ for (int k = 0; k < suite.testCount(); k++) {
+ Test test = suite.testAt(k);
+ test.run(result);
+ }
+ closeAllEditors();
+ //==============================
+ executions++;
+ if (Customization.USE_CONSOLE_OUTPUT) {
+ System.out.print(result.errorCount() - prev_errCount +
ConsoleTestMessages.HibernateAllMappingTests_errors + " \t"); //$NON-NLS-1$
+ System.out.print(result.failureCount() - prev_failCount +
ConsoleTestMessages.HibernateAllMappingTests_fails + "\t"); //$NON-NLS-1$
+ long period = System.currentTimeMillis() - st_pack_time;
+ String time = period / 1000 + "." + (period % 1000) / 100; //$NON-NLS-1$
+ System.out.println(time + ConsoleTestMessages.HibernateAllMappingTests_seconds +
+ " {" + javaElement.getElementName() + "}");
//$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ if (Customization.STOP_AFTER_MISSING_PACK) {
+ if (result.failureCount() > prev_failCount) {
+ break;
+ }
+ }
+ prev_failCount = result.failureCount();
+ prev_errCount = result.errorCount();
+ }
+ }
+ }
+
+ abstract public void testEachPackWithTestSet() throws CoreException, IOException;
+
+ protected void customizeCfgXml(IPackageFragment pack) {
+ assertNotNull(pack);
+ try {
+ ConsoleConfigUtils.customizeCfgXmlForPack(pack);
+ } catch (CoreException e) {
+ String out =
NLS.bind(ConsoleTestMessages.UpdateConfigurationTest_error_customising_file_for_package,
+ new Object[] { ConsoleConfigUtils.CFG_FILE_NAME, pack.getPath(), e.getMessage() }
);
+ fail(out);
+ }
+ }
+
+ protected void closeAllEditors() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
+ }
+
+ 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;
+ }
+
+ public void setTestProject(ConfigurableTestProject testProject) {
+ this.testProject = testProject;
+ }
+}
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsCore.java
(from rev 15729,
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateAllMappingTests.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsCore.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsCore.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.hibernate.eclipse.console.test.mappingproject;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.hibernate.eclipse.console.test.ConsoleTestMessages;
+import org.hibernate.eclipse.console.test.project.TestProject;
+import org.hibernate.eclipse.console.test.utils.ConsoleConfigUtils;
+
+/**
+ *
+ */
+public class MappingTestsCore extends MappingTestsBase {
+
+ public MappingTestsCore(String name) {
+ super(name);
+ }
+
+ protected void setUpConsoleConfig() throws Exception {
+ IPath cfgFilePath = new Path(testProject.getIProject().getName() + File.separator +
+ TestProject.SRC_FOLDER + File.separator + ConsoleConfigUtils.CFG_FILE_NAME);
+ ConsoleConfigUtils.createConsoleConfig(consoleConfigName,
+ cfgFilePath, testProject.getIProject().getName());
+ }
+
+ public void testEachPackWithTestSet() throws CoreException, IOException {
+ long start_time = System.currentTimeMillis();
+ // 1) ---
+ // here we use one BIG project configuration for testing - time consuming thing
+ //boolean useAllRes = testProject.useAllSources();
+ //assertTrue(useAllRes);
+ // 1) ---
+ // 2) +++
+ // here we use many SMALL projects configurations for testing.
+ // this case is essential better for run time.
+ boolean createListRes = testProject.createTestFoldersList();
+ assertTrue(createListRes);
+ // 2) +++
+ testProject.restartTestFolders();
+ executions = 0;
+ while (testProject.setupNextTestFolder()) {
+ allTestsRunForProject();
+ }
+ if (Customization.USE_CONSOLE_OUTPUT) {
+ System.out.println("=====================================================");
//$NON-NLS-1$
+ System.out.print(result.errorCount() +
ConsoleTestMessages.HibernateAllMappingTests_errors + " \t"); //$NON-NLS-1$
+ System.out.print(result.failureCount() +
ConsoleTestMessages.HibernateAllMappingTests_fails + "\t"); //$NON-NLS-1$
+ System.out.print((System.currentTimeMillis() - start_time) / 1000 +
ConsoleTestMessages.HibernateAllMappingTests_seconds + "\t" ); //$NON-NLS-1$
+ System.out.println(executions +
ConsoleTestMessages.HibernateAllMappingTests_packages_tested );
+ }
+ }
+}
Added:
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
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestsJpa.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * 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.hibernate.eclipse.console.test.mappingproject;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.hibernate.eclipse.console.test.ConsoleTestMessages;
+import org.hibernate.eclipse.console.test.project.TestProject;
+import org.hibernate.eclipse.console.test.utils.ConsoleConfigUtils;
+
+/**
+ *
+ * @author vitali
+ */
+public class MappingTestsJpa extends MappingTestsBase {
+
+ public MappingTestsJpa(String name) {
+ super(name);
+ }
+
+ protected void setUpConsoleConfig() throws Exception {
+ ConsoleConfigUtils.createJpaConsoleConfig(consoleConfigName,
+ 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 FileFilter filterFoldersJpa = new FileFilter() {
+ public boolean accept(File f) {
+ return f.exists() && f.isDirectory() && !f.isHidden() &&
+ (f.getAbsolutePath().toLowerCase().contains(jpaMarkerStr) ||
+ f.getAbsolutePath().toLowerCase().contains(jpaMarkerMetaInf));
+ }
+ };
+
+ static final String jpaMarkerCfgXml = TestProject.SRC_FOLDER + File.separator +
"hibernate.cfg.xml"; //$NON-NLS-1$
+
+ public static final FileFilter filterFilesJavaXmlPlus = new FileFilter() {
+ public boolean accept(File f) {
+ return f.exists() && f.isFile() && !f.isHidden() &&
+ ((f.getName().toLowerCase().endsWith(".java") ||
f.getName().toLowerCase().endsWith(".xml")) && //$NON-NLS-1$
//$NON-NLS-2$
+ !(f.getAbsolutePath().toLowerCase().contains(jpaMarkerCfgXml)));
+ }
+ };
+
+ public void testEachPackWithTestSet() throws CoreException, IOException {
+ long start_time = System.currentTimeMillis();
+ boolean createListRes = testProject.createTestFoldersList(
+ filterFilesJavaXmlPlus, filterFoldersJpa);
+ assertTrue(createListRes);
+ boolean useSelRes = testProject.useSelectedFolders();
+ assertTrue(useSelRes);
+ testProject.restartTestFolders();
+ executions = 0;
+ allTestsRunForProject();
+ if (Customization.USE_CONSOLE_OUTPUT) {
+ System.out.println("=====================================================");
//$NON-NLS-1$
+ System.out.print(result.errorCount() +
ConsoleTestMessages.HibernateAllMappingTests_errors + " \t"); //$NON-NLS-1$
+ System.out.print(result.failureCount() +
ConsoleTestMessages.HibernateAllMappingTests_fails + "\t"); //$NON-NLS-1$
+ System.out.print((System.currentTimeMillis() - start_time) / 1000 +
ConsoleTestMessages.HibernateAllMappingTests_seconds + "\t" ); //$NON-NLS-1$
+ System.out.println(executions +
ConsoleTestMessages.HibernateAllMappingTests_packages_tested );
+ }
+ }
+
+ protected void customizeCfgXml(IPackageFragment pack) {
+ // do not customize cfg hml
+ }
+}
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 2009-06-15
15:57:28 UTC (rev 15955)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenMappingFileTest.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -75,19 +75,28 @@
new Object[]{testPackage.getElementName(), ex.getMessage()});
fail(out);
}
- if (persClasses.length > 0){
+ if (persClasses.length > 0) {
+ final String testClass = "class"; //$NON-NLS-1$
for (int i = 0; i < persClasses.length; i++) {
- assertTrue(persClasses[0] instanceof PersistentClass);
+ 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) continue;
+ if (props[j].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;
+ 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);
}
}
@@ -121,7 +130,9 @@
} 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.OpenMappingFileTest_mapping_file_for_property_not_opened_package,
new Object[]{compositeProperty.getNodeName(), testPackage.getElementName(),
ex.getMessage()});
@@ -147,7 +158,9 @@
} 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.OpenMappingFileTest_mapping_file_for_not_opened_package,
new Object[]{selection, testPackage.getElementName(), ex.getMessage()});
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 2009-06-15
15:57:28 UTC (rev 15955)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/ConfigurableTestProject.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -11,6 +11,7 @@
package org.hibernate.eclipse.console.test.project;
import java.io.File;
+import java.io.FileFilter;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
@@ -80,9 +81,9 @@
if (activePackage >= foldersList.size()) {
return false;
}
+ FilesTransfer.delete(new File(project.getLocation().append(SRC_FOLDER).toOSString()));
final String pack = foldersList.get(activePackage);
final File srcFolder = getFolder(RESOURCE_SRC_PATH + pack);
- FilesTransfer.delete(new File(project.getLocation().append(SRC_FOLDER).toOSString()));
IPackageFragmentRoot sourcePackageFragment = createFolder(SRC_FOLDER + File.separator +
pack);
FilesTransfer.copyFolder(srcFolder, (IFolder)sourcePackageFragment.getResource());
return true;
@@ -100,7 +101,7 @@
return folder;
}
- public boolean createTestFoldersList() {
+ public boolean createTestFoldersList(FileFilter filterFiles, FileFilter filterFolders)
{
activePackage = -1;
foldersList = new ArrayList<String>();
File srcFolder = null;
@@ -112,8 +113,7 @@
if (srcFolder == null) {
return false;
}
- FilesTransfer.collectFoldersWithFiles(srcFolder, FilesTransfer.filterFilesJava,
- FilesTransfer.filterFolders, foldersList);
+ FilesTransfer.collectFoldersWithFiles(srcFolder, filterFiles, filterFolders,
foldersList);
IPath base = Path.fromOSString(srcFolder.getPath());
for (int i = 0; i < foldersList.size(); i++) {
String str = foldersList.get(i);
@@ -124,6 +124,10 @@
return true;
}
+ public boolean createTestFoldersList() {
+ return createTestFoldersList(FilesTransfer.filterFilesJava,
FilesTransfer.filterFolders);
+ }
+
public boolean useAllSources() {
activePackage = -1;
foldersList = new ArrayList<String>();
@@ -147,6 +151,23 @@
return false;
}
+ public boolean useSelectedFolders() throws IOException, CoreException {
+ activePackage = -1;
+ if (foldersList == null) {
+ return false;
+ }
+ FilesTransfer.delete(new File(project.getLocation().append(SRC_FOLDER).toOSString()));
+ for (int i = 0; i < foldersList.size(); i++) {
+ final String pack = foldersList.get(i);
+ final File srcFolder = getFolder(RESOURCE_SRC_PATH + pack);
+ IPackageFragmentRoot sourcePackageFragment = createFolder(SRC_FOLDER + File.separator
+ pack);
+ FilesTransfer.copyFolder(srcFolder, (IFolder)sourcePackageFragment.getResource());
+ }
+ foldersList = new ArrayList<String>();
+ foldersList.add(""); //$NON-NLS-1$
+ return true;
+ }
+
public void fullBuild() throws CoreException {
IPackageFragmentRoot sourcePackageFragment = createSourceFolder();
sourcePackageFragment.getResource().refreshLocal(IResource.DEPTH_INFINITE, null);
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/utils/ConsoleConfigUtils.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/utils/ConsoleConfigUtils.java 2009-06-15
15:57:28 UTC (rev 15955)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/utils/ConsoleConfigUtils.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -11,6 +11,7 @@
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
@@ -125,6 +126,49 @@
}
/**
+ * "Launch" the wizard and create hibernate jpa console configuration in the
current workspace.
+ * @param name - console configuration name
+ * @param cfgFilePath - path to hibernate.cfg.xml
+ * @param project - name of java project selected for console configuration
+ * @throws CoreException
+ * @throws NoSuchFieldException
+ * @throws IllegalAccessException
+ */
+ public static void createJpaConsoleConfig(String name, String project, String
persistenceUnitName) throws CoreException, NoSuchFieldException, IllegalAccessException {
+ final IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ final ConsoleConfigurationCreationWizard wiz = new
ConsoleConfigurationCreationWizard();
+ final WizardDialog wdialog = new WizardDialog(win.getShell(), wiz);
+ wdialog.create();
+ ConsoleConfigurationWizardPage page =
((ConsoleConfigurationWizardPage)wiz.getPages()[0]);
+ ILaunchConfigurationTab[] tabs = page.getTabs();
+ ConsoleConfigurationMainTab main = (ConsoleConfigurationMainTab) tabs[0];
+ Class<? extends ConsoleConfigurationMainTab> clazz = main.getClass();
+ //
+ Field projectName = clazz.getDeclaredField("projectNameText"); //$NON-NLS-1$
+ projectName.setAccessible(true);
+ Text text = (Text)projectName.get(main);
+ text.setText(project);
+ //
+ Field persistenceUnitNameText =
clazz.getDeclaredField("persistenceUnitNameText"); //$NON-NLS-1$
+ persistenceUnitNameText.setAccessible(true);
+ text = (Text)persistenceUnitNameText.get(main);
+ text.setText(persistenceUnitName);
+ //
+ Field jpaMode = clazz.getDeclaredField("jpaMode"); //$NON-NLS-1$
+ Field coreMode = clazz.getDeclaredField("coreMode"); //$NON-NLS-1$
+ jpaMode.setAccessible(true);
+ coreMode.setAccessible(true);
+ Button button = (Button)coreMode.get(main);
+ button.setSelection(false);
+ button = (Button)jpaMode.get(main);
+ button.setSelection(true);
+ //
+ page.setName(name);
+ page.performFinish();
+ wdialog.close();
+ }
+
+ /**
* Delete console configuration with given name.
* @param name
*/
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/utils/FilesTransfer.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/utils/FilesTransfer.java 2009-06-15
15:57:28 UTC (rev 15955)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/utils/FilesTransfer.java 2009-06-15
16:02:13 UTC (rev 15956)
@@ -53,6 +53,13 @@
}
};
+ public static final FileFilter filterFilesJavaXml = new FileFilter() {
+ public boolean accept(File f) {
+ return f.exists() && f.isFile() && !f.isHidden() &&
+ (f.getName().toLowerCase().endsWith(".java") ||
f.getName().toLowerCase().endsWith(".xml")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ };
+
/**
* Copy whole folder content from source folder to destination folder.
* @param src - source folder
@@ -144,48 +151,35 @@
* Delete the whole directory
* @param path
*/
- public static void delete(File path) {
+ public static boolean delete(File path) {
+ boolean res = true, tmp = true;
if (path.exists()) {
File[] files = path.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
- delete(files[i]);
+ tmp = delete(files[i]);;
} else {
- deleteFile(files[i]);
+ tmp = deleteFile(files[i]);
}
+ res = res && tmp;
}
}
- deleteFile(path);
-
+ tmp = deleteFile(path);
+ res = res && tmp;
+ return res;
}
/**
* Delete single file
* @param file
*/
- public static void deleteFile(File file) {
- try {
- if (file.exists()) {
- if (!file.delete()) {
- throw new RuntimeException(getMessage(file));
- }
+ public static boolean deleteFile(File file) {
+ boolean res = false;
+ if (file.exists()) {
+ if (file.delete()) {
+ res = true;
}
- } catch (Throwable e) {
- throw new RuntimeException(getMessage(file) ,e);
}
+ return res;
}
-
-
- private static String getMessage(File file) {
- StringBuffer buffer = new StringBuffer();
- buffer.append("Cannot remove the "); //$NON-NLS-1$
- buffer.append(file.getAbsolutePath());
- buffer.append(" file. "); //$NON-NLS-1$
- if (file.exists() && file.isDirectory()) {
- String[] files = file.list();
- buffer.append("List="); //$NON-NLS-1$
- buffer.append(files.toString());
- }
- return buffer.toString();
- }
}