Author: jkuhnert
Date: Sat Nov 18 13:50:21 2006
New Revision: 476615

URL: http://svn.apache.org/viewvc?view=rev&rev=476615
Log:
Resolves TAPESTRY-881. Added ability to define alternate .properties file names 
on namespace specifications. 

Also added behavior making ApplicationSpecificationInitializer look in the 
classpath as well as context 
path for an app spec by default.

Added:
    tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/
    tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/Home.html   
(with props)
    tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/
    
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/i18n.application
    
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/random.properties
    
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/web.xml
    tapestry/tapestry4/trunk/tapestry-framework/src/test/Fred.application
    
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/i18n/
    
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/i18n/TestI18nResources.java
Modified:
    tapestry/tapestry4/trunk/pom.xml
    
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/workbench.application
    tapestry/tapestry4/trunk/tapestry-framework/pom.xml
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ApplicationSpecificationInitializer.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/wml/Go.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/JettyRunner.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestApplicationSpecificationInitializer.java

Modified: tapestry/tapestry4/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/pom.xml?view=diff&rev=476615&r1=476614&r2=476615
==============================================================================
--- tapestry/tapestry4/trunk/pom.xml (original)
+++ tapestry/tapestry4/trunk/pom.xml Sat Nov 18 13:50:21 2006
@@ -222,7 +222,7 @@
             <dependency>
                 <groupId>org.openqa.selenium.server</groupId>
                 <artifactId>selenium-server</artifactId>
-                <version>0.8.1</version>
+                <version>0.9.1-SNAPSHOT</version>
                 <scope>test</scope>
             </dependency>
         </dependencies>

Modified: 
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/workbench.application
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/workbench.application?view=diff&rev=476615&r1=476614&r2=476615
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/workbench.application
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/workbench.application
 Sat Nov 18 13:50:21 2006
@@ -26,7 +26,7 @@
   <meta key="org.apache.tapestry.component-class-packages" 
value="org.apache.tapestry.workbench.components"/>
   
   <extension name="org.apache.tapestry.request-decoder" 
class="org.apache.tapestry.workbench.RequestDecoder"/>
-         
+  
   <library id="contrib" 
specification-path="classpath:/org/apache/tapestry/contrib/Contrib.library"/>
   
 </application>

Modified: tapestry/tapestry4/trunk/tapestry-framework/pom.xml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/pom.xml?view=diff&rev=476615&r1=476614&r2=476615
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/pom.xml Sat Nov 18 13:50:21 2006
@@ -1,5 +1,4 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0";
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.apache.tapestry</groupId>
@@ -119,17 +118,20 @@
         <dependency>
             <groupId>org.apache.tapestry</groupId>
             <artifactId>tapestry-test</artifactId>
-        </dependency>        
-        
+        </dependency>
+
         <dependency>
             <groupId>org.openqa.selenium.client-drivers</groupId>
-            <artifactId>selenium-java-client-driver</artifactId>               
 
-        </dependency>   
+            <artifactId>selenium-java-client-driver</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.openqa.selenium.server</groupId>
-            <artifactId>selenium-server</artifactId>                
-        </dependency>        
-        
+            <artifactId>selenium-server</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+        </dependency>
     </dependencies>
 
     <build>
@@ -228,14 +230,14 @@
                 </reportSets>
             </plugin>
             <!-- 
-            <plugin>
+                <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-checkstyle-plugin</artifactId>
                 <version>2.2-SNAPSHOT</version>
                 <configuration>
-                    
<configLocation>${basedir}/../tapestry-checkstyle.xml</configLocation>
+                
<configLocation>${basedir}/../tapestry-checkstyle.xml</configLocation>
                 </configuration>
-            </plugin>
+                </plugin>
             -->
         </plugins>
     </reporting>

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ApplicationSpecificationInitializer.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ApplicationSpecificationInitializer.java?view=diff&rev=476615&r1=476614&r2=476615
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ApplicationSpecificationInitializer.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ApplicationSpecificationInitializer.java
 Sat Nov 18 13:50:21 2006
@@ -55,12 +55,11 @@
         if (specResource == null)
         {
             _log.warn(ImplMessages.noApplicationSpecification(servlet));
-
+            
             spec = constructStandinSpecification(servlet);
-        }
-        else
+        } else
             spec = _parser.parseApplicationSpecification(specResource);
-
+        
         _globals.storeActivator(new HttpServletWebActivator(servlet));
         _globals.storeSpecification(spec);
     }
@@ -82,8 +81,18 @@
         Resource result = check(webInfAppLocation, expectedName);
         if (result != null)
             return result;
-
-        return check(webInfLocation, expectedName);
+        
+        result = check(webInfLocation, expectedName);
+        if (result != null)
+            return result;
+        
+        // Now look for it in classpath, just in case
+        
+        result = _classpathResourceFactory.newResource(expectedName);
+        if (result != null && result.getResourceURL() != null)
+            return result;
+        
+        return null;
     }
 
     private Resource check(Resource resource, String name)

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java?view=diff&rev=476615&r1=476614&r2=476615
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java
 Sat Nov 18 13:50:21 2006
@@ -14,6 +14,8 @@
 
 package org.apache.tapestry.services.impl;
 
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+
 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -56,6 +58,13 @@
 
     public static final String MESSAGES_ENCODING_PROPERTY_NAME = 
"org.apache.tapestry.messages-encoding";
     
+    /**
+     * The alternate file name of a namespace properties file to lookup. Can 
be used to override the default
+     * behaviour which is to look for a &lt;namespace name&gt;.properties file 
to find localized/global properties.
+     */
+    
+    public static final String NAMESPACE_PROPERTIES_NAME = 
"org.apache.tapestry.namespace-properties-name";
+    
     private static final String SUFFIX = ".properties";
     
     private Properties _emptyProperties = new Properties();
@@ -66,7 +75,7 @@
      * a [EMAIL PROTECTED] Properties}.
      */
 
-    private Map _componentCache = new HashMap();
+    private Map _componentCache = new ConcurrentHashMap();
 
     private ComponentPropertySource _componentPropertySource;
 
@@ -76,27 +85,24 @@
      * the component's containing page.
      */
 
-    protected synchronized Properties getLocalizedProperties(
-            IComponent component)
+    protected Properties getLocalizedProperties(IComponent component)
     {
         Defense.notNull(component, "component");
 
-        Resource specificationLocation = component.getSpecification()
-                .getSpecificationLocation();
+        Resource specificationLocation = 
component.getSpecification().getSpecificationLocation();
+        
         Locale locale = component.getPage().getLocale();
-
+        
         Map propertiesMap = 
findPropertiesMapForResource(specificationLocation);
-
+        
         Properties result = (Properties) propertiesMap.get(locale);
 
         if (result == null)
         {
-
             // Not found, create it now.
-
-            result = assembleComponentProperties(component,
-                    specificationLocation, propertiesMap, locale);
-
+            
+            result = assembleComponentProperties(component, 
specificationLocation, propertiesMap, locale);
+            
             propertiesMap.put(locale, result);
         }
 
@@ -116,17 +122,16 @@
         return result;
     }
 
-    private Properties getNamespaceProperties(IComponent component,
-            Locale locale)
+    private Properties getNamespaceProperties(IComponent component, Locale 
locale)
     {
         INamespace namespace = component.getNamespace();
-
+        
         Resource namespaceLocation = namespace.getSpecificationLocation();
-
+        
         Map propertiesMap = findPropertiesMapForResource(namespaceLocation);
-
+        
         Properties result = (Properties) propertiesMap.get(locale);
-
+        
         if (result == null)
         {
             result = assembleNamespaceProperties(namespace, propertiesMap,
@@ -138,12 +143,13 @@
         return result;
     }
 
-    private Properties assembleComponentProperties(IComponent component,
-            Resource baseResourceLocation, Map propertiesMap, Locale locale)
+    private Properties assembleComponentProperties(IComponent component, 
Resource baseResourceLocation, 
+            Map propertiesMap, Locale locale)
     {
-        List localizations = findLocalizationsForResource(baseResourceLocation,
-                locale);
-
+        List localizations = 
+            findLocalizationsForResource(baseResourceLocation, locale, 
+                
component.getSpecification().getProperty(NAMESPACE_PROPERTIES_NAME));
+        
         Properties parent = null;
         Properties assembledProperties = null;
 
@@ -164,8 +170,7 @@
             assembledProperties = new Properties(namespaceProperties);
 
             // Read localized properties for component
-            Properties properties = readComponentProperties(component, l, rl
-                    .getResource(), null);
+            Properties properties = readComponentProperties(component, l, 
rl.getResource(), null);
 
             // Override parent properties with current locale
             if (parent != null)
@@ -187,11 +192,12 @@
     private Properties assembleNamespaceProperties(INamespace namespace,
             Map propertiesMap, Locale locale)
     {
-        List localizations = findLocalizationsForResource(namespace
-                .getSpecificationLocation(), locale);
-
+        List localizations = 
+            findLocalizationsForResource(namespace.getSpecificationLocation(), 
locale, 
+                    namespace.getPropertyValue(NAMESPACE_PROPERTIES_NAME));
+        
         // Build them back up in reverse order.
-
+        
         Properties parent = _emptyProperties;
 
         Iterator i = localizations.iterator();
@@ -206,9 +212,8 @@
 
             if (properties == null)
             {
-                properties = readNamespaceProperties(namespace, l, rl
-                        .getResource(), parent);
-
+                properties = readNamespaceProperties(namespace, l, 
rl.getResource(), parent);
+                
                 propertiesMap.put(l, properties);
             }
 
@@ -226,21 +231,20 @@
      * to most specific (i.e., "foo_en_US_yokel.properties").
      */
 
-    private List findLocalizationsForResource(Resource resource, Locale locale)
+    private List findLocalizationsForResource(Resource resource, Locale 
locale, String alternateName)
     {
         List result = new ArrayList();
-
-        String baseName = extractBaseName(resource);
-
-        LocalizedNameGenerator g = new LocalizedNameGenerator(baseName, locale,
-                SUFFIX);
-
+        
+        String baseName = alternateName == null ? extractBaseName(resource) : 
alternateName;
+        
+        LocalizedNameGenerator g = new LocalizedNameGenerator(baseName, 
locale, SUFFIX);
+        
         while(g.more())
         {
             String localizedName = g.next();
             Locale l = g.getCurrentLocale();
-            Resource localizedResource = resource
-                    .getRelativeResource(localizedName);
+            
+            Resource localizedResource = 
resource.getRelativeResource(localizedName);
 
             result.add(new ResourceLocalization(l, localizedResource));
         }
@@ -262,29 +266,26 @@
             Locale locale, Resource propertiesResource, Properties parent)
     {
         String encoding = getComponentMessagesEncoding(component, locale);
-
-        return readPropertiesResource(propertiesResource.getResourceURL(),
-                encoding, parent);
+        
+        return readPropertiesResource(propertiesResource.getResourceURL(), 
encoding, parent);
     }
-
+    
     private Properties readNamespaceProperties(INamespace namespace,
             Locale locale, Resource propertiesResource, Properties parent)
     {
         String encoding = getNamespaceMessagesEncoding(namespace, locale);
-
-        return readPropertiesResource(propertiesResource.getResourceURL(),
-                encoding, parent);
+        
+        return readPropertiesResource(propertiesResource.getResourceURL(), 
encoding, parent);
     }
 
-    private Properties readPropertiesResource(URL resourceURL, String encoding,
-            Properties parent)
+    private Properties readPropertiesResource(URL resourceURL, String 
encoding, Properties parent)
     {
         if (resourceURL == null) return parent;
-
+        
         Properties result = new Properties(parent);
-
+        
         LocalizedProperties wrapper = new LocalizedProperties(result);
-
+        
         InputStream input = null;
 
         try
@@ -293,7 +294,8 @@
 
             if (encoding == null)
                 wrapper.load(input);
-            else wrapper.load(input, encoding);
+            else 
+                wrapper.load(input, encoding);
 
             input.close();
         }
@@ -326,7 +328,7 @@
      * Clears the cache of read properties files.
      */
 
-    public synchronized void resetEventDidOccur()
+    public void resetEventDidOccur()
     {
         _componentCache.clear();
     }
@@ -340,8 +342,7 @@
     private String getComponentMessagesEncoding(IComponent component,
             Locale locale)
     {
-        String encoding = _componentPropertySource
-                .getLocalizedComponentProperty(component, locale,
+        String encoding = 
_componentPropertySource.getLocalizedComponentProperty(component, locale,
                         MESSAGES_ENCODING_PROPERTY_NAME);
 
         if (encoding == null)

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/wml/Go.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/wml/Go.java?view=diff&rev=476615&r1=476614&r2=476615
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/wml/Go.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/wml/Go.java
 Sat Nov 18 13:50:21 2006
@@ -17,7 +17,6 @@
 import org.apache.tapestry.IMarkupWriter;
 import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.form.Form;
-import org.apache.tapestry.form.FormSupport;
 
 /**
  * The go element declares a go task, indicating navigation to a URI. If the 
URI

Added: tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/Home.html
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/Home.html?view=auto&rev=476615
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/Home.html 
(added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/Home.html 
Sat Nov 18 13:50:21 2006
@@ -0,0 +1,5 @@
+<html jwcid="@Shell" title="i18n Tests">
+    <body jwcid="@Body">    
+        Hello <span key="name"/>.  
+    </body>
+</html>

Propchange: 
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/Home.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/i18n.application
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/i18n.application?view=auto&rev=476615
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/i18n.application
 (added)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/i18n.application
 Sat Nov 18 13:50:21 2006
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+   Copyright 2006 The Apache Software Foundation
+
+   Licensed 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.
+-->
+
+<!DOCTYPE application PUBLIC 
+  "-//Apache Software Foundation//Tapestry Specification 4.0//EN" 
+  "http://tapestry.apache.org/dtd/Tapestry_4_0.dtd";>
+       
+<application name="Various i18n tests">
+    
+    <meta key="org.apache.tapestry.page-class-packages" 
+       value="org.apache.tapestry.integration.i18n.pages"/>
+    <meta key="org.apache.tapestry.component-class-packages" 
+       value="org.apache.tapestry.integration.i18n.components"/>
+   
+    <meta key="org.apache.tapestry.namespace-properties-name"
+        value="random" />
+    
+</application> 

Added: 
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/random.properties
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/random.properties?view=auto&rev=476615
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/random.properties
 (added)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/random.properties
 Sat Nov 18 13:50:21 2006
@@ -0,0 +1,2 @@
+
+name=Random!

Added: 
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/web.xml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/web.xml?view=auto&rev=476615
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/web.xml 
(added)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/web.xml 
Sat Nov 18 13:50:21 2006
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!-- 
+   Copyright 2004, 2005 The Apache Software Foundation
+
+   Licensed 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.
+-->
+
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 
2.3//EN"
+"http://java.sun.com/dtd/web-app_2_3.dtd";>
+
+<web-app>
+       <display-name>i18n</display-name>
+       <description>i18n Tests</description>
+       <filter>
+               <filter-name>redirect</filter-name>
+               <filter-class>org.apache.tapestry.RedirectFilter</filter-class>
+       </filter>
+       <filter-mapping>
+               <filter-name>redirect</filter-name>
+               <url-pattern>/</url-pattern>
+       </filter-mapping>
+       
+       <servlet>
+               <servlet-name>i18n</servlet-name>
+               
<servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class>
+               <load-on-startup>0</load-on-startup>
+       </servlet>      
+       
+       <servlet-mapping>
+               <servlet-name>i18n</servlet-name>
+               <url-pattern>/app</url-pattern>
+       </servlet-mapping>
+    
+       <session-config>
+               <session-timeout>15</session-timeout>
+       </session-config>               
+</web-app>

Added: tapestry/tapestry4/trunk/tapestry-framework/src/test/Fred.application
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/Fred.application?view=auto&rev=476615
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/Fred.application 
(added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/Fred.application Sat 
Nov 18 13:50:21 2006
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+   Copyright 2004, 2005 The Apache Software Foundation
+
+   Licensed 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.
+-->
+
+<!DOCTYPE application
+      PUBLIC "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
+      "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd";>
+
+
+<application name="Fred"/>

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/JettyRunner.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/JettyRunner.java?view=diff&rev=476615&r1=476614&r2=476615
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/JettyRunner.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/JettyRunner.java
 Sat Nov 18 13:50:21 2006
@@ -16,6 +16,8 @@
 
 import static java.lang.String.format;
 
+import java.io.File;
+
 import org.mortbay.http.NCSARequestLog;
 import org.mortbay.http.SocketListener;
 import org.mortbay.jetty.Server;
@@ -30,14 +32,16 @@
 
     public static final int DEFAULT_PORT = 80;
 
+    private static final String DEFAULTS_DESCRIPTOR = 
"src/test-data/conf/webdefault.xml";
+    
     private final String _contextPath;
 
     private final int _port;
 
-    private final String _warPath;
+    private String _warPath;
 
     private final Server _jetty;
-
+    
     public static void main(String[] args)
     {
         new JettyRunner("src/test-data/app1");
@@ -65,7 +69,7 @@
         _contextPath = contextPath;
         _port = port;
         _warPath = warPath;
-
+        
         _jetty = createAndStart();
     }
 
@@ -97,13 +101,25 @@
             SocketListener socketListener = new SocketListener();
             socketListener.setPort(_port);
             server.addListener(socketListener);
-
+            
             NCSARequestLog log = new NCSARequestLog();
             server.setRequestLog(log);
-
+            
+            File warPath = new File(_warPath);
+            if (!warPath.exists()) {
+                _warPath = new File("tapestry-framework", _warPath).getPath();
+            }
+            
             WebApplicationContext context = 
server.addWebApplication(_contextPath, _warPath);
-
-            context.setDefaultsDescriptor("src/test-data/conf/webdefault.xml");
+            
+            File descPath = new File(DEFAULTS_DESCRIPTOR);
+            String descriptorPath = descPath.getPath();
+            
+            if (!descPath.exists()) {
+                descriptorPath = new File("tapestry-framework", 
DEFAULTS_DESCRIPTOR).getPath();
+            }
+            
+            context.setDefaultsDescriptor(descriptorPath);
 
             server.start();
 

Added: 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/i18n/TestI18nResources.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/i18n/TestI18nResources.java?view=auto&rev=476615
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/i18n/TestI18nResources.java
 (added)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/i18n/TestI18nResources.java
 Sat Nov 18 13:50:21 2006
@@ -0,0 +1,84 @@
+// Copyright 2004, 2005 The Apache Software Foundation
+//
+// Licensed 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.tapestry.integration.i18n;
+
+import org.apache.tapestry.integration.JettyRunner;
+import org.openqa.selenium.server.SeleniumServer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.Selenium;
+
+
+/**
+ * Tests the i18n test application. 
+ * 
+ * Initially created to test TAPESTRY-881 feature enhancement.
+ *
+ * @author jkuhnert
+ */
[EMAIL PROTECTED](timeOut = 50000, groups = "integration")
+public class TestI18nResources
+{
+    private static final int JETTY_PORT = 9999;
+    private static final String BASE_URL = "http://localhost:9999/";;
+    
+    /** 60 seconds */
+    public static final String PAGE_LOAD_TIMEOUT = "600000";
+    
+    private Selenium _selenium;
+    
+    private SeleniumServer _server;
+    
+    private JettyRunner _jettyRunner;
+    
+    @BeforeClass
+    public void startupBackground() throws Exception
+    {
+        _jettyRunner = new JettyRunner("/", JETTY_PORT, "src/test-data/i18n");
+        
+        _server = new SeleniumServer();
+
+        _server.start();
+
+        _selenium = new DefaultSelenium("localhost", 
SeleniumServer.DEFAULT_PORT, "*firefox",
+                BASE_URL);
+
+        _selenium.start();
+    }
+
+    @AfterClass
+    public void shutdownBackground() throws Exception
+    {
+        _selenium.stop();
+        _selenium = null;
+
+        _server.stop();
+        _server = null;
+
+        _jettyRunner.stop();
+        _jettyRunner = null;
+    }
+    
+    public void test_Key_Exists()
+    throws Exception
+    {
+        _selenium.open(BASE_URL);
+        
+        assert _selenium.isTextPresent("Random!");
+    }
+    
+}

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestApplicationSpecificationInitializer.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestApplicationSpecificationInitializer.java?view=diff&rev=476615&r1=476614&r2=476615
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestApplicationSpecificationInitializer.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestApplicationSpecificationInitializer.java
 Sat Nov 18 13:50:21 2006
@@ -14,7 +14,7 @@
 
 package org.apache.tapestry.services.impl;
 
-import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.*;
 
 import java.net.URL;
 
@@ -97,6 +97,77 @@
         verify();
     }
 
+    public void test_Default_On_Classpath() throws Exception
+    {
+        DefaultClassResolver cr = new DefaultClassResolver();
+        Resource appSpecResource = new ClasspathResource(cr, 
"Fred.application");
+        
+        ApplicationSpecificationInitializer i = new 
ApplicationSpecificationInitializer();
+        Log log = newMock(Log.class);
+        i.setLog(log);
+        
+        ServletContext context = newMock(ServletContext.class);
+        
+        ClasspathResourceFactoryImpl cf = new ClasspathResourceFactoryImpl();
+        cf.setClassResolver(cr);
+
+        i.setClasspathResourceFactory(cf);
+        
+        HttpServlet servlet = new ServletFixture();
+        
+        ServletConfig config = newMock(ServletConfig.class);
+        checkOrder(config, false);
+        
+        IApplicationSpecification as = new ApplicationSpecification();
+        
+        ISpecificationParser parser = newMock(ISpecificationParser.class);
+        
+        i.setParser(parser);
+        
+        
expect(config.getInitParameter(ApplicationSpecificationInitializer.APP_SPEC_PATH_PARAM)).andReturn(null);
+        
+        expect(config.getServletContext()).andReturn(context);
+        
+        expect(config.getServletName()).andReturn("Fred").anyTimes();
+        
+        // begin testing finding spec
+        
+        expect(log.isDebugEnabled()).andReturn(true);
+        
+        Resource r = new ContextResource(context, 
"/WEB-INF/Fred/Fred.application");
+        
+        log.debug("Checking for existence of " + r);
+        
+        expect(context.getResource(r.getPath())).andReturn(null);
+        
+        expect(log.isDebugEnabled()).andReturn(true);
+        
+        r = new ContextResource(context, "/WEB-INF/Fred.application");
+        
+        log.debug("Checking for existence of " + r);
+        
+        expect(context.getResource(r.getPath())).andReturn(null);
+        
+        
expect(parser.parseApplicationSpecification(appSpecResource)).andReturn(as);
+        
+        ApplicationGlobals ag = new ApplicationGlobalsImpl();
+
+        i.setGlobals(ag);
+
+        replay();
+        
+        servlet.init(config);
+        
+        // The real ApplicationServlet will build a Registry and, indirectly, 
invoke this.
+        
+        i.initialize(servlet);
+        
+        assertNotNull(ag.getActivator());
+        assertSame(as, ag.getSpecification());
+
+        verify();
+    }
+    
     public void test_In_App_Context_Folder() throws Exception
     {
         DefaultClassResolver cr = new DefaultClassResolver();


Reply via email to