use of nl.topicus.jdbc.CloudSpannerXADataSource in project spanner-jdbc by olavloite.
the class CloudSpannerXADataSourceTest method testGetConnection.
@Test
public void testGetConnection() throws SQLException {
CloudSpannerXADataSource subject = new CloudSpannerXADataSource();
CloudSpannerDataSourceTest.setCommonDataSourceTestProperties(subject);
subject.setCreateXATable(false);
CloudSpannerXAConnection connection = subject.getXAConnection();
assertNotNull(connection);
assertNotNull(subject.getDescription());
Connection con = connection.getConnection();
Assert.assertTrue(con.isWrapperFor(CloudSpannerConnection.class));
CloudSpannerConnection cloudSpannerConnection = con.unwrap(CloudSpannerConnection.class);
CloudSpannerDataSourceTest.testCommonDataSourceTestProperties(cloudSpannerConnection);
}
use of nl.topicus.jdbc.CloudSpannerXADataSource in project spanner-jdbc by olavloite.
the class XATester method testXA.
public void testXA(String projectId, String instanceId, String database, String pvtKeyPath) throws SQLException {
log.info("Starting XA tests");
int originalLogLevel = CloudSpannerDriver.getLogLevel();
CloudSpannerDriver.setLogLevel(CloudSpannerDriver.DEBUG);
CloudSpannerXADataSource ds = new CloudSpannerXADataSource();
ds.setProjectId(projectId);
ds.setInstanceId(instanceId);
ds.setDatabase(database);
ds.setPvtKeyPath(pvtKeyPath);
ds.setAllowExtendedMode(true);
try (CloudSpannerXAConnection xaConnection = ds.getXAConnection()) {
testXATransaction(xaConnection, CommitMode.TwoPhase);
testXARollback(xaConnection);
deleteTestRow(xaConnection);
testXARecover(xaConnection);
deleteTestRow(xaConnection);
} catch (Exception e) {
throw new CloudSpannerSQLException("Exception occurred during XA tests", Code.INTERNAL, e);
} finally {
CloudSpannerDriver.setLogLevel(originalLogLevel);
}
log.info("Finished XA tests");
}
use of nl.topicus.jdbc.CloudSpannerXADataSource in project spanner-jdbc by olavloite.
the class CloudSpannerXADataSourceTest method testGetConnectionWithUserNameAndPassword.
@Test
public void testGetConnectionWithUserNameAndPassword() throws SQLException {
CloudSpannerXADataSource subject = new CloudSpannerXADataSource();
CloudSpannerDataSourceTest.setCommonDataSourceTestProperties(subject);
subject.setCreateXATable(false);
CloudSpannerXAConnection connection = subject.getXAConnection("test", "test");
assertNotNull(connection);
Connection con = connection.getConnection();
Assert.assertTrue(con.isWrapperFor(CloudSpannerConnection.class));
CloudSpannerConnection cloudSpannerConnection = con.unwrap(CloudSpannerConnection.class);
CloudSpannerDataSourceTest.testCommonDataSourceTestProperties(cloudSpannerConnection);
}
Aggregations