### Question:
XpathUtils { public static ByteBuffer asByteBuffer(String expression, Node node) throws XPathExpressionException { String base64EncodedString = evaluateAsString(expression, node); if (isEmptyString(base64EncodedString)) return null; if (!isEmpty(node)) { byte[] decodedBytes = Base64.decode(base64EncodedString); return ByteBuffer.wrap(decodedBytes); } return null; }  static Document documentFrom(InputStream is); static Document documentFrom(String xml); static Document documentFrom(URL url); static Double asDouble(String expression, Node node); static String asString(String expression, Node node); static Integer asInteger(String expression, Node node); static Boolean asBoolean(String expression, Node node); static Float asFloat(String expression, Node node); static Long asLong(String expression, Node node); static Byte asByte(String expression, Node node); static Date asDate(String expression, Node node); static ByteBuffer asByteBuffer(String expression, Node node); static boolean isEmpty(Node node); static int nodeLength(NodeList list); static Node asNode(String nodeName, Node node); static XPath xpath();  }### Answer:
@Test public void testAsByteBuffer() throws Exception { String expectedData = "hello world"; Document document = XpathUtils.documentFrom(DOCUMENT); ByteBuffer byteBuffer = XpathUtils.asByteBuffer("Foo/Blob", document); assertEquals(expectedData.length(), byteBuffer.limit()); String data = new String(byteBuffer.array(), StringUtils.UTF8); assertEquals(expectedData, data); assertNull(XpathUtils.asByteBuffer("Foo/Empty", document)); }
@Test public void testAsByteBuffer() throws Exception { String expectedData = "hello world"; Document document = XpathUtils.documentFrom(DOCUMENT); ByteBuffer byteBuffer = XpathUtils.asByteBuffer("Foo/Blob", document); assertEquals(expectedData.length(), byteBuffer.limit()); String data = new String(byteBuffer.array(), StringUtils.UTF8); assertEquals(expectedData, data); assertEquals(null, XpathUtils.asByteBuffer("Foo/Empty", document)); }