I'm creating a unit test for a code that generates an archive based on a jar and I'm trying to compare the generated manifest file with an existing test resource using the code below:
Manifest smActual = new Manifest(jar.getInputStream(
dpzip.getEntry(Constants.MANIFEST_LOCATION));
Manifest smExpected = new Manifest(
new FileInputStream(expected.toFile()))
assertTrue(smActual.equals(smExpected));
The problem is that the assert is always failing. Even if I compare the smExpected file with itself.
The manifest looks like the one below. Note it has two sections:
Manifest-Version: 1.0
Package-Name: it-project--normal
Package-Version: 0.1.0
Name: plugins/dependency-2.4.0.jar
Bundle-Version: 2.4.0
Bundle-SymbolicName: org.dependency
Name: plugins/anotherBundle.jar
Bundle-SymbolicName: org.anotherBundle
Bundle-Version: 1.0.0
I did some debug and I'm getting a failure in the assertion bellow:
Attributes att1 = smExpected
.getAttributes("plugins/dependency-2.4.0.jar");
Attributes att2 = smActual
.getAttributes("plugins/dependency-2.4.0.jar");
assertTrue(att1.values().equals(att2.values()));
But it passed with:
assertThat(smActual.getMainAttributes(), equalTo(smExpected.getMainAttributes()));
my environment is:
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
Linux ubuntu 3.13.0-74-generic #118-Ubuntu SMP Thu Dec 17 22:52:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux