Hibernate SVN: r11369 - in branches/Branch_3_2/Hibernate3/test/org/hibernate: test and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-29 11:55:41 -0400 (Thu, 29 Mar 2007)
New Revision: 11369
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/FailureExpectedCollector.java
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
Log:
addded class to collect (and display) "failure expected" tests
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/FailureExpectedCollector.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/FailureExpectedCollector.java (rev 0)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/FailureExpectedCollector.java 2007-03-29 15:55:41 UTC (rev 11369)
@@ -0,0 +1,50 @@
+package org.hibernate.junit;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import junit.framework.TestSuite;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.hibernate.test.AllTests;
+
+/**
+ * A simple class to collect the names of "failure expected" tests...
+ *
+ * @author Steve Ebersole
+ */
+public class FailureExpectedCollector {
+
+ public static void main(String[] args) {
+ Set testNames = collectAllFailureExpectedTestNames();
+ Iterator itr = testNames.iterator();
+ int i = 0;
+ while ( itr.hasNext() ) {
+ i++;
+ System.out.println( i + ") " + itr.next() );
+ }
+ }
+
+ public static Set collectAllFailureExpectedTestNames() {
+ Set names = new HashSet();
+ collectFailureExpectedTestNames( names, ( TestSuite ) AllTests.unfilteredSuite() );
+ return names;
+ }
+
+ public static void collectFailureExpectedTestNames(final Set names, TestSuite suite) {
+ TestSuiteVisitor.Handler handler = new TestSuiteVisitor.Handler() {
+ public void handleTestCase(Test test) {
+ TestCase testCase = ( TestCase ) test;
+ if ( testCase.getName().endsWith( "FailureExpected" ) ) {
+ names.add( testCase.getClass().getName() + "#" + testCase.getName() );
+ }
+ }
+ public void startingTestSuite(TestSuite suite) {}
+ public void completedTestSuite(TestSuite suite) {}
+ };
+ TestSuiteVisitor visitor = new TestSuiteVisitor( handler );
+ visitor.visit( suite );
+ }
+}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2007-03-29 15:55:13 UTC (rev 11368)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2007-03-29 15:55:41 UTC (rev 11369)
@@ -148,6 +148,18 @@
}
/**
+ * Returns the entire test suite (both legacy and new) w/o filtering
+ *
+ * @return the entire test suite
+ */
+ public static Test unfilteredSuite() {
+ TestSuite suite = new TestSuite();
+ suite.addTest( NewTests.unfilteredSuite() );
+ suite.addTest( LegacyTests.unfilteredSuite() );
+ return suite;
+ }
+
+ /**
* Runs the entire test suite.
* <p/>
* @see #suite
@@ -163,11 +175,21 @@
public static class NewTests {
/**
- * Returns the new test suite
+ * Returns the new test suite (filtered)
*
* @return the new test suite
*/
public static Test suite() {
+ return filter( ( TestSuite ) unfilteredSuite() );
+ }
+
+
+ /**
+ * Returns the new test suite (unfiltered)
+ *
+ * @return the new test suite
+ */
+ public static Test unfilteredSuite() {
TestSuite suite = new TestSuite("New tests suite");
suite.addTest( OpsSuite.suite() );
suite.addTest( NaturalIdTest.suite() );
@@ -280,7 +302,7 @@
suite.addTest( DialectFunctionalTestsSuite.suite() );
suite.addTest( DialectUnitTestsSuite.suite() );
- return filter( suite );
+ return suite;
}
/**
@@ -304,6 +326,10 @@
* @return the legacy test suite
*/
public static Test suite() {
+ return filter( ( TestSuite ) unfilteredSuite() );
+ }
+
+ public static Test unfilteredSuite() {
TestSuite suite = new TestSuite("Legacy tests suite");
suite.addTest( FumTest.suite() );
suite.addTest( MasterDetailTest.suite() );
@@ -324,8 +350,7 @@
suite.addTest( OneToOneCacheTest.suite() );
suite.addTest( NonReflectiveBinderTest.suite() );
suite.addTest( ConfigurationPerformanceTest.suite() ); // Added to ensure we can utilize the recommended performance tips ;)
- return filter( suite );
-// return suite;
+ return suite;
}
/**
17 years, 8 months
Hibernate SVN: r11368 - in trunk/Hibernate3/test/org/hibernate: test and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-29 11:55:13 -0400 (Thu, 29 Mar 2007)
New Revision: 11368
Added:
trunk/Hibernate3/test/org/hibernate/junit/FailureExpectedCollector.java
Modified:
trunk/Hibernate3/test/org/hibernate/test/AllTests.java
Log:
addded class to collect (and display) "failure expected" tests
Added: trunk/Hibernate3/test/org/hibernate/junit/FailureExpectedCollector.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/junit/FailureExpectedCollector.java (rev 0)
+++ trunk/Hibernate3/test/org/hibernate/junit/FailureExpectedCollector.java 2007-03-29 15:55:13 UTC (rev 11368)
@@ -0,0 +1,50 @@
+package org.hibernate.junit;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import junit.framework.TestSuite;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.hibernate.test.AllTests;
+
+/**
+ * A simple class to collect the names of "failure expected" tests...
+ *
+ * @author Steve Ebersole
+ */
+public class FailureExpectedCollector {
+
+ public static void main(String[] args) {
+ Set testNames = collectAllFailureExpectedTestNames();
+ Iterator itr = testNames.iterator();
+ int i = 0;
+ while ( itr.hasNext() ) {
+ i++;
+ System.out.println( i + ") " + itr.next() );
+ }
+ }
+
+ public static Set collectAllFailureExpectedTestNames() {
+ Set names = new HashSet();
+ collectFailureExpectedTestNames( names, ( TestSuite ) AllTests.unfilteredSuite() );
+ return names;
+ }
+
+ public static void collectFailureExpectedTestNames(final Set names, TestSuite suite) {
+ TestSuiteVisitor.Handler handler = new TestSuiteVisitor.Handler() {
+ public void handleTestCase(Test test) {
+ TestCase testCase = ( TestCase ) test;
+ if ( testCase.getName().endsWith( "FailureExpected" ) ) {
+ names.add( testCase.getClass().getName() + "#" + testCase.getName() );
+ }
+ }
+ public void startingTestSuite(TestSuite suite) {}
+ public void completedTestSuite(TestSuite suite) {}
+ };
+ TestSuiteVisitor visitor = new TestSuiteVisitor( handler );
+ visitor.visit( suite );
+ }
+}
Modified: trunk/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/AllTests.java 2007-03-29 13:26:40 UTC (rev 11367)
+++ trunk/Hibernate3/test/org/hibernate/test/AllTests.java 2007-03-29 15:55:13 UTC (rev 11368)
@@ -148,10 +148,22 @@
}
/**
+ * Returns the entire test suite (both legacy and new) w/o filtering
+ *
+ * @return the entire test suite
+ */
+ public static Test unfilteredSuite() {
+ TestSuite suite = new TestSuite();
+ suite.addTest( NewTests.unfilteredSuite() );
+ suite.addTest( LegacyTests.unfilteredSuite() );
+ return suite;
+ }
+
+ /**
* Runs the entire test suite.
- * <p/>
+ *
+ * @param args n/a
* @see #suite
- * @param args n/a
*/
public static void main(String args[]) {
TestRunner.run( suite() );
@@ -163,11 +175,20 @@
public static class NewTests {
/**
- * Returns the new test suite
+ * Returns the new test suite (filtered)
*
* @return the new test suite
*/
public static Test suite() {
+ return filter( ( TestSuite ) unfilteredSuite() );
+ }
+
+ /**
+ * Returns the new test suite (unfiltered)
+ *
+ * @return the new test suite
+ */
+ public static Test unfilteredSuite() {
TestSuite suite = new TestSuite("New tests suite");
suite.addTest( OpsSuite.suite() );
suite.addTest( NaturalIdTest.suite() );
@@ -280,7 +301,7 @@
suite.addTest( DialectFunctionalTestsSuite.suite() );
suite.addTest( DialectUnitTestsSuite.suite() );
- return filter( suite );
+ return suite;
}
/**
@@ -304,6 +325,15 @@
* @return the legacy test suite
*/
public static Test suite() {
+ return filter( ( TestSuite ) unfilteredSuite() );
+ }
+
+ /**
+ * Returns the legacy test suite
+ *
+ * @return the legacy test suite
+ */
+ public static Test unfilteredSuite() {
TestSuite suite = new TestSuite("Legacy tests suite");
suite.addTest( FumTest.suite() );
suite.addTest( MasterDetailTest.suite() );
@@ -324,8 +354,7 @@
suite.addTest( OneToOneCacheTest.suite() );
suite.addTest( NonReflectiveBinderTest.suite() );
suite.addTest( ConfigurationPerformanceTest.suite() ); // Added to ensure we can utilize the recommended performance tips ;)
- return filter( suite );
-// return suite;
+ return suite;
}
/**
17 years, 8 months
Hibernate SVN: r11367 - trunk/Hibernate3/src/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-29 09:26:40 -0400 (Thu, 29 Mar 2007)
New Revision: 11367
Modified:
trunk/Hibernate3/src/org/hibernate/dialect/PostgreSQLDialect.java
Log:
test suite fixes : postgresql (dialect metadata)
Modified: trunk/Hibernate3/src/org/hibernate/dialect/PostgreSQLDialect.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/dialect/PostgreSQLDialect.java 2007-03-29 13:26:25 UTC (rev 11366)
+++ trunk/Hibernate3/src/org/hibernate/dialect/PostgreSQLDialect.java 2007-03-29 13:26:40 UTC (rev 11367)
@@ -296,11 +296,17 @@
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- public boolean supportsRowValueConstructorSyntax() {
- return true;
- }
+// seems to not really...
+// public boolean supportsRowValueConstructorSyntax() {
+// return true;
+// }
public boolean supportsEmptyInList() {
return false;
}
+
+ public boolean supportsExpectedLobUsagePattern() {
+ // seems to have spotty LOB suppport
+ return false;
+ }
}
17 years, 8 months
Hibernate SVN: r11366 - branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-29 09:26:25 -0400 (Thu, 29 Mar 2007)
New Revision: 11366
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/PostgreSQLDialect.java
Log:
test suite fixes : postgresql (dialect metadata)
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/PostgreSQLDialect.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/PostgreSQLDialect.java 2007-03-29 13:25:48 UTC (rev 11365)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/PostgreSQLDialect.java 2007-03-29 13:26:25 UTC (rev 11366)
@@ -296,11 +296,17 @@
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- public boolean supportsRowValueConstructorSyntax() {
- return true;
- }
+// seems to not really...
+// public boolean supportsRowValueConstructorSyntax() {
+// return true;
+// }
public boolean supportsEmptyInList() {
return false;
}
+
+ public boolean supportsExpectedLobUsagePattern() {
+ // PostgreSQL seems to have spotty LOB suppport
+ return false;
+ }
}
17 years, 8 months
Hibernate SVN: r11365 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-29 09:25:48 -0400 (Thu, 29 Mar 2007)
New Revision: 11365
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where/NumericTrueFalseType.java
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where/File.hbm.xml
Log:
test suite fixes : postgresql (boolean handling)
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where/File.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where/File.hbm.xml 2007-03-29 13:25:25 UTC (rev 11364)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where/File.hbm.xml 2007-03-29 13:25:48 UTC (rev 11365)
@@ -6,15 +6,14 @@
<!--
Demonstrates use of a class-level where restriction
-->
-<hibernate-mapping
- package="org.hibernate.test.where">
+<hibernate-mapping package="org.hibernate.test.where">
<class name="File" where="deleted=0" table="T_FILE">
<id name="id">
<generator class="increment"/>
</id>
<property name="name"/>
- <property name="deleted"/>
+ <property name="deleted" type="org.hibernate.test.where.NumericTrueFalseType"/>
<many-to-one name="parent"/>
<set name="children" inverse="true" where="deleted=0">
<key column="parent"/>
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where/NumericTrueFalseType.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where/NumericTrueFalseType.java (rev 0)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/where/NumericTrueFalseType.java 2007-03-29 13:25:48 UTC (rev 11365)
@@ -0,0 +1,53 @@
+package org.hibernate.test.where;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.Types;
+
+import org.hibernate.type.BooleanType;
+import org.hibernate.dialect.Dialect;
+
+/**
+ * Maps int db values to boolean java values. Zero is considered false; any
+ * non-zero value is considered true.
+ *
+ * @author Steve Ebersole
+ */
+public class NumericTrueFalseType extends BooleanType {
+
+ public Object get(ResultSet rs, String name) throws SQLException {
+ int value = rs.getInt( name );
+ if ( rs.wasNull() ) {
+ return getDefaultValue();
+ }
+ else if ( value == 0 ) {
+ return Boolean.FALSE;
+ }
+ else {
+ return Boolean.TRUE;
+ }
+ }
+
+ public void set(PreparedStatement st, Object value, int index) throws SQLException {
+ if ( value == null ) {
+ st.setNull( index, Types.INTEGER );
+ }
+ else {
+ boolean bool = ( ( Boolean ) value ).booleanValue();
+ st.setInt( index, bool ? 1 : 0 );
+ }
+ }
+
+ public String objectToSQLString(Object value, Dialect dialect) throws Exception {
+ return ( ( Boolean ) value ).booleanValue() ? "1" : "0";
+ }
+
+ public int sqlType() {
+ return Types.INTEGER;
+ }
+
+ public String getName() {
+ return "numeric_boolean";
+ }
+}
17 years, 8 months
Hibernate SVN: r11364 - trunk/Hibernate3/test/org/hibernate/test/where.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-29 09:25:25 -0400 (Thu, 29 Mar 2007)
New Revision: 11364
Added:
trunk/Hibernate3/test/org/hibernate/test/where/NumericTrueFalseType.java
Modified:
trunk/Hibernate3/test/org/hibernate/test/where/File.hbm.xml
Log:
test suite fixes : postgresql (boolean handling)
Modified: trunk/Hibernate3/test/org/hibernate/test/where/File.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/where/File.hbm.xml 2007-03-29 13:09:51 UTC (rev 11363)
+++ trunk/Hibernate3/test/org/hibernate/test/where/File.hbm.xml 2007-03-29 13:25:25 UTC (rev 11364)
@@ -1,25 +1,24 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
+<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!--
+<!--
Demonstrates use of a class-level where restriction
-->
-<hibernate-mapping
- package="org.hibernate.test.where">
+<hibernate-mapping package="org.hibernate.test.where">
<class name="File" where="deleted=0" table="T_FILE">
<id name="id">
<generator class="increment"/>
</id>
<property name="name"/>
- <property name="deleted"/>
+ <property name="deleted" type="org.hibernate.test.where.NumericTrueFalseType"/>
<many-to-one name="parent"/>
<set name="children" inverse="true" where="deleted=0">
<key column="parent"/>
<one-to-many class="File"/>
</set>
- </class>
+ </class>
</hibernate-mapping>
Added: trunk/Hibernate3/test/org/hibernate/test/where/NumericTrueFalseType.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/where/NumericTrueFalseType.java (rev 0)
+++ trunk/Hibernate3/test/org/hibernate/test/where/NumericTrueFalseType.java 2007-03-29 13:25:25 UTC (rev 11364)
@@ -0,0 +1,53 @@
+package org.hibernate.test.where;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.Types;
+
+import org.hibernate.type.BooleanType;
+import org.hibernate.dialect.Dialect;
+
+/**
+ * Maps int db values to boolean java values. Zero is considered false; any
+ * non-zero value is considered true.
+ *
+ * @author Steve Ebersole
+ */
+public class NumericTrueFalseType extends BooleanType {
+
+ public Object get(ResultSet rs, String name) throws SQLException {
+ int value = rs.getInt( name );
+ if ( rs.wasNull() ) {
+ return getDefaultValue();
+ }
+ else if ( value == 0 ) {
+ return Boolean.FALSE;
+ }
+ else {
+ return Boolean.TRUE;
+ }
+ }
+
+ public void set(PreparedStatement st, Object value, int index) throws SQLException {
+ if ( value == null ) {
+ st.setNull( index, Types.INTEGER );
+ }
+ else {
+ boolean bool = ( ( Boolean ) value ).booleanValue();
+ st.setInt( index, bool ? 1 : 0 );
+ }
+ }
+
+ public String objectToSQLString(Object value, Dialect dialect) throws Exception {
+ return ( ( Boolean ) value ).booleanValue() ? "1" : "0";
+ }
+
+ public int sqlType() {
+ return Types.INTEGER;
+ }
+
+ public String getName() {
+ return "numeric_boolean";
+ }
+}
17 years, 8 months
Hibernate SVN: r11363 - trunk/Hibernate3/test/org/hibernate/test/sql.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-29 09:09:51 -0400 (Thu, 29 Mar 2007)
New Revision: 11363
Modified:
trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
Log:
test suite fixes : postgresql (alias casing)
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2007-03-29 13:09:39 UTC (rev 11362)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2007-03-29 13:09:51 UTC (rev 11363)
@@ -20,6 +20,7 @@
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.hibernate.transform.Transformers;
+import org.hibernate.transform.AliasToEntityMapResultTransformer;
/**
* @author Steve Ebersole
@@ -472,7 +473,7 @@
Object[] o = (Object[]) list.get(0);
assertEquals(8, o.length);
- list = s.createSQLQuery(getEmploymentSQL()).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
+ list = s.createSQLQuery( getEmploymentSQL() ).setResultTransformer( new UpperCasedAliasToEntityMapResultTransformer() ).list();
assertEquals(1, list.size());
m = (Map) list.get(0);
assertTrue(m.containsKey("EMPID"));
@@ -595,4 +596,13 @@
}
}
+ private static class UpperCasedAliasToEntityMapResultTransformer extends AliasToEntityMapResultTransformer {
+ public Object transformTuple(Object[] tuple, String[] aliases) {
+ String[] ucAliases = new String[aliases.length];
+ for ( int i = 0; i < aliases.length; i++ ) {
+ ucAliases[i] = aliases[i].toUpperCase();
+ }
+ return super.transformTuple( tuple, ucAliases );
+ }
+ }
}
17 years, 8 months
Hibernate SVN: r11362 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-29 09:09:39 -0400 (Thu, 29 Mar 2007)
New Revision: 11362
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
Log:
test suite fixes : postgresql (alias casing)
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2007-03-29 12:48:35 UTC (rev 11361)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2007-03-29 13:09:39 UTC (rev 11362)
@@ -20,6 +20,7 @@
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.hibernate.transform.Transformers;
+import org.hibernate.transform.AliasToEntityMapResultTransformer;
/**
* @author Steve Ebersole
@@ -472,7 +473,7 @@
Object[] o = (Object[]) list.get(0);
assertEquals(8, o.length);
- list = s.createSQLQuery(getEmploymentSQL()).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
+ list = s.createSQLQuery( getEmploymentSQL() ).setResultTransformer( new UpperCasedAliasToEntityMapResultTransformer() ).list();
assertEquals(1, list.size());
m = (Map) list.get(0);
assertTrue(m.containsKey("EMPID"));
@@ -595,4 +596,13 @@
}
}
+ private static class UpperCasedAliasToEntityMapResultTransformer extends AliasToEntityMapResultTransformer {
+ public Object transformTuple(Object[] tuple, String[] aliases) {
+ String[] ucAliases = new String[aliases.length];
+ for ( int i = 0; i < aliases.length; i++ ) {
+ ucAliases[i] = aliases[i].toUpperCase();
+ }
+ return super.transformTuple( tuple, ucAliases );
+ }
+ }
}
17 years, 8 months
Hibernate SVN: r11361 - in trunk/Hibernate3/test/org/hibernate/test: legacy and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-29 08:48:35 -0400 (Thu, 29 Mar 2007)
New Revision: 11361
Modified:
trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
trunk/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java
trunk/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java
Log:
test suite fixes : postgresql (boolean handling)
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java 2007-03-29 12:47:49 UTC (rev 11360)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java 2007-03-29 12:48:35 UTC (rev 11361)
@@ -11,7 +11,6 @@
import antlr.RecognitionException;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -516,8 +515,7 @@
}
public void testSubstitutions() throws Exception {
- HashMap replacements = new HashMap();
- replacements.put("true", "1");
+ Map replacements = buildTrueFalseReplacementMapForDialect();
replacements.put("yes", "'Y'");
assertTranslation( "from Human h where h.pregnant = true", replacements );
assertTranslation( "from Human h where h.pregnant = yes", replacements );
@@ -663,27 +661,35 @@
public void testPolymorphism() throws Exception {
- HashMap replacements = new HashMap();
- replacements.put( "false", "0" );
- replacements.put( "true", "1" );
+ Map replacements = buildTrueFalseReplacementMapForDialect();
assertTranslation( "from Mammal" );
assertTranslation( "from Dog" );
assertTranslation( "from Mammal m where m.pregnant = false and m.bodyWeight > 10", replacements );
assertTranslation( "from Dog d where d.pregnant = false and d.bodyWeight > 10", replacements );
}
- public void testTokenReplacement() throws Exception {
+ private Map buildTrueFalseReplacementMapForDialect() {
HashMap replacements = new HashMap();
- replacements.put( "false", "0" );
- replacements.put( "true", "1" );
- assertTranslation( "from Mammal m where m.pregnant = false and m.bodyWeight > 10",
- replacements );
+ try {
+ String dialectTrueRepresentation = getDialect().toBooleanValueString( true );
+ // if this call succeeds, then the dialect is saying to represent true/false as int values...
+ Integer.parseInt( dialectTrueRepresentation );
+ replacements.put( "true", "1" );
+ replacements.put( "false", "0" );
+ }
+ catch( NumberFormatException nfe ) {
+ // the Integer#parseInt call failed...
+ }
+ return replacements;
}
+ public void testTokenReplacement() throws Exception {
+ Map replacements = buildTrueFalseReplacementMapForDialect();
+ assertTranslation( "from Mammal m where m.pregnant = false and m.bodyWeight > 10", replacements );
+ }
+
public void testProduct() throws Exception {
- HashMap replacements = new HashMap();
- replacements.put( "false", "0" );
- replacements.put( "true", "1" );
+ Map replacements = buildTrueFalseReplacementMapForDialect();
assertTranslation( "from Animal, Animal" );
assertTranslation( "from Animal x, Animal y where x.bodyWeight = y.bodyWeight" );
assertTranslation( "from Animal x, Mammal y where x.bodyWeight = y.bodyWeight and not y.pregnant = true", replacements );
@@ -747,9 +753,7 @@
}
public void testExplicitJoins() throws Exception {
- HashMap replacements = new HashMap();
- replacements.put( "false", "0" );
- replacements.put( "true", "1" );
+ Map replacements = buildTrueFalseReplacementMapForDialect();
assertTranslation( "from Zoo zoo join zoo.mammals mam where mam.pregnant = true and mam.description like '%white%'", replacements );
assertTranslation( "from Zoo zoo join zoo.animals an where an.description like '%white%'" );
}
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java 2007-03-29 12:47:49 UTC (rev 11360)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java 2007-03-29 12:48:35 UTC (rev 11361)
@@ -106,7 +106,7 @@
assertTranslation( hql, null, scalar, null );
}
- protected void assertTranslation(String hql, HashMap replacements) {
+ protected void assertTranslation(String hql, Map replacements) {
ComparisonFailure cf = null;
try {
assertTranslation( hql, replacements, false, null );
@@ -141,7 +141,7 @@
System.out.println( "OLD SQL: " + oldsql );
}
- protected void assertTranslation(String hql, HashMap replacements, boolean scalar, String sql) {
+ protected void assertTranslation(String hql, Map replacements, boolean scalar, String sql) {
SessionFactoryImplementor factory = getSessionFactoryImplementor();
// Create an empty replacements map if we don't have one.
@@ -198,12 +198,12 @@
}
- protected QueryTranslatorImpl createNewQueryTranslator(String hql, HashMap replacements, boolean scalar) {
+ protected QueryTranslatorImpl createNewQueryTranslator(String hql, Map replacements, boolean scalar) {
SessionFactoryImplementor factory = getSessionFactoryImplementor();
return createNewQueryTranslator( hql, replacements, scalar, factory );
}
- private QueryTranslatorImpl createNewQueryTranslator(String hql, HashMap replacements, boolean scalar, SessionFactoryImplementor factory) {
+ private QueryTranslatorImpl createNewQueryTranslator(String hql, Map replacements, boolean scalar, SessionFactoryImplementor factory) {
QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
QueryTranslatorImpl newQueryTranslator = ( QueryTranslatorImpl ) ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
newQueryTranslator.compile( replacements, scalar );
Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java 2007-03-29 12:47:49 UTC (rev 11360)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java 2007-03-29 12:48:35 UTC (rev 11361)
@@ -5,6 +5,7 @@
import org.hibernate.hql.classic.ClassicQueryTranslatorFactory;
import org.hibernate.util.StringHelper;
import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.dialect.Dialect;
/**
* @author Steve Ebersole
@@ -32,14 +33,25 @@
super.configure( cfg );
if ( !useAntlrParser ) {
cfg.setProperty( Environment.QUERY_TRANSLATOR, ClassicQueryTranslatorFactory.class.getName() );
- String subs = cfg.getProperties().getProperty( Environment.QUERY_SUBSTITUTIONS );
- if ( StringHelper.isEmpty( subs ) ) {
- subs = "true=1, false=0";
+ try {
+ String dialectTrueRepresentation = Dialect.getDialect().toBooleanValueString( true );
+ // if this call succeeds, then the dialect is saying to represent true/false as int values...
+ Integer.parseInt( dialectTrueRepresentation );
+ String subs = cfg.getProperties().getProperty( Environment.QUERY_SUBSTITUTIONS );
+ if ( subs == null ) {
+ subs = "";
+ }
+ if ( StringHelper.isEmpty( subs ) ) {
+ subs = "true=1, false=0";
+ }
+ else {
+ subs += ", true=1, false=0";
+ }
+ cfg.getProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, subs );
}
- else {
- subs += ", true=1, false=0";
+ catch( NumberFormatException nfe ) {
+ // the Integer#parseInt call failed...
}
- cfg.getProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, subs );
}
}
}
17 years, 8 months
Hibernate SVN: r11360 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-29 08:47:49 -0400 (Thu, 29 Mar 2007)
New Revision: 11360
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java
Log:
test suite fixes : postgresql (boolean handling)
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLTest.java 2007-03-29 12:35:51 UTC (rev 11359)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLTest.java 2007-03-29 12:47:49 UTC (rev 11360)
@@ -11,7 +11,6 @@
import antlr.RecognitionException;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.hibernate.Hibernate;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -516,8 +515,7 @@
}
public void testSubstitutions() throws Exception {
- HashMap replacements = new HashMap();
- replacements.put("true", "1");
+ Map replacements = buildTrueFalseReplacementMapForDialect();
replacements.put("yes", "'Y'");
assertTranslation( "from Human h where h.pregnant = true", replacements );
assertTranslation( "from Human h where h.pregnant = yes", replacements );
@@ -663,27 +661,35 @@
public void testPolymorphism() throws Exception {
- HashMap replacements = new HashMap();
- replacements.put( "false", "0" );
- replacements.put( "true", "1" );
+ Map replacements = buildTrueFalseReplacementMapForDialect();
assertTranslation( "from Mammal" );
assertTranslation( "from Dog" );
assertTranslation( "from Mammal m where m.pregnant = false and m.bodyWeight > 10", replacements );
assertTranslation( "from Dog d where d.pregnant = false and d.bodyWeight > 10", replacements );
}
- public void testTokenReplacement() throws Exception {
+ private Map buildTrueFalseReplacementMapForDialect() {
HashMap replacements = new HashMap();
- replacements.put( "false", "0" );
- replacements.put( "true", "1" );
- assertTranslation( "from Mammal m where m.pregnant = false and m.bodyWeight > 10",
- replacements );
+ try {
+ String dialectTrueRepresentation = getDialect().toBooleanValueString( true );
+ // if this call succeeds, then the dialect is saying to represent true/false as int values...
+ Integer.parseInt( dialectTrueRepresentation );
+ replacements.put( "true", "1" );
+ replacements.put( "false", "0" );
+ }
+ catch( NumberFormatException nfe ) {
+ // the Integer#parseInt call failed...
+ }
+ return replacements;
}
+ public void testTokenReplacement() throws Exception {
+ Map replacements = buildTrueFalseReplacementMapForDialect();
+ assertTranslation( "from Mammal m where m.pregnant = false and m.bodyWeight > 10", replacements );
+ }
+
public void testProduct() throws Exception {
- HashMap replacements = new HashMap();
- replacements.put( "false", "0" );
- replacements.put( "true", "1" );
+ Map replacements = buildTrueFalseReplacementMapForDialect();
assertTranslation( "from Animal, Animal" );
assertTranslation( "from Animal x, Animal y where x.bodyWeight = y.bodyWeight" );
assertTranslation( "from Animal x, Mammal y where x.bodyWeight = y.bodyWeight and not y.pregnant = true", replacements );
@@ -747,9 +753,7 @@
}
public void testExplicitJoins() throws Exception {
- HashMap replacements = new HashMap();
- replacements.put( "false", "0" );
- replacements.put( "true", "1" );
+ Map replacements = buildTrueFalseReplacementMapForDialect();
assertTranslation( "from Zoo zoo join zoo.mammals mam where mam.pregnant = true and mam.description like '%white%'", replacements );
assertTranslation( "from Zoo zoo join zoo.animals an where an.description like '%white%'" );
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java 2007-03-29 12:35:51 UTC (rev 11359)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java 2007-03-29 12:47:49 UTC (rev 11360)
@@ -106,7 +106,7 @@
assertTranslation( hql, null, scalar, null );
}
- protected void assertTranslation(String hql, HashMap replacements) {
+ protected void assertTranslation(String hql, Map replacements) {
ComparisonFailure cf = null;
try {
assertTranslation( hql, replacements, false, null );
@@ -141,7 +141,7 @@
System.out.println( "OLD SQL: " + oldsql );
}
- protected void assertTranslation(String hql, HashMap replacements, boolean scalar, String sql) {
+ protected void assertTranslation(String hql, Map replacements, boolean scalar, String sql) {
SessionFactoryImplementor factory = getSessionFactoryImplementor();
// Create an empty replacements map if we don't have one.
@@ -198,12 +198,12 @@
}
- protected QueryTranslatorImpl createNewQueryTranslator(String hql, HashMap replacements, boolean scalar) {
+ protected QueryTranslatorImpl createNewQueryTranslator(String hql, Map replacements, boolean scalar) {
SessionFactoryImplementor factory = getSessionFactoryImplementor();
return createNewQueryTranslator( hql, replacements, scalar, factory );
}
- private QueryTranslatorImpl createNewQueryTranslator(String hql, HashMap replacements, boolean scalar, SessionFactoryImplementor factory) {
+ private QueryTranslatorImpl createNewQueryTranslator(String hql, Map replacements, boolean scalar, SessionFactoryImplementor factory) {
QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
QueryTranslatorImpl newQueryTranslator = ( QueryTranslatorImpl ) ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
newQueryTranslator.compile( replacements, scalar );
17 years, 8 months