Author: craigmcc
Date: Sat Jan  6 19:06:03 2007
New Revision: 493637

URL: http://svn.apache.org/viewvc?view=rev&rev=493637
Log:
SHALE-262 Create a concrete Converter and Renderer so we can exercise all
of the configuration processing.  Need to add one more feature so that you
can optionally load the standard component/converter/renderer/validator
implementations from the (platform-specific) configuration resources for
whichever JSF implementation you are using.

Added:
    
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyConverter.java
   (with props)
    
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyRenderer.java
   (with props)
Modified:
    
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/ConfigParserTestCase.java
    
shale/framework/trunk/shale-test/src/test/resources/org/apache/shale/test/config/faces-config-1.xml

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=493637&r1=493636&r2=493637
==============================================================================
--- 
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 19:06:03 2007
@@ -21,6 +21,8 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import javax.faces.convert.Converter;
+import javax.faces.render.Renderer;
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import org.apache.shale.test.base.AbstractJsfTestCase;
@@ -112,6 +114,10 @@
         assertTrue(list.contains("converter-id-1"));
         assertTrue(list.contains("converter-id-2"));
 
+        Converter converter = application.createConverter(Integer.class);
+        assertNotNull(converter);
+        assertTrue(converter instanceof MyConverter);
+
         items = application.getValidatorIds();
         list.clear();
         while (items.hasNext()) {
@@ -120,6 +126,14 @@
         assertTrue(list.contains("validator-id-1"));
         assertTrue(list.contains("validator-id-2"));
 
+        Renderer renderer = renderKit.getRenderer("component-family-1", 
"renderer-type-1");
+        assertNotNull(renderer);
+        assertTrue(renderer instanceof MyRenderer);
+        
+        renderer = renderKit.getRenderer("component-family-2", 
"renderer-type-2");
+        assertNotNull(renderer);
+        assertTrue(renderer instanceof MyRenderer);
+        
     }
 
 

Added: 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyConverter.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyConverter.java?view=auto&rev=493637
==============================================================================
--- 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyConverter.java
 (added)
+++ 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyConverter.java
 Sat Jan  6 19:06:03 2007
@@ -0,0 +1,37 @@
+/*
+ * 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.shale.test.config;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+/**
+ * <p>Concrete converter implementation for testing.</p>
+ */
+public class MyConverter implements Converter {
+
+    public Object getAsObject(FacesContext context, UIComponent component, 
String value) {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getAsString(FacesContext context, UIComponent component, 
Object value) {
+        throw new UnsupportedOperationException();
+    }
+
+}

Propchange: 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyConverter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyRenderer.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyRenderer.java?view=auto&rev=493637
==============================================================================
--- 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyRenderer.java
 (added)
+++ 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyRenderer.java
 Sat Jan  6 19:06:03 2007
@@ -0,0 +1,27 @@
+/*
+ * 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.shale.test.config;
+
+import javax.faces.render.Renderer;
+
+/**
+ * <p>Concrete renderer implementation for testing.</p>
+ */
+public class MyRenderer extends Renderer {
+    
+}

Propchange: 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
shale/framework/trunk/shale-test/src/test/java/org/apache/shale/test/config/MyRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: 
shale/framework/trunk/shale-test/src/test/resources/org/apache/shale/test/config/faces-config-1.xml
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-test/src/test/resources/org/apache/shale/test/config/faces-config-1.xml?view=diff&rev=493637&r1=493636&r2=493637
==============================================================================
--- 
shale/framework/trunk/shale-test/src/test/resources/org/apache/shale/test/config/faces-config-1.xml
 (original)
+++ 
shale/framework/trunk/shale-test/src/test/resources/org/apache/shale/test/config/faces-config-1.xml
 Sat Jan  6 19:06:03 2007
@@ -39,7 +39,10 @@
       <converter-class>com.mycompany.MyConverter2</converter-class>
   </converter>
 
-  <!-- FIXME - need a real converter for by-class registration -->
+  <converter>
+      <converter-for-class>java.lang.Integer</converter-for-class>
+      
<converter-class>org.apache.shale.test.config.MyConverter</converter-class>
+  </converter>
 
   <validator>
       <validator-id>validator-id-1</validator-id>
@@ -51,22 +54,20 @@
       <validator-class>com.mycompany.MyValidator2</validator-class>
   </validator>
 
-<!-- FIXME - need some real Renderer classes
   <render-kit>
 
       <renderer>
           <component-family>component-family-1</component-family>
           <renderer-type>renderer-type-1</renderer-type>
-          <renderer-class>com.mycompany.MyRenderer1</renderer-class>
+          
<renderer-class>org.apache.shale.test.config.MyRenderer</renderer-class>
       </renderer>
 
       <renderer>
           <component-family>component-family-2</component-family>
           <renderer-type>renderer-type-2</renderer-type>
-          <renderer-class>com.mycompany.MyRenderer2</renderer-class>
+          
<renderer-class>org.apache.shale.test.config.MyRenderer</renderer-class>
       </renderer>
 
   </render-kit>
--->
 
 </faces-config>


Reply via email to