Search in sources :

Example 1 with Startable

use of org.hibernate.service.spi.Startable in project hibernate-orm by hibernate.

the class BaseTransactionIsolationConfigTest method testSettingIsolationAsName.

@Test
public void testSettingIsolationAsName() throws Exception {
    Properties properties = Environment.getProperties();
    augmentConfigurationSettings(properties);
    properties.put(AvailableSettings.ISOLATION, "TRANSACTION_SERIALIZABLE");
    ConnectionProvider provider = getConnectionProviderUnderTest();
    try {
        ((Configurable) provider).configure(properties);
        if (Startable.class.isInstance(provider)) {
            ((Startable) provider).start();
        }
        Connection connection = provider.getConnection();
        assertEquals(Connection.TRANSACTION_SERIALIZABLE, connection.getTransactionIsolation());
        provider.closeConnection(connection);
    } finally {
        ((Stoppable) provider).stop();
    }
}
Also used : Startable(org.hibernate.service.spi.Startable) Connection(java.sql.Connection) Stoppable(org.hibernate.service.spi.Stoppable) Configurable(org.hibernate.service.spi.Configurable) Properties(java.util.Properties) ConnectionProvider(org.hibernate.engine.jdbc.connections.spi.ConnectionProvider) Test(org.junit.Test)

Example 2 with Startable

use of org.hibernate.service.spi.Startable in project hibernate-orm by hibernate.

the class BaseTransactionIsolationConfigTest method testSettingIsolationAsNameAlt.

@Test
public void testSettingIsolationAsNameAlt() throws Exception {
    Properties properties = Environment.getProperties();
    augmentConfigurationSettings(properties);
    properties.put(AvailableSettings.ISOLATION, "SERIALIZABLE");
    ConnectionProvider provider = getConnectionProviderUnderTest();
    try {
        ((Configurable) provider).configure(properties);
        if (Startable.class.isInstance(provider)) {
            ((Startable) provider).start();
        }
        Connection connection = provider.getConnection();
        assertEquals(Connection.TRANSACTION_SERIALIZABLE, connection.getTransactionIsolation());
        provider.closeConnection(connection);
    } finally {
        ((Stoppable) provider).stop();
    }
}
Also used : Startable(org.hibernate.service.spi.Startable) Connection(java.sql.Connection) Stoppable(org.hibernate.service.spi.Stoppable) Configurable(org.hibernate.service.spi.Configurable) Properties(java.util.Properties) ConnectionProvider(org.hibernate.engine.jdbc.connections.spi.ConnectionProvider) Test(org.junit.Test)

Example 3 with Startable

use of org.hibernate.service.spi.Startable in project hibernate-orm by hibernate.

the class BaseTransactionIsolationConfigTest method testSettingIsolationAsNumericString.

@Test
public void testSettingIsolationAsNumericString() throws Exception {
    Properties properties = Environment.getProperties();
    augmentConfigurationSettings(properties);
    properties.put(AvailableSettings.ISOLATION, Integer.toString(Connection.TRANSACTION_SERIALIZABLE));
    ConnectionProvider provider = getConnectionProviderUnderTest();
    try {
        ((Configurable) provider).configure(properties);
        if (Startable.class.isInstance(provider)) {
            ((Startable) provider).start();
        }
        Connection connection = provider.getConnection();
        assertEquals(Connection.TRANSACTION_SERIALIZABLE, connection.getTransactionIsolation());
        provider.closeConnection(connection);
    } finally {
        ((Stoppable) provider).stop();
    }
}
Also used : Startable(org.hibernate.service.spi.Startable) Connection(java.sql.Connection) Stoppable(org.hibernate.service.spi.Stoppable) Configurable(org.hibernate.service.spi.Configurable) Properties(java.util.Properties) ConnectionProvider(org.hibernate.engine.jdbc.connections.spi.ConnectionProvider) Test(org.junit.Test)

Example 4 with Startable

use of org.hibernate.service.spi.Startable in project hibernate-orm by hibernate.

the class BaseTransactionIsolationConfigTest method testSettingIsolationAsNumeric.

@Test
public void testSettingIsolationAsNumeric() throws Exception {
    Properties properties = Environment.getProperties();
    augmentConfigurationSettings(properties);
    properties.put(AvailableSettings.ISOLATION, Connection.TRANSACTION_SERIALIZABLE);
    ConnectionProvider provider = getConnectionProviderUnderTest();
    try {
        ((Configurable) provider).configure(properties);
        if (Startable.class.isInstance(provider)) {
            ((Startable) provider).start();
        }
        Connection connection = provider.getConnection();
        assertEquals(Connection.TRANSACTION_SERIALIZABLE, connection.getTransactionIsolation());
        provider.closeConnection(connection);
    } finally {
        ((Stoppable) provider).stop();
    }
}
Also used : Startable(org.hibernate.service.spi.Startable) Connection(java.sql.Connection) Stoppable(org.hibernate.service.spi.Stoppable) Configurable(org.hibernate.service.spi.Configurable) Properties(java.util.Properties) ConnectionProvider(org.hibernate.engine.jdbc.connections.spi.ConnectionProvider) Test(org.junit.Test)

Aggregations

Connection (java.sql.Connection)4 Properties (java.util.Properties)4 ConnectionProvider (org.hibernate.engine.jdbc.connections.spi.ConnectionProvider)4 Configurable (org.hibernate.service.spi.Configurable)4 Startable (org.hibernate.service.spi.Startable)4 Stoppable (org.hibernate.service.spi.Stoppable)4 Test (org.junit.Test)4