@Test public void nullResult() { Map<String, byte[]> dataMap = new HashMap<>(); dataMap.put("null", null); dataMap.put("empty-array", new byte[] {}); dataMap.put("0", new byte[] { 0 }); MemoryDataLoader memoryDataLoader = new MemoryDataLoader(dataMap); DSSFileLoader dataLoader = new FileCacheDataLoader(memoryDataLoader); for (String url : dataMap.keySet()) { XmlDownloadTask task = new XmlDownloadTask(dataLoader, url); assertThrows(DSSException.class, () -> task.get()); } }
@Override public XmlDownloadResult get() { try { final DSSDocument dssDocument = dssFileLoader.getDocument(url); final Document dom = DomUtils.buildDOM(dssDocument); final byte[] canonicalizedContent = DSSXMLUtils.canonicalizeSubtree(CanonicalizationMethod.EXCLUSIVE, dom); return new XmlDownloadResult(dssDocument, new Digest(DigestAlgorithm.SHA256, DSSUtils.digest(DigestAlgorithm.SHA256, canonicalizedContent))); } catch (DSSException e) { throw e; } catch (Exception e) { throw new DSSException(String.format("Unable to retrieve the content for url '%s'. Reason : '%s'", url, e.getMessage()), e); } }
XmlDownloadTask implements Supplier<XmlDownloadResult> { @Override public XmlDownloadResult get() { try { final DSSDocument dssDocument = dssFileLoader.getDocument(url); final Document dom = DomUtils.buildDOM(dssDocument); final byte[] canonicalizedContent = DSSXMLUtils.canonicalizeSubtree(CanonicalizationMethod.EXCLUSIVE, dom); return new XmlDownloadResult(dssDocument, new Digest(DigestAlgorithm.SHA256, DSSUtils.digest(DigestAlgorithm.SHA256, canonicalizedContent))); } catch (DSSException e) { throw e; } catch (Exception e) { throw new DSSException(String.format("Unable to retrieve the content for url '%s'. Reason : '%s'", url, e.getMessage()), e); } } }
XmlDownloadTask implements Supplier<XmlDownloadResult> { @Override public XmlDownloadResult get() { try { final DSSDocument dssDocument = dssFileLoader.getDocument(url); final Document dom = DomUtils.buildDOM(dssDocument); final byte[] canonicalizedContent = DSSXMLUtils.canonicalizeSubtree(CanonicalizationMethod.EXCLUSIVE, dom); return new XmlDownloadResult(dssDocument, new Digest(DigestAlgorithm.SHA256, DSSUtils.digest(DigestAlgorithm.SHA256, canonicalizedContent))); } catch (DSSException e) { throw e; } catch (Exception e) { throw new DSSException(String.format("Unable to retrieve the content for url '%s'. Reason : '%s'", url, e.getMessage()), e); } } XmlDownloadTask(DSSFileLoader dssFileLoader, String url); }
XmlDownloadTask implements Supplier<XmlDownloadResult> { @Override public XmlDownloadResult get() { try { final DSSDocument dssDocument = dssFileLoader.getDocument(url); final Document dom = DomUtils.buildDOM(dssDocument); final byte[] canonicalizedContent = DSSXMLUtils.canonicalizeSubtree(CanonicalizationMethod.EXCLUSIVE, dom); return new XmlDownloadResult(dssDocument, new Digest(DigestAlgorithm.SHA256, DSSUtils.digest(DigestAlgorithm.SHA256, canonicalizedContent))); } catch (DSSException e) { throw e; } catch (Exception e) { throw new DSSException(String.format("Unable to retrieve the content for url '%s'. Reason : '%s'", url, e.getMessage()), e); } } XmlDownloadTask(DSSFileLoader dssFileLoader, String url); @Override XmlDownloadResult get(); }
XmlDownloadTask implements Supplier<XmlDownloadResult> { @Override public XmlDownloadResult get() { try { final DSSDocument dssDocument = dssFileLoader.getDocument(url); final Document dom = DomUtils.buildDOM(dssDocument); final byte[] canonicalizedContent = DSSXMLUtils.canonicalizeSubtree(CanonicalizationMethod.EXCLUSIVE, dom); return new XmlDownloadResult(dssDocument, new Digest(DigestAlgorithm.SHA256, DSSUtils.digest(DigestAlgorithm.SHA256, canonicalizedContent))); } catch (DSSException e) { throw e; } catch (Exception e) { throw new DSSException(String.format("Unable to retrieve the content for url '%s'. Reason : '%s'", url, e.getMessage()), e); } } XmlDownloadTask(DSSFileLoader dssFileLoader, String url); @Override XmlDownloadResult get();  }