Re-enabled additional tests

This commit is contained in:
Andrea Boriero 2020-06-17 16:45:17 +01:00
parent 567b6cc076
commit 79e5203897
19 changed files with 113 additions and 205 deletions

View File

@ -0,0 +1,46 @@
package org.hibernate.orm.test.annotations.embeddables.collection;
import org.hibernate.AnnotationException;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Andrea Boriero
*/
public abstract class AbstractEmbeddableWithManyToManyTest {
@Test
public void test() {
try {
BootstrapServiceRegistryBuilder bootstrapServiceRegistryBuilder = new BootstrapServiceRegistryBuilder();
final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder(
bootstrapServiceRegistryBuilder.build() );
StandardServiceRegistry ssr = ssrb.build();
MetadataSources metadataSources = new MetadataSources( ssr );
addResources( metadataSources );
addAnnotatedClasses(metadataSources);
metadataSources.buildMetadata();
fail( "Should throw AnnotationException!" );
}
catch (AnnotationException expected) {
assertTrue( expected.getMessage().startsWith(
"@OneToMany, @ManyToMany or @ElementCollection cannot be used inside an @Embeddable that is also contained within an @ElementCollection"
) );
}
}
protected void addAnnotatedClasses(MetadataSources metadataSources){
}
protected void addResources(MetadataSources metadataSources){
}
}

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.collection;
package org.hibernate.orm.test.annotations.embeddables.collection;
import java.io.Serializable;
import java.util.ArrayList;
@ -25,48 +25,20 @@ import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Version;
import org.hibernate.AnnotationException;
import org.hibernate.boot.MetadataSources;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Vlad Mihalcea
*/
@TestForIssue(jiraKey = "HHH-11302")
public class EmbeddableWithManyToMany_HHH_11302_Test
extends BaseCoreFunctionalTestCase {
extends AbstractEmbeddableWithManyToManyTest {
// Add your entities here.
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
ContactType.class,
Person.class
};
}
protected void buildSessionFactory() {
try {
super.buildSessionFactory();
fail( "Should throw AnnotationException!" );
}
catch ( AnnotationException expected ) {
assertTrue( expected.getMessage().startsWith(
"@OneToMany, @ManyToMany or @ElementCollection cannot be used inside an @Embeddable that is also contained within an @ElementCollection"
) );
}
finally {
serviceRegistry().destroy();
}
}
@Test
public void test() {
protected void addAnnotatedClasses(MetadataSources metadataSources) {
metadataSources.addAnnotatedClasses( ContactType.class, Person.class );
}
@Entity

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.collection;
package org.hibernate.orm.test.annotations.embeddables.collection;
import java.io.Serializable;
import java.util.ArrayList;
@ -25,48 +25,20 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
import org.hibernate.AnnotationException;
import org.hibernate.boot.MetadataSources;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Vlad Mihalcea
*/
@TestForIssue(jiraKey = "HHH-11302")
public class EmbeddableWithOneToMany_HHH_11302_Test
extends BaseCoreFunctionalTestCase {
extends AbstractEmbeddableWithManyToManyTest {
// Add your entities here.
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
ContactType.class,
Person.class
};
}
protected void buildSessionFactory() {
try {
super.buildSessionFactory();
fail( "Should throw AnnotationException!" );
}
catch ( AnnotationException expected ) {
assertTrue( expected.getMessage().startsWith(
"@OneToMany, @ManyToMany or @ElementCollection cannot be used inside an @Embeddable that is also contained within an @ElementCollection"
) );
}
finally {
serviceRegistry().destroy();
}
}
@Test
public void test() {
protected void addAnnotatedClasses(MetadataSources metadataSources) {
metadataSources.addAnnotatedClasses( ContactType.class, Person.class );
}
@Entity

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.collection;
package org.hibernate.orm.test.annotations.embeddables.collection;
import java.io.Serializable;
import java.util.Set;
@ -21,47 +21,20 @@ import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import org.hibernate.AnnotationException;
import org.hibernate.boot.MetadataSources;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Vlad Mihalcea
*/
@TestForIssue(jiraKey = "HHH-8564")
public class EmbeddableWithOneToMany_HHH_8564_Test
extends BaseCoreFunctionalTestCase {
extends AbstractEmbeddableWithManyToManyTest {
// Add your entities here.
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
User.class,
};
}
protected void buildSessionFactory() {
try {
super.buildSessionFactory();
fail( "Should throw AnnotationException!" );
}
catch ( AnnotationException expected ) {
assertTrue( expected.getMessage().startsWith(
"@OneToMany, @ManyToMany or @ElementCollection cannot be used inside an @Embeddable that is also contained within an @ElementCollection"
) );
}
finally {
serviceRegistry().destroy();
}
}
@Test
public void test() {
protected void addAnnotatedClasses(MetadataSources metadataSources) {
metadataSources.addAnnotatedClasses( User.class );
}
@Embeddable
@ -89,7 +62,7 @@ public class EmbeddableWithOneToMany_HHH_8564_Test
}
public static enum AddressType {
public enum AddressType {
OFFICE, HOME, BILLING

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.collection;
package org.hibernate.orm.test.annotations.embeddables.collection;
import java.util.LinkedList;
import java.util.List;
@ -19,47 +19,20 @@ import javax.persistence.MapKeyColumn;
import javax.persistence.OneToMany;
import javax.persistence.Version;
import org.hibernate.AnnotationException;
import org.hibernate.boot.MetadataSources;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Vlad Mihalcea
*/
@TestForIssue(jiraKey = "HHH-8860")
public class EmbeddableWithOneToMany_HHH_8860_Test
extends BaseCoreFunctionalTestCase {
extends AbstractEmbeddableWithManyToManyTest {
// Add your entities here.
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
Data.class,
};
}
protected void buildSessionFactory() {
try {
super.buildSessionFactory();
fail( "Should throw AnnotationException!" );
}
catch ( AnnotationException expected ) {
assertTrue( expected.getMessage().startsWith(
"@OneToMany, @ManyToMany or @ElementCollection cannot be used inside an @Embeddable that is also contained within an @ElementCollection"
) );
}
finally {
serviceRegistry().destroy();
}
}
@Test
public void test() {
protected void addAnnotatedClasses(MetadataSources metadataSources) {
metadataSources.addAnnotatedClasses( Data.class );
}
@Entity(name = "Data")

View File

@ -1,4 +1,4 @@
package org.hibernate.test.annotations.embeddables.collection.xml;
package org.hibernate.orm.test.annotations.embeddables.collection.xml;
import java.io.Serializable;
import java.util.ArrayList;

View File

@ -1,4 +1,4 @@
package org.hibernate.test.annotations.embeddables.collection.xml;
package org.hibernate.orm.test.annotations.embeddables.collection.xml;
import java.io.Serializable;

View File

@ -0,0 +1,24 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.orm.test.annotations.embeddables.collection.xml;
import org.hibernate.boot.MetadataSources;
import org.hibernate.orm.test.annotations.embeddables.collection.AbstractEmbeddableWithManyToManyTest;
import org.hibernate.testing.TestForIssue;
/**
* @author Vlad Mihalcea
*/
@TestForIssue(jiraKey = "HHH-11302")
public class EmbeddableWithOneToMany_HHH_11302_xml_Test extends AbstractEmbeddableWithManyToManyTest {
protected void addResources(MetadataSources metadataSources) {
metadataSources.addResource( "org/hibernate/orm/test/annotations/embeddables/collection/orm.xml" );
}
}

View File

@ -1,4 +1,4 @@
package org.hibernate.test.annotations.embeddables.collection.xml;
package org.hibernate.orm.test.annotations.embeddables.collection.xml;
import java.io.Serializable;
import java.util.List;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.nested;
package org.hibernate.orm.test.annotations.embeddables.nested;
import java.util.ArrayList;
import java.util.List;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.nested;
package org.hibernate.orm.test.annotations.embeddables.nested;
import java.util.Date;
import javax.persistence.Column;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.nested;
package org.hibernate.orm.test.annotations.embeddables.nested;
import java.math.BigDecimal;
import javax.persistence.Column;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.nested;
package org.hibernate.orm.test.annotations.embeddables.nested;
import java.sql.Types;
@ -22,16 +22,16 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Value;
import org.hibernate.type.CustomType;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.hibernate.testing.junit4.ExtraAssertions.assertJdbcTypeCode;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Steve Ebersole
*/
public class NestedEmbeddableMetadataTest extends BaseUnitTestCase {
public class NestedEmbeddableMetadataTest {
@Test
public void testEnumTypeInterpretation() {
final StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.nested.fieldaccess;
package org.hibernate.orm.test.annotations.embeddables.nested.fieldaccess;
import java.util.ArrayList;
import java.util.List;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.nested.fieldaccess;
package org.hibernate.orm.test.annotations.embeddables.nested.fieldaccess;
import java.sql.Types;
@ -21,19 +21,19 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Value;
import org.hibernate.type.CustomType;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test;
import org.hibernate.testing.orm.junit.FailureExpected;
import org.junit.jupiter.api.Test;
import static org.hibernate.testing.junit4.ExtraAssertions.assertJdbcTypeCode;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Steve Ebersole
*/
public class FieldAccessedNestedEmbeddableMetadataTest extends BaseUnitTestCase {
public class FieldAccessedNestedEmbeddableMetadataTest {
@Test
@FailureExpected( jiraKey = "HHH-9089" )
@FailureExpected(jiraKey = "HHH-9089")
public void testEnumTypeInterpretation() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.nested.fieldaccess;
package org.hibernate.orm.test.annotations.embeddables.nested.fieldaccess;
import java.util.Date;
import javax.persistence.Column;

View File

@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.nested.fieldaccess;
package org.hibernate.orm.test.annotations.embeddables.nested.fieldaccess;
import java.math.BigDecimal;
import javax.persistence.Column;

View File

@ -1,52 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.annotations.embeddables.collection.xml;
import java.util.Map;
import org.hibernate.AnnotationException;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.TestForIssue;
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Vlad Mihalcea
*/
@TestForIssue(jiraKey = "HHH-11302")
public class EmbeddableWithOneToMany_HHH_11302_xml_Test extends
BaseEntityManagerFunctionalTestCase {
@Override
public String[] getEjb3DD() {
return new String[] {
"org/hibernate/test/annotations/embeddables/collection/orm.xml"
};
}
public void buildEntityManagerFactory() {
try {
super.buildEntityManagerFactory();
fail( "Should throw AnnotationException!" );
}
catch ( AnnotationException expected ) {
assertTrue( expected.getMessage().startsWith(
"@OneToMany, @ManyToMany or @ElementCollection cannot be used inside an @Embeddable that is also contained within an @ElementCollection"
) );
}
}
@Test
public void test() {
}
}

View File

@ -9,7 +9,7 @@
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0">
<package>org.hibernate.test.annotations.embeddables.collection.xml</package>
<package>org.hibernate.orm.test.annotations.embeddables.collection.xml</package>
<entity class="Person">
<attributes>
<id name="id">