src/test/java/org/embulk/output/oracle/OracleOutputPluginTest.java in embulk-output-oracle-0.6.5 vs src/test/java/org/embulk/output/oracle/OracleOutputPluginTest.java in embulk-output-oracle-0.7.0

- old
+ new

@@ -1,7 +1,8 @@ package org.embulk.output.oracle; +import static java.util.Locale.ENGLISH; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import java.io.File; import java.lang.reflect.Constructor; @@ -23,24 +24,21 @@ import org.embulk.input.filesplit.LocalFileSplitInputPlugin; import org.embulk.output.AbstractJdbcOutputPluginTest; import org.embulk.output.OracleOutputPlugin; import org.embulk.spi.InputPlugin; import org.embulk.spi.OutputPlugin; -import org.junit.BeforeClass; import org.junit.Test; public class OracleOutputPluginTest extends AbstractJdbcOutputPluginTest { - static { + @Override + protected void prepare() throws SQLException + { tester.addPlugin(OutputPlugin.class, "oracle", OracleOutputPlugin.class); tester.addPlugin(InputPlugin.class, "filesplit", LocalFileSplitInputPlugin.class); - } - @BeforeClass - public static void beforeClass() throws Exception - { if (System.getProperty("path.separator").equals(";")) { // for Windows System.setProperty("file.encoding", "MS932"); } @@ -49,18 +47,19 @@ } catch (ClassNotFoundException | NoClassDefFoundError e) { System.err.println("Warning: you should put 'ojdbc7.jar' in 'embulk-input-oracle/driver' directory in order to test."); return; } - try (Connection connection = new OracleOutputPluginTest().connect()) { + try (Connection connection = connect()) { String version = connection.getMetaData().getDriverVersion(); System.out.println("Driver version = " + version); enabled = true; } catch (SQLException e) { System.err.println(e); - System.err.println("Warning: prepare a schema on Oracle 12c (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw', charset = UTF-8)."); + System.err.println(String.format(ENGLISH, "Warning: prepare a schema on Oracle 12c (server = %s, port = %d, database = %s, user = %s, password = %s, charset = UTF-8).", + getHost(), getPort(), getDatabase(), getUser(), getPassword())); // for example // CREATE USER EMBULK_USER IDENTIFIED BY "embulk_pw"; // GRANT DBA TO EMBULK_USER; } } @@ -690,9 +689,10 @@ } @Override protected Connection connect() throws SQLException { - return DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:TESTDB", "TEST_USER", "test_pw"); + return DriverManager.getConnection(String.format(ENGLISH, "jdbc:oracle:thin:@%s:%d:%s", getHost(), getPort(), getDatabase()), + getUser(), getPassword()); } }