Search in sources :

Example 1 with SpannerReadOptions

use of org.springframework.cloud.gcp.data.spanner.core.SpannerReadOptions in project spring-cloud-gcp by spring-cloud.

the class SpannerTemplateIntegrationTests method readOnlyTransactionTest.

@Test
public void readOnlyTransactionTest() {
    this.expectedEx.expect(SpannerDataException.class);
    this.expectedEx.expectMessage("A read-only transaction template cannot perform mutations.");
    Trade trade = Trade.aTrade();
    this.spannerOperations.performReadOnlyTransaction((transactionOperations) -> {
        // cannot do mutate in a read-only transaction
        transactionOperations.insert(trade);
        return null;
    }, new SpannerReadOptions());
}
Also used : Trade(org.springframework.cloud.gcp.data.spanner.test.domain.Trade) SpannerReadOptions(org.springframework.cloud.gcp.data.spanner.core.SpannerReadOptions) Test(org.junit.Test) AbstractSpannerIntegrationTest(org.springframework.cloud.gcp.data.spanner.test.AbstractSpannerIntegrationTest)

Aggregations

Test (org.junit.Test)1 SpannerReadOptions (org.springframework.cloud.gcp.data.spanner.core.SpannerReadOptions)1 AbstractSpannerIntegrationTest (org.springframework.cloud.gcp.data.spanner.test.AbstractSpannerIntegrationTest)1 Trade (org.springframework.cloud.gcp.data.spanner.test.domain.Trade)1