Package org.apache.tiles

Examples of org.apache.tiles.TilesApplicationContext


        }
    }

    /** {@inheritDoc} */
    public TilesApplicationContext createApplicationContext(Object context) {
        TilesApplicationContext retValue = null;

        for (Iterator<TilesContextFactory> factoryIt = factories.iterator(); factoryIt
                .hasNext() && retValue == null;) {
            retValue = factoryIt.next().createApplicationContext(context);
        }
View Full Code Here


        for (Map.Entry<String, String> entry : initParameters.entrySet()) {
            context.setInitParameter(entry.getKey(), entry.getValue());
        }

        TilesApplicationContext applicationContext = new ServletTilesApplicationContext(
                context);
        AbstractTilesApplicationContextFactory acFactory = AbstractTilesApplicationContextFactory
                .createFactory(applicationContext);
        applicationContext = acFactory.createApplicationContext(context);
View Full Code Here

        }
    }

    /** {@inheritDoc} */
    public TilesApplicationContext createApplicationContext(Object context) {
        TilesApplicationContext retValue = null;

        for (Iterator<AbstractTilesApplicationContextFactory> factoryIt = factories
                .iterator(); factoryIt.hasNext() && retValue == null;) {
            retValue = factoryIt.next().createApplicationContext(context);
        }
View Full Code Here

     * {@link org.apache.tiles.startup.BasicTilesInitializer
     * #getContainerKey(org.apache.tiles.TilesApplicationContext)}.
     */
    public void testGetContainerKey() {
        BasicTilesInitializer initializer = new BasicTilesInitializer();
        TilesApplicationContext context = EasyMock
                .createMock(TilesApplicationContext.class);
        Map<String, String> params = new HashMap<String, String>();
        params.put(BasicTilesInitializer.CONTAINER_KEY_INIT_PARAMETER,
                "myKey");
        EasyMock.expect(context.getInitParams()).andReturn(params);
        EasyMock.replay(context);
        String key = initializer.getContainerKey(context);
        assertEquals("The key is not the same", "myKey", key);
    }
View Full Code Here

    private Map<String, String> defaults;

    /** {@inheritDoc} */
    @Override
    public void setUp() {
        TilesApplicationContext context = EasyMock
                .createMock(TilesApplicationContext.class);

        Map<String, String> initParameters = new HashMap<String, String>();

        initParameters.put(
                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM,
                KeyedDefinitionsFactoryTilesContainerFactory.class.getName());
        initParameters.put(
                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES,
                RepeaterTilesApplicationContextFactory.class.getName());
        initParameters.put(
                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES,
                RepeaterTilesRequestContextFactory.class.getName());
        initParameters.put(
                KeyedDefinitionsFactoryTilesContainerFactory.CONTAINER_KEYS_INIT_PARAM,
                "one,two");
        initParameters.put(
                KeyedDefinitionsFactoryTilesContainer.DEFINITIONS_CONFIG_PREFIX
                        + "one", "/WEB-INF/tiles-one.xml");
        initParameters.put(
                KeyedDefinitionsFactoryTilesContainer.DEFINITIONS_CONFIG_PREFIX
                + "two", "/WEB-INF/tiles-two.xml");
        EasyMock.expect(context.getInitParams()).andReturn(initParameters)
                .anyTimes();
        try {
            Set<URL> urlSet;
            URL url = getClass().getResource("/org/apache/tiles/factory/test-defs.xml");
            urlSet = new HashSet<URL>();
            urlSet.add(url);
            EasyMock.expect(context.getResources("/WEB-INF/tiles.xml")).andReturn(urlSet);
            url = getClass().getResource("/org/apache/tiles/factory/test-defs-key-one.xml");
            urlSet = new HashSet<URL>();
            urlSet.add(url);
            EasyMock.expect(context.getResources("/WEB-INF/tiles-one.xml")).andReturn(urlSet);
            url = getClass().getResource("/org/apache/tiles/factory/test-defs-key-two.xml");
            urlSet = new HashSet<URL>();
            urlSet.add(url);
            EasyMock.expect(context.getResources("/WEB-INF/tiles-two.xml")).andReturn(urlSet);
        } catch (MalformedURLException e) {
            throw new RuntimeException("Error getting Tiles configuration URL",
                    e);
        } catch (IOException e) {
            throw new RuntimeException("Error getting Tiles configuration URL",
View Full Code Here

     * @throws IOException If something goes wrong.
     */
    public void testPostponedDefinitionsFactoryInitialization()
            throws IOException {
        KeyedDefinitionsFactoryTilesContainer container;
        TilesApplicationContext context = EasyMock
                .createMock(TilesApplicationContext.class);

        Map<String, String> initParams = new HashMap<String, String>();
        initParams.put(
                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM,
                KeyedDefinitionsFactoryTilesContainerFactory.class.getName());
        initParams.put(
                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES,
                RepeaterTilesApplicationContextFactory.class.getName());
        initParams.put(ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES,
                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES);
        EasyMock.expect(context.getInitParams()).andReturn(initParams)
                .anyTimes();
        Set<URL> urlSet = new HashSet<URL>();
        URL url = getClass().getResource("/org/apache/tiles/factory/test-defs.xml");
        urlSet = new HashSet<URL>();
        urlSet.add(url);
        EasyMock.expect(context.getResources("/WEB-INF/tiles.xml")).andReturn(urlSet);
        url = getClass().getResource("/org/apache/tiles/factory/test-defs-key-one.xml");
        urlSet = new HashSet<URL>();
        urlSet.add(url);
        EasyMock.expect(context.getResources("/WEB-INF/tiles-one.xml")).andReturn(urlSet);
        url = getClass().getResource("/org/apache/tiles/factory/test-defs-key-two.xml");
        urlSet = new HashSet<URL>();
        urlSet.add(url);
        EasyMock.expect(context.getResources("/WEB-INF/tiles-two.xml")).andReturn(urlSet);
        EasyMock.replay(context);
        KeyedDefinitionsFactoryTilesContainerFactory factory =
            (KeyedDefinitionsFactoryTilesContainerFactory)
            AbstractTilesContainerFactory.getTilesContainerFactory(context);
        factory.setDefaultConfiguration(defaults);
View Full Code Here

    private BasicTilesContainer container;

    /** {@inheritDoc} */
    @Override
    public void setUp() {
        TilesApplicationContext context = EasyMock
                .createMock(TilesApplicationContext.class);
        Map<String, String> initParams = new HashMap<String, String>();
        URL url = getClass().getResource("/org/apache/tiles/factory/test-defs.xml");

        initParams.put(
                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES,
                RepeaterTilesApplicationContextFactory.class.getName());
        initParams.put(
                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES,
                RepeaterTilesRequestContextFactory.class.getName());
        try {
            Set<URL> urls = new HashSet<URL>();
            urls.add(url);
            EasyMock.expect(context.getResources("/WEB-INF/tiles.xml"))
                    .andReturn(urls);
        } catch (IOException e) {
            throw new RuntimeException("Error getting Tiles configuration URL",
                    e);
        }
        EasyMock.expect(context.getInitParams()).andReturn(initParams)
                .anyTimes();
        EasyMock.replay(context);
        AbstractTilesContainerFactory factory = AbstractTilesContainerFactory
                .getTilesContainerFactory(context);
        container = (BasicTilesContainer) factory.createContainer(context);
View Full Code Here

        request = EasyMock.createMock(TilesRequestContext.class);
        EasyMock.expect(request.getRequestScope()).andReturn(requestScope)
                .anyTimes();
        EasyMock.expect(request.getSessionScope()).andReturn(sessionScope)
                .anyTimes();
        TilesApplicationContext applicationContext = EasyMock
                .createMock(TilesApplicationContext.class);
        EasyMock.expect(applicationContext.getApplicationScope()).andReturn(
                applicationScope).anyTimes();
        EasyMock.replay(request, applicationContext);

        evaluator.setApplicationContext(applicationContext);
        Map<String, String> params = new HashMap<String, String>();
View Full Code Here

        config.put(ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES,
                "this.is.not.a.class.Name,"
                + RepeaterTilesApplicationContextFactory.class.getName());
        ChainedTilesApplicationContextFactory factory = new ChainedTilesApplicationContextFactory();
        factory.init(config);
        TilesApplicationContext context = factory.createApplicationContext(appContext);
        assertNotNull("The request context is not correct",
                context == appContext);
    }
View Full Code Here

        List<AbstractTilesApplicationContextFactory> factories =
            new ArrayList<AbstractTilesApplicationContextFactory>();
        RepeaterTilesApplicationContextFactory repFactory = new RepeaterTilesApplicationContextFactory();
        factories.add(repFactory);
        factory.setFactories(factories);
        TilesApplicationContext context = factory
                .createApplicationContext(appContext);
        assertNotNull("The request context is not correct",
                context == requestContext);
    }
View Full Code Here

TOP

Related Classes of org.apache.tiles.TilesApplicationContext

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.