Skip to content

Commit

Permalink
FIX: Align messages with draft specification
Browse files Browse the repository at this point in the history
- swapped `MAN-1` and `MAN-4` so that the first matches the reporting in the spec.
  • Loading branch information
carlwilson committed Nov 21, 2023
1 parent eced1e0 commit aede51f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private List<Message> checkManifestEntries(final OdfPackage odfPackage) {
} else {
ZipEntry zipEntry = odfPackage.getZipArchive().getZipEntry(entryPath);
if (zipEntry == null) {
messages.add(FACTORY.getError("MAN-1", entryPath));
messages.add(FACTORY.getError("MAN-4", entryPath));
}
}
}
Expand All @@ -243,7 +243,7 @@ private final Map<String, List<Message>> auditZipEntries(final OdfPackage odfPac
continue;
}
if (manifest != null && odfPackage.getManifest().getEntry(zipEntry.getName()) == null) {
messages.add(FACTORY.getError("MAN-4", zipEntry.getName()));
messages.add(FACTORY.getError("MAN-1", zipEntry.getName()));
}
messageMap.put(zipEntry.getName(), messages);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ MIM-3 = The "mimetype" file SHALL NOT use an 'extra field' in its header.
MIM-4 = An OpenDocument package SHALL contain a mimetype file IF the manifest contains a <manifest:file-entry> element whose manifest:full-path attribute has the value \"/\".
MIM-5 = An OpenDocument package mimetype file content SHALL be equal to the manifest:media-type attribute of the manifest <manifest:file-entry> element whose manifest:full-path attribute has the value \"/\".
MIM-6 = The content of the "mimetype" file SHALL be ASCII encoded.
MAN-1 = The manifest SHALL contain an entry for every file in the package, manifest file entry %s has no corresponding zip entry.
MAN-1 = The manifest SHALL contain an entry for every file in the package, zip entry %s has no corresponding manifest file entry.
MAN-2 = An OpenDocument package manifest SHALL NOT contain a file entry for itself.
MAN-3 = An OpenDocument package manifest SHALL NOT contain a file entry the mimetype file.
MAN-4 = The manifest SHALL contain an entry for every file in the package, zip entry %s has no corresponding manifest file entry.
MAN-4 = The manifest SHALL contain an entry for every file in the package, manifest file entry %s has no corresponding zip entry.
MAN-5 = An OpenDocument package manifest SHALL contain a <manifest:file-entry> element whose manifest:full-path attribute has the value \"/\" if a mimetype file is present.
MAN-6 = The OpenDocument package manifest NEED NOT contain entries for file paths starting with META-INF/, %s.
MAN-7 = An OpenDocument package SHOULD contain a <manifest:file-entry> element whose manifest:full-path attribute has the value \"/\"".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void testMissingManifestEntry() throws ParserConfigurationException, SAXE
OdfPackage pkg = parser.parsePackage(TestFiles.MANIFEST_MISSING_ENTRY_ODS.openStream(), TestFiles.MANIFEST_MISSING_ENTRY_ODS.toString());
ValidationReport report = parser.validatePackage(pkg);
assertFalse("MANIFEST_MISSING_ENTRY_ODS should NOT be valid", report.isValid());
assertTrue(report.getMessages().stream().filter(m -> m.getId().equals("MAN-4")).count() > 0);
assertTrue(report.getMessages().stream().filter(m -> m.getId().equals("MAN-1")).count() > 0);
}

@Test
Expand All @@ -219,7 +219,7 @@ public void testMissingXmlEntry() throws ParserConfigurationException, SAXExcept
OdfPackage pkg = parser.parsePackage(TestFiles.MANIFEST_MISSING_XML_ENTRY_ODS.openStream(), TestFiles.MANIFEST_MISSING_XML_ENTRY_ODS.toString());
ValidationReport report = parser.validatePackage(pkg);
assertFalse("MANIFEST_MISSING_XML_ENTRY_ODS should NOT be valid", report.isValid());
assertTrue(report.getMessages().stream().filter(m -> m.getId().equals("MAN-4")).count() > 0);
assertTrue(report.getMessages().stream().filter(m -> m.getId().equals("MAN-1")).count() > 0);
}

@Test
Expand All @@ -228,7 +228,7 @@ public void testMissingFile() throws ParserConfigurationException, SAXException,
OdfPackage pkg = parser.parsePackage(TestFiles.MISSING_FILE_ODS.openStream(), TestFiles.MISSING_FILE_ODS.toString());
ValidationReport report = parser.validatePackage(pkg);
assertFalse("MISSING_FILE_ODS should NOT be valid", report.isValid());
assertTrue(report.getMessages().stream().filter(m -> m.getId().equals("MAN-1")).count() > 0);
assertTrue(report.getMessages().stream().filter(m -> m.getId().equals("MAN-4")).count() > 0);
}

@Test
Expand Down

0 comments on commit aede51f

Please sign in to comment.