AbstractAggregatorImpl extends HttpServlet implements IAggregator { protected Map<String, URI> getPathsAndAliases(InitParams initParams) { final String sourceMethod = "getPahtsAndAliases"; boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(AbstractAggregatorImpl.class.getName(), sourceMethod, new Object[]{initParams}); } Map<String, URI> resourcePaths = new HashMap<String, URI>(); List<String> aliases = initParams.getValues(InitParams.ALIAS_INITPARAM); for (String alias : aliases) { addAlias(alias, null, "alias", resourcePaths); } List<String> resourceIds = initParams.getValues(InitParams.RESOURCEID_INITPARAM); for (String resourceId : resourceIds) { aliases = initParams.getValues(resourceId + ":alias"); List<String> baseNames = initParams.getValues(resourceId + ":base-name"); if (aliases == null || aliases.size() != 1) { throw new IllegalArgumentException(resourceId + ":aliases"); } if (baseNames == null || baseNames.size() != 1) { throw new IllegalArgumentException(resourceId + ":base-name"); } String alias = aliases.get(0); String baseName = baseNames.get(0); boolean isPathComp = false; for (String part : alias.split("/")) { if (part.length() > 0) { isPathComp = true; break; } } if (baseName.startsWith("/")) { throw new IllegalArgumentException("Root relative base-name not allowed: " + baseName); } if (!isPathComp) { throw new IllegalArgumentException(resourceId + ":alias = " + alias); } addAlias(alias, URI.create(baseName), resourceId + ":alias", resourcePaths); } if (isTraceLogging) { log.exiting(AbstractAggregatorImpl.class.getName(), sourceMethod, resourcePaths); } return Collections.unmodifiableMap(resourcePaths); }  @Override void init(ServletConfig servletConfig); @Override void destroy(); @Override boolean reloadConfig(); @Override IDependencies getDependencies(); @Override String getName(); @Override IConfig getConfig(); @Override ICacheManager getCacheManager(); @Override InitParams getInitParams(); @Override HttpServlet asServlet(); @Override IHttpTransport getTransport(); @Override IResourceFactory getResourceFactory(Mutable<URI> uriRef); @Override IResource newResource(URI uri); @Override IResource runConverters(IResource resource); @Override IModuleBuilder getModuleBuilder(String mid, IResource res); @Override Iterable<IAggregatorExtension> getExtensions(String extensionPointId); @Override IModule newModule(String mid, URI uri); @Override ILayerCache newLayerCache(); @Override IModuleCache newModuleCache(); @Override IGzipCache newGzipCache(); @Override String substituteProps(String str); @Override String substituteProps(String str, SubstitutionTransformer transformer); String getPropValue(String propName); @Override abstract IOptions getOptions(); @Override abstract IExecutors getExecutors(); @Override IPlatformServices getPlatformServices(); void initialize(IConfig config); @Override String setForceError(String forceError); @Override Future<?> buildAsync(final Callable<?> builder, final HttpServletRequest req); @Override HttpServletRequest getCurrentRequest();  }
@Test public void testGetPathsAndAliases() throws Exception { TestAggregatorImpl aggregator = EasyMock.createMockBuilder(TestAggregatorImpl.class) .addMockedMethod("newResource").createMock(); EasyMock.expect(aggregator.newResource(EasyMock.isA(URI.class))).andAnswer(new IAnswer<IResource>() { @Override public IResource answer() throws Throwable { URI uri = (URI)EasyMock.getCurrentArguments()[0]; return new StringResource("Test Resource for " + uri.toString(), uri); } }).anyTimes(); EasyMock.replay(aggregator); InitParams initParams = new InitParams( Arrays.asList(new InitParam[] { new InitParam(InitParams.ALIAS_INITPARAM, "aliasPath", aggregator), new InitParam(InitParams.RESOURCEID_INITPARAM, "resid", aggregator), new InitParam("resid:alias", "resAlias", aggregator), new InitParam("resid:base-name", "resBaseName", aggregator) }) ); Map<String, URI> map = aggregator.getPathsAndAliases(initParams); Assert.assertTrue(map.containsKey("/aliasPath")); Assert.assertNull(map.get("/aliasPath")); Assert.assertEquals(URI.create("resBaseName"), map.get("/resAlias")); Assert.assertEquals(2, map.size()); }