From 874be02da79705bd9aee07f09544140d593706cf Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Mon, 26 Aug 2024 11:22:34 +0200 Subject: [PATCH 1/6] [gitflow-maven-plugin] Update for next development version 5.6.1-SNAPSHOT --- core/pom.xml | 2 +- junit4/pom.xml | 6 +++--- junit5/pom.xml | 6 +++--- parent/pom.xml | 4 ++-- pom.xml | 4 ++-- relocate/pom.xml | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 6c34b777..c403badb 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -25,7 +25,7 @@ io.wcm io.wcm.testing.aem-mock.parent - 5.6.0 + 5.6.1-SNAPSHOT ../parent/pom.xml diff --git a/junit4/pom.xml b/junit4/pom.xml index 9026ccf4..5aeeb055 100644 --- a/junit4/pom.xml +++ b/junit4/pom.xml @@ -25,7 +25,7 @@ io.wcm io.wcm.testing.aem-mock.parent - 5.6.0 + 5.6.1-SNAPSHOT ../parent/pom.xml @@ -54,7 +54,7 @@ io.wcm io.wcm.testing.aem-mock.core - 5.6.0 + 5.6.1-SNAPSHOT compile @@ -87,7 +87,7 @@ io.wcm io.wcm.testing.aem-mock.core - 5.6.0 + 5.6.1-SNAPSHOT tests test diff --git a/junit5/pom.xml b/junit5/pom.xml index 282b9499..f1254c73 100644 --- a/junit5/pom.xml +++ b/junit5/pom.xml @@ -25,7 +25,7 @@ io.wcm io.wcm.testing.aem-mock.parent - 5.6.0 + 5.6.1-SNAPSHOT ../parent/pom.xml @@ -54,14 +54,14 @@ io.wcm io.wcm.testing.aem-mock.core - 5.6.0 + 5.6.1-SNAPSHOT compile io.wcm io.wcm.testing.aem-mock.core - 5.6.0 + 5.6.1-SNAPSHOT tests test diff --git a/parent/pom.xml b/parent/pom.xml index ab774748..5098ddd4 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -31,7 +31,7 @@ io.wcm io.wcm.testing.aem-mock.parent - 5.6.0 + 5.6.1-SNAPSHOT pom AEM Mocks @@ -71,7 +71,7 @@ 1.0.0 - 2024-08-26T09:18:14Z + 2024-08-26T09:22:32Z diff --git a/pom.xml b/pom.xml index cc92f311..5542bfa3 100644 --- a/pom.xml +++ b/pom.xml @@ -25,14 +25,14 @@ io.wcm io.wcm.testing.aem-mock.parent - 5.6.0 + 5.6.1-SNAPSHOT parent/pom.xml io.wcm io.wcm.testing.aem-mock.root pom - 5.6.0 + 5.6.1-SNAPSHOT AEM Mocks ${site.url}/${site.url.module.prefix}/ diff --git a/relocate/pom.xml b/relocate/pom.xml index 7b7c9069..1e317029 100644 --- a/relocate/pom.xml +++ b/relocate/pom.xml @@ -25,7 +25,7 @@ io.wcm io.wcm.testing.aem-mock.parent - 5.6.0 + 5.6.1-SNAPSHOT ../parent/pom.xml From 7af231767ea1bcdc5253e2c8035a16bc76ae8b8b Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Mon, 2 Sep 2024 14:56:14 +0200 Subject: [PATCH 2/6] Update to latest OSGi Mock --- changes.xml | 6 ++++++ parent/pom.xml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changes.xml b/changes.xml index 1c9f6763..546a477e 100644 --- a/changes.xml +++ b/changes.xml @@ -23,6 +23,12 @@ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd"> + + + Update to latest OSGi Mock. + + + Add mock implementation of Adobe Granite Asset API. diff --git a/parent/pom.xml b/parent/pom.xml index 5098ddd4..e484f059 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -50,7 +50,7 @@ - 3.5.0 + 3.5.1-SNAPSHOT 1.6.14 From fc23802bddd0585f5f00f9bb8ffb36994a62dc0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hoh?= Date: Mon, 9 Sep 2024 16:57:21 +0200 Subject: [PATCH 3/6] add support for Rendition.getBinary() (#50) Co-authored-by: Stefan Seifert --- changes.xml | 3 + .../testing/mock/aem/dam/MockRendition.java | 56 +++++++++++++++++-- .../mock/aem/dam/MockRenditionTest.java | 19 +++++++ 3 files changed, 74 insertions(+), 4 deletions(-) diff --git a/changes.xml b/changes.xml index 546a477e..405816bb 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 e357ba12..9168aa36 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 @@ -21,16 +21,22 @@ import java.io.IOException; import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; import javax.jcr.Binary; +import javax.jcr.RepositoryException; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.jackrabbit.api.binary.BinaryDownload; +import org.apache.jackrabbit.api.binary.BinaryDownloadOptions; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceUtil; import org.apache.sling.api.resource.ResourceWrapper; import org.apache.sling.api.resource.ValueMap; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import com.day.cq.commons.jcr.JcrConstants; import com.day.cq.dam.api.Asset; @@ -123,12 +129,54 @@ public boolean equals(Object obj) { return StringUtils.equals(getPath(), ((MockRendition)obj).getPath()); } - - // --- unsupported operations --- - @Override public Binary getBinary() { - throw new UnsupportedOperationException(); + return new MockBinary(this); + } + + + private static class MockBinary implements BinaryDownload { + + private Rendition rendition; + + MockBinary(Rendition rendition) { + this.rendition = rendition; + } + + + @Override + public InputStream getStream() throws RepositoryException { + return rendition.getStream(); + } + + @Override + public int read(byte[] b, long position) throws IOException, RepositoryException { + throw new UnsupportedOperationException(); + } + + @Override + public long getSize() throws RepositoryException { + return rendition.getSize(); + } + + @Override + public void dispose() { + // nothing to do + } + + @Override + public @Nullable URI getURI(BinaryDownloadOptions downloadOptions) throws RepositoryException { + final String path = "https://blostore.local/blostore/" + rendition.getPath(); + try { + return new URI(path); + } + catch (URISyntaxException e) { + // nothing + } + return null; + } + } + } 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 82f712c3..1bddb77e 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,12 @@ 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; import org.apache.sling.api.resource.Resource; import org.junit.Before; import org.junit.Rule; @@ -95,4 +100,18 @@ public void testAdaptTo() { assertSame(rendition, rendition.adaptTo(com.adobe.granite.asset.api.Rendition.class)); } + @Test + public void testBinaryDownload() throws RepositoryException { + 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()); + + binary.dispose(); + } + } From 3324e3f93a1341c537425b18735349043b5eb37a Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Mon, 16 Sep 2024 11:01:14 +0200 Subject: [PATCH 4/6] Revert "Update to latest OSGi Mock" --- changes.xml | 3 --- parent/pom.xml | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/changes.xml b/changes.xml index 405816bb..9782a063 100644 --- a/changes.xml +++ b/changes.xml @@ -27,9 +27,6 @@ Add support for Rendition.getBinary() method. - - Update to latest OSGi Mock. - diff --git a/parent/pom.xml b/parent/pom.xml index e484f059..5098ddd4 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -50,7 +50,7 @@ - 3.5.1-SNAPSHOT + 3.5.0 1.6.14 From cf12352e1f5fd502814165918bf999c35c58e6b4 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Mon, 16 Sep 2024 11:14:25 +0200 Subject: [PATCH 5/6] prepare release --- changes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes.xml b/changes.xml index 9782a063..8171291b 100644 --- a/changes.xml +++ b/changes.xml @@ -23,7 +23,7 @@ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd"> - + Add support for Rendition.getBinary() method. From 44c3367714d3d2beffe5af896e3b37b22434c3be Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Mon, 16 Sep 2024 11:26:28 +0200 Subject: [PATCH 6/6] [gitflow-maven-plugin] Update versions for release 5.6.2 --- core/pom.xml | 2 +- junit4/pom.xml | 6 +++--- junit5/pom.xml | 6 +++--- parent/pom.xml | 4 ++-- pom.xml | 4 ++-- relocate/pom.xml | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index c403badb..3ff74270 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -25,7 +25,7 @@ io.wcm io.wcm.testing.aem-mock.parent - 5.6.1-SNAPSHOT + 5.6.2 ../parent/pom.xml diff --git a/junit4/pom.xml b/junit4/pom.xml index 5aeeb055..d2224b2e 100644 --- a/junit4/pom.xml +++ b/junit4/pom.xml @@ -25,7 +25,7 @@ io.wcm io.wcm.testing.aem-mock.parent - 5.6.1-SNAPSHOT + 5.6.2 ../parent/pom.xml @@ -54,7 +54,7 @@ io.wcm io.wcm.testing.aem-mock.core - 5.6.1-SNAPSHOT + 5.6.2 compile @@ -87,7 +87,7 @@ io.wcm io.wcm.testing.aem-mock.core - 5.6.1-SNAPSHOT + 5.6.2 tests test diff --git a/junit5/pom.xml b/junit5/pom.xml index f1254c73..61cc5ee4 100644 --- a/junit5/pom.xml +++ b/junit5/pom.xml @@ -25,7 +25,7 @@ io.wcm io.wcm.testing.aem-mock.parent - 5.6.1-SNAPSHOT + 5.6.2 ../parent/pom.xml @@ -54,14 +54,14 @@ io.wcm io.wcm.testing.aem-mock.core - 5.6.1-SNAPSHOT + 5.6.2 compile io.wcm io.wcm.testing.aem-mock.core - 5.6.1-SNAPSHOT + 5.6.2 tests test diff --git a/parent/pom.xml b/parent/pom.xml index 5098ddd4..58597920 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -31,7 +31,7 @@ io.wcm io.wcm.testing.aem-mock.parent - 5.6.1-SNAPSHOT + 5.6.2 pom AEM Mocks @@ -71,7 +71,7 @@ 1.0.0 - 2024-08-26T09:22:32Z + 2024-09-16T09:26:26Z diff --git a/pom.xml b/pom.xml index 5542bfa3..aff27674 100644 --- a/pom.xml +++ b/pom.xml @@ -25,14 +25,14 @@ io.wcm io.wcm.testing.aem-mock.parent - 5.6.1-SNAPSHOT + 5.6.2 parent/pom.xml io.wcm io.wcm.testing.aem-mock.root pom - 5.6.1-SNAPSHOT + 5.6.2 AEM Mocks ${site.url}/${site.url.module.prefix}/ diff --git a/relocate/pom.xml b/relocate/pom.xml index 1e317029..09d0f01b 100644 --- a/relocate/pom.xml +++ b/relocate/pom.xml @@ -25,7 +25,7 @@ io.wcm io.wcm.testing.aem-mock.parent - 5.6.1-SNAPSHOT + 5.6.2 ../parent/pom.xml