use of com.google.cloud.spanner.v1.SpannerSettings in project java-spanner by googleapis.
the class RetryOnInvalidatedSessionTest method startStaticServer.
@BeforeClass
public static void startStaticServer() throws IOException {
mockSpanner = new MockSpannerServiceImpl();
// We don't want any unpredictable aborted transactions.
mockSpanner.setAbortProbability(0.0D);
mockSpanner.putStatementResult(StatementResult.read("FOO", KeySet.all(), Collections.singletonList("BAR"), READ_RESULTSET));
mockSpanner.putStatementResult(StatementResult.read("FOO", KeySet.singleKey(Key.of()), Collections.singletonList("BAR"), READ_ROW_RESULTSET));
mockSpanner.putStatementResult(StatementResult.query(SELECT1AND2, SELECT1_RESULTSET));
mockSpanner.putStatementResult(StatementResult.update(UPDATE_STATEMENT, UPDATE_COUNT));
String uniqueName = InProcessServerBuilder.generateName();
server = InProcessServerBuilder.forName(uniqueName).directExecutor().addService(mockSpanner).build().start();
channelProvider = LocalChannelProvider.create(uniqueName);
SpannerSettings settings = SpannerSettings.newBuilder().setTransportChannelProvider(channelProvider).setCredentialsProvider(NoCredentialsProvider.create()).build();
spannerClient = SpannerClient.create(settings);
executor = Executors.newSingleThreadExecutor();
}
use of com.google.cloud.spanner.v1.SpannerSettings in project java-spanner by googleapis.
the class TransactionManagerAbortedTest method startStaticServer.
@BeforeClass
public static void startStaticServer() throws IOException {
mockSpanner = new MockSpannerServiceImpl();
// We don't want any unpredictable aborted transactions.
mockSpanner.setAbortProbability(0.0D);
mockSpanner.putStatementResult(StatementResult.read("FOO", KeySet.all(), Collections.singletonList("BAR"), READ_RESULTSET));
mockSpanner.putStatementResult(StatementResult.read("FOO", KeySet.singleKey(Key.of()), Collections.singletonList("BAR"), READ_ROW_RESULTSET));
mockSpanner.putStatementResult(StatementResult.query(SELECT1AND2, SELECT1AND2_RESULTSET));
mockSpanner.putStatementResult(StatementResult.update(UPDATE_STATEMENT, UPDATE_COUNT));
mockSpanner.putStatementResult(StatementResult.exception(UPDATE_ABORTED_STATEMENT, mockSpanner.createAbortedException(ByteString.copyFromUtf8("test"))));
String uniqueName = InProcessServerBuilder.generateName();
server = InProcessServerBuilder.forName(uniqueName).scheduledExecutorService(new ScheduledThreadPoolExecutor(1)).addService(mockSpanner).build().start();
channelProvider = LocalChannelProvider.create(uniqueName);
SpannerSettings settings = SpannerSettings.newBuilder().setTransportChannelProvider(channelProvider).setCredentialsProvider(NoCredentialsProvider.create()).build();
spannerClient = SpannerClient.create(settings);
}
Aggregations