Skip to content

Commit

Permalink
register in AppAemContext
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Jan 15, 2024
1 parent ed1f965 commit f8e6172
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<body>

<release version="2.0.0" date="not released">
<action type="add" dev="sseifert">
<action type="add" dev="sseifert" issue="30">
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.
</action>
<action type="remove" dev="sseifert" issue="27">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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());
}
Expand Down

0 comments on commit f8e6172

Please sign in to comment.