You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2008/06/22 16:55:45 UTC

svn commit: r670362 - in /tiles/framework/trunk/tiles-test: ./ src/main/java/org/apache/tiles/test/definition/ src/main/java/org/apache/tiles/test/definition/dao/ src/main/java/org/apache/tiles/test/exception/ src/main/java/org/apache/tiles/test/factor...

Author: apetrelli
Date: Sun Jun 22 07:55:44 2008
New Revision: 670362

URL: http://svn.apache.org/viewvc?rev=670362&view=rev
Log:
TILES-257
Using a demonstration DAO that loads definitions from a DB.
Added Selenium tests.

Added:
    tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/definition/
    tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/definition/dao/
    tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/definition/dao/LocaleDbDefinitionDAO.java   (with props)
    tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/exception/
    tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/exception/TilesTestRuntimeException.java   (with props)
    tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestDbTilesContainerFactory.java   (with props)
    tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/init/
    tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/init/InitContextListener.java   (with props)
    tiles/framework/trunk/tiles-test/src/main/resources/org/apache/tiles/test/
    tiles/framework/trunk/tiles-test/src/main/resources/org/apache/tiles/test/db/
    tiles/framework/trunk/tiles-test/src/main/resources/org/apache/tiles/test/db/schema.sql
    tiles/framework/trunk/tiles-test/src/main/webapp/defaultlocale_db.jsp   (with props)
    tiles/framework/trunk/tiles-test/src/main/webapp/selectlocale_db.jsp   (with props)
    tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_db.jsp   (with props)
    tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_extended_db.jsp   (with props)
    tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionDbTest.html   (with props)
    tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionExtendedDbTest.html   (with props)
    tiles/framework/trunk/tiles-test/src/test/selenium/LocalizationDbTest.html   (with props)
Modified:
    tiles/framework/trunk/tiles-test/pom.xml
    tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/servlet/SelectLocaleServlet.java
    tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/web-24.xml
    tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/web.xml
    tiles/framework/trunk/tiles-test/src/main/webapp/index.jsp
    tiles/framework/trunk/tiles-test/src/test/selenium/TestSuite.html

Modified: tiles/framework/trunk/tiles-test/pom.xml
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/pom.xml?rev=670362&r1=670361&r2=670362&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-test/pom.xml (original)
+++ tiles/framework/trunk/tiles-test/pom.xml Sun Jun 22 07:55:44 2008
@@ -82,6 +82,21 @@
         <artifactId>freemarker</artifactId>
         <version>2.3.10</version>
       </dependency>
+      <dependency>
+        <groupId>hsqldb</groupId>
+        <artifactId>hsqldb</artifactId>
+        <version>1.8.0.7</version>
+      </dependency>
+      <dependency>
+        <groupId>commons-io</groupId>
+        <artifactId>commons-io</artifactId>
+        <version>1.4</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-jdbc</artifactId>
+        <version>2.5.4</version>
+      </dependency>
    </dependencies>
    
    <build>

Added: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/definition/dao/LocaleDbDefinitionDAO.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/definition/dao/LocaleDbDefinitionDAO.java?rev=670362&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/definition/dao/LocaleDbDefinitionDAO.java (added)
+++ tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/definition/dao/LocaleDbDefinitionDAO.java Sun Jun 22 07:55:44 2008
@@ -0,0 +1,276 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tiles.test.definition.dao;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.tiles.Attribute;
+import org.apache.tiles.Definition;
+import org.apache.tiles.definition.dao.DefinitionDAO;
+import org.apache.tiles.util.LocaleUtil;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.jdbc.core.support.JdbcDaoSupport;
+
+/**
+ * Stub definition DAO to demonstrate that Tiles definitions can be stored in a
+ * Database.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LocaleDbDefinitionDAO extends JdbcDaoSupport implements
+        DefinitionDAO<Locale> {
+
+    /**
+     * Selects a customization by its name.
+     */
+    private static final String SELECT_CUSTOMIZATION_BY_NAME_SQL =
+        "select ID, PARENT_ID, NAME from CUSTOMIZATION "
+            + "where NAME = ? ";
+
+    /**
+     * Selects a customization by its Id.
+     */
+    private static final String SELECT_CUSTOMIZATION_BY_ID_SQL =
+        "select ID, PARENT_ID, NAME from CUSTOMIZATION "
+            + "where ID = ? ";
+
+    /**
+     * Selects a definition by its name and a customization Id.
+     */
+    private static final String SELECT_DEFINITION_SQL =
+        "select ID, PARENT_NAME, NAME, PREPARER, TEMPLATE from DEFINITION "
+            + "where NAME = ? and CUSTOMIZATION_ID = ? ";
+
+    /**
+     * Selects attributes of a definition, given the definition Id.
+     */
+    private static final String SELECT_ATTRIBUTES_SQL =
+        "select ID, NAME, TYPE, VALUE, CASCADE_ATTRIBUTE from ATTRIBUTE "
+            + "where DEFINITION_ID = ? ";
+
+    /**
+     * Maps a row of a {@link ResultSet} to a {@link Definition}.
+     */
+    private final DefinitionRowMapper definitionRowMapper = new DefinitionRowMapper();
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    public Definition getDefinition(String name, Locale locale) {
+        List<Map<String, Object>> customizations = null;
+        Long customizationId = null, parentCustomizationId = null;
+        do {
+            customizations = getJdbcTemplate().queryForList(
+                    SELECT_CUSTOMIZATION_BY_NAME_SQL,
+                    new Object[] { locale.toString() });
+            if (!customizations.isEmpty()) {
+                Map<String, Object> customization = customizations.get(0);
+                customizationId = ((Number) customization.get("ID")).longValue();
+                parentCustomizationId = numberToLong((Number) customization.get("PARENT_ID"));
+            } else {
+                locale = LocaleUtil.getParentLocale(locale);
+            }
+        } while (customizations.isEmpty());
+
+        return getDefinition(name, customizationId, parentCustomizationId,
+                locale);
+    }
+
+    /** {@inheritDoc} */
+    public Map<String, Definition> getDefinitions(Locale locale) {
+        throw new UnsupportedOperationException(
+                "Currently the 'getDefinitions' method is not supported");
+    }
+
+    /**
+     * Loads a definition from the DB.
+     *
+     * @param name The name of the definition.
+     * @param baseCustomizationId The id of the customization item.
+     * @param baseParentCustomizationId The id of the parent customization item.
+     * @param locale The locale.
+     * @return The definition.
+     */
+    @SuppressWarnings("unchecked")
+    protected DbDefinition getDefinition(String name, Long baseCustomizationId,
+            Long baseParentCustomizationId, Locale locale) {
+        DbDefinition definition = null;
+        Long customizationId = baseCustomizationId;
+        Long parentCustomizationId = baseParentCustomizationId;
+        List<DbDefinition> definitions = null;
+        boolean finished = false;
+        do {
+            definitions = getJdbcTemplate()
+                    .query(SELECT_DEFINITION_SQL,
+                            new Object[] { name, customizationId },
+                            definitionRowMapper);
+            if (definitions.isEmpty()) {
+                if (parentCustomizationId != null) {
+                    Map<String, Object> customization = getJdbcTemplate().queryForMap(
+                            SELECT_CUSTOMIZATION_BY_ID_SQL,
+                            new Object[] { parentCustomizationId });
+                    customizationId = ((Number) customization.get("ID")).longValue();
+                    parentCustomizationId = numberToLong((Number) customization.get("PARENT_ID"));
+                } else {
+                    finished = true;
+                }
+            } else {
+                definition = definitions.get(0);
+                finished = true;
+            }
+        } while (!finished);
+
+        if (definition != null) {
+            AttributeRowMapper attributeRowMapper = new AttributeRowMapper(definition);
+            getJdbcTemplate().query(SELECT_ATTRIBUTES_SQL,
+                    new Object[] { definition.getId() }, attributeRowMapper);
+        }
+        return definition;
+    }
+
+    /**
+     * Returns a {@link Long} object only if the number is not null.
+     *
+     * @param number The number to convert.
+     * @return The number converted into {@link Long} if not null,
+     * <code>null</code> otherwise.
+     */
+    private static Long numberToLong(Number number) {
+        Long retValue = null;
+        if (number != null) {
+            retValue = number.longValue();
+        }
+        return retValue;
+    }
+
+    /**
+     * A definition with the new property "id".
+     */
+    private static class DbDefinition extends Definition {
+
+        /**
+         * The id of the definition.
+         */
+        private Long id;
+
+        /**
+         * The default constructor.
+         */
+        public DbDefinition() {
+            super();
+        }
+
+        /**
+         * Copy constructor.
+         *
+         * @param definition The definition to copy from.
+         */
+        public DbDefinition(Definition definition) {
+            super(definition);
+        }
+
+        /**
+         * Constructor.
+         *
+         * @param name The name of the definition.
+         * @param template The template on which the definition is based.
+         * @param attributes The attributes of the definition.
+         */
+        public DbDefinition(String name, String template,
+                Map<String, Attribute> attributes) {
+            super(name, template, attributes);
+        }
+
+        /**
+         * Returns the Id of the definition.
+         *
+         * @return The id.
+         */
+        public Long getId() {
+            return id;
+        }
+
+        /**
+         * Sets the id of the definition.
+         *
+         * @param id The id to set
+         */
+        public void setId(Long id) {
+            this.id = id;
+        }
+
+    }
+
+    /**
+     * Maps a row of a {@link ResultSet} to a {@link Definition}.
+     */
+    private static final class DefinitionRowMapper implements RowMapper {
+
+        /** {@inheritDoc} */
+        public Object mapRow(ResultSet rs, int row) throws SQLException {
+            DbDefinition definition = new DbDefinition();
+            definition.setId(numberToLong((Number) rs.getObject("ID")));
+            definition.setName(rs.getString("NAME"));
+            definition.setTemplate(rs.getString("TEMPLATE"));
+            definition.setPreparer(rs.getString("PREPARER"));
+            definition.setExtends(rs.getString("PARENT_NAME"));
+            return definition;
+        }
+
+    }
+
+    /**
+     * Maps a row of a {@link ResultSet} to an {@link Attribute}. It stores the
+     * attributes directly in their definition.
+     */
+    private static final class AttributeRowMapper implements RowMapper {
+
+        /**
+         * The definition in which the attributes will be stored.
+         */
+        private Definition definition;
+
+        /**
+         * Constructor.
+         *
+         * @param definition The definition in which the attributes will be
+         * stored.
+         */
+        private AttributeRowMapper(Definition definition) {
+            this.definition = definition;
+        }
+
+        /** {@inheritDoc} */
+        public Object mapRow(ResultSet rs, int row) throws SQLException {
+            Attribute attribute = new Attribute();
+            attribute.setRenderer(rs.getString("TYPE"));
+            attribute.setValue(rs.getString("VALUE"));
+            definition.putAttribute(rs.getString("NAME"), attribute, rs
+                    .getBoolean("CASCADE_ATTRIBUTE"));
+            return attribute;
+        }
+
+    }
+}

Propchange: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/definition/dao/LocaleDbDefinitionDAO.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/definition/dao/LocaleDbDefinitionDAO.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/exception/TilesTestRuntimeException.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/exception/TilesTestRuntimeException.java?rev=670362&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/exception/TilesTestRuntimeException.java (added)
+++ tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/exception/TilesTestRuntimeException.java Sun Jun 22 07:55:44 2008
@@ -0,0 +1,65 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tiles.test.exception;
+
+/**
+ * Runtime exception used during the execution of the test web application.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TilesTestRuntimeException extends RuntimeException {
+
+    /**
+     * Constructor.
+     */
+    public TilesTestRuntimeException() {
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param message The message of the exception.
+     */
+    public TilesTestRuntimeException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param cause The cause of the exception.
+     */
+    public TilesTestRuntimeException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param message The message of the exception.
+     * @param cause The cause of the exception.
+     */
+    public TilesTestRuntimeException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+}

Propchange: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/exception/TilesTestRuntimeException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/exception/TilesTestRuntimeException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestDbTilesContainerFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestDbTilesContainerFactory.java?rev=670362&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestDbTilesContainerFactory.java (added)
+++ tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestDbTilesContainerFactory.java Sun Jun 22 07:55:44 2008
@@ -0,0 +1,61 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tiles.test.factory;
+
+import java.util.Locale;
+
+import javax.sql.DataSource;
+
+import org.apache.tiles.TilesApplicationContext;
+import org.apache.tiles.context.TilesContextFactory;
+import org.apache.tiles.definition.LocaleDefinitionsFactory;
+import org.apache.tiles.definition.dao.DefinitionDAO;
+import org.apache.tiles.factory.BasicTilesContainerFactory;
+import org.apache.tiles.locale.LocaleResolver;
+import org.apache.tiles.test.definition.dao.LocaleDbDefinitionDAO;
+
+/**
+ * Test alternate Tiles container factory that uses a DB to store definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestDbTilesContainerFactory extends BasicTilesContainerFactory {
+
+    /** {@inheritDoc} */
+    @Override
+    protected DefinitionDAO<Locale> createLocaleDefinitionDao(Object context,
+            TilesApplicationContext applicationContext,
+            TilesContextFactory contextFactory, LocaleResolver resolver) {
+        LocaleDbDefinitionDAO definitionDao = new LocaleDbDefinitionDAO();
+        definitionDao.setDataSource((DataSource) applicationContext
+                .getApplicationScope().get("dataSource"));
+        return definitionDao;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    protected LocaleDefinitionsFactory instantiateDefinitionsFactory(
+            Object context, TilesApplicationContext applicationContext,
+            TilesContextFactory contextFactory, LocaleResolver resolver) {
+        return new LocaleDefinitionsFactory();
+   }
+}

Propchange: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestDbTilesContainerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestDbTilesContainerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/init/InitContextListener.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/init/InitContextListener.java?rev=670362&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/init/InitContextListener.java (added)
+++ tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/init/InitContextListener.java Sun Jun 22 07:55:44 2008
@@ -0,0 +1,137 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tiles.test.init;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.sql.DataSource;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.test.exception.TilesTestRuntimeException;
+import org.hsqldb.jdbc.jdbcDataSource;
+
+/**
+ * Initializes the data source of the DB.
+ *
+ * @version $Rev$ $Date$
+ */
+public class InitContextListener implements ServletContextListener {
+
+    /**
+     * The logging object.
+     */
+    private static final Log LOG = LogFactory.getLog(InitContextListener.class);
+
+    /** {@inheritDoc} */
+    public void contextInitialized(ServletContextEvent event) {
+        DataSource dataSource = createDataSource();
+        event.getServletContext().setAttribute("dataSource", dataSource);
+        String[] commands = getSQLCommands();
+        executeCommands(dataSource, commands);
+    }
+
+    /** {@inheritDoc} */
+    public void contextDestroyed(ServletContextEvent event) {
+        // Do nothing
+    }
+
+    /**
+     * Creates the data source to use.
+     *
+     * @return The data source.
+     */
+    private DataSource createDataSource() {
+        jdbcDataSource dataSource = new jdbcDataSource();
+        dataSource.setDatabase("jdbc:hsqldb:mem:tiles");
+        dataSource.setUser("sa");
+        dataSource.setPassword("");
+        return dataSource;
+    }
+
+    /**
+     * Loads and returns the SQL commands to initialize the DB.
+     *
+     * @return The SQL commands to execute.
+     */
+    private String[] getSQLCommands() {
+        InputStream stream = getClass().getResourceAsStream(
+                "/org/apache/tiles/test/db/schema.sql");
+        String text;
+        try {
+            text = IOUtils.toString(stream);
+        } catch (IOException e) {
+            throw new TilesTestRuntimeException("Cannot read schema SQL text", e);
+        } finally {
+            try {
+                stream.close();
+            } catch (IOException e) {
+                LOG.error("Error during close of the stream containing the SQL schema", e);
+            }
+        }
+        return text.split(";");
+    }
+
+    /**
+     * Execute SQL commands.
+     *
+     * @param dataSource The data source to use.
+     * @param commands The commands to execute.
+     */
+    private void executeCommands(DataSource dataSource, String[] commands) {
+        Connection conn = null;
+        Statement stmt = null;
+        try {
+            conn = dataSource.getConnection();
+            for (int i = 0; i < commands.length; i++) {
+                stmt = conn.createStatement();
+                stmt.executeUpdate(commands[i]);
+            }
+            conn.commit();
+        } catch (SQLException e) {
+            try {
+                conn.rollback();
+            } catch (SQLException e1) {
+                LOG.error("Error during rollback", e);
+            }
+            throw new TilesTestRuntimeException("Error during execution of SQL commands", e);
+        } finally {
+            try {
+                if (conn != null) {
+                    conn.close();
+                }
+                if (stmt != null) {
+                    stmt.close();
+                }
+            } catch (SQLException e) {
+                LOG.error("Error during closing resources", e);
+            }
+        }
+    }
+}

Propchange: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/init/InitContextListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/init/InitContextListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/servlet/SelectLocaleServlet.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/servlet/SelectLocaleServlet.java?rev=670362&r1=670361&r2=670362&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/servlet/SelectLocaleServlet.java (original)
+++ tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/servlet/SelectLocaleServlet.java Sun Jun 22 07:55:44 2008
@@ -23,6 +23,7 @@
 import java.io.IOException;
 import java.util.Locale;
 
+import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
@@ -30,8 +31,8 @@
 import javax.servlet.http.HttpSession;
 
 import org.apache.tiles.TilesContainer;
-import org.apache.tiles.access.TilesAccess;
 import org.apache.tiles.locale.impl.DefaultLocaleResolver;
+import org.apache.tiles.servlet.context.ServletUtil;
 
 /**
  * Servlet able to let a user choose a locale.
@@ -40,6 +41,19 @@
  */
 public class SelectLocaleServlet extends HttpServlet {
 
+    /**
+     * The key of the container to use.
+     */
+    private String containerKey;
+
+    /** {@inheritDoc} */
+    @Override
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        containerKey = config
+                .getInitParameter("org.apache.tiles.test.servlet.ServletConfig.CONTAINER_KEY");
+    }
+
     /** {@inheritDoc} */
     @Override
     protected void doGet(HttpServletRequest request,
@@ -80,7 +94,9 @@
             }
         }
         session.setAttribute(DefaultLocaleResolver.LOCALE_KEY, locale);
-        TilesContainer container = TilesAccess.getContainer(request
+        ServletUtil.setCurrentContainer(request, request
+                .getSession().getServletContext(), containerKey);
+        TilesContainer container = ServletUtil.getCurrentContainer(request, request
                 .getSession().getServletContext());
         container.render("test.localized.definition", request, response);
     }

Added: tiles/framework/trunk/tiles-test/src/main/resources/org/apache/tiles/test/db/schema.sql
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/resources/org/apache/tiles/test/db/schema.sql?rev=670362&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/resources/org/apache/tiles/test/db/schema.sql (added)
+++ tiles/framework/trunk/tiles-test/src/main/resources/org/apache/tiles/test/db/schema.sql Sun Jun 22 07:55:44 2008
@@ -0,0 +1,146 @@
+
+CREATE TABLE public.Definition (
+                id NUMERIC(12,0) NOT NULL,
+                name VARCHAR(255) NOT NULL,
+                preparer VARCHAR(1000) NULL,
+                template VARCHAR(1000) NULL,
+                Customization_id NUMERIC(12,0) NOT NULL,
+                parent_name VARCHAR(255) NULL,
+                CONSTRAINT Definition_pk PRIMARY KEY (id)
+);
+
+CREATE INDEX public.Definition_idx
+ ON public.Definition
+ ( name ASC );
+
+CREATE TABLE public.Attribute (
+                id NUMERIC(12,0) NOT NULL,
+                name VARCHAR(255) NOT NULL,
+                type VARCHAR(255) NULL,
+                value VARCHAR(1000) NOT NULL,
+                cascade_attribute BOOLEAN NOT NULL,
+                Definition_id NUMERIC(12,0) NULL,
+                Parent_id NUMERIC(12,0) NULL,
+                CONSTRAINT Attribute_pk PRIMARY KEY (id)
+);
+
+CREATE TABLE public.Role (
+                id NUMERIC(12,0) NOT NULL,
+                name VARCHAR(255) NOT NULL,
+                CONSTRAINT Role_pk PRIMARY KEY (id)
+);
+
+CREATE INDEX public.Role_idx
+ ON public.Role
+ ( name ASC );
+
+CREATE TABLE public.Customization (
+                id NUMERIC(12,0) NOT NULL,
+                Parent_id NUMERIC(12,0) NULL,
+                name VARCHAR(255) NOT NULL,
+                CONSTRAINT Customization_pk PRIMARY KEY (id)
+);
+
+CREATE INDEX public.Customization_idx
+ ON public.Customization
+ ( name ASC );
+
+CREATE INDEX public.Customization_idx1
+ ON public.Customization
+ ( name ASC );
+
+CREATE TABLE public.Visible_for (
+                Definition_id NUMERIC(12,0) NOT NULL,
+                Role_id NUMERIC(12,0) NOT NULL,
+                CONSTRAINT Visible_for_pk PRIMARY KEY (Definition_id, Role_id)
+);
+
+CREATE TABLE public.Attribute_visible_for (
+                Attribute_id NUMERIC(12,0) NOT NULL,
+                Role_id NUMERIC(12,0) NOT NULL,
+                CONSTRAINT Attribute_visible_for_pk PRIMARY KEY (Attribute_id, Role_id)
+);
+
+
+ALTER TABLE public.Attribute ADD CONSTRAINT Definition_Attribute_fk
+FOREIGN KEY (Definition_id)
+REFERENCES public.Definition (id)
+;
+
+
+ALTER TABLE public.Visible_for ADD CONSTRAINT Definition_Visible_for_fk
+FOREIGN KEY (Definition_id)
+REFERENCES public.Definition (id)
+;
+
+
+ALTER TABLE public.Attribute ADD CONSTRAINT Attribute_Attribute_fk
+FOREIGN KEY (Parent_id)
+REFERENCES public.Attribute (id)
+;
+
+
+ALTER TABLE public.Attribute_visible_for ADD CONSTRAINT Attribute_Attribute_visible_for_fk
+FOREIGN KEY (Attribute_id)
+REFERENCES public.Attribute (id)
+;
+
+
+ALTER TABLE public.Visible_for ADD CONSTRAINT Role_Visible_for_fk
+FOREIGN KEY (Role_id)
+REFERENCES public.Role (id)
+;
+
+
+ALTER TABLE public.Attribute_visible_for ADD CONSTRAINT Role_Attribute_visible_for_fk
+FOREIGN KEY (Role_id)
+REFERENCES public.Role (id)
+;
+
+
+ALTER TABLE public.Definition ADD CONSTRAINT Customization_Definition_fk
+FOREIGN KEY (Customization_id)
+REFERENCES public.Customization (id)
+;
+
+
+ALTER TABLE public.Customization ADD CONSTRAINT Customization_Customization_fk
+FOREIGN KEY (Parent_id)
+REFERENCES public.Customization (id)
+;
+
+INSERT INTO "PUBLIC"."CUSTOMIZATION" (ID,PARENT_ID,NAME) VALUES (0,null,'');
+INSERT INTO "PUBLIC"."CUSTOMIZATION" (ID,PARENT_ID,NAME) VALUES (1,0,'en');
+INSERT INTO "PUBLIC"."CUSTOMIZATION" (ID,PARENT_ID,NAME) VALUES (2,1,'en_GB');
+INSERT INTO "PUBLIC"."CUSTOMIZATION" (ID,PARENT_ID,NAME) VALUES (3,1,'en_US');
+INSERT INTO "PUBLIC"."CUSTOMIZATION" (ID,PARENT_ID,NAME) VALUES (4,0,'fr');
+INSERT INTO "PUBLIC"."CUSTOMIZATION" (ID,PARENT_ID,NAME) VALUES (5,0,'it');
+
+INSERT INTO "PUBLIC"."DEFINITION" (ID,PARENT_NAME,NAME,PREPARER,TEMPLATE,CUSTOMIZATION_ID) VALUES (0,null,'test.localized.definition',null,'/layout.jsp',0);
+INSERT INTO "PUBLIC"."DEFINITION" (ID,PARENT_NAME,NAME,PREPARER,TEMPLATE,CUSTOMIZATION_ID) VALUES (2,null,'test.localized.definition',null,'/layout.jsp',2);
+INSERT INTO "PUBLIC"."DEFINITION" (ID,PARENT_NAME,NAME,PREPARER,TEMPLATE,CUSTOMIZATION_ID) VALUES (3,null,'test.localized.definition',null,'/layout.jsp',3);
+INSERT INTO "PUBLIC"."DEFINITION" (ID,PARENT_NAME,NAME,PREPARER,TEMPLATE,CUSTOMIZATION_ID) VALUES (4,null,'test.localized.definition',null,'/layout.jsp',4);
+INSERT INTO "PUBLIC"."DEFINITION" (ID,PARENT_NAME,NAME,PREPARER,TEMPLATE,CUSTOMIZATION_ID) VALUES (5,null,'test.localized.definition',null,'/layout.jsp',5);
+
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (0,'title',null,'Default locale',0,0,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (1,'header',null,'/header.jsp',0,0,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (2,'body',null,'/defaultlocale_db.jsp',0,0,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (3,'title',null,'British English locale',0,2,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (4,'header',null,'/header.jsp',0,2,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (5,'body',null,'/defaultlocale_db.jsp',0,2,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (6,'title',null,'American English locale',0,3,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (7,'header',null,'/header.jsp',0,3,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (8,'body',null,'/defaultlocale_db.jsp',0,3,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (9,'title',null,'French locale',0,4,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (10,'header',null,'/header.jsp',0,4,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (11,'body',null,'/defaultlocale_db.jsp',0,4,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (12,'title',null,'Italian locale',0,5,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (13,'header',null,'/header.jsp',0,5,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (14,'body',null,'/defaultlocale_db.jsp',0,5,null);
+
+INSERT INTO "PUBLIC"."DEFINITION" (ID,PARENT_NAME,NAME,PREPARER,TEMPLATE,CUSTOMIZATION_ID) VALUES (6,null,'test.definition',null,'/layout.jsp',0);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (15,'title',null,'This is the title.',0,6,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (16,'header',null,'/header.jsp',0,6,null);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (17,'body',null,'/body.jsp',0,6,null);
+INSERT INTO "PUBLIC"."DEFINITION" (ID,PARENT_NAME,NAME,PREPARER,TEMPLATE,CUSTOMIZATION_ID) VALUES (7,'test.definition','test.definition.extended',null,null,0);
+INSERT INTO "PUBLIC"."ATTRIBUTE" (ID,NAME,TYPE,VALUE,CASCADE_ATTRIBUTE,DEFINITION_ID,PARENT_ID) VALUES (18,'title',null,'This is an extended definition.',0,7,null);

Modified: tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/web-24.xml
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/web-24.xml?rev=670362&r1=670361&r2=670362&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/web-24.xml (original)
+++ tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/web-24.xml Sun Jun 22 07:55:44 2008
@@ -30,6 +30,9 @@
     <display-name>Tiles 2 Test Application</display-name>
     <distributable/>
 
+    <listener>
+      <listener-class>org.apache.tiles.test.init.InitContextListener</listener-class>
+    </listener>
     <filter>
         <filter-name>Tiles Decoration Filter</filter-name>
         <filter-class>org.apache.tiles.web.util.TilesDecorationFilter</filter-class>
@@ -64,16 +67,15 @@
     <servlet>
         <servlet-name>tiles</servlet-name>
         <servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
-        <load-on-startup>2</load-on-startup>
         <init-param>
             <param-name>org.apache.tiles.factory.AbstractTilesContainerFactory</param-name>
             <param-value>org.apache.tiles.test.factory.TestTilesContainerFactory</param-value>
         </init-param>
+        <load-on-startup>2</load-on-startup>
     </servlet>
     <servlet>
         <servlet-name>tiles-alt</servlet-name>
         <servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
-        <load-on-startup>3</load-on-startup>
         <init-param>
             <param-name>org.apache.tiles.factory.AbstractTilesContainerFactory</param-name>
             <param-value>org.apache.tiles.test.factory.TestAlternateTilesContainerFactory</param-value>
@@ -82,6 +84,20 @@
             <param-name>org.apache.tiles.web.startup.TilesListener.CONTAINER_KEY</param-name>
             <param-value>alternate</param-value>
         </init-param>
+        <load-on-startup>3</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>tiles-db</servlet-name>
+        <servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
+        <init-param>
+            <param-name>org.apache.tiles.factory.AbstractTilesContainerFactory</param-name>
+            <param-value>org.apache.tiles.test.factory.TestDbTilesContainerFactory</param-value>
+        </init-param>
+        <init-param>
+            <param-name>org.apache.tiles.web.startup.TilesListener.CONTAINER_KEY</param-name>
+            <param-value>db</param-value>
+        </init-param>
+        <load-on-startup>4</load-on-startup>
     </servlet>
     <servlet>
         <servlet-name>freemarker</servlet-name>
@@ -115,7 +131,7 @@
             <param-value>0.##########</param-value>
         </init-param>
         
-        <load-on-startup>3</load-on-startup>
+        <load-on-startup>5</load-on-startup>
     </servlet>
 
     <servlet>
@@ -140,6 +156,14 @@
         <servlet-name>selectLocaleServlet</servlet-name>
         <servlet-class>org.apache.tiles.test.servlet.SelectLocaleServlet</servlet-class>
     </servlet>
+    <servlet>
+        <servlet-name>selectLocaleServletDb</servlet-name>
+        <servlet-class>org.apache.tiles.test.servlet.SelectLocaleServlet</servlet-class>
+        <init-param>
+            <param-name>org.apache.tiles.test.servlet.ServletConfig.CONTAINER_KEY</param-name>
+            <param-value>db</param-value>
+        </init-param>
+    </servlet>
 
     <welcome-file-list>
         <welcome-file>index.jsp</welcome-file>
@@ -160,8 +184,12 @@
     </servlet-mapping>
 
     <servlet-mapping>
+        <servlet-name>selectLocaleServletDb</servlet-name>
+        <url-pattern>/servlets/selectLocaleServletDb</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
         <servlet-name>Tiles Dispatch Servlet</servlet-name>
         <url-pattern>*.tiles</url-pattern>
     </servlet-mapping>
-
 </web-app>

Modified: tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/web.xml?rev=670362&r1=670361&r2=670362&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/web.xml (original)
+++ tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/web.xml Sun Jun 22 07:55:44 2008
@@ -22,14 +22,17 @@
  */
 -->
 
-<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
          version="2.5">
 
     <display-name>Tiles 2 Test Application</display-name>
     <distributable/>
 
+    <listener>
+      <listener-class>org.apache.tiles.test.init.InitContextListener</listener-class>
+    </listener>
     <filter>
         <filter-name>Tiles Decoration Filter</filter-name>
         <filter-class>org.apache.tiles.web.util.TilesDecorationFilter</filter-class>
@@ -64,16 +67,15 @@
     <servlet>
         <servlet-name>tiles</servlet-name>
         <servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
-        <load-on-startup>2</load-on-startup>
         <init-param>
             <param-name>org.apache.tiles.factory.AbstractTilesContainerFactory</param-name>
             <param-value>org.apache.tiles.test.factory.TestTilesContainerFactory</param-value>
         </init-param>
+        <load-on-startup>2</load-on-startup>
     </servlet>
     <servlet>
         <servlet-name>tiles-alt</servlet-name>
         <servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
-        <load-on-startup>3</load-on-startup>
         <init-param>
             <param-name>org.apache.tiles.factory.AbstractTilesContainerFactory</param-name>
             <param-value>org.apache.tiles.test.factory.TestAlternateTilesContainerFactory</param-value>
@@ -82,6 +84,20 @@
             <param-name>org.apache.tiles.web.startup.TilesListener.CONTAINER_KEY</param-name>
             <param-value>alternate</param-value>
         </init-param>
+        <load-on-startup>3</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>tiles-db</servlet-name>
+        <servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
+        <init-param>
+            <param-name>org.apache.tiles.factory.AbstractTilesContainerFactory</param-name>
+            <param-value>org.apache.tiles.test.factory.TestDbTilesContainerFactory</param-value>
+        </init-param>
+        <init-param>
+            <param-name>org.apache.tiles.web.startup.TilesListener.CONTAINER_KEY</param-name>
+            <param-value>db</param-value>
+        </init-param>
+        <load-on-startup>4</load-on-startup>
     </servlet>
     <servlet>
         <servlet-name>freemarker</servlet-name>
@@ -115,7 +131,7 @@
             <param-value>0.##########</param-value>
         </init-param>
         
-        <load-on-startup>4</load-on-startup>
+        <load-on-startup>5</load-on-startup>
     </servlet>
 
     <servlet>
@@ -140,6 +156,14 @@
         <servlet-name>selectLocaleServlet</servlet-name>
         <servlet-class>org.apache.tiles.test.servlet.SelectLocaleServlet</servlet-class>
     </servlet>
+    <servlet>
+        <servlet-name>selectLocaleServletDb</servlet-name>
+        <servlet-class>org.apache.tiles.test.servlet.SelectLocaleServlet</servlet-class>
+        <init-param>
+            <param-name>org.apache.tiles.test.servlet.ServletConfig.CONTAINER_KEY</param-name>
+            <param-value>db</param-value>
+        </init-param>
+    </servlet>
 
     <welcome-file-list>
         <welcome-file>index.jsp</welcome-file>
@@ -160,8 +184,12 @@
     </servlet-mapping>
 
     <servlet-mapping>
+        <servlet-name>selectLocaleServletDb</servlet-name>
+        <url-pattern>/servlets/selectLocaleServletDb</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
         <servlet-name>Tiles Dispatch Servlet</servlet-name>
         <url-pattern>*.tiles</url-pattern>
     </servlet-mapping>
-
 </web-app>

Added: tiles/framework/trunk/tiles-test/src/main/webapp/defaultlocale_db.jsp
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/webapp/defaultlocale_db.jsp?rev=670362&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/webapp/defaultlocale_db.jsp (added)
+++ tiles/framework/trunk/tiles-test/src/main/webapp/defaultlocale_db.jsp Sun Jun 22 07:55:44 2008
@@ -0,0 +1,28 @@
+<%@ page session="false" %>
+<%--
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+--%>
+<div align="center"><b><i>
+<div id="defaultLocaleMessage">Your default Locale is <%=request.getLocale().toString() %></div>
+</i></b></div>
+<a href="../selectlocale_db.jsp">Select another locale</a>
\ No newline at end of file

Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/defaultlocale_db.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/defaultlocale_db.jsp
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: tiles/framework/trunk/tiles-test/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/webapp/index.jsp?rev=670362&r1=670361&r2=670362&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/webapp/index.jsp (original)
+++ tiles/framework/trunk/tiles-test/src/main/webapp/index.jsp Sun Jun 22 07:55:44 2008
@@ -92,6 +92,11 @@
     <a href="testinsertdefinition_role_tag.jsp">Test Insert Configured Definition with Specified Role in Tag</a><br/>
     <a href="testinsertdefinition_attribute_roles.jsp">Test Insert Configured Definition with Attribute that have Roles</a><br/>
 
+    <h3>Database Verification tests</h3>
+    <a href="testinsertdefinition_db.jsp">Test Insert Configured Definition from DB</a><br/>
+    <a href="testinsertdefinition_extended_db.jsp">Test Insert Extended Configured Definition from DB</a><br/>
+    <a href="selectlocale_db.jsp">Test Localization from DB</a><br/>
+
     <h2>Currently not working tests</h2>
 
 </html>
\ No newline at end of file

Added: tiles/framework/trunk/tiles-test/src/main/webapp/selectlocale_db.jsp
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/webapp/selectlocale_db.jsp?rev=670362&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/webapp/selectlocale_db.jsp (added)
+++ tiles/framework/trunk/tiles-test/src/main/webapp/selectlocale_db.jsp Sun Jun 22 07:55:44 2008
@@ -0,0 +1,45 @@
+<%@ page session="false" %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<%--
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+--%>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Select your locale</title>
+</head>
+<body>
+<form action="servlets/selectLocaleServletDb">
+Select your locale:
+<select name="locale">
+<option selected="selected" value="">Default</option>
+<option value="en_US">American English</option>
+<option value="en_GB">British English</option>
+<option value="fr_FR">French</option>
+<option value="it_IT">Italian</option>
+</select>
+<input type="submit" value="Submit" />
+</form>
+<div id="defaultLocaleMessage">Your default Locale is <%=request.getLocale().toString() %></div>
+</body>
+</html>

Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/selectlocale_db.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/selectlocale_db.jsp
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_db.jsp
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_db.jsp?rev=670362&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_db.jsp (added)
+++ tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_db.jsp Sun Jun 22 07:55:44 2008
@@ -0,0 +1,28 @@
+<%@ page session="false" %>
+<%--
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+--%>
+<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
+
+<tiles:setCurrentContainer containerKey="db"/>
+<tiles:insertDefinition name="test.definition" />

Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_db.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_db.jsp
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_extended_db.jsp
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_extended_db.jsp?rev=670362&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_extended_db.jsp (added)
+++ tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_extended_db.jsp Sun Jun 22 07:55:44 2008
@@ -0,0 +1,28 @@
+<%@ page session="false" %>
+<%--
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+--%>
+<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
+
+<tiles:setCurrentContainer containerKey="db"/>
+<tiles:insertDefinition name="test.definition.extended" />

Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_extended_db.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/framework/trunk/tiles-test/src/main/webapp/testinsertdefinition_extended_db.jsp
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionDbTest.html
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionDbTest.html?rev=670362&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionDbTest.html (added)
+++ tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionDbTest.html Sun Jun 22 07:55:44 2008
@@ -0,0 +1,61 @@
+<!--
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+-->
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Configured Definition Db Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Configured Definition Db Test</td></tr>
+</thead><tbody>
+<tr>
+	<td>open</td>
+	<td>/tiles-test/index.jsp</td>
+	<td></td>
+</tr>
+<tr>
+	<td>clickAndWait</td>
+	<td>link=Test Insert Configured Definition from DB</td>
+	<td></td>
+</tr>
+<tr>
+	<td>assertTextPresent</td>
+	<td>This is the title.</td>
+	<td></td>
+</tr>
+<tr>
+	<td>assertTextPresent</td>
+	<td>This is the header</td>
+	<td></td>
+</tr>
+<tr>
+	<td>assertTextPresent</td>
+	<td>This is a body</td>
+	<td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>

Propchange: tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionDbTest.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionDbTest.html
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionExtendedDbTest.html
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionExtendedDbTest.html?rev=670362&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionExtendedDbTest.html (added)
+++ tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionExtendedDbTest.html Sun Jun 22 07:55:44 2008
@@ -0,0 +1,61 @@
+<!--
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+-->
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Configured Definition Extended Db Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Configured Definition Extended Db Test</td></tr>
+</thead><tbody>
+<tr>
+	<td>open</td>
+	<td>/tiles-test/index.jsp</td>
+	<td></td>
+</tr>
+<tr>
+	<td>clickAndWait</td>
+	<td>link=Test Insert Extended Configured Definition from DB</td>
+	<td></td>
+</tr>
+<tr>
+	<td>assertTextPresent</td>
+	<td>This is an extended definition.</td>
+	<td></td>
+</tr>
+<tr>
+	<td>assertTextPresent</td>
+	<td>This is the header</td>
+	<td></td>
+</tr>
+<tr>
+	<td>assertTextPresent</td>
+	<td>This is a body</td>
+	<td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>

Propchange: tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionExtendedDbTest.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/framework/trunk/tiles-test/src/test/selenium/ConfiguredDefinitionExtendedDbTest.html
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/framework/trunk/tiles-test/src/test/selenium/LocalizationDbTest.html
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/test/selenium/LocalizationDbTest.html?rev=670362&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-test/src/test/selenium/LocalizationDbTest.html (added)
+++ tiles/framework/trunk/tiles-test/src/test/selenium/LocalizationDbTest.html Sun Jun 22 07:55:44 2008
@@ -0,0 +1,141 @@
+<!--
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+-->
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Localization Db Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Localization Db Test</td></tr>
+</thead><tbody>
+<tr>
+	<td>open</td>
+	<td>/tiles-test/index.jsp</td>
+	<td></td>
+</tr>
+<tr>
+	<td>clickAndWait</td>
+	<td>link=Test Localization from DB</td>
+	<td></td>
+</tr>
+<tr>
+	<td>storeText</td>
+	<td>defaultLocaleMessage</td>
+	<td>localeMessage</td>
+</tr>
+<tr>
+	<td>clickAndWait</td>
+	<td>//input[@value='Submit']</td>
+	<td></td>
+</tr>
+<tr>
+	<td>assertText</td>
+	<td>defaultLocaleMessage</td>
+	<td>${localeMessage}</td>
+</tr>
+<tr>
+	<td>clickAndWait</td>
+	<td>link=Select another locale</td>
+	<td></td>
+</tr>
+<tr>
+	<td>select</td>
+	<td>locale</td>
+	<td>label=American English</td>
+</tr>
+<tr>
+	<td>clickAndWait</td>
+	<td>//input[@value='Submit']</td>
+	<td></td>
+</tr>
+<tr>
+	<td>assertTextPresent</td>
+	<td>American English locale</td>
+	<td></td>
+</tr>
+<tr>
+	<td>clickAndWait</td>
+	<td>link=Select another locale</td>
+	<td></td>
+</tr>
+<tr>
+	<td>select</td>
+	<td>locale</td>
+	<td>label=British English</td>
+</tr>
+<tr>
+	<td>clickAndWait</td>
+	<td>//input[@value='Submit']</td>
+	<td></td>
+</tr>
+<tr>
+	<td>assertTextPresent</td>
+	<td>British English locale</td>
+	<td></td>
+</tr>
+<tr>
+	<td>clickAndWait</td>
+	<td>link=Select another locale</td>
+	<td></td>
+</tr>
+<tr>
+	<td>select</td>
+	<td>locale</td>
+	<td>label=French</td>
+</tr>
+<tr>
+	<td>clickAndWait</td>
+	<td>//input[@value='Submit']</td>
+	<td></td>
+</tr>
+<tr>
+	<td>assertTextPresent</td>
+	<td>French locale</td>
+	<td></td>
+</tr>
+<tr>
+	<td>clickAndWait</td>
+	<td>link=Select another locale</td>
+	<td></td>
+</tr>
+<tr>
+	<td>select</td>
+	<td>locale</td>
+	<td>label=Italian</td>
+</tr>
+<tr>
+	<td>clickAndWait</td>
+	<td>//input[@value='Submit']</td>
+	<td></td>
+</tr>
+<tr>
+	<td>assertTextPresent</td>
+	<td>Italian locale</td>
+	<td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>

Propchange: tiles/framework/trunk/tiles-test/src/test/selenium/LocalizationDbTest.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/framework/trunk/tiles-test/src/test/selenium/LocalizationDbTest.html
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: tiles/framework/trunk/tiles-test/src/test/selenium/TestSuite.html
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-test/src/test/selenium/TestSuite.html?rev=670362&r1=670361&r2=670362&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-test/src/test/selenium/TestSuite.html (original)
+++ tiles/framework/trunk/tiles-test/src/test/selenium/TestSuite.html Sun Jun 22 07:55:44 2008
@@ -190,6 +190,15 @@
         <td><a href="ConfiguredDefinitionAttributeRolesTest.html">Configured Definition Attribute Roles Test</a></td>
     </tr>
     <tr>
+        <td><a href="ConfiguredDefinitionDbTest.html">Configured Definition Db Test</a></td>
+    </tr>
+    <tr>
+        <td><a href="ConfiguredDefinitionExtendedDbTest.html">Configured Definition Extended Db Test</a></td>
+    </tr>
+    <tr>
+        <td><a href="LocalizationDbTest.html">Localization Db Test</a></td>
+    </tr>
+    <tr>
         <td><a href="InitContainerTest.html">Init Container Tag Test</a></td>
     </tr>
 </table>