use of com.google.cloud.spanner.MockSpannerServiceImpl in project java-spanner by googleapis.
the class LocalConnectionCheckerTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
mockSpanner = new MockSpannerServiceImpl();
// We don't want any unpredictable aborted transactions.
mockSpanner.setAbortProbability(0.0D);
final InetSocketAddress address = new InetSocketAddress("localhost", 0);
server = NettyServerBuilder.forAddress(address).addService(mockSpanner).build();
server.start();
}
use of com.google.cloud.spanner.MockSpannerServiceImpl in project java-spanner by googleapis.
the class GfeLatencyTest method startServer.
@BeforeClass
public static void startServer() throws IOException {
SpannerRpcViews.registerGfeLatencyAndHeaderMissingCountViews();
assumeFalse(EmulatorSpannerHelper.isUsingEmulator());
mockSpanner = new MockSpannerServiceImpl();
// We don't want any unpredictable aborted transactions.
mockSpanner.setAbortProbability(0.0D);
mockSpanner.putStatementResult(MockSpannerServiceImpl.StatementResult.query(SELECT1AND2, SELECT1_RESULTSET));
mockSpanner.putStatementResult(MockSpannerServiceImpl.StatementResult.update(UPDATE_FOO_STATEMENT, 1L));
address = new InetSocketAddress("localhost", 0);
server = NettyServerBuilder.forAddress(address).addService(mockSpanner).intercept(new ServerInterceptor() {
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> serverCall, Metadata headers, ServerCallHandler<ReqT, RespT> serverCallHandler) {
return serverCallHandler.startCall(new ForwardingServerCall.SimpleForwardingServerCall<ReqT, RespT>(serverCall) {
@Override
public void sendHeaders(Metadata headers) {
headers.put(Metadata.Key.of("server-timing", Metadata.ASCII_STRING_MARSHALLER), String.format("gfet4t7; dur=%d", fakeServerTiming.get()));
super.sendHeaders(headers);
}
}, headers);
}
}).build().start();
optionsMap.put(SpannerRpc.Option.CHANNEL_HINT, 1L);
spanner = createSpannerOptions(address, server).getService();
databaseClient = spanner.getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId));
mockSpannerNoHeader = new MockSpannerServiceImpl();
mockSpannerNoHeader.setAbortProbability(0.0D);
mockSpannerNoHeader.putStatementResult(MockSpannerServiceImpl.StatementResult.query(SELECT1AND2, SELECT1_RESULTSET));
mockSpannerNoHeader.putStatementResult(MockSpannerServiceImpl.StatementResult.update(UPDATE_FOO_STATEMENT, 1L));
addressNoHeader = new InetSocketAddress("localhost", 0);
serverNoHeader = NettyServerBuilder.forAddress(addressNoHeader).addService(mockSpannerNoHeader).build().start();
spannerNoHeader = createSpannerOptions(addressNoHeader, serverNoHeader).getService();
databaseClientNoHeader = spannerNoHeader.getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId));
}
use of com.google.cloud.spanner.MockSpannerServiceImpl in project beam by apache.
the class SpannerChangeStreamErrorTest method setUp.
@Before
public void setUp() throws Exception {
mockSpannerService = new MockSpannerServiceImpl();
serviceHelper = new MockServiceHelper(SPANNER_HOST, Collections.singletonList(mockSpannerService));
serviceHelper.start();
serviceHelper.reset();
}
use of com.google.cloud.spanner.MockSpannerServiceImpl in project java-spanner-jdbc by googleapis.
the class JdbcDatabaseMetaDataWithMockedServerTest method startStaticServer.
@BeforeClass
public static void startStaticServer() throws IOException {
mockSpanner = new MockSpannerServiceImpl();
// We don't want any unpredictable aborted transactions.
mockSpanner.setAbortProbability(0.0D);
InetSocketAddress address = new InetSocketAddress("localhost", 0);
server = NettyServerBuilder.forAddress(address).addService(mockSpanner).build().start();
}
use of com.google.cloud.spanner.MockSpannerServiceImpl in project java-spanner-jdbc by googleapis.
the class JdbcDriverTest method startStaticServer.
@BeforeClass
public static void startStaticServer() throws IOException {
MockSpannerServiceImpl mockSpanner = new MockSpannerServiceImpl();
InetSocketAddress address = new InetSocketAddress("localhost", 0);
server = NettyServerBuilder.forAddress(address).addService(mockSpanner).build().start();
}
Aggregations