From 89497b0efd9eb19eda01b9380dfd5824c30d5ab7 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Mon, 9 Sep 2024 16:49:14 +0200 Subject: [PATCH] update changelog, improve unit tests --- changes.xml | 3 +++ .../io/wcm/testing/mock/aem/dam/MockRendition.java | 2 +- .../wcm/testing/mock/aem/dam/MockRenditionTest.java | 12 ++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/changes.xml b/changes.xml index 546a477..c5cf4a9 100644 --- a/changes.xml +++ b/changes.xml @@ -24,6 +24,9 @@ + + Add support for Rendition.getBinary() method. + Update to latest OSGi Mock. diff --git a/core/src/main/java/io/wcm/testing/mock/aem/dam/MockRendition.java b/core/src/main/java/io/wcm/testing/mock/aem/dam/MockRendition.java index d99737b..9168aa3 100644 --- a/core/src/main/java/io/wcm/testing/mock/aem/dam/MockRendition.java +++ b/core/src/main/java/io/wcm/testing/mock/aem/dam/MockRendition.java @@ -166,7 +166,7 @@ public void dispose() { @Override public @Nullable URI getURI(BinaryDownloadOptions downloadOptions) throws RepositoryException { - final String path = "https://blostore.local:12345/blostore/" + rendition.getPath(); + final String path = "https://blostore.local/blostore/" + rendition.getPath(); try { return new URI(path); } diff --git a/core/src/test/java/io/wcm/testing/mock/aem/dam/MockRenditionTest.java b/core/src/test/java/io/wcm/testing/mock/aem/dam/MockRenditionTest.java index 059be0a..45b3102 100644 --- a/core/src/test/java/io/wcm/testing/mock/aem/dam/MockRenditionTest.java +++ b/core/src/test/java/io/wcm/testing/mock/aem/dam/MockRenditionTest.java @@ -23,7 +23,9 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import javax.jcr.Binary; import javax.jcr.RepositoryException; import org.apache.jackrabbit.api.binary.BinaryDownload; @@ -100,8 +102,14 @@ public void testAdaptTo() { @Test public void testBinaryDownload() throws RepositoryException { - BinaryDownload d = (BinaryDownload)rendition.getBinary(); - assertNotNull(d.getURI(null)); + Binary binary = rendition.getBinary(); + assertNotNull(binary); + assertEquals(0L, binary.getSize()); + assertNotNull(binary.getStream()); + + assertTrue(binary instanceof BinaryDownload); + assertEquals("https://blostore.local/blostore//content/dam/sample/portraits/scott_reynolds.jpg/jcr:content/renditions/original", + ((BinaryDownload)binary).getURI(null).toString()); } }