summaryrefslogtreecommitdiff
path: root/luni/src/test/java/org/apache
Commit message (Collapse)AuthorAgeFilesLines
* Add API coverage for java.security methodsVictor Chang2021-03-111-2/+5
| | | | | | Bug: 182166453 Test: atest CtsLibcoreTestCases:libcore.java.security Change-Id: Ic528c887c6ef85dcd3b814b38a8cf756a924675a
* Skip Elliptic curve DH in KeyFactory2Test.Pete Bentley2021-02-081-1/+8
| | | | | | | | | | | These tests rely on the KeySpec class for each class of keys, and for XDH these are not yet available on Android. XDH already has full unit tests under Conscrypt. Bug: 179675498 Test: atest CtsLibcoreTestCases:org.apache.harmony.security.tests.java.security.KeyFactory2Test Change-Id: Ic6e57f52e9e20fd8931e13530fb072dc20aaf3b9
* Inclusive Language Fixit: Replace dummy with fakePaul Duffin2020-07-284-33/+33
| | | | | | Bug: 162205877 Test: m java Change-Id: I294a033305448533d101349dc41bd216ce2ec63f
* Extract luni crypto tests into separate moduleDaulet Zhanguzin2020-04-031-2/+2
| | | | | | | | | | | | Some tests that validate Conscrypt dependencies live outside of Conscrypt - luni tests in this case. Extracting relevant ones into a separate lib so it can be referenced by MtsConscryptTestCases. Test: mts mts-conscrypt Bug: 150644123 Bug: 150644835 Change-Id: Ib595a01bde5806bfd3a73ab92e03159525c52ca6
* Add TestRule to enable access to deprecated BC algorithmsPaul Duffin2019-09-252-31/+19
| | | | | | | | | | | | | | | | | | | | | | | Android restricts access to a number of deprecated BouncyCastle algorithms to APKs that target SDK version <= 27. However, those algorithms still need testing. Rather than set the target SDK version to be <= 27 (which could have other side effects) tests use Providers.setMaximumAllowableApiLevelForBcDeprecation(int) to raise the level to make them accessible at the current target SDK version and resets it the default value afterwards. This change adds a JUnit test rule to implement that behavior and uses it to replace duplicate setUp() and tearDown() code across a number of tests. It also insulates the tests from having to access the internal sun.security.jca.Providers and dalvik.system.VMRuntime classes. This is intended to be used by external/conscrypt so that the conscrypt-tests module can stop depending on core-all-systems-module. Bug: 141539296 Test: atest CtsLibcoreTestCases Change-Id: If41b5c221c392e9b6d14d500537115d3380c4999
* Add tests for CipherSpi.updateAAD() and SSLEngine(String, int)Adam Vartanian2019-04-011-0/+36
| | | | | | | | | | We added tests for the implementations in Conscrypt, but these test the behavior of the underlying CipherSpi and SSLEngine classes themselves. Test: cts -m CtsLibcoreTestCases -t org.apache.harmony Bug: 129008943 Change-Id: I2eecebdabfe34aafaacab4a974383becd8eed63e
* Add JUnit 4 TestRule for running tests with a specific target SDKPaul Duffin2019-03-211-34/+25
| | | | | | | | | | | | | | | | | | | | | | | | Refactors code to replace lots of custom code for testing behavior for specific target SDK versions, whether it is try...finally... blocks or methods using lambdas with a JUnit 4 TestRule. As the tests were JUnit 3 that also required switching them from extending TestCase to extending TestCaseWithRules which adds support for JUnit 4 TestRules to TestCase. This is preparation work for some follow up work on ObjectStreamClass. Test: atest \ core-tests:org.apache.harmony.tests.java.io.ObjectStreamClassTest \ core-tests:libcore.java.lang.OldRuntimeTest \ core-tests:libcore.java.lang.PackageTest \ core-tests:libcore.java.lang.reflect.annotations.AnnotationsTest \ core-tests:libcore.java.util.CollectionsTest \ core-tests:org.apache.harmony.regex.tests.java.util.regex.PatternTest \ core-tests:libcore.junit.util.SwitchTargetSdkVersionRuleTest Bug: 109930347 Change-Id: I4ea11288eb344eaeb2e6cc9f3225748e518e1827
* Delete several DH key testsAdam Vartanian2019-02-212-78/+0
| | | | | | | | | | | | The Bouncy Castle upgrade added a subclass of DHParameterSpec that includes more information about the key parameters. There's no reason to bar extending those classes, so we no longer need the assertion that it's precisely the base class. Once that's gone, the rest of the assertions are largely just testing the signatures of the methods, so we can just delete the test cases entirely. Test: cts -m CtsLibcoreTestCases -t org.apache.harmony.crypto.tests.javax.crypto.interfaces Change-Id: I4f69a7527d7f5eace1c3bbaf662cb9d584c28f5b
* Fix harmony URLConnectionTest hanging for 25sec.Tobias Thierer2018-11-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Handler for file:// URLs contains a fallback to FtpURLConnection for URLs with nonempty host (with some exceptions). URLConnectionTest.test_getContentType() contained a typo ("file:/" instead of "file://"). This led to the URL having a non-empty host value ("data"), which triggered a fallback to FtpURLConnection in the Handler for file:// URLs. The test attempted to resolve the host "data", eventually timing out. getContentType() by itself swallows any IOException and just returns null, and the test was written to tolerate null, so it didn't fail. The test code hasn't been touched since the initial commit in 2009, which makes it hard to tell whether the null tolerance was because someone had observed the test failing (but not understood why), or perhaps wanted to make the test tolerant of poor contentType detection. This CL fixes the typo, which makes the test pass in milliseconds rather than in 25+ seconds. This CL also makes the test stricter by checking specifically for "text/html" rather than a case-insensitive version of it or null. It also checks for a file:// (as opposed to ftp://) URLConnection for the two cases fixed by this CL and by http://r.android.com/82755 (commit 2587ef91ba693d73e97704e8163c050b286e7330). The logic for fallback to FtpURLConnection remains in place; basic test coverage for it exists in org.apache.harmony.tests.java.net.URLTest#test_openConnection_FileProtocol (this CL fixes a minor typo in that test name). The test appears to derive from code written for https://issues.apache.org/jira/browse/HARMONY-5779 Test: atest CtsLibcoreTestCases:org.apache.harmony.luni.tests.java.net.URLConnectionTest Test: atest CtsLibcoreTestCases:org.apache.harmony.tests.java.net.URLTest Test: CtsLibcoreTestCases Test: Checked that nothing else in CtsLibcoreTestCases relies on the fallback to FtpURLConnection by locally replacing it with an AssertionError and checking that the only failing test is test_openConnection_FileProtocol(). Fixes: 119607552 Change-Id: Ib5bf45f11e49c56a34fda5fe3cb27485c2d7176c
* Refactor PatternTestNikita Iashchenko2018-10-051-319/+590
| | | | | | | | | | | | Refactor PatternTest to split up large test methods. There were several test methods that contained a large number of tests and assertions. These have been split into individual test methods to improve readability and avoid early failures preventing later assertions executing. Bug: 109668649 Test: cts -m CtsLibcoreTestCases -t org.apache.harmony.regex.tests.java.util.regex.PatternTest Change-Id: I5b04c1c44bc34afe70f3305c8772ccaf36f136cb
* Verify Pattern, step 2: Integrate behavior change for Pattern.split().Tobias Thierer2018-06-261-6/+70
| | | | | | | | | | | | | | | | | | | | | | This is the second attempt to submit this CL. The first attempt broke TextUtilsTest which is now updated by another CL in this topic; also, the original CL changed behavior for all apps whereas this CL only changes it for apps targeting API > 28. This CL integrates a behavior change that was forgotten in the update from OpenJDK 7u40 to 8u121-b13. This CL also adds a test to guard against regressions. Bug: 109659282 Test: testMatchBeginningOfInputSequence() fails before this CL, but passes after this CL. Test: cts-tradefed run singleCommand cts -a arm64-v8a -m CtsLibcoreTestCases \ -t org.apache.harmony.tests.java.util.regex.SplitTest Test: cts-tradefed run singleCommand cts -a arm64-v8a -m CtsLibcoreTestCases \ -t org.apache.harmony.regex.tests.java.util.regex.PatternTest Change-Id: Ic3631667de0b5cbc4531d42b342d752a701e822f
* Revert "Verify Pattern, step 2: Integrate behavior change for Pattern.split()."Colin Cross2018-06-191-29/+6
| | | | | | | | | | This reverts commit 990d9dfa0432ff598aaf64519a5ce1129e822ee7. Reason for revert: Broke CtsTextTestCases Bug: 109659282 Bug: 110381464 Change-Id: I91e2cf50d17a6822690b375bc9fa83ecea84ce04
* Verify Pattern, step 2: Integrate behavior change for Pattern.split().Tobias Thierer2018-06-121-6/+29
| | | | | | | | | | | | | | This CL integrates a behavior change that was forgotten in the update from OpenJDK 7u40 to 8u121-b13. This CL also adds a test to guard against regressions. Bug: 109659282 Test: testMatchBeginningOfInputSequence() fails before this CL, but passes after this CL. Test: make cts && cts-tradefed run cts -m CtsLibcoreTestCases Change-Id: Ie7340629a0954fa231d1a1f2a51885c0774ed436
* Drop luni's duplicate {Matcher2,Mode,Replace,Split}Test.java.Tobias Thierer2018-06-124-661/+0
| | | | | | | | | | | | | | | | These files are identical to the ones in a slightly different package in harmony-tests, except that luni's SplitTest was missing a file header. To avoid future divergence, this CL drops the copy in luni/. PatternTest and PatternSyntaxExceptionTest remain in luni (harmony-tests/ has PatternErrorTest and MatcherTest instead). Bug: 109727025 Test Treehugger Test: Ran CtsLibcoreTestCases at a later CL. Change-Id: I83f59fe5dcceeffe3231d1db1de47758c0d1d92b
* Unify duplicate copies of harmony {Matcher2,Mode,Replace,Split}Test.Tobias Thierer2018-06-124-23/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Android is carrying near-duplicate copies of these tests introduced in: 1.) luni/: commit fdb2704414a9ed92394ada0d1395e4db86889465 (2008-10-21, "Initial Contribution") 2.) harmony-tests/: commit bfd68b1dd4409f61fbc6800ba61f4605ad57945b (2013-05-03, "Add the harmony regex tests.") The initial copies already differed, eg. This CL integrates differences between the two copies. After this CL, the files are pairwise identical except: - they are in different packages - luni's SplitTest.java is missing the file header Most of the changes are integrated luni/ -> harmony-tests, keeping tests that were previously only present in one copy, eg.: - slightly more verbose test case in ReplaceTest.testSimpleReplace() - SplitTest.testEmptySplits() (added in commit 51809b9c7995d8b813f68712b096d23179de3af0 ) - Matcher2Test tests added by http://r.android.com/695546 In cases where the "better" version is not clear, an arbitrary judgement call was made. Examples: - @SuppressWarnings("nls"): Differed in the original imports. Might be Eclipse specific, but kept for now. - minor whitespace changes - formatting of ReplaceTest This CL does not touch the following files / differences: - luni/ has PatternTest but harmony-tests/ has MatcherTest - luni/ has PatternSyntaxExceptionTest but harmony-tests/ has PatternErrorTest Bug: 109727025 Test: Treehugger Test: Ran CtsLibcoreTestCases at a later CL. Change-Id: Ib1c1c25c2010c082e119a0b8b21dadf58576e3f7
* Clean up a couple test oddities.Adam Vartanian2018-02-062-0/+6
| | | | | | | | | | | | | | | | | | | | Some internal changes exposed existing problems in our tests. CipherTest's test_getInstance was needlessly case-sensitive. Algorithm names are case insensitive, so normalize them before using them in sets in the test. KeyGeneratorTest and SecretKeyFactoryTest both had a problem where the first test was a failing test, which meant that the provider infrastructure cycled through all the available providers trying to find one that wouldn't fail and then locked into the least-preferred provider, so we were testing the wrong thing. Instead, lock in the preferred provider (by calling getProvider()) before running any of the tests, so we know we're testing the provider we intend to test. Bug: 72860937 Test: cts -m CtsLibcoreTestCases Change-Id: I98bcc5b34655eec9bdb4423c7739ba5ebd1d6f1d
* Libcore: Suppress InvalidPatternSyntax warning in testsAndreas Gampe2018-01-251-0/+1
| | | | | | | | | The tests exercises a unusual orwrong patterns to test corner cases and exception paths. Ignore the errorprone warning. Bug: 72451126 Test: m javac-check RUN_ERROR_PRONE=true Change-Id: I710b9d7ee2d5379b31f3dde5a04d35ea22c5d7b8
* Move libcore tests to non-libcore packages.Tobias Thierer2017-11-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The integration of OpenJDK 9 javac into the Android build system requires non-libcore code to live in non-libcore packages, as long as that code isn't considered part of the same module as libcore at javac time. This CL moves libcore test related classes out of such packages; since libcore tests could already only test public (as opposed to package private APIs), no change other than the package name and imports is necessary. Because many libcore tests already live below a top-level package "libcore" (eg., the tests for java.util are in libcore.java.util), this CL likewise prepends "libcore." to the package names of affected classes. For classes relating to libcore.* packages, this results in a package name of the form "libcore.libcore.*". Alternative considered but not pursued: To compile the test classes without moving the out of a libcore package, javac would need to consider them to be in the same module as libcore. This would likely be possible via javac --patch-module, but this has not been explored in detail because: - Most luni tests are already in a toplevel package libcore.*, so this CL makes the test structure more consistent. - Use of --patch-module would likely cause problems when running tests under a runtime that implements the OpenJDK 9 module system; for example, --patch-module cannot add exported packages to the module, so any new packages added in tests (such as the libcore.* packages of most existing luni tests) would not be visible at test runtime. - Having tests in different packages from code under tests makes it more obvious (including to IDEs in which the code might be edited as a single project) that these tests cannot access package-private identifiers in the code under test. Test: Treehugger Test: "make cts" with EXPERIMENTAL_USE_OPENJDK9=true passes with additional changes present locally that have not yet been exported as CLs. Test: CtsLibcoreTestCases Bug: 68224249 Bug: 68932217 (tracks potential follow-up work) Change-Id: Ib6b8e6f3bc87093bc219d2108e601163c6e334cd
* Deprecate BC implementations of duplicated algorithmsAdam Vartanian2017-10-132-1/+36
| | | | | | | | | | | | | | | | | | | | | | | The first step in deprecating the BC implementations of algorithms that are also provided by Conscrypt. This checks whether the app's target API level is greater than a given threshold (currently O, but subject to change later) and disallows access to those algorithms when true. This limit only applies to requests from the system-created BC provider. Apps can install their own provider, in which case they get the implementations they requested. This doesn't yet implement the deprecation for Cipher instances, since the transformation scheme makes that more complicated. The ultimate removal of these algorithms, once a sufficient deprecation period has elapsed, is tracked in b/67761667. Bug: 67626877 Test: cts -m CtsLibcoreTestCases Test: cts -m CtsLibcoreOkHttpTestCases Test: cts -m CtsLibcoreWycheproofBCTestCases Test: cts -m CtsLibcoreWycheproofConscryptTestCases Change-Id: I48f07226e66873a65859121af32028c1547952ac
* Automated: Canonicalize spelling of Android-changed across libcoreTobias Thierer2017-03-062-34/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This applies the same regexp replacement across libcore that http://r.android.com/345826 had only applied to ojluni. Most of the previous noncanonical spellings were a lowercased "android-" that should be "Android-". This CL was created by running the following command on top of the above CL. No manual changes were made. find . -name \*\.java | xargs sed -i \ -e 's/Android[- ]changed/Android-changed/ig' \ -e 's/Android-changed :/Android-changed:/g' \ -e 's/Android-changed \(BEGIN\|END\)/\1 Android-changed/g' \ -e 's/Android-changed - /Android-changed: /g' \ -e 's/Android[- ]removed/Android-removed/ig' \ -e 's/Android-removed :/Android-removed:/g' \ -e 's/Android-removed \(BEGIN\|END\)/\1 Android-removed/g' \ -e 's/Android-removed - /Android-removed: /g' \ -e 's/Android[- ]added/Android-added/ig' \ -e 's/Android-added :/Android-added:/g' \ -e 's/Android-added \(BEGIN\|END\)/\1 Android-added/g' \ -e 's/Android-added - /Android-added: /g' \ -e 's/----- \(BEGIN\|END\) android\( -----\)\?/\1 Android-changed/g' \ -e 's/\/\* \(BEGIN\|END\) Android-changed \*\//\/\/ \1 Android-changed/g' Bug: 35841464 Test: make droid cts Change-Id: I060c7236b7607763e5d27d60aa395d2507703a95
* Speed up DHPublicKeyTest; make DHPrivateKeyTest consistent.Tobias Thierer2017-02-092-3/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DHPublicKeyTest.test_getParams() was generating 1024bit Diffie-Hellman parameters; this operation is very slow and very variable, often taking more than the 5 minutes allowed before the test times out. In practice, parameters are not generated at random, especially not on a mobile device; instead, in practice well-known parameters are picked rather than generating a random one. To make this the test both more realistic and faster to run, this CL splits up DHPublicKeyTest.test_getParams() into two tests: 1.) generate a 192bit, rather than 1024bit, parameters 2.) use hard coded 2048bit parameters to generate keys. The 2048-bit group from RFC 7919, Appendix A, was used. The same is done to DHPrivateKeyTest.test_getParams(), which was previously only doing 1.). Historical context: DHPrivateKeyTest historically had observed the same problems; therefore, commit 8bc378b1cec65bc06766a14a9cc575fec931b418 in Feb 2011 changed it to only use 192bit, i.e. do 1.); DHPublicKeyTest was not touched at that time. DHPublicKeyTest's timeout was increased in June 2015 (cts commit d16b864e9537e172436bfb8a5de76e9e49fcea35) but that broke with the switch to CTSv2. Test: Check that DHPrivateKeyTest and DHPublicKeyTest pass within a few seconds on a Nexus 6P. Bug: 30741591 Change-Id: I6af0a70761557e4f4c1641cad7807d2211553e25
* Fix NPE in Signature getCurrentSpi.rhed_jao2016-12-081-0/+79
| | | | | | | | | | For Signature created by Delegate(SignatureSpi, String) constructor, lock object is always null. 'getCurrentSpi' function throws NPE in this case. Bug: 33383388 Test: vogar SignatureTest Change-Id: Ibbcf482d805b3c0ffa9ee2b75100041b7a056376
* Address URLConnectionTest post-commit review commentsYi Kong2016-11-021-5/+18
| | | | | | | | | | | | This change addresses some post-commit review comments for commit 44c55c5b639d6c1eea6eeae8414ef9df95b67bb7: * Moved SocketTimeoutException into a separate test. * Added more infomative comments regarding setDelay. * Reduced method visibility, being public method is unnecessary. Bug: 32363029 Test: URLConnectionTest#test_setReadTimeoutI_SocketTimeoutException Change-Id: Ia13ba801cfa6e06fc7597f4f665fa2d002b688e1
* Fix URLConnectionTest.test_setReadTimeoutI on host testYi Kong2016-10-311-0/+1
| | | | | | | | | | | | This was failing because the test assumes that read will not complete within 1ms, while it is still possible, especially on host tests. This patch introduces a minimum time delay before the TestWebServer sends data. Bug: 32363029 Test: org.apache.harmony.luni.tests.java.net.URLConnectionTest#test_setReadTimeoutI under host tests Change-Id: Ibb4e2125f99b0544d0f09331b4ab9b0448b14035
* Temporarily disabled closeguard test for making ART bot greenShubham Ajmera2016-10-261-2/+2
| | | | | | | | Bug: 31542223 Test: cts-tradefed run cts -m CtsLibcoreTestCases -t \ org.apache.harmony.luni.tests.java.net.URLConnectionTest Change-Id: I6c7fb209308d023f5a575aacf02c6030949b203b
* Detect and fix resource leakages in testsPaul Duffin2016-10-211-22/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Tests that test those classes that use CloseGuard to detect reosurce leakages are switched to use TestCaseWithRules and ResourceLeakageDetector.getRule() to detect any resource leakages and the leaks fixed. A number of tests could not be fixed due to bugs in the core classes so a new DisableResourceLeakageDetection annotation was added as part of this change. A method annotated with that does not perform resource leakage detection. The affected tests were annotated with a description and a reference to an associated bug. This uses try-with-resources to aid in closing resources. While that does provide some benefits it is all too easy to change the behavior of the test unless care is taken. To avoid that it is important not to merge it with an existing try block such as those which follow the following pattern: try {... fail()} catch(..) {} Merging them could result in the test catching and ignoring exceptions thrown during the creation of the resource which is almost certainly not what the test was intending. Test: Tested with vogar and CTS Bug: 31542223 Change-Id: Id32bb40fe04eb9719d7e6cd367abb53118b21832
* Merge "javax.crypto.CipherSpi: port this class from jdk8u60"Sergio Giro2016-10-071-0/+133
|\
| * javax.crypto.CipherSpi: port this class from jdk8u60Sergio Giro2016-09-261-0/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes made upstream in CipherSpi#bufferCrypt(ByteBuffer input, ByteBuffer output) - when the input is not backed by an array, do not call get() for a chunk of size 0. This doesn't change behaviour, as for the size of the chunk to be 0, the size of the input must be 0, and this is checked earlier in the method (it returns early in that case). - do not call the "position" method when finishing reading from a buffer not backed by an array. - do not call put() when writing an output of size 0 to a buffer not backed by an array. Bug: 29631070 Test: vogar CipherSpiTest Change-Id: Id803bc6d9df0c1711f3cf7e5d49751bccd0e91b3
* | Treat TryFailThrowable error prone check as errorPaul Duffin2016-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | Enabling the option detected a problem in URLConnectionTest so this fixes that. Test: m -j -l32 javac-check-core-tests RUN_ERROR_PRONE=true run org.apache.harmony.luni.tests.java.net.URLConnectionTest test using vogar and CTS Bug: 31507496 Change-Id: Ie3f150e79fc1e58f812bf5c81181a68dae752271
* | Merge "Revert "Use JUnit 4 annotation instead of 'large' tag for CTSv2""Treehugger Robot2016-09-151-8/+4
|\ \
| * | Revert "Use JUnit 4 annotation instead of 'large' tag for CTSv2"Narayan Kamath2016-09-151-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 4e580f21a911ae25c437a62d8d724ae6b5c28282. Causing flakiness on the bots + vogar. bug: 30741591 Change-Id: Ic59750e65794d2ec95249a5e88a854d0a5dd3224
* | | Merge "ojluni: solve issues with exceptions in cipher-related streams"Sergio Giro2016-09-142-1/+185
|\ \ \ | |/ / |/| |
| * | ojluni: solve issues with exceptions in cipher-related streamsSergio Giro2016-09-132-1/+185
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Port from http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/8402ef8fabde Incorrect handling of exceptions and closed ciphers can result in problems with authentication. See http://bugs.java.com/view_bug.do?bug_id=7160837 - CipherOutputStream: when closing, avoid calling doFinal on the cipher (again) if the stream was already closed - DigestOutputStream: write to stream before updating the digest Note: CipherInputStream has been already updated in https://android-review.googlesource.com/#/c/249160/ Bug: 29631070 Test: vogar DigestOutputStream CipherOutputStream Change-Id: If4884d1ece21cfcb46e085a08b0910ee8b6cb2d3
* / Use JUnit 4 annotation instead of 'large' tag for CTSv2Tobias Thierer2016-09-131-4/+8
|/ | | | | | | | | | | | | | | | | | | | | | | | | | CTSv2 doesn't support tests tagged as 'large' having a larger timeout; therefore, the move to CTSv2 broke tests that do not reliably finish within 5min, such as DHPublicKeyTest. This CL converts the test to JUnit 4 in order to express the timeout via JUnit 4 annotations. It also removes DHPrivateKeyTest from the 'large' list without setting a custom timeout since that test is only using a 192bit rather than 1024bit key and is already much faster. The more general problem of cleaning up other tests marked as 'large' appears beyond this CL's scope and was not done. The fact that DHPublicKeyTest.test_getParams()'s run time is so large and so variable is not clear; we should investigate it in more detail when we have time. Bug: 30741591 Test: cts-tradefed run cts -m CtsLibcoreTestCases -t \ org.apache.harmony.crypto.tests.javax.crypto.interfaces.DHPublicKeyTest Test: Also ran DHPrivateKeyTest Change-Id: Ia64bef2325464b20e88cec71b1605848839bf546
* SignatureTest: make the mock MySignature publicSergio Giro2016-09-091-1/+3
| | | | | | | | | | Needs to be public as this is checked by the provider class when providing an instance Bug: 31387682 Test: run cts --class org.apache.harmony.security.tests.java.security.SignatureTest Change-Id: Iab669b585febfddfc5de373d58f44baddbf12b53
* Fix 58 libcore tests that caught "expected" Exceptions but didn't fail()Tobias Thierer2016-09-064-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There were no changes to code under test. 4 tests were fixed to not tolerate an Exception: - libcore.java.util.CollectionsTest#test_CheckedMap_computeIfAbsent In the case where a Map key is present, computeIfAbsent() should not invoke the Function, so there is no return value that could be expected to undergo a type check. The test was changed to verify that the Function is not invoked. - libcore.java.util.concurrent.CopyOnWriteArrayListTest#test_sort and libcore.java.util.concurrent.CopyOnWriteArrayListTest#test_subList_sort were sorting an already-sorted non-null list that contains no null values. That logic was redundant and wouldn't have thrown. - org.apache.harmony.security.tests.java.security.KeyStoreSpiTest#test_engineEntryInstanceOf (the KeyStoreSpi documentation does not mention whether NPE is thrown; the implementation comes from upstream and does not throw it). 54 tests were fixed by adding the missing fail(); No attempt was made to make this failure message specific to the exception that was expected. Tests that weren't changed: - SSLEngineTest.test_wrap_ByteBuffer_ByteBuffer_04() requires investigation to determine the correct resolution. A comment was added to the test linking to the corresponding bug. - ThreadTest#testParkUntilWithUnderflowValue() and OldNodeChangeEventTest.waitForEvent() were not touched since it was not clear whether that it was relevent to the test whether or not the exception was thrown. - two cases in Files2Test#test_setPosixFilePermissions_NPE() are left to a future CL Test: (croot; make vogar core-tests) \ && git diff aosp/master --name-only | xargs vogar `cparg core-tests` Change-Id: I1cd3220a06e331ff049b146b393f78879f07211a
* java.security: update java.security.KeyStore to jdk8u60Sergio Giro2016-08-304-0/+203
| | | | | | | | | | | | | | | | | | | | | | | | | Pulling upstream changes from OpenJDK version jdk8u60 for java.security.KeyStore. - New method getAttributes in KeyStore.Entry - New interface Attribute in KeyStore.Entry - New constructor specifying protection algorithm and protection parameters in KeyStore.PasswordProtection. - New getters for protection algorithm and protection parameters in KeyStore.PasswordProtection - In PrivateKeyEntry, SecretKeyEntry and TrustedCertificateEntry, new constructor allowing to specify attributes, and corresponding getter getAttributes. This commit also contains cosmetic JavaDoc changes like - Use of @code in place of <code> tags. - Tidied up casts/generics. This completes the port to jdk8u60 for this class. Change-Id: Ifec9d07b8f6c367a6fa2672fd5c43747057336ad Test: make droid docs, vogar KS*{Entry,Password}*.java Bug: 29631070
* javax.crypto.spec: update PBEParameterSpec to Java 8Sergio Giro2016-08-241-1/+25
| | | | | | | | | | | | | | Pulling upstream changes from OpenJDK version jdk8u60 for PBEParameterSpec. Added new constructor allowing an AlgorithmParameterSpec and the corresponding getter getParameterSpec. This CL finishes the port of this package. Change-Id: I02d463285e185fcb4031a5266d2857b1530159b7 Test: make droid docs, vogar PBEParameterSpecTest Bug: 29631070
* Remove expensive operations from constructorNeil Fuller2016-06-301-26/+23
| | | | | | | | CTS does a "dry run" of tests and some of what KeyStore3Test is doing looks expensive and can be moved to setUp(). Test: Ran the CTS tests Change-Id: I9fef983c4963de5db0fa2a732371658e1d32942f
* Tidy up MockWebServer usageNeil Fuller2016-06-291-0/+2
| | | | | | | | | Make sure that MockWebServer instances are shut down correctly after tests. Test: Ran the tests under CTS Bug: 29820565 Change-Id: I5455de018e2e6e3dd57cfc572becc93e0f566a26
* Port a number of OpenJDK8 stream methodsYi Kong2016-04-121-0/+40
| | | | | | | | | | | | | | Ports the following methods with tests: java.io.BufferedReader#lines java.util.BitSet#stream java.util.Random#doubles java.util.Random#ints java.util.Random#longs java.util.regex.Pattern#asPredicate java.util.regex.Pattern#splitAsStream Bug: 28108421 Change-Id: I4813221c69c207ba42ae306d231f3f7c807abbc6
* Add Iterable#forEach & Map#forEach from openJdk8Przemyslaw Szczepaniak2016-03-011-0/+33
| | | | | | | | Based on openJdk 8u40 source & iam@ stream change in ag/872080 Bug: 27404545 Change-Id: Ic67e20b35c24e7acce513e010b727510af09a83e
* Merge "ProviderServiceTest: change tests to check that newly created ↵Sergio Giro2016-01-251-4/+37
|\ | | | | | | services must be registered"
| * ProviderServiceTest: change tests to check that newly created services must ↵Sergio Giro2016-01-251-4/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | be registered In previous versions, you didn't need to register the service with the provider as long the provider was passed as a parameter when creating the service. Changing the tests to adapt to the new behaviour. Bug: 26517383 Change-Id: I25ddbbade99e57c428b4d1855e55d57ada1156e7
* | Merge "java/security: remove system.scope from security.properties"Sergio Giro2016-01-201-5/+5
|\ \
| * | java/security: remove system.scope from security.propertiesSergio Giro2016-01-191-5/+5
| |/ | | | | | | | | | | | | | | | | | | | | Fixes IdentityScopeTest accordingly and solves the bug tagged. Other bugs that will possibly benefit from this change (still not solved): 26517816 26590281 Bug: 26515695 Change-Id: I7a95da43c61b78f72a132dbe49e0f1b5c31f6137
* / IdentityTest/SignerTest: avoid using IdentityScope.getSystemScope()Sergio Giro2016-01-201-4/+9
|/ | | | | | | | There is no default system scope anymore. Bug: 26590281 Bug: 26517816 Change-Id: Icd3dd88bdf9c4525888a27652916a7323415453b
* Update bogus PatternSyntaxException test case.Narayan Kamath2016-01-061-2/+4
| | | | | | | | Providing an index but not a pattern doesn't make much sense so the output shouldn't either. bug: 26326992 Change-Id: Iec8868656366e89b6fb4c21bc86d4812db1a09a8
* Deleting unused or broken filesPaul Duffin2015-12-212-271/+0
| | | | | | | | | | | The tests removed from luni/src/test are testing files that no longer exist. It's possible that they provided some coverage of the code which is not provided for the OpenJDK code. The classes removed from ojluni/src/main are the ones not explicitly mentioned in the openjdk_java_files.mk. Change-Id: Id52d65d9b1f06e1a6e7afbd93336c7d12e0c3083
* Merge "ProviderTest: use the correct provider object when creating a ↵Sergio Giro2015-12-161-9/+9
|\ | | | | | | | | | | | | | | | | service" am: 2428e4b908 am: 762906e33e * commit '762906e33e88a9ee06a407fe21be5bad0c68ea74': ProviderTest: use the correct provider object when creating a service