use of javax.sql.DataSource in project databus by linkedin.
the class TestOracleJarUtils method testCreateOracleDataSource.
@Test
public void testCreateOracleDataSource() throws Exception {
// Invoke the method more than once in the same process
DataSource ds1 = OracleJarUtils.createOracleDataSource("jdbc:oracle:thin:person/person@devdb:1521:db");
DataSource ds2 = OracleJarUtils.createOracleDataSource("jdbc:oracle:thin:person/person@devdb:1521:db");
// Should create a new object each time, and be invocable as many times as desired
boolean isEqual = ds1.equals(ds2);
Assert.assertEquals(isEqual, false);
boolean isIdentical = (ds1 == ds2);
Assert.assertEquals(isIdentical, false);
}
use of javax.sql.DataSource in project mybatis-3 by mybatis.
the class ScriptRunnerTest method shouldReturnWarningIfNotTheCurrentDelimiterUsed.
@Test
public void shouldReturnWarningIfNotTheCurrentDelimiterUsed() throws Exception {
DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
Connection conn = ds.getConnection();
ScriptRunner runner = new ScriptRunner(conn);
runner.setAutoCommit(false);
runner.setStopOnError(true);
runner.setErrorLogWriter(null);
runner.setLogWriter(null);
String resource = "org/apache/ibatis/jdbc/ScriptChangingDelimiterMissingDelimiter.sql";
Reader reader = Resources.getResourceAsReader(resource);
try {
runner.runScript(reader);
fail("Expected script runner to fail due to the usage of invalid delimiter.");
} catch (Exception e) {
assertTrue(e.getMessage().contains("end-of-line terminator"));
}
}
use of javax.sql.DataSource in project mybatis-3 by mybatis.
the class ScriptRunnerTest method shouldRunScriptsUsingConnection.
@Test
public void shouldRunScriptsUsingConnection() throws Exception {
DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
Connection conn = ds.getConnection();
ScriptRunner runner = new ScriptRunner(conn);
runner.setAutoCommit(true);
runner.setStopOnError(false);
runner.setErrorLogWriter(null);
runner.setLogWriter(null);
runJPetStoreScripts(runner);
assertProductsTableExistsAndLoaded();
}
use of javax.sql.DataSource in project mybatis-3 by mybatis.
the class ScriptRunnerTest method shouldRunScriptsBySendingFullScriptAtOnce.
@Test
@Ignore("This fails with HSQLDB 2.0 due to the create index statements in the schema script")
public void shouldRunScriptsBySendingFullScriptAtOnce() throws Exception {
DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
Connection conn = ds.getConnection();
ScriptRunner runner = new ScriptRunner(conn);
runner.setSendFullScript(true);
runner.setAutoCommit(true);
runner.setStopOnError(false);
runner.setErrorLogWriter(null);
runner.setLogWriter(null);
runJPetStoreScripts(runner);
assertProductsTableExistsAndLoaded();
}
use of javax.sql.DataSource in project mybatis-3 by mybatis.
the class ScriptRunnerTest method testLogging.
@Test
public void testLogging() throws Exception {
DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
Connection conn = ds.getConnection();
ScriptRunner runner = new ScriptRunner(conn);
runner.setAutoCommit(true);
runner.setStopOnError(false);
runner.setErrorLogWriter(null);
runner.setSendFullScript(false);
StringWriter sw = new StringWriter();
PrintWriter logWriter = new PrintWriter(sw);
runner.setLogWriter(logWriter);
Reader reader = new StringReader("select userid from account where userid = 'j2ee';");
runner.runScript(reader);
assertEquals("select userid from account where userid = 'j2ee'" + System.getProperty("line.separator") + System.getProperty("line.separator") + "USERID\t" + System.getProperty("line.separator") + "j2ee\t" + System.getProperty("line.separator"), sw.toString());
}
Aggregations