From fa09bc28668d173045810164014f5857a75bd8af Mon Sep 17 00:00:00 2001 From: brmeyer Date: Tue, 11 Dec 2012 15:21:35 -0500 Subject: [PATCH] HHH-7797 initial test case --- .../UniqueConstraintTest.java | 8 +-- .../test/constraint/ConstraintTest.java | 64 +++++++++++++++++++ .../org/hibernate/testing/DialectChecks.java | 6 -- 3 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/constraint/ConstraintTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/uniqueconstraint/UniqueConstraintTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/uniqueconstraint/UniqueConstraintTest.java index c6335c9988..08048f050b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/uniqueconstraint/UniqueConstraintTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/uniqueconstraint/UniqueConstraintTest.java @@ -1,15 +1,12 @@ package org.hibernate.test.annotations.uniqueconstraint; -import org.junit.Test; +import static org.junit.Assert.fail; import org.hibernate.JDBCException; import org.hibernate.Session; import org.hibernate.Transaction; -import org.hibernate.testing.DialectChecks; -import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.fail; +import org.junit.Test; /** * @author Manuel Bernhardt @@ -25,7 +22,6 @@ public class UniqueConstraintTest extends BaseCoreFunctionalTestCase { } @Test - @RequiresDialectFeature( DialectChecks.SupportNotNullUnique.class ) public void testUniquenessConstraintWithSuperclassProperty() throws Exception { Session s = openSession(); Transaction tx = s.beginTransaction(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/constraint/ConstraintTest.java b/hibernate-core/src/test/java/org/hibernate/test/constraint/ConstraintTest.java new file mode 100644 index 0000000000..936f61c73c --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/constraint/ConstraintTest.java @@ -0,0 +1,64 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +package org.hibernate.test.constraint; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.Test; + +/** + * HHH-7797 re-wrote the way dialects handle unique constraints. Test as + * many variations of unique, not null, and primary key constraints as possible. + * + * @author Brett Meyer + */ +@TestForIssue( jiraKey = "HHH-7797" ) +public class ConstraintTest extends BaseCoreFunctionalTestCase { + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { + Entity1.class + }; + } + + @Test + public void testConstraints() { + // nothing yet -- more interested in DDL creation + } + + // Primary key w/ not null and unique + @Entity + public static class Entity1 { + @Id + @GeneratedValue +// @Column( nullable = false, unique = true) + public long id; + + @Column( nullable = false, unique = true) + public String foo; + } +} \ No newline at end of file diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/DialectChecks.java b/hibernate-testing/src/main/java/org/hibernate/testing/DialectChecks.java index a2e56fdda2..8408818ca0 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/DialectChecks.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/DialectChecks.java @@ -92,12 +92,6 @@ abstract public class DialectChecks { } } - public static class SupportNotNullUnique implements DialectCheck { - public boolean isMatch(Dialect dialect) { - return dialect.supportsNotNullUnique(); - } - } - public static class SupportLimitCheck implements DialectCheck { public boolean isMatch(Dialect dialect) { return dialect.supportsLimit();