List of usage examples for org.apache.wicket.markup MarkupResourceStream getInputStream
@Override public InputStream getInputStream() throws ResourceStreamNotFoundException
From source file:org.cast.isi.ISIXmlComponent.java
License:Open Source License
/** * If an IMarkupFragment contains unicode d7, converts it into one that uses the corresponding character entity. * * @param fragment/* w ww .ja va 2 s.c om*/ * @return * @throws ResourceStreamNotFoundException */ protected static IMarkupFragment hackUnicodeD7(IMarkupFragment fragment) throws IOException, ResourceStreamNotFoundException { MarkupResourceStream markupStream = fragment.getMarkupResourceStream(); InputStream is = markupStream.getInputStream(); String x = getStringFromInputStream(is); if (x.contains("\u00d7")) { log.debug("Fixing instances of unicode D7"); x = x.replaceAll("\u00d7", "×"); return createMarkupFragmentFromString(x); } else { return fragment; } }
From source file:org.cast.isi.ISIXmlComponentTest.java
License:Open Source License
@Test public void testCreateMarkupFragmentFromString() throws Exception { String s = "<span>some markup</span>"; IMarkupFragment fragment = ISIXmlComponent.createMarkupFragmentFromString(s); MarkupResourceStream markupStream = fragment.getMarkupResourceStream(); InputStream is = markupStream.getInputStream(); String x = ISIXmlComponent.getStringFromInputStream(is); assertEquals("Expected no changes to input string", s, x); }
From source file:org.cast.isi.ISIXmlComponentTest.java
License:Open Source License
@Test public void testCreateMarkupFragmentFromNullString() throws Exception { String s = null;/* www. j a v a 2s. c om*/ IMarkupFragment fragment = ISIXmlComponent.createMarkupFragmentFromString(s); try { MarkupResourceStream markupStream = fragment.getMarkupResourceStream(); InputStream is = markupStream.getInputStream(); String x = ISIXmlComponent.getStringFromInputStream(is); fail("Expected NullPointerException didn't happen"); } catch (NullPointerException x) { } }