From 58e4c675d3f2a137c97b57d06d659b4c9b6a5c67 Mon Sep 17 00:00:00 2001 From: Etienne Miret Date: Sun, 8 Feb 2015 22:43:24 +0100 Subject: [PATCH] HHH-9247 Add test for parsing named-attribute-nodes in orm.xml. --- .../test/annotations/entityGraph/Author.java | 76 +++++++++++++++++++ .../test/annotations/entityGraph/Book.java | 75 ++++++++++++++++++ .../entityGraph/OrmXmlParseTest.java | 46 +++++++++++ .../annotations/entityGraph/package-info.java | 29 +++++++ .../test/annotations/entityGraph/orm.xml | 43 +++++++++++ 5 files changed, 269 insertions(+) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/Author.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/Book.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/OrmXmlParseTest.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/package-info.java create mode 100644 hibernate-core/src/test/resources/org/hibernate/test/annotations/entityGraph/orm.xml diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/Author.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/Author.java new file mode 100644 index 0000000000..15d5507ce6 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/Author.java @@ -0,0 +1,76 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2015, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * 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, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY 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 + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + +package org.hibernate.test.annotations.entityGraph; + +import java.util.Date; +import java.util.Set; + + +/** + * @author Etienne Miret + */ +public class Author { + + private Long id; + + private String name; + + private Date birth; + + private Set books; + + public Author() { + super(); + } + + public Long getId() { + return id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Date getBirth() { + return birth; + } + + public void setBirth(Date birth) { + this.birth = birth; + } + + public Set getBooks() { + return books; + } + + public void setBooks(Set books) { + this.books = books; + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/Book.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/Book.java new file mode 100644 index 0000000000..aec9593481 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/Book.java @@ -0,0 +1,75 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2015, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * 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, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY 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 + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + +package org.hibernate.test.annotations.entityGraph; + +import java.util.Set; + + +/** + * @author Etienne Miret + */ +public class Book { + + private Long id; + + private String isbn; + + private String title; + + private Set authors; + + public Book() { + super(); + } + + public Long getId() { + return id; + } + + public String getIsbn() { + return isbn; + } + + public void setIsbn(String isbn) { + this.isbn = isbn; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Set getAuthors() { + return authors; + } + + public void setAuthors(Set authors) { + this.authors = authors; + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/OrmXmlParseTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/OrmXmlParseTest.java new file mode 100644 index 0000000000..eb1f980375 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/OrmXmlParseTest.java @@ -0,0 +1,46 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2015, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * 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, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY 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 + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + +package org.hibernate.test.annotations.entityGraph; + +import org.hibernate.cfg.Configuration; +import org.hibernate.internal.util.ConfigHelper; +import org.hibernate.testing.TestForIssue; +import org.junit.Test; + + +/** + * @author Etienne Miret + */ +public class OrmXmlParseTest { + + @Test + @TestForIssue( jiraKey = "HHH-9247" ) + public void parseNamedAttributeNode() { + final Configuration cfg = new Configuration(); + cfg.addURL( ConfigHelper.findAsResource( "org/hibernate/test/annotations/entityGraph/orm.xml" ) ); + cfg.buildMappings(); + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/package-info.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/package-info.java new file mode 100644 index 0000000000..b87ccd7e83 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/entityGraph/package-info.java @@ -0,0 +1,29 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2015, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * 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, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY 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 + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + +/** + * This package groups tests about the JPA 2.1 Entity Graph feature. + * See section 3.7 from the JPA 2.1 specification. + */ +package org.hibernate.test.annotations.entityGraph; diff --git a/hibernate-core/src/test/resources/org/hibernate/test/annotations/entityGraph/orm.xml b/hibernate-core/src/test/resources/org/hibernate/test/annotations/entityGraph/orm.xml new file mode 100644 index 0000000000..6cd4d1e226 --- /dev/null +++ b/hibernate-core/src/test/resources/org/hibernate/test/annotations/entityGraph/orm.xml @@ -0,0 +1,43 @@ + + org.hibernate.test.annotations.entityGraph + FIELD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +