core: rm unnecessary InternalNameResolverProvider

This commit is contained in:
ZHANG Dapeng 2018-03-13 10:21:40 -07:00 committed by GitHub
parent 9c5e96e376
commit 6b9e090d70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 52 deletions

View File

@ -1,25 +0,0 @@
/*
* Copyright 2018, gRPC Authors All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.grpc;
import com.google.common.annotations.VisibleForTesting;
public class InternalNameResolverProvider {
@VisibleForTesting
public static final Iterable<Class<?>> HARDCODED_CLASSES =
NameResolverProvider.HARDCODED_CLASSES;
}

View File

@ -94,6 +94,29 @@ public class NameResolverProviderTest {
ImmutableSet.of("io.grpc.internal.DnsNameResolverProvider"));
}
@Test
public void provided() {
for (NameResolverProvider current
: InternalServiceProviders.getCandidatesViaServiceLoader(
NameResolverProvider.class, getClass().getClassLoader())) {
if (current instanceof DnsNameResolverProvider) {
return;
}
}
fail("DnsNameResolverProvider not registered");
}
@Test
public void providedHardCoded() {
for (NameResolverProvider current : InternalServiceProviders.getCandidatesViaHardCoded(
NameResolverProvider.class, NameResolverProvider.HARDCODED_CLASSES)) {
if (current instanceof DnsNameResolverProvider) {
return;
}
}
fail("DnsNameResolverProvider not registered");
}
public static final class HardcodedClassesCallable implements Callable<Iterator<Class<?>>> {
@Override
public Iterator<Class<?>> call() throws Exception {

View File

@ -19,12 +19,8 @@ package io.grpc.internal;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import io.grpc.Attributes;
import io.grpc.InternalNameResolverProvider;
import io.grpc.InternalServiceProviders;
import io.grpc.NameResolverProvider;
import java.net.URI;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -35,29 +31,6 @@ import org.junit.runners.JUnit4;
public class DnsNameResolverProviderTest {
private DnsNameResolverProvider provider = new DnsNameResolverProvider();
@Test
public void provided() {
for (NameResolverProvider current
: InternalServiceProviders.getCandidatesViaServiceLoader(
NameResolverProvider.class, getClass().getClassLoader())) {
if (current instanceof DnsNameResolverProvider) {
return;
}
}
fail("DnsNameResolverProvider not registered");
}
@Test
public void providedHardCoded() {
for (NameResolverProvider current : InternalServiceProviders.getCandidatesViaHardCoded(
NameResolverProvider.class, InternalNameResolverProvider.HARDCODED_CLASSES)) {
if (current instanceof DnsNameResolverProvider) {
return;
}
}
fail("DnsNameResolverProvider not registered");
}
@Test
public void isAvailable() {
assertTrue(provider.isAvailable());