Author: steve.ebersole(a)jboss.com
Date: 2007-05-26 02:37:10 -0400 (Sat, 26 May 2007)
New Revision: 11573
Added:
trunk/Hibernate3/testsuite/src/test/perf/
trunk/Hibernate3/testsuite/src/test/perf/org/
trunk/Hibernate3/testsuite/src/test/profile/
trunk/Hibernate3/testsuite/src/test/profile/hsqldb/
trunk/Hibernate3/testsuite/src/test/profile/hsqldb/hibernate.properties
trunk/Hibernate3/testsuite/src/test/resources/
trunk/Hibernate3/testsuite/src/test/resources/hibernate.cfg.xml
trunk/Hibernate3/testsuite/src/test/resources/log4j.properties
trunk/Hibernate3/testsuite/src/test/unmaintained/
trunk/Hibernate3/testsuite/src/test/unmaintained/org/
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.hbm.xml
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.java
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/TestSchemaTools.java
Removed:
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestSelector.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewPerformanceTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewerPerformanceTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/PerformanceTest.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/tool/
Modified:
trunk/Hibernate3/testsuite/pom.xml
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/ConfigurationPerformanceTest.java
Log:
a little better on the test suite
Modified: trunk/Hibernate3/testsuite/pom.xml
===================================================================
--- trunk/Hibernate3/testsuite/pom.xml 2007-05-26 05:19:56 UTC (rev 11572)
+++ trunk/Hibernate3/testsuite/pom.xml 2007-05-26 06:37:10 UTC (rev 11573)
@@ -43,6 +43,89 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-swarmcache</artifactId>
</dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.11</version>
+ </dependency>
+ <!-- these are optional on core... :( -->
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.4.GA</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.1_3</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-attrs</artifactId>
+ <version>1.5.3</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ <version>1.1</version>
+ </dependency>
</dependencies>
+ <build>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </testResource>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/resources</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+
<name>hibernate.test.validatefailureexpected</name>
+ <value>true</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>hsqldb</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/profile/hsqldb</directory>
+ </testResource>
+ </testResources>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
</project>
\ No newline at end of file
Modified:
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java
===================================================================
---
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java 2007-05-26
05:19:56 UTC (rev 11572)
+++
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/FailureExpectedCollector.java 2007-05-26
06:37:10 UTC (rev 11573)
@@ -1,14 +1,14 @@
-package org.hibernate.junit;
+package org.hibernate.test;
-import java.util.Set;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Set;
-import junit.framework.TestSuite;
import junit.framework.Test;
import junit.framework.TestCase;
+import junit.framework.TestSuite;
-import org.hibernate.test.AllTests;
+import org.hibernate.junit.TestSuiteVisitor;
/**
* A simple class to collect the names of "failure expected" tests...
Deleted: trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestSelector.java
===================================================================
---
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestSelector.java 2007-05-26
05:19:56 UTC (rev 11572)
+++
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/TestSelector.java 2007-05-26
06:37:10 UTC (rev 11573)
@@ -1,64 +0,0 @@
-package org.hibernate.test;
-
-import java.util.Set;
-import java.util.HashSet;
-import java.io.File;
-
-import org.apache.tools.ant.types.selectors.FileSelector;
-import org.apache.tools.ant.BuildException;
-
-import org.hibernate.junit.TestSuiteVisitor;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * A custom Ant FileSelector used to limit the tests run from the Ant
- * build script to only those defined in the {@link org.hibernate.test.AllTests} suite.
- * <p/>
- * {@link org.hibernate.test.AllTests} is used/maintained by the developers to easily
- * run the test suite in all IDEs. It represents all the tests
- * which should actually be run and included in test results.
- *
- * @author Steve Ebersole
- */
-public class TestSelector implements FileSelector {
-
- private final Set allTestClassNames = new HashSet();
-
- public TestSelector() {
- TestSuiteVisitor.Handler handler = new TestSuiteVisitor.Handler() {
- public void handleTestCase(Test test) {
- allTestClassNames.add( test.getClass().getName() );
- }
- public void startingTestSuite(TestSuite suite) {}
- public void completedTestSuite(TestSuite suite) {}
- };
- TestSuiteVisitor visitor = new TestSuiteVisitor( handler );
- visitor.visit( ( TestSuite ) AllTests.suite() );
- }
-
-
- // FileSelector impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean isSelected(File dir, String fileFromDir, File fullFile) throws
BuildException {
- String correspondingClassName = determineClassName( fileFromDir );
- return allTestClassNames.contains( correspondingClassName );
- }
-
- private String determineClassName(String file) {
- if ( file.endsWith( ".class" ) ) {
- file = file.substring( 0, file.length() - 6 );
- }
- else if ( file.endsWith( ".java" ) ) {
- file = file.substring( 0, file.length() - 5 );
- }
- else {
- return null;
- }
- file = file.replace( '\\', '.' );
- file = file.replace( '/', '.' );
- return file;
- }
-
-}
Modified:
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/ConfigurationPerformanceTest.java
===================================================================
---
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/ConfigurationPerformanceTest.java 2007-05-26
05:19:56 UTC (rev 11572)
+++
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/ConfigurationPerformanceTest.java 2007-05-26
06:37:10 UTC (rev 11573)
@@ -83,7 +83,7 @@
public void testLoadingAndSerializationOfConfiguration() throws HibernateException,
FileNotFoundException, IOException, ClassNotFoundException {
- String prefix = "./test/org/hibernate/test/";
+ String prefix = "./src/test/java/org/hibernate/test/";
try {
// first time
System.err.println("###FIRST SAVELOAD###");
Deleted:
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewPerformanceTest.java
===================================================================
---
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewPerformanceTest.java 2007-05-26
05:19:56 UTC (rev 11572)
+++
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewPerformanceTest.java 2007-05-26
06:37:10 UTC (rev 11573)
@@ -1,92 +0,0 @@
-//$Id: NewPerformanceTest.java 5718 2005-02-13 23:01:34Z oneovthafew $
-package org.hibernate.test.legacy;
-
-import java.io.Serializable;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-import org.hibernate.classic.Session;
-import org.hibernate.test.TestCase;
-
-public class NewPerformanceTest extends TestCase {
-
- public NewPerformanceTest(String arg0) {
- super(arg0);
- }
-
- public void testPerformance() throws Exception {
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- }
-
- Session s = openSession();
- prepare(s, simples, ids, n);
- s.close();
-
- long find = 0;
- long flush = 0;
-
- for ( int i=0; i<100; i++ ) {
-
- s = openSession();
- long time = System.currentTimeMillis();
- List list = s.createQuery("from Simple s where not s.name='osama bin
laden' and s.other is null").list();
- find += System.currentTimeMillis() - time;
- assertTrue( list.size()==n );
- time = System.currentTimeMillis();
- s.flush();
- flush += System.currentTimeMillis() - time;
- time = System.currentTimeMillis();
- s.connection().commit();
- find += System.currentTimeMillis() - time;
- s.close();
-
- }
-
- System.out.println( "Objects: " + n + " - find(): " + find +
"ms / flush(): " + flush + "ms / Ratio: " + ( (float) flush )/find );
- System.out.println( "Objects: " + n + " flush time per object: " +
flush / 100.0 / n );
- System.out.println( "Objects: " + n + " load time per object: " +
find / 100.0 / n );
- s = openSession();
- delete(s);
- s.close();
-
- }
- }
-
- private void prepare(Session s, Simple[] simples, Serializable[] ids, int N) throws
Exception {
- for ( int i=0; i<N; i++ ) {
- s.save( simples[i], ids[i] );
- }
- s.flush();
- s.connection().commit();
- }
-
- private void delete(Session s) throws Exception {
- s.delete("from Simple s");
- s.flush();
- s.connection().commit();
- }
-
- public String[] getMappings() {
- return new String[] { "legacy/Simple.hbm.xml" };
- }
-
- public static Test suite() throws Exception {
- return new TestSuite(NewPerformanceTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
-}
Deleted:
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewerPerformanceTest.java
===================================================================
---
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewerPerformanceTest.java 2007-05-26
05:19:56 UTC (rev 11572)
+++
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/NewerPerformanceTest.java 2007-05-26
06:37:10 UTC (rev 11573)
@@ -1,402 +0,0 @@
-//$Id: NewerPerformanceTest.java 4599 2004-09-26 05:18:27Z oneovthafew $
-package org.hibernate.test.legacy;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-import org.hibernate.classic.Session;
-import org.hibernate.cfg.Environment;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.connection.ConnectionProviderFactory;
-import org.hibernate.test.TestCase;
-
-public class NewerPerformanceTest extends TestCase {
-
- public NewerPerformanceTest(String arg0) {
- super(arg0);
- }
-
- public void testMany() throws Exception {
-
- ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider(
Environment.getProperties() );
-
- long hiber=0;
- long jdbc=0;
-
- for ( int n=0; n<20; n++ ) {
-
- Session s = openSession();
- s.delete("from Simple");
- s.flush();
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- s.save(simples[i], ids[i]);
- }
- s.flush();
- s.connection().commit();
- s.close();
-
- //allow cache to settle
-
- s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- Connection c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- //Now do timings
-
- int N=30;
-
- long time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- s = openSession();
- hibernate(s, simples, ids, n, "h1");
- s.close();
- }
- hiber += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j1" );
- cp.closeConnection(c);
- }
- jdbc += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- s = openSession();
- hibernate(s, simples, ids, n, "h2");
- s.close();
- }
- hiber += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j2" );
- cp.closeConnection(c);
- }
- jdbc += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- s = openSession();
- hibernate(s, simples, ids, n, "h1");
- s.close();
- }
- hiber += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j1" );
- cp.closeConnection(c);
- }
- jdbc += System.currentTimeMillis() - time;
-
- }
-
- System.out.println( "Hibernate: " + hiber + "ms / Direct JDBC: " +
jdbc + "ms = Ratio: " + ( (float) hiber )/jdbc );
-
- cp.close();
- System.gc();
- }
-
- public void testSimultaneous() throws Exception {
-
- ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider(
Environment.getProperties() );
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Session s = openSession();
- s.delete("from Simple");
- s.flush();
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- s.save(simples[i], ids[i]);
- }
- s.flush();
- s.connection().commit();
- s.close();
-
- //allow cache to settle
-
- s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- Connection c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- //Now do timings
-
- s = openSession();
- long time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h1");
- long hiber = System.currentTimeMillis() - time;
- s.close();
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j1" );
- long jdbc = System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- System.out.println( "Objects: " + n + " - Hibernate: " + hiber +
"ms / Direct JDBC: " + jdbc + "ms = Ratio: " + ( (float) hiber )/jdbc
);
-
- }
-
- cp.close();
- System.gc();
- }
-
- public void testHibernateOnly() throws Exception {
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Session s = openSession();
- Simple[] simples = new Simple[n];
- s.delete("from Simple");
- s.flush();
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- s.save(simples[i], ids[i]);
- }
- s.flush();
- s.connection().commit();
- s.close();
-
- //Now do timings
-
- s = openSession();
- long time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h1");
- long hiber = System.currentTimeMillis() - time;
- s.close();
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- System.out.println( "Objects: " + n + " - Hibernate: " + hiber );
-
- }
-
- System.gc();
- }
-
- public void testJdbcOnly() throws Exception {
-
- ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider(
Environment.getProperties() );
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Session s = openSession();
- Simple[] simples = new Simple[n];
- s.delete("from Simple");
- s.flush();
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- s.save(simples[i], ids[i]);
- }
- s.flush();
- s.connection().commit();
- s.close();
-
-
- //Now do timings
-
- Connection c = cp.getConnection();
- long time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j1" );
- long jdbc = System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- System.out.println( "Objects: " + n + " Direct JDBC: " + jdbc );
-
- }
-
- cp.close();
- System.gc();
- }
-
- /*private void hibernate(Session s, Simple[] simples, Serializable[] ids, int N, String
runname) throws Exception {
- for ( int i=0; i<N; i++ ) {
- s.get( Simple.class, ids[i] );
- //s.find("from Simple s where s.id = ?", ids[i], Hibernate.LONG);
- }
- //s.flush();
- s.connection().commit();
- }
-
- private void directJDBC(Connection c, Simple[] simples, Serializable[] ids, int N,
String runname) throws SQLException {
-
- for ( int i=0; i<N; i++ ) {
- PreparedStatement select = c.prepareStatement("SELECT s.id_, s.name, s.address,
s.count_, s.date_, s.pay, s.other FROM Simple s where s.id_=?");
- select.setLong( 1, ( (Long) ids[i] ).longValue() );
- ResultSet rs = select.executeQuery();
- rs.next();
- /*new Long( rs.getLong(1) );
- rs.getString(2);
- rs.getString(3);
- rs.getInt(4);
- rs.getDate(5);
- rs.getFloat(6);
- rs.getLong(7);*/
- /*Simple s = new Simple();
- new Long( rs.getLong("id_") ); rs.wasNull();
- s.setName( rs.getString("name") ); rs.wasNull();
- s.setAddress( rs.getString("address") ); rs.wasNull();
- s.setCount( rs.getInt("count_") ); rs.wasNull();
- s.setDate( rs.getTimestamp("date_") ); rs.wasNull();
- s.setPay( new Float( rs.getFloat("pay") ) ); rs.wasNull();
- rs.getLong("other"); rs.wasNull(); s.setOther(null);
- rs.close();
- select.close();
- }
- c.commit();
- }*/
-
- private void hibernate(Session s, Simple[] simples, Serializable[] ids, int N, String
runname) throws Exception {
- s.createQuery("from Simple s").list();
- s.connection().commit();
- }
-
- private void directJDBC(Connection c, Simple[] simples, Serializable[] ids, int N,
String runname) throws SQLException {
- List result=new ArrayList();
- PreparedStatement select = c.prepareStatement("SELECT s.id_ as id_, s.name as
name, s.address as address, s.count_ as count_, s.date_ as date_, s.pay as pay, s.other as
other FROM Simple s");
- ResultSet rs = select.executeQuery();
- while ( rs.next() ) {
- /*new Long( rs.getLong(1) );
- rs.getString(2);
- rs.getString(3);
- rs.getInt(4);
- rs.getDate(5);
- rs.getFloat(6);
- rs.getLong(7);*/
- Simple s = new Simple();
- new Long( rs.getLong("id_") ); rs.wasNull();
- s.setName( rs.getString("name") ); rs.wasNull();
- s.setAddress( rs.getString("address") ); rs.wasNull();
- s.setCount( rs.getInt("count_") ); rs.wasNull();
- s.setDate( rs.getTimestamp("date_") ); rs.wasNull();
- s.setPay( new Float( rs.getFloat("pay") ) ); rs.wasNull();
- rs.getLong("other"); rs.wasNull(); s.setOther(null);
- result.add(s);
- }
- rs.close();
- select.close();
- c.commit();
- }
-
- public String[] getMappings() {
- return new String[] { "legacy/Simple.hbm.xml" };
- }
-
- public static Test suite() {
- return new TestSuite(NewerPerformanceTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-
-}
-
-
-
-
-
-
-
Deleted:
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/PerformanceTest.java
===================================================================
---
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/PerformanceTest.java 2007-05-26
05:19:56 UTC (rev 11572)
+++
trunk/Hibernate3/testsuite/src/test/java/org/hibernate/test/legacy/PerformanceTest.java 2007-05-26
06:37:10 UTC (rev 11573)
@@ -1,356 +0,0 @@
-//$Id: PerformanceTest.java 6900 2005-05-25 01:24:22Z oneovthafew $
-package org.hibernate.test.legacy;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Types;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-import org.hibernate.classic.Session;
-import org.hibernate.cfg.Environment;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.connection.ConnectionProviderFactory;
-import org.hibernate.test.TestCase;
-
-public class PerformanceTest extends TestCase {
-
- public PerformanceTest(String arg0) {
- super(arg0);
- }
-
- public void testMany() throws Exception {
-
- ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider(
Environment.getProperties() );
-
- long hiber=0;
- long jdbc=0;
-
- for ( int n=0; n<20; n++ ) {
-
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- }
-
- //allow cache to settle
-
- Session s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- Connection c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- //Now do timings
-
- int N=30;
-
- long time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- s = openSession();
- hibernate(s, simples, ids, n, "h1");
- s.close();
- }
- hiber += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j1" );
- cp.closeConnection(c);
- }
- jdbc += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- s = openSession();
- hibernate(s, simples, ids, n, "h2");
- s.close();
- }
- hiber += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j2" );
- cp.closeConnection(c);
- }
- jdbc += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- s = openSession();
- hibernate(s, simples, ids, n, "h1");
- s.close();
- }
- hiber += System.currentTimeMillis() - time;
-
- time = System.currentTimeMillis();
- for (int i=0; i<N; i++) {
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j1" );
- cp.closeConnection(c);
- }
- jdbc += System.currentTimeMillis() - time;
-
- }
-
- System.out.println( "Hibernate: " + hiber + "ms / Direct JDBC: " +
jdbc + "ms = Ratio: " + ( (float) hiber )/jdbc );
-
- cp.close();
- System.gc();
- }
-
- public void testSimultaneous() throws Exception {
-
- ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider(
Environment.getProperties() );
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- }
-
- //allow cache to settle
-
- Session s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- Connection c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- s = openSession();
- hibernate(s, simples, ids, n, "h0");
- s.close();
-
- c = cp.getConnection();
- directJDBC( c, simples, ids, n, "j0" );
- cp.closeConnection(c);
-
- //Now do timings
-
- s = openSession();
- long time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h1");
- long hiber = System.currentTimeMillis() - time;
- s.close();
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j1" );
- long jdbc = System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- System.out.println( "Objects: " + n + " - Hibernate: " + hiber +
"ms / Direct JDBC: " + jdbc + "ms = Ratio: " + ( (float) hiber )/jdbc
);
-
- }
-
- cp.close();
- System.gc();
- }
-
- public void testHibernateOnly() throws Exception {
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- }
-
- //Now do timings
-
- Session s = openSession();
- long time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h1");
- long hiber = System.currentTimeMillis() - time;
- s.close();
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- s = openSession();
- time = System.currentTimeMillis();
- hibernate(s, simples, ids, n, "h2");
- hiber += System.currentTimeMillis() - time;
- s.close();
-
- System.out.println( "Objects: " + n + " - Hibernate: " + hiber );
-
- }
-
- System.gc();
- }
-
- public void testJdbcOnly() throws Exception {
-
- ConnectionProvider cp = ConnectionProviderFactory.newConnectionProvider(
Environment.getProperties() );
-
- for ( int n=2; n<4000; n*=2 ) {
-
- Simple[] simples = new Simple[n];
- Serializable[] ids = new Serializable[n];
- for ( int i=0; i<n; i++ ) {
- simples[i] = new Simple();
- simples[i].init();
- simples[i].setCount(i);
- ids[i] = new Long(i);
- }
-
- //Now do timings
-
- Connection c = cp.getConnection();
- long time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j1" );
- long jdbc = System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- c = cp.getConnection();
- time = System.currentTimeMillis();
- directJDBC( c, simples, ids, n, "j2" );
- jdbc += System.currentTimeMillis() - time;
- cp.closeConnection(c);
-
- System.out.println( "Objects: " + n + " Direct JDBC: " + jdbc );
-
- }
-
- cp.close();
- System.gc();
- }
-
- private void hibernate(Session s, Simple[] simples, Serializable[] ids, int N, String
runname) throws Exception {
- for ( int i=0; i<N; i++ ) {
- s.save( simples[i], ids[i] );
- }
- for ( int i=0; i<N; i++ ) {
- simples[0].setName("A Different Name!" + i + N + runname);
- }
- //s.flush();
- // the results of this test are highly dependent upon
- // how many times we flush!
- assertTrue( "assertion", s.delete("from Simple s")==N );
- s.flush();
- s.connection().commit();
- }
-
- private void directJDBC(Connection c, Simple[] simples, Serializable[] ids, int N,
String runname) throws SQLException {
-
- PreparedStatement insert = c.prepareStatement("insert into Simple ( name, address,
count_, date_, other, id_ ) values ( ?, ?, ?, ?, ?, ? )");
- PreparedStatement delete = c.prepareStatement("delete from Simple where id_ =
?");
- PreparedStatement select = c.prepareStatement("SELECT s.id_, s.name, s.address,
s.count_, s.date_, s.other FROM Simple s");
- PreparedStatement update = c.prepareStatement("update Simple set name = ?, address
= ?, count_ = ?, date_ = ?, other = ? where id_ = ?");
- for ( int i=0; i<N; i++ ) {
- insert.setString(1, simples[i].getName() );
- insert.setString(2, simples[i].getAddress() );
- insert.setInt(3, simples[i].getCount() );
- insert.setDate( 4, (java.sql.Date) simples[i].getDate() );
- insert.setNull(5, Types.BIGINT);
- insert.setLong( 6, ( (Long) ids[i] ).longValue() );
- insert.executeUpdate();
- }
- insert.close();
- for ( int i=0; i<N; i++ ) {
- update.setString(1, "A Different Name!" + i + N + runname );
- update.setString(2, simples[i].getAddress() );
- update.setInt(3, simples[i].getCount() );
- update.setDate( 4, (java.sql.Date) simples[i].getDate() );
- update.setNull(5, Types.BIGINT);
- update.setLong( 6, ( (Long) ids[i] ).longValue() );
- update.executeUpdate();
- }
- update.close();
- java.sql.ResultSet rs = select.executeQuery();
- Long[] keys = new Long[N];
- int j=0;
- while ( rs.next() ) {
- keys[j++] = new Long( rs.getLong(1) );
- rs.getString(2);
- rs.getString(3);
- rs.getInt(4);
- rs.getDate(5);
- rs.getLong(6);
- }
- rs.close();
- select.close();
- for ( int i=0; i<N; i++ ) {
- delete.setLong(1, keys[i].longValue() );
- delete.executeUpdate();
- }
- delete.close();
- c.commit();
- }
-
- public String[] getMappings() {
- return new String[] { "legacy/Simple.hbm.xml" };
- }
-
- public static Test suite() throws Exception {
- return new TestSuite(PerformanceTest.class);
- }
-
- public static void main(String[] args) throws Exception {
- TestRunner.run( suite() );
- }
-}
Added: trunk/Hibernate3/testsuite/src/test/profile/hsqldb/hibernate.properties
===================================================================
--- trunk/Hibernate3/testsuite/src/test/profile/hsqldb/hibernate.properties
(rev 0)
+++ trunk/Hibernate3/testsuite/src/test/profile/hsqldb/hibernate.properties 2007-05-26
06:37:10 UTC (rev 11573)
@@ -0,0 +1,19 @@
+hibernate.dialect org.hibernate.dialect.HSQLDialect
+hibernate.connection.driver_class org.hsqldb.jdbcDriver
+hibernate.connection.username sa
+hibernate.connection.password
+hibernate.connection.url jdbc:hsqldb:target/test/db/hsqldb/hibernate
+
+hibernate.connection.pool_size 1
+
+hibernate.jdbc.batch_versioned_data true
+hibernate.jdbc.use_streams_for_binary true
+
+hibernate.format_sql true
+
+hibernate.max_fetch_depth 1
+
+hibernate.cache.region_prefix hibernate.test
+hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
+
+hibernate.query.substitutions yes 'Y', no 'N'
\ No newline at end of file
Added: trunk/Hibernate3/testsuite/src/test/resources/hibernate.cfg.xml
===================================================================
--- trunk/Hibernate3/testsuite/src/test/resources/hibernate.cfg.xml
(rev 0)
+++ trunk/Hibernate3/testsuite/src/test/resources/hibernate.cfg.xml 2007-05-26 06:37:10
UTC (rev 11573)
@@ -0,0 +1,8 @@
+<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration
DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+<hibernate-configuration>
+ <session-factory name="foo">
+ <property name="show_sql">true</property>
+ <mapping resource="org/hibernate/test/legacy/Simple.hbm.xml"/>
+ <class-cache class="org.hibernate.test.legacy.Simple"
region="Simple" usage="read-write"/>
+ </session-factory>
+</hibernate-configuration>
\ No newline at end of file
Copied: trunk/Hibernate3/testsuite/src/test/resources/log4j.properties (from rev 11570,
trunk/Hibernate3/documentation/tutorial/src/main/resources/log4j.properties)
===================================================================
--- trunk/Hibernate3/testsuite/src/test/resources/log4j.properties
(rev 0)
+++ trunk/Hibernate3/testsuite/src/test/resources/log4j.properties 2007-05-26 06:37:10 UTC
(rev 11573)
@@ -0,0 +1,41 @@
+### direct log messages to stdout ###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+
+### set log levels - for more verbose logging change 'info' to 'debug'
###
+
+log4j.rootLogger=warn, stdout
+
+log4j.logger.org.hibernate=info
+#log4j.logger.org.hibernate=debug
+
+### log HQL query parser activity
+#log4j.logger.org.hibernate.hql.ast.AST=debug
+
+### log just the SQL
+#log4j.logger.org.hibernate.SQL=debug
+
+### log JDBC bind parameters ###
+log4j.logger.org.hibernate.type=info
+#log4j.logger.org.hibernate.type=debug
+
+### log schema export/update ###
+log4j.logger.org.hibernate.tool.hbm2ddl=debug
+
+### log HQL parse trees
+#log4j.logger.org.hibernate.hql=debug
+
+### log cache activity ###
+#log4j.logger.org.hibernate.cache=debug
+
+### log transaction activity
+#log4j.logger.org.hibernate.transaction=debug
+
+### log JDBC resource acquisition
+#log4j.logger.org.hibernate.jdbc=debug
+
+### enable the following line if you want to track down connection ###
+### leakages when using DriverManagerConnectionProvider ###
+#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
Added:
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.hbm.xml
===================================================================
--- trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.hbm.xml
(rev 0)
+++
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.hbm.xml 2007-05-26
06:37:10 UTC (rev 11573)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.tool">
+ <class name="Team" table="`Team`">
+ <id name="id" column="`iD`">
+ <generator class="native">
+ <param name="sequence">TEAM_SEQ</param>
+ </generator>
+ </id>
+ <property name="name"/>
+ </class>
+
+ <class entity-name="OtherTeam" name="Team"
table="TEAM">
+ <id name="id" column="id">
+ <generator class="native">
+ <param name="sequence">TEAM_SEQ</param>
+ </generator>
+ </id>
+ <property name="name" column="xname"/>
+ </class>
+
+</hibernate-mapping>
Added: trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.java
===================================================================
--- trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.java
(rev 0)
+++
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/Team.java 2007-05-26
06:37:10 UTC (rev 11573)
@@ -0,0 +1,20 @@
+package org.hibernate.test.tool;
+
+
+public class Team {
+ private Long id;
+ private String name;
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
Added:
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/TestSchemaTools.java
===================================================================
---
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/TestSchemaTools.java
(rev 0)
+++
trunk/Hibernate3/testsuite/src/test/unmaintained/org/hibernate/test/tool/TestSchemaTools.java 2007-05-26
06:37:10 UTC (rev 11573)
@@ -0,0 +1,226 @@
+package org.hibernate.test.tool;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.SQLException;
+
+import junit.framework.Test;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.HSQLDialect;
+import org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.hibernate.tool.hbm2ddl.SchemaUpdate;
+import org.hibernate.tool.hbm2ddl.SchemaValidator;
+
+/**
+ * @author Anthony
+ *
+ * Basic smoke test for schemaupdate/validator.
+ * Dependent on schemas, and probably also HQLDB - Not possible to have in the global
test suite at the moment.
+ *
+ * WARNING, if you want this test to work, you need to define a default schema = SB
+ * in hibernate global configuration.
+ * This schema should not be the same at the default db user schema and should come after
the users schema alphabetically.
+ *
+ */
+public class TestSchemaTools extends DatabaseSpecificFunctionalTestCase {
+
+ public TestSchemaTools(String name) {
+ super( name );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "tool/Team.hbm.xml" };
+ }
+
+ public boolean createSchema() {
+ return false;
+ }
+
+ public void afterSessionFactoryBuilt(SessionFactoryImplementor sfi) {
+ super.afterSessionFactoryBuilt( sfi );
+ Session session = null;
+ try {
+ session = sfi.openSession();
+ Statement stat = session.connection().createStatement();
+ stat.execute("CREATE SCHEMA sb AUTHORIZATION DBA ");
+ stat.execute(" CREATE SCHEMA sa AUTHORIZATION DBA ");
+ stat.execute(" CREATE TABLE \"SA\".\"Team\" (test INTEGER)
");
+ stat.close();
+ }
+ catch ( SQLException e ) {
+ throw new RuntimeException( "could not prepare additional schemas" );
+ }
+ finally {
+ if ( session != null ) {
+ try {
+ session.close();
+ }
+ catch( Throwable ignore ) {
+ }
+ }
+ }
+ }
+
+ protected void prepareTest() throws Exception {
+ super.prepareTest();
+ }
+
+
+ public boolean appliesTo(Dialect dialect) {
+ return dialect instanceof HSQLDialect;
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( TestSchemaTools.class );
+ }
+
+ public void testSchemaTools() throws Exception{
+ // database schema have been created thanks to the setUp method
+ // we have 2 schemas SA et SB, SB must be set as the default schema
+ // used by hibernate hibernate.default_schema SB
+ SchemaExport se = new SchemaExport(getCfg());
+ se.create(true,true);
+
+ // here we modify the generated table in order to test SchemaUpdate
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("ALTER TABLE \"SB\".\"Team\" DROP COLUMN name
");
+
+ // update schema
+ SchemaUpdate su = new SchemaUpdate(getCfg());
+ su.execute(true,true);
+
+ // we can run schema validation. Note that in the setUp method a *wrong* table
+ // has been created with different column names
+ // if schema validator chooses the bad db schema, then the testcase will fail
(exception)
+ SchemaValidator sv = new SchemaValidator(getCfg());
+ sv.validate();
+
+ // it's time to clean our database
+ se.drop(true,true);
+
+ // then the schemas and false table.
+
+ stat.execute("DROP TABLE \"SA\".\"Team\" ");
+ stat.execute(" DROP SCHEMA sa ");
+ stat.execute("DROP SCHEMA sb ");
+ stat.close();
+ session.close();
+ }
+
+ public void testSchemaToolsNonQuote() throws Exception{
+ // database schema have been created thanks to the setUp method
+ // we have 2 schemas SA et SB, SB must be set as the default schema
+ // used by hibernate hibernate.default_schema SB
+ SchemaExport se = new SchemaExport(getCfg());
+ se.create(true,true);
+
+ // here we modify the generated table in order to test SchemaUpdate
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("ALTER TABLE \"SB\".\"TEAM\" DROP COLUMN xname
");
+
+ // update schema
+ SchemaUpdate su = new SchemaUpdate(getCfg());
+ su.execute(true,true);
+
+ // we can run schema validation. Note that in the setUp method a *wrong* table
+ // has been created with different column names
+ // if schema validator chooses the bad db schema, then the testcase will fail
(exception)
+ SchemaValidator sv = new SchemaValidator(getCfg());
+ sv.validate();
+
+ // it's time to clean our database
+ se.drop(true,true);
+
+ // then the schemas and false table.
+
+ stat.execute("DROP TABLE \"SA\".\"Team\" ");
+ stat.execute(" DROP SCHEMA sa ");
+ stat.execute("DROP SCHEMA sb ");
+ stat.close();
+ session.close();
+ }
+ public void testFailingQuoteValidation() throws Exception{
+ // database schema have been created thanks to the setUp method
+ // we have 2 schemas SA et SB, SB must be set as the default schema
+ // used by hibernate hibernate.default_schema SB
+ SchemaExport se = new SchemaExport(getCfg());
+ se.create(true,true);
+
+ // here we modify the generated table in order to test SchemaUpdate
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("ALTER TABLE \"SB\".\"Team\" DROP COLUMN name
");
+
+ // update schema
+ //SchemaUpdate su = new SchemaUpdate(getCfg());
+ //su.execute(true,true);
+
+ try {
+ SchemaValidator sv = new SchemaValidator(getCfg());
+ sv.validate();
+ fail("should fail since we mutated the current schema.");
+ } catch(HibernateException he) {
+
+ }
+
+ // it's time to clean our database
+ se.drop(true,true);
+
+ // then the schemas and false table.
+
+ stat.execute("DROP TABLE \"SA\".\"Team\" ");
+ stat.execute(" DROP SCHEMA sa ");
+ stat.execute("DROP SCHEMA sb ");
+ stat.close();
+ session.close();
+ }
+
+ public void testFailingNonQuoteValidation() throws Exception{
+ // database schema have been created thanks to the setUp method
+ // we have 2 schemas SA et SB, SB must be set as the default schema
+ // used by hibernate hibernate.default_schema SB
+ SchemaExport se = new SchemaExport(getCfg());
+ se.create(true,true);
+
+ // here we modify the generated table in order to test SchemaUpdate
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("ALTER TABLE \"SB\".\"TEAM\" DROP COLUMN xname
");
+
+ // update schema
+ //SchemaUpdate su = new SchemaUpdate(getCfg());
+ //su.execute(true,true);
+
+ try {
+ SchemaValidator sv = new SchemaValidator(getCfg());
+ sv.validate();
+ fail("should fail since we mutated the current schema.");
+ } catch(HibernateException he) {
+
+ }
+
+ // it's time to clean our database
+ se.drop(true,true);
+
+ // then the schemas and false table.
+
+ stat.execute("DROP TABLE \"SA\".\"Team\" ");
+ stat.execute(" DROP SCHEMA sa ");
+ stat.execute("DROP SCHEMA sb ");
+ stat.close();
+ session.close();
+ }
+
+}