use of com.google.cloud.spanner.InstanceNotFoundException in project java-spanner by googleapis.
the class ITDatabaseTest method instanceNotFound.
@Test
public void instanceNotFound() {
InstanceId testId = env.getTestHelper().getInstanceId();
InstanceId nonExistingInstanceId = InstanceId.of(testId.getProject(), testId.getInstance() + "-na");
DatabaseClient client = env.getTestHelper().getClient().getDatabaseClient(DatabaseId.of(nonExistingInstanceId, "some-db"));
try (ResultSet rs = client.singleUse().executeQuery(Statement.of("SELECT 1"))) {
rs.next();
fail("missing expected exception");
} catch (InstanceNotFoundException e) {
assertThat(e.getResourceName()).isEqualTo(nonExistingInstanceId.getName());
}
}
Aggregations