Search in sources :

Example 1 with JtaPlatformInaccessibleException

use of org.hibernate.resource.transaction.backend.jta.internal.JtaPlatformInaccessibleException in project hibernate-orm by hibernate.

the class InaccessibleJtaPlatformTests method testInaccessibleUserTransactionHandling.

@Test
public void testInaccessibleUserTransactionHandling() {
    // first, have JtaPlatform throw an exception
    try {
        final JtaPlatformInaccessibleImpl jtaPlatform = new JtaPlatformInaccessibleImpl(true);
        final TransactionCoordinator transactionCoordinator = new JtaTransactionCoordinatorImpl(transactionCoordinatorBuilder, owner, true, jtaPlatform, false, false);
        transactionCoordinator.getTransactionDriverControl().begin();
        fail("Expecting JtaPlatformInaccessibleException, but call succeeded");
    } catch (JtaPlatformInaccessibleException expected) {
    // expected condition
    } catch (Exception e) {
        fail("Expecting JtaPlatformInaccessibleException, but got " + e.getClass().getName());
    }
    // then, have it return null
    try {
        final JtaPlatformInaccessibleImpl jtaPlatform = new JtaPlatformInaccessibleImpl(false);
        final TransactionCoordinator transactionCoordinator = new JtaTransactionCoordinatorImpl(transactionCoordinatorBuilder, owner, true, jtaPlatform, false, false);
        transactionCoordinator.getTransactionDriverControl().begin();
        fail("Expecting JtaPlatformInaccessibleException, but call succeeded");
    } catch (JtaPlatformInaccessibleException expected) {
    // expected condition
    } catch (Exception e) {
        fail("Expecting JtaPlatformInaccessibleException, but got " + e.getClass().getName());
    }
}
Also used : JtaPlatformInaccessibleException(org.hibernate.resource.transaction.backend.jta.internal.JtaPlatformInaccessibleException) TransactionCoordinator(org.hibernate.resource.transaction.spi.TransactionCoordinator) JtaTransactionCoordinatorImpl(org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl) JtaPlatformInaccessibleException(org.hibernate.resource.transaction.backend.jta.internal.JtaPlatformInaccessibleException) Test(org.junit.Test)

Example 2 with JtaPlatformInaccessibleException

use of org.hibernate.resource.transaction.backend.jta.internal.JtaPlatformInaccessibleException in project hibernate-orm by hibernate.

the class InaccessibleJtaPlatformTests method testInaccessibleTransactionManagerHandling.

@Test
public void testInaccessibleTransactionManagerHandling() {
    // first, have JtaPlatform throw an exception
    try {
        final JtaPlatformInaccessibleImpl jtaPlatform = new JtaPlatformInaccessibleImpl(true);
        final TransactionCoordinator transactionCoordinator = new JtaTransactionCoordinatorImpl(transactionCoordinatorBuilder, owner, true, jtaPlatform, false, false);
        transactionCoordinator.getTransactionDriverControl().begin();
        fail("Expecting JtaPlatformInaccessibleException, but call succeeded");
    } catch (JtaPlatformInaccessibleException expected) {
    // expected condition
    } catch (Exception e) {
        fail("Expecting JtaPlatformInaccessibleException, but got " + e.getClass().getName());
    }
    // then, have it return null
    try {
        final JtaPlatformInaccessibleImpl jtaPlatform = new JtaPlatformInaccessibleImpl(false);
        final TransactionCoordinator transactionCoordinator = new JtaTransactionCoordinatorImpl(transactionCoordinatorBuilder, owner, true, jtaPlatform, false, false);
        transactionCoordinator.getTransactionDriverControl().begin();
        fail("Expecting JtaPlatformInaccessibleException, but call succeeded");
    } catch (JtaPlatformInaccessibleException expected) {
    // expected condition
    } catch (Exception e) {
        fail("Expecting JtaPlatformInaccessibleException, but got " + e.getClass().getName());
    }
}
Also used : JtaPlatformInaccessibleException(org.hibernate.resource.transaction.backend.jta.internal.JtaPlatformInaccessibleException) TransactionCoordinator(org.hibernate.resource.transaction.spi.TransactionCoordinator) JtaTransactionCoordinatorImpl(org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl) JtaPlatformInaccessibleException(org.hibernate.resource.transaction.backend.jta.internal.JtaPlatformInaccessibleException) Test(org.junit.Test)

Aggregations

JtaPlatformInaccessibleException (org.hibernate.resource.transaction.backend.jta.internal.JtaPlatformInaccessibleException)2 JtaTransactionCoordinatorImpl (org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl)2 TransactionCoordinator (org.hibernate.resource.transaction.spi.TransactionCoordinator)2 Test (org.junit.Test)2