@Test
public void testParseExportString()
{

  String exportPackage = "com.acme.foo,com.acme.bar;version=1,com.acme.bar;version=2;uses:=\"a.b.c,d.e.f\";security=false;mandatory:=security";
  List<NameValuePair> exportPackageReturn = ManifestHeaderProcessor.parseExportString(exportPackage);
  int i =0;
  assertEquals("The number of the packages is wrong.", 3, exportPackageReturn.size());
  for (NameValuePair nvp : exportPackageReturn) {
    if (nvp.getName().equals("com.acme.foo")) {
      i++;
      assertTrue("The directive or attribute should not be set.", nvp.getAttributes().isEmpty() );
    } else if ((nvp.getName().equals("com.acme.bar")) && ("2".equals(nvp.getAttributes().get("version")))) {
      i++;
      assertEquals("The directive is wrong.", "a.b.c,d.e.f", nvp.getAttributes().get("uses:"));
      assertEquals("The directive is wrong.", "false", nvp.getAttributes().get("security"));
      assertEquals("The directive is wrong.", "security", nvp.getAttributes().get("mandatory:"));
    } else if ((nvp.getName().equals("com.acme.bar")) && ("1".equals(nvp.getAttributes().get("version")))) {
      i++;
      assertNull("The directive is wrong.", nvp.getAttributes().get("uses:"));
      assertNull("The directive is wrong.", nvp.getAttributes().get("security"));
      assertNull("The directive is wrong.", nvp.getAttributes().get("mandatory:"));
    }
  }
  // make sure all three packages stored
  assertEquals("The names of the packages are wrong.", 3, i);
  exportPackage = "com.acme.foo";
  exportPackageReturn = ManifestHeaderProcessor.parseExportString(exportPackage);
  int k =0;
  assertEquals("The number of the packages is wrong.", 1, exportPackageReturn.size());
  for (NameValuePair nvp : exportPackageReturn) {
    if (nvp.getName().equals("com.acme.foo")) {
      k++;
      assertTrue("The directive or attribute should not be set.", nvp.getAttributes().isEmpty() );
    }
  }
  assertEquals("The names of the packages are wrong.", 1, k);
  // test multiple packages separated by ;
  exportPackage = "com.acme.foo;com.acme.bar;version=\"2\";resolution:=optional";
  exportPackageReturn = ManifestHeaderProcessor.parseExportString(exportPackage);
  k =0;
  assertEquals("The number of the packages is wrong.", 2, exportPackageReturn.size());
  for (NameValuePair nvp : exportPackageReturn) {
    if (nvp.getName().equals("com.acme.foo")) {
      k++;
      assertEquals("The attribute is wrong.", "2", nvp.getAttributes().get("version") );
      assertEquals("The attribute is wrong.", "optional", nvp.getAttributes().get("resolution:"));
    } else if (nvp.getName().equals("com.acme.bar")) {
      k++;
      assertEquals("The attribute is wrong.", "2", nvp.getAttributes().get("version") );
      assertEquals("The attribute is wrong.", "optional", nvp.getAttributes().get("resolution:"));
    }
  }
  assertEquals("The names of the packages are wrong.", 2, k);
  exportPackageReturn = ManifestHeaderProcessor.parseExportString("some.export.with.space.in;directive := spacey");
  assertEquals(exportPackageReturn.toString(), "spacey", exportPackageReturn.get(0).getAttributes().get("directive:"));
}