Search in sources :

Example 1 with TransactDatabaseLocker

use of org.apache.activemq.store.jdbc.adapter.TransactDatabaseLocker in project activemq-artemis by apache.

the class ConfigTest method testJdbcLockConfigOverride.

@Test
public void testJdbcLockConfigOverride() throws Exception {
    JDBCPersistenceAdapter adapter = new JDBCPersistenceAdapter();
    Mockery context = new Mockery();
    final DataSource dataSource = context.mock(DataSource.class);
    final Connection connection = context.mock(Connection.class);
    final DatabaseMetaData metadata = context.mock(DatabaseMetaData.class);
    final ResultSet result = context.mock(ResultSet.class);
    adapter.setDataSource(dataSource);
    adapter.setCreateTablesOnStartup(false);
    context.checking(new Expectations() {

        {
            allowing(dataSource).getConnection();
            will(returnValue(connection));
            allowing(connection).getMetaData();
            will(returnValue(metadata));
            allowing(connection);
            allowing(metadata).getDriverName();
            will(returnValue("Microsoft_SQL_Server_2005_jdbc_driver"));
            allowing(result).next();
            will(returnValue(true));
        }
    });
    adapter.start();
    assertTrue("has the locker override", adapter.getLocker() instanceof TransactDatabaseLocker);
    adapter.stop();
}
Also used : Expectations(org.jmock.Expectations) JDBCPersistenceAdapter(org.apache.activemq.store.jdbc.JDBCPersistenceAdapter) TransactDatabaseLocker(org.apache.activemq.store.jdbc.adapter.TransactDatabaseLocker) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) DatabaseMetaData(java.sql.DatabaseMetaData) Mockery(org.jmock.Mockery) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Aggregations

Connection (java.sql.Connection)1 DatabaseMetaData (java.sql.DatabaseMetaData)1 ResultSet (java.sql.ResultSet)1 DataSource (javax.sql.DataSource)1 JDBCPersistenceAdapter (org.apache.activemq.store.jdbc.JDBCPersistenceAdapter)1 TransactDatabaseLocker (org.apache.activemq.store.jdbc.adapter.TransactDatabaseLocker)1 Expectations (org.jmock.Expectations)1 Mockery (org.jmock.Mockery)1 Test (org.junit.Test)1