Search in sources :

Example 1 with VanityPathConfig

use of org.apache.sling.resourceresolver.impl.mapping.MapConfigurationProvider.VanityPathConfig in project sling by apache.

the class MapEntriesTest method setup.

@SuppressWarnings({ "unchecked" })
@Before
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    final List<VanityPathConfig> configs = new ArrayList<>();
    configs.add(new VanityPathConfig("/libs/", false));
    configs.add(new VanityPathConfig("/libs/denied", true));
    configs.add(new VanityPathConfig("/foo/", false));
    configs.add(new VanityPathConfig("/baa/", false));
    configs.add(new VanityPathConfig("/justVanityPath", false));
    configs.add(new VanityPathConfig("/justVanityPath2", false));
    configs.add(new VanityPathConfig("/badVanityPath", false));
    configs.add(new VanityPathConfig("/redirectingVanityPath", false));
    configs.add(new VanityPathConfig("/redirectingVanityPath301", false));
    configs.add(new VanityPathConfig("/vanityPathOnJcrContent", false));
    Collections.sort(configs);
    vanityBloomFilterFile = new File("src/main/resourcesvanityBloomFilter.txt");
    when(bundle.getSymbolicName()).thenReturn("TESTBUNDLE");
    when(bundleContext.getBundle()).thenReturn(bundle);
    when(bundleContext.getDataFile("vanityBloomFilter.txt")).thenReturn(vanityBloomFilterFile);
    when(resourceResolverFactory.getServiceResourceResolver(any(Map.class))).thenReturn(resourceResolver);
    when(resourceResolverFactory.isVanityPathEnabled()).thenReturn(true);
    when(resourceResolverFactory.getVanityPathConfig()).thenReturn(configs);
    when(resourceResolverFactory.isOptimizeAliasResolutionEnabled()).thenReturn(true);
    when(resourceResolverFactory.getObservationPaths()).thenReturn(new Path[] { new Path("/") });
    when(resourceResolverFactory.getMapRoot()).thenReturn(MapEntries.DEFAULT_MAP_ROOT);
    when(resourceResolverFactory.getMaxCachedVanityPathEntries()).thenReturn(-1L);
    when(resourceResolverFactory.isMaxCachedVanityPathEntriesStartup()).thenReturn(true);
    when(resourceResolver.findResources(anyString(), eq("sql"))).thenReturn(Collections.<Resource>emptySet().iterator());
    mapEntries = new MapEntries(resourceResolverFactory, bundleContext, eventAdmin);
    final Field aliasMapField = MapEntries.class.getDeclaredField("aliasMap");
    aliasMapField.setAccessible(true);
    this.aliasMap = (Map<String, Map<String, String>>) aliasMapField.get(mapEntries);
}
Also used : Path(org.apache.sling.api.resource.path.Path) Field(java.lang.reflect.Field) ArrayList(java.util.ArrayList) Resource(org.apache.sling.api.resource.Resource) VanityPathConfig(org.apache.sling.resourceresolver.impl.mapping.MapConfigurationProvider.VanityPathConfig) Matchers.anyString(org.mockito.Matchers.anyString) File(java.io.File) ValueMap(org.apache.sling.api.resource.ValueMap) Map(java.util.Map) HashMap(java.util.HashMap) Before(org.junit.Before)

Aggregations

File (java.io.File)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Resource (org.apache.sling.api.resource.Resource)1 ValueMap (org.apache.sling.api.resource.ValueMap)1 Path (org.apache.sling.api.resource.path.Path)1 VanityPathConfig (org.apache.sling.resourceresolver.impl.mapping.MapConfigurationProvider.VanityPathConfig)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1