Package org.apache.tiles.definition

Examples of org.apache.tiles.definition.DefinitionsReader


    /**
     * Tests {@link LocaleUrlDefinitionDAO#setReader(DefinitionsReader)}.
     */
    public void testSetReader() {
        DefinitionsReader reader = createMock(DefinitionsReader.class);
        replay(reader);
        definitionDao.setReader(reader);
        assertEquals("There reader has not been set correctly", reader, definitionDao.reader);
        verify(reader);
    }
View Full Code Here


        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        List<ApplicationResource> urlSet = new ArrayList<ApplicationResource>();
        urlSet.add(url1);
        expect(applicationContext.getResources("/WEB-INF/tiles.xml")).andReturn(urlSet);
        replay(applicationContext);
        DefinitionsReader reader = new DigesterDefinitionsReader();
        definitionDao.setReader(reader);
        List<ApplicationResource> sourceURLs = new ArrayList<ApplicationResource>();
        sourceURLs.add(url1);
        definitionDao.setSources(sourceURLs);
        assertEquals("The reader is not of the correct class", DigesterDefinitionsReader.class,
View Full Code Here

        List<ApplicationResource> sourceURLs = new ArrayList<ApplicationResource>();
        sourceURLs.add(url1);
        sourceURLs.add(url2);
        sourceURLs.add(url3);
        definitionDao.setSources(sourceURLs);
        DefinitionsReader reader = new DigesterDefinitionsReader();
        definitionDao.setReader(reader);

        assertNotNull("test.def1 definition not found.", definitionDao
                .getDefinition("test.def1", null));
        assertNotNull("test.def2 definition not found.", definitionDao
View Full Code Here

        List<ApplicationResource> sourceURLs = new ArrayList<ApplicationResource>();
        sourceURLs.add(url1);
        sourceURLs.add(url2);
        sourceURLs.add(url3);
        definitionDao.setSources(sourceURLs);
        DefinitionsReader reader = new DigesterDefinitionsReader();
        definitionDao.setReader(reader);

        Map<String, Definition> defaultDefinitions = definitionDao
                .getDefinitions(null);
        Map<String, Definition> usDefinitions = definitionDao
View Full Code Here

    /**
     * Tests {@link LocaleUrlDefinitionDAO#setReader(DefinitionsReader)}.
     */
    public void testSetReader() {
        DefinitionsReader reader = createMock(DefinitionsReader.class);
        definitionDao.setReader(reader);
        assertEquals("There reader has not been set correctly", reader,
                definitionDao.reader);
    }
View Full Code Here

        Set<ApplicationResource> urlSet = new HashSet<ApplicationResource>();
        urlSet.add(url1);
        expect(applicationContext.getResources("/WEB-INF/tiles.xml"))
                .andReturn(urlSet);
        replay(applicationContext);
        DefinitionsReader reader = new DigesterDefinitionsReader();
        definitionDao.setReader(reader);
        List<ApplicationResource> sourceURLs = new ArrayList<ApplicationResource>();
        sourceURLs.add(url1);
        definitionDao.setSources(sourceURLs);
        assertEquals("The reader is not of the correct class",
View Full Code Here

    /**
     * Tests {@link BasicTilesContainerFactory#createDefinitionsReader(
     * ApplicationContext)}.
     */
    public void testCreateDefinitionsReader() {
        DefinitionsReader reader = factory.createDefinitionsReader(applicationContext);
        assertTrue("The class of the reader is not correct", reader instanceof DigesterDefinitionsReader);
    }
View Full Code Here

    /**
     * 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.
            if (LOG.isDebugEnabled()) {
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.
            if (LOG.isDebugEnabled()) {
                LOG.debug("Exception caught, it is OK", e);
View Full Code Here

TOP

Related Classes of org.apache.tiles.definition.DefinitionsReader

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.