### Question:
ManifestUpdaterImpl implements ManifestUpdater { @Override public void write( java.util.jar.Manifest originalManifest, OutputStream outputStream, String name, String symbolicName, String version ) throws IOException { java.util.jar.Manifest newManifest = new java.util.jar.Manifest(); if ( originalManifest != null ) { newManifest = new java.util.jar.Manifest( originalManifest ); } Attributes mainAttributes = newManifest.getMainAttributes(); for ( Map.Entry<Object, Object> entry : entries.entrySet() ) { mainAttributes.putValue( entry.getKey().toString(), entry.getValue().toString() ); } mainAttributes.putValue( "Manifest-Version", "1.0" ); mainAttributes.putValue( "Bundle-ManifestVersion", "2" ); mainAttributes.putValue( "Bundle-SymbolicName", bundleName != null ? bundleName : symbolicName ); mainAttributes.putValue( "Bundle-Name", name ); mainAttributes.putValue( "Bundle-Version", version ); mainAttributes.putValue( "Bundle-PlatformPluginName", symbolicName ); mainAttributes .putValue( "Export-Service", join( getExportServices(), "," ) ); mainAttributes .putValue( "Import-Package", getImportString() ); mainAttributes.putValue( "DynamicImport-Package", "*" ); newManifest.write( outputStream ); } ManifestUpdaterImpl(); @Override void setBundleSymbolicName( String name ); @Override String getBundleSymbolicName(); @Override Map<String, String> getImports(); @Override Set<String> getExportServices(); @Override void addEntry( Object key, Object value ); @Override void write( java.util.jar.Manifest originalManifest, OutputStream outputStream, String name,
                               String symbolicName, String version );  }### Answer:
@Test public void testWriteNoOriginalManifest() throws IOException { ManifestUpdaterImpl manifestUpdater = new ManifestUpdaterImpl(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream( ); manifestUpdater.write( null, byteArrayOutputStream, "test", "test.symbolic", "version" ); Manifest manifest = new Manifest( new ByteArrayInputStream( byteArrayOutputStream.toByteArray() ) ); assertEquals( "test.symbolic", manifest.getMainAttributes().getValue( "Bundle-SymbolicName" ) ); assertEquals( "test", manifest.getMainAttributes().getValue( "Bundle-Name" ) ); assertEquals( "version", manifest.getMainAttributes().getValue( "Bundle-Version" ) ); }
@Test public void testWriteOriginalManifest() throws IOException { ManifestUpdaterImpl manifestUpdater = new ManifestUpdaterImpl(); Manifest original = new Manifest( ); original.getMainAttributes().putValue( "test", "ing" ); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream( ); manifestUpdater.write( original, byteArrayOutputStream, "test", "test.symbolic", "version" ); Manifest manifest = new Manifest( new ByteArrayInputStream( byteArrayOutputStream.toByteArray() ) ); assertEquals( "test.symbolic", manifest.getMainAttributes().getValue( "Bundle-SymbolicName" ) ); assertEquals( "test", manifest.getMainAttributes().getValue( "Bundle-Name" ) ); assertEquals( "version", manifest.getMainAttributes().getValue( "Bundle-Version" ) ); assertEquals( "version", manifest.getMainAttributes().getValue( "Bundle-Version" ) ); }