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);
}
Aggregations