private static void sanityCheck ( ) { List < TestContainerFactory > factories = new ArrayList < TestContainerFactory > ( ) ; Iterator < TestContainerFactory > iter = ServiceLoader . load ( TestContainerFactory . class ) . iterator ( ) ; while ( iter . hasNext ( ) ) { factories . add ( iter . next ( ) ) ; } if ( factories . size ( ) == 0 ) { throw new TestContainerException ( "No TestContainer implementation in Classpath" ) ; } else if ( factories . size ( ) > 1 ) { for ( TestContainerFactory fac : factories ) { LOG . error ( "Ambiguous TestContainer: " + fac . getClass ( ) . getName ( ) ) ; } throw new TestContainerException ( "Too many TestContainer implementations in Classpath" ) ; } else { // good! return ; } }
Exits with an exception if Classpath not set up properly .