PeppolSBDHPayloadReader extends JAXBReaderBuilder <JAXBTYPE, PeppolSBDHPayloadReader <JAXBTYPE>> { @Nonnull public static PeppolSBDHPayloadReader <BinaryContentType> binaryContent () { return new PeppolSBDHPayloadReader <> (EPeppolSBDHPayloadType.BINARY, BinaryContentType.class); } PeppolSBDHPayloadReader(@Nonnull final EPeppolSBDHPayloadType eDocType, @Nonnull final Class <JAXBTYPE> aImplClass); @Nonnull static PeppolSBDHPayloadReader <BinaryContentType> binaryContent(); @Nonnull static PeppolSBDHPayloadReader <TextContentType> textContent();  }
@Test public void testBinary () { final byte [] aSrc = "Hallo Wält".getBytes (StandardCharsets.UTF_8); final String sEncoded = Base64.safeEncodeBytes (aSrc); BinaryContentType aCT = PeppolSBDHPayloadReader.binaryContent () .read ("<BinaryContent xmlns='http: sEncoded + "</BinaryContent>"); assertNotNull (aCT); assertEquals ("bla/foo", aCT.getMimeType ()); assertArrayEquals (aSrc, aCT.getValue ()); assertNull (aCT.getEncoding ()); aCT = PeppolSBDHPayloadReader.binaryContent () .read ("<BinaryContent xmlns='http: sEncoded + "</BinaryContent>"); assertNotNull (aCT); assertEquals ("bla/foo", aCT.getMimeType ()); assertArrayEquals (aSrc, aCT.getValue ()); assertEquals ("utf16be", aCT.getEncoding ()); aCT = PeppolSBDHPayloadReader.binaryContent () .read ("<BinaryContent xmlns='http: assertNotNull (aCT); assertEquals ("bla/foo", aCT.getMimeType ()); assertArrayEquals (ArrayHelper.EMPTY_BYTE_ARRAY, aCT.getValue ()); assertNull (aCT.getEncoding ()); aCT = PeppolSBDHPayloadReader.binaryContent () .read ("<BinaryContent xmlns='http: assertNotNull (aCT); assertEquals ("bla/foo", aCT.getMimeType ()); assertArrayEquals (ArrayHelper.EMPTY_BYTE_ARRAY, aCT.getValue ()); assertNull (aCT.getEncoding ()); assertNull (PeppolSBDHPayloadReader.binaryContent () .read ("<BinaryContent xmlns='ttp: sEncoded + "</BinaryContent>")); assertNull (PeppolSBDHPayloadReader.binaryContent () .read ("<BinaryContent2 xmlns='http: sEncoded + "</BinaryContent2>")); assertNull (PeppolSBDHPayloadReader.binaryContent () .read ("<BinaryContent xmlns='http: sEncoded + "</BinaryContent>")); }