From f8e6172822cbc39d68cd87a6e74a27912fef703c Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Mon, 15 Jan 2024 15:46:37 +0100 Subject: [PATCH] register in AppAemContext --- changes.xml | 2 +- .../handler/media/testcontext/AppAemContext.java | 4 +++- .../WebOptimizedImageDeliveryServiceImplTest.java | 13 ++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/changes.xml b/changes.xml index 0a9f3498..62f04f51 100644 --- a/changes.xml +++ b/changes.xml @@ -24,7 +24,7 @@ - + Add support for Web Optimized Image Delivery (part of Next Generation Dynamic Media) - rendering asset renditions from AEM Sites instance on the edge. Active by default, can be disabled. diff --git a/src/test/java/io/wcm/handler/media/testcontext/AppAemContext.java b/src/test/java/io/wcm/handler/media/testcontext/AppAemContext.java index c4433a00..40608089 100644 --- a/src/test/java/io/wcm/handler/media/testcontext/AppAemContext.java +++ b/src/test/java/io/wcm/handler/media/testcontext/AppAemContext.java @@ -35,6 +35,7 @@ import io.wcm.handler.media.spi.MediaFormatProvider; import io.wcm.handler.media.spi.MediaHandlerConfig; import io.wcm.handler.mediasource.dam.impl.dynamicmedia.DynamicMediaSupportServiceImpl; +import io.wcm.handler.mediasource.dam.impl.dynamicmedia.WebOptimizedImageDeliveryServiceImpl; import io.wcm.handler.url.SiteConfig; import io.wcm.handler.url.impl.DefaultUrlHandlerConfig; import io.wcm.handler.url.impl.SiteRootDetectorImpl; @@ -116,8 +117,9 @@ public void execute(@NotNull AemContext context) throws Exception { context.registerService(MediaFormatProvider.class, new DummyMediaFormatProvider()); context.registerInjectActivateService(MediaFormatProviderManagerImpl.class); - // dynamic media + // dynamic media/NGDM context.registerInjectActivateService(DynamicMediaSupportServiceImpl.class); + context.registerInjectActivateService(WebOptimizedImageDeliveryServiceImpl.class); // sling models registration context.addModelsForPackage( diff --git a/src/test/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/WebOptimizedImageDeliveryServiceImplTest.java b/src/test/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/WebOptimizedImageDeliveryServiceImplTest.java index de0b24bb..f3bb18c8 100644 --- a/src/test/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/WebOptimizedImageDeliveryServiceImplTest.java +++ b/src/test/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/WebOptimizedImageDeliveryServiceImplTest.java @@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -35,23 +36,29 @@ class WebOptimizedImageDeliveryServiceImplTest { private final AemContext context = AppAemContext.newAemContext(); + private WebOptimizedImageDeliveryService underTest; + + @BeforeAll + void setUp() { + underTest = context.getService(WebOptimizedImageDeliveryService.class); + } + + @Test void testEnabled_AssetDeliveryNotPresent() { - WebOptimizedImageDeliveryService underTest = context.registerInjectActivateService(WebOptimizedImageDeliveryServiceImpl.class); assertFalse(underTest.isEnabled()); } @Test void testEnabled_AssetDeliveryPresent() { context.registerInjectActivateService(MockAssetDelivery.class); - WebOptimizedImageDeliveryService underTest = context.registerInjectActivateService(WebOptimizedImageDeliveryServiceImpl.class); assertTrue(underTest.isEnabled()); } @Test void testEnabled_AssetDeliveryPresent_Disabled() { context.registerInjectActivateService(MockAssetDelivery.class); - WebOptimizedImageDeliveryService underTest = context.registerInjectActivateService(WebOptimizedImageDeliveryServiceImpl.class, + underTest = context.registerInjectActivateService(WebOptimizedImageDeliveryServiceImpl.class, "enabled", false); assertFalse(underTest.isEnabled()); }