jdk/test/java/util/Collections/CheckedQueue.java
author mduigou
Wed, 19 Oct 2011 14:17:47 -0700
changeset 10790 331fdf9a8824
child 25177 487a5e71f6dd
permissions -rw-r--r--
5029031: Add Collections.checkedQueue() Reviewed-by: mduigou Contributed-by: darryl.mocek@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10790
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
     1
/*
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
     4
 *
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
     7
 * published by the Free Software Foundation.
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
     8
 *
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    13
 * accompanied this code).
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    14
 *
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    18
 *
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    21
 * questions.
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    22
 */
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    23
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    24
/*
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    25
 * @test
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    26
 * @bug 5020931
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    27
 * @summary Unit test for Collections.checkedQueue
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    28
 */
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    29
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    30
import java.lang.reflect.Method;
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    31
import java.util.Collections;
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    32
import java.util.Iterator;
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    33
import java.util.Queue;
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    34
import java.util.concurrent.ArrayBlockingQueue;
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    35
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    36
public class CheckedQueue {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    37
    static int status = 0;
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    38
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    39
    public static void main(String[] args) throws Exception {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    40
        new CheckedQueue();
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    41
    }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    42
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    43
    public CheckedQueue() throws Exception {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    44
        run();
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    45
    }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    46
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    47
    private void run() throws Exception {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    48
        Method[] methods = this.getClass().getDeclaredMethods();
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    49
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    50
        for (int i = 0; i < methods.length; i++) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    51
            Method method = methods[i];
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    52
            String methodName = method.getName();
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    53
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    54
            if (methodName.startsWith("test")) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    55
                try {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    56
                    Object obj = method.invoke(this, new Object[0]);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    57
                } catch(Exception e) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    58
                    throw new Exception(this.getClass().getName() + "." +
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    59
                            methodName + " test failed, test exception "
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    60
                            + "follows\n" + e.getCause());
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    61
                }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    62
            }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    63
        }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    64
    }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    65
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    66
    /**
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    67
     * This test adds items to a queue.
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    68
     */
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    69
    private void test00() {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    70
        int arrayLength = 10;
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    71
        ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(arrayLength);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    72
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    73
        for (int i = 0; i < arrayLength; i++) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    74
            abq.add(new String(Integer.toString(i)));
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    75
        }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    76
    }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    77
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    78
    /**
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    79
     * This test tests the CheckedQueue.add method.  It creates a queue of
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    80
     * {@code String}s gets the checked queue, and attempt to add an Integer to
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    81
     * the checked queue.
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    82
     */
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    83
    private void test01() throws Exception {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    84
        int arrayLength = 10;
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    85
        ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(arrayLength + 1);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    86
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    87
        for (int i = 0; i < arrayLength; i++) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    88
            abq.add(new String(Integer.toString(i)));
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    89
        }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    90
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    91
        Queue q = Collections.checkedQueue(abq, String.class);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    92
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    93
        try {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    94
            q.add(new Integer(0));
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    95
            throw new Exception(this.getClass().getName() + "." + "test01 test"
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    96
                    + " failed, should throw ClassCastException.");
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    97
        } catch(ClassCastException cce) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    98
            // Do nothing.
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
    99
        }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   100
    }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   101
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   102
    /**
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   103
     * This test tests the CheckedQueue.add method.  It creates a queue of one
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   104
     * {@code String}, gets the checked queue, and attempt to add an Integer to
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   105
     * the checked queue.
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   106
     */
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   107
    private void test02() throws Exception {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   108
        ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   109
        Queue q = Collections.checkedQueue(abq, String.class);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   110
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   111
        try {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   112
            q.add(new Integer(0));
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   113
            throw new Exception(this.getClass().getName() + "." + "test02 test"
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   114
                    + " failed, should throw ClassCastException.");
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   115
        } catch(ClassCastException e) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   116
            // Do nothing.
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   117
        }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   118
    }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   119
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   120
    /**
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   121
     * This test tests the Collections.checkedQueue method call for nulls in
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   122
     * each and both of the parameters.
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   123
     */
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   124
    private void test03() throws Exception {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   125
        ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   126
        Queue q;
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   127
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   128
        try {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   129
            q = Collections.checkedQueue(null, String.class);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   130
            throw new Exception(this.getClass().getName() + "." + "test03 test"
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   131
                    + " failed, should throw NullPointerException.");
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   132
        } catch(NullPointerException npe) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   133
            // Do nothing
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   134
        }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   135
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   136
        try {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   137
            q = Collections.checkedQueue(abq, null);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   138
            throw new Exception(this.getClass().getName() + "." + "test03 test"
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   139
                    + " failed, should throw NullPointerException.");
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   140
        } catch(Exception e) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   141
            // Do nothing
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   142
        }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   143
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   144
        try {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   145
            q = Collections.checkedQueue(null, null);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   146
            throw new Exception(this.getClass().getName() + "." + "test03 test"
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   147
                    + " failed, should throw NullPointerException.");
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   148
        } catch(Exception e) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   149
            // Do nothing
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   150
        }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   151
    }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   152
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   153
    /**
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   154
     * This test tests the CheckedQueue.offer method.
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   155
     */
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   156
    private void test04() throws Exception {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   157
        ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   158
        Queue q = Collections.checkedQueue(abq, String.class);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   159
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   160
        try {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   161
            q.offer(null);
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   162
            throw new Exception(this.getClass().getName() + "." + "test04 test"
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   163
                    + " failed, should throw NullPointerException.");
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   164
        } catch (NullPointerException npe) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   165
            // Do nothing
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   166
        }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   167
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   168
        try {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   169
            q.offer(new Integer(0));
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   170
            throw new Exception(this.getClass().getName() + "." + "test04 test"
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   171
                    + " failed, should throw ClassCastException.");
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   172
        } catch (ClassCastException cce) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   173
            // Do nothing
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   174
        }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   175
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   176
        q.offer(new String("0"));
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   177
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   178
        try {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   179
            q.offer(new String("1"));
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   180
            throw new Exception(this.getClass().getName() + "." + "test04 test"
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   181
                    + " failed, should throw IllegalStateException.");
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   182
        } catch(IllegalStateException ise) {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   183
            // Do nothing
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   184
        }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   185
    }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   186
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   187
    private void test05() {
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   188
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   189
    }
331fdf9a8824 5029031: Add Collections.checkedQueue()
mduigou
parents:
diff changeset
   190
}