### Question:
ManifestUtils { public static String getManifestInformation(Class<?> target) throws ManipulationException { String result = ""; if (target == null) { throw new ManipulationException( "No target specified." ); } try { final CodeSource cs = target.getProtectionDomain().getCodeSource(); if ( cs == null ) { logger.debug( "Unable to retrieve manifest for {} as CodeSource was null for the protection domain ({})", target, target.getProtectionDomain() ); } else { final URL jarUrl = cs.getLocation(); if ( new File( jarUrl.getPath() ).isDirectory() ) { logger.debug( "Unable to retrieve manifest for {} as location is a directory not a jar ({})", target, jarUrl.getPath() ); } else { try (JarInputStream jarStream = new JarInputStream( jarUrl.openStream() )) { final Manifest manifest = jarStream.getManifest(); result = manifest.getMainAttributes().getValue( "Implementation-Version" ); result += " ( SHA: " + manifest.getMainAttributes().getValue( "Scm-Revision" ) + " )"; } } } } catch ( final IOException e ) { throw new ManipulationException( "Error retrieving information from manifest", e ); } return result; }  static String getManifestInformation(Class<?> target);  }### Answer:
@Test public void testNoClass() { try { ManifestUtils.getManifestInformation( null ); fail("No exception thrown"); } catch (ManipulationException e) { assertTrue( e.getMessage().contains( "No target specified" ) ); } }
@Test public void testThisClass() throws ManipulationException { ManifestUtils.getManifestInformation( ManifestUtilsTest.class ); assertTrue( systemRule.getLog() .contains( "Unable to retrieve manifest for class " + "org.commonjava.maven.ext.common.util.ManifestUtilsTest as " + "location is a directory not a jar" ) ); }
@Test public void testThirdPartyClass() throws ManipulationException { String result = ManifestUtils.getManifestInformation( Model.class ); assertTrue( result.contains( "3.5.0 ( SHA: null )" ) ); }
@Test public void testJarClass() throws ManipulationException { String m = ManifestUtils.getManifestInformation( Test.class ); assertTrue( m.contains( "4" ) ); }