Skip to content

Commit

Permalink
okhttp: cleanup channel in channel builder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiitk authored and dfawley committed Jan 15, 2021
1 parent 5de2c41 commit 0abb7f8
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -24,10 +24,12 @@

import com.squareup.okhttp.ConnectionSpec;
import io.grpc.ChannelLogger;
import io.grpc.ManagedChannel;
import io.grpc.internal.ClientTransportFactory;
import io.grpc.internal.FakeClock;
import io.grpc.internal.GrpcUtil;
import io.grpc.internal.SharedResourceHolder;
import io.grpc.testing.GrpcCleanupRule;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
Expand All @@ -46,11 +48,13 @@
public class OkHttpChannelBuilderTest {

@Rule public final ExpectedException thrown = ExpectedException.none();
@Rule public final GrpcCleanupRule grpcCleanupRule = new GrpcCleanupRule();

@Test
public void authorityIsReadable() {
OkHttpChannelBuilder builder = OkHttpChannelBuilder.forAddress("original", 1234);
assertEquals("original:1234", builder.build().authority());
ManagedChannel channel = grpcCleanupRule.register(builder.build());
assertEquals("original:1234", channel.authority());
}

@Test
Expand All @@ -68,7 +72,8 @@ public void overrideAuthorityIsReadableForTarget() {
private void overrideAuthorityIsReadableHelper(OkHttpChannelBuilder builder,
String overrideAuthority) {
builder.overrideAuthority(overrideAuthority);
assertEquals(overrideAuthority, builder.build().authority());
ManagedChannel channel = grpcCleanupRule.register(builder.build());
assertEquals(overrideAuthority, channel.authority());
}

@Test
Expand Down

0 comments on commit 0abb7f8

Please sign in to comment.