HHH-7797 initial test case

This commit is contained in:
brmeyer 2012-12-11 15:21:35 -05:00 committed by Brett Meyer
parent 7254d465ae
commit fa09bc2866
3 changed files with 66 additions and 12 deletions

View File

@ -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 <bernhardt.manuel@gmail.com>
@ -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();

View File

@ -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;
}
}

View File

@ -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();