Exemplo n.º 1
0
  public void testAdapter() throws Exception {
    String config =
        ""
            + "<gatein-resources>"
            + "<module>"
            + "<name>foo_module</name>"
            + "<script><name>foo</name>"
            + "<adapter>aaa;<include>/foo_module.js</include>bbb;</adapter>"
            + "</script>"
            + "</module>"
            + "</gatein-resources>";

    JavascriptConfigParser parser =
        new JavascriptConfigParser(
            new MockServletContext("mypath"), new ByteArrayInputStream(config.getBytes("UTF-8")));
    List<ScriptResourceDescriptor> scripts = parseScripts(parser);

    ScriptResourceDescriptor des = scripts.get(0);
    Javascript.Local module = (Javascript.Local) des.getModules().get(0);
    Content[] contents = module.getContents();

    assertNotNull(contents);
    assertEquals(3, contents.length);
    assertEquals("aaa;", contents[0].getSource());
    assertFalse(contents[0].isPath());
    assertEquals("/foo_module.js", contents[1].getSource());
    assertTrue(contents[1].isPath());
  }
Exemplo n.º 2
0
  public void testResourceBundle() throws Exception {
    String config =
        ""
            + "<gatein-resources>"
            + "<portal>"
            + "<name>foo</name>"
            + "<module>"
            + "<script>"
            + "<name>foo_module</name>"
            + "<path>/foo_module.js</path>"
            + "<resource-bundle>my_bundle</resource-bundle>"
            + "</script>"
            + "</module>"
            + "</portal>"
            + "</gatein-resources>";

    //
    JavascriptConfigParser parser =
        new JavascriptConfigParser(
            new MockServletContext("mypath"), new ByteArrayInputStream(config.getBytes("UTF-8")));
    List<ScriptResourceDescriptor> scripts = parseScripts(parser);
    assertEquals(1, scripts.size());
    ScriptResourceDescriptor desc = scripts.get(0);
    assertEquals(new ResourceId(ResourceScope.PORTAL, "foo"), desc.getId());
    assertEquals(1, desc.getModules().size());
    Javascript.Local js = (Javascript.Local) desc.getModules().get(0);
    assertEquals("my_bundle", js.getResourceBundle());
  }