Author: vyemialyanchyk
Date: 2010-11-15 14:16:39 -0500 (Mon, 15 Nov 2010)
New Revision: 26581
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/LaunchConfigTestProject2.launch
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/hibernate-console.properties
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/lib/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/lib/ejb3-persistence.jar
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/lib/hsqldb.jar
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/META-INF/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/META-INF/persistence.xml
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/Booking.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/Hotel.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/User.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/testLaunchCfg.launch
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenExternalProcessExecutionTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/LaunchConfigTestProject2.java
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/META-INF/MANIFEST.MF
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.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/project/SimpleTestProject.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/TestProject.java
Log:
https://jira.jboss.org/browse/JBIDE-7602 - fixed, test for codegen created
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/META-INF/MANIFEST.MF 2010-11-15
18:32:33 UTC (rev 26580)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/META-INF/MANIFEST.MF 2010-11-15
19:16:39 UTC (rev 26581)
@@ -41,6 +41,7 @@
Require-Bundle: org.junit,
org.eclipse.jdt.core,
org.eclipse.jdt.launching,
+ org.eclipse.core.externaltools,
org.eclipse.ui,
org.eclipse.jdt.ui,
org.eclipse.core.runtime,
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/LaunchConfigTestProject2.launch
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/LaunchConfigTestProject2.launch
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/LaunchConfigTestProject2.launch 2010-11-15
19:16:39 UTC (rev 26581)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Hibernate Console launch configuration -->
+<launchConfiguration
type="org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType">
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR"
value="LaunchConfigTestProject2"/>
+<stringAttribute key="org.hibernate.eclipse.launch.PROPERTY_FILE"
value="/LaunchConfigTestProject2/hibernate-console.properties"/>
+<stringAttribute key="org.hibernate.eclipse.launch.CONFIGURATION_FACTORY"
value="JPA"/>
+</launchConfiguration>
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/hibernate-console.properties
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/hibernate-console.properties
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/hibernate-console.properties 2010-11-15
19:16:39 UTC (rev 26581)
@@ -0,0 +1,10 @@
+#File used by hibernate tools to override <datasource> and other container specific
settings in persistence.xml
+hibernate.connection.password=
+hibernate.connection.username=sa
+hibernate.connection.driver_class=org.hsqldb.jdbcDriver
+hibernate.dialect=org.hibernate.dialect.HSQLDialect
+hibernate.connection.url=jdbc:hsqldb:.
+
+hibernate.connection.provider_class=org.hibernate.connection.DriverManagerConnectionProvider
+hibernate.datasource=
+hibernate.transaction.manager_lookup_class=
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/lib/ejb3-persistence.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/lib/ejb3-persistence.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/lib/hsqldb.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/lib/hsqldb.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/META-INF/persistence.xml
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/META-INF/persistence.xml
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/META-INF/persistence.xml 2010-11-15
19:16:39 UTC (rev 26581)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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="bookingDatabase">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+
<jta-data-source>java:/LaunchConfigTestProject2Datasource</jta-data-source>
+ <properties>
+ <property name="hibernate.hbm2ddl.auto"
value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ <!-- These are the default for JBoss EJB3, but not for HEM: -->
+ <property name="hibernate.cache.provider_class"
value="org.hibernate.cache.HashtableCacheProvider"/>
+ <property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/Booking.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/Booking.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/Booking.java 2010-11-15
19:16:39 UTC (rev 26581)
@@ -0,0 +1,188 @@
+//$Id: Booking.java 5579 2007-06-27 00:06:49Z gavin $
+package org.jboss.seam.example.booking;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.util.Date;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import org.hibernate.validator.Length;
+import org.hibernate.validator.NotNull;
+import org.hibernate.validator.Pattern;
+
+@Entity
+public class Booking implements Serializable
+{
+ private Long id;
+ private User user;
+ private Hotel hotel;
+ private Date checkinDate;
+ private Date checkoutDate;
+ private String creditCard;
+ private String creditCardName;
+ private int creditCardExpiryMonth;
+ private int creditCardExpiryYear;
+ private boolean smoking;
+ private int beds;
+
+ public Booking() {}
+
+ public Booking(Hotel hotel, User user)
+ {
+ this.hotel = hotel;
+ this.user = user;
+ }
+
+ @Transient
+ public BigDecimal getTotal()
+ {
+ return hotel.getPrice().multiply( new BigDecimal( getNights() ) );
+ }
+
+ @Transient
+ public int getNights()
+ {
+ return (int) ( checkoutDate.getTime() - checkinDate.getTime() ) / 1000 / 60 / 60 /
24;
+ }
+
+ @Id @GeneratedValue
+ public Long getId()
+ {
+ return id;
+ }
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ @NotNull
+ @Basic @Temporal(TemporalType.DATE)
+ public Date getCheckinDate()
+ {
+ return checkinDate;
+ }
+ public void setCheckinDate(Date datetime)
+ {
+ this.checkinDate = datetime;
+ }
+
+ @ManyToOne @NotNull
+ public Hotel getHotel()
+ {
+ return hotel;
+ }
+ public void setHotel(Hotel hotel)
+ {
+ this.hotel = hotel;
+ }
+
+ @ManyToOne @NotNull
+ public User getUser()
+ {
+ return user;
+ }
+ public void setUser(User user)
+ {
+ this.user = user;
+ }
+
+ @Basic @Temporal(TemporalType.DATE)
+ @NotNull
+ public Date getCheckoutDate()
+ {
+ return checkoutDate;
+ }
+ public void setCheckoutDate(Date checkoutDate)
+ {
+ this.checkoutDate = checkoutDate;
+ }
+
+ @NotNull(message="Credit card number is required")
+ @Length(min=16, max=16, message="Credit card number must 16 digits long")
+ @Pattern(regex="^\\d*$", message="Credit card number must be
numeric")
+ public String getCreditCard()
+ {
+ return creditCard;
+ }
+
+ public void setCreditCard(String creditCard)
+ {
+ this.creditCard = creditCard;
+ }
+
+ @Transient
+ public String getDescription()
+ {
+ DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
+ return hotel==null ? null : hotel.getName() +
+ ", " + df.format( getCheckinDate() ) +
+ " to " + df.format( getCheckoutDate() );
+ }
+
+ public boolean isSmoking()
+ {
+ return smoking;
+ }
+
+ public void setSmoking(boolean smoking)
+ {
+ this.smoking = smoking;
+ }
+
+ public int getBeds()
+ {
+ return beds;
+ }
+
+ public void setBeds(int beds)
+ {
+ this.beds = beds;
+ }
+ @NotNull(message="Credit card name is required")
+ @Length(min=3, max=70, message="Credit card name is required")
+ public String getCreditCardName()
+ {
+ return creditCardName;
+ }
+
+ public void setCreditCardName(String creditCardName)
+ {
+ this.creditCardName = creditCardName;
+ }
+
+ public int getCreditCardExpiryMonth()
+ {
+ return creditCardExpiryMonth;
+ }
+
+ public void setCreditCardExpiryMonth(int creditCardExpiryMonth)
+ {
+ this.creditCardExpiryMonth = creditCardExpiryMonth;
+ }
+
+ public int getCreditCardExpiryYear()
+ {
+ return creditCardExpiryYear;
+ }
+
+ public void setCreditCardExpiryYear(int creditCardExpiryYear)
+ {
+ this.creditCardExpiryYear = creditCardExpiryYear;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Booking(" + user + ","+ hotel + ")";
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/Hotel.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/Hotel.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/Hotel.java 2010-11-15
19:16:39 UTC (rev 26581)
@@ -0,0 +1,112 @@
+//$Id: Hotel.java 5579 2007-06-27 00:06:49Z gavin $
+package org.jboss.seam.example.booking;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.validator.Length;
+import org.hibernate.validator.NotNull;
+
+@Entity
+public class Hotel implements Serializable
+{
+ private Long id;
+ private String name;
+ private String address;
+ private String city;
+ private String state;
+ private String zip;
+ private String country;
+ private BigDecimal price;
+
+ @Id @GeneratedValue
+ public Long getId()
+ {
+ return id;
+ }
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ @Length(max=50) @NotNull
+ public String getName()
+ {
+ return name;
+ }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @Length(max=100) @NotNull
+ public String getAddress()
+ {
+ return address;
+ }
+ public void setAddress(String address)
+ {
+ this.address = address;
+ }
+
+ @Length(max=40) @NotNull
+ public String getCity()
+ {
+ return city;
+ }
+ public void setCity(String city)
+ {
+ this.city = city;
+ }
+
+ @Length(min=4, max=6) @NotNull
+ public String getZip()
+ {
+ return zip;
+ }
+ public void setZip(String zip)
+ {
+ this.zip = zip;
+ }
+
+ @Length(min=2, max=10) @NotNull
+ public String getState()
+ {
+ return state;
+ }
+ public void setState(String state)
+ {
+ this.state = state;
+ }
+
+ @Length(min=2, max=40) @NotNull
+ public String getCountry()
+ {
+ return country;
+ }
+ public void setCountry(String country)
+ {
+ this.country = country;
+ }
+
+ @Column(precision=6, scale=2)
+ public BigDecimal getPrice()
+ {
+ return price;
+ }
+ public void setPrice(BigDecimal price)
+ {
+ this.price = price;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Hotel(" + name + "," + address + "," + city +
"," + zip + ")";
+ }
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/User.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/User.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/src/org/jboss/seam/example/booking/User.java 2010-11-15
19:16:39 UTC (rev 26581)
@@ -0,0 +1,70 @@
+//$Id: User.java 5579 2007-06-27 00:06:49Z gavin $
+package org.jboss.seam.example.booking;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.hibernate.validator.Length;
+import org.hibernate.validator.NotNull;
+import org.hibernate.validator.Pattern;
+
+@Entity
+@Table(name="Customer")
+public class User implements Serializable
+{
+ private String username;
+ private String password;
+ private String name;
+
+ public User(String name, String password, String username)
+ {
+ this.name = name;
+ this.password = password;
+ this.username = username;
+ }
+
+ public User() {}
+
+ @NotNull
+ @Length(max=100)
+ public String getName()
+ {
+ return name;
+ }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @NotNull
+ @Length(min=5, max=15)
+ public String getPassword()
+ {
+ return password;
+ }
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ @Id
+ @Length(min=4, max=15)
+ @Pattern(regex="^\\w*$", message="not a valid username")
+ public String getUsername()
+ {
+ return username;
+ }
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "User(" + username + ")";
+ }
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/testLaunchCfg.launch
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/testLaunchCfg.launch
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project2/testLaunchCfg.launch 2010-11-15
19:16:39 UTC (rev 26581)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<launchConfiguration
type="org.hibernate.eclipse.launch.CodeGenerationLaunchConfigurationType">
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER"
value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH"
value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="org.eclipse.ant.internal.launching.remote.InternalAntRunner"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION"
value="\LaunchConfigTestProject2\build_2794024212908788293xml"/>
+<stringAttribute key="org.hibernate.tools.configurationname"
value="LaunchConfigTestProject2"/>
+<booleanAttribute key="org.hibernate.tools.ejb3"
value="false"/>
+<listAttribute key="org.hibernate.tools.exporters">
+<listEntry value="org.hibernate.tools.hbm2java"/>
+<listEntry value="org.hibernate.tools.hbm2hbmxml"/>
+<listEntry value="org.hibernate.tools.hbm2dao"/>
+<listEntry value="org.hibernate.tools.hbmtemplate"/>
+<listEntry value="org.hibernate.tools.hbm2cfgxml"/>
+<listEntry value="org.hibernate.tools.hbm2doc"/>
+<listEntry value="org.hibernate.tools.hbm2ddl"/>
+<listEntry value="org.hibernate.tools.query"/>
+</listAttribute>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2cfgxml"
value="false"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2cfgxml.extension_id"
value="org.hibernate.tools.hbm2cfgxml"/>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2dao"
value="false"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2dao.extension_id"
value="org.hibernate.tools.hbm2dao"/>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2ddl"
value="false"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2ddl.extension_id"
value="org.hibernate.tools.hbm2ddl"/>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2doc"
value="true"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2doc.extension_id"
value="org.hibernate.tools.hbm2doc"/>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2hbmxml"
value="false"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2hbmxml.extension_id"
value="org.hibernate.tools.hbm2hbmxml"/>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2java"
value="false"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbm2java.extension_id"
value="org.hibernate.tools.hbm2java"/>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbmtemplate"
value="false"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.hbmtemplate.extension_id"
value="org.hibernate.tools.hbmtemplate"/>
+<booleanAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.query"
value="false"/>
+<stringAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.query.extension_id"
value="org.hibernate.tools.query"/>
+<mapAttribute
key="org.hibernate.tools.exporters.org.hibernate.tools.query.properties">
+<mapEntry key="outputFileName" value="asdf.txt"/>
+<mapEntry key="outputdir"
value="\LaunchConfigTestProject2\temp_test_out_folder"/>
+<mapEntry key="query_string" value="from
org.jboss.seam.example.booking.Booking"/>
+</mapAttribute>
+<booleanAttribute key="org.hibernate.tools.jdk5"
value="false"/>
+<stringAttribute key="org.hibernate.tools.outputdir"
value="\LaunchConfigTestProject2\temp_test_out_folder"/>
+<stringAttribute key="org.hibernate.tools.package"
value="hsql"/>
+<booleanAttribute key="org.hibernate.tools.prefercompositeids"
value="true"/>
+<booleanAttribute key="org.hibernate.tools.reveng.detect_many_to_many"
value="true"/>
+<booleanAttribute key="org.hibernate.tools.reveng.detect_one_to_one"
value="true"/>
+<booleanAttribute key="org.hibernate.tools.reveng.detect_optimistc_lock"
value="true"/>
+<booleanAttribute key="org.hibernate.tools.schema2hbm"
value="false"/>
+<booleanAttribute key="org.hibernate.tools.useExternalProcess"
value="true"/>
+<booleanAttribute key="org.hibernate.tools.useOwnTemplates"
value="false"/>
+<stringAttribute key="process_factory_id"
value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
+</launchConfiguration>
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenExternalProcessExecutionTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenExternalProcessExecutionTest.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenExternalProcessExecutionTest.java 2010-11-15
19:16:39 UTC (rev 26581)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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;
+
+import org.eclipse.core.externaltools.internal.IExternalToolConstants;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.core.LaunchManager;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
+import org.hibernate.eclipse.console.EclipseLaunchConsoleConfigurationPreferences;
+import org.hibernate.eclipse.console.test.project.LaunchConfigTestProject2;
+
+import junit.framework.TestCase;
+
+/**
+ * Execute codegeneration launch configuration in external process,
+ * to check the generation is successful.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+@SuppressWarnings("restriction")
+public class CodeGenExternalProcessExecutionTest extends TestCase {
+
+ private ConsoleConfiguration consoleCfg;
+ private LaunchConfigTestProject2 project;
+ private LaunchManager launchManager = new LaunchManager();
+
+ public CodeGenExternalProcessExecutionTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ this.project = new LaunchConfigTestProject2();
+
+ final String fileNameConsoleConfig =
LaunchConfigTestProject2.LAUNCH_CONSOLE_CONFIG_TEST_FILE;
+ ILaunchConfiguration launchConfig = loadLaunchConfigFromFile(fileNameConsoleConfig);
+ final EclipseLaunchConsoleConfigurationPreferences cfgprefs =
+ new EclipseLaunchConsoleConfigurationPreferences(launchConfig);
+ consoleCfg = new ConsoleConfiguration(cfgprefs);
+ KnownConfigurations.getInstance().addConfiguration(consoleCfg, true);
+ }
+
+ protected void tearDown() throws Exception {
+ this.project.deleteIProject();
+ this.project = null;
+
+ KnownConfigurations.getInstance().removeAllConfigurations();
+ consoleCfg = null;
+ }
+
+ public void testExecuteExternalLaunchConfig() {
+ IFolder testFolder = project.getTestFolder();
+ int nTest = -1;
+ try {
+ nTest = testFolder.members().length;
+ } catch (CoreException e) {
+ }
+ assertEquals(0, nTest);
+ final String fileNameCodeGen = LaunchConfigTestProject2.LAUNCH_CODE_GEN_TEST_FILE;
+ ILaunchConfiguration launchConfig = loadLaunchConfigFromFile(fileNameCodeGen);
+ ILaunchConfigurationWorkingCopy launchConfigWC = null;
+ try {
+ launchConfigWC = launchConfig.getWorkingCopy();
+ } catch (CoreException e) {
+ }
+ assertNotNull(launchConfigWC);
+ launchConfigWC.setAttribute(IExternalToolConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
+ DebugUIPlugin.launchInForeground(launchConfigWC, ILaunchManager.RUN_MODE);
+ nTest = -1;
+ try {
+ nTest = testFolder.members().length;
+ } catch (CoreException e) {
+ }
+ assertTrue(nTest > 0);
+ }
+
+ protected LaunchConfigTestProject2 getProject() {
+ return this.project;
+ }
+
+ public ILaunchConfiguration loadLaunchConfigFromFile(String fileName) {
+ IPath path = new Path(fileName);
+ IFile ifile = getProject().getIProject().getFile(path);
+ ILaunchConfiguration launchConfig = launchManager.getLaunchConfiguration((IFile)
ifile);
+ return launchConfig;
+ }
+}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java 2010-11-15
18:32:33 UTC (rev 26580)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java 2010-11-15
19:16:39 UTC (rev 26581)
@@ -26,6 +26,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
import org.eclipse.datatools.connectivity.internal.ConnectionProfile;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
@@ -216,9 +217,9 @@
IConnectionProfile profile = new ConnectionProfile("testName", null, null) {
//$NON-NLS-1$
public Properties getProperties(String type) {
Properties res = new Properties();
- res.setProperty("org.eclipse.datatools.connectivity.db.URL",
"url"); //$NON-NLS-1$ //$NON-NLS-2$
- res.setProperty("org.eclipse.datatools.connectivity.db.username",
"username"); //$NON-NLS-1$ //$NON-NLS-2$
- res.setProperty("org.eclipse.datatools.connectivity.db.password",
"passw"); //$NON-NLS-1$ //$NON-NLS-2$
+ res.setProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID, "url");
//$NON-NLS-1$
+ res.setProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID,
"username"); //$NON-NLS-1$
+ res.setProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID, "passw");
//$NON-NLS-1$
return res;
}
};
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 2010-11-15
18:32:33 UTC (rev 26580)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/ConfigurableTestProject.java 2010-11-15
19:16:39 UTC (rev 26581)
@@ -13,23 +13,15 @@
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.resources.IResource;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.osgi.util.NLS;
-import org.hibernate.eclipse.console.test.ConsoleTestMessages;
-import org.hibernate.eclipse.console.test.HibernateConsoleTestPlugin;
import org.hibernate.eclipse.console.test.mappingproject.Customization;
import org.hibernate.eclipse.console.test.utils.FilesTransfer;
@@ -89,18 +81,6 @@
return true;
}
- protected File getFolder(String path) throws IOException {
- URL entry = HibernateConsoleTestPlugin.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 boolean createTestFoldersList(FileFilter filterFiles, FileFilter filterFolders)
{
activePackage = -1;
foldersList = new ArrayList<String>();
@@ -167,11 +147,4 @@
foldersList.add(""); //$NON-NLS-1$
return true;
}
-
- public void fullBuild() throws CoreException {
- IPackageFragmentRoot sourcePackageFragment = createSourceFolder();
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- //sourcePackageFragment.getResource().refreshLocal();
- project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- }
}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/LaunchConfigTestProject2.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/LaunchConfigTestProject2.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/LaunchConfigTestProject2.java 2010-11-15
19:16:39 UTC (rev 26581)
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.project;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+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.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+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.utils.FilesTransfer;
+import org.hibernate.eclipse.console.test.utils.ResourceReadUtils;
+
+/**
+ * Test project to execute codegeneration launch configuration.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class LaunchConfigTestProject2 extends TestProject {
+
+ public static final String TEST_TMP_OUT_FOLDER = "temp_test_out_folder";
//$NON-NLS-1$
+ public static final String META_INF_FOLDER =
"src/META-INF".replaceAll("//", File.separator); //$NON-NLS-1$
//$NON-NLS-2$
+ public static final String PROJECT_PATH =
"res/project2/".replaceAll("//", File.separator); //$NON-NLS-1$
//$NON-NLS-2$
+ public static final String RESOURCE_SRC_PATH =
"res/project2/src/".replaceAll("//", File.separator); //$NON-NLS-1$
//$NON-NLS-2$
+ public static final String RESOURCE_LIB_PATH =
"res/project2/lib/".replaceAll("//", File.separator); //$NON-NLS-1$
//$NON-NLS-2$
+ public static final String HIBERNATE_PLUGIN_LIB_PATH = "lib"; //$NON-NLS-1$
+
+ public static final String LAUNCH_CODE_GEN_TEST_FILE = "testLaunchCfg.launch";
//$NON-NLS-1$
+ public static final String LAUNCH_CONSOLE_CONFIG_TEST_FILE =
"LaunchConfigTestProject2.launch"; //$NON-NLS-1$
+ public static final String HIBERNATE_CONSOLE_PROPERTIES_FILE =
"hibernate-console.properties"; //$NON-NLS-1$
+ public static final String PERSISTENCE_XML_FILE = "persistence.xml";
//$NON-NLS-1$
+
+ public LaunchConfigTestProject2() {
+ super("LaunchConfigTestProject2"); //$NON-NLS-1$
+ }
+
+ public LaunchConfigTestProject2(String projectName) {
+ super(projectName);
+ }
+
+ 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;
+ }
+
+ @SuppressWarnings("unused")
+ protected void buildProject() throws JavaModelException, CoreException, IOException {
+ super.buildProject();
+ IPackageFragmentRoot tst = createFolder(TEST_TMP_OUT_FOLDER);
+ tst.getResource().refreshLocal(IResource.DEPTH_INFINITE, null);
+ //
+ importFileToProject(LAUNCH_CODE_GEN_TEST_FILE);
+ importFileToProject(LAUNCH_CONSOLE_CONFIG_TEST_FILE);
+ importFileToProject(HIBERNATE_CONSOLE_PROPERTIES_FILE);
+ long startCopyFiles = System.currentTimeMillis();
+ IPackageFragmentRoot sourcePackageFragment = createSourceFolder();
+ 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);
+ setupSourceTestFolder();
+ //
+ tst = createFolder(META_INF_FOLDER);
+ importFileToProject(META_INF_FOLDER + File.separator + PERSISTENCE_XML_FILE);
+ //
+ fullBuild();
+ }
+
+ public IFolder getTestFolder() {
+ return project.getFolder(TEST_TMP_OUT_FOLDER);
+ }
+
+ public boolean setupSourceTestFolder() throws IOException, CoreException {
+ ArrayList<String> foldersList = new ArrayList<String>();
+ File srcFolder = null;
+ try {
+ srcFolder = getFolder(RESOURCE_SRC_PATH);
+ } catch (IOException e) {
+ // ignore
+ }
+ if (srcFolder == null) {
+ return false;
+ }
+ FilesTransfer.collectFoldersWithFiles(srcFolder, FilesTransfer.filterFilesJava,
+ FilesTransfer.filterFolders, foldersList);
+ IPath base = Path.fromOSString(srcFolder.getPath());
+ for (int i = 0; i < foldersList.size(); i++) {
+ String str = foldersList.get(i);
+ IPath path = Path.fromOSString(str);
+ path = path.makeRelativeTo(base);
+ foldersList.set(i, path.toOSString());
+ }
+ for (int i = 0; i < foldersList.size(); i++) {
+ FilesTransfer.delete(new
File(project.getLocation().append(SRC_FOLDER).toOSString()));
+ final String pack = foldersList.get(i);
+ srcFolder = getFolder(RESOURCE_SRC_PATH + pack);
+ IPackageFragmentRoot sourcePackageFragment = createFolder(SRC_FOLDER + File.separator
+ pack);
+ FilesTransfer.copyFolder(srcFolder, (IFolder)sourcePackageFragment.getResource());
+ }
+ return true;
+ }
+
+ public String getSample(String fileName) {
+ return ResourceReadUtils.getSample(PROJECT_PATH + fileName);
+ }
+
+ public void importFileToProject(String fileName) throws CoreException {
+ getIProject().getFile(fileName).create(
+ new ByteArrayInputStream(getSample(fileName).getBytes()),
+ false, new NullProgressMonitor());
+ }
+}
+
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/SimpleTestProject.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/SimpleTestProject.java 2010-11-15
18:32:33 UTC (rev 26580)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/SimpleTestProject.java 2010-11-15
19:16:39 UTC (rev 26581)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.project;
import java.io.IOException;
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/TestProject.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/TestProject.java 2010-11-15
18:32:33 UTC (rev 26580)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/project/TestProject.java 2010-11-15
19:16:39 UTC (rev 26581)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.project;
import java.io.File;
@@ -2,2 +12,3 @@
import java.io.IOException;
+import java.net.URL;
import java.util.ArrayList;
@@ -11,9 +22,12 @@
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
@@ -22,6 +36,7 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.osgi.util.NLS;
import org.hibernate.eclipse.console.test.ConsoleTestMessages;
+import org.hibernate.eclipse.console.test.HibernateConsoleTestPlugin;
import org.hibernate.eclipse.console.test.project.xpl.JavaProjectHelper;
import org.hibernate.eclipse.console.test.utils.FilesTransfer;
@@ -180,4 +195,24 @@
entries.add(JavaCore.newContainerEntry(JRE_CONTAINER));
javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[0]), null);
}
+
+ protected File getFolder(String path) throws IOException {
+ URL entry = HibernateConsoleTestPlugin.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;
+ }
+
+ @SuppressWarnings("unused")
+ public void fullBuild() throws CoreException {
+ IPackageFragmentRoot sourcePackageFragment = createSourceFolder();
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ //sourcePackageFragment.getResource().refreshLocal();
+ project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
+ }
}