use of org.apache.poi.hpsf.MarkUnsupportedException in project poi by apache.
the class TestEmptyProperties method testCreatePropertySets.
/**
* <p>Tests whether property sets can be created from the POI
* files in the POI file system. This test case expects the first
* file to be a {@link SummaryInformation}, the second file to be
* a {@link DocumentSummaryInformation} and the rest to be no
* property sets. In the latter cases a {@link
* NoPropertySetStreamException} will be thrown when trying to
* create a {@link PropertySet}.</p>
*
* @exception IOException if an I/O exception occurs.
*
* @exception UnsupportedEncodingException if a character encoding is not
* supported.
*/
@Test
public void testCreatePropertySets() throws UnsupportedEncodingException, IOException {
Class<?>[] expected = { NoPropertySetStreamException.class, SummaryInformation.class, NoPropertySetStreamException.class };
for (int i = 0; i < expected.length; i++) {
InputStream in = new ByteArrayInputStream(poiFiles.get(i).getBytes());
Object o;
try {
o = PropertySetFactory.create(in);
} catch (NoPropertySetStreamException ex) {
o = ex;
} catch (MarkUnsupportedException ex) {
o = ex;
}
in.close();
assertEquals(o.getClass(), expected[i]);
}
}
use of org.apache.poi.hpsf.MarkUnsupportedException in project poi by apache.
the class TestBasic method testCreatePropertySets.
/**
* <p>Tests whether property sets can be created from the POI
* files in the POI file system. This test case expects the first
* file to be a {@link SummaryInformation}, the second file to be
* a {@link DocumentSummaryInformation} and the rest to be no
* property sets. In the latter cases a {@link
* NoPropertySetStreamException} will be thrown when trying to
* create a {@link PropertySet}.</p>
*
* @exception IOException if an I/O exception occurs.
*
* @exception UnsupportedEncodingException if a character encoding is not
* supported.
*/
@Test
public void testCreatePropertySets() throws UnsupportedEncodingException, IOException {
Class<?>[] expected = { SummaryInformation.class, DocumentSummaryInformation.class, NoPropertySetStreamException.class, NoPropertySetStreamException.class, NoPropertySetStreamException.class };
for (int i = 0; i < expected.length; i++) {
InputStream in = new ByteArrayInputStream(poiFiles.get(i).getBytes());
Object o;
try {
o = PropertySetFactory.create(in);
} catch (NoPropertySetStreamException ex) {
o = ex;
} catch (MarkUnsupportedException ex) {
o = ex;
}
in.close();
assertEquals(expected[i], o.getClass());
}
}
use of org.apache.poi.hpsf.MarkUnsupportedException in project tika by apache.
the class SummaryExtractor method parseSummaryEntryIfExists.
private void parseSummaryEntryIfExists(DirectoryNode root, String entryName) throws IOException, TikaException {
try {
DocumentEntry entry = (DocumentEntry) root.getEntry(entryName);
PropertySet properties = new PropertySet(new DocumentInputStream(entry));
if (properties.isSummaryInformation()) {
parse(new SummaryInformation(properties));
}
if (properties.isDocumentSummaryInformation()) {
parse(new DocumentSummaryInformation(properties));
}
} catch (FileNotFoundException e) {
// entry does not exist, just skip it
} catch (NoPropertySetStreamException e) {
// no property stream, just skip it
} catch (UnexpectedPropertySetTypeException e) {
throw new TikaException("Unexpected HPSF document", e);
} catch (MarkUnsupportedException e) {
throw new TikaException("Invalid DocumentInputStream", e);
} catch (Exception e) {
LOG.warn("Ignoring unexpected exception while parsing summary entry {}", entryName, e);
}
}
Aggregations