HHH-14249 Add test for issue
This commit is contained in:
parent
74218d84c4
commit
79e6ffe483
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* 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.fileimport;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andrea Boriero
|
||||||
|
*/
|
||||||
|
@TestForIssue(jiraKey = "HHH-14249")
|
||||||
|
public class MultiLineImportWithSpacesAfterTheLastStatementTest {
|
||||||
|
public static final String IMPORT_FILE = "org/hibernate/test/fileimport/multi-line-statements-with-spaces-after-last-delimiter.sql";
|
||||||
|
|
||||||
|
private final MultipleLinesSqlCommandExtractor extractor = new MultipleLinesSqlCommandExtractor();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExtraction() throws Exception {
|
||||||
|
final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
|
||||||
|
|
||||||
|
try (final InputStream stream = classLoader.getResourceAsStream( IMPORT_FILE )) {
|
||||||
|
assertThat( stream, notNullValue() );
|
||||||
|
try (final InputStreamReader reader = new InputStreamReader( stream )) {
|
||||||
|
final String[] commands = extractor.extractCommands( reader );
|
||||||
|
assertThat( commands, notNullValue() );
|
||||||
|
assertThat( commands.length, is( 3 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* 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.fileimport;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andrea Boriero
|
||||||
|
*/
|
||||||
|
@TestForIssue(jiraKey = "HHH-14249")
|
||||||
|
public class MultiLineImportWithTabsAndSpacesTest {
|
||||||
|
public static final String IMPORT_FILE = "org/hibernate/test/fileimport/multi-line-statements-starting-with-tabs-and-spaces.sql";
|
||||||
|
|
||||||
|
private final MultipleLinesSqlCommandExtractor extractor = new MultipleLinesSqlCommandExtractor();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExtraction() throws Exception {
|
||||||
|
final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
|
||||||
|
|
||||||
|
try (final InputStream stream = classLoader.getResourceAsStream( IMPORT_FILE )) {
|
||||||
|
assertThat( stream, notNullValue() );
|
||||||
|
try (final InputStreamReader reader = new InputStreamReader( stream )) {
|
||||||
|
final String[] commands = extractor.extractCommands( reader );
|
||||||
|
assertThat( commands, notNullValue() );
|
||||||
|
assertThat( commands.length, is( 3 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
CREATE TABLE test_data (
|
||||||
|
id NUMBER NOT NULL PRIMARY KEY -- primary key
|
||||||
|
, text VARCHAR2(100) /* any other data */
|
||||||
|
); DELETE
|
||||||
|
FROM test_data;
|
||||||
|
|
||||||
|
INSERT INTO test_data VALUES (1, 'sample');
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
CREATE TABLE test_data (
|
||||||
|
id NUMBER NOT NULL PRIMARY KEY -- primary key
|
||||||
|
, text VARCHAR2(100) /* any other data */
|
||||||
|
); DELETE
|
||||||
|
FROM test_data;
|
||||||
|
|
||||||
|
INSERT INTO test_data VALUES (1, 'sample');
|
Loading…
Reference in New Issue