try {
InputStream in = new FileInputStream(containerSignatures);
ContainerSignatureSaxParser parser = new ContainerSignatureSaxParser();
containerSignatureDefinitions = parser.parse(in);
} catch (SignatureParseException e) {
throw new CommandExecutionException ("Can't parse container signature file");
} catch (Exception e) {
throw new CommandExecutionException(e);
}
ole2ContainerContentIdentifier.init(containerSignatureDefinitions, "OLE2");
object = ole2ContainerContentIdentifier.getContainerIdentifierInit();
assertEquals(object.getClass(), containerIdentifierInit.getClass());
object = ole2ContainerContentIdentifier.getFormats();
assertEquals(object.getClass(), formats.getClass());
String fileName;
File file = new File(ole2File);
if (!file.exists()) {
fail("OLE2 test file not found");
}
URI uri = file.toURI();
RequestIdentifier identifier = new RequestIdentifier(uri);
identifier.setParentId(1L);
try {
fileName = file.getCanonicalPath();
RequestMetaData metaData =
new RequestMetaData(file.length(), file.lastModified(), fileName);
FileSystemIdentificationRequest request =
new FileSystemIdentificationRequest(metaData, identifier);
IdentificationResultCollection results =
new IdentificationResultCollection(request);
InputStream ole2Stream = new FileInputStream(file);
request.open(ole2Stream);
results = ole2ContainerContentIdentifier.process(request.getSourceInputStream(), results);
if (results.getResults().isEmpty()) {
fail("OLE2 file not identified");
}
String fmtExpected = "";
for (IdentificationResult identResult : results.getResults()) {
if (identResult.getPuid().equals("fmt/40")) {
fmtExpected = identResult.getPuid();
}
}
assertEquals(fmtExpected, "fmt/40");
} catch (IOException e) {
throw new CommandExecutionException(e);
}
}