Search in sources :

Example 1 with MockInstanceAdminImpl

use of com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl in project java-spanner by googleapis.

the class InstanceAdminGaxTest method startStaticServer.

@BeforeClass
public static void startStaticServer() throws IOException {
    mockInstanceAdmin = new MockInstanceAdminImpl();
    String uniqueName = InProcessServerBuilder.generateName();
    server = InProcessServerBuilder.forName(uniqueName).scheduledExecutorService(new ScheduledThreadPoolExecutor(1)).addService(mockInstanceAdmin).build().start();
    channelProvider = LocalChannelProvider.create(uniqueName);
}
Also used : ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) MockInstanceAdminImpl(com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl) BeforeClass(org.junit.BeforeClass)

Example 2 with MockInstanceAdminImpl

use of com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl in project java-spanner-jdbc by googleapis.

the class JdbcAbortedTransactionTest 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.query(SELECT1, SELECT1_RESULTSET));
    mockSpanner.putStatementResult(StatementResult.update(UPDATE_STATEMENT, UPDATE_COUNT));
    MockInstanceAdminImpl mockInstanceAdmin = new MockInstanceAdminImpl();
    MockDatabaseAdminImpl mockDatabaseAdmin = new MockDatabaseAdminImpl();
    InetSocketAddress address = new InetSocketAddress("localhost", 0);
    server = NettyServerBuilder.forAddress(address).addService(mockSpanner).addService(mockInstanceAdmin).addService(mockDatabaseAdmin).build().start();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) MockDatabaseAdminImpl(com.google.cloud.spanner.admin.database.v1.MockDatabaseAdminImpl) MockInstanceAdminImpl(com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl) MockSpannerServiceImpl(com.google.cloud.spanner.MockSpannerServiceImpl) BeforeClass(org.junit.BeforeClass)

Example 3 with MockInstanceAdminImpl

use of com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl in project java-spanner-jdbc by googleapis.

the class JdbcGrpcErrorTest 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.query(SELECT1, SELECT1_RESULTSET));
    mockSpanner.putStatementResult(StatementResult.update(UPDATE_STATEMENT, UPDATE_COUNT));
    mockSpanner.putStatementResult(StatementResult.exception(INVALID_UPDATE_STATEMENT, Status.NOT_FOUND.withDescription("Unknown table name").asRuntimeException()));
    MockInstanceAdminImpl mockInstanceAdmin = new MockInstanceAdminImpl();
    MockDatabaseAdminImpl mockDatabaseAdmin = new MockDatabaseAdminImpl();
    InetSocketAddress address = new InetSocketAddress("localhost", 0);
    server = NettyServerBuilder.forAddress(address).addService(mockSpanner).addService(mockInstanceAdmin).addService(mockDatabaseAdmin).build().start();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) MockDatabaseAdminImpl(com.google.cloud.spanner.admin.database.v1.MockDatabaseAdminImpl) MockInstanceAdminImpl(com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl) MockSpannerServiceImpl(com.google.cloud.spanner.MockSpannerServiceImpl) BeforeClass(org.junit.BeforeClass)

Example 4 with MockInstanceAdminImpl

use of com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl in project java-spanner by googleapis.

the class SpannerThreadsTest method startServer.

@BeforeClass
public static void startServer() throws IOException {
    assumeTrue("Skip tests when emulator is enabled as this test interferes with the check whether the emulator is running", System.getenv("SPANNER_EMULATOR_HOST") == null);
    mockSpanner = new MockSpannerServiceImpl();
    // We don't want any unpredictable aborted transactions.
    mockSpanner.setAbortProbability(0.0D);
    mockSpanner.putStatementResult(StatementResult.query(SELECT1AND2, SELECT1_RESULTSET));
    mockInstanceAdmin = new MockInstanceAdminImpl();
    mockDatabaseAdmin = new MockDatabaseAdminImpl();
    address = new InetSocketAddress("localhost", 0);
    server = NettyServerBuilder.forAddress(address).addService(mockSpanner).addService(mockInstanceAdmin).addService(mockDatabaseAdmin).build().start();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) MockDatabaseAdminImpl(com.google.cloud.spanner.admin.database.v1.MockDatabaseAdminImpl) MockInstanceAdminImpl(com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl) BeforeClass(org.junit.BeforeClass)

Example 5 with MockInstanceAdminImpl

use of com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl in project java-spanner by googleapis.

the class AbstractMockServerTest method startStaticServer.

@BeforeClass
public static void startStaticServer() throws IOException {
    mockSpanner = new MockSpannerServiceImpl();
    // We don't want any unpredictable aborted transactions.
    mockSpanner.setAbortProbability(0.0D);
    mockInstanceAdmin = new MockInstanceAdminImpl();
    mockDatabaseAdmin = new MockDatabaseAdminImpl();
    mockOperations = new OperationsImplBase() {

        @Override
        public void getOperation(GetOperationRequest request, StreamObserver<Operation> responseObserver) {
            responseObserver.onNext(Operation.newBuilder().setDone(false).setName(request.getName()).setMetadata(Any.pack(Empty.getDefaultInstance())).build());
            responseObserver.onCompleted();
        }
    };
    address = new InetSocketAddress("localhost", 0);
    server = NettyServerBuilder.forAddress(address).addService(mockSpanner).addService(mockInstanceAdmin).addService(mockDatabaseAdmin).addService(mockOperations).build().start();
    mockSpanner.putStatementResult(StatementResult.query(SELECT_COUNT_STATEMENT, SELECT_COUNT_RESULTSET_BEFORE_INSERT));
    mockSpanner.putStatementResult(StatementResult.update(INSERT_STATEMENT, UPDATE_COUNT));
    mockSpanner.putStatementResult(StatementResult.query(SELECT_RANDOM_STATEMENT, RANDOM_RESULT_SET));
    futureParentHandlers = Logger.getLogger(AbstractFuture.class.getName()).getUseParentHandlers();
    exceptionRunnableParentHandlers = Logger.getLogger(LogExceptionRunnable.class.getName()).getUseParentHandlers();
    nettyServerParentHandlers = Logger.getLogger("io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler").getUseParentHandlers();
    clientStreamParentHandlers = Logger.getLogger("io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler").getUseParentHandlers();
    Logger.getLogger(AbstractFuture.class.getName()).setUseParentHandlers(false);
    Logger.getLogger(LogExceptionRunnable.class.getName()).setUseParentHandlers(false);
    Logger.getLogger("io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler").setUseParentHandlers(false);
    Logger.getLogger("io.grpc.internal.AbstractClientStream").setUseParentHandlers(false);
}
Also used : LogExceptionRunnable(io.grpc.internal.LogExceptionRunnable) GetOperationRequest(com.google.longrunning.GetOperationRequest) InetSocketAddress(java.net.InetSocketAddress) MockDatabaseAdminImpl(com.google.cloud.spanner.admin.database.v1.MockDatabaseAdminImpl) MockInstanceAdminImpl(com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl) Operation(com.google.longrunning.Operation) OperationsImplBase(com.google.longrunning.OperationsGrpc.OperationsImplBase) MockSpannerServiceImpl(com.google.cloud.spanner.MockSpannerServiceImpl) AbstractFuture(com.google.common.util.concurrent.AbstractFuture) BeforeClass(org.junit.BeforeClass)

Aggregations

MockInstanceAdminImpl (com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl)5 BeforeClass (org.junit.BeforeClass)5 MockDatabaseAdminImpl (com.google.cloud.spanner.admin.database.v1.MockDatabaseAdminImpl)4 InetSocketAddress (java.net.InetSocketAddress)4 MockSpannerServiceImpl (com.google.cloud.spanner.MockSpannerServiceImpl)3 AbstractFuture (com.google.common.util.concurrent.AbstractFuture)1 GetOperationRequest (com.google.longrunning.GetOperationRequest)1 Operation (com.google.longrunning.Operation)1 OperationsImplBase (com.google.longrunning.OperationsGrpc.OperationsImplBase)1 LogExceptionRunnable (io.grpc.internal.LogExceptionRunnable)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1