Search in sources :

Example 6 with TransactionParameterBuffer

use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.

the class TestFBTpbMapper method testModifyingClone_doesNotModifyOriginal.

@Test
public void testModifyingClone_doesNotModifyOriginal() throws Exception {
    FBTpbMapper original = new FBTpbMapper();
    FBTpbMapper clone = (FBTpbMapper) original.clone();
    TransactionParameterBuffer newTpb = FBTpbMapper.processMapping("isc_tpb_read_committed,isc_tpb_no_rec_version,isc_tpb_write,isc_tpb_wait");
    clone.setMapping(Connection.TRANSACTION_READ_COMMITTED, newTpb);
    assertNotEquals(original, clone);
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) Test(org.junit.Test)

Example 7 with TransactionParameterBuffer

use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.

the class TestFBTpbMapper method testProcessMappingWithLockTimeout.

@Test
public void testProcessMappingWithLockTimeout() throws Exception {
    String testMapping = "isc_tpb_read_committed,isc_tpb_no_rec_version,isc_tpb_write,isc_tpb_wait,isc_tpb_lock_timeout=5";
    TransactionParameterBuffer tpbValue = FBTpbMapper.processMapping(testMapping);
    assertTrue("must be isc_tpb_read_committed+isc_tpb_no_rec_version+isc_tpb_write+isc_tpb_wait,5", tpbValue.size() == 5 && tpbValue.hasArgument(ISCConstants.isc_tpb_read_committed) && tpbValue.hasArgument(ISCConstants.isc_tpb_no_rec_version) && tpbValue.hasArgument(ISCConstants.isc_tpb_write) && tpbValue.hasArgument(ISCConstants.isc_tpb_wait) && tpbValue.hasArgument(ISCConstants.isc_tpb_lock_timeout) && tpbValue.getArgumentAsInt(ISCConstants.isc_tpb_lock_timeout) == 5);
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) Test(org.junit.Test)

Example 8 with TransactionParameterBuffer

use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.

the class TestFBTpbMapper method testSetMapping_NONE_throwsIllegalArgumentException.

@Test
public void testSetMapping_NONE_throwsIllegalArgumentException() throws Exception {
    FBTpbMapper mapper = new FBTpbMapper();
    TransactionParameterBuffer newTpb = FBTpbMapper.processMapping("isc_tpb_read_committed,isc_tpb_no_rec_version,isc_tpb_write,isc_tpb_wait");
    expectedException.expect(IllegalArgumentException.class);
    mapper.setMapping(Connection.TRANSACTION_NONE, newTpb);
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) Test(org.junit.Test)

Example 9 with TransactionParameterBuffer

use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.

the class TestFBTpbMapper method testSetMapping_updatesMapping.

@Test
public void testSetMapping_updatesMapping() throws Exception {
    FBTpbMapper mapper = new FBTpbMapper();
    TransactionParameterBuffer newReadCommitted = FBTpbMapper.processMapping("isc_tpb_read_committed,isc_tpb_no_rec_version,isc_tpb_write,isc_tpb_wait");
    mapper.setMapping(Connection.TRANSACTION_READ_COMMITTED, newReadCommitted);
    TransactionParameterBuffer newSerializable = FBTpbMapper.processMapping("isc_tpb_consistency,isc_tpb_read,isc_tpb_wait");
    mapper.setMapping(Connection.TRANSACTION_SERIALIZABLE, newSerializable);
    TransactionParameterBuffer newRepeatableRead = FBTpbMapper.processMapping("isc_tpb_concurrency,isc_tpb_write,isc_tpb_nowait");
    mapper.setMapping(Connection.TRANSACTION_REPEATABLE_READ, newRepeatableRead);
    assertEquals(newReadCommitted, mapper.getMapping(Connection.TRANSACTION_READ_COMMITTED));
    assertEquals(newSerializable, mapper.getMapping(Connection.TRANSACTION_SERIALIZABLE));
    assertEquals(newRepeatableRead, mapper.getMapping(Connection.TRANSACTION_REPEATABLE_READ));
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) Test(org.junit.Test)

Example 10 with TransactionParameterBuffer

use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.

the class TestFBTpbMapper method testProcessMappingToConnectionProperties.

@Test
public void testProcessMappingToConnectionProperties() throws Exception {
    final Properties props = new Properties();
    props.setProperty(FBTpbMapper.TRANSACTION_READ_COMMITTED, "isc_tpb_read_committed,isc_tpb_no_rec_version,isc_tpb_write,isc_tpb_wait");
    props.setProperty(FBTpbMapper.TRANSACTION_SERIALIZABLE, "isc_tpb_consistency,isc_tpb_read,isc_tpb_wait");
    props.setProperty(FBTpbMapper.TRANSACTION_REPEATABLE_READ, "isc_tpb_concurrency,isc_tpb_write,isc_tpb_nowait");
    props.setProperty("not_a_transaction_isolation_level", "some_value");
    FBConnectionProperties connectionProps = new FBConnectionProperties();
    assertNull("TRANSACTION_READ_COMMITTED should not have a TPB before processing", connectionProps.getTransactionParameters(Connection.TRANSACTION_READ_COMMITTED));
    assertNull("TRANSACTION_SERIALIZABLE should not have a TPB before processing", connectionProps.getTransactionParameters(Connection.TRANSACTION_SERIALIZABLE));
    assertNull("TRANSACTION_REPEATABLE_READ should not have a TPB before processing", connectionProps.getTransactionParameters(Connection.TRANSACTION_REPEATABLE_READ));
    FBTpbMapper.processMapping(connectionProps, props);
    TransactionParameterBuffer tpbReadCommitted = connectionProps.getTransactionParameters(Connection.TRANSACTION_READ_COMMITTED);
    assertTrue("READ_COMMITTED must be isc_tpb_read_committed+isc_tpb_no_rec_version+isc_tpb_write+isc_tpb_wait", tpbReadCommitted.size() == 4 && tpbReadCommitted.hasArgument(ISCConstants.isc_tpb_read_committed) && tpbReadCommitted.hasArgument(ISCConstants.isc_tpb_no_rec_version) && tpbReadCommitted.hasArgument(ISCConstants.isc_tpb_write) && tpbReadCommitted.hasArgument(ISCConstants.isc_tpb_wait));
    TransactionParameterBuffer tpbRepeatableRead = connectionProps.getTransactionParameters(Connection.TRANSACTION_REPEATABLE_READ);
    assertTrue("REPEATABLE_READ must be isc_tpb_consistency+isc_tpb_write+isc_tpb_nowait", tpbRepeatableRead.size() == 3 && tpbRepeatableRead.hasArgument(ISCConstants.isc_tpb_concurrency) && tpbRepeatableRead.hasArgument(ISCConstants.isc_tpb_write) && tpbRepeatableRead.hasArgument(ISCConstants.isc_tpb_nowait));
    TransactionParameterBuffer tpbSerializable = connectionProps.getTransactionParameters(Connection.TRANSACTION_SERIALIZABLE);
    assertTrue("SERIALIZABLE must be isc_tpb_concurrency+isc_tpb_read+isc_tpb_wait", tpbSerializable.size() == 3 && tpbSerializable.hasArgument(ISCConstants.isc_tpb_consistency) && tpbSerializable.hasArgument(ISCConstants.isc_tpb_read) && tpbSerializable.hasArgument(ISCConstants.isc_tpb_wait));
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

TransactionParameterBuffer (org.firebirdsql.gds.TransactionParameterBuffer)25 Test (org.junit.Test)12 TransactionParameterBufferImpl (org.firebirdsql.gds.impl.TransactionParameterBufferImpl)8 Properties (java.util.Properties)3 HashMap (java.util.HashMap)2 FBTestProperties (org.firebirdsql.common.FBTestProperties)2 FBResourceException (org.firebirdsql.jca.FBResourceException)2 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 FbDatabase (org.firebirdsql.gds.ng.FbDatabase)1 FbTransaction (org.firebirdsql.gds.ng.FbTransaction)1 FBManagedConnection (org.firebirdsql.jca.FBManagedConnection)1 FBConnection (org.firebirdsql.jdbc.FBConnection)1