diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/Dog.hbm.xml b/hibernate-core/src/matrix/java/org/hibernate/test/importfile/Dog.hbm.xml deleted file mode 100644 index c42ef4c611..0000000000 --- a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/Dog.hbm.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/Human.hbm.xml b/hibernate-core/src/matrix/java/org/hibernate/test/importfile/Human.hbm.xml deleted file mode 100644 index d57bfed83f..0000000000 --- a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/Human.hbm.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/CommandExtractorServiceTest.java b/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java similarity index 92% rename from hibernate-core/src/matrix/java/org/hibernate/test/importfile/CommandExtractorServiceTest.java rename to hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java index e3ee9d7351..516b659e86 100644 --- a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/CommandExtractorServiceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.test.importfile; +package org.hibernate.test.fileimport; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; @@ -37,7 +37,7 @@ import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor; public class CommandExtractorServiceTest extends MultiLineImportFileTest { @Override public void configure(Configuration cfg) { - cfg.setProperty( Environment.HBM2DDL_IMPORT_FILES, "/multiline-stmt.sql" ); + cfg.setProperty( Environment.HBM2DDL_IMPORT_FILES, "/org/hibernate/test/fileimport/multi-line-statements.sql" ); } @Override diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/Dog.java b/hibernate-core/src/test/java/org/hibernate/test/fileimport/Dog.java similarity index 88% rename from hibernate-core/src/matrix/java/org/hibernate/test/importfile/Dog.java rename to hibernate-core/src/test/java/org/hibernate/test/fileimport/Dog.java index 0d501d2f79..b5c738dbc5 100644 --- a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/Dog.java +++ b/hibernate-core/src/test/java/org/hibernate/test/fileimport/Dog.java @@ -1,4 +1,4 @@ -package org.hibernate.test.importfile; +package org.hibernate.test.fileimport; /** diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/Human.java b/hibernate-core/src/test/java/org/hibernate/test/fileimport/Human.java similarity index 92% rename from hibernate-core/src/matrix/java/org/hibernate/test/importfile/Human.java rename to hibernate-core/src/test/java/org/hibernate/test/fileimport/Human.java index f64d2b6ccc..5e9dd35555 100644 --- a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/Human.java +++ b/hibernate-core/src/test/java/org/hibernate/test/fileimport/Human.java @@ -1,4 +1,4 @@ -package org.hibernate.test.importfile; +package org.hibernate.test.fileimport; /** diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/MultiLineImportFileTest.java b/hibernate-core/src/test/java/org/hibernate/test/fileimport/MultiLineImportFileTest.java similarity index 66% rename from hibernate-core/src/matrix/java/org/hibernate/test/importfile/MultiLineImportFileTest.java rename to hibernate-core/src/test/java/org/hibernate/test/fileimport/MultiLineImportFileTest.java index 8d3179b5a1..9907a864b0 100644 --- a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/MultiLineImportFileTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/fileimport/MultiLineImportFileTest.java @@ -21,20 +21,21 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.test.importfile; +package org.hibernate.test.fileimport; import java.math.BigInteger; +import org.junit.Test; + import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; -import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor; - -import org.junit.Test; - +import org.hibernate.dialect.H2Dialect; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -42,16 +43,23 @@ import static org.junit.Assert.assertNull; /** * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) */ -@TestForIssue( jiraKey = "HHH-2403" ) +@TestForIssue(jiraKey = "HHH-2403") +@RequiresDialect(value = H2Dialect.class, + jiraKey = "HHH-6286", + comment = "Only running the tests against H2, because the sql statements in the import file are not generic. " + + "This test should actually not test directly against the db") public class MultiLineImportFileTest extends BaseCoreFunctionalTestCase { @Override public void configure(Configuration cfg) { - cfg.setProperty( Environment.HBM2DDL_IMPORT_FILES, "/multiline-stmt.sql" ); - cfg.setProperty( Environment.HBM2DDL_IMPORT_FILES_SQL_EXTRACTOR, MultipleLinesSqlCommandExtractor.class.getName() ); + cfg.setProperty( Environment.HBM2DDL_IMPORT_FILES, "/org/hibernate/test/fileimport/multi-line-statements.sql" ); + cfg.setProperty( + Environment.HBM2DDL_IMPORT_FILES_SQL_EXTRACTOR, + MultipleLinesSqlCommandExtractor.class.getName() + ); } @Override - public String[] getMappings() { + public String[] getMappings() { return NO_MAPPINGS; } @@ -61,12 +69,13 @@ public class MultiLineImportFileTest extends BaseCoreFunctionalTestCase { final Transaction tx = s.beginTransaction(); BigInteger count = (BigInteger) s.createSQLQuery( "SELECT COUNT(*) FROM test_data" ).uniqueResult(); - assertEquals( "incorrect row number", 3L, count.longValue() ); + assertEquals( "Incorrect row number", 3L, count.longValue() ); - final String multilineText = (String) s.createSQLQuery( "SELECT text FROM test_data WHERE id = 2" ).uniqueResult(); - // "Multiline comment line 1\r\n-- line 2'\r\n/* line 3 */" - final String expected = String.format( "Multiline comment line 1%n-- line 2'%n/* line 3 */" ); - assertEquals( "multiline string inserted incorrectly", expected, multilineText ); + final String multiLineText = (String) s.createSQLQuery( "SELECT text FROM test_data WHERE id = 2" ) + .uniqueResult(); + // "Multi-line comment line 1\r\n-- line 2'\r\n/* line 3 */" + final String expected = String.format( "Multi-line comment line 1%n-- line 2'%n/* line 3 */" ); + assertEquals( "Multi-line string inserted incorrectly", expected, multiLineText ); String empty = (String) s.createSQLQuery( "SELECT text FROM test_data WHERE id = 3" ).uniqueResult(); assertNull( "NULL value inserted incorrectly", empty ); diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/SingleLineImportFileTest.java b/hibernate-core/src/test/java/org/hibernate/test/fileimport/SingleLineImportFileTest.java similarity index 85% rename from hibernate-core/src/matrix/java/org/hibernate/test/importfile/SingleLineImportFileTest.java rename to hibernate-core/src/test/java/org/hibernate/test/fileimport/SingleLineImportFileTest.java index b149031869..24e74cd424 100644 --- a/hibernate-core/src/matrix/java/org/hibernate/test/importfile/SingleLineImportFileTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/fileimport/SingleLineImportFileTest.java @@ -21,7 +21,8 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.test.importfile; +package org.hibernate.test.fileimport; + import java.util.List; import org.junit.Test; @@ -40,30 +41,33 @@ import static org.junit.Assert.assertEquals; public class SingleLineImportFileTest extends BaseCoreFunctionalTestCase { @Override public void configure(Configuration cfg) { - cfg.setProperty( Environment.HBM2DDL_IMPORT_FILES, "/humans.sql,/dogs.sql" ); + cfg.setProperty( + Environment.HBM2DDL_IMPORT_FILES, + "/org/hibernate/test/fileimport/humans.sql,/org/hibernate/test/fileimport/dogs.sql" + ); } @Override public String[] getMappings() { return new String[] { - "importfile/Human.hbm.xml", - "importfile/Dog.hbm.xml" + "fileimport/Human.hbm.xml", + "fileimport/Dog.hbm.xml" }; } @Test public void testImportFile() throws Exception { - Session s = openSession( ); + Session s = openSession(); final Transaction tx = s.beginTransaction(); final List humans = s.createQuery( "from " + Human.class.getName() ).list(); assertEquals( "humans.sql not imported", 3, humans.size() ); final List dogs = s.createQuery( "from " + Dog.class.getName() ).list(); assertEquals( "dogs.sql not imported", 3, dogs.size() ); - for (Object entity : dogs) { + for ( Object entity : dogs ) { s.delete( entity ); } - for (Object entity : humans) { + for ( Object entity : humans ) { s.delete( entity ); } tx.commit(); diff --git a/hibernate-core/src/test/resources/org/hibernate/test/fileimport/Dog.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/test/fileimport/Dog.hbm.xml new file mode 100644 index 0000000000..b2ba686464 --- /dev/null +++ b/hibernate-core/src/test/resources/org/hibernate/test/fileimport/Dog.hbm.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/hibernate-core/src/test/resources/org/hibernate/test/fileimport/Human.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/test/fileimport/Human.hbm.xml new file mode 100644 index 0000000000..ee23d38e33 --- /dev/null +++ b/hibernate-core/src/test/resources/org/hibernate/test/fileimport/Human.hbm.xml @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/hibernate-core/src/test/resources/dogs.sql b/hibernate-core/src/test/resources/org/hibernate/test/fileimport/dogs.sql similarity index 100% rename from hibernate-core/src/test/resources/dogs.sql rename to hibernate-core/src/test/resources/org/hibernate/test/fileimport/dogs.sql diff --git a/hibernate-core/src/test/resources/humans.sql b/hibernate-core/src/test/resources/org/hibernate/test/fileimport/humans.sql similarity index 100% rename from hibernate-core/src/test/resources/humans.sql rename to hibernate-core/src/test/resources/org/hibernate/test/fileimport/humans.sql diff --git a/hibernate-core/src/test/resources/multiline-stmt.sql b/hibernate-core/src/test/resources/org/hibernate/test/fileimport/multi-line-statements.sql similarity index 92% rename from hibernate-core/src/test/resources/multiline-stmt.sql rename to hibernate-core/src/test/resources/org/hibernate/test/fileimport/multi-line-statements.sql index 94bf179c93..6587b2887b 100644 --- a/hibernate-core/src/test/resources/multiline-stmt.sql +++ b/hibernate-core/src/test/resources/org/hibernate/test/fileimport/multi-line-statements.sql @@ -14,7 +14,7 @@ DELETE /* * Data insertion... */ -INSERT INTO test_data VALUES (2, 'Multiline comment line 1 +INSERT INTO test_data VALUES (2, 'Multi-line comment line 1 -- line 2'' /* line 3 */');