Revision: 1254
Author:   mathiasbr
Date:     2006-07-31 07:16:23 -0700 (Mon, 31 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/spring-rich-c/?rev=1254&view=rev

Log Message:
-----------
changes to make spring rich run under spring 2.0-rc2

Modified Paths:
--------------
    
branches/spring2migration/archetype/src/main/resources/archetype-resources/pom.xml
    branches/spring2migration/pom.xml
    branches/spring2migration/samples/petclinic/business/pom.xml
    
branches/spring2migration/samples/simple/src/main/java/org/springframework/richclient/samples/simple/ui/convert/DateToText.java
    
branches/spring2migration/samples/simple/src/main/java/org/springframework/richclient/samples/simple/ui/convert/TextToDate.java
    branches/spring2migration/sandbox/pom.xml
    branches/spring2migration/support/pom.xml
    
branches/spring2migration/support/src/main/java/org/springframework/binding/validation/support/ValangRichValidator.java
    
branches/spring2migration/support/src/main/java/org/springframework/binding/value/support/BufferedCollectionValueModel.java
    
branches/spring2migration/support/src/main/java/org/springframework/richclient/application/DefaultConversionService.java
    
branches/spring2migration/support/src/main/java/org/springframework/richclient/tree/BeanTreeCellRenderer.java
    
branches/spring2migration/support/src/main/java/org/springframework/richclient/util/ClassUtils.java
    
branches/spring2migration/support/src/test/java/org/springframework/binding/form/support/AbstractFormModelTests.java
    
branches/spring2migration/support/src/test/java/org/springframework/binding/form/support/DefaultFormModelTests.java
Modified: 
branches/spring2migration/archetype/src/main/resources/archetype-resources/pom.xml
===================================================================
--- 
branches/spring2migration/archetype/src/main/resources/archetype-resources/pom.xml
  2006-07-31 11:29:54 UTC (rev 1253)
+++ 
branches/spring2migration/archetype/src/main/resources/archetype-resources/pom.xml
  2006-07-31 14:16:23 UTC (rev 1254)
@@ -6,12 +6,12 @@
   <packaging>jar</packaging>
   <version>${version}</version>
   <name>Spring RCP Project Archetype</name>
-  
+
   <properties>
     <springrich.version>0.2.0-SNAPSHOT</springrich.version>
-    <spring.version>1.2.8</spring.version>
+    <spring.version>2.0-rc2</spring.version>
   </properties>
-  
+
   <build>
       <plugins>
           <plugin>
@@ -30,7 +30,7 @@
                   </archive>
               </configuration>
           </plugin>
-          
+
           <!-- This plugin copies the dependencies into target/lib -->
           <plugin>
               <groupId>org.codehaus.mojo</groupId>

Modified: branches/spring2migration/pom.xml
===================================================================
--- branches/spring2migration/pom.xml   2006-07-31 11:29:54 UTC (rev 1253)
+++ branches/spring2migration/pom.xml   2006-07-31 14:16:23 UTC (rev 1254)
@@ -461,9 +461,9 @@
         </repository>
     </repositories>
     <pluginRepositories/>
-    
+
     <properties>
-      <spring.version>1.2.7</spring.version>
+      <spring.version>2.0-rc2</spring.version>
     </properties>
 
     <dependencies>
@@ -476,7 +476,7 @@
             <artifactId>easymock</artifactId>
         </dependency>
     </dependencies>
-    
+
     <dependencyManagement>
         <dependencies>
             <!--
@@ -594,12 +594,32 @@
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-binding</artifactId>
-                <version>0.2005-07-22</version>
+                <version>1.0-rc3</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>log4j</groupId>
+                        <artifactId>log4j</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>ognl</groupId>
+                        <artifactId>ognl</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
-                <groupId>org.springframework</groupId>
-                <artifactId>spring-modules-sandbox</artifactId>
-                <version>0.1-20060304</version>
+                <groupId>org.springmodules</groupId>
+                <artifactId>spring-modules-validation</artifactId>
+                <version>0.5</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.springframework</groupId>
+                        <artifactId>spring</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>antlr</groupId>
+                        <artifactId>antlr</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
 
             <!-- Logging -->
@@ -613,13 +633,6 @@
                 <artifactId>commons-logging</artifactId>
                 <version>1.0.4</version>
             </dependency>
-            <dependency>
-                <groupId>log4j</groupId>
-                <artifactId>log4j</artifactId>
-                <version>1.2.12</version>
-                <scope>runtime</scope>
-                <optional>true</optional>
-            </dependency>
 
             <!-- Dependency injection -->
             <dependency>
@@ -644,10 +657,6 @@
                         <artifactId>connector</artifactId>
                     </exclusion>
                     <exclusion>
-                        <groupId>aopalliance</groupId>
-                        <artifactId>aopalliance</artifactId>
-                    </exclusion>
-                    <exclusion>
                         <groupId>xdoclet</groupId>
                         <artifactId>xjavadoc</artifactId>
                     </exclusion>
@@ -743,11 +752,6 @@
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
-                <artifactId>spring-orm</artifactId>
-                <version>${spring.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.springframework</groupId>
                 <artifactId>spring-jdbc</artifactId>
                 <version>${spring.version}</version>
             </dependency>

Modified: branches/spring2migration/samples/petclinic/business/pom.xml
===================================================================
--- branches/spring2migration/samples/petclinic/business/pom.xml        
2006-07-31 11:29:54 UTC (rev 1253)
+++ branches/spring2migration/samples/petclinic/business/pom.xml        
2006-07-31 14:16:23 UTC (rev 1254)
@@ -43,10 +43,6 @@
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
-            <artifactId>spring-orm</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
             <artifactId>spring-jdbc</artifactId>
         </dependency>
 

Modified: 
branches/spring2migration/samples/simple/src/main/java/org/springframework/richclient/samples/simple/ui/convert/DateToText.java
===================================================================
--- 
branches/spring2migration/samples/simple/src/main/java/org/springframework/richclient/samples/simple/ui/convert/DateToText.java
     2006-07-31 11:29:54 UTC (rev 1253)
+++ 
branches/spring2migration/samples/simple/src/main/java/org/springframework/richclient/samples/simple/ui/convert/DateToText.java
     2006-07-31 14:16:23 UTC (rev 1254)
@@ -20,6 +20,7 @@
 
 import org.springframework.binding.convert.support.AbstractFormattingConverter;
 import org.springframework.binding.format.support.DateFormatter;
+import org.springframework.binding.util.MapAccessor;
 
 /**
  * Convert a Date value to a String. This will determine how all Date fields 
are rendered
@@ -62,7 +63,7 @@
     /**
      * Convert the Date to a String using the configured format.
      */
-    protected Object doConvert( Object source, Class targetClass ) throws 
Exception {
+    protected Object doConvert( Object source, Class targetClass, MapAccessor 
context ) throws Exception {
         return (source == null) ? "" : format.formatValue(source);
     }
 

Modified: 
branches/spring2migration/samples/simple/src/main/java/org/springframework/richclient/samples/simple/ui/convert/TextToDate.java
===================================================================
--- 
branches/spring2migration/samples/simple/src/main/java/org/springframework/richclient/samples/simple/ui/convert/TextToDate.java
     2006-07-31 11:29:54 UTC (rev 1253)
+++ 
branches/spring2migration/samples/simple/src/main/java/org/springframework/richclient/samples/simple/ui/convert/TextToDate.java
     2006-07-31 14:16:23 UTC (rev 1254)
@@ -23,6 +23,7 @@
 
 import org.springframework.binding.convert.support.AbstractConverter;
 import org.springframework.binding.format.support.DateFormatter;
+import org.springframework.binding.util.MapAccessor;
 import org.springframework.util.StringUtils;
 
 /**
@@ -60,7 +61,7 @@
      * @return converted Date
      * @throws Exception on parsing failure
      */
-    protected Object doConvert( Object source, Class targetClass ) throws 
Exception {
+    protected Object doConvert( Object source, Class targetClass, MapAccessor 
context ) throws Exception {
         String src = (String) source;
 
         // If the user entered slashes, convert them to dashes

Modified: branches/spring2migration/sandbox/pom.xml
===================================================================
--- branches/spring2migration/sandbox/pom.xml   2006-07-31 11:29:54 UTC (rev 
1253)
+++ branches/spring2migration/sandbox/pom.xml   2006-07-31 14:16:23 UTC (rev 
1254)
@@ -39,6 +39,11 @@
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
+            <artifactId>spring-dao</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
             <artifactId>spring-aop</artifactId>
             <optional>true</optional>
         </dependency>

Modified: branches/spring2migration/support/pom.xml
===================================================================
--- branches/spring2migration/support/pom.xml   2006-07-31 11:29:54 UTC (rev 
1253)
+++ branches/spring2migration/support/pom.xml   2006-07-31 14:16:23 UTC (rev 
1254)
@@ -69,12 +69,6 @@
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
         </dependency>
-        <!-- TODO test cases should use log4j transparently -->
-        <dependency>
-          <groupId>log4j</groupId>
-          <artifactId>log4j</artifactId>
-          <scope>test</scope>
-        </dependency>
 
         <!-- Dependency injection -->
         <dependency>
@@ -111,11 +105,11 @@
             <groupId>org.springframework</groupId>
             <artifactId>spring-binding</artifactId>
         </dependency>
-        
+
         <!-- only required when ValangRichValidator is used -->
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-modules-sandbox</artifactId>
+            <groupId>org.springmodules</groupId>
+            <artifactId>spring-modules-validation</artifactId>
             <optional>true</optional>
         </dependency>
 

Modified: 
branches/spring2migration/support/src/main/java/org/springframework/binding/validation/support/ValangRichValidator.java
===================================================================
--- 
branches/spring2migration/support/src/main/java/org/springframework/binding/validation/support/ValangRichValidator.java
     2006-07-31 11:29:54 UTC (rev 1253)
+++ 
branches/spring2migration/support/src/main/java/org/springframework/binding/validation/support/ValangRichValidator.java
     2006-07-31 14:16:23 UTC (rev 1254)
@@ -46,14 +46,14 @@
 import org.springframework.util.Assert;
 import org.springframework.util.CachingMapDecorator;
 import org.springframework.util.StringUtils;
-import org.springmodules.validation.ValangValidator;
-import org.springmodules.validation.functions.AbstractFunction;
-import org.springmodules.validation.functions.AbstractMathFunction;
-import org.springmodules.validation.functions.BeanPropertyFunction;
-import org.springmodules.validation.functions.Function;
-import org.springmodules.validation.functions.MapEntryFunction;
-import org.springmodules.validation.predicates.BasicValidationRule;
-import org.springmodules.validation.predicates.GenericTestPredicate;
+import org.springmodules.validation.valang.ValangValidator;
+import org.springmodules.validation.valang.functions.AbstractFunction;
+import org.springmodules.validation.valang.functions.AbstractMathFunction;
+import org.springmodules.validation.valang.functions.BeanPropertyFunction;
+import org.springmodules.validation.valang.functions.Function;
+import org.springmodules.validation.valang.functions.MapEntryFunction;
+import org.springmodules.validation.valang.predicates.BasicValidationRule;
+import org.springmodules.validation.valang.predicates.GenericTestPredicate;
 
 /**
  * Implementation of <code>RichValidator</code> that delegates to a

Modified: 
branches/spring2migration/support/src/main/java/org/springframework/binding/value/support/BufferedCollectionValueModel.java
===================================================================
--- 
branches/spring2migration/support/src/main/java/org/springframework/binding/value/support/BufferedCollectionValueModel.java
 2006-07-31 11:29:54 UTC (rev 1253)
+++ 
branches/spring2migration/support/src/main/java/org/springframework/binding/value/support/BufferedCollectionValueModel.java
 2006-07-31 14:16:23 UTC (rev 1254)
@@ -34,6 +34,7 @@
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.FatalBeanException;
 import org.springframework.binding.value.ValueModel;
+import org.springframework.richclient.util.ClassUtils;
 import org.springframework.util.Assert;
 
 /**
@@ -121,7 +122,7 @@
     public static Class getConcreteCollectionType(Class wrappedType) {
         Class class2Create;
         if (wrappedType.isArray()) {
-            if (BeanUtils.isPrimitiveArray(wrappedType)) {
+            if (ClassUtils.isPrimitiveArray(wrappedType)) {
                 throw new IllegalArgumentException("wrappedType can not be an 
array of primitive types");
             }
             class2Create = wrappedType;

Modified: 
branches/spring2migration/support/src/main/java/org/springframework/richclient/application/DefaultConversionService.java
===================================================================
--- 
branches/spring2migration/support/src/main/java/org/springframework/richclient/application/DefaultConversionService.java
    2006-07-31 11:29:54 UTC (rev 1253)
+++ 
branches/spring2migration/support/src/main/java/org/springframework/richclient/application/DefaultConversionService.java
    2006-07-31 14:16:23 UTC (rev 1254)
@@ -21,35 +21,35 @@
 
 import org.springframework.binding.convert.support.AbstractConverter;
 import org.springframework.binding.convert.support.AbstractFormattingConverter;
-import org.springframework.binding.format.FormatterLocator;
-import org.springframework.binding.format.support.SimpleFormatterLocator;
+import org.springframework.binding.format.FormatterFactory;
+import org.springframework.binding.format.support.SimpleFormatterFactory;
+import org.springframework.binding.util.MapAccessor;
 import org.springframework.util.StringUtils;
 
 public class DefaultConversionService extends 
org.springframework.binding.convert.support.DefaultConversionService {
 
     public DefaultConversionService() {
-        super(false);
-        addDefaultConverters();
     }
 
     protected void addDefaultConverters() {
-        addConverter(new TextToDate(getFormatterLocator(), true));
-        addConverter(new DateToText(getFormatterLocator(), true));
-        addConverter(new TextToNumber(getFormatterLocator(), true));
-        addConverter(new NumberToText(getFormatterLocator(), true));
+        super.addDefaultConverters();
+        addConverter(new TextToDate(getFormatterFactory(), true));
+        addConverter(new DateToText(getFormatterFactory(), true));
+        addConverter(new TextToNumber(getFormatterFactory(), true));
+        addConverter(new NumberToText(getFormatterFactory(), true));
         addConverter(new BooleanToText());
         addConverter(new TextToBoolean());
     }
 
-    private FormatterLocator getFormatterLocator() {
-        return new SimpleFormatterLocator();
+    private FormatterFactory getFormatterFactory() {
+        return new SimpleFormatterFactory();
     }
 
     public static final class TextToDate extends AbstractFormattingConverter {
 
         private final boolean allowEmpty;
 
-        protected TextToDate(FormatterLocator formatterLocator, boolean 
allowEmpty) {
+        protected TextToDate(FormatterFactory formatterLocator, boolean 
allowEmpty) {
             super(formatterLocator);
             this.allowEmpty = allowEmpty;
         }
@@ -62,8 +62,8 @@
             return new Class[] {Date.class};
         }
 
-        protected Object doConvert(Object source, Class targetClass) throws 
Exception {
-            return (!allowEmpty || StringUtils.hasText((String)source)) ? 
getFormatterLocator().getDateTimeFormatter()
+        protected Object doConvert(Object source, Class targetClass, 
MapAccessor context) throws Exception {
+            return (!allowEmpty || StringUtils.hasText((String)source)) ? 
getFormatterFactory().getDateTimeFormatter()
                     .parseValue((String)source, Date.class) : null;
         }
     }
@@ -72,7 +72,7 @@
 
         private final boolean allowEmpty;
 
-        protected DateToText(FormatterLocator formatterLocator, boolean 
allowEmpty) {
+        protected DateToText(FormatterFactory formatterLocator, boolean 
allowEmpty) {
             super(formatterLocator);
             this.allowEmpty = allowEmpty;
         }
@@ -85,8 +85,8 @@
             return new Class[] {String.class};
         }
 
-        protected Object doConvert(Object source, Class targetClass) throws 
Exception {
-            return (!allowEmpty || source != null) ? 
getFormatterLocator().getDateTimeFormatter().formatValue(
+        protected Object doConvert(Object source, Class targetClass, 
MapAccessor context) throws Exception {
+            return (!allowEmpty || source != null) ? 
getFormatterFactory().getDateTimeFormatter().formatValue(
                     source) : "";
         }
     }
@@ -95,7 +95,7 @@
 
         private final boolean allowEmpty;
 
-        protected TextToNumber(FormatterLocator formatterLocator, boolean 
allowEmpty) {
+        protected TextToNumber(FormatterFactory formatterLocator, boolean 
allowEmpty) {
             super(formatterLocator);
             this.allowEmpty = allowEmpty;
         }
@@ -109,8 +109,8 @@
                     BigInteger.class, BigDecimal.class,};
         }
 
-        protected Object doConvert(Object source, Class targetClass) throws 
Exception {
-            return (!allowEmpty || StringUtils.hasText((String)source)) ? 
getFormatterLocator().getNumberFormatter(
+        protected Object doConvert(Object source, Class targetClass, 
MapAccessor context) throws Exception {
+            return (!allowEmpty || StringUtils.hasText((String)source)) ? 
getFormatterFactory().getNumberFormatter(
                     targetClass).parseValue((String)source, targetClass) : 
null;
         }
     }
@@ -119,7 +119,7 @@
 
         private final boolean allowEmpty;
 
-        protected NumberToText(FormatterLocator formatterLocator, boolean 
allowEmpty) {
+        protected NumberToText(FormatterFactory formatterLocator, boolean 
allowEmpty) {
             super(formatterLocator);
             this.allowEmpty = allowEmpty;
         }
@@ -133,8 +133,8 @@
             return new Class[] {String.class};
         }
 
-        protected Object doConvert(Object source, Class targetClass) throws 
Exception {
-            return (!allowEmpty || source != null) ? 
getFormatterLocator().getNumberFormatter(source.getClass())
+        protected Object doConvert(Object source, Class targetClass, 
MapAccessor context) throws Exception {
+            return (!allowEmpty || source != null) ? 
getFormatterFactory().getNumberFormatter(source.getClass())
                     .formatValue(source) : "";
         }
     }
@@ -177,7 +177,7 @@
             return new Class[] {Boolean.class};
         }
 
-        protected Object doConvert(Object source, Class targetClass) throws 
Exception {
+        protected Object doConvert(Object source, Class targetClass, 
MapAccessor context) throws Exception {
             String text = (String)source;
             if (!StringUtils.hasText(text)) {
                 return null;
@@ -230,7 +230,7 @@
             return new Class[] {String.class};
         }
 
-        protected Object doConvert(Object source, Class targetClass) throws 
Exception {
+        protected Object doConvert(Object source, Class targetClass, 
MapAccessor context) throws Exception {
             Boolean bool = (Boolean)source;
             if (this.trueString != null && bool.booleanValue()) {
                 return trueString;

Modified: 
branches/spring2migration/support/src/main/java/org/springframework/richclient/tree/BeanTreeCellRenderer.java
===================================================================
--- 
branches/spring2migration/support/src/main/java/org/springframework/richclient/tree/BeanTreeCellRenderer.java
       2006-07-31 11:29:54 UTC (rev 1253)
+++ 
branches/spring2migration/support/src/main/java/org/springframework/richclient/tree/BeanTreeCellRenderer.java
       2006-07-31 14:16:23 UTC (rev 1254)
@@ -31,6 +31,7 @@
 import org.springframework.beans.FatalBeanException;
 import org.springframework.richclient.core.DescribedElement;
 import org.springframework.richclient.core.VisualizedElement;
+import org.springframework.richclient.util.ClassUtils;
 import org.springframework.util.Assert;
 
 /**
@@ -71,7 +72,7 @@
         if (value instanceof DefaultMutableTreeNode) {
             DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
             Object bean = node.getUserObject();
-            if (bean != null && !BeanUtils.isSimpleProperty(bean.getClass())) {
+            if (bean != null && !ClassUtils.isPrimitiveArray(bean.getClass())) 
{
                 if (bean instanceof DescribedElement) {
                     DescribedElement element = (DescribedElement)bean;
                     setText(element.getDisplayName());

Modified: 
branches/spring2migration/support/src/main/java/org/springframework/richclient/util/ClassUtils.java
===================================================================
--- 
branches/spring2migration/support/src/main/java/org/springframework/richclient/util/ClassUtils.java
 2006-07-31 11:29:54 UTC (rev 1253)
+++ 
branches/spring2migration/support/src/main/java/org/springframework/richclient/util/ClassUtils.java
 2006-07-31 14:16:23 UTC (rev 1254)
@@ -186,14 +186,14 @@
         * Check if the given class represents a primitive wrapper array.
         */
        public static boolean isPrimitiveWrapperArray(Class clazz) {
-               return 
org.springframework.beans.BeanUtils.isPrimitiveWrapperArray(clazz);
+               return 
org.springframework.util.ClassUtils.isPrimitiveWrapperArray(clazz);
        }
 
        /**
         * Check if the given class represents a primitive array.
         */
        public static boolean isPrimitiveArray(Class clazz) {
-               return 
org.springframework.beans.BeanUtils.isPrimitiveArray(clazz);
+               return 
org.springframework.util.ClassUtils.isPrimitiveArray(clazz);
        }
 
        /**

Modified: 
branches/spring2migration/support/src/test/java/org/springframework/binding/form/support/AbstractFormModelTests.java
===================================================================
--- 
branches/spring2migration/support/src/test/java/org/springframework/binding/form/support/AbstractFormModelTests.java
        2006-07-31 11:29:54 UTC (rev 1253)
+++ 
branches/spring2migration/support/src/test/java/org/springframework/binding/form/support/AbstractFormModelTests.java
        2006-07-31 14:16:23 UTC (rev 1254)
@@ -19,8 +19,10 @@
 import java.beans.PropertyChangeListener;
 
 import org.springframework.beans.NotReadablePropertyException;
+import org.springframework.binding.convert.ConversionException;
 import org.springframework.binding.convert.ConversionExecutor;
 import org.springframework.binding.convert.ConversionService;
+import 
org.springframework.binding.convert.support.GenericConversionService.NoOpConverter;
 import org.springframework.binding.form.CommitListener;
 import org.springframework.binding.form.FormModel;
 import org.springframework.binding.support.BeanPropertyAccessStrategy;
@@ -324,7 +326,8 @@
         assertEquals(String.class, cs.lastSource);
         assertEquals(Integer.class, cs.lastTarget);
 
-        cs.executer = new ConversionExecutor(null, null);
+        cs.executer = new ConversionExecutor(String.class, Integer.class,
+                new NoOpConverter(String.class, Integer.class));
         ValueModel cvm = fm.getValueModel("simpleProperty", Integer.class);
         assertEquals(3, cs.calls);
         assertEquals(Integer.class, cs.lastSource);
@@ -460,5 +463,10 @@
             fail("this method should never be called");
             return null;
         }
+
+        public ConversionExecutor[] getConversionExecutorsFrom(Class 
sourceClass) throws ConversionException {
+            fail("this method should never be called");
+            return null;
+        }
     }
 }

Modified: 
branches/spring2migration/support/src/test/java/org/springframework/binding/form/support/DefaultFormModelTests.java
===================================================================
--- 
branches/spring2migration/support/src/test/java/org/springframework/binding/form/support/DefaultFormModelTests.java
 2006-07-31 11:29:54 UTC (rev 1253)
+++ 
branches/spring2migration/support/src/test/java/org/springframework/binding/form/support/DefaultFormModelTests.java
 2006-07-31 14:16:23 UTC (rev 1254)
@@ -15,10 +15,13 @@
  */
 package org.springframework.binding.form.support;
 
+import java.util.Map;
 import java.util.Set;
 
+import org.springframework.binding.convert.ConversionException;
 import org.springframework.binding.convert.ConversionExecutor;
-import org.springframework.binding.convert.support.AbstractConverter;
+import org.springframework.binding.convert.Converter;
+import 
org.springframework.binding.convert.support.GenericConversionService.NoOpConverter;
 import org.springframework.binding.form.BindingErrorMessageProvider;
 import org.springframework.binding.form.FormModel;
 import org.springframework.binding.form.ValidatingFormModel;
@@ -38,7 +41,7 @@
 /**
  * Tests for @link DefaultFormModel
  * 
- * @author  Oliver Hutchison
+ * @author Oliver Hutchison
  */
 public class DefaultFormModelTests extends AbstractFormModelTests {
 
@@ -51,11 +54,11 @@
     }
 
     public void testPropertyChangeCausesValidation() {
-        DefaultFormModel fm = (DefaultFormModel)getFormModel(new TestBean());
+        DefaultFormModel fm = (DefaultFormModel) getFormModel(new TestBean());
         TestValidator v = new TestValidator();
         fm.setValidator(v);
         TestConversionService cs = new TestConversionService();
-        cs.executer = new ConversionExecutor(new NoOpConverter(String.class, 
String.class), String.class);
+        cs.executer = new ConversionExecutor(String.class, String.class, new 
NoOpConverter(String.class, String.class));
         fm.setConversionService(cs);
         ValueModel vm = fm.getValueModel("simpleProperty");
         assertEquals(1, v.count);
@@ -90,7 +93,7 @@
         v.results = getValidationResults("message1");
         vm.setValue("1");
         assertEquals(2, v.count);
-        assertEquals(1, r.getMessageCount());        
+        assertEquals(1, r.getMessageCount());
         assertContainsMessage("message1", r.getMessages());
 
         v.results = getValidationResults("message2");
@@ -117,7 +120,7 @@
     }
 
     public void testRaiseClearValidationMessage() {
-        TestDefaultFormModel fm = (TestDefaultFormModel)getFormModel(new 
TestBean());
+        TestDefaultFormModel fm = (TestDefaultFormModel) getFormModel(new 
TestBean());
         ValidationResultsModel r = fm.getValidationResults();
         TestValidator v = new TestValidator();
         fm.setValidator(v);
@@ -150,7 +153,7 @@
     }
 
     public void testChangingValidatingClearsMessagesOrValidates() {
-        DefaultFormModel fm = (DefaultFormModel)getFormModel(new TestBean());
+        DefaultFormModel fm = (DefaultFormModel) getFormModel(new TestBean());
         ValidationResultsModel r = fm.getValidationResults();
         TestValidator v = new TestValidator();
         v.results = getValidationResults("message1");
@@ -193,7 +196,7 @@
 
     public void testSetThrowsExceptionRaisesValidationMessage() {
         final ErrorBean errorBean = new ErrorBean();
-        DefaultFormModel fm = (DefaultFormModel)getFormModel(errorBean);
+        DefaultFormModel fm = (DefaultFormModel) getFormModel(errorBean);
         final ValueModel vm = fm.getValueModel("error");
 
         vm.setValue("test");
@@ -205,9 +208,10 @@
     }
 
     public void testTypeConversionThrowsExceptionRaisesValidationMessage() {
-        DefaultFormModel fm = (DefaultFormModel)getFormModel(new TestBean());
+        DefaultFormModel fm = (DefaultFormModel) getFormModel(new TestBean());
         TestConversionService cs = new TestConversionService();
-        cs.executer = new ConversionExecutor(null, null);
+        cs.executer = new ConversionExecutor(String.class, Integer.class, new 
ExceptionConverter(String.class,
+                Integer.class));
         fm.setConversionService(cs);
         final ValueModel vm = fm.getValueModel("simpleProperty", 
Integer.class);
 
@@ -217,7 +221,7 @@
 
     public void testValidatingEvents() {
         TestPropertyChangeListener pcl = new 
TestPropertyChangeListener(ValidatingFormModel.VALIDATING_PROPERTY);
-        DefaultFormModel fm = (DefaultFormModel)getFormModel(new TestBean());
+        DefaultFormModel fm = (DefaultFormModel) getFormModel(new TestBean());
         fm.addPropertyChangeListener(ValidatingFormModel.VALIDATING_PROPERTY, 
pcl);
         assertTrue(fm.isEnabled());
 
@@ -245,8 +249,8 @@
 
         // no additional asserts, this test should just not throw an exception!
     }
-    
-    public void testDefaultFormModelFromValueModel() throws Exception {        
+
+    public void testDefaultFormModelFromValueModel() throws Exception {
         TestBean testBean = new TestBean();
         ValueModel valueModel = new ValueHolder(testBean);
         DefaultFormModel model = new DefaultFormModel(valueModel);
@@ -260,8 +264,8 @@
     }
 
     private void assertContainsMessage(String message, Set messages) {
-        assertTrue("Set of messages does not contain expected message '" + 
message + "'",
-                messages.contains(new 
DefaultValidationMessage("simpleProperty", Severity.ERROR, message)));
+        assertTrue("Set of messages does not contain expected message '" + 
message + "'", messages
+                .contains(new DefaultValidationMessage("simpleProperty", 
Severity.ERROR, message)));
     }
 
     public static class TestValidator implements Validator {
@@ -290,30 +294,6 @@
         }
     }
 
-    public static class NoOpConverter extends AbstractConverter {
-
-        private Class sourceClass;
-
-        private Class targetClass;
-
-        public NoOpConverter(Class sourceClass, Class targetClass) {
-            this.sourceClass = sourceClass;
-            this.targetClass = targetClass;
-        }
-
-        protected Object doConvert(Object source, Class targetClass) throws 
Exception {
-            return source;
-        }
-
-        public Class[] getSourceClasses() {
-            return new Class[] {sourceClass};
-        }
-
-        public Class[] getTargetClasses() {
-            return new Class[] {targetClass};
-        }
-    }
-
     private static class TestDefaultFormModel extends DefaultFormModel {
         public TestDefaultFormModel(Object bean) {
             super(bean, false);
@@ -344,4 +324,29 @@
             super.clearValidationMessage(validationMessage);
         }
     }
+
+    private static class ExceptionConverter implements Converter {
+
+        private final Class sourceClass;
+
+        private final Class targetClass;
+
+        public ExceptionConverter(Class sourceClass, Class targetClass) {
+            this.sourceClass = sourceClass;
+            this.targetClass = targetClass;
+        }
+
+        public Object convert(Object source, Class targetClass, Map context) 
throws ConversionException {
+            throw new ConversionException("test", targetClass);
+        }
+
+        public Class[] getSourceClasses() {
+            return new Class[] { sourceClass };
+        }
+
+        public Class[] getTargetClasses() {
+            return new Class[] { targetClass };
+        }
+
+    }
 }
\ No newline at end of file


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
spring-rich-c-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to