Revision: 903
http://plexus.svn.sourceforge.net/plexus/?rev=903&view=rev
Author: rconner
Date: 2010-11-19 23:41:00 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Checking in some pending changes while I'm waiting for unit tests elsewhere to run....
Added an AbstractTask base class so that toString() is easy to specify.
Added a Matcher which matches if the argument Iterator.next() throws a NoSuchElementException.
Modified Paths:
--------------
trunk/plexus-graph/src/test/java/com/phoenixst/test/TaskMatchers.java
Modified: trunk/plexus-graph/src/test/java/com/phoenixst/test/TaskMatchers.java
===================================================================
--- trunk/plexus-graph/src/test/java/com/phoenixst/test/TaskMatchers.java 2010-10-20 17:01:27 UTC (rev 902)
+++ trunk/plexus-graph/src/test/java/com/phoenixst/test/TaskMatchers.java 2010-11-19 23:41:00 UTC (rev 903)
@@ -15,6 +15,9 @@
package com.phoenixst.test;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Factory;
@@ -28,10 +31,8 @@
*/
public final class TaskMatchers
{
-
static final ThreadLocal< String > FAILURE_STRING = new ThreadLocal< String >();
-
private TaskMatchers()
{
// prevent instantiation
@@ -39,6 +40,29 @@
@Factory
+ public static Matcher< Iterator< ? > > isDone()
+ {
+ return new BaseMatcher< Iterator< ? > >()
+ {
+ public boolean matches( Object obj )
+ {
+ try {
+ ((Iterator< ? >) obj).next();
+ } catch( NoSuchElementException e ) {
+ return true;
+ }
+ return false;
+ }
+
+ public void describeTo( Description description )
+ {
+ description.appendText( "Iterator should be exhausted " );
+ }
+ };
+ }
+
+
+ @Factory
public static < T > Matcher< T > can( final Task task )
{
return new BaseMatcher< T >()
@@ -108,4 +132,21 @@
public void execute( Object object ) throws Throwable;
}
+ public abstract static class AbstractTask
+ implements Task
+ {
+ private final String name;
+
+ public AbstractTask( String name )
+ {
+ this.name = name;
+ }
+
+ @Override
+ public String toString()
+ {
+ return name;
+ }
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|