PagePreviewReader extends WebloungeContentReader { public Composer read(InputStream is, ResourceURI uri) throws SAXException, IOException, ParserConfigurationException { reset(); this.pageURI = uri; this.composer = new ComposerImpl(PREVIEW_COMPOSER_NAME); SAXParser parser = parserRef.get(); if (parser == null) { parser = parserFactory.newSAXParser(); parserRef = new WeakReference<SAXParser>(parser); } parser.parse(is, this); return composer; } PagePreviewReader(); Composer read(InputStream is, ResourceURI uri); void reset(); void startElement(String uri, String local, String raw,
      Attributes attrs); void endElement(String uri, String local, String raw); void characters(char[] chars, int start, int end); void warning(SAXParseException e); void error(SAXParseException e); void fatalError(SAXParseException e); static final String PREVIEW_COMPOSER_NAME; }
@Test public void testRead() { InputStream is = getClass().getResourceAsStream(previewFile); Composer preview = null; try { PagePreviewReader reader = new PagePreviewReader(); preview = reader.read(is, pageURI); } catch (Throwable t) { t.printStackTrace(); fail("Error parsing page preview"); } assertNotNull(preview); assertEquals(composerName, preview.getIdentifier()); assertEquals(1, preview.getPagelets().length); Pagelet previewTitle = preview.getPagelets()[0]; assertEquals(titleModule, previewTitle.getModule()); assertEquals(titlePagelet, previewTitle.getIdentifier()); }