use of com.google.cloud.spanner.SessionNotFoundException in project java-spanner by googleapis.
the class ITClosedSessionTest method testTransactionManagerNoRecreation.
@Test
public void testTransactionManagerNoRecreation() {
client.setAllowSessionReplacing(false);
client.invalidateNextSession();
try (TransactionManager manager = client.transactionManager()) {
TransactionContext txn = manager.begin();
while (true) {
try (ResultSet rs = txn.executeQuery(Statement.of("SELECT 1"))) {
rs.next();
fail("Expected exception");
}
}
} catch (SessionNotFoundException ex) {
assertNotNull(ex.getMessage());
}
}
use of com.google.cloud.spanner.SessionNotFoundException in project java-spanner by googleapis.
the class ITClosedSessionTest method testReadWriteTransactionNoRecreation.
@Test
public void testReadWriteTransactionNoRecreation() {
client.setAllowSessionReplacing(false);
client.invalidateNextSession();
try {
TransactionRunner txn = client.readWriteTransaction();
txn.run(transaction -> {
try (ResultSet rs = transaction.executeQuery(Statement.of("SELECT 1"))) {
rs.next();
fail("Expected exception");
}
return null;
});
fail("Expected exception");
} catch (SessionNotFoundException ex) {
assertNotNull(ex.getMessage());
}
}
use of com.google.cloud.spanner.SessionNotFoundException in project java-spanner by googleapis.
the class ITClosedSessionTest method testReadOnlyTransactionNoRecreation.
@Test
public void testReadOnlyTransactionNoRecreation() {
client.setAllowSessionReplacing(false);
client.invalidateNextSession();
try (ReadOnlyTransaction txn = client.readOnlyTransaction()) {
try (ResultSet rs = txn.executeQuery(Statement.of("SELECT 1"))) {
rs.next();
fail("Expected exception");
}
fail("Expected exception");
} catch (SessionNotFoundException ex) {
assertNotNull(ex.getMessage());
}
}
use of com.google.cloud.spanner.SessionNotFoundException in project java-spanner by googleapis.
the class ITClosedSessionTest method testSingleUseNoRecreation.
@Test
public void testSingleUseNoRecreation() {
// This should trigger an exception with code NOT_FOUND and the text 'Session not found'.
client.setAllowSessionReplacing(false);
client.invalidateNextSession();
try (ResultSet rs = Statement.of("SELECT 1").executeQuery(client.singleUse())) {
rs.next();
fail("Expected exception");
} catch (SessionNotFoundException ex) {
assertNotNull(ex.getMessage());
}
}
Aggregations