diff options
author | Narayan Kamath <narayan@google.com> | 2018-02-21 14:11:53 +0000 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2018-02-21 14:52:51 +0000 |
commit | 0fbfc627ee2f1e43e69f6339c48d169e74f556d5 (patch) | |
tree | 56c05c5846ce4375b904f9ca48018dae1ffdb6a9 | |
parent | 89c32b38a82dc7e810f53c44284fa7b60e7f10f0 (diff) |
CoreTests: Tidy up legacy tests.
(not to be confused with core/tests/FrameworksCoreTests.)
- JniLibTest: Completely broken, ther's no Jni lib to load.
- MiscRegressionTest: Doesn't test anything.
- Sha1Test: We have more systematic and complete benchmarks in libcore.
The Apache HTTP tests remain, and only because they are the only
remaining tests of the Apache HTTP lib. They will be moved to the apache
repository in a separate commit.
Also remove bogus dependencies on conscrypt and bouncycastle.
Bug: 73635411
Test: adb shell am instrument -w android.core/android.test.InstrumentationTestRunner
Change-Id: Ia3648da023ceabcb6023941961810516857c4f48
-rw-r--r-- | tests/CoreTests/android/Android.mk | 10 | ||||
-rw-r--r-- | tests/CoreTests/android/core/JniLibTest.java | 59 | ||||
-rw-r--r-- | tests/CoreTests/android/core/MiscRegressionTest.java | 37 | ||||
-rw-r--r-- | tests/CoreTests/android/core/RequestAPITest.java | 13 | ||||
-rw-r--r-- | tests/CoreTests/android/core/Sha1Test.java | 69 |
5 files changed, 11 insertions, 177 deletions
diff --git a/tests/CoreTests/android/Android.mk b/tests/CoreTests/android/Android.mk index 56d7918aa01e..04f6739a6ced 100644 --- a/tests/CoreTests/android/Android.mk +++ b/tests/CoreTests/android/Android.mk @@ -7,14 +7,14 @@ LOCAL_SRC_FILES := \ $(call all-subdir-java-files) LOCAL_JAVA_LIBRARIES := \ - android.test.runner \ - bouncycastle \ - conscrypt \ + android.test.runner.stubs \ org.apache.http.legacy \ - android.test.base \ + android.test.base.stubs \ + +LOCAL_SDK_VERSION := current LOCAL_STATIC_JAVA_LIBRARIES := junit -LOCAL_PACKAGE_NAME := CoreTests +LOCAL_PACKAGE_NAME := LegacyCoreTests include $(BUILD_PACKAGE) diff --git a/tests/CoreTests/android/core/JniLibTest.java b/tests/CoreTests/android/core/JniLibTest.java deleted file mode 100644 index d4760720f818..000000000000 --- a/tests/CoreTests/android/core/JniLibTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * 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 android.core; - -import android.test.suitebuilder.annotation.Suppress; -import android.util.Log; -import junit.framework.TestCase; - - -@Suppress -public class JniLibTest extends TestCase { - - @Override - protected void setUp() throws Exception { - super.setUp(); - /* - * This causes the native shared library to be loaded when the - * class is first used. The library is only loaded once, even if - * multiple classes include this line. - * - * The library must be in java.library.path, which is derived from - * LD_LIBRARY_PATH. The actual library name searched for will be - * "libjni_lib_test.so" under Linux, but may be different on other - * platforms. - */ - try { - System.loadLibrary("jni_lib_test"); - } catch (UnsatisfiedLinkError ule) { - Log.e("JniLibTest", "WARNING: Could not load jni_lib_test natives"); - } - } - - private static native int nativeStaticThing(float f); - private native void nativeThing(int val); - - public void testNativeCall() { - Log.i("JniLibTest", "JNI search path is " - + System.getProperty("java.library.path")); - Log.i("JniLibTest", "'jni_lib_test' becomes '" - + System.mapLibraryName("jni_lib_test") + "'"); - - int result = nativeStaticThing(1234.5f); - nativeThing(result); - } -} diff --git a/tests/CoreTests/android/core/MiscRegressionTest.java b/tests/CoreTests/android/core/MiscRegressionTest.java deleted file mode 100644 index 32995b574e59..000000000000 --- a/tests/CoreTests/android/core/MiscRegressionTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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 android.core; - -import android.test.suitebuilder.annotation.MediumTest; -import java.util.logging.Logger; -import junit.framework.TestCase; - -public class MiscRegressionTest extends TestCase { - - // Regression test for #951285: Suitable LogHandler should be chosen - // depending on the environment. - @MediumTest - public void testAndroidLogHandler() throws Exception { - Logger.global.severe("This has logging Level.SEVERE, should become ERROR"); - Logger.global.warning("This has logging Level.WARNING, should become WARN"); - Logger.global.info("This has logging Level.INFO, should become INFO"); - Logger.global.config("This has logging Level.CONFIG, should become DEBUG"); - Logger.global.fine("This has logging Level.FINE, should become VERBOSE"); - Logger.global.finer("This has logging Level.FINER, should become VERBOSE"); - Logger.global.finest("This has logging Level.FINEST, should become VERBOSE"); - } -} diff --git a/tests/CoreTests/android/core/RequestAPITest.java b/tests/CoreTests/android/core/RequestAPITest.java index 94eb23e1b5dc..206f228c3804 100644 --- a/tests/CoreTests/android/core/RequestAPITest.java +++ b/tests/CoreTests/android/core/RequestAPITest.java @@ -22,7 +22,6 @@ import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.Suppress; import android.util.Log; import android.webkit.CookieSyncManager; -import com.google.android.collect.Maps; import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -87,7 +86,7 @@ public class RequestAPITest extends AndroidTestCase implements HttpConstants { * header is attempted to be set */ Log.d(LOGTAG, "testRequestAddNullHeader start "); - Map<String, String> headers = Maps.newHashMap(); + Map<String, String> headers = new HashMap<>(); headers.put(null, null); verifyFailure(headers); Log.d(LOGTAG, "testRequestAddNullHeader - returning"); @@ -99,7 +98,7 @@ public class RequestAPITest extends AndroidTestCase implements HttpConstants { * value is attempted to be set */ Log.d(LOGTAG, "testRequestAddNullValue start "); - Map<String, String> headers = Maps.newHashMap(); + Map<String, String> headers = new HashMap<>(); headers.put("TestHeader", null); verifyFailure(headers); Log.d(LOGTAG, "testRequestAddNullValue - returning"); @@ -111,7 +110,7 @@ public class RequestAPITest extends AndroidTestCase implements HttpConstants { * header is attempted to be set */ Log.d(LOGTAG, "testRequestAddEmptyValue start "); - Map<String, String> headers = Maps.newHashMap(); + Map<String, String> headers = new HashMap<>(); headers.put("TestHeader", ""); verifyFailure(headers); Log.d(LOGTAG, "testRequestAddEmptyValue - returning"); @@ -131,7 +130,7 @@ public class RequestAPITest extends AndroidTestCase implements HttpConstants { * generating and exception */ Log.d(LOGTAG, "testRequestAddHeader start "); - Map<String, String> headers = Maps.newHashMap(); + Map<String, String> headers = new HashMap<>(); headers.put("TestHeader", "RequestAddHeader"); verifySuccess(headers); Log.d(LOGTAG, "testRequestAddHeader - returning"); @@ -143,7 +142,7 @@ public class RequestAPITest extends AndroidTestCase implements HttpConstants { * can be set without generating and exception */ Log.d(LOGTAG, "testRequestAddMultiHeader start "); - Map<String, String> headers = Maps.newHashMap(); + Map<String, String> headers = new HashMap<>(); headers.put("TestHeader", "RequestAddMultiHeader"); headers.put("TestHeader2", "RequestAddMultiHeader"); headers.put("TestHeader3", "RequestAddMultiHeader"); @@ -157,7 +156,7 @@ public class RequestAPITest extends AndroidTestCase implements HttpConstants { * and values can be set without generating and exception */ Log.d(LOGTAG, "testRequestAddSameHeader start "); - Map<String, String> headers = Maps.newHashMap(); + Map<String, String> headers = new HashMap<>(); headers.put("TestHeader", "RequestAddSameHeader"); headers.put("TestHeader", "RequestAddSameHeader"); headers.put("TestHeader", "RequestAddSameHeader"); diff --git a/tests/CoreTests/android/core/Sha1Test.java b/tests/CoreTests/android/core/Sha1Test.java deleted file mode 100644 index 8ed120542a44..000000000000 --- a/tests/CoreTests/android/core/Sha1Test.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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 android.core; - -import android.test.suitebuilder.annotation.SmallTest; -import java.security.MessageDigest; -import junit.framework.TestCase; - -/** - * Tests SHA1 message digest algorithm. - */ -public class Sha1Test extends TestCase { - class TestData { - private String input; - private String result; - - public TestData(String i, String r) { - input = i; - result = r; - } - } - - TestData[] mTestData = new TestData[]{ - new TestData("abc", "a9993e364706816aba3e25717850c26c9cd0d89d"), - new TestData("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - "84983e441c3bd26ebaae4aa1f95129e5e54670f1") - }; - - @SmallTest - public void testSha1() throws Exception { - MessageDigest digest = MessageDigest.getInstance("SHA-1"); - - int numTests = mTestData.length; - for (int i = 0; i < numTests; i++) { - digest.update(mTestData[i].input.getBytes()); - byte[] hash = digest.digest(); - String encodedHash = encodeHex(hash); - assertEquals(encodedHash, mTestData[i].result); - } - } - - private static String encodeHex(byte[] bytes) { - StringBuffer hex = new StringBuffer(bytes.length * 2); - - for (int i = 0; i < bytes.length; i++) { - if (((int) bytes[i] & 0xff) < 0x10) { - hex.append("0"); - } - hex.append(Integer.toString((int) bytes[i] & 0xff, 16)); - } - - return hex.toString(); - } -} - |