Package org.apache.tiles.definition.digester

Examples of org.apache.tiles.definition.digester.DigesterDefinitionsReader$FillDefinitionRule


    /**
     * Tests the read method under normal conditions.
     */
    public void testRead() {
        try {
            DefinitionsReader reader = new DigesterDefinitionsReader();
            reader.init(new HashMap<String, String>());
           
            URL configFile = this.getClass().getClassLoader().getResource(
                    "org/apache/tiles/config/tiles-defs.xml");
            assertNotNull("Config file not found", configFile);
           
            InputStream source = configFile.openStream();
            Map<String, Definition> definitions = reader.read(source);
           
            assertNotNull("Definitions not returned.", definitions);
            assertNotNull("Couldn't find doc.mainLayout tile.",
                    definitions.get("doc.mainLayout"));
            assertNotNull("Couldn't Find title attribute.", definitions.get(
View Full Code Here


    /**
     * Tests calling read without calling init.
     */
    public void testNoInit() {
        try {
            DefinitionsReader reader = new DigesterDefinitionsReader();
           
            // What happens if we don't call init?
            // reader.init(new HashMap());
           
            URL configFile = this.getClass().getClassLoader().getResource(
                    "org/apache/tiles/config/tiles-defs.xml");
            assertNotNull("Config file not found", configFile);
           
            InputStream source = configFile.openStream();
            reader.read(source);
           
            fail("Should've thrown exception.");
        } catch (DefinitionsFactoryException e) {
            // correct.
        } catch (Exception e) {
View Full Code Here

     * Tests read with bad input source.
     */
    public void testBadSource() {
        try {
            // Create Digester Reader.
            DefinitionsReader reader = new DigesterDefinitionsReader();
            Map<String, String> params = new HashMap<String, String>();

            // Initialize reader.
            reader.init(params);

            // Read definitions.
            reader.read(new String("Bad Input"));
            fail("Should've thrown an exception.");
        } catch (DefinitionsFactoryException e) {
            // correct.
        } catch (Exception e) {
            fail("Exception reading configuration." + e);
View Full Code Here

    /**
     * Tests read with bad XML source.
     */
    public void testBadXml() {
        try {
            DefinitionsReader reader = new DigesterDefinitionsReader();
            reader.init(new HashMap<String, String>());
           
            URL configFile = this.getClass().getClassLoader().getResource(
                    "org/apache/tiles/config/malformed-defs.xml");
            assertNotNull("Config file not found", configFile);
           
            InputStream source = configFile.openStream();
            reader.read(source);
            fail("Should've thrown an exception.");
        } catch (DefinitionsFactoryException e) {
            // correct.
        } catch (Exception e) {
            fail("Exception reading configuration." + e);
View Full Code Here

            params.get(DefinitionsFactory.READER_IMPL_PROPERTY);

        if (readerClassName != null) {
            reader = (DefinitionsReader) ClassUtil.instantiate(readerClassName);
        } else {
            reader = new DigesterDefinitionsReader();
        }
        reader.init(params);
       
        String resolverClassName = params
                .get(DefinitionsFactory.LOCALE_RESOLVER_IMPL_PROPERTY);
View Full Code Here

    }

    @Override
    protected DefinitionsReader createDefinitionsReader(TilesApplicationContext applicationContext,
        TilesRequestContextFactory contextFactory) {
      DigesterDefinitionsReader reader = new DigesterDefinitionsReader();
      if (!validateDefinitions){
        Map<String,String> map = new HashMap<String,String>();
        map.put(DigesterDefinitionsReader.PARSER_VALIDATE_PARAMETER_NAME, Boolean.FALSE.toString());
        reader.init(map);
      }
      return reader;
    }
View Full Code Here

      return dao;
    }

    @Override
    protected DefinitionsReader createDefinitionsReader(ApplicationContext context) {
      DigesterDefinitionsReader reader = (DigesterDefinitionsReader) super.createDefinitionsReader(context);
      reader.setValidating(validateDefinitions);
      return reader;
    }
View Full Code Here

    }

    @Override
    protected DefinitionsReader createDefinitionsReader(TilesApplicationContext applicationContext,
        TilesRequestContextFactory contextFactory) {
      DigesterDefinitionsReader reader = new DigesterDefinitionsReader();
      if (!validateDefinitions){
        Map<String,String> map = new HashMap<String,String>();
        map.put(DigesterDefinitionsReader.PARSER_VALIDATE_PARAMETER_NAME, Boolean.FALSE.toString());
        reader.init(map);
      }
      return reader;
    }
View Full Code Here

                .getResource("org/apache/tiles/config/defs-wildcard.xml"))
                .andReturn(url);
        EasyMock.replay(applicationContext);
        ((TilesApplicationContextAware) definitionDao)
                .setApplicationContext(applicationContext);
        definitionDao.setReader(new DigesterDefinitionsReader());

        Definition definition = definitionDao.getDefinition("test.defName.subLayered", Locale.ITALY);
        assertEquals("The template is not correct", "/testName.jsp", definition
                .getTemplateAttribute().getValue());
        assertEquals("The header attribute is not correct",
View Full Code Here

                .getResource("org/apache/tiles/config/defs-wildcard.xml"))
                .andReturn(url);
        EasyMock.replay(applicationContext);
        ((TilesApplicationContextAware) definitionDao)
                .setApplicationContext(applicationContext);
        definitionDao.setReader(new DigesterDefinitionsReader());

        Definition definition = definitionDao.getDefinition("test.defName.subLayered", null);
        assertEquals("The template is not correct", "/testName.jsp", definition
                .getTemplateAttribute().getValue());
        assertEquals("The header attribute is not correct",
View Full Code Here

TOP

Related Classes of org.apache.tiles.definition.digester.DigesterDefinitionsReader$FillDefinitionRule

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.