[Japi-cvs] SF.net SVN: japi: [504] libs/lang/trunk/src/test/net/sf/japi/lang/ SuperClassIteratorTes
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2007-07-06 21:03:28
|
Revision: 504 http://svn.sourceforge.net/japi/?rev=504&view=rev Author: christianhujer Date: 2007-07-06 14:03:25 -0700 (Fri, 06 Jul 2007) Log Message: ----------- Added test cases for Iterable working and remove() throwing UnsupportedOperationException. Modified Paths: -------------- libs/lang/trunk/src/test/net/sf/japi/lang/SuperClassIteratorTest.java Modified: libs/lang/trunk/src/test/net/sf/japi/lang/SuperClassIteratorTest.java =================================================================== --- libs/lang/trunk/src/test/net/sf/japi/lang/SuperClassIteratorTest.java 2007-07-06 20:51:32 UTC (rev 503) +++ libs/lang/trunk/src/test/net/sf/japi/lang/SuperClassIteratorTest.java 2007-07-06 21:03:25 UTC (rev 504) @@ -19,10 +19,10 @@ package test.net.sf.japi.lang; +import java.util.NoSuchElementException; import net.sf.japi.lang.SuperClassIterator; +import org.junit.Assert; import org.junit.Test; -import org.junit.Assert; -import java.util.NoSuchElementException; /** Test for {@link SuperClassIterator}. * Created by IntelliJ IDEA. @@ -31,8 +31,9 @@ */ public class SuperClassIteratorTest { - /** Tests whether iterating the superclasses works. */ - @Test public void testIteration() { + /** Tests that iterating the superclasses works. */ + @Test + public void testIteration() { final SuperClassIterator it = new SuperClassIterator(String.class); Assert.assertTrue("Must have next.", it.hasNext()); Assert.assertEquals("First class must be String.class.", String.class, it.next()); @@ -41,19 +42,38 @@ Assert.assertFalse("Must not have next now.", it.hasNext()); } - /** Tests whether iterating the superclasses works. */ - @Test public void testException() { + /** Tests that iterating the superclasses works. */ + @Test + public void testException() { final SuperClassIterator it = new SuperClassIterator(String.class); it.next(); it.next(); } - /** Tests whether iterating the superclasses works. */ - @Test(expected = NoSuchElementException.class) public void testException2() { + /** Tests that iterating the superclasses works. */ + @Test(expected = NoSuchElementException.class) + public void testException2() { final SuperClassIterator it = new SuperClassIterator(String.class); it.next(); it.next(); it.next(); } + /** Tests that {@link SuperClassIterator#remove()} throws an exception. */ + @Test(expected = UnsupportedOperationException.class) + public void testRemove() { + final SuperClassIterator it = new SuperClassIterator(String.class); + it.remove(); + } + + /** Tests that using {@link SuperClassIterator} as Iterable works. */ + @Test + public void testIterable() { + for (final Class c : new SuperClassIterator(String.class)) { + if (!c.equals(String.class) && !c.equals(Object.class)) { + Assert.assertTrue("Expected String.class or Object.class.", false); + } + } + } + } // class SuperClassIteratorTest This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |