/** * Sets content to new byte array, with unspecified charset. It is * recommended to use the {@code setContentBytes(byte[], Charset)} API instead, * where possible. * @param newBytes New content. */ public final void setContentBytes(byte[] newBytes) { setContentBytes(newBytes, null); }
/** * Sets content to new byte array, with unspecified charset. It is * recommended to use the {@code setContentBytes(byte[], Charset)} API instead, * where possible. * @param newBytes New content. */ public final void setContentBytes(byte[] newBytes) { setContentBytes(newBytes, null); }
/** * Sets content to new byte array, with unspecified charset. It is * recommended to use the {@code setContentBytes(byte[], Charset)} API instead, * where possible. * @param newBytes New content. */ public final void setContentBytes(byte[] newBytes) { setContentBytes(newBytes, null); }
@Test public void modifyBytesReflectedInContentAndTree() throws Exception { assertEquals(0, mhc.getNumChanges()); mhc.setContentBytes("NEW CONTENT".getBytes("UTF8"), Charsets.UTF_8); assertEquals(1, mhc.getNumChanges()); Document document = mhc.getDocument(); assertEquals(1, document.getChildNodes().getLength()); assertEquals("NEW CONTENT", document.getChildNodes().item(0).getTextContent()); assertEquals("NEW CONTENT", mhc.getContent()); assertEquals(1, mhc.getNumChanges()); InputStream is = mhc.getContentBytes(); assertEquals("NEW CONTENT", new String(IOUtils.toByteArray(is), "UTF8")); assertEquals(1, mhc.getNumChanges()); }
@Test public void modifyBytesReflectedInContentAndTree() throws Exception { assertEquals(0, mhc.getNumChanges()); mhc.setContentBytes("NEW CONTENT".getBytes("UTF8"), Charsets.UTF_8); assertEquals(1, mhc.getNumChanges()); Document document = mhc.getDocument(); assertEquals(1, document.getChildNodes().getLength()); assertEquals("NEW CONTENT", document.getChildNodes().item(0).getTextContent()); assertEquals("NEW CONTENT", mhc.getContent()); assertEquals(1, mhc.getNumChanges()); InputStream is = mhc.getContentBytes(); assertEquals("NEW CONTENT", new String(IOUtils.toByteArray(is), "UTF8")); assertEquals(1, mhc.getNumChanges()); }
@Test public void modifyBytesReflectedInContentAndTree() throws Exception { assertEquals(0, mhc.getNumChanges()); mhc.setContentBytes("NEW CONTENT".getBytes("UTF8"), Charsets.UTF_8); assertEquals(1, mhc.getNumChanges()); Document document = mhc.getDocument(); assertEquals(1, document.getChildNodes().getLength()); assertEquals("NEW CONTENT", document.getChildNodes().item(0).getTextContent()); assertEquals("NEW CONTENT", mhc.getContent()); assertEquals(1, mhc.getNumChanges()); InputStream is = mhc.getContentBytes(); assertEquals("NEW CONTENT", new String(IOUtils.toByteArray(is), "UTF8")); assertEquals(1, mhc.getNumChanges()); }