testing: delete some deprecated APIs in TestUtils

This commit is contained in:
dapengzhang0 2017-11-22 14:36:44 -08:00 committed by ZHANG Dapeng
parent dc71083ce9
commit 3275dcbc0f
1 changed files with 0 additions and 109 deletions

View File

@ -22,16 +22,10 @@ import io.grpc.ServerCall;
import io.grpc.ServerCallHandler;
import io.grpc.ServerInterceptor;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
@ -41,7 +35,6 @@ import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
@ -53,9 +46,6 @@ import javax.security.auth.x500.X500Principal;
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1791")
public class TestUtils {
@Deprecated
public static final String TEST_SERVER_HOST = "foo.test.google.fr";
/**
* Capture the request headers from a client. Useful for testing metadata propagation.
*/
@ -73,60 +63,6 @@ public class TestUtils {
};
}
/**
* Capture the request attributes. Useful for testing ServerCalls.
* {@link ServerCall#getAttributes()}
*
* @deprecated Not for public use
*/
@Deprecated
public static ServerInterceptor recordServerCallInterceptor(
final AtomicReference<ServerCall<?, ?>> serverCallCapture) {
return new ServerInterceptor() {
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
ServerCall<ReqT, RespT> call,
Metadata requestHeaders,
ServerCallHandler<ReqT, RespT> next) {
serverCallCapture.set(call);
return next.startCall(call, requestHeaders);
}
};
}
/**
* Creates a new {@link InetSocketAddress} that overrides the host with {@link #TEST_SERVER_HOST}.
*
* @deprecated Not for public use
*/
@Deprecated
public static InetSocketAddress testServerAddress(String host, int port) {
try {
InetAddress inetAddress = InetAddress.getByName(host);
inetAddress = InetAddress.getByAddress(TEST_SERVER_HOST, inetAddress.getAddress());
return new InetSocketAddress(inetAddress, port);
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
}
/**
* Creates a new {@link InetSocketAddress} on localhost that overrides the host with
* {@link #TEST_SERVER_HOST}.
*
* @deprecated Not for public use
*/
@Deprecated
public static InetSocketAddress testServerAddress(int port) {
try {
InetAddress inetAddress = InetAddress.getByName("::1");
inetAddress = InetAddress.getByAddress(TEST_SERVER_HOST, inetAddress.getAddress());
return new InetSocketAddress(inetAddress, port);
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
}
/**
* Returns the ciphers preferred to use during tests. They may be chosen because they are widely
* available or because they are fast. There is no requirement that they provide confidentiality
@ -153,35 +89,6 @@ public class TestUtils {
return Collections.unmodifiableList(ciphersMinusGcm);
}
/**
* Saves a file from the classpath resources in src/main/resources/certs as a file on the
* filesystem.
*
* @param name name of a file in src/main/resources/certs.
*
* @deprecated Not for public use. Use {@link TlsTesting#loadCert} instead.
*/
@Deprecated
public static File loadCert(String name) throws IOException {
InputStream in = new BufferedInputStream(TestUtils.class.getResourceAsStream("/certs/" + name));
File tmpFile = File.createTempFile(name, "");
tmpFile.deleteOnExit();
OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile));
try {
int b;
while ((b = in.read()) != -1) {
os.write(b);
}
os.flush();
} finally {
in.close();
os.close();
}
return tmpFile;
}
/**
* Loads an X.509 certificate from the classpath resources in src/main/resources/certs.
*
@ -227,21 +134,5 @@ public class TestUtils {
return context.getSocketFactory();
}
/**
* Sleeps for at least the specified time. When in need of a guaranteed sleep time, use this in
* preference to {@code Thread.sleep} which might not sleep for the required time.
*
* @deprecated Not for public use
*/
@Deprecated
public static void sleepAtLeast(long millis) throws InterruptedException {
long delay = TimeUnit.MILLISECONDS.toNanos(millis);
long end = System.nanoTime() + delay;
while (delay > 0) {
TimeUnit.NANOSECONDS.sleep(delay);
delay = end - System.nanoTime();
}
}
private TestUtils() {}
}