import java.io.*; import java.util.jar.*; String[] wanted = { "a/ResultPrinter.class", "junit/textui/TestRunner.class", "b/Test.class", "b/TestCase.class", "junit/framework/Assert.class", }; String[] unwanted = { "junit/textui/ResultPrinter.class", "junit/framework/Test.class", "junit/framework/TestCase.class", }; JarFile jarFile = new JarFile( new File( basedir, "target/test-1.0.jar" ) ); for ( String path : wanted ) { if ( jarFile.getEntry( path ) == null ) { throw new IllegalStateException( "wanted path is missing: " + path ); } } for ( String path : unwanted ) { if ( jarFile.getEntry( path ) != null ) { throw new IllegalStateException( "unwanted path is present: " + path ); } } jarFile.close();