Skip to content

Commit

Permalink
remove public modifiers.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhumin8 committed May 10, 2024
1 parent fda5e7c commit 2cca11c
Show file tree
Hide file tree
Showing 18 changed files with 133 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void sendMessage(ReqT message) {
private EchoClient httpJsonClientWithRetries;

@BeforeEach
public void createClients() throws Exception {
void createClients() throws Exception {
RetrySettings defaultRetrySettings =
RetrySettings.newBuilder()
.setInitialRpcTimeout(Duration.ofMillis(5000L))
Expand Down Expand Up @@ -157,14 +157,14 @@ public void createClients() throws Exception {
}

@AfterEach
public void destroyClient() {
void destroyClient() {
grpcClientWithoutRetries.close();
grpcClientWithRetries.close();
httpJsonClient.close();
}

@Test
public void testGrpc_autoPopulateRequestIdWhenAttemptedOnceSuccessfully() {
void testGrpc_autoPopulateRequestIdWhenAttemptedOnceSuccessfully() {
List<String> capturedRequestIds = new ArrayList<>();
grpcRequestInterceptor.setOnRequestIntercepted(
request -> {
Expand All @@ -181,7 +181,7 @@ public void testGrpc_autoPopulateRequestIdWhenAttemptedOnceSuccessfully() {
}

@Test
public void testGrpc_shouldNotAutoPopulateRequestIdIfSetInRequest() {
void testGrpc_shouldNotAutoPopulateRequestIdIfSetInRequest() {
List<String> capturedRequestIds = new ArrayList<>();
grpcRequestInterceptor.setOnRequestIntercepted(
request -> {
Expand All @@ -197,7 +197,7 @@ public void testGrpc_shouldNotAutoPopulateRequestIdIfSetInRequest() {
}

@Test
public void testHttpJson_autoPopulateRequestIdWhenAttemptedOnceSuccessfully() {
void testHttpJson_autoPopulateRequestIdWhenAttemptedOnceSuccessfully() {
List<String> capturedRequestIds = new ArrayList<>();
httpJsonInterceptor.setOnRequestIntercepted(
request -> {
Expand All @@ -214,7 +214,7 @@ public void testHttpJson_autoPopulateRequestIdWhenAttemptedOnceSuccessfully() {
}

@Test
public void testHttpJson_shouldNotAutoPopulateRequestIdIfSetInRequest() {
void testHttpJson_shouldNotAutoPopulateRequestIdIfSetInRequest() {
String UUIDsent = UUID.randomUUID().toString();
List<String> capturedRequestIds = new ArrayList<>();
httpJsonInterceptor.setOnRequestIntercepted(
Expand All @@ -230,7 +230,7 @@ public void testHttpJson_shouldNotAutoPopulateRequestIdIfSetInRequest() {
}

@Test
public void testGRPC_setsSameRequestIdIfSetInRequestWhenRequestsAreRetried() throws Exception {
void testGRPC_setsSameRequestIdIfSetInRequestWhenRequestsAreRetried() throws Exception {
List<String> capturedRequestIds = new ArrayList<>();
grpcRequestInterceptor.setOnRequestIntercepted(
request -> {
Expand Down Expand Up @@ -264,7 +264,7 @@ public void testGRPC_setsSameRequestIdIfSetInRequestWhenRequestsAreRetried() thr
}

@Test
public void testGRPC_setsSameAutoPopulatedRequestIdWhenRequestsAreRetried() throws Exception {
void testGRPC_setsSameAutoPopulatedRequestIdWhenRequestsAreRetried() throws Exception {
List<String> capturedRequestIds = new ArrayList<>();
grpcRequestInterceptor.setOnRequestIntercepted(
request -> {
Expand Down Expand Up @@ -302,8 +302,7 @@ public void testGRPC_setsSameAutoPopulatedRequestIdWhenRequestsAreRetried() thro
}

@Test
public void testHttpJson_setsSameRequestIdIfSetInRequestWhenRequestsAreRetried()
throws Exception {
void testHttpJson_setsSameRequestIdIfSetInRequestWhenRequestsAreRetried() throws Exception {
List<String> capturedRequestIds = new ArrayList<>();
httpJsonInterceptor.setOnRequestIntercepted(
request -> {
Expand Down Expand Up @@ -336,7 +335,7 @@ public void testHttpJson_setsSameRequestIdIfSetInRequestWhenRequestsAreRetried()
}

@Test
public void testHttpJson_setsSameAutoPopulatedRequestIdWhenRequestsAreRetried() throws Exception {
void testHttpJson_setsSameAutoPopulatedRequestIdWhenRequestsAreRetried() throws Exception {
List<String> capturedRequestIds = new ArrayList<>();
httpJsonInterceptor.setOnRequestIntercepted(
request -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class ITBidiStreaming {
private static EchoClient grpcClient;

@BeforeAll
public static void createClients() throws Exception {
static void createClients() throws Exception {
// Create gRPC Echo Client
grpcClient = TestClientInitializer.createGrpcEchoClient();
}

@AfterAll
public static void destroyClients() throws Exception {
static void destroyClients() throws Exception {
grpcClient.close();
grpcClient.awaitTermination(TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS);
}
Expand All @@ -57,7 +57,7 @@ public static void destroyClients() throws Exception {
// three requests, respond twice for every request etc. If that happens, the response content may
// not be exactly the same as request content.
@Test
public void testGrpc_splitCall_shouldListensToResponse() throws Exception {
void testGrpc_splitCall_shouldListensToResponse() throws Exception {
// given
List<String> expected = Arrays.asList("The rain in Spain stays mainly on the plain".split(" "));
TestResponseObserver responseObserver = new TestResponseObserver();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ class ITClientShutdown {
// Test to ensure the client can close + terminate properly
@Test
@Timeout(15)
public void testGrpc_closeClient() throws Exception {
void testGrpc_closeClient() throws Exception {
EchoClient grpcClient = TestClientInitializer.createGrpcEchoClient();
assertClientTerminated(grpcClient);
}

// Test to ensure the client can close + terminate properly
@Test
@Timeout(15)
public void testHttpJson_closeClient() throws Exception {
void testHttpJson_closeClient() throws Exception {
EchoClient httpjsonClient = TestClientInitializer.createHttpJsonEchoClient();
assertClientTerminated(httpjsonClient);
}

// Test to ensure the client can close + terminate after a quick RPC invocation
@Test
@Timeout(15)
public void testGrpc_rpcInvoked_closeClient() throws Exception {
void testGrpc_rpcInvoked_closeClient() throws Exception {
EchoClient grpcClient = TestClientInitializer.createGrpcEchoClient();
// Response is ignored for this test
grpcClient.echo(EchoRequest.newBuilder().setContent("Test").build());
Expand All @@ -62,7 +62,7 @@ public void testGrpc_rpcInvoked_closeClient() throws Exception {
// Test to ensure the client can close + terminate after a quick RPC invocation
@Test
@Timeout(15)
public void testHttpJson_rpcInvoked_closeClient() throws Exception {
void testHttpJson_rpcInvoked_closeClient() throws Exception {
EchoClient httpjsonClient = TestClientInitializer.createHttpJsonEchoClient();
// Response is ignored for this test
httpjsonClient.echo(EchoRequest.newBuilder().setContent("Test").build());
Expand All @@ -74,8 +74,7 @@ public void testHttpJson_rpcInvoked_closeClient() throws Exception {
// the test does not continue on forever.
@Test
@Timeout(15)
public void testGrpc_rpcInvokedWithLargeTimeout_closeClientOnceResponseReceived()
throws Exception {
void testGrpc_rpcInvokedWithLargeTimeout_closeClientOnceResponseReceived() throws Exception {
// Set the maxAttempts to 1 to ensure there are no retries scheduled. The single RPC
// invocation should time out in 15s, but the client will receive a response in 2s.
// Any outstanding tasks (timeout tasks) should be cancelled once a response has been
Expand Down Expand Up @@ -108,8 +107,7 @@ public void testGrpc_rpcInvokedWithLargeTimeout_closeClientOnceResponseReceived(
// the test does not continue on forever.
@Test
@Timeout(15)
public void testHttpJson_rpcInvokedWithLargeTimeout_closeClientOnceResponseReceived()
throws Exception {
void testHttpJson_rpcInvokedWithLargeTimeout_closeClientOnceResponseReceived() throws Exception {
// Set the maxAttempts to 1 to ensure there are no retries scheduled. The single RPC
// invocation should time out in 15s, but the client will receive a response in 2s.
// Any outstanding tasks (timeout tasks) should be cancelled once a response has been
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ class ITClientSideStreaming {
private static EchoClient grpcClient;

@BeforeAll
public static void createClients() throws Exception {
static void createClients() throws Exception {
// Create gRPC Echo Client
grpcClient = TestClientInitializer.createGrpcEchoClient();
}

@AfterAll
public static void destroyClients() throws InterruptedException {
static void destroyClients() throws InterruptedException {
grpcClient.close();
grpcClient.awaitTermination(TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS);
}

@Test
public void testGrpc_sendStreamedContent_receiveConcatenatedResponse()
void testGrpc_sendStreamedContent_receiveConcatenatedResponse()
throws ExecutionException, InterruptedException {
CollectStreamObserver<EchoResponse> responseObserver = new CollectStreamObserver<>();
ApiStreamObserver<EchoRequest> requestObserver =
Expand All @@ -71,7 +71,7 @@ public void testGrpc_sendStreamedContent_receiveConcatenatedResponse()
}

@Test
public void testGrpc_sendStreamedContent_handleServerError() {
void testGrpc_sendStreamedContent_handleServerError() {
CollectStreamObserver<EchoResponse> responseObserver = new CollectStreamObserver<>();
ApiStreamObserver<EchoRequest> requestObserver =
grpcClient.collectCallable().clientStreamingCall(responseObserver);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ITCommonServiceMixins {
private static EchoClient httpjsonClient;

@BeforeAll
public static void createClients() throws Exception {
static void createClients() throws Exception {
// Create gRPC Echo Client
grpcClient = TestClientInitializer.createGrpcEchoClient();

Expand All @@ -66,7 +66,7 @@ public static void createClients() throws Exception {
}

@AfterAll
public static void destroyClients() throws InterruptedException {
static void destroyClients() throws InterruptedException {
grpcClient.close();
httpjsonClient.close();

Expand All @@ -76,7 +76,7 @@ public static void destroyClients() throws InterruptedException {
}

@Test
public void testGrpc_getLocation() {
void testGrpc_getLocation() {
GetLocationRequest request =
GetLocationRequest.newBuilder().setName("projects/showcase/location/us-central1").build();
Location location = grpcClient.getLocation(request);
Expand All @@ -89,7 +89,7 @@ public void testGrpc_getLocation() {
}

@Test
public void testGrpc_listLocations() {
void testGrpc_listLocations() {
ListLocationsRequest request =
ListLocationsRequest.newBuilder().setName("projects/showcase").build();
EchoClient.ListLocationsPagedResponse locationsPagedResponse =
Expand All @@ -104,7 +104,7 @@ public void testGrpc_listLocations() {
}

@Test
public void testHttpJson_getLocation() {
void testHttpJson_getLocation() {
GetLocationRequest request =
GetLocationRequest.newBuilder().setName("projects/showcase/locations/us-central1").build();
Location location = httpjsonClient.getLocation(request);
Expand All @@ -117,7 +117,7 @@ public void testHttpJson_getLocation() {
}

@Test
public void testHttpJson_listLocations() {
void testHttpJson_listLocations() {
ListLocationsRequest request =
ListLocationsRequest.newBuilder().setName("projects/showcase").build();
EchoClient.ListLocationsPagedResponse locationsPagedResponse =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static void destroyClients() throws InterruptedException {
}

@BeforeEach
public void cleanupData() {
void cleanupData() {
IdentityClient.ListUsersPagedResponse pagedResponse =
grpcClient.listUsers(ListUsersRequest.newBuilder().setPageSize(5).build());
for (IdentityClient.ListUsersPage listUsersPage : pagedResponse.iteratePages()) {
Expand All @@ -81,7 +81,7 @@ public void cleanupData() {
}

@Test
public void testHttpJson_Create() {
void testHttpJson_Create() {
User userResponse = createDefaultUser();

// These properties should be the same
Expand All @@ -99,7 +99,7 @@ public void testHttpJson_Create() {
}

@Test
public void testHttpJson_Read() {
void testHttpJson_Read() {
List<User> expectedUsersList =
ImmutableList.of(
createDefaultUser(),
Expand All @@ -126,7 +126,7 @@ public void testHttpJson_Read() {
}

@Test
public void testHttpJson_Update() {
void testHttpJson_Update() {
User userResponse = createDefaultUser();
// Update multiple fields in the User. Age + Nickname are not included in the FieldMask
// userResponse's enableNotifications field is populated from the server
Expand Down Expand Up @@ -161,7 +161,7 @@ public void testHttpJson_Update() {
}

@Test
public void testHttpJson_Delete() {
void testHttpJson_Delete() {
User userResponse = createDefaultUser();

httpjsonClient.deleteUser(
Expand Down
Loading

0 comments on commit 2cca11c

Please sign in to comment.