Search in sources :

Example 6 with ConfigurationResourceResolvingStrategy

use of org.apache.sling.caconfig.resource.spi.ConfigurationResourceResolvingStrategy in project sling by apache.

the class DefaultConfigurationResourceResolvingStrategyTest method testGetResourceCollection_PropsParent.

/**
     * Resource inheritance with enabling list merging on a parent context level.
     * => no inheritance takes place
     */
@Test
public void testGetResourceCollection_PropsParent() {
    ConfigurationResourceResolvingStrategy underTest = context.registerInjectActivateService(new DefaultConfigurationResourceResolvingStrategy());
    // build config resources
    context.build().resource("/conf/site1/sling:test/feature/c").resource("/conf/site2/sling:test/feature/c").resource("/conf/site2/sling:test/feature/d").resource("/apps/conf/sling:test/feature/a").resource("/libs/conf/sling:test/feature", PROPERTY_CONFIG_COLLECTION_INHERIT, true).resource("b");
    assertThat(underTest.getResourceCollection(site1Page1, BUCKETS, "feature"), ResourceCollectionMatchers.paths("/conf/site1/sling:test/feature/c"));
    assertThat(underTest.getResourceCollection(site2Page1, BUCKETS, "feature"), ResourceCollectionMatchers.paths("/conf/site2/sling:test/feature/c", "/conf/site2/sling:test/feature/d"));
}
Also used : ConfigurationResourceResolvingStrategy(org.apache.sling.caconfig.resource.spi.ConfigurationResourceResolvingStrategy) Test(org.junit.Test)

Example 7 with ConfigurationResourceResolvingStrategy

use of org.apache.sling.caconfig.resource.spi.ConfigurationResourceResolvingStrategy in project sling by apache.

the class DefaultConfigurationResourceResolvingStrategyTest method testDisabled.

@Test
public void testDisabled() {
    ConfigurationResourceResolvingStrategy underTest = context.registerInjectActivateService(new DefaultConfigurationResourceResolvingStrategy(), "enabled", false);
    assertNull(underTest.getResource(site1Page1, BUCKETS, "test"));
    assertNull(underTest.getResourceCollection(site1Page1, BUCKETS, "feature"));
    assertNull(underTest.getResourcePath(site1Page1, BUCKET, "test"));
    assertNull(underTest.getResourceCollectionParentPath(site1Page1, BUCKET, "feature"));
}
Also used : ConfigurationResourceResolvingStrategy(org.apache.sling.caconfig.resource.spi.ConfigurationResourceResolvingStrategy) Test(org.junit.Test)

Example 8 with ConfigurationResourceResolvingStrategy

use of org.apache.sling.caconfig.resource.spi.ConfigurationResourceResolvingStrategy in project sling by apache.

the class DefaultConfigurationResourceResolvingStrategyTest method testGetResourceCollection_NoInheritProps.

/**
     * Default resource inheritance without customizing inheritance.
     * => no resource list merging.
     */
@Test
public void testGetResourceCollection_NoInheritProps() {
    ConfigurationResourceResolvingStrategy underTest = context.registerInjectActivateService(new DefaultConfigurationResourceResolvingStrategy());
    // build config resources
    context.build().resource("/conf/site1/sling:test/feature/c").resource("/conf/site2/sling:test/feature/c").resource("/conf/site2/sling:test/feature/d").resource("/apps/conf/sling:test/feature/a").resource("/libs/conf/sling:test/feature/b");
    assertThat(underTest.getResourceCollection(site1Page1, BUCKETS, "feature"), ResourceCollectionMatchers.paths("/conf/site1/sling:test/feature/c"));
    assertThat(underTest.getResourceCollection(site2Page1, BUCKETS, "feature"), ResourceCollectionMatchers.paths("/conf/site2/sling:test/feature/c", "/conf/site2/sling:test/feature/d"));
}
Also used : ConfigurationResourceResolvingStrategy(org.apache.sling.caconfig.resource.spi.ConfigurationResourceResolvingStrategy) Test(org.junit.Test)

Example 9 with ConfigurationResourceResolvingStrategy

use of org.apache.sling.caconfig.resource.spi.ConfigurationResourceResolvingStrategy in project sling by apache.

the class DefaultConfigurationResourceResolvingStrategyTest method testGetResource.

@Test
public void testGetResource() {
    ConfigurationResourceResolvingStrategy underTest = context.registerInjectActivateService(new DefaultConfigurationResourceResolvingStrategy());
    // build config resources
    context.build().resource("/conf/site1/sling:test/test").resource("/libs/conf/sling:test/test");
    assertEquals("/conf/site1/sling:test/test", underTest.getResource(site1Page1, BUCKETS, "test").getPath());
    assertEquals("/libs/conf/sling:test/test", underTest.getResource(site2Page1, BUCKETS, "test").getPath());
}
Also used : ConfigurationResourceResolvingStrategy(org.apache.sling.caconfig.resource.spi.ConfigurationResourceResolvingStrategy) Test(org.junit.Test)

Example 10 with ConfigurationResourceResolvingStrategy

use of org.apache.sling.caconfig.resource.spi.ConfigurationResourceResolvingStrategy in project sling by apache.

the class DefaultConfigurationResourceResolvingStrategyTest method testGetResourceCollection_InheritMultipleLevels.

/**
     * Resource inheritance with enabling list merging on all levels.
     * => merge resource lists from all levels
     */
@Test
public void testGetResourceCollection_InheritMultipleLevels() {
    ConfigurationResourceResolvingStrategy underTest = context.registerInjectActivateService(new DefaultConfigurationResourceResolvingStrategy());
    // build config resources
    context.build().resource("/conf/site1/sling:test/feature", PROPERTY_CONFIG_COLLECTION_INHERIT, true).resource("c").resource("/conf/site2/sling:test/feature", PROPERTY_CONFIG_COLLECTION_INHERIT, true).siblingsMode().resource("c").resource("d").resource("/apps/conf/sling:test/feature", PROPERTY_CONFIG_COLLECTION_INHERIT, true).resource("a").resource("/libs/conf/sling:test/feature").resource("b");
    assertThat(underTest.getResourceCollection(site1Page1, BUCKETS, "feature"), ResourceCollectionMatchers.paths("/conf/site1/sling:test/feature/c", "/apps/conf/sling:test/feature/a", "/libs/conf/sling:test/feature/b"));
    assertThat(underTest.getResourceCollection(site2Page1, BUCKETS, "feature"), ResourceCollectionMatchers.paths("/conf/site2/sling:test/feature/c", "/conf/site2/sling:test/feature/d", "/apps/conf/sling:test/feature/a", "/libs/conf/sling:test/feature/b"));
}
Also used : ConfigurationResourceResolvingStrategy(org.apache.sling.caconfig.resource.spi.ConfigurationResourceResolvingStrategy) Test(org.junit.Test)

Aggregations

ConfigurationResourceResolvingStrategy (org.apache.sling.caconfig.resource.spi.ConfigurationResourceResolvingStrategy)12 Test (org.junit.Test)12 Function (com.google.common.base.Function)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 Resource (org.apache.sling.api.resource.Resource)1 DefaultConfigurationResourceResolvingStrategy (org.apache.sling.caconfig.resource.impl.def.DefaultConfigurationResourceResolvingStrategy)1