Author: craigmcc
Date: Sat Jan  6 20:33:12 2007
New Revision: 493642

URL: http://svn.apache.org/viewvc?view=rev&rev=493642
Log:
SHALE-262 finish up our first feature for 1.1 by providing an easy way to
use the configuration resources from whatever JSF implementation you are
running to configure the mock objects hierarchy with "real" configuration
info.

Modified:
    shale/framework/trunk/shale-test/pom.xml
    
shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/config/ConfigParser.java
    
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/ConfigParserTestCase.java

Modified: shale/framework/trunk/shale-test/pom.xml
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/pom.xml?view=diff&rev=493642&r1=493641&r2=493642
==============================================================================
--- shale/framework/trunk/shale-test/pom.xml (original)
+++ shale/framework/trunk/shale-test/pom.xml Sat Jan  6 20:33:12 2007
@@ -104,6 +104,12 @@
                     <scope>provided</scope>
                 </dependency>
                 <dependency>
+                    <groupId>org.apache.myfaces.core</groupId>
+                    <artifactId>myfaces-impl</artifactId>
+                    <version>1.1.4</version>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
                     <groupId>javax.servlet</groupId>
                     <artifactId>servlet-api</artifactId>
                     <version>2.4</version>
@@ -146,6 +152,12 @@
                     <artifactId>jsf-api</artifactId>
                     <version>1.2_02</version>
                     <scope>provided</scope>
+                </dependency>
+                <dependency>
+                    <groupId>javax.faces</groupId>
+                    <artifactId>jsf-impl</artifactId>
+                    <version>1.2_02</version>
+                    <scope>test</scope>
                 </dependency>
                 <dependency>
                     <groupId>javax.servlet</groupId>

Modified: 
shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/config/ConfigParser.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/config/ConfigParser.java?view=diff&rev=493642&r1=493641&r2=493642
==============================================================================
--- 
shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/config/ConfigParser.java
 (original)
+++ 
shale/framework/trunk/shale-test/src/main/java/org/apache/shale/test/config/ConfigParser.java
 Sat Jan  6 20:33:12 2007
@@ -66,6 +66,25 @@
     }
     
 
+    // ------------------------------------------------------ Manifest 
Constants
+
+
+    /**
+     * <p>Configuration resource URLs for the JSF RI.</p>
+     */
+    private static final String[] JSFRI_RESOURCES =
+    { "/com/sun/faces/jsf-ri-runtime.xml",
+    };
+
+
+    /**
+     * <p>Configuration resource URLs for Apache MyFaces.</p>
+     */
+    private static final String[] MYFACES_RESOURCES =
+    { "/org/apache/myfaces/resource/standard-faces-config.xml",
+    };
+
+
     // ------------------------------------------------------ Instance 
Variables
 
 
@@ -78,6 +97,28 @@
     // ------------------------------------------------------- Public 
Properties
 
 
+    /**
+     * <p>Return the URLs of the platform configuration resources for this
+     * application.  The following platforms are currently supported:</p>
+     * <ul>
+     * <li>JavaServer Faces Reference Implementation (version 1.0 - 1.2)</li>
+     * <li>MyFaces (version 1.1)</li>
+     * </ul>
+     *
+     * <p>If MyFaces (version 1.2), currently under development, does not 
change
+     * the name of the configuration resource, it will be supported as 
well.</p>
+     */
+    public URL[] getPlatformURLs() {
+
+        URL[] urls = translate(JSFRI_RESOURCES);
+        if (urls[0] == null) {
+            urls = translate(MYFACES_RESOURCES);
+        }
+        return urls;
+
+    }
+
+
     // ---------------------------------------------------------- Public 
Methods
 
 
@@ -169,6 +210,22 @@
         }
         return this.digester;
 
+    }
+
+
+    /**
+     * <p>Translate an array of resource names into an array of resource 
URLs.</p>
+     *
+     * @param names Resource names to translate
+     */
+    private URL[] translate(String[] names) {
+
+        URL[] results = new URL[names.length];
+        for (int i = 0; i < names.length; i++) {
+            results[i] = this.getClass().getResource(names[i]);
+        }
+        return results;
+        
     }
 
 

Modified: 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/ConfigParserTestCase.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/ConfigParserTestCase.java?view=diff&rev=493642&r1=493641&r2=493642
==============================================================================
--- 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/ConfigParserTestCase.java
 (original)
+++ 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/ConfigParserTestCase.java
 Sat Jan  6 20:33:12 2007
@@ -81,6 +81,21 @@
     // ------------------------------------------------- Individual Test 
Methods
 
 
+    // Test access to the platform configuration resources
+    public void testPlatform() throws Exception {
+
+        // Make sure we can acquire a good set of URLs
+        URL[] urls = parser.getPlatformURLs();
+        assertNotNull(urls);
+        assertEquals(1, urls.length);
+        assertNotNull(urls[0]);
+
+        // Now can we actually parse them?
+        parser.parse(urls);
+
+    }
+
+
     // Test a pristine instance
     public void testPristine() {
 


Reply via email to