use of com.swiftmq.jms.smqp.v750.CreateSessionRequest in project java-spanner by googleapis.
the class SpannerClientTest method createSessionTest.
@Test
public void createSessionTest() throws Exception {
Session expectedResponse = Session.newBuilder().setName(SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]").toString()).putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).setApproximateLastUseTime(Timestamp.newBuilder().build()).build();
mockSpanner.addResponse(expectedResponse);
DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
Session actualResponse = client.createSession(database);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockSpanner.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateSessionRequest actualRequest = ((CreateSessionRequest) actualRequests.get(0));
Assert.assertEquals(database.toString(), actualRequest.getDatabase());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.swiftmq.jms.smqp.v750.CreateSessionRequest in project java-spanner by googleapis.
the class SpannerClientTest method createSessionTest2.
@Test
public void createSessionTest2() throws Exception {
Session expectedResponse = Session.newBuilder().setName(SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]").toString()).putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).setApproximateLastUseTime(Timestamp.newBuilder().build()).build();
mockSpanner.addResponse(expectedResponse);
String database = "database1789464955";
Session actualResponse = client.createSession(database);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockSpanner.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateSessionRequest actualRequest = ((CreateSessionRequest) actualRequests.get(0));
Assert.assertEquals(database, actualRequest.getDatabase());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.swiftmq.jms.smqp.v750.CreateSessionRequest in project grpc-gcp-java by GoogleCloudPlatform.
the class SpannerLoadTest method createAsyncSessions.
private static List<String> createAsyncSessions(SpannerStub stub) throws InterruptedException {
List<AsyncResponseObserver<Session>> resps = new ArrayList<>();
List<String> respNames = new ArrayList<>();
CreateSessionRequest req = CreateSessionRequest.newBuilder().setDatabase(DATABASE).build();
for (int i = 0; i < MAX_CHANNEL * MAX_STREAM / 2; i++) {
AsyncResponseObserver<Session> resp = new AsyncResponseObserver<Session>();
stub.createSession(req, resp);
resps.add(resp);
}
for (AsyncResponseObserver<Session> resp : resps) {
respNames.add(resp.get().getName());
}
return respNames;
}
use of com.swiftmq.jms.smqp.v750.CreateSessionRequest in project grpc-gcp-java by GoogleCloudPlatform.
the class SpannerIntegrationTest method testUnbindWithInvalidAffinityKey.
@Test
public void testUnbindWithInvalidAffinityKey() {
SpannerBlockingStub stub = getSpannerBlockingStub();
CreateSessionRequest req = CreateSessionRequest.newBuilder().setDatabase(DATABASE_PATH).build();
Session session = stub.createSession(req);
expectedEx.expect(StatusRuntimeException.class);
expectedEx.expectMessage("INVALID_ARGUMENT: Invalid DeleteSession request.");
// No channel bound with the key "invalid_session", will use the least busy one.
stub.deleteSession(DeleteSessionRequest.newBuilder().setName("invalid_session").build());
}
use of com.swiftmq.jms.smqp.v750.CreateSessionRequest in project grpc-gcp-java by GoogleCloudPlatform.
the class SpannerIntegrationTest method createFutureSessions.
private List<String> createFutureSessions(SpannerFutureStub stub) throws Exception {
List<ListenableFuture<Session>> futures = new ArrayList<>();
List<String> futureNames = new ArrayList<>();
assertEquals(ConnectivityState.IDLE, gcpChannel.getState(false));
// Check CreateSession with multiple channels and streams,
CreateSessionRequest req = CreateSessionRequest.newBuilder().setDatabase(DATABASE_PATH).build();
for (int i = 0; i < MAX_CHANNEL * MAX_STREAM; i++) {
ListenableFuture<Session> future = stub.createSession(req);
futures.add(future);
}
checkChannelRefs(MAX_CHANNEL, MAX_STREAM, 0);
for (ListenableFuture<Session> future : futures) {
futureNames.add(future.get().getName());
}
// Since createSession will bind the key, check the number of keys bound with channels.
assertEquals(ConnectivityState.READY, gcpChannel.getState(false));
assertEquals(MAX_CHANNEL * MAX_STREAM, gcpChannel.affinityKeyToChannelRef.size());
checkChannelRefs(MAX_CHANNEL, 0, MAX_STREAM);
return futureNames;
}
Aggregations