test/java/util/Collection/ListDefaults.java updates

Chris Hegarty chris.hegarty at oracle.com
Mon May 13 17:06:08 UTC 2013


Thanks Akhil, let me flesh it out a little more and send a formal webrev.

-Chris.

On 05/13/2013 05:58 PM, Akhil Arora wrote:
> Looks good to me. I have had to add similar print statements when
> debugging, but I deleted them before committing, to keep the default
> test output clean.
>
> Minor - it would be good to have a little more consistency... some tests
> print the class name always, some only on failure. Also would be good to
> have similar changes in the CollectionDefaults and IteratorDefaults tests.
>
> On 05/13/2013 06:25 AM, Chris Hegarty wrote:
>> Akil, Mike,
>>
>> I've recently been diagnosing failures with ListDefaults.java, when
>> working on a separate issue. I found it difficult to determine which
>> collection type was having problems, in some failure cases.
>>
>> The diffs below are what I had to implement in my local repo to help
>> identify the cause of several failures. It is probably not complete in
>> terms of updating all the possible error conditions, but what I have
>> sitting in my local repo, and possibly useful.
>>
>> If you agree with the changes, I can file a bug and push them.
>>
>> diff --git a/test/java/util/Collection/ListDefaults.java
>> b/test/java/util/Collection/ListDefaults.java
>> old mode 100644
>> new mode 100755
>> --- a/test/java/util/Collection/ListDefaults.java
>> +++ b/test/java/util/Collection/ListDefaults.java
>> @@ -117,17 +117,18 @@ public class ListDefaults {
>>
>>       @Test(dataProvider = "listProvider")
>>       public void testProvidedWithNull(final List<Integer> list) throws
>> Exception {
>> +        final String cn = list.getClass().getName();
>>           try {
>>               list.forEach(null);
>> -            fail("expected NPE not thrown");
>> +            fail("expected NPE not thrown; " + cn + ".forEach()");
>>           } catch (NullPointerException npe) {}
>>           try {
>>               list.replaceAll(null);
>> -            fail("expected NPE not thrown");
>> +            fail("expected NPE not thrown; " + cn + ".replaceAll()");
>>           } catch (NullPointerException npe) {}
>>           try {
>>               list.removeIf(null);
>> -            fail("expected NPE not thrown");
>> +            fail("expected NPE not thrown; " + cn + ".removeIf()");
>>           } catch (NullPointerException npe) {}
>>       }
>>
>> @@ -183,8 +184,9 @@ public class ListDefaults {
>>               final List<Integer> list = ((List<Integer>)
>> test.collection);
>>
>>               try {
>> +                final String cn = list.getClass().getName();
>>                   list.removeIf(null);
>> -                fail("expected NPE not thrown");
>> +                fail("expected NPE not thrown;" + cn + ".removeIf()");
>>               } catch (NullPointerException npe) {}
>>               CollectionAsserts.assertContents(list, original);
>>
>> @@ -215,10 +217,12 @@ public class ListDefaults {
>>               final List<Integer> list = ((List<Integer>)
>> test.collection);
>>               final List<Integer> listCopy = new ArrayList<>(list);
>>               if (original.size() > SUBLIST_SIZE) {
>> +                System.out.println("Testcase.name: " + test.name + ",
>> classname:" + test.className);
>>                   final List<Integer> subList =
>> list.subList(SUBLIST_FROM, SUBLIST_TO);
>>                   final List<Integer> subListCopy = new
>> ArrayList<>(subList);
>>                   listCopy.removeAll(subList);
>>                   subList.removeIf(pOdd);
>> +                System.out.println("Testcase.name: " + test.name + ",
>> classname:" + test.className + " COMPLETE");
>>                   for (int i : subList) {
>>                       assertTrue((i % 2) == 0);
>>                   }
>> @@ -274,8 +278,9 @@ public class ListDefaults {
>>               final List<Integer> list = ((List<Integer>)
>> test.collection);
>>
>>               try {
>> +                final String cn = list.getClass().getName();
>>                   list.replaceAll(null);
>> -                fail("expected NPE not thrown");
>> +                fail("expected NPE not thrown;" + cn + ".replaceAll()");
>>               } catch (NullPointerException npe) {}
>>               CollectionAsserts.assertContents(list, original);
>>
>> -Chris.
>



More information about the core-libs-dev mailing list