KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jaxen > util > SingleObjectIteratorTest


1 /* $Header$
2  * $Revision$
3  * $Date$
4  *
5  * ====================================================================
6  *
7  * Copyright (C) 2005 Elliotte Rusty Harold.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright
15  * notice, this list of conditions, and the following disclaimer.
16  *
17  * 2. Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions, and the disclaimer that follows
19  * these conditions in the documentation and/or other materials
20  * provided with the distribution.
21  *
22  * 3. The name "Jaxen" must not be used to endorse or promote products
23  * derived from this software without prior written permission. For
24  * written permission, please contact license@jaxen.org.
25  *
26  * 4. Products derived from this software may not be called "Jaxen", nor
27  * may "Jaxen" appear in their name, without prior written permission
28  * from the Jaxen Project Management (pm@jaxen.org).
29  *
30  * In addition, we request (but do not require) that you include in the
31  * end-user documentation provided with the redistribution and/or in the
32  * software itself an acknowledgement equivalent to the following:
33  * "This product includes software developed by the
34  * Jaxen Project (http://www.jaxen.org/)."
35  * Alternatively, the acknowledgment may be graphical using the logos
36  * available at http://www.jaxen.org/
37  *
38  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41  * DISCLAIMED. IN NO EVENT SHALL THE Jaxen AUTHORS OR THE PROJECT
42  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  *
51  * ====================================================================
52  * This software consists of voluntary contributions made by many
53  * individuals on behalf of the Jaxen Project and was originally
54  * created by bob mcwhirter <bob@werken.com> and
55  * James Strachan <jstrachan@apache.org>. For more information on the
56  * Jaxen Project, please see <http://www.jaxen.org/>.
57  *
58  * $Id$
59  */

60 package org.jaxen.util;
61
62 import java.util.Iterator JavaDoc;
63 import java.util.NoSuchElementException JavaDoc;
64
65 import junit.framework.TestCase;
66
67 public class SingleObjectIteratorTest extends TestCase {
68
69     private Iterator JavaDoc iterator = new SingleObjectIterator(new Object JavaDoc());
70     
71     public void testNoInfiniteLoops() {
72      
73         iterator.next();
74         try {
75             iterator.next();
76             fail("Iterated twice");
77         }
78         catch (NoSuchElementException JavaDoc ex) {
79         }
80         
81     }
82     
83     
84     public void testRemove() {
85         
86         try {
87             iterator.remove();
88             fail("Removed from iterator");
89         }
90         catch (UnsupportedOperationException JavaDoc ex) {
91         }
92         
93     }
94     
95 }
96
Popular Tags