public void testShared() throws Exception { String config = "" + "<gatein-resources>" + "<module>" + "<name>foo</name>" + "<script>" + "<name>foo_module</name>" + "<path>/foo_module.js</path>" + "</script>" + "<depends>" + "<module>bar</module>" + "</depends>" + "<depends>" + "<module>juu</module>" + "</depends>" + "</module>" + "<scripts>" + "<name>foo_scripts</name>" + "<script>" + "<name>foo_module</name>" + "<path>/foo_module.js</path>" + "</script>" + "<depends>" + "<scripts>bar</scripts>" + "</depends>" + "<depends>" + "<scripts>juu</scripts>" + "</depends>" + "</scripts>" + "</gatein-resources>"; // JavascriptConfigParser parser = new JavascriptConfigParser( new MockServletContext("mypath"), new ByteArrayInputStream(config.getBytes("UTF-8"))); List<ScriptResourceDescriptor> scripts = parseScripts(parser); assertEquals(2, scripts.size()); ScriptResourceDescriptor desc = scripts.get(0); assertEquals(new ResourceId(ResourceScope.SHARED, "foo"), desc.getId()); assertNull(desc.getAlias()); assertEquals( Arrays.asList( new DependencyDescriptor(new ResourceId(ResourceScope.SHARED, "bar")), new DependencyDescriptor(new ResourceId(ResourceScope.SHARED, "juu"))), desc.getDependencies()); desc = scripts.get(1); assertEquals(new ResourceId(ResourceScope.SHARED, "foo_scripts"), desc.getId()); assertEquals( Arrays.asList( new DependencyDescriptor(new ResourceId(ResourceScope.SHARED, "bar")), new DependencyDescriptor(new ResourceId(ResourceScope.SHARED, "juu"))), desc.getDependencies()); }
public void testAlias() throws Exception { String config = "" + "<gatein-resources>" + "<module>" + "<name>foo</name>" + "<as>f</as>" + "<depends>" + "<module>bar</module>" + "<as>b</as>" + "</depends>" + "</module>" + "</gatein-resources>"; // JavascriptConfigParser parser = new JavascriptConfigParser( new MockServletContext("mypath"), new ByteArrayInputStream(config.getBytes("UTF-8"))); List<ScriptResourceDescriptor> scripts = parseScripts(parser); ScriptResourceDescriptor desc = scripts.get(0); assertEquals("f", desc.getAlias()); assertEquals("b", desc.getDependencies().get(0).getAlias()); config = "" + "<gatein-resources>" + "<portal>" + "<name>zoo</name>" + "<as>z</as>" + "<module>" + "<depends>" + "<module>zozo</module>" + "<as>zz</as>" + "</depends>" + "</module>" + "</portal>" + "</gatein-resources>"; JavascriptConfigParser parser1 = new JavascriptConfigParser( new MockServletContext("mypath"), new ByteArrayInputStream(config.getBytes("UTF-8"))); List<ScriptResourceDescriptor> ptScripts = parseScripts(parser1); ScriptResourceDescriptor portalDesc = ptScripts.get(0); assertEquals("z", portalDesc.getAlias()); assertEquals("zz", portalDesc.getDependencies().get(0).getAlias()); }