Switch core-tests-support to @CorePlatformApi
Rather than depending on internals, switch core-tests-support
to using the core platform API.
core-tests-support had a static dependency on the platform
bouncycastle target which included a copy of the repackaged
bouncycastle in CTS. This copy would then not be used. This looks
like a mistake. After this change a copy of bouncycastle is included
under its original package.
TestIoUtils was relying on a hidden method in java.lang.Math. This
has been replaced with public API calls.
Bug: 113148576
Test: build
Test: Ran CTS: cts -m CtsLibcoreTestCases
Change-Id: Ib8045537c2c191aca3f416cc459f265c8d957dfc
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index e187e66..1f312a6 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -334,16 +334,14 @@
hostdex: true,
srcs: ["support/src/test/java/**/*.java"],
- no_standard_libs: true,
+ sdk_version: "core_platform_current",
libs: [
- "core-all",
"junit",
- "bouncycastle",
],
- system_modules: "core-all-system-modules",
static_libs: [
- "bouncycastle-bcpkix",
- "bouncycastle-ocsp",
+ "bouncycastle-unbundled",
+ "bouncycastle-bcpkix-unbundled",
+ "bouncycastle-ocsp-unbundled",
],
}
diff --git a/luni/src/test/java/libcore/java/security/cert/CertPathValidatorTest.java b/luni/src/test/java/libcore/java/security/cert/CertPathValidatorTest.java
index e621b5c..0f84e91 100644
--- a/luni/src/test/java/libcore/java/security/cert/CertPathValidatorTest.java
+++ b/luni/src/test/java/libcore/java/security/cert/CertPathValidatorTest.java
@@ -32,22 +32,22 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
-import com.android.org.bouncycastle.asn1.x509.CRLReason;
-import com.android.org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
-import com.android.org.bouncycastle.cert.X509CertificateHolder;
-import com.android.org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
-import com.android.org.bouncycastle.cert.ocsp.BasicOCSPResp;
-import com.android.org.bouncycastle.cert.ocsp.BasicOCSPRespBuilder;
-import com.android.org.bouncycastle.cert.ocsp.CertificateID;
-import com.android.org.bouncycastle.cert.ocsp.CertificateStatus;
-import com.android.org.bouncycastle.cert.ocsp.OCSPResp;
-import com.android.org.bouncycastle.cert.ocsp.OCSPRespBuilder;
-import com.android.org.bouncycastle.cert.ocsp.RevokedStatus;
-import com.android.org.bouncycastle.operator.DigestCalculatorProvider;
-import com.android.org.bouncycastle.operator.bc.BcDigestCalculatorProvider;
-import com.android.org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import junit.framework.TestCase;
import libcore.java.security.TestKeyStore;
+import org.bouncycastle.asn1.x509.CRLReason;
+import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
+import org.bouncycastle.cert.X509CertificateHolder;
+import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
+import org.bouncycastle.cert.ocsp.BasicOCSPResp;
+import org.bouncycastle.cert.ocsp.BasicOCSPRespBuilder;
+import org.bouncycastle.cert.ocsp.CertificateID;
+import org.bouncycastle.cert.ocsp.CertificateStatus;
+import org.bouncycastle.cert.ocsp.OCSPResp;
+import org.bouncycastle.cert.ocsp.OCSPRespBuilder;
+import org.bouncycastle.cert.ocsp.RevokedStatus;
+import org.bouncycastle.operator.DigestCalculatorProvider;
+import org.bouncycastle.operator.bc.BcDigestCalculatorProvider;
+import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import dalvik.system.VMRuntime;
import sun.security.jca.Providers;
diff --git a/support/src/test/java/libcore/java/security/TestKeyStore.java b/support/src/test/java/libcore/java/security/TestKeyStore.java
index 691bdf3..b3544b7 100644
--- a/support/src/test/java/libcore/java/security/TestKeyStore.java
+++ b/support/src/test/java/libcore/java/security/TestKeyStore.java
@@ -18,33 +18,6 @@
import static org.junit.Assert.assertEquals;
-import com.android.org.bouncycastle.asn1.DEROctetString;
-import com.android.org.bouncycastle.asn1.x500.X500Name;
-import com.android.org.bouncycastle.asn1.x509.BasicConstraints;
-import com.android.org.bouncycastle.asn1.x509.CRLReason;
-import com.android.org.bouncycastle.asn1.x509.ExtendedKeyUsage;
-import com.android.org.bouncycastle.asn1.x509.Extension;
-import com.android.org.bouncycastle.asn1.x509.GeneralName;
-import com.android.org.bouncycastle.asn1.x509.GeneralNames;
-import com.android.org.bouncycastle.asn1.x509.GeneralSubtree;
-import com.android.org.bouncycastle.asn1.x509.KeyPurposeId;
-import com.android.org.bouncycastle.asn1.x509.KeyUsage;
-import com.android.org.bouncycastle.asn1.x509.NameConstraints;
-import com.android.org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
-import com.android.org.bouncycastle.cert.X509CertificateHolder;
-import com.android.org.bouncycastle.cert.X509v3CertificateBuilder;
-import com.android.org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
-import com.android.org.bouncycastle.cert.ocsp.BasicOCSPResp;
-import com.android.org.bouncycastle.cert.ocsp.BasicOCSPRespBuilder;
-import com.android.org.bouncycastle.cert.ocsp.CertificateID;
-import com.android.org.bouncycastle.cert.ocsp.CertificateStatus;
-import com.android.org.bouncycastle.cert.ocsp.OCSPResp;
-import com.android.org.bouncycastle.cert.ocsp.OCSPRespBuilder;
-import com.android.org.bouncycastle.cert.ocsp.RevokedStatus;
-import com.android.org.bouncycastle.jce.provider.BouncyCastleProvider;
-import com.android.org.bouncycastle.operator.DigestCalculatorProvider;
-import com.android.org.bouncycastle.operator.bc.BcDigestCalculatorProvider;
-import com.android.org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.PrintStream;
@@ -81,6 +54,33 @@
import javax.security.auth.x500.X500Principal;
import libcore.javax.net.ssl.TestKeyManager;
import libcore.javax.net.ssl.TestTrustManager;
+import org.bouncycastle.asn1.DEROctetString;
+import org.bouncycastle.asn1.x500.X500Name;
+import org.bouncycastle.asn1.x509.BasicConstraints;
+import org.bouncycastle.asn1.x509.CRLReason;
+import org.bouncycastle.asn1.x509.ExtendedKeyUsage;
+import org.bouncycastle.asn1.x509.Extension;
+import org.bouncycastle.asn1.x509.GeneralName;
+import org.bouncycastle.asn1.x509.GeneralNames;
+import org.bouncycastle.asn1.x509.GeneralSubtree;
+import org.bouncycastle.asn1.x509.KeyPurposeId;
+import org.bouncycastle.asn1.x509.KeyUsage;
+import org.bouncycastle.asn1.x509.NameConstraints;
+import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
+import org.bouncycastle.cert.X509CertificateHolder;
+import org.bouncycastle.cert.X509v3CertificateBuilder;
+import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
+import org.bouncycastle.cert.ocsp.BasicOCSPResp;
+import org.bouncycastle.cert.ocsp.BasicOCSPRespBuilder;
+import org.bouncycastle.cert.ocsp.CertificateID;
+import org.bouncycastle.cert.ocsp.CertificateStatus;
+import org.bouncycastle.cert.ocsp.OCSPResp;
+import org.bouncycastle.cert.ocsp.OCSPRespBuilder;
+import org.bouncycastle.cert.ocsp.RevokedStatus;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.operator.DigestCalculatorProvider;
+import org.bouncycastle.operator.bc.BcDigestCalculatorProvider;
+import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
/**
* TestKeyStore is a convenience class for other tests that
diff --git a/support/src/test/java/libcore/javax/net/ssl/TestKeyManager.java b/support/src/test/java/libcore/javax/net/ssl/TestKeyManager.java
index 03420fe6..5b49318 100644
--- a/support/src/test/java/libcore/javax/net/ssl/TestKeyManager.java
+++ b/support/src/test/java/libcore/javax/net/ssl/TestKeyManager.java
@@ -20,7 +20,6 @@
import java.net.Socket;
import java.security.Principal;
import java.security.PrivateKey;
-import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLEngine;
diff --git a/support/src/test/java/libcore/javax/net/ssl/TestSSLSocketPair.java b/support/src/test/java/libcore/javax/net/ssl/TestSSLSocketPair.java
index 55ce3bb..f96fc59 100644
--- a/support/src/test/java/libcore/javax/net/ssl/TestSSLSocketPair.java
+++ b/support/src/test/java/libcore/javax/net/ssl/TestSSLSocketPair.java
@@ -17,7 +17,6 @@
package libcore.javax.net.ssl;
import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
diff --git a/support/src/test/java/libcore/testing/io/TestIoUtils.java b/support/src/test/java/libcore/testing/io/TestIoUtils.java
index 4296103..8e241df 100644
--- a/support/src/test/java/libcore/testing/io/TestIoUtils.java
+++ b/support/src/test/java/libcore/testing/io/TestIoUtils.java
@@ -17,8 +17,10 @@
package libcore.testing.io;
import java.io.File;
+import java.util.Random;
public class TestIoUtils {
+ private final static Random random = new Random();
private TestIoUtils() {}
@@ -27,7 +29,7 @@
*/
public static File createTemporaryDirectory(String prefix) {
while (true) {
- String candidateName = prefix + Math.randomIntInternal();
+ String candidateName = prefix + nextRandomInt();
File result = new File(System.getProperty("java.io.tmpdir"), candidateName);
if (result.mkdir()) {
return result;
@@ -48,4 +50,8 @@
}
}
}
+
+ private synchronized static int nextRandomInt() {
+ return random.nextInt();
+ }
}