Search in sources :

Example 16 with DatabaseConnection

use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.

the class DatabaseConnectionCase method testConnectWithNullProperties.

@Test
public void testConnectWithNullProperties() throws Exception {
    DatabaseConnection con = configure(createConnection());
    con.setConnectionProperties(null);
    LifecycleHelper.init(con);
    LifecycleHelper.start(con);
    con.connect();
}
Also used : DatabaseConnection(com.adaptris.core.jdbc.DatabaseConnection) Test(org.junit.Test)

Example 17 with DatabaseConnection

use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.

the class DatabaseConnectionCase method testConnectWithoutDebugMode.

@Test
public void testConnectWithoutDebugMode() throws Exception {
    DatabaseConnection conn = configure(createConnection());
    conn.setDebugMode(false);
    LifecycleHelper.init(conn);
    conn.connect();
}
Also used : DatabaseConnection(com.adaptris.core.jdbc.DatabaseConnection) Test(org.junit.Test)

Example 18 with DatabaseConnection

use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.

the class DatabaseConnectionCase method testConnectionDataSource.

@Test
public void testConnectionDataSource() throws Exception {
    DatabaseConnection con = configure(createConnection());
    try {
        LifecycleHelper.init(con);
        LifecycleHelper.start(con);
        assertNotNull(con.asDataSource());
        assertNotNull(con.asDataSource().getConnection());
    } finally {
        LifecycleHelper.stop(con);
        LifecycleHelper.close(con);
    }
}
Also used : DatabaseConnection(com.adaptris.core.jdbc.DatabaseConnection) Test(org.junit.Test)

Example 19 with DatabaseConnection

use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.

the class DatabaseConnectionCase method testSetConnectionAttempts.

@Test
public void testSetConnectionAttempts() throws Exception {
    DatabaseConnection con = createConnection();
    assertNull(con.getConnectionAttempts());
    assertEquals(-1, con.connectionAttempts());
    con.setConnectionAttempts(Integer.valueOf(1));
    assertEquals(Integer.valueOf(1), con.getConnectionAttempts());
    assertEquals(1, con.connectionAttempts());
    con.setConnectionAttempts(null);
    assertNull(con.getConnectionAttempts());
    assertEquals(-1, con.connectionAttempts());
}
Also used : DatabaseConnection(com.adaptris.core.jdbc.DatabaseConnection) Test(org.junit.Test)

Example 20 with DatabaseConnection

use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.

the class DatabaseConnectionCase method testConnectionWhenNotInitialised.

@Test
public void testConnectionWhenNotInitialised() throws Exception {
    DatabaseConnection con = configure(createConnection());
    try {
        con.connect();
        fail("Expected failure as not initialised");
    } catch (Exception e) {
        // Expected
        ;
    }
}
Also used : DatabaseConnection(com.adaptris.core.jdbc.DatabaseConnection) Test(org.junit.Test)

Aggregations

DatabaseConnection (com.adaptris.core.jdbc.DatabaseConnection)20 Test (org.junit.Test)20 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)3 AdvancedJdbcPooledConnection (com.adaptris.core.jdbc.AdvancedJdbcPooledConnection)3 JdbcConnection (com.adaptris.core.jdbc.JdbcConnection)3 JdbcPooledConnection (com.adaptris.core.jdbc.JdbcPooledConnection)3 Connection (java.sql.Connection)3 NullService (com.adaptris.core.NullService)2 ServiceException (com.adaptris.core.ServiceException)2 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)1 TimeInterval (com.adaptris.util.TimeInterval)1