incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r421025 [2/3] - in /incubator/adffaces/branches/matzew-mock-overhaul/adf-faces: ./ adf-faces-api/ adf-faces-api/src/test/java/org/apache/myfaces/adf/component/ adf-faces-api/src/test/java/org/apache/myfaces/adf/component/core/ adf-faces-api...
Date Tue, 11 Jul 2006 23:29:18 GMT
Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlCellFormatTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlCellFormatTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlCellFormatTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlCellFormatTest.java Tue Jul 11 16:29:16 2006
@@ -17,6 +17,9 @@
 
 import java.io.IOException;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.myfaces.adf.component.UIComponentTestCase;
 
 /**
@@ -35,6 +38,21 @@
     String testName)
   {
     super(testName);
+  }
+  
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(HtmlCellFormatTest.class);
   }
 
   /**

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlFrameBorderLayoutTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlFrameBorderLayoutTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlFrameBorderLayoutTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlFrameBorderLayoutTest.java Tue Jul 11 16:29:16 2006
@@ -17,6 +17,9 @@
 
 import java.io.IOException;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.myfaces.adf.component.UIComponentTestCase;
 
 /**
@@ -35,6 +38,21 @@
     String testName)
   {
     super(testName);
+  }
+  
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(HtmlFrameBorderLayoutTest.class);
   }
 
   /**

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlFrameTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlFrameTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlFrameTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlFrameTest.java Tue Jul 11 16:29:16 2006
@@ -17,6 +17,9 @@
 
 import java.io.IOException;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.myfaces.adf.component.UIComponentTestCase;
 
 /**
@@ -35,6 +38,21 @@
     String testName)
   {
     super(testName);
+  }
+  
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(HtmlFrameTest.class);
   }
 
   /**

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlHtmlTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlHtmlTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlHtmlTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlHtmlTest.java Tue Jul 11 16:29:16 2006
@@ -17,6 +17,9 @@
 
 import java.io.IOException;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.myfaces.adf.component.UIComponentTestCase;
 
 /**
@@ -36,6 +39,21 @@
     String testName)
   {
     super(testName);
+  }
+  
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(HtmlHtmlTest.class);
   }
 
   /**

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlRowLayoutTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlRowLayoutTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlRowLayoutTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlRowLayoutTest.java Tue Jul 11 16:29:16 2006
@@ -17,6 +17,9 @@
 
 import java.io.IOException;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.myfaces.adf.component.UIComponentTestCase;
 
 /**
@@ -35,6 +38,21 @@
     String testName)
   {
     super(testName);
+  }
+  
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(HtmlRowLayoutTest.class);
   }
 
   /**

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlScriptTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlScriptTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlScriptTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlScriptTest.java Tue Jul 11 16:29:16 2006
@@ -17,6 +17,9 @@
 
 import java.io.IOException;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.myfaces.adf.component.UIComponentTestCase;
 
 /**
@@ -35,6 +38,21 @@
     String testName)
   {
     super(testName);
+  }
+  
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(HtmlScriptTest.class);
   }
 
   /**

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlTableLayoutTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlTableLayoutTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlTableLayoutTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/html/HtmlTableLayoutTest.java Tue Jul 11 16:29:16 2006
@@ -17,6 +17,9 @@
 
 import java.io.IOException;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.myfaces.adf.component.UIComponentTestCase;
 
 /**
@@ -35,6 +38,21 @@
     String testName)
   {
     super(testName);
+  }
+  
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(HtmlTableLayoutTest.class);
   }
 
   /**

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/AdfDateTimeConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/AdfDateTimeConverterTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/AdfDateTimeConverterTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/AdfDateTimeConverterTest.java Tue Jul 11 16:29:16 2006
@@ -21,7 +21,7 @@
 import java.util.Locale;
 import java.util.TimeZone;
 
-import javax.faces.component.MockUIComponent;
+import javax.faces.component.UIComponent;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 
@@ -29,8 +29,9 @@
 import junit.framework.TestSuite;
 
 import org.apache.myfaces.adf.context.MockAdfFacesContext;
-import org.apache.myfaces.adfbuild.test.MockUtils;
+import org.apache.myfaces.adfbuild.test.MockUIComponentWrapper;
 import org.apache.shale.test.mock.MockFacesContext;
+import org.jmock.Mock;
 
 public class AdfDateTimeConverterTest extends DateTimeConverterTestCase
 {
@@ -80,7 +81,8 @@
     Date date = gcal.getTime();
 
     DateTimeConverter dtConv   = new DateTimeConverter();
-    MockUIComponent component  = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
     String inputValue          = "6/4/2999";
 
     dtConv.setDateStyle("shortish");
@@ -91,7 +93,7 @@
 
     String exptectedStr = dtConv.getAsString(facesContext, component, dt);
     assertEquals(inputValue, exptectedStr);
-    component.verify();
+    mock.verify();
   }
 
   public void testShortishDateStyle()
@@ -110,7 +112,8 @@
     Date date = gcal.getTime();
 
     DateTimeConverter dtConv   = new DateTimeConverter();
-    MockUIComponent component  = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
     String inputValue          = "6/4/1600";
     String secondaryPattern    = "MM/d/yyyy";
 
@@ -140,7 +143,7 @@
     String expectedOut = dtConv.getAsString(facesContext, component, date);
     assertEquals(inputValue, expectedOut);
 
-    component.verify();
+    mock.verify();
   }
 
   public void testLeniencyOnPrimaryPattern()
@@ -181,8 +184,9 @@
     GregorianCalendar cal = new GregorianCalendar(2004, Calendar.JUNE, 4);
     cal.setTimeZone(DEFAULT_TIME_ZONE);
     Date dt = cal.getTime();
-    MockUIComponent component
-       = MockUtils.buildMockUIComponent(iterations);
+    Mock mock = buildMockUIComponent(iterations);
+    UIComponent component = (UIComponent) mock.proxy();
+    
     for (int i = 0; i < validInputs.length; i++)
     {
       DateTimeConverter
@@ -196,7 +200,7 @@
       Date convDate = (Date) dtConv.getAsObject(facesContext, component,
                                                 validInputs[i]);
       assertEquals(convDate, dt);
-      component.verify();
+      mock.verify();
     }
   }
 
@@ -218,7 +222,8 @@
       fdtConv.setLocale((Locale)data[i][2]);
       fdtConv.setTimeZone((TimeZone)data[i][3]);
 
-      MockUIComponent component = MockUtils.buildMockUIComponent();
+      Mock mock = buildMockUIComponent();
+      UIComponent component = (UIComponent) mock.proxy();
       Date dtConvDate  = (Date)dtConv.getAsObject(facesContext, component, inputValue);
       Date fdtConvDate = (Date)fdtConv.getAsObject(facesContext, component, inputValue);
       //      assertEquals(dtConvDate, fdtConvDate);
@@ -246,10 +251,10 @@
     Converter conv1,
     Converter conv2,
     MockFacesContext context,
-    MockUIComponent component
+    MockUIComponentWrapper wrapper
     )
   {
-    super.doTestStateHolderSaveRestore(conv1, conv2, context, component);
+    super.doTestStateHolderSaveRestore(conv1, conv2, context, wrapper);
   }
 
   public void testCustomMessageIsSet()
@@ -264,7 +269,8 @@
 
     for (int i = 0; i < failingValues.length ; i++)
     {
-      MockUIComponent component = MockUtils.buildMockUIComponent(3 * 4);
+      Mock mock = buildMockUIComponent(3 * 4);
+      UIComponent component = (UIComponent) mock.proxy();
 
       org.apache.myfaces.adf.convert.DateTimeConverter converter =
         new org.apache.myfaces.adf.convert.DateTimeConverter();

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/AdfNumberConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/AdfNumberConverterTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/AdfNumberConverterTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/AdfNumberConverterTest.java Tue Jul 11 16:29:16 2006
@@ -13,20 +13,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.myfaces.adf.convert;
+
 import java.text.DecimalFormatSymbols;
 
 import java.util.Locale;
 
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.NumberConverter;
-import javax.faces.component.MockUIComponent;
+import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewRoot;
 
 import org.apache.myfaces.adf.context.MockAdfFacesContext;
-import org.apache.myfaces.adfbuild.test.MockUtils;
+import org.apache.myfaces.adfbuild.test.MockUIComponentWrapper;
 import org.apache.shale.test.mock.MockFacesContext;
+import org.jmock.Mock;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -90,7 +91,8 @@
     _mafct.setDecimalSeparator('*');
     _mafct.setNumberGroupingSeparator('!');
     _mafct.setCurrencyCode(null);
-    MockUIComponent component = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
 
     NumberConverter conv = getNumberConverter();
 
@@ -99,12 +101,12 @@
     String out = conv.getAsString(facesContext, component, inputValue);
     assertEquals("8!989*789", out);
 
-    component.verify();
+    mock.verify();
   }
 
   protected void doTestStrictNess(
     MockFacesContext context,
-    MockUIComponent component,
+    MockUIComponentWrapper wrapper,
     Locale locale,
     String inputValue)
   {
@@ -114,7 +116,7 @@
      try
      {
        // ADF Converter is not lenient.
-       Object obj = converter.getAsObject(context, component, inputValue);
+       Object obj = converter.getAsObject(context, wrapper.getUIComponent(), inputValue);
        fail("Expected converter exception");
      }
      catch (ConverterException ce)
@@ -132,7 +134,10 @@
     for (int i = 0; i < failingValues.length ; i++)
     {
       MockFacesContext context  = new MockFacesContext();
-      MockUIComponent component = MockUtils.buildMockUIComponent(3);
+      Mock mock = buildMockUIComponent(3);
+      UIComponent component = (UIComponent) mock.proxy();
+      MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
+
 
       org.apache.myfaces.adf.convert.NumberConverter converter =
         new org.apache.myfaces.adf.convert.NumberConverter();

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/ColorConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/ColorConverterTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/ColorConverterTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/ColorConverterTest.java Tue Jul 11 16:29:16 2006
@@ -20,8 +20,11 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.faces.component.UIComponent;
 import javax.faces.convert.ConverterException;
-import javax.faces.component.MockUIComponent;
+
+import org.apache.myfaces.adfbuild.test.MockUIComponentWrapper;
+import org.jmock.Mock;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -61,10 +64,13 @@
    */
   public void testNull() throws ConverterException
   {
-    MockUIComponent component = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
+
     ColorConverter converter  = new ColorConverter();
 
-    doTestNull(facesContext, component, converter);
+    doTestNull(facesContext, wrapper, converter);
   }
 
   /**
@@ -72,10 +78,12 @@
    */
   public void testNullContext()
   {
-    MockUIComponent component = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
     ColorConverter converter  = new ColorConverter();
 
-    doTestNullContext(component, converter);
+    doTestNullContext(wrapper, converter);
   }
 
   public void testNullComponent()
@@ -127,10 +135,12 @@
   public void testDefaultColorPatternWorks()
   {
     ColorConverter converter  = new ColorConverter();
-    MockUIComponent component = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
     String value = "#FFFFFF";
     Color expectedColor = new Color(255,255,255);
-    doTestGetAsObject(converter, facesContext, component, value, expectedColor);
+    doTestGetAsObject(converter, facesContext, wrapper, value, expectedColor);
   }
 
   /**
@@ -139,7 +149,9 @@
   public void testStateHolderSaveRestore()
   {
     ColorConverter converter = new ColorConverter();
-    MockUIComponent component = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     String[] patterns = {"#RRGGBB","RR.GG.BB"};
     converter.setPatterns(patterns);
@@ -147,8 +159,8 @@
     ColorConverter restoreConverter = new  ColorConverter();
 
     doTestStateHolderSaveRestore(converter, restoreConverter,
-        facesContext, component);
-    component.verify();
+        facesContext, wrapper);
+    mock.verify();
   }
   /**
    * Test ColorConverte's getAsObject(FacesContext, UIComponent, String) method
@@ -157,7 +169,9 @@
   public void testGetAsObjectConversion()
   {
     ColorConverter converter = new ColorConverter();
-    MockUIComponent component = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     String[] patterns = { "#RRGGBB",
                           "RR.GG.BB",
@@ -185,9 +199,9 @@
     converter.setPatterns(patterns);
     for (int i = 0; i < values.length; i++)
     {
-      doTestGetAsObject(converter, facesContext, component,values[i], matchColors[i]);
+      doTestGetAsObject(converter, facesContext, wrapper, values[i], matchColors[i]);
     }
-    component.verify();
+    mock.verify();
   }
 
   /**
@@ -197,7 +211,9 @@
   public void testGetAsString()
   {
     ColorConverter converter  = new ColorConverter();
-    MockUIComponent component = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     Color[] colors = {  new Color(255,2,4),
                         new Color(255,2,6),
@@ -224,10 +240,10 @@
     {
       String[] patterns = (String[]) patternsHoloder.get(i);
       converter.setPatterns(patterns);
-      doTestGetAsString(converter, facesContext, component,
+      doTestGetAsString(converter, facesContext, wrapper,
                                     colors[i], matchValues[i] );
     }
-    component.verify();
+    mock.verify();
   }
 
   /**
@@ -236,8 +252,8 @@
   public void testNullValueForPatterns()
   {
     ColorConverter converter = new ColorConverter();
-    MockUIComponent component = new MockUIComponent();
-
+    Mock mock = mock(UIComponent.class);
+    
     try
     {
       converter.setPatterns(null);
@@ -247,14 +263,16 @@
     {
       // expected fine
     }
-    component.verify();
+    mock.verify();
   }
 
   public void testGetAsObjectIllegalValue()
   {
     ColorConverter converter = new ColorConverter();
-    MockUIComponent component = new MockUIComponent();
-    component.setupGetId("test");
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    mock.stubs().method("getId").will(returnValue("test"));
+    //component.setupGetId("test");
     try
     {
       converter.getAsString(facesContext, component, new Integer(1));
@@ -263,6 +281,6 @@
     {
       // expected
     }
-    component.verify();
+    mock.verify();
   }
 }

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/ConverterTestCase.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/ConverterTestCase.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/ConverterTestCase.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/ConverterTestCase.java Tue Jul 11 16:29:16 2006
@@ -17,13 +17,15 @@
 package org.apache.myfaces.adf.convert;
 
 import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 
-import javax.faces.component.MockUIComponent;
-
+import org.apache.myfaces.adfbuild.test.AbstractBaseTestCase;
+import org.apache.myfaces.adfbuild.test.MockUIComponentWrapper;
 import org.apache.shale.test.base.AbstractJsfTestCase;
 import org.apache.shale.test.mock.MockFacesContext;
+import org.jmock.Mock;
 
 /**
  * Base class for unit tests of Converters
@@ -32,7 +34,7 @@
  * @author vijay venkatarman (vijay.venkataraman@oracle.com)
  *
  */
-public abstract class ConverterTestCase extends AbstractJsfTestCase
+public abstract class ConverterTestCase extends AbstractBaseTestCase
 {
   public ConverterTestCase(String testName)
   {
@@ -50,27 +52,27 @@
    */
   protected void doTestNull(
     MockFacesContext context,
-    MockUIComponent component,
+    MockUIComponentWrapper wrapper,
     Converter converter
     ) throws ConverterException
   {
-    Object obj = converter.getAsObject(context, component, null);
+    Object obj = converter.getAsObject(context, wrapper.getUIComponent(), null);
     assertEquals(null, obj);
-    String str = converter.getAsString(context, component, null);
+    String str = converter.getAsString(context, wrapper.getUIComponent(), null);
     assertEquals("",str);
-    component.verify();
+    wrapper.getMock().verify();
   }
 
   /**
    * If contex or component = null then should throw NullPointerException
    */
   protected void doTestNullContext(
-    MockUIComponent component,
+    MockUIComponentWrapper wrapper,
     Converter converter) throws NullPointerException
   {
     try
     {
-      converter.getAsObject(null, component , "dummy");
+      converter.getAsObject(null, wrapper.getUIComponent(), "dummy");
       fail("Expected NullpointerException - if context or component is null");
     }
     catch (NullPointerException npe)
@@ -79,7 +81,7 @@
     }
     try
     {
-      converter.getAsString(null, component , "dummy");
+      converter.getAsString(null, wrapper.getUIComponent(), "dummy");
       fail("Expected NullpointerException - if context or component is null");
     }
     catch (NullPointerException npe)
@@ -117,7 +119,8 @@
   protected void doTestBlankValue(Converter converter)
   {
     MockFacesContext context = new MockFacesContext();
-    MockUIComponent component = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
     Object value = converter.getAsObject(context, component,"");
     assertEquals(null, value);
   }
@@ -134,15 +137,15 @@
   protected void doTestGetAsObject(
     Converter converter,
     MockFacesContext context,
-    MockUIComponent component,
+    MockUIComponentWrapper wrapper,
     String value,
     Object expectedValue
     )  throws ConverterException
   {
-    Object conv = converter.getAsObject(context, component, value);
+    Object conv = converter.getAsObject(context, wrapper.getUIComponent(), value);
     assertEquals(expectedValue, conv);
 
-    component.verify();
+    wrapper.getMock().verify();
   }
 
 
@@ -157,14 +160,14 @@
   protected void doTestGetAsString(
     Converter converter,
     MockFacesContext context,
-    MockUIComponent component,
+    MockUIComponentWrapper wrapper,
     Object value,
     String expectedValue
     )  throws ConverterException
   {
-    Object conv = converter.getAsString(context, component, value);
+    Object conv = converter.getAsString(context, wrapper.getUIComponent(), value);
     assertEquals(conv, expectedValue);
-    component.verify();
+    wrapper.getMock().verify();
   }
 
 
@@ -197,7 +200,7 @@
     Converter thisConverter,
     Converter otherConverter,
     MockFacesContext context,
-    MockUIComponent component
+    MockUIComponentWrapper wrapper
     )
   {
     Object state = ((StateHolder)thisConverter).saveState(context);
@@ -205,7 +208,7 @@
     ((StateHolder)otherConverter).restoreState(context, state);
     // do all actions of save and restore
     doTestEquals(thisConverter, otherConverter, true);
-    component.verify();
+    wrapper.getMock().verify();
   }
 
 
@@ -223,4 +226,4 @@
   {
     return ( o1 == o2 || (o1 != null && o1.equals(o2)));
   }
-}
+}
\ No newline at end of file

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/DateTimeConverterTestCase.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/DateTimeConverterTestCase.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/DateTimeConverterTestCase.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/DateTimeConverterTestCase.java Tue Jul 11 16:29:16 2006
@@ -22,11 +22,12 @@
 import java.util.Locale;
 import java.util.TimeZone;
 
+import javax.faces.component.UIComponent;
 import javax.faces.convert.ConverterException;
-import javax.faces.component.MockUIComponent;
 
 import org.apache.myfaces.adf.convert.ConverterTestCase;
-import org.apache.myfaces.adfbuild.test.MockUtils;
+import org.apache.myfaces.adfbuild.test.MockUIComponentWrapper;
+import org.jmock.Mock;
 
 /**
  * Test DateTimeConverter
@@ -70,11 +71,13 @@
    */
   protected void checkNullInputValue() throws ConverterException
   {
-    MockUIComponent component = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     javax.faces.convert.DateTimeConverter converter  = getDateTimeConverter();
 
-    doTestNull(facesContext, component, converter);
+    doTestNull(facesContext, wrapper, converter);
   }
 
   /**
@@ -82,10 +85,12 @@
    */
   protected void checkNullContext()
   {
-    MockUIComponent component    = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
     javax.faces.convert.DateTimeConverter converter = getDateTimeConverter();
 
-    doTestNullContext(component, converter);
+    doTestNullContext(wrapper, converter);
   }
 
   protected void checkNullComponent()
@@ -163,7 +168,9 @@
   {
 
     javax.faces.convert.DateTimeConverter converter = getDateTimeConverter();
-    MockUIComponent component   = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     javax.faces.convert.DateTimeConverter restoreConverter = getDateTimeConverter();
 
@@ -182,40 +189,40 @@
       converter.setLocale(_LOCALES[i]);
       restoreConverter.setLocale(_LOCALES[i]);
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 facesContext, component);
+                                 facesContext, wrapper);
 
       converter.setPattern(_PATTERNS[i]);
       restoreConverter.setPattern(_PATTERNS[i]);
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 facesContext, component);
+                                 facesContext, wrapper);
 
       converter.setTimeStyle(_TIME_STYLES[i]);
       restoreConverter.setTimeStyle(_TIME_STYLES[i]);
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 facesContext, component);
+                                 facesContext, wrapper);
 
       converter.setTimeZone(_TIME_ZONES[i]);
       restoreConverter.setTimeZone(_TIME_ZONES[i]);
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 facesContext, component);
+                                 facesContext, wrapper);
 
       converter.setType(_TYPES[i]);
       restoreConverter.setType(_TYPES[i]);
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 facesContext, component);
+                                 facesContext, wrapper);
 
       String secPattern = _SECONDARY_PATTERNS[i];
       setSecondaryPattern(converter, secPattern);
       setSecondaryPattern(restoreConverter, secPattern);
 
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                   facesContext, component);
+                                   facesContext, wrapper);
 
       converter.setTransient(_TRANSIENT_VALUES[i]);
       restoreConverter.setTransient(_TRANSIENT_VALUES[i]);
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 facesContext, component);
-      component.verify();
+                                 facesContext, wrapper);
+      mock.verify();
     }
   }
 
@@ -233,9 +240,11 @@
       dtConv.setTimeZone(_STIME_ZONES[i]);
       dtConv.setType(_STYPES[i]);
 
-      MockUIComponent component =  new MockUIComponent();
+      Mock mock = mock(UIComponent.class);
+      UIComponent component = (UIComponent) mock.proxy();
+      MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
       
-      MockUtils.setFacesContext(facesContext);
+      setFacesContext(facesContext);
       try
       {
         Date obj = (Date)dtConv.getAsObject(facesContext, component, _SINPUT_VALUES[i]);
@@ -243,10 +252,10 @@
       }
       finally
       {
-        MockUtils.setFacesContext(null);
+        setFacesContext(null);
       }
 
-      component.verify();
+      mock.verify();
    }
   }
 
@@ -260,7 +269,9 @@
     dtConv.setTimeZone(null);
     dtConv.setPattern(pattern);
 
-    MockUIComponent component  = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     facesContext.getViewRoot().setLocale(Locale.ENGLISH);
 
@@ -270,7 +281,7 @@
     GregorianCalendar gcal = new GregorianCalendar(getTzone("UTC"));
     gcal.set(2001,6,4,12,8,56);
 
-    MockUtils.setFacesContext(facesContext);
+    setFacesContext(facesContext);
     try
     {
       Date dt = (Date) dtConv.getAsObject(facesContext, component, inputValue);
@@ -279,7 +290,7 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
  }
 
@@ -312,7 +323,9 @@
     for (int i = 0; i < patternBasedValues.length; i++)
     {
 
-      MockUIComponent  component = new MockUIComponent();
+      Mock mock = mock(UIComponent.class);
+      UIComponent component = (UIComponent) mock.proxy();
+      MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
       javax.faces.convert.DateTimeConverter fdtConv
         = getDateTimeConverter();
@@ -329,7 +342,7 @@
         facesContext.getViewRoot().setLocale(Locale.GERMAN);
       }
 
-      MockUtils.setFacesContext(facesContext);
+      setFacesContext(facesContext);
       try
       {
         String fobtPattern = fdtConv.getAsString(facesContext, component, date);
@@ -345,9 +358,9 @@
       }
       finally
       {
-        MockUtils.setFacesContext(null);
+        setFacesContext(null);
       }
-      component.verify();
+      mock.verify();
     }
   }
 
@@ -371,12 +384,14 @@
       // by default dateStyle is shortish and type is date
 
       javax.faces.convert.DateTimeConverter dtConv = getDateTimeConverter();
-      MockUIComponent  component = new MockUIComponent();
+      Mock mock = mock(UIComponent.class);
+      UIComponent component = (UIComponent) mock.proxy();
+      MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
       _setStyleOnConverter(dtConv, styleType, styles[i]);
 
       dtConv.setLocale(Locale.ENGLISH);
-      MockUtils.setFacesContext(facesContext);
+      setFacesContext(facesContext);
       try
       {
         String out =  dtConv.getAsString(facesContext, component, dt);
@@ -384,14 +399,15 @@
       }
       finally
       {
-        MockUtils.setFacesContext(null);
+        setFacesContext(null);
       }
 
-      component.verify();
+      mock.verify();
 
-      MockUIComponent  cmp   = new MockUIComponent();
+      Mock mok = mock(UIComponent.class);
+      UIComponent cmp = (UIComponent) mok.proxy();
 
-      MockUtils.setFacesContext(facesContext);
+      setFacesContext(facesContext);
       try
       {
         try
@@ -399,7 +415,7 @@
           javax.faces.convert.DateTimeConverter extDtConv = getDateTimeConverter();
           extDtConv.setLocale(Locale.ENGLISH);
           _setStyleOnConverter(extDtConv, styleType, styles[i].toUpperCase());
-          String outPut = extDtConv.getAsString(facesContext, component, dt);
+          String outPut = extDtConv.getAsString(facesContext, cmp, dt);
           fail("Upper case not accepted for styles");
         }
         catch (RuntimeException ce)
@@ -409,10 +425,10 @@
       }
       finally
       {
-        MockUtils.setFacesContext(null);
+        setFacesContext(null);
       }
 
-      cmp.verify();
+      mok.verify();
     }
   }
 

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/JsfDateTimeConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/JsfDateTimeConverterTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/JsfDateTimeConverterTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/JsfDateTimeConverterTest.java Tue Jul 11 16:29:16 2006
@@ -15,7 +15,6 @@
 */
 package org.apache.myfaces.adf.convert;
 
-import javax.faces.component.MockUIComponent;
 import javax.faces.component.StateHolder;
 import javax.faces.convert.Converter;
 import javax.faces.convert.DateTimeConverter;
@@ -23,6 +22,7 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.myfaces.adfbuild.test.MockUIComponentWrapper;
 import org.apache.shale.test.mock.MockFacesContext;
 
 public class JsfDateTimeConverterTest extends DateTimeConverterTestCase
@@ -51,7 +51,7 @@
     Converter conv1,
     Converter conv2,
     MockFacesContext context,
-    MockUIComponent component
+    MockUIComponentWrapper wrapper
     )
   {
     DateTimeConverter dtConv1, dtConv2;
@@ -65,7 +65,7 @@
     boolean isEqual =  _isConvertersEqual(dtConv1, dtConv2);
 
     assertEquals(true, isEqual);
-    component.verify();
+    wrapper.getMock().verify();
   }
 
   protected void doTestEquals(

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/JsfNumberConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/JsfNumberConverterTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/JsfNumberConverterTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/JsfNumberConverterTest.java Tue Jul 11 16:29:16 2006
@@ -21,11 +21,11 @@
 import javax.faces.component.StateHolder;
 import javax.faces.convert.Converter;
 import javax.faces.convert.NumberConverter;
-import javax.faces.component.MockUIComponent;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.myfaces.adfbuild.test.MockUIComponentWrapper;
 import org.apache.shale.test.mock.MockFacesContext;
 
 /**
@@ -64,7 +64,7 @@
     Converter conv1,
     Converter conv2,
     MockFacesContext context,
-    MockUIComponent component
+    MockUIComponentWrapper wrapper
     )
   {
     Object state = ((StateHolder)conv1).saveState(context);
@@ -75,7 +75,7 @@
                                            (NumberConverter)conv2);
 
     assertEquals(true, isEqual);
-    component.verify();
+    wrapper.getMock().verify();
   }
 
   // This is a bad equals comparison. But this is max we can do.
@@ -115,13 +115,13 @@
 
    protected void doTestStrictNess(
     MockFacesContext context,
-    MockUIComponent component,
+    MockUIComponentWrapper wrapper,
     Locale locale,
     String inputValue)
   {
      NumberConverter converter = getNumberConverter();
      converter.setLocale(locale);
-     Object obj = converter.getAsObject(context, component, inputValue);
+     Object obj = converter.getAsObject(context, wrapper.getUIComponent(), inputValue);
      // JSF Converter is lenient - so it will get parsed to a valid object
      assertEquals(true, (obj != null));
   };

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/NumberConverterTestCase.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/NumberConverterTestCase.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/NumberConverterTestCase.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/NumberConverterTestCase.java Tue Jul 11 16:29:16 2006
@@ -19,11 +19,12 @@
 
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.NumberConverter;
-import javax.faces.component.MockUIComponent;
+import javax.faces.component.UIComponent;
 
 import org.apache.myfaces.adf.convert.ConverterTestCase;
-import org.apache.myfaces.adfbuild.test.MockUtils;
+import org.apache.myfaces.adfbuild.test.MockUIComponentWrapper;
 import org.apache.shale.test.mock.MockFacesContext;
+import org.jmock.Mock;
 
 /**
  * Test NumberConverter
@@ -42,10 +43,12 @@
    */
   public void testNullContext()
   {
-    MockUIComponent component = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
     NumberConverter converter = getNumberConverter();
 
-    doTestNullContext(component, converter);
+    doTestNullContext(wrapper, converter);
   }
 
   public void testNullComponent()
@@ -62,10 +65,12 @@
    */
   public void testNullInputValue() throws ConverterException
   {
-    MockUIComponent component = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
     NumberConverter converter  = getNumberConverter();
 
-    doTestNull(facesContext, component, converter);
+    doTestNull(facesContext, wrapper, converter);
   }
 
   public void testEmptyValueConversion()
@@ -75,8 +80,9 @@
 
   public void testValueType()
   {
-    MockUIComponent component = new MockUIComponent();
-    MockUtils.setFacesContext(facesContext);
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    setFacesContext(facesContext);
     try
     {
       String input = "123";
@@ -90,9 +96,9 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
-    component.verify();
+    mock.verify();
   }
 
   public void testAppropriateFormatsArePicked()
@@ -115,9 +121,10 @@
 
     for (int i = 0; i < patterns.length; i++)
     {
-      MockUIComponent component = new MockUIComponent();
-      
-      MockUtils.setFacesContext(facesContext);
+      Mock mock = mock(UIComponent.class);
+      UIComponent component = (UIComponent) mock.proxy();
+
+      setFacesContext(facesContext);
       try
       {
         nconv.setPattern(patterns[i]);
@@ -133,9 +140,9 @@
       }
       finally
       {
-        MockUtils.setFacesContext(null);
+        setFacesContext(null);
       }
-      component.verify();
+      mock.verify();
     }
   }
 
@@ -144,52 +151,54 @@
     NumberConverter converter = getNumberConverter();
 
     NumberConverter restoreConverter = getNumberConverter();
-    MockUIComponent comp = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     for (int i = 0; i < _LOCALES.length; i++)
     {
       converter.setLocale(_LOCALES[i]);
       restoreConverter.setLocale(_LOCALES[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, wrapper);
 
       converter.setCurrencyCode( _CURRENCY_CODES[i]);
       restoreConverter.setCurrencyCode( _CURRENCY_CODES[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, wrapper);
 
       converter.setCurrencySymbol(_CURRENCY_SYMBOLS[i]);
       restoreConverter.setCurrencySymbol(_CURRENCY_SYMBOLS[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, wrapper);
 
       converter.setIntegerOnly(_INTEGER_ONLY[1]);
       restoreConverter.setIntegerOnly(_INTEGER_ONLY[1]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, wrapper);
 
       converter.setMaxFractionDigits(_MAX_FRACTION_DIGITS[i]);
       restoreConverter.setMaxFractionDigits(_MAX_FRACTION_DIGITS[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, wrapper);
 
       converter.setMaxIntegerDigits(_MAX_INT_DIGITS[i]);
       restoreConverter.setMaxIntegerDigits(_MAX_INT_DIGITS[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, wrapper);
 
       converter.setMinFractionDigits(_MIN_FRACT_DIGITS[i]);
       restoreConverter.setMinFractionDigits(_MIN_FRACT_DIGITS[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, wrapper);
 
       converter.setMinIntegerDigits(_MIN_INT_DIGITS[i]);
       restoreConverter.setMinIntegerDigits(_MIN_INT_DIGITS[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, wrapper);
 
       converter.setPattern( _PATTTERNS[i]);
       restoreConverter.setPattern(_PATTTERNS[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, wrapper);
 
       converter.setTransient(_TRANSIENT[i]);
       restoreConverter.setTransient(_TRANSIENT[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, wrapper);
 
       converter.setType(_TYPES[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, wrapper);
 
     }
   }
@@ -197,12 +206,14 @@
   public void testCurrencyCodeIsHonoured()
   {
     NumberConverter converter = getNumberConverter();
-    MockUIComponent component   = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+
     converter.setLocale(Locale.US);
     converter.setType("currency");
     Double  value = new Double(99);
 
-    MockUtils.setFacesContext(facesContext);
+    setFacesContext(facesContext);
     try
     {
       String outPut = converter.getAsString(facesContext, component, value);
@@ -216,21 +227,22 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
-    component.verify();
+    mock.verify();
   }
 
   public void testCurrencyCodeIsHonouredWhenCurrencyCodeAndCurrencySymbolIsSet()
   {
     NumberConverter converter   = getNumberConverter();
-    MockUIComponent component = MockUtils.buildMockUIComponent(2);
-    
+    Mock mock = buildMockUIComponent(2);
+    UIComponent component = (UIComponent) mock.proxy();
+
     converter.setLocale(Locale.US);
     converter.setType("currency");
     Double value = new Double(99);
 
-    MockUtils.setFacesContext(facesContext);
+    setFacesContext(facesContext);
     try
     {
       String outPut = converter.getAsString(facesContext, component, value);
@@ -257,15 +269,16 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
-    component.verify();
+    mock.verify();
   }
 
   public void testCurrencySymbolIsHonoured()
   {
     NumberConverter converter = getNumberConverter();
-    MockUIComponent component   = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
     converter.setLocale(Locale.US);
     converter.setType("currency");
     Double  value = new Double(99);
@@ -273,7 +286,7 @@
     // since we set currency symbol to '*' we should get the value to be *99.00
     converter.setCurrencySymbol("*");
     
-    MockUtils.setFacesContext(facesContext);
+    setFacesContext(facesContext);
     try
     {
       String outPut = converter.getAsString(facesContext, component, value);
@@ -281,22 +294,23 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
-    component.verify();
+    mock.verify();
   }
 
   public void testIntegerOnlyIsHonoured()
   {
     // integerOnly is used only while parsing to create number objects
     NumberConverter converter = getNumberConverter();
-    MockUIComponent component   = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
     converter.setLocale(Locale.US);
 
     String[] inputs = {"23.10", "44.90876", "11111", "67859.0001"};
     Number[] expectedValues = {new Long(23), new Long(44), new Long(11111), new Long(67859)};
 
-    MockUtils.setFacesContext(facesContext);
+    setFacesContext(facesContext);
     try
     {
       for (int i = 0; i < inputs.length; i++)
@@ -308,9 +322,9 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
-    component.verify();
+    mock.verify();
   }
 
 
@@ -318,13 +332,14 @@
   {
     // integerOnly is used only while parsing to create number objects
     NumberConverter converter = getNumberConverter();
-    MockUIComponent component   = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
     converter.setLocale(Locale.US);
 
     String[] inputs = {"23.10", "44.90876", "11111", "67859.0001"};
     Number[] expectedValues = {new Long(23), new Long(44), new Long(11111), new Long(67859)};
 
-    MockUtils.setFacesContext(facesContext);
+    setFacesContext(facesContext);
     try
     {
       for (int i = 0; i < inputs.length; i++)
@@ -343,22 +358,23 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
-    component.verify();
+    mock.verify();
   }
 
   public void testLocaleIsPickedUpFromViewRoot()
   {
 
     NumberConverter converter = getNumberConverter();
-    MockUIComponent component   = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
 
     facesContext.getViewRoot().setLocale(Locale.US);
 
     String input = "1234.56";
 
-    MockUtils.setFacesContext(facesContext);
+    setFacesContext(facesContext);
     try
     {
       // if we get a valid object, implies locale was indeed picked up.
@@ -368,7 +384,7 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
   }
 
@@ -379,9 +395,10 @@
     String[] expectedValues = {"9,999", "99", "0.99", "99999.567", "9999"};
 
     NumberConverter converter = getNumberConverter();
-    MockUIComponent component   = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
     converter.setLocale(Locale.US);
-    MockUtils.setFacesContext(facesContext);
+    setFacesContext(facesContext);
     try
     {
       for (int i = 0; i < inputValues.length; i++)
@@ -393,22 +410,23 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
-    component.verify();
+    mock.verify();
   }
 
   public void testStrictnessOfConversion()
   {
     String[] inputValues = {"123ABC", "22.22.2" };
-    MockUIComponent component
-      = MockUtils.buildMockUIComponent(inputValues.length * 3);
+    Mock mock = buildMockUIComponent(inputValues.length * 3);
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     for (int i = 0; i < inputValues.length; i++)
     {
-      doTestStrictNess(facesContext, component, Locale.US, inputValues[i]);
+      doTestStrictNess(facesContext, wrapper, Locale.US, inputValues[i]);
     }
-    component.verify();
+    mock.verify();
   }
 
   public void testSettingFractDigitsAndSettingMinDigitsAreHononured()
@@ -422,9 +440,10 @@
     int[] minFractDigits = {0, 2, 0, 2};
 
     NumberConverter converter   = getNumberConverter();
-    MockUIComponent component   = new MockUIComponent();
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
 
-    MockUtils.setFacesContext(facesContext);
+    setFacesContext(facesContext);
     try
     {
       converter.setLocale(Locale.US);
@@ -441,16 +460,16 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
-    component.verify();
+    mock.verify();
   }
 
   protected abstract NumberConverter getNumberConverter();
 
   protected abstract void doTestStrictNess(
     MockFacesContext context,
-    MockUIComponent component,
+    MockUIComponentWrapper wrapper,
     Locale locale,
     String inputValue);
 

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/util/Base64InputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/util/Base64InputStreamTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/util/Base64InputStreamTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/util/Base64InputStreamTest.java Tue Jul 11 16:29:16 2006
@@ -19,6 +19,9 @@
 import java.io.IOException;
 import java.io.StringReader;
 import java.io.BufferedReader;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 import org.apache.myfaces.adfbuild.test.FacesTestCase;
 
@@ -39,7 +42,22 @@
  	public Base64InputStreamTest(String testName)
   	{
   	  super(testName);
- 	}
+ 	}
+  
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(Base64InputStreamTest.class);
+  }
 	
   /**
    * Tests decoding of stream that contains no trailing padding characters.

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/util/Base64OutputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/util/Base64OutputStreamTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/util/Base64OutputStreamTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/util/Base64OutputStreamTest.java Tue Jul 11 16:29:16 2006
@@ -20,6 +20,9 @@
 import java.io.StringWriter;
 import java.io.BufferedWriter;
 import java.util.zip.GZIPOutputStream;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 import org.apache.myfaces.adfbuild.test.FacesTestCase;
 
@@ -38,8 +41,23 @@
  	public Base64OutputStreamTest(String testName)
   	{
   	  super(testName);
- 	}
-	
+ 	}
+  
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(Base64OutputStreamTest.class);
+  }
+  
   /**
    * Tests decoding of stream that contains no trailing padding characters.
    */ 	

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/ByteLengthValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/ByteLengthValidatorTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/ByteLengthValidatorTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/ByteLengthValidatorTest.java Tue Jul 11 16:29:16 2006
@@ -16,11 +16,11 @@
 package org.apache.myfaces.adf.validator;
 
 
+import javax.faces.component.UIComponent;
 import javax.faces.validator.ValidatorException;
 
-import org.apache.myfaces.adfbuild.test.MockUtils;
-
-import javax.faces.component.MockUIComponent;
+import org.apache.myfaces.adfbuild.test.MockUIComponentWrapper;
+import org.jmock.Mock;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -59,9 +59,11 @@
    */
   public void testNull() throws ValidatorException
   {
-    MockUIComponent component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
     ByteLengthValidator validator = new ByteLengthValidator();
-    doTestNull(facesContext, component, validator);
+    doTestNull(facesContext, wrapper, validator);
   }
 
   /**
@@ -70,9 +72,11 @@
   public void testNullContext()
   {
 
-    MockUIComponent component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
     ByteLengthValidator validator = new ByteLengthValidator();
-    doTestNullContext(component, validator);
+    doTestNullContext(wrapper, validator);
   }
  /**
   * Check when component whose value is null is passed to the validator.
@@ -104,23 +108,28 @@
     String encodings[] = {"ISO-8859-1"};
     int maxBytes[]     = {4};
 
-    MockUIComponent component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     for (int i = 0; i < values.length ; i++)
     {
       validator.setEncoding(encodings[i]);
       validator.setMaximum(maxBytes[i]);
-      doTestValidate(validator, facesContext, component, values[i]);
+      doTestValidate(validator, facesContext, wrapper, values[i]);
     }
   }
 
   public void testDefaultEncodingWorks()
   {
-    MockUIComponent component = MockUtils.buildMockUIComponent();
+    
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
     ByteLengthValidator validator = new ByteLengthValidator();
     String value = "four";
     validator.setMaximum(4);
-    doTestValidate(validator, facesContext, component, value);
+    doTestValidate(validator, facesContext, wrapper, value);
   }
 
   /**
@@ -128,7 +137,9 @@
    */
   public void testStateHolderSaveRestore()
   {
-    MockUIComponent component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
     ByteLengthValidator validator = new ByteLengthValidator();
     validator.setEncoding("ISO-8859-1");
     validator.setMaximum(4);
@@ -136,7 +147,7 @@
     ByteLengthValidator restoreValidator = new  ByteLengthValidator();
 
     doTestStateHolderSaveRestore(validator, restoreValidator,
-                                 facesContext, component);
+                                 facesContext, wrapper);
   }
 
   /**
@@ -174,8 +185,10 @@
 
   public void testCustomMessageIsSet()
   {
-    MockUIComponent component = MockUtils.buildMockUIComponent();
-    setMockLabelForComponent(component);
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
+    setMockLabelForComponent(wrapper);
     ByteLengthValidator validator = new ByteLengthValidator();
     int maxBytes[]     = {3};
     validator.setMaximumMessageDetail("\"{1}\"" + _IS_GREATER

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/DateTimeRangeValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/DateTimeRangeValidatorTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/DateTimeRangeValidatorTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/DateTimeRangeValidatorTest.java Tue Jul 11 16:29:16 2006
@@ -19,13 +19,14 @@
 
 import javax.faces.convert.DateTimeConverter;
 import javax.faces.validator.ValidatorException;
-import javax.faces.component.MockUIComponent;
+import javax.faces.component.UIComponent;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.myfaces.adfbuild.test.MockUtils;
+import org.apache.myfaces.adfbuild.test.MockUIComponentWrapper;
 import org.apache.shale.test.mock.MockApplication;
+import org.jmock.Mock;
 
 /**
  * Unit tests for DateTimeRangeValidator.
@@ -69,8 +70,10 @@
   {
     DateTimeRangeValidator validator = new DateTimeRangeValidator();
 
-    MockUIComponent  component = MockUtils.buildMockUIComponent();
-    doTestNull(facesContext, component, validator);
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
+    doTestNull(facesContext, wrapper, validator);
   }
 
    /**
@@ -78,10 +81,12 @@
    */
   public void testNullContext()
   {
-    MockUIComponent component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
     RegExpValidator validator = new RegExpValidator();
 
-    doTestNullContext(component, validator);
+    doTestNullContext(wrapper, validator);
   }
 
   /**
@@ -101,12 +106,14 @@
   {
     DateTimeRangeValidator validator = new DateTimeRangeValidator();
 
-    MockUIComponent  component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
-    component.setupGetId("test");
+    mock.stubs().method("getId").will(returnValue("test"));
     try
     {
-      MockUtils.setFacesContext(facesContext);
+      setFacesContext(facesContext);
       validator.validate(facesContext, component, "not-a-date");
       fail("ValidatorException not thrown");
     }
@@ -116,9 +123,9 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
-    component.verify();
+    mock.verify();
   }
 
   /**
@@ -132,18 +139,20 @@
     DateTimeRangeValidator validator = new DateTimeRangeValidator();
     validator.setMaximum(new Date(millis));
 
-    MockUIComponent  component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     try
     {
-      MockUtils.setFacesContext(facesContext);
+      setFacesContext(facesContext);
       validator.validate(facesContext, component, new Date(millis - 1));
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
-    component.verify();
+    mock.verify();
   }
 
   protected void setMockCreateConverter(MockApplication app)
@@ -161,13 +170,15 @@
     DateTimeRangeValidator validator = new DateTimeRangeValidator();
     validator.setMaximum(new Date(millis));
 
-    MockUIComponent component = MockUtils.buildMockUIComponent(4);
-    setMockLabelForComponent(component);
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
+    setMockLabelForComponent(wrapper);
 
     setMockCreateConverter(application);
     try
     {
-      MockUtils.setFacesContext(facesContext);
+      setFacesContext(facesContext);
       validator.setMaximumMessageDetail("max set");
       validator.validate(facesContext, component, new Date(millis + 1));
       fail("ValidatorException not thrown");
@@ -180,10 +191,10 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
 
-    component.verify();
+    mock.verify();
   }
 
   /**
@@ -197,11 +208,12 @@
     DateTimeRangeValidator validator = new DateTimeRangeValidator();
     validator.setMinimum(new Date(millis));
 
-    MockUIComponent  component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
 
     validator.validate(facesContext, component, new Date(millis + 1));
 
-    component.verify();
+    mock.verify();
   }
 
   /**
@@ -213,15 +225,16 @@
     DateTimeRangeValidator validator = new DateTimeRangeValidator();
     validator.setMinimum(new Date(millis));
 
-    MockUIComponent  component = MockUtils.buildMockUIComponent();
-
-    setMockLabelForComponent(component);
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
+    setMockLabelForComponent(wrapper);
     
     setMockCreateConverter(application);
 
     try
     {
-      MockUtils.setFacesContext(facesContext);
+      setFacesContext(facesContext);
       validator.setMinimumMessageDetail("min set");
       validator.validate(facesContext, component, new Date(millis - 1));
       fail("ValidatorException not thrown");
@@ -234,10 +247,10 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
 
-    component.verify();
+    mock.verify();
   }
 
   /**
@@ -252,19 +265,20 @@
     validator.setMinimum(new Date(millis));
     validator.setMaximum(new Date(millis + 2));
 
-    MockUIComponent  component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
 
     try
     {
-      MockUtils.setFacesContext(facesContext);
+      setFacesContext(facesContext);
       validator.validate(facesContext, component, new Date(millis + 1));
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
 
-    component.verify();
+    mock.verify();
   }
 
   /**
@@ -277,15 +291,16 @@
     validator.setMinimum(new Date(millis));
     validator.setMaximum(new Date(millis + 10));
 
-    MockUIComponent  component = MockUtils.buildMockUIComponent();
-
-    setMockLabelForComponent(component);
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
+    setMockLabelForComponent(wrapper);
 
     setMockCreateConverter(application);
 
     try
     {
-      MockUtils.setFacesContext(facesContext);
+      setFacesContext(facesContext);
       validator.setMinimumMessageDetail("min");
       validator.validate(facesContext, component, new Date(millis - 1));
       fail("ValidatorException not thrown");
@@ -297,10 +312,10 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
 
-    component.verify();
+    mock.verify();
   }
 
   /**
@@ -313,14 +328,16 @@
     validator.setMinimum(new Date(millis));
     validator.setMaximum(new Date(millis + 10));
 
-    MockUIComponent  component = MockUtils.buildMockUIComponent();
-    setMockLabelForComponent(component);
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
+    setMockLabelForComponent(wrapper);
 
     setMockCreateConverter(application);
 
     try
     {
-      MockUtils.setFacesContext(facesContext);
+      setFacesContext(facesContext);
       validator.setNotInRangeMessageDetail("not in range is set");
       validator.validate(facesContext, component, new Date(millis + 20));
       fail("ValidatorException not thrown");
@@ -333,10 +350,10 @@
     }
     finally
     {
-      MockUtils.setFacesContext(null);
+      setFacesContext(null);
     }
 
-    component.verify();
+    mock.verify();
   }
 
 
@@ -354,12 +371,14 @@
     originalValidator.setMaximumMessageDetail("max");
     originalValidator.setNotInRangeMessageDetail("not in range");
 
-    MockUIComponent  component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     DateTimeRangeValidator restoredValidator = new DateTimeRangeValidator();
 
     doTestStateHolderSaveRestore(originalValidator, restoredValidator,
-                                 facesContext, component);
+                                 facesContext, wrapper);
   }
 
 }

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/RegExpValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/RegExpValidatorTest.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/RegExpValidatorTest.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/RegExpValidatorTest.java Tue Jul 11 16:29:16 2006
@@ -17,13 +17,14 @@
 package org.apache.myfaces.adf.validator;
 
 import javax.faces.validator.ValidatorException;
-import javax.faces.component.MockUIComponent;
+import javax.faces.component.UIComponent;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
 import org.apache.myfaces.adf.validator.RegExpValidator;
-import org.apache.myfaces.adfbuild.test.MockUtils;
+import org.apache.myfaces.adfbuild.test.MockUIComponentWrapper;
+import org.jmock.Mock;
 
 /**
  * Unit tests for RegExpValidator
@@ -59,10 +60,12 @@
    */
   public void testNull() throws ValidatorException
   {
-    MockUIComponent component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
     RegExpValidator validator = new RegExpValidator();
 
-    doTestNull(facesContext, component, validator);
+    doTestNull(facesContext, wrapper, validator);
   }
 
   /**
@@ -70,10 +73,12 @@
    */
   public void testNullContext()
   {
-    MockUIComponent component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
     RegExpValidator validator = new RegExpValidator();
 
-    doTestNullContext(component, validator);
+    doTestNullContext(wrapper, validator);
   }
 
   public void testNullComponent()
@@ -98,7 +103,8 @@
   {
     // since the pattern has not been set it will be null
     // let us push some arbitary value
-    MockUIComponent component = MockUtils.buildMockUIComponent();
+    Mock mock = mock(UIComponent.class); 
+    UIComponent component = (UIComponent) mock.proxy();
 
     try
     {
@@ -112,7 +118,7 @@
     {
       // suppress it - this is as expected
     }
-    component.verify();
+    mock.verify();
   }
 
   /**
@@ -121,8 +127,10 @@
   public void testBlankValueOnPattern()
   {
     // some very basic sanity test
-    MockUIComponent component = MockUtils.buildMockUIComponent();
-    setMockLabelForComponent(component);
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
+    setMockLabelForComponent(wrapper);
 
     try
     {
@@ -137,7 +145,7 @@
       // if exception then fine.
     }
 
-    component.verify();
+    mock.verify();
   }
 
   /**
@@ -151,14 +159,16 @@
     //some very basic sanity test
     //
     RegExpValidator validator = new RegExpValidator();
-    MockUIComponent component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     String values[]   = {"9123456","9x"};
     String patterns[] = {"[0-9]*","[9][x]"};
     for (int i = 0; i < values.length ; i++)
     {
       validator.setPattern(patterns[i]);
-      doTestValidate(validator, facesContext, component, values[i]);
+      doTestValidate(validator, facesContext, wrapper, values[i]);
     }
   }
 
@@ -168,14 +178,16 @@
   public void testStateHolderSaveRestore()
   {
     RegExpValidator validator = new RegExpValidator();
-    MockUIComponent component = MockUtils.buildMockUIComponent();
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
 
     validator.setPattern("TestSaveRestore");
     validator.setNoMatchMessageDetail("\"{0}\" in \"{1}\" failed!! {4}");
     RegExpValidator restoreValidator = new  RegExpValidator();
 
     doTestStateHolderSaveRestore(validator, restoreValidator,
-                                 facesContext, component);
+                                 facesContext, wrapper);
   }
 
   /**
@@ -202,8 +214,10 @@
 
   public void testCustomMessageIsSet()
   {
-    MockUIComponent component     = MockUtils.buildMockUIComponent();
-    setMockLabelForComponent(component);
+    Mock mock = buildMockUIComponent();
+    UIComponent component = (UIComponent) mock.proxy();
+    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
+    setMockLabelForComponent(wrapper);
     RegExpValidator validator = new RegExpValidator();
 
     validator.setPattern("[0-9]*");

Modified: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/ValidatorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/ValidatorTestCase.java?rev=421025&r1=421024&r2=421025&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/ValidatorTestCase.java (original)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/ValidatorTestCase.java Tue Jul 11 16:29:16 2006
@@ -20,30 +20,32 @@
 import java.util.Map;
 
 import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
 import javax.faces.validator.Validator;
 import javax.faces.validator.ValidatorException;
-import javax.faces.component.MockUIComponent;
 
-import org.apache.shale.test.base.AbstractJsfTestCase;
+import org.apache.myfaces.adfbuild.test.AbstractBaseTestCase;
+import org.apache.myfaces.adfbuild.test.MockUIComponentWrapper;
 import org.apache.shale.test.mock.MockFacesContext;
+import org.jmock.Mock;
 
 /**
  * Base class for unit tests for Validators
  *
  * @author vijay venkatarman
  */
-public abstract class ValidatorTestCase extends AbstractJsfTestCase
+public abstract class ValidatorTestCase extends AbstractBaseTestCase
 {
   public ValidatorTestCase(String testName)
   {
     super(testName);
   }
 
-  protected static void setMockLabelForComponent(MockUIComponent component)
+  protected void setMockLabelForComponent(MockUIComponentWrapper wrapper)
   {
     Map attributes = new HashMap();
     attributes.put("label", "label");
-    component.setupGetAttributes(attributes);
+    wrapper.getMock().stubs().method("getAttributes").will(returnValue(attributes));
   }
 
   /**
@@ -53,25 +55,25 @@
    */
   protected void doTestNull(
     MockFacesContext context,
-    MockUIComponent component,
+    MockUIComponentWrapper wrapper,
     Validator validator
     ) throws ValidatorException
   {
-    validator.validate(context, component, null);
+    validator.validate(context, wrapper.getUIComponent(), null);
 
-    component.verify();
+    wrapper.getMock().verify();
   }
 
   /**
    * if contex or component = null then should throw NullPointerException
    */
   protected void doTestNullContext(
-    MockUIComponent component,
+    MockUIComponentWrapper wrapper,
     Validator validator) throws NullPointerException
   {
     try
     {
-      validator.validate(null, component , "dummy");
+      validator.validate(null, wrapper.getUIComponent(), "dummy");
       fail("Expected NullpointerException - if context or component is null");
     }
     catch (NullPointerException npe)
@@ -107,12 +109,12 @@
   protected void doTestValidate(
     Validator validator,
     MockFacesContext context,
-    MockUIComponent component,
+    MockUIComponentWrapper wrapper,
     Object value
     )  throws ValidatorException
   {
-    validator.validate(context, component, value );
-    component.verify();
+    validator.validate(context, wrapper.getUIComponent(), value );
+    wrapper.getMock().verify();
   }
 
   /**
@@ -141,21 +143,21 @@
     Validator thisValidator,
     Validator otherValidator,
     MockFacesContext context,
-    MockUIComponent component)
+    MockUIComponentWrapper wrapper)
   {
     Object state = ((StateHolder)thisValidator).saveState(context);
 
     ((StateHolder)otherValidator).restoreState(context, state);
     // do all actions of save and restore
     doTestEquals(thisValidator, otherValidator, true);
-    component.verify();
+    wrapper.getMock().verify();
   }
 
   public void doTestIsNotString(Validator validator)
   {
-    MockUIComponent component = new MockUIComponent();
-
-    component.setupGetId("test");
+    Mock mock = mock(UIComponent.class);
+    UIComponent component = (UIComponent) mock.proxy();
+    mock.stubs().method("getId").will(returnValue("test"));
     try
     {
       validator.validate(facesContext, component, new Integer(1));

Added: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adfbuild/test/AbstractBaseTestCase.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adfbuild/test/AbstractBaseTestCase.java?rev=421025&view=auto
==============================================================================
--- incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adfbuild/test/AbstractBaseTestCase.java (added)
+++ incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adfbuild/test/AbstractBaseTestCase.java Tue Jul 11 16:29:16 2006
@@ -0,0 +1,59 @@
+package org.apache.myfaces.adfbuild.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.apache.shale.test.jmock.AbstractJsfTestCase;
+import org.jmock.Mock;
+
+public abstract class AbstractBaseTestCase extends AbstractJsfTestCase
+{
+
+  public AbstractBaseTestCase(String name)
+  {
+    super(name);
+  }
+  
+  protected void setFacesContext(FacesContext context)
+  {
+    FacesTestCase.TestFacesContext.setCurrentInstance(context);
+  }
+
+  protected Mock buildMockUIComponent()
+  {
+    return buildMockUIComponent(1);
+  }
+
+  protected Mock buildMockUIComponent(
+    int iterations
+    )
+  {
+    return buildMockUIComponent(iterations, new String[] {"label"});
+  }
+
+  /**
+   * Builds a MockUIComponent with attributes setup for the requested number of
+   * test iterations.
+   */
+  protected Mock buildMockUIComponent(
+    int iterations,
+    String attributeNames[]
+     )
+  {
+    int i;
+    Mock c = mock(UIComponent.class);
+    Map attrs = new HashMap();
+    for (i = 0; i < attributeNames.length; i++)
+      attrs.put(attributeNames[i], attributeNames[i]);
+    for (i = 0; i < iterations; i++)
+    {
+      c.stubs().method("getAttributes").will(returnValue(attrs));
+      c.stubs().method("getId").will(returnValue("mockId"));
+    }
+
+    return c;
+  }
+}
\ No newline at end of file

Propchange: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adfbuild/test/AbstractBaseTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adfbuild/test/AbstractBaseTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message