< prev index next >

core/tests/org.openjdk.jmc.common.test/src/test/java/org/openjdk/jmc/common/util/BoundedListTest.java

Print this page

        

*** 150,163 **** } @Test public void testEmptyIterator() { BoundedList<Integer> bl = new BoundedList<>(10); ! assertFalse("Empty list should have no elements!", bl.iterator().hasNext()); //$NON-NLS-1$ try { bl.iterator().next(); ! fail("next should have generated an exception!"); //$NON-NLS-1$ } catch (NoSuchElementException el) { // Fall through... } } --- 150,163 ---- } @Test public void testEmptyIterator() { BoundedList<Integer> bl = new BoundedList<>(10); ! assertFalse("Empty list should have no elements!", bl.iterator().hasNext()); try { bl.iterator().next(); ! fail("next should have generated an exception!"); } catch (NoSuchElementException el) { // Fall through... } }
*** 192,230 **** @Test public void testMultiThreadedConsumption() throws InterruptedException { final BoundedList<Long> bl = new BoundedList<>(20); ProducerThread t = new ProducerThread(bl); ValidationThread[] validators = new ValidationThread[10]; ! new Thread(t, "Producer").start(); //$NON-NLS-1$ for (int i = 0; i < validators.length; i++) { validators[i] = new ValidationThread(bl); ! new Thread(validators[i], "Validator " + i).start(); //$NON-NLS-1$ } Thread.sleep(30000); for (ValidationThread validator : validators) { validator.stop(); } t.stop(); long maxNo = 0; for (ValidationThread validator : validators) { ! assertEquals("Failed count validation!", -1, validator.countError); //$NON-NLS-1$ ! assertEquals("Failed sequence validation!", -1, validator.sequenceError); //$NON-NLS-1$ maxNo = Math.max(maxNo, validator.maxNum); } ! System.out.println("Allocated up to " + t.counter); //$NON-NLS-1$ ! System.out.println("Max no was " + maxNo); //$NON-NLS-1$ } // FIXME: This test has been commented out for a long time. Check if it is still relevant and either remove or reintroduce it. // @Category(value = SlowTests.class) // @Test // public void testNoLeak() { // BoundedList<Long> bl = new BoundedList<Long>(10); // // Adding a few billion numbers, just to show that we do not leak under normal circumstances... // for (long i = 1; i <= Integer.MAX_VALUE; i++) { // if (i % (Integer.MAX_VALUE / 20) == 0) { ! // System.out.println(String.format("Passed %.0f%%", (i * 100f) / Integer.MAX_VALUE)); //$NON-NLS-1$ // } // bl.add(i); // } // // On a 32-bit platform we should either crash or pass... // } --- 192,230 ---- @Test public void testMultiThreadedConsumption() throws InterruptedException { final BoundedList<Long> bl = new BoundedList<>(20); ProducerThread t = new ProducerThread(bl); ValidationThread[] validators = new ValidationThread[10]; ! new Thread(t, "Producer").start(); for (int i = 0; i < validators.length; i++) { validators[i] = new ValidationThread(bl); ! new Thread(validators[i], "Validator " + i).start(); } Thread.sleep(30000); for (ValidationThread validator : validators) { validator.stop(); } t.stop(); long maxNo = 0; for (ValidationThread validator : validators) { ! assertEquals("Failed count validation!", -1, validator.countError); ! assertEquals("Failed sequence validation!", -1, validator.sequenceError); maxNo = Math.max(maxNo, validator.maxNum); } ! System.out.println("Allocated up to " + t.counter); ! System.out.println("Max no was " + maxNo); } // FIXME: This test has been commented out for a long time. Check if it is still relevant and either remove or reintroduce it. // @Category(value = SlowTests.class) // @Test // public void testNoLeak() { // BoundedList<Long> bl = new BoundedList<Long>(10); // // Adding a few billion numbers, just to show that we do not leak under normal circumstances... // for (long i = 1; i <= Integer.MAX_VALUE; i++) { // if (i % (Integer.MAX_VALUE / 20) == 0) { ! // System.out.println(String.format("Passed %.0f%%", (i * 100f) / Integer.MAX_VALUE)); // } // bl.add(i); // } // // On a 32-bit platform we should either crash or pass... // }
< prev index next >