Buggy code:
public class RequirementTest { @ Test public void testConsumerBundle ( ) throws Exception { String testClassFileName = ( TestClass . class . getName ( ) . replace ( '.' , '//' ) ) + ".class" ; URL testClassURL = getClass ( ) . getResource ( ( "//" + testClassFileName ) ) ; String test2ClassFileName = ( Test2Class . class . getName ( ) . replace ( '.' , '//' ) ) + ".class" ; URL test2ClassURL = getClass ( ) . getResource ( ( "//" + test2ClassFileName ) ) ; String test3ClassFileName = ( Test3Class . class . getName ( ) . replace ( '.' , '//' ) ) + ".class" ; URL test3ClassURL = getClass ( ) . getResource ( ( "//" + test3ClassFileName ) ) ; File jarFile = new File ( ( ( ( ( System . getProperty ( "java.io.tmpdir" ) ) + "//testjar_" ) + ( System . currentTimeMillis ( ) ) ) + ".jar" ) ) ; File expectedFile = null ; try { Manifest mf = new Manifest ( ) ; Attributes mainAttributes = mf . getMainAttributes ( ) ; mainAttributes . putValue ( "Manifest-Version" , "1.0" ) ; mainAttributes . putValue ( "Bundle-ManifestVersion" , "2.0" ) ; mainAttributes . putValue ( "Bundle-SymbolicName" , "testbundle" ) ; mainAttributes . putValue ( "Foo" , "Bar<seq2seq4repair_space>Bar" ) ; mainAttributes . putValue ( "Import-Package" , "org.foo.bar" ) ; mainAttributes . putValue ( REQUIRE_CAPABILITY , ( "osgi.serviceloader;<seq2seq4repair_space>filter:=\"(osgi.serviceloader=org.apache.aries.spifly.mysvc.SPIProvider)\";cardinality:=multiple," + "osgi.extender;<seq2seq4repair_space>filter:=\"(osgi.extender=osgi.serviceloader.processor)\"" ) ) ; JarOutputStream jos = new JarOutputStream ( new FileOutputStream ( jarFile ) , mf ) ; jos . putNextEntry ( new ZipEntry ( testClassFileName ) ) ; Streams . pump ( testClassURL . openStream ( ) , jos ) ; jos . putNextEntry ( new ZipEntry ( test2ClassFileName ) ) ; Streams . pump ( test2ClassURL . openStream ( ) , jos ) ; jos . putNextEntry ( new ZipEntry ( test3ClassFileName ) ) ; Streams . pump ( test3ClassURL . openStream ( ) , jos ) ; jos . close ( ) ; Main . main ( jarFile . getCanonicalPath ( ) ) ; expectedFile = new File ( jarFile . getParent ( ) , jarFile . getName ( ) . replaceAll ( "[.]jar" , "_spifly.jar" ) ) ; Assert . assertTrue ( "A<seq2seq4repair_space>processed<seq2seq4repair_space>separate<seq2seq4repair_space>bundle<seq2seq4repair_space>should<seq2seq4repair_space>have<seq2seq4repair_space>been<seq2seq4repair_space>created" , expectedFile . exists ( ) ) ; JarFile transformedJarFile = new JarFile ( expectedFile ) ; Manifest expectedMF = transformedJarFile . getManifest ( ) ; Assert . assertEquals ( "1.0" , expectedMF . getMainAttributes ( ) . getValue ( "Manifest-Version" ) ) ; Assert . assertEquals ( "2.0" , expectedMF . getMainAttributes ( ) . getValue ( "Bundle-ManifestVersion" ) ) ; Assert . assertEquals ( "testbundle" , expectedMF . getMainAttributes ( ) . getValue ( "Bundle-SymbolicName" ) ) ; Assert . assertEquals ( "Bar<seq2seq4repair_space>Bar" , expectedMF . getMainAttributes ( ) . getValue ( "Foo" ) ) ; <START_BUG> Assert . assertEquals ( "osgi.serviceloader;<seq2seq4repair_space>filter:=\"(osgi.serviceloader=org.apache.aries.spifly.mysvc.SPIProvider)\";cardinality:=multiple," , expectedMF . getMainAttributes ( ) . getValue ( REQUIRE_CAPABILITY ) ) ; <END_BUG> String importPackage = expectedMF . getMainAttributes ( ) . getValue ( "Import-Package" ) ; Assert . assertTrue ( ( ( "org.foo.bar,org.apache.aries.spifly;version=\"[1.0.0,1.1.0)\"" . equals ( importPackage ) ) || ( "org.apache.aries.spifly;version=\"[1.0.0,1.1.0)\",org.foo.bar" . equals ( importPackage ) ) ) ) ; JarFile initialJarFile = new JarFile ( jarFile ) ; byte [ ] orgBytes = Streams . suck ( initialJarFile . getInputStream ( new ZipEntry ( testClassFileName ) ) ) ; byte [ ] nonTransBytes = Streams . suck ( transformedJarFile . getInputStream ( new ZipEntry ( testClassFileName ) ) ) ; Assert . assertArrayEquals ( orgBytes , nonTransBytes ) ; byte [ ] orgBytes2 = Streams . suck ( initialJarFile . getInputStream ( new ZipEntry ( test2ClassFileName ) ) ) ; byte [ ] nonTransBytes2 = Streams . suck ( transformedJarFile . getInputStream ( new ZipEntry ( test2ClassFileName ) ) ) ; Assert . assertArrayEquals ( orgBytes2 , nonTransBytes2 ) ; byte [ ] orgBytes3 = Streams . suck ( initialJarFile . getInputStream ( new ZipEntry ( test3ClassFileName ) ) ) ; byte [ ] transBytes3 = Streams . suck ( transformedJarFile . getInputStream ( new ZipEntry ( test3ClassFileName ) ) ) ; Assert . assertFalse ( "The<seq2seq4repair_space>transformed<seq2seq4repair_space>class<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>different" , Arrays . equals ( orgBytes3 , transBytes3 ) ) ; initialJarFile . close ( ) ; transformedJarFile . close ( ) ; } finally { jarFile . delete ( ) ; if ( expectedFile != null ) expectedFile . delete ( ) ; } } }

Fix:
Assert . assertEquals ( "osgi.serviceloader;<seq2seq4repair_space>filter:=\"(osgi.serviceloader=org.apache.aries.spifly.mysvc.SPIProvider)\";cardinality:=multiple" , expectedMF . getMainAttributes ( ) . getValue ( REQUIRE_CAPABILITY ) ) ;