Browse files

Added test class for "Adding SQLServerMetaDataDialect to support auto…

… discovery of Identity and guid strategy"

Could not test the test class, our db went down :(, Max can you test it?
  • Loading branch information...
1 parent a36fb49 commit 8ec346cff0627f4a0f1f18385f88c1b56451fbc7 @derkd derkd committed with koentsje Jun 9, 2011
Showing with 115 additions and 25 deletions.
  1. +41 −25 pom.xml
  2. +74 −0 src/test/org/hibernate/tool/test/jdbc2cfg/identity/SQLServerIdentityTest.java
View
66 pom.xml
@@ -498,6 +498,7 @@
<jdbc.driver.groupId>com.h2database</jdbc.driver.groupId>
<jdbc.driver.artifactId>h2</jdbc.driver.artifactId>
<db.dialect>org.hibernate.dialect.H2Dialect</db.dialect>
+ <jdbc.driver.jdbc.driver.version>1.2.124</jdbc.driver.jdbc.driver.version>
<jdbc.driver>org.h2.Driver</jdbc.driver>
<jdbc.url>jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE</jdbc.url>
<jdbc.user>sa</jdbc.user>
@@ -676,10 +677,10 @@
<profile>
<id>oracle9i</id>
<properties>
- <jdbc.driver.groupId>com.oracle</jdbc.driver.groupId>
- <jdbc.driver.artifactId>ojdbc14</jdbc.driver.artifactId>
- <!-- use the 10g drivers which are surprisingly largely bug free -->
- <jdbc.driver.version>10.0.2.0</jdbc.driver.version>
+ <jdbc.driver.groupId>com.oracle</jdbc.driver.groupId>
+ <jdbc.driver.artifactId>ojdbc14</jdbc.driver.artifactId>
+ <!-- use the 10g drivers which are surprisingly largely bug free -->
+ <jdbc.driver.jdbc.driver.version>10.0.2.0</jdbc.driver.jdbc.driver.version>
<db.dialect>org.hibernate.dialect.Oracle9iDialect</db.dialect>
<jdbc.driver>oracle.jdbc.driver.OracleDriver</jdbc.driver>
<jdbc.url>jdbc:oracle:thin:@dev20.qa.atl.jboss.com:1521:qa</jdbc.url>
@@ -693,10 +694,10 @@
<profile>
<id>oracle10g</id>
<properties>
- <jdbc.driver.groupId>com.oracle</jdbc.driver.groupId>
- <jdbc.driver.artifactId>ojdbc14</jdbc.driver.artifactId>
- <!-- use the 10g drivers which are surprisingly largely bug free -->
- <jdbc.driver.version>10.0.2.0</jdbc.driver.version>
+ <jdbc.driver.groupId>com.oracle</jdbc.driver.groupId>
+ <jdbc.driver.artifactId>ojdbc14</jdbc.driver.artifactId>
+ <!-- use the 10g drivers which are surprisingly largely bug free -->
+ <jdbc.driver.jdbc.driver.version>10.0.2.0</jdbc.driver.jdbc.driver.version>
<db.dialect>org.hibernate.dialect.Oracle10gDialect</db.dialect>
<jdbc.driver>oracle.jdbc.driver.OracleDriver</jdbc.driver>
<jdbc.url>jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.com:1521:qaora10</jdbc.url>
@@ -710,9 +711,9 @@
<profile>
<id>oracle11g</id>
<properties>
- <jdbc.driver.groupId>com.oracle</jdbc.driver.groupId>
- <jdbc.driver.artifactId>ojdbc5</jdbc.driver.artifactId>
- <jdbc.driver.version>11.1.0.7.0</jdbc.driver.version>
+ <jdbc.driver.groupId>com.oracle</jdbc.driver.groupId>
+ <jdbc.driver.artifactId>ojdbc5</jdbc.driver.artifactId>
+ <jdbc.driver.jdbc.driver.version>11.1.0.7.0</jdbc.driver.jdbc.driver.version>
<db.dialect>org.hibernate.dialect.Oracle10gDialect</db.dialect>
<jdbc.driver>oracle.jdbc.driver.OracleDriver</jdbc.driver>
<jdbc.url>jdbc:oracle:thin:@dev04.qa.atl2.redhat.com:1521:qaora11</jdbc.url>
@@ -726,10 +727,10 @@
<profile>
<id>oracle11gRAC</id>
<properties>
- <jdbc.driver.groupId>com.oracle</jdbc.driver.groupId>
- <jdbc.driver.artifactId>ojdbc5</jdbc.driver.artifactId>
- <jdbc.driver.version>11.1.0.7.0</jdbc.driver.version>
- <scope>test</scope>
+ <jdbc.driver.groupId>com.oracle</jdbc.driver.groupId>
+ <jdbc.driver.artifactId>ojdbc5</jdbc.driver.artifactId>
+ <jdbc.driver.jdbc.driver.version>11.1.0.7.0</jdbc.driver.jdbc.driver.version>
+ <scope>test</scope>
<db.dialect>org.hibernate.dialect.Oracle10gDialect</db.dialect>
<jdbc.driver>oracle.jdbc.driver.OracleDriver</jdbc.driver>
<jdbc.url>
@@ -745,9 +746,9 @@
<profile>
<id>sybase15</id>
<properties>
- <jdbc.driver.groupId>com.sybase</jdbc.driver.groupId>
- <jdbc.driver.artifactId>jconnect</jdbc.driver.artifactId>
- <jdbc.driver.version>6.0.5</jdbc.driver.version>
+ <jdbc.driver.groupId>com.sybase</jdbc.driver.groupId>
+ <jdbc.driver.artifactId>jconnect</jdbc.driver.artifactId>
+ <jdbc.driver.jdbc.driver.version>6.0.5</jdbc.driver.jdbc.driver.version>
<db.dialect>org.hibernate.dialect.SybaseASE15Dialect</db.dialect>
<jdbc.driver>com.sybase.jdbc3.jdbc.SybDriver</jdbc.driver>
<jdbc.url>jdbc:sybase:Tds:vmg07.mw.lab.eng.bos.redhat.com:5000/hibbrtru</jdbc.url>
@@ -761,9 +762,9 @@
<profile>
<id>mssql2005</id>
<properties>
- <jdbc.driver.groupId>com.microsoft.sqlserver</jdbc.driver.groupId>
- <jdbc.driver.artifactId>msjdbc</jdbc.driver.artifactId>
- <jdbc.driver.version>2.0.1008.2</jdbc.driver.version>
+ <jdbc.driver.groupId>com.microsoft.sqlserver</jdbc.driver.groupId>
+ <jdbc.driver.artifactId>msjdbc</jdbc.driver.artifactId>
+ <jdbc.driver.jdbc.driver.version>2.0.1008.2</jdbc.driver.jdbc.driver.version>
<db.dialect>org.hibernate.dialect.SQLServerDialect</db.dialect>
<jdbc.driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc.driver>
<jdbc.url>jdbc:sqlserver://dev30.qa.atl.jboss.com:3918</jdbc.url>
@@ -772,15 +773,30 @@
<jdbc.isolation>4096</jdbc.isolation>
</properties>
</profile>
+
+ <!-- The SQLServer2005 (MS JDBC) test envionment -->
+ <profile>
+ <id>mssql2005_jtds</id>
+ <properties>
+ <jdbc.driver.groupId>net.sourceforge.jtds</jdbc.driver.groupId>
+ <jdbc.driver.artifactId>jtds</jdbc.driver.artifactId>
+ <jdbc.driver.jdbc.driver.version>1.2.4</jdbc.driver.jdbc.driver.version><!-- newest is 1.2.5 but not in repo -->
+ <db.dialect>org.hibernate.dialect.SQLServerDialect</db.dialect>
+ <jdbc.driver>net.sourceforge.jtds.jdbc.Driver</jdbc.driver>
+ <jdbc.url>jdbc:jtds:sqlserver://dev30.qa.atl.jboss.com:3918</jdbc.url>
+ <jdbc.user>hibbrtru</jdbc.user>
+ <jdbc.pass>hibbrtru</jdbc.pass>
+ <jdbc.isolation>4096</jdbc.isolation>
+ </properties>
+ </profile>
<!-- The SQLServer2005 (MS JDBC) test envionment -->
<profile>
<id>mssql2008</id>
<properties>
- <jdbc.driver.groupId>com.microsoft.sqlserver</jdbc.driver.groupId>
- <jdbc.driver.artifactId>msjdbc</jdbc.driver.artifactId>
- <jdbc.driver.version>2.0.1008.2</jdbc.driver.version>
-
+ <jdbc.driver.groupId>com.microsoft.sqlserver</jdbc.driver.groupId>
+ <jdbc.driver.artifactId>msjdbc</jdbc.driver.artifactId>
+ <jdbc.driver.jdbc.driver.version>2.0.1008.2</jdbc.driver.jdbc.driver.version>
<db.dialect>org.hibernate.dialect.SQLServerDialect</db.dialect>
<jdbc.driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc.driver>
<jdbc.url>jdbc:sqlserver://vmg04.mw.lab.eng.bos.redhat.com:1433</jdbc.url>
View
74 src/test/org/hibernate/tool/test/jdbc2cfg/identity/SQLServerIdentityTest.java
@@ -0,0 +1,74 @@
+package org.hibernate.tool.test.jdbc2cfg.identity;
+
+import java.sql.SQLException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.cfg.JDBCMetaDataConfiguration;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.SQLServerDialect;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.tool.JDBCMetaDataBinderTestCase;
+
+/**
+ * @author max
+ *
+ */
+public class SQLServerIdentityTest extends JDBCMetaDataBinderTestCase {
+
+
+ /**
+ * @return
+ */
+ protected String[] getDropSQL() {
+ return new String[] {
+ "drop table identity",
+ "drop table guid",
+ };
+ }
+
+ /**
+ * @return
+ */
+ protected String[] getCreateSQL() {
+
+ return new String[] {
+ "CREATE TABLE identity (id INT NOT NULL IDENTITY, data varchar(100),CONSTRAINT PK_identity PRIMARY KEY (id))",
+ "CREATE TABLE guid (uid UNIQUEIDENTIFIER DEFAULT newid() NOT NULL, data varchar(100), CONSTRAINT PK_guid PRIMARY KEY (uid))",
+ };
+ }
+
+ public boolean appliesTo(Dialect dialect) {
+ return dialect instanceof SQLServerDialect;
+ }
+
+ protected void configure(JDBCMetaDataConfiguration configuration) {
+ configuration.setProperty( "hibernatetool.metadatadialect", SQLServerDialect.class.getName() );
+ }
+
+
+ //public void assertNoTables() throws SQLException {
+ // can't do that on mysql
+ //}
+
+ public static Test suite() {
+ return new TestSuite(SQLServerIdentityTest.class);
+ }
+
+ public void testIdentity() throws SQLException {
+ PersistentClass classMapping = cfg.getClassMapping(toClassName("identity") );
+ assertNotNull(classMapping);
+
+ assertEquals("identity", ((SimpleValue)classMapping.getIdentifierProperty().getValue()).getIdentifierGeneratorStrategy());
+ }
+
+ public void testGuid() throws SQLException {
+ PersistentClass classMapping = cfg.getClassMapping(toClassName("guid") );
+ assertNotNull(classMapping);
+
+ assertEquals("guid", ((SimpleValue)classMapping.getIdentifierProperty().getValue()).getIdentifierGeneratorStrategy());
+ }
+
+}

0 comments on commit 8ec346c

Please sign in to comment.