File tree Expand file tree Collapse file tree
api/src/main/java/io/grpc
netty/src/test/java/io/grpc/netty Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,6 +101,15 @@ public static ManagedChannelBuilder<?> newChannelBuilder(
101101 return ManagedChannelRegistry .getDefaultRegistry ().newChannelBuilder (target , creds );
102102 }
103103
104+ /**
105+ * Creates a channel builder with a target string, credentials and nameResolverRegistry.
106+ */
107+ public static ManagedChannelBuilder <?> newChannelBuilderForNameResolverRegistry (String target ,
108+ ChannelCredentials creds , NameResolverRegistry nameResolverRegistry ) {
109+ return ManagedChannelRegistry .getDefaultRegistry ().newChannelBuilder (nameResolverRegistry ,
110+ target , creds );
111+ }
112+
104113 /**
105114 * Creates a channel builder from a host, port, and credentials. The host and port are combined to
106115 * form an authority string and then passed to {@link #newChannelBuilder(String,
Original file line number Diff line number Diff line change 2828import io .grpc .ManagedChannelProvider ;
2929import io .grpc .ManagedChannelProvider .NewChannelBuilderResult ;
3030import io .grpc .ManagedChannelRegistryAccessor ;
31+ import io .grpc .NameResolverRegistry ;
3132import io .grpc .TlsChannelCredentials ;
3233import io .grpc .stub .StreamObserver ;
3334import io .grpc .testing .GrpcCleanupRule ;
@@ -120,6 +121,19 @@ public void managedChannelRegistry_newChannelBuilder() {
120121 channel .shutdownNow ();
121122 }
122123
124+ @ Test
125+ public void managedChannelRegistry_newChannelBuilderForNameResolverRegistry () {
126+ Assume .assumeTrue (Utils .isEpollAvailable ());
127+ ManagedChannelBuilder <?> managedChannelBuilder
128+ = Grpc .newChannelBuilderForNameResolverRegistry ("unix:///sock.sock" ,
129+ InsecureChannelCredentials .create (), NameResolverRegistry .getDefaultRegistry ());
130+ assertThat (managedChannelBuilder ).isNotNull ();
131+ ManagedChannel channel = managedChannelBuilder .build ();
132+ assertThat (channel ).isNotNull ();
133+ assertThat (channel .authority ()).isEqualTo ("/sock.sock" );
134+ channel .shutdownNow ();
135+ }
136+
123137 @ Test
124138 public void udsClientServerTestUsingProvider () throws IOException {
125139 Assume .assumeTrue (Utils .isEpollAvailable ());
You can’t perform that action at this time.
0 commit comments