2828import io .grpc .Channel ;
2929import io .grpc .ChannelCredentials ;
3030import io .grpc .ClientCall ;
31+ import io .grpc .InsecureChannelCredentials ;
3132import io .grpc .ManagedChannel ;
3233import io .grpc .MethodDescriptor ;
3334import io .grpc .Server ;
4849import io .netty .channel .EventLoopGroup ;
4950import java .io .File ;
5051import java .time .Duration ;
51- import java .util .Optional ;
5252import java .util .concurrent .TimeUnit ;
5353import org .junit .Before ;
5454import org .junit .ClassRule ;
@@ -82,7 +82,7 @@ public void getChannelResource_success() {
8282 Resource <Channel > resource =
8383 S2AHandshakerServiceChannel .getChannelResource (
8484 "localhost:" + plaintextServer .getPort (),
85- /* s2aChannelCredentials= */ Optional . empty ());
85+ InsecureChannelCredentials . create ());
8686 assertThat (resource .toString ()).isEqualTo ("grpc-s2a-channel" );
8787 }
8888
@@ -104,11 +104,11 @@ public void getChannelResource_twoEqualChannels() {
104104 Resource <Channel > resource =
105105 S2AHandshakerServiceChannel .getChannelResource (
106106 "localhost:" + plaintextServer .getPort (),
107- /* s2aChannelCredentials= */ Optional . empty ());
107+ InsecureChannelCredentials . create ());
108108 Resource <Channel > resourceTwo =
109109 S2AHandshakerServiceChannel .getChannelResource (
110110 "localhost:" + plaintextServer .getPort (),
111- /* s2aChannelCredentials= */ Optional . empty ());
111+ InsecureChannelCredentials . create ());
112112 assertThat (resource ).isEqualTo (resourceTwo );
113113 }
114114
@@ -133,10 +133,10 @@ public void getChannelResource_twoDistinctChannels() {
133133 Resource <Channel > resource =
134134 S2AHandshakerServiceChannel .getChannelResource (
135135 "localhost:" + plaintextServer .getPort (),
136- /* s2aChannelCredentials= */ Optional . empty ());
136+ InsecureChannelCredentials . create ());
137137 Resource <Channel > resourceTwo =
138138 S2AHandshakerServiceChannel .getChannelResource (
139- "localhost:" + Utils .pickUnusedPort (), /* s2aChannelCredentials= */ Optional . empty ());
139+ "localhost:" + Utils .pickUnusedPort (), InsecureChannelCredentials . create ());
140140 assertThat (resourceTwo ).isNotEqualTo (resource );
141141 }
142142
@@ -161,7 +161,7 @@ public void close_success() {
161161 Resource <Channel > resource =
162162 S2AHandshakerServiceChannel .getChannelResource (
163163 "localhost:" + plaintextServer .getPort (),
164- /* s2aChannelCredentials= */ Optional . empty ());
164+ InsecureChannelCredentials . create ());
165165 Channel channel = resource .create ();
166166 resource .close (channel );
167167 StatusRuntimeException expected =
@@ -199,7 +199,7 @@ public void newCall_performSimpleRpcSuccess() {
199199 Resource <Channel > resource =
200200 S2AHandshakerServiceChannel .getChannelResource (
201201 "localhost:" + plaintextServer .getPort (),
202- /* s2aChannelCredentials= */ Optional . empty ());
202+ InsecureChannelCredentials . create ());
203203 Channel channel = resource .create ();
204204 assertThat (channel ).isInstanceOf (EventLoopHoldingChannel .class );
205205 assertThat (
@@ -268,7 +268,7 @@ public void create_succeedsAfterCloseIsCalledOnce() throws Exception {
268268 Resource <Channel > resource =
269269 S2AHandshakerServiceChannel .getChannelResource (
270270 "localhost:" + plaintextServer .getPort (),
271- /* s2aChannelCredentials= */ Optional . empty ());
271+ InsecureChannelCredentials . create ());
272272 Channel channelOne = resource .create ();
273273 resource .close (channelOne );
274274
@@ -320,15 +320,14 @@ private static Server createPlaintextServer() {
320320 ServerBuilder .forPort (Utils .pickUnusedPort ()).addService (service ).build ());
321321 }
322322
323- private static Optional < ChannelCredentials > getTlsChannelCredentials () throws Exception {
323+ private static ChannelCredentials getTlsChannelCredentials () throws Exception {
324324 File clientCert = new File ("src/test/resources/client_cert.pem" );
325325 File clientKey = new File ("src/test/resources/client_key.pem" );
326326 File rootCert = new File ("src/test/resources/root_cert.pem" );
327- return Optional .of (
328- TlsChannelCredentials .newBuilder ()
327+ return TlsChannelCredentials .newBuilder ()
329328 .keyManager (clientCert , clientKey )
330329 .trustManager (rootCert )
331- .build ()) ;
330+ .build ();
332331 }
333332
334333 private static class SimpleServiceImpl extends SimpleServiceGrpc .SimpleServiceImplBase {
0 commit comments