Java Code Examples for java.util.Collections#checkedQueue()
The following examples show how to use
java.util.Collections#checkedQueue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckedQueue.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * This test tests the CheckedQueue.offer method. */ @Test public void testOffer() { ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1); Queue q = Collections.checkedQueue(abq, String.class); try { q.offer(null); fail("should throw NullPointerException."); } catch (NullPointerException npe) { // Do nothing } try { q.offer(0); fail("should throw ClassCastException."); } catch (ClassCastException cce) { // Do nothing } assertTrue(q.offer("0"), "queue should have room"); // no room at the inn! assertFalse(q.offer("1"), "queue should be full"); }
Example 2
Source File: CheckedQueue.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * This test adds items to a queue. */ @Test public void testAdd() { int arrayLength = 10; Queue<String> abq = Collections.checkedQueue(new ArrayBlockingQueue<>(arrayLength), String.class); for (int i = 0; i < arrayLength; i++) { abq.add(Integer.toString(i)); } try { abq.add("full"); } catch (IllegalStateException full) { } }
Example 3
Source File: CheckedQueue.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * This test adds items to a queue. */ @Test public void testAdd() { int arrayLength = 10; Queue<String> abq = Collections.checkedQueue(new ArrayBlockingQueue<>(arrayLength), String.class); for (int i = 0; i < arrayLength; i++) { abq.add(Integer.toString(i)); } try { abq.add("full"); } catch (IllegalStateException full) { } }
Example 4
Source File: CheckedQueue.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * This test tests the CheckedQueue.offer method. */ @Test public void testOffer() { ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1); Queue q = Collections.checkedQueue(abq, String.class); try { q.offer(null); fail("should throw NullPointerException."); } catch (NullPointerException npe) { // Do nothing } try { q.offer(0); fail("should throw ClassCastException."); } catch (ClassCastException cce) { // Do nothing } assertTrue(q.offer("0"), "queue should have room"); // no room at the inn! assertFalse(q.offer("1"), "queue should be full"); }
Example 5
Source File: CheckedQueue.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * This test adds items to a queue. */ @Test public void testAdd() { int arrayLength = 10; Queue<String> abq = Collections.checkedQueue(new ArrayBlockingQueue<>(arrayLength), String.class); for (int i = 0; i < arrayLength; i++) { abq.add(Integer.toString(i)); } try { abq.add("full"); } catch (IllegalStateException full) { } }
Example 6
Source File: CheckedQueue.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * This test tests the CheckedQueue.offer method. */ @Test public void testOffer() { ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1); Queue q = Collections.checkedQueue(abq, String.class); try { q.offer(null); fail("should throw NullPointerException."); } catch (NullPointerException npe) { // Do nothing } try { q.offer(0); fail("should throw ClassCastException."); } catch (ClassCastException cce) { // Do nothing } assertTrue(q.offer("0"), "queue should have room"); // no room at the inn! assertFalse(q.offer("1"), "queue should be full"); }
Example 7
Source File: CheckedQueue.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * This test tests the CheckedQueue.offer method. */ @Test public void testOffer() { ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1); Queue q = Collections.checkedQueue(abq, String.class); try { q.offer(null); fail("should throw NullPointerException."); } catch (NullPointerException npe) { // Do nothing } try { q.offer(0); fail("should throw ClassCastException."); } catch (ClassCastException cce) { // Do nothing } assertTrue(q.offer("0"), "queue should have room"); // no room at the inn! assertFalse(q.offer("1"), "queue should be full"); }
Example 8
Source File: CheckedQueue.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * This test adds items to a queue. */ @Test public void testAdd() { int arrayLength = 10; Queue<String> abq = Collections.checkedQueue(new ArrayBlockingQueue<>(arrayLength), String.class); for (int i = 0; i < arrayLength; i++) { abq.add(Integer.toString(i)); } try { abq.add("full"); } catch (IllegalStateException full) { } }
Example 9
Source File: CheckedQueue.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * This test tests the CheckedQueue.add method. It creates a queue of * {@code String}s gets the checked queue, and attempt to add an Integer to * the checked queue. */ private void test01() throws Exception { int arrayLength = 10; ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(arrayLength + 1); for (int i = 0; i < arrayLength; i++) { abq.add(new String(Integer.toString(i))); } Queue q = Collections.checkedQueue(abq, String.class); try { q.add(new Integer(0)); throw new Exception(this.getClass().getName() + "." + "test01 test" + " failed, should throw ClassCastException."); } catch(ClassCastException cce) { // Do nothing. } }
Example 10
Source File: CheckedQueue.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * This test tests the CheckedQueue.add method. It creates a queue of one * {@code String}, gets the checked queue, and attempt to add an Integer to * the checked queue. */ @Test(expectedExceptions = ClassCastException.class) public void testAddFail2() { ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1); Queue q = Collections.checkedQueue(abq, String.class); q.add(0); }
Example 11
Source File: CheckedQueue.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * This test tests the CheckedQueue.add method. It creates a queue of one * {@code String}, gets the checked queue, and attempt to add an Integer to * the checked queue. */ @Test(expectedExceptions = ClassCastException.class) public void testAddFail2() { ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1); Queue q = Collections.checkedQueue(abq, String.class); q.add(0); }
Example 12
Source File: CheckedQueue.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * This test tests the CheckedQueue.add method. It creates a queue of one * {@code String}, gets the checked queue, and attempt to add an Integer to * the checked queue. */ @Test(expectedExceptions = ClassCastException.class) public void testAddFail2() { ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1); Queue q = Collections.checkedQueue(abq, String.class); q.add(0); }
Example 13
Source File: CheckedQueue.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * This test tests the CheckedQueue.add method. It creates a queue of * {@code String}s gets the checked queue, and attempt to add an Integer to * the checked queue. */ @Test(expectedExceptions = ClassCastException.class) public void testAddFail1() { int arrayLength = 10; ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(arrayLength + 1); for (int i = 0; i < arrayLength; i++) { abq.add(Integer.toString(i)); } Queue q = Collections.checkedQueue(abq, String.class); q.add(0); }
Example 14
Source File: CheckedQueue.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * This test tests the CheckedQueue.offer method. */ private void test04() throws Exception { ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1); Queue q = Collections.checkedQueue(abq, String.class); try { q.offer(null); throw new Exception(this.getClass().getName() + "." + "test04 test" + " failed, should throw NullPointerException."); } catch (NullPointerException npe) { // Do nothing } try { q.offer(new Integer(0)); throw new Exception(this.getClass().getName() + "." + "test04 test" + " failed, should throw ClassCastException."); } catch (ClassCastException cce) { // Do nothing } q.offer(new String("0")); try { q.offer(new String("1")); throw new Exception(this.getClass().getName() + "." + "test04 test" + " failed, should throw IllegalStateException."); } catch(IllegalStateException ise) { // Do nothing } }
Example 15
Source File: CheckedQueue.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * This test tests the CheckedQueue.add method. It creates a queue of * {@code String}s gets the checked queue, and attempt to add an Integer to * the checked queue. */ @Test(expectedExceptions = ClassCastException.class) public void testAddFail1() { int arrayLength = 10; ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(arrayLength + 1); for (int i = 0; i < arrayLength; i++) { abq.add(Integer.toString(i)); } Queue q = Collections.checkedQueue(abq, String.class); q.add(0); }
Example 16
Source File: CheckedQueue.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * This test tests the CheckedQueue.add method. It creates a queue of * {@code String}s gets the checked queue, and attempt to add an Integer to * the checked queue. */ @Test(expectedExceptions = ClassCastException.class) public void testAddFail1() { int arrayLength = 10; ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(arrayLength + 1); for (int i = 0; i < arrayLength; i++) { abq.add(Integer.toString(i)); } Queue q = Collections.checkedQueue(abq, String.class); q.add(0); }
Example 17
Source File: CheckedQueue.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * This test tests the CheckedQueue.add method. It creates a queue of one * {@code String}, gets the checked queue, and attempt to add an Integer to * the checked queue. */ @Test(expectedExceptions = ClassCastException.class) public void testAddFail2() { ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1); Queue q = Collections.checkedQueue(abq, String.class); q.add(0); }
Example 18
Source File: CheckedQueue.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * This test tests the CheckedQueue.add method. It creates a queue of one * {@code String}, gets the checked queue, and attempt to add an Integer to * the checked queue. */ private void test02() throws Exception { ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1); Queue q = Collections.checkedQueue(abq, String.class); try { q.add(new Integer(0)); throw new Exception(this.getClass().getName() + "." + "test02 test" + " failed, should throw ClassCastException."); } catch(ClassCastException e) { // Do nothing. } }
Example 19
Source File: CheckedQueue.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * This test tests the CheckedQueue.offer method. */ private void test04() throws Exception { ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1); Queue q = Collections.checkedQueue(abq, String.class); try { q.offer(null); throw new Exception(this.getClass().getName() + "." + "test04 test" + " failed, should throw NullPointerException."); } catch (NullPointerException npe) { // Do nothing } try { q.offer(new Integer(0)); throw new Exception(this.getClass().getName() + "." + "test04 test" + " failed, should throw ClassCastException."); } catch (ClassCastException cce) { // Do nothing } q.offer(new String("0")); try { q.offer(new String("1")); throw new Exception(this.getClass().getName() + "." + "test04 test" + " failed, should throw IllegalStateException."); } catch(IllegalStateException ise) { // Do nothing } }
Example 20
Source File: CheckedQueue.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * This test tests the CheckedQueue.add method. It creates a queue of * {@code String}s gets the checked queue, and attempt to add an Integer to * the checked queue. */ @Test(expectedExceptions = ClassCastException.class) public void testAddFail1() { int arrayLength = 10; ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(arrayLength + 1); for (int i = 0; i < arrayLength; i++) { abq.add(Integer.toString(i)); } Queue q = Collections.checkedQueue(abq, String.class); q.add(0); }