Package org.apache.myfaces.tobago.internal.config

Examples of org.apache.myfaces.tobago.internal.config.ThemeBuilder


public class ThemeParserUnitTest {

  @Test
  public void test() throws IOException, SAXException, ParserConfigurationException, URISyntaxException {
    final ThemeBuilder themeBuilder = TobagoConfigTestUtils.createThemeBuilder();
    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    Enumeration<URL> urls = classLoader.getResources("theme-config.xml");

    final TobagoConfigParser parser = new TobagoConfigParser();
    ThemeImpl theme = null;
    if  (urls.hasMoreElements()) {
      final URL themeUrl = urls.nextElement();
      theme = parser.parse(themeUrl).getThemeDefinitions().get(0);
      Assert.assertEquals("test", theme.getName());
      Assert.assertNotNull(theme.getResources());
      Assert.assertNotNull(theme.getProductionResources());
      final ThemeResources resources = theme.getResources();
      final ThemeResources productionResources = theme.getProductionResources();

      Assert.assertEquals(3, resources.getScriptList().size());
      Assert.assertEquals("script/tobago.js", resources.getScriptList().get(0).getName());
      Assert.assertEquals("script/tobago-logging.js", resources.getScriptList().get(1).getName());
      Assert.assertEquals("script/tobago-console.js", resources.getScriptList().get(2).getName());

      Assert.assertEquals(1, productionResources.getScriptList().size());
      themeBuilder.addTheme(theme);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config2.xml");

    ThemeImpl theme2 = null;
    if (urls.hasMoreElements()) {
      final URL themeUrl = urls.nextElement();
      theme2 = parser.parse(themeUrl).getThemeDefinitions().get(0);
      Assert.assertEquals("test2", theme2.getName());
      Assert.assertNotNull(theme2.getResources());
      Assert.assertEquals(1, theme2.getResources().getScriptList().size());
      Assert.assertEquals(1, theme2.getResources().getStyleList().size());
      themeBuilder.addTheme(theme2);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config3.xml");

    ThemeImpl theme3 = null;
    if (urls.hasMoreElements()) {
      final URL themeUrl = urls.nextElement();
      theme3 = parser.parse(themeUrl).getThemeDefinitions().get(0);
      Assert.assertEquals("test3", theme3.getName());
      Assert.assertEquals(0, theme3.getResources().getScriptList().size());
      Assert.assertEquals(0, theme3.getResources().getStyleList().size());
      themeBuilder.addTheme(theme3);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config4.xml");

    ThemeImpl theme4 = null;
    if (urls.hasMoreElements()) {
      final URL themeUrl = urls.nextElement();
      theme4 = parser.parse(themeUrl).getThemeDefinitions().get(0);
      Assert.assertEquals("test4", theme4.getName());
      Assert.assertEquals(0, theme4.getResources().getScriptList().size());
      Assert.assertEquals(0, theme4.getResources().getStyleList().size());
      themeBuilder.addTheme(theme4);
    } else {
      Assert.fail();
    }

    themeBuilder.resolveThemes();
    Assert.assertEquals(3, theme.getResources().getScriptList().size());
    Assert.assertEquals("script/tobago.js", theme.getResources().getScriptList().get(0).getName());
    Assert.assertEquals("script/tobago-logging.js", theme.getResources().getScriptList().get(1).getName());
    Assert.assertEquals("script/tobago-console.js", theme.getResources().getScriptList().get(2).getName());
View Full Code Here


      final ServletContext servletContext, final TobagoConfigImpl tobagoConfig)
      throws ServletException {
    assert !initialized;
    final ResourceManagerImpl resourceManager = new ResourceManagerImpl(tobagoConfig);

    final ThemeBuilder themeBuilder = new ThemeBuilder(tobagoConfig);
    final ResourceLocator resourceLocator = new ResourceLocator(servletContext, resourceManager, themeBuilder);
    resourceLocator.locate();
    themeBuilder.resolveThemes();

    servletContext.setAttribute(RESOURCE_MANAGER, resourceManager);

    initialized = true;
  }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.tobago.internal.config.ThemeBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.