incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r419080 - in /incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf: convert/ validator/
Date Tue, 04 Jul 2006 20:04:04 GMT
Author: matzew
Date: Tue Jul  4 13:04:03 2006
New Revision: 419080

URL: http://svn.apache.org/viewvc?rev=419080&view=rev
Log:
porting down to shale-1.0.2 (still pending)

Modified:
    incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/AdfDateTimeConverterTest.java
    incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/AdfNumberConverterTest.java
    incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/ColorConverterTest.java
    incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/ConverterTestCase.java
    incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/DateTimeConverterTestCase.java
    incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/JsfDateTimeConverterTest.java
    incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/JsfNumberConverterTest.java
    incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/convert/NumberConverterTestCase.java
    incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/ByteLengthValidatorTest.java
    incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/DateTimeRangeValidatorTest.java
    incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/RegExpValidatorTest.java
    incubator/adffaces/branches/matzew-mock-overhaul/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/validator/ValidatorTestCase.java

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=419080&r1=419079&r2=419080&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  4 13:04:03 2006
@@ -21,17 +21,16 @@
 import java.util.Locale;
 import java.util.TimeZone;
 
-import javax.faces.component.UIViewRoot;
+import javax.faces.component.MockUIComponent;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 
-import org.apache.myfaces.adf.context.AdfFacesContext;
-import org.apache.myfaces.adf.context.MockAdfFacesContext;
-
-import javax.faces.component.MockUIComponent;
-import javax.faces.context.MockFacesContext;
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
+import org.apache.myfaces.adf.context.MockAdfFacesContext;
 import org.apache.myfaces.adfbuild.test.MockUtils;
+import org.apache.shale.test.mock.MockFacesContext;
 
 public class AdfDateTimeConverterTest extends DateTimeConverterTestCase
 {
@@ -39,6 +38,28 @@
   {
     super(name);
   }
+  
+
+  public void setUp()
+  {
+    super.setUp();
+    _mafct = new MockAdfFacesContext();
+    _mafct.setTwoDigitYearStart(1950);
+    _mafct.setTimeZone(DEFAULT_TIME_ZONE);
+  }
+
+  public void tearDown()
+  {
+    super.tearDown();
+    _mafct.release();
+    _mafct = null;
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(AdfDateTimeConverterTest.class);
+  }
+  
 
   /**
    * @todo move this to the parent class once JSF fixes the bug
@@ -59,19 +80,17 @@
     Date date = gcal.getTime();
 
     DateTimeConverter dtConv   = new DateTimeConverter();
-    MockFacesContext context   = new MockFacesContext();
     MockUIComponent component  = MockUtils.buildMockUIComponent();
     String inputValue          = "6/4/2999";
 
     dtConv.setDateStyle("shortish");
     dtConv.setLocale(Locale.ENGLISH);
 
-    Date dt = (Date) dtConv.getAsObject(context, component, inputValue);
+    Date dt = (Date) dtConv.getAsObject(facesContext, component, inputValue);
     assertEquals(true, isEqual(date, dt));
 
-    String exptectedStr = dtConv.getAsString(context, component, dt);
+    String exptectedStr = dtConv.getAsString(facesContext, component, dt);
     assertEquals(inputValue, exptectedStr);
-    context.verify();
     component.verify();
   }
 
@@ -91,7 +110,6 @@
     Date date = gcal.getTime();
 
     DateTimeConverter dtConv   = new DateTimeConverter();
-    MockFacesContext context   = new MockFacesContext();
     MockUIComponent component  = MockUtils.buildMockUIComponent();
     String inputValue          = "6/4/1600";
     String secondaryPattern    = "MM/d/yyyy";
@@ -101,12 +119,12 @@
     dtConv.setType("Let us un set it");
     dtConv.setSecondaryPattern(secondaryPattern);
     // This should work fine
-    Date dt = (Date) dtConv.getAsObject(context, component, inputValue);
+    Date dt = (Date) dtConv.getAsObject(facesContext, component, inputValue);
     assertEquals(true, isEqual(date, dt));
 
     try
     {
-      dtConv.getAsString(context, component, dt);
+      dtConv.getAsString(facesContext, component, dt);
       fail("Use of secondary pattern in the above fashion is expected to fail here");
     }
     catch (RuntimeException ce)
@@ -119,10 +137,9 @@
 
     // now we set date and type so this is expected to work fine.
 
-    String expectedOut = dtConv.getAsString(context, component, date);
+    String expectedOut = dtConv.getAsString(facesContext, component, date);
     assertEquals(inputValue, expectedOut);
 
-    context.verify();
     component.verify();
   }
 
@@ -140,15 +157,6 @@
     dotestLeniencyOnPattern(primaryPattern, secondaryPattern);
   }
 
-  private void _setupFacesContext(MockFacesContext context, int count)
-  {
-    UIViewRoot uiRoot = new UIViewRoot();
-    uiRoot.setLocale(Locale.ENGLISH);
-
-    for (int j = 0; j < count; j++)
-      context.setupGetViewRoot(uiRoot);
-  }
-
   protected void dotestLeniencyOnPattern(
     String primaryPattern,
     String secondaryPatttern
@@ -177,7 +185,6 @@
        = MockUtils.buildMockUIComponent(iterations);
     for (int i = 0; i < validInputs.length; i++)
     {
-      MockFacesContext context  = new MockFacesContext();
       DateTimeConverter
         dtConv = (DateTimeConverter) getDateTimeConverter();
       dtConv.setLocale(Locale.ENGLISH);
@@ -186,12 +193,9 @@
       dtConv.setTimeZone(DEFAULT_TIME_ZONE);
       dtConv.setType("INVALID"); // make this type invalid
 
-      _setupFacesContext(context, validInputs.length * 3);
-
-      Date convDate = (Date) dtConv.getAsObject(context, component,
+      Date convDate = (Date) dtConv.getAsObject(facesContext, component,
                                                 validInputs[i]);
       assertEquals(convDate, dt);
-      context.verify();
       component.verify();
     }
   }
@@ -214,15 +218,13 @@
       fdtConv.setLocale((Locale)data[i][2]);
       fdtConv.setTimeZone((TimeZone)data[i][3]);
 
-      MockFacesContext context  = new MockFacesContext();
-      _setupFacesContext(context, 4);
       MockUIComponent component = MockUtils.buildMockUIComponent();
-      Date dtConvDate  = (Date)dtConv.getAsObject(context, component, inputValue);
-      Date fdtConvDate = (Date)fdtConv.getAsObject(context, component, inputValue);
+      Date dtConvDate  = (Date)dtConv.getAsObject(facesContext, component, inputValue);
+      Date fdtConvDate = (Date)fdtConv.getAsObject(facesContext, component, inputValue);
       //      assertEquals(dtConvDate, fdtConvDate);
 
-      String dtConvPattern  = dtConv.getAsString(context, component, dtConvDate);
-      String fdtConvPattern = fdtConv.getAsString(context, component, dtConvDate);
+      String dtConvPattern  = dtConv.getAsString(facesContext, component, dtConvDate);
+      String fdtConvPattern = fdtConv.getAsString(facesContext, component, dtConvDate);
       //      assertEquals(dtConvPattern, fdtConvPattern);
     }
   }
@@ -262,19 +264,15 @@
 
     for (int i = 0; i < failingValues.length ; i++)
     {
-      MockFacesContext context  = new MockFacesContext();
       MockUIComponent component = MockUtils.buildMockUIComponent(3 * 4);
 
       org.apache.myfaces.adf.convert.DateTimeConverter converter =
         new org.apache.myfaces.adf.convert.DateTimeConverter();
 
-      UIViewRoot root = new UIViewRoot();
-      root.setLocale(Locale.US);
-
       for (int j = 0; j < 3; j++)
       {
         for (int k = 0; k < 4; k++)
-          context.setupGetViewRoot(root);
+        	facesContext.getViewRoot().setLocale(Locale.US);
       }
 
       try
@@ -296,7 +294,7 @@
         else
           converter.setType(types[i]);
 
-        Object obj = converter.getAsObject(context, component, failingValues[i]);
+        Object obj = converter.getAsObject(facesContext, component, failingValues[i]);
         fail("Expected converter exception");
       }
       catch (ConverterException ce)
@@ -308,19 +306,6 @@
     }
   }
 
-  protected void setUp()
-  {
-    _mafct = new MockAdfFacesContext();
-    _mafct.setTwoDigitYearStart(1950);
-    _mafct.setTimeZone(DEFAULT_TIME_ZONE);
-  }
-
-  protected void tearDown()
-  {
-    _mafct.release();
-    _mafct = null;
-  }
-
   private Object[][] _getDataForPatterns()
   {
     // pattern, inputvalue,locale,timezone
@@ -347,5 +332,4 @@
   private MockAdfFacesContext _mafct;
 
   private static final TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault();
-}
-
+}
\ 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/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=419080&r1=419079&r2=419080&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  4 13:04:03 2006
@@ -19,16 +19,17 @@
 
 import java.util.Locale;
 
-import javax.faces.component.UIViewRoot;
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.NumberConverter;
+import javax.faces.component.MockUIComponent;
+import javax.faces.component.UIViewRoot;
 
-import org.apache.myfaces.adf.context.AdfFacesContext;
 import org.apache.myfaces.adf.context.MockAdfFacesContext;
 import org.apache.myfaces.adfbuild.test.MockUtils;
+import org.apache.shale.test.mock.MockFacesContext;
 
-import javax.faces.component.MockUIComponent;
-import javax.faces.context.MockFacesContext;
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 /**
  * Test ADF NumberConverter
@@ -47,25 +48,31 @@
     return new org.apache.myfaces.adf.convert.NumberConverter();
   }
 
-  protected void setUp()
+  public void setUp()
   {
+    super.setUp();
     _mafct = new MockAdfFacesContext();
     _mafct.setDecimalSeparator('.');
     _mafct.setNumberGroupingSeparator(',');
     _mafct.setCurrencyCode(null);
   }
 
-  protected void tearDown()
+  public void tearDown()
   {
-
-   // AdfFacesContext uses a thread local variable to hold itself and has a
-   // check in it. So you need to release, since all instances for tests
-   // are created on the same thread by Junit.
+    
+    // AdfFacesContext uses a thread local variable to hold itself and has a
+    // check in it. So you need to release, since all instances for tests
+    // are created on the same thread by Junit.
     _mafct.release();
-
     _mafct = null;
+    super.tearDown();
   }
 
+  public static Test suite()
+  {
+    return new TestSuite(AdfNumberConverterTest.class);
+  }
+  
   public void testCurrencyCodeIsHonoured()
   {
      DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
@@ -76,22 +83,22 @@
 
   public void testValueSetInAdfFacesContextIsHonoured()
   {
-    tearDown();
+    //ugly ?
+    _mafct.release();
+    _mafct = null;
     _mafct = new MockAdfFacesContext();
     _mafct.setDecimalSeparator('*');
     _mafct.setNumberGroupingSeparator('!');
     _mafct.setCurrencyCode(null);
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = new MockUIComponent();
 
     NumberConverter conv = getNumberConverter();
 
     conv.setLocale(Locale.US);
     Number inputValue =  new Double(8989.789);
-    String out = conv.getAsString(context, component, inputValue);
+    String out = conv.getAsString(facesContext, component, inputValue);
     assertEquals("8!989*789", out);
 
-    context.verify();
     component.verify();
   }
 
@@ -103,10 +110,7 @@
   {
      NumberConverter converter = getNumberConverter();
      converter.setLocale(locale);
-     UIViewRoot root = new UIViewRoot();
-     root.setLocale(locale);
-     context.setupGetViewRoot(root);
-     context.setupGetViewRoot(root);
+     context.getViewRoot().setLocale(locale);
      try
      {
        // ADF Converter is not lenient.
@@ -133,12 +137,13 @@
       org.apache.myfaces.adf.convert.NumberConverter converter =
         new org.apache.myfaces.adf.convert.NumberConverter();
 
-      UIViewRoot root = new UIViewRoot();
+      UIViewRoot root = facesContext.getViewRoot();
       root.setLocale(Locale.US);
+      
 
       for (int j = 0; j < 3; j++)
       {
-        context.setupGetViewRoot(root);
+        context.setViewRoot(root);
       }
 
       try

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=419080&r1=419079&r2=419080&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  4 13:04:03 2006
@@ -19,16 +19,18 @@
 import java.awt.Color;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Locale;
-import javax.faces.component.UIViewRoot;
+
 import javax.faces.convert.ConverterException;
 import javax.faces.component.MockUIComponent;
-import javax.faces.context.MockFacesContext;;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 /**
  * Unit tests for ColorConverter
  * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-api/src/test/java/oracle/adf/view/faces/convert/ColorConverterTest.java#1 $) $Date: 16-aug-2005.15:12:23 $
  * @author vijay venkataraman (vijay.venkataraman@oracle.com)
+ * @author Matthias Wessendorf
  */
 public class ColorConverterTest extends ConverterTestCase
 {
@@ -37,6 +39,21 @@
     super(testName);
   }
 
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(ColorConverterTest.class);
+  }
+  
   /**
    * Tests that null returns immediately.
    *
@@ -44,11 +61,10 @@
    */
   public void testNull() throws ConverterException
   {
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = new MockUIComponent();
     ColorConverter converter  = new ColorConverter();
 
-    doTestNull(context, component, converter);
+    doTestNull(facesContext, component, converter);
   }
 
   /**
@@ -64,10 +80,9 @@
 
   public void testNullComponent()
   {
-    MockFacesContext context  = new MockFacesContext();
     ColorConverter converter  = new ColorConverter();
 
-    doTestNullComponent(context, converter);
+    doTestNullComponent(facesContext, converter);
   }
 
   public void testEmptyValueConversion()
@@ -112,11 +127,10 @@
   public void testDefaultColorPatternWorks()
   {
     ColorConverter converter  = new ColorConverter();
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = new MockUIComponent();
     String value = "#FFFFFF";
     Color expectedColor = new Color(255,255,255);
-    doTestGetAsObject(converter, context, component, value, expectedColor);
+    doTestGetAsObject(converter, facesContext, component, value, expectedColor);
   }
 
   /**
@@ -125,7 +139,6 @@
   public void testStateHolderSaveRestore()
   {
     ColorConverter converter = new ColorConverter();
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = new MockUIComponent();
 
     String[] patterns = {"#RRGGBB","RR.GG.BB"};
@@ -134,8 +147,7 @@
     ColorConverter restoreConverter = new  ColorConverter();
 
     doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 context, component);
-    context.verify();
+        facesContext, component);
     component.verify();
   }
   /**
@@ -145,7 +157,6 @@
   public void testGetAsObjectConversion()
   {
     ColorConverter converter = new ColorConverter();
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = new MockUIComponent();
 
     String[] patterns = { "#RRGGBB",
@@ -174,9 +185,8 @@
     converter.setPatterns(patterns);
     for (int i = 0; i < values.length; i++)
     {
-      doTestGetAsObject(converter, context, component,values[i], matchColors[i]);
+      doTestGetAsObject(converter, facesContext, component,values[i], matchColors[i]);
     }
-    context.verify();
     component.verify();
   }
 
@@ -187,7 +197,6 @@
   public void testGetAsString()
   {
     ColorConverter converter  = new ColorConverter();
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = new MockUIComponent();
 
     Color[] colors = {  new Color(255,2,4),
@@ -215,10 +224,9 @@
     {
       String[] patterns = (String[]) patternsHoloder.get(i);
       converter.setPatterns(patterns);
-      doTestGetAsString(converter, context, component,
+      doTestGetAsString(converter, facesContext, component,
                                     colors[i], matchValues[i] );
     }
-    context.verify();
     component.verify();
   }
 
@@ -228,7 +236,6 @@
   public void testNullValueForPatterns()
   {
     ColorConverter converter = new ColorConverter();
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = new MockUIComponent();
 
     try
@@ -240,29 +247,22 @@
     {
       // expected fine
     }
-    context.verify();
     component.verify();
   }
 
   public void testGetAsObjectIllegalValue()
   {
     ColorConverter converter = new ColorConverter();
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = new MockUIComponent();
-    UIViewRoot root = new UIViewRoot();
-    root.setLocale(new Locale("xx","MOCK"));
     component.setupGetId("test");
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
     try
     {
-      converter.getAsString(context, component, new Integer(1));
+      converter.getAsString(facesContext, component, new Integer(1));
       fail("Expected a converter exception");
     } catch (IllegalArgumentException ex)
     {
       // expected
     }
-    context.verify();
     component.verify();
   }
-}
+}
\ 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/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=419080&r1=419079&r2=419080&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  4 13:04:03 2006
@@ -17,15 +17,13 @@
 package org.apache.myfaces.adf.convert;
 
 import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 
-import junit.framework.TestCase;
-
 import javax.faces.component.MockUIComponent;
-import javax.faces.context.MockFacesContext;
+
+import org.apache.shale.test.base.AbstractJsfTestCase;
+import org.apache.shale.test.mock.MockFacesContext;
 
 /**
  * Base class for unit tests of Converters
@@ -34,7 +32,7 @@
  * @author vijay venkatarman (vijay.venkataraman@oracle.com)
  *
  */
-public abstract class ConverterTestCase extends TestCase
+public abstract class ConverterTestCase extends AbstractJsfTestCase
 {
   public ConverterTestCase(String testName)
   {
@@ -60,7 +58,6 @@
     assertEquals(null, obj);
     String str = converter.getAsString(context, component, null);
     assertEquals("",str);
-    context.verify();
     component.verify();
   }
 
@@ -145,7 +142,6 @@
     Object conv = converter.getAsObject(context, component, value);
     assertEquals(expectedValue, conv);
 
-    context.verify();
     component.verify();
   }
 
@@ -168,7 +164,6 @@
   {
     Object conv = converter.getAsString(context, component, value);
     assertEquals(conv, expectedValue);
-    context.verify();
     component.verify();
   }
 
@@ -210,7 +205,6 @@
     ((StateHolder)otherConverter).restoreState(context, state);
     // do all actions of save and restore
     doTestEquals(thisConverter, otherConverter, true);
-    context.verify();
     component.verify();
   }
 

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=419080&r1=419079&r2=419080&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  4 13:04:03 2006
@@ -15,20 +15,17 @@
  */
 
 package org.apache.myfaces.adf.convert;
+
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.Locale;
 import java.util.TimeZone;
 
-import javax.faces.component.UIViewRoot;
 import javax.faces.convert.ConverterException;
-
-import org.apache.myfaces.adf.convert.ConverterTestCase;
-
 import javax.faces.component.MockUIComponent;
-import javax.faces.context.MockFacesContext;
 
+import org.apache.myfaces.adf.convert.ConverterTestCase;
 import org.apache.myfaces.adfbuild.test.MockUtils;
 
 /**
@@ -42,7 +39,7 @@
   {
     super(testName);
   }
-
+  
   /**
    * @todo once all test case work fine - we can move all in to one method
    */
@@ -73,12 +70,11 @@
    */
   protected void checkNullInputValue() throws ConverterException
   {
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = new MockUIComponent();
 
     javax.faces.convert.DateTimeConverter converter  = getDateTimeConverter();
 
-    doTestNull(context, component, converter);
+    doTestNull(facesContext, component, converter);
   }
 
   /**
@@ -94,10 +90,9 @@
 
   protected void checkNullComponent()
   {
-    MockFacesContext context = new MockFacesContext();
     javax.faces.convert.DateTimeConverter converter  = getDateTimeConverter();
 
-    doTestNullComponent(context, converter);
+    doTestNullComponent(facesContext, converter);
   }
 
   /**
@@ -168,7 +163,6 @@
   {
 
     javax.faces.convert.DateTimeConverter converter = getDateTimeConverter();
-    MockFacesContext context    = new MockFacesContext();
     MockUIComponent component   = new MockUIComponent();
 
     javax.faces.convert.DateTimeConverter restoreConverter = getDateTimeConverter();
@@ -188,40 +182,39 @@
       converter.setLocale(_LOCALES[i]);
       restoreConverter.setLocale(_LOCALES[i]);
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 context, component);
+                                 facesContext, component);
 
       converter.setPattern(_PATTERNS[i]);
       restoreConverter.setPattern(_PATTERNS[i]);
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 context, component);
+                                 facesContext, component);
 
       converter.setTimeStyle(_TIME_STYLES[i]);
       restoreConverter.setTimeStyle(_TIME_STYLES[i]);
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 context, component);
+                                 facesContext, component);
 
       converter.setTimeZone(_TIME_ZONES[i]);
       restoreConverter.setTimeZone(_TIME_ZONES[i]);
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 context, component);
+                                 facesContext, component);
 
       converter.setType(_TYPES[i]);
       restoreConverter.setType(_TYPES[i]);
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 context, component);
+                                 facesContext, component);
 
       String secPattern = _SECONDARY_PATTERNS[i];
       setSecondaryPattern(converter, secPattern);
       setSecondaryPattern(restoreConverter, secPattern);
 
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                   context, component);
+                                   facesContext, component);
 
       converter.setTransient(_TRANSIENT_VALUES[i]);
       restoreConverter.setTransient(_TRANSIENT_VALUES[i]);
       doTestStateHolderSaveRestore(converter, restoreConverter,
-                                 context, component);
-      context.verify();
+                                 facesContext, component);
       component.verify();
     }
   }
@@ -240,13 +233,12 @@
       dtConv.setTimeZone(_STIME_ZONES[i]);
       dtConv.setType(_STYPES[i]);
 
-      MockFacesContext context  =  new MockFacesContext();
       MockUIComponent component =  new MockUIComponent();
       
-      MockUtils.setFacesContext(context);
+      MockUtils.setFacesContext(facesContext);
       try
       {
-        Date obj = (Date)dtConv.getAsObject(context, component, _SINPUT_VALUES[i]);
+        Date obj = (Date)dtConv.getAsObject(facesContext, component, _SINPUT_VALUES[i]);
         assertEquals(true, isEqual(obj,_SEXPECTED_DATES[i]));
       }
       finally
@@ -254,7 +246,6 @@
         MockUtils.setFacesContext(null);
       }
 
-      context.verify();
       component.verify();
    }
   }
@@ -269,12 +260,9 @@
     dtConv.setTimeZone(null);
     dtConv.setPattern(pattern);
 
-    MockFacesContext context   = new MockFacesContext();
     MockUIComponent component  = new MockUIComponent();
 
-    UIViewRoot uiRoot = new UIViewRoot();
-    uiRoot.setLocale(Locale.ENGLISH);
-    context.setupGetViewRoot(uiRoot);
+    facesContext.getViewRoot().setLocale(Locale.ENGLISH);
 
     TimeZone tz = TimeZone.getDefault();
     TimeZone.setDefault(getTzone("UTC"));
@@ -282,10 +270,10 @@
     GregorianCalendar gcal = new GregorianCalendar(getTzone("UTC"));
     gcal.set(2001,6,4,12,8,56);
 
-    MockUtils.setFacesContext(context);
+    MockUtils.setFacesContext(facesContext);
     try
     {
-      Date dt = (Date) dtConv.getAsObject(context, component, inputValue);
+      Date dt = (Date) dtConv.getAsObject(facesContext, component, inputValue);
       Date expectedDt = gcal.getTime();
       assertEquals(true, isEqual(dt, expectedDt));
     }
@@ -324,7 +312,6 @@
     for (int i = 0; i < patternBasedValues.length; i++)
     {
 
-      MockFacesContext context   = new MockFacesContext();
       MockUIComponent  component = new MockUIComponent();
 
       javax.faces.convert.DateTimeConverter fdtConv
@@ -339,20 +326,17 @@
       // locale is indeed picked up from the view root
       if (loc == null)
       {
-        UIViewRoot uiRoot = new UIViewRoot();
-        uiRoot.setLocale(Locale.GERMAN);
-        context.setupGetViewRoot(uiRoot);
-        context.setupGetViewRoot(uiRoot);
+        facesContext.getViewRoot().setLocale(Locale.GERMAN);
       }
 
-      MockUtils.setFacesContext(context);
+      MockUtils.setFacesContext(facesContext);
       try
       {
-        String fobtPattern = fdtConv.getAsString(context, component, date);
+        String fobtPattern = fdtConv.getAsString(facesContext, component, date);
         
         assertEquals(patternBasedValues[i][3], fobtPattern);
         
-        Date fdt = (Date)fdtConv.getAsObject(context, component, fobtPattern);
+        Date fdt = (Date)fdtConv.getAsObject(facesContext, component, fobtPattern);
         
         /**
          * @todo to find - why we get this millisecond difference
@@ -363,8 +347,6 @@
       {
         MockUtils.setFacesContext(null);
       }
-
-      context.verify();
       component.verify();
     }
   }
@@ -389,16 +371,15 @@
       // by default dateStyle is shortish and type is date
 
       javax.faces.convert.DateTimeConverter dtConv = getDateTimeConverter();
-      MockFacesContext context   = new MockFacesContext();
       MockUIComponent  component = new MockUIComponent();
 
       _setStyleOnConverter(dtConv, styleType, styles[i]);
 
       dtConv.setLocale(Locale.ENGLISH);
-      MockUtils.setFacesContext(context);
+      MockUtils.setFacesContext(facesContext);
       try
       {
-        String out =  dtConv.getAsString(context, component, dt);
+        String out =  dtConv.getAsString(facesContext, component, dt);
         assertEquals(true, (out != null));
       }
       finally
@@ -406,13 +387,11 @@
         MockUtils.setFacesContext(null);
       }
 
-      context.verify();
       component.verify();
 
-      MockFacesContext ctx   = new MockFacesContext();
       MockUIComponent  cmp   = new MockUIComponent();
 
-      MockUtils.setFacesContext(ctx);
+      MockUtils.setFacesContext(facesContext);
       try
       {
         try
@@ -420,7 +399,7 @@
           javax.faces.convert.DateTimeConverter extDtConv = getDateTimeConverter();
           extDtConv.setLocale(Locale.ENGLISH);
           _setStyleOnConverter(extDtConv, styleType, styles[i].toUpperCase());
-          String outPut = extDtConv.getAsString(context, component, dt);
+          String outPut = extDtConv.getAsString(facesContext, component, dt);
           fail("Upper case not accepted for styles");
         }
         catch (RuntimeException ce)
@@ -433,12 +412,10 @@
         MockUtils.setFacesContext(null);
       }
 
-      ctx.verify();
       cmp.verify();
     }
   }
 
-
   protected abstract javax.faces.convert.DateTimeConverter getDateTimeConverter();
 
   protected abstract void setSecondaryPattern(
@@ -726,59 +703,4 @@
   private static Date[]  _SEXPECTED_DATES
     = _getDates(_SLOCALES,_STIME_ZONES, _DAYS,_MONTHS, _YEARS, _HOURS, _MINS, _SECS);
 
-}
-
-
- /*
- public void testPrintValues()
- {
-   System.out.println("\n<TR>\n");
-   System.out.println("<TD>");System.out.print("Date Style\n");
-   System.out.println("<TD>");System.out.print("Locale\n");
-   System.out.println("<TD>");System.out.print("Pattern\n");
-   System.out.println("<TD>");System.out.print("TimeStyle\n");
-   System.out.println("<TD>");System.out.print("TimeZone\n");
-   System.out.println("<TD>");System.out.print("Type\n");
-   System.out.println("<TD>");System.out.print("SecondaryPattern\n");
-   System.out.println("<TD>");System.out.print("getAsObject()\n");
-   System.out.println("<TD>");System.out.print("getAsString()\n");
-   System.out.println("</TR>");
-   for (int i = 0; i < _DATE_STYLES.length; i++)
-   {
-      System.out.println("<TR>");
-      System.out.println("<TD>");
-      System.out.print(_DATE_STYLES[i]+"\n");
-      //System.out.print("\t");
-
-      System.out.print("<TD>");
-      System.out.print(_LOCALES[i]+"\n");
-      //System.out.print("\t");
-
-      System.out.println("<TD>");
-      System.out.print(_PATTERNS[i]+"\n");
-      //System.out.print("\t");
-
-      System.out.print("<TD>");
-      System.out.print(_TIME_STYLES[i]+"\n");
-      //System.out.print("\t");
-
-      System.out.print("<TD>");
-      System.out.print(_TIME_ZONES[i].getID()+"\n");
-      //System.out.print("\t");
-
-      System.out.print("<TD>");
-      System.out.print(_TYPES[i]+"\n");
-      //System.out.print("\t");
-
-      System.out.print("<TD>");
-      System.out.print(_SECONDARY_PATTERNS[i]+"\n");
-      //System.out.print("\t\n");
-      System.out.print("<TD>");
-      System.out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n");
-
-      System.out.print("<TD>");
-      System.out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n");
-      System.out.println("</TR>");
-
-   }  */
-
+}
\ 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/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=419080&r1=419079&r2=419080&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  4 13:04:03 2006
@@ -17,17 +17,36 @@
 
 import javax.faces.component.MockUIComponent;
 import javax.faces.component.StateHolder;
-import javax.faces.context.MockFacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.DateTimeConverter;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.shale.test.mock.MockFacesContext;
 
 public class JsfDateTimeConverterTest extends DateTimeConverterTestCase
 {
   public JsfDateTimeConverterTest(String name)
   {
     super(name);
-  }
-
+  }
+  
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(JsfDateTimeConverterTest.class);
+  }
+  
   protected void doTestStateHolderSaveRestore(
     Converter conv1,
     Converter conv2,
@@ -35,9 +54,9 @@
     MockUIComponent component
     )
   {
-    javax.faces.convert.DateTimeConverter dtConv1, dtConv2;
-    dtConv1 = (javax.faces.convert.DateTimeConverter)conv1;
-    dtConv2 = (javax.faces.convert.DateTimeConverter)conv2;
+    DateTimeConverter dtConv1, dtConv2;
+    dtConv1 = (DateTimeConverter)conv1;
+    dtConv2 = (DateTimeConverter)conv2;
 
     Object state = ((StateHolder)conv1).saveState(context);
 
@@ -46,7 +65,6 @@
     boolean isEqual =  _isConvertersEqual(dtConv1, dtConv2);
 
     assertEquals(true, isEqual);
-    context.verify();
     component.verify();
   }
 
@@ -56,21 +74,21 @@
     boolean expectedOutCome
     )
   {
-    javax.faces.convert.DateTimeConverter dtConv1, dtConv2;
-    dtConv1 = (javax.faces.convert.DateTimeConverter)conv1;
-    dtConv2 = (javax.faces.convert.DateTimeConverter)conv2;
+    DateTimeConverter dtConv1, dtConv2;
+    dtConv1 = (DateTimeConverter)conv1;
+    dtConv2 = (DateTimeConverter)conv2;
     boolean isEqual =  _isConvertersEqual(dtConv1, dtConv2);
     assertEquals(expectedOutCome, isEqual);
   }
 
   protected DateTimeConverter getDateTimeConverter()
   {
-    return new javax.faces.convert.DateTimeConverter();
+    return new DateTimeConverter();
   }
 
 
   protected void setSecondaryPattern(
-    javax.faces.convert.DateTimeConverter converter,
+    DateTimeConverter converter,
     String secondaryPattern
     )
   {
@@ -87,8 +105,8 @@
   }
 
   private boolean _isConvertersEqual(
-    javax.faces.convert.DateTimeConverter conv1,
-    javax.faces.convert.DateTimeConverter conv2
+    DateTimeConverter conv1,
+    DateTimeConverter conv2
     )
   {
     return
@@ -102,4 +120,4 @@
       );
   }
 
-}
+}
\ 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/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=419080&r1=419079&r2=419080&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  4 13:04:03 2006
@@ -21,9 +21,12 @@
 import javax.faces.component.StateHolder;
 import javax.faces.convert.Converter;
 import javax.faces.convert.NumberConverter;
-
 import javax.faces.component.MockUIComponent;
-import javax.faces.context.MockFacesContext;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.shale.test.mock.MockFacesContext;
 
 /**
  * Test JSF NumberConverter
@@ -37,6 +40,21 @@
     super(name);
   }
 
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(JsfNumberConverterTest.class);
+  }
+  
   protected NumberConverter getNumberConverter()
   {
     return new NumberConverter();
@@ -57,7 +75,6 @@
                                            (NumberConverter)conv2);
 
     assertEquals(true, isEqual);
-    context.verify();
     component.verify();
   }
 
@@ -109,4 +126,4 @@
      assertEquals(true, (obj != null));
   };
 
-}
+}
\ 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/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=419080&r1=419079&r2=419080&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  4 13:04:03 2006
@@ -17,17 +17,13 @@
 package org.apache.myfaces.adf.convert;
 import java.util.Locale;
 
-import javax.faces.component.UIViewRoot;
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.NumberConverter;
+import javax.faces.component.MockUIComponent;
 
 import org.apache.myfaces.adf.convert.ConverterTestCase;
 import org.apache.myfaces.adfbuild.test.MockUtils;
-
-import javax.faces.application.MockApplication;
-import javax.faces.component.MockUIComponent;
-import javax.faces.context.MockExternalContext;
-import javax.faces.context.MockFacesContext;
+import org.apache.shale.test.mock.MockFacesContext;
 
 /**
  * Test NumberConverter
@@ -46,7 +42,7 @@
    */
   public void testNullContext()
   {
-    MockUIComponent component    = new MockUIComponent();
+    MockUIComponent component = new MockUIComponent();
     NumberConverter converter = getNumberConverter();
 
     doTestNullContext(component, converter);
@@ -54,10 +50,9 @@
 
   public void testNullComponent()
   {
-    MockFacesContext context = new MockFacesContext();
     NumberConverter converter  = getNumberConverter();
 
-    doTestNullComponent(context, converter);
+    doTestNullComponent(facesContext, converter);
   }
 
   /**
@@ -67,12 +62,10 @@
    */
   public void testNullInputValue() throws ConverterException
   {
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = new MockUIComponent();
-
     NumberConverter converter  = getNumberConverter();
 
-    doTestNull(context, component, converter);
+    doTestNull(facesContext, component, converter);
   }
 
   public void testEmptyValueConversion()
@@ -82,31 +75,23 @@
 
   public void testValueType()
   {
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = new MockUIComponent();
-    UIViewRoot root = new UIViewRoot();
-    root.setLocale(Locale.US);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-
-    MockUtils.setFacesContext(context);
+    MockUtils.setFacesContext(facesContext);
     try
     {
       String input = "123";
       NumberConverter converter = getNumberConverter();
-      Object number = converter.getAsObject(context, component, input);
+      Object number = converter.getAsObject(facesContext, component, input);
       assertEquals(true, number instanceof Number);
       assertEquals(true, (((Number)number).intValue() == 123));
 
-      String outVal = converter.getAsString(context, component, number);
+      String outVal = converter.getAsString(facesContext, component, number);
       assertEquals(input, outVal);
     }
     finally
     {
       MockUtils.setFacesContext(null);
     }
-
-    context.verify();
     component.verify();
   }
 
@@ -130,20 +115,19 @@
 
     for (int i = 0; i < patterns.length; i++)
     {
-      MockFacesContext context  = new MockFacesContext();
       MockUIComponent component = new MockUIComponent();
       
-      MockUtils.setFacesContext(context);
+      MockUtils.setFacesContext(facesContext);
       try
       {
         nconv.setPattern(patterns[i]);
         nconv.setType(types[i]);
         nconv.setLocale(locales[i]);
         
-        Object convValue = nconv.getAsObject(context, component, inputValues[i]);
+        Object convValue = nconv.getAsObject(facesContext, component, inputValues[i]);
         assertEquals(expectedValues[i], convValue);
         
-        String outValue = nconv.getAsString(context, component, expectedValues[i]);
+        String outValue = nconv.getAsString(facesContext, component, expectedValues[i]);
         
         assertEquals(expectedStringValues[i], outValue);
       }
@@ -151,8 +135,6 @@
       {
         MockUtils.setFacesContext(null);
       }
-      
-      context.verify();
       component.verify();
     }
   }
@@ -160,58 +142,54 @@
   public void testStateHolderSaveRestore()
   {
     NumberConverter converter = getNumberConverter();
-    MockFacesContext context    = new MockFacesContext();
-    MockUIComponent component   = new MockUIComponent();
 
     NumberConverter restoreConverter = getNumberConverter();
-    MockFacesContext ctx = new MockFacesContext();
     MockUIComponent comp = new MockUIComponent();
 
     for (int i = 0; i < _LOCALES.length; i++)
     {
       converter.setLocale(_LOCALES[i]);
       restoreConverter.setLocale(_LOCALES[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, ctx, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
 
       converter.setCurrencyCode( _CURRENCY_CODES[i]);
       restoreConverter.setCurrencyCode( _CURRENCY_CODES[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, ctx, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
 
       converter.setCurrencySymbol(_CURRENCY_SYMBOLS[i]);
       restoreConverter.setCurrencySymbol(_CURRENCY_SYMBOLS[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, ctx, comp);
-
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
 
       converter.setIntegerOnly(_INTEGER_ONLY[1]);
       restoreConverter.setIntegerOnly(_INTEGER_ONLY[1]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, ctx, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
 
       converter.setMaxFractionDigits(_MAX_FRACTION_DIGITS[i]);
       restoreConverter.setMaxFractionDigits(_MAX_FRACTION_DIGITS[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, ctx, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
 
       converter.setMaxIntegerDigits(_MAX_INT_DIGITS[i]);
       restoreConverter.setMaxIntegerDigits(_MAX_INT_DIGITS[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, ctx, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
 
       converter.setMinFractionDigits(_MIN_FRACT_DIGITS[i]);
       restoreConverter.setMinFractionDigits(_MIN_FRACT_DIGITS[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, ctx, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
 
       converter.setMinIntegerDigits(_MIN_INT_DIGITS[i]);
       restoreConverter.setMinIntegerDigits(_MIN_INT_DIGITS[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, ctx, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
 
       converter.setPattern( _PATTTERNS[i]);
       restoreConverter.setPattern(_PATTTERNS[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, ctx, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
 
       converter.setTransient(_TRANSIENT[i]);
       restoreConverter.setTransient(_TRANSIENT[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, ctx, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
 
       converter.setType(_TYPES[i]);
-      doTestStateHolderSaveRestore(converter, restoreConverter, ctx, comp);
+      doTestStateHolderSaveRestore(converter, restoreConverter, facesContext, comp);
 
     }
   }
@@ -219,50 +197,43 @@
   public void testCurrencyCodeIsHonoured()
   {
     NumberConverter converter = getNumberConverter();
-    MockFacesContext context    = new MockFacesContext();
     MockUIComponent component   = new MockUIComponent();
     converter.setLocale(Locale.US);
     converter.setType("currency");
     Double  value = new Double(99);
 
-    MockUtils.setFacesContext(context);
+    MockUtils.setFacesContext(facesContext);
     try
     {
-      String outPut = converter.getAsString(context, component, value);
+      String outPut = converter.getAsString(facesContext, component, value);
       assertEquals("$99.00", outPut);
       //Locale is US. By general convention the output prefix would be '$'
       // since we set the currency code to 'DEM' value should be DEM[value]
       converter.setCurrencyCode("DEM");
       
-      outPut = converter.getAsString(context, component, value);
+      outPut = converter.getAsString(facesContext, component, value);
       assertEquals("DEM99.00", outPut);
     }
     finally
     {
       MockUtils.setFacesContext(null);
     }
-    context.verify();
     component.verify();
   }
 
   public void testCurrencyCodeIsHonouredWhenCurrencyCodeAndCurrencySymbolIsSet()
   {
     NumberConverter converter   = getNumberConverter();
-    MockFacesContext context    = new MockFacesContext();
-    MockApplication application = new MockApplication();
-    context.setupGetApplication(application);
-    application.setupGetMessageBundle(null);
-
     MockUIComponent component = MockUtils.buildMockUIComponent(2);
     
     converter.setLocale(Locale.US);
     converter.setType("currency");
-    Double  value = new Double(99);
+    Double value = new Double(99);
 
-    MockUtils.setFacesContext(context);
+    MockUtils.setFacesContext(facesContext);
     try
     {
-      String outPut = converter.getAsString(context, component, value);
+      String outPut = converter.getAsString(facesContext, component, value);
       assertEquals("$99.00", outPut);
       //Locale is US. By general convention the output prefix would be '$'
       // since we set the currency code to 'DEM' value should be DEM[value]
@@ -272,18 +243,11 @@
       // code is set.
       converter.setCurrencySymbol("*");
       
-      outPut = converter.getAsString(context, component, value);
+      outPut = converter.getAsString(facesContext, component, value);
       assertEquals("DEM99.00", outPut);
       try
       {
-        UIViewRoot root = new UIViewRoot();
-        root.setLocale(Locale.US);
-        context.setupGetViewRoot(root);
-        context.setupGetViewRoot(root);
-        MockExternalContext external = new MockExternalContext();
-        context.setupGetExternalContext(external);
-        
-        Number outValue = (Number)converter.getAsObject(context, component, "DEM99.00");
+        Number outValue = (Number)converter.getAsObject(facesContext, component, "DEM99.00");
         fail("Exception should occur - since currency should not be considered while formatting");
       }
       catch(Exception e)
@@ -295,15 +259,12 @@
     {
       MockUtils.setFacesContext(null);
     }
-
-    context.verify();
     component.verify();
   }
 
   public void testCurrencySymbolIsHonoured()
   {
     NumberConverter converter = getNumberConverter();
-    MockFacesContext context    = new MockFacesContext();
     MockUIComponent component   = new MockUIComponent();
     converter.setLocale(Locale.US);
     converter.setType("currency");
@@ -312,18 +273,16 @@
     // since we set currency symbol to '*' we should get the value to be *99.00
     converter.setCurrencySymbol("*");
     
-    MockUtils.setFacesContext(context);
+    MockUtils.setFacesContext(facesContext);
     try
     {
-      String outPut = converter.getAsString(context, component, value);
+      String outPut = converter.getAsString(facesContext, component, value);
       assertEquals("*99.00", outPut);
     }
     finally
     {
       MockUtils.setFacesContext(null);
     }
-
-    context.verify();
     component.verify();
   }
 
@@ -331,20 +290,19 @@
   {
     // integerOnly is used only while parsing to create number objects
     NumberConverter converter = getNumberConverter();
-    MockFacesContext context    = new MockFacesContext();
     MockUIComponent component   = new MockUIComponent();
     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(context);
+    MockUtils.setFacesContext(facesContext);
     try
     {
       for (int i = 0; i < inputs.length; i++)
       {
         converter.setIntegerOnly(true);
-        Number num = (Number) converter.getAsObject(context, component, inputs[i]);
+        Number num = (Number) converter.getAsObject(facesContext, component, inputs[i]);
         assertEquals(expectedValues[i], num);
       }
     }
@@ -352,8 +310,6 @@
     {
       MockUtils.setFacesContext(null);
     }
-
-    context.verify();
     component.verify();
   }
 
@@ -362,14 +318,13 @@
   {
     // integerOnly is used only while parsing to create number objects
     NumberConverter converter = getNumberConverter();
-    MockFacesContext context    = new MockFacesContext();
     MockUIComponent component   = new MockUIComponent();
     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(context);
+    MockUtils.setFacesContext(facesContext);
     try
     {
       for (int i = 0; i < inputs.length; i++)
@@ -382,7 +337,7 @@
         
         // this should be taken care by the parsing code
         converter.setIntegerOnly(true);
-        Number num = (Number) converter.getAsObject(context, component, inputs[i]);
+        Number num = (Number) converter.getAsObject(facesContext, component, inputs[i]);
         assertEquals(expectedValues[i], num);
       }
     }
@@ -390,8 +345,6 @@
     {
       MockUtils.setFacesContext(null);
     }
-
-    context.verify();
     component.verify();
   }
 
@@ -399,22 +352,18 @@
   {
 
     NumberConverter converter = getNumberConverter();
-    MockFacesContext context    = new MockFacesContext();
     MockUIComponent component   = new MockUIComponent();
 
-    UIViewRoot root = new UIViewRoot();
-    root.setLocale(Locale.US);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
+    facesContext.getViewRoot().setLocale(Locale.US);
 
     String input = "1234.56";
 
-    MockUtils.setFacesContext(context);
+    MockUtils.setFacesContext(facesContext);
     try
     {
       // if we get a valid object, implies locale was indeed picked up.
       // otherwise we would have got a null pointer exception or other exception
-      Object value = converter.getAsObject(context, component, input);
+      Object value = converter.getAsObject(facesContext, component, input);
       assertEquals(new Double(1234.56), value);
     }
     finally
@@ -430,16 +379,15 @@
     String[] expectedValues = {"9,999", "99", "0.99", "99999.567", "9999"};
 
     NumberConverter converter = getNumberConverter();
-    MockFacesContext context    = new MockFacesContext();
     MockUIComponent component   = new MockUIComponent();
     converter.setLocale(Locale.US);
-    MockUtils.setFacesContext(context);
+    MockUtils.setFacesContext(facesContext);
     try
     {
       for (int i = 0; i < inputValues.length; i++)
       {
         converter.setGroupingUsed(isGroupingUsed[i]);
-        String out = converter.getAsString(context, component, inputValues[i]);
+        String out = converter.getAsString(facesContext, component, inputValues[i]);
         assertEquals(expectedValues[i], out);
       }
     }
@@ -447,23 +395,19 @@
     {
       MockUtils.setFacesContext(null);
     }
-
-    context.verify();
     component.verify();
   }
 
   public void testStrictnessOfConversion()
   {
     String[] inputValues = {"123ABC", "22.22.2" };
-    MockFacesContext context    = new MockFacesContext();
     MockUIComponent component
       = MockUtils.buildMockUIComponent(inputValues.length * 3);
 
     for (int i = 0; i < inputValues.length; i++)
     {
-      doTestStrictNess(context, component, Locale.US, inputValues[i]);
+      doTestStrictNess(facesContext, component, Locale.US, inputValues[i]);
     }
-    context.verify();
     component.verify();
   }
 
@@ -478,10 +422,9 @@
     int[] minFractDigits = {0, 2, 0, 2};
 
     NumberConverter converter   = getNumberConverter();
-    MockFacesContext context    = new MockFacesContext();
     MockUIComponent component   = new MockUIComponent();
 
-    MockUtils.setFacesContext(context);
+    MockUtils.setFacesContext(facesContext);
     try
     {
       converter.setLocale(Locale.US);
@@ -492,7 +435,7 @@
         converter.setMinFractionDigits(minFractDigits[i]);
         converter.setMinIntegerDigits(minIntDigits[i]);
         
-        String out = converter.getAsString(context, component, inputValues[i]);
+        String out = converter.getAsString(facesContext, component, inputValues[i]);
         assertEquals(expectedValues[i], out);   
       }
     }
@@ -500,7 +443,6 @@
     {
       MockUtils.setFacesContext(null);
     }
-    context.verify();
     component.verify();
   }
 
@@ -576,4 +518,4 @@
 // Pattern             tested
 // Type                tested
 // GroupingUsed        tested
-// IntegerOnly         tested   // only while parsing
+// IntegerOnly         tested   // only while parsing
\ 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/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=419080&r1=419079&r2=419080&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  4 13:04:03 2006
@@ -15,16 +15,15 @@
  */
 package org.apache.myfaces.adf.validator;
 
-import java.util.Locale;
 
-import javax.faces.component.UIViewRoot;
 import javax.faces.validator.ValidatorException;
 
 import org.apache.myfaces.adfbuild.test.MockUtils;
 
 import javax.faces.component.MockUIComponent;
-import javax.faces.context.MockFacesContext;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 /**
  * Unit tests for ByteLengthValidator
@@ -38,6 +37,21 @@
     super(testName);
   }
 
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(ByteLengthValidatorTest.class);
+  }
+  
   /**
    * Tests that null returns immediately.
    *
@@ -45,10 +59,9 @@
    */
   public void testNull() throws ValidatorException
   {
-    MockFacesContext context = new MockFacesContext();
     MockUIComponent component = MockUtils.buildMockUIComponent();
     ByteLengthValidator validator = new ByteLengthValidator();
-    doTestNull(context, component, validator);
+    doTestNull(facesContext, component, validator);
   }
 
   /**
@@ -67,9 +80,8 @@
   */
   public void testNullComponent()
   {
-    MockFacesContext context      = new MockFacesContext();
     ByteLengthValidator validator = new ByteLengthValidator();
-    doTestNullComponent(context, validator);
+    doTestNullComponent(facesContext, validator);
   }
 
   /**
@@ -86,7 +98,6 @@
   public void testSanitySuccess()
   {
 
-    MockFacesContext context      = new MockFacesContext();
     ByteLengthValidator validator = new ByteLengthValidator();
     //some very basic sanity test
     String values[]    = {"four"};
@@ -99,18 +110,17 @@
     {
       validator.setEncoding(encodings[i]);
       validator.setMaximum(maxBytes[i]);
-      doTestValidate(validator, context, component, values[i]);
+      doTestValidate(validator, facesContext, component, values[i]);
     }
   }
 
   public void testDefaultEncodingWorks()
   {
-    MockFacesContext context      = new MockFacesContext();
     MockUIComponent component = MockUtils.buildMockUIComponent();
     ByteLengthValidator validator = new ByteLengthValidator();
     String value = "four";
     validator.setMaximum(4);
-    doTestValidate(validator, context, component, value);
+    doTestValidate(validator, facesContext, component, value);
   }
 
   /**
@@ -118,7 +128,6 @@
    */
   public void testStateHolderSaveRestore()
   {
-    MockFacesContext context = new MockFacesContext();
     MockUIComponent component = MockUtils.buildMockUIComponent();
     ByteLengthValidator validator = new ByteLengthValidator();
     validator.setEncoding("ISO-8859-1");
@@ -127,7 +136,7 @@
     ByteLengthValidator restoreValidator = new  ByteLengthValidator();
 
     doTestStateHolderSaveRestore(validator, restoreValidator,
-                                 context, component);
+                                 facesContext, component);
   }
 
   /**
@@ -165,13 +174,7 @@
 
   public void testCustomMessageIsSet()
   {
-    MockFacesContext context = new MockFacesContext();
     MockUIComponent component = MockUtils.buildMockUIComponent();
-    UIViewRoot root = new UIViewRoot();
-    Locale usLoc =  Locale.US;
-    root.setLocale(usLoc);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
     setMockLabelForComponent(component);
     ByteLengthValidator validator = new ByteLengthValidator();
     int maxBytes[]     = {3};
@@ -186,7 +189,7 @@
     {
       validator.setMaximum(maxBytes[0]);
       validator.setEncoding(encodings[0]);
-      validator.validate(context, component, values[0]);
+      validator.validate(facesContext, component, values[0]);
     }
     catch (ValidatorException ve)
     {
@@ -196,4 +199,4 @@
   }
   private static final String _IS_GREATER
     = " exceeds maximum allowed length of ";
-}
+}
\ 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/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=419080&r1=419079&r2=419080&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  4 13:04:03 2006
@@ -16,17 +16,16 @@
 package org.apache.myfaces.adf.validator;
 
 import java.util.Date;
-import java.util.Locale;
 
-import javax.faces.component.UIViewRoot;
 import javax.faces.convert.DateTimeConverter;
 import javax.faces.validator.ValidatorException;
-
-import javax.faces.application.MockApplication;
 import javax.faces.component.MockUIComponent;
-import javax.faces.context.MockFacesContext;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 import org.apache.myfaces.adfbuild.test.MockUtils;
+import org.apache.shale.test.mock.MockApplication;
 
 /**
  * Unit tests for DateTimeRangeValidator.
@@ -45,6 +44,21 @@
   {
     super(testName);
   }
+  
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(DateTimeRangeValidatorTest.class);
+  }
 
   /**
    * Tests that null returns immediately.
@@ -55,9 +69,8 @@
   {
     DateTimeRangeValidator validator = new DateTimeRangeValidator();
 
-    MockFacesContext context   = new MockFacesContext();
     MockUIComponent  component = MockUtils.buildMockUIComponent();
-    doTestNull(context, component, validator);
+    doTestNull(facesContext, component, validator);
   }
 
    /**
@@ -76,10 +89,9 @@
    */
   public void testNullComponent()
   {
-    MockFacesContext context  = new MockFacesContext();
     RegExpValidator validator = new RegExpValidator();
 
-    doTestNullComponent(context, validator);
+    doTestNullComponent(facesContext, validator);
   }
 
   /**
@@ -89,19 +101,13 @@
   {
     DateTimeRangeValidator validator = new DateTimeRangeValidator();
 
-    MockFacesContext context   = new MockFacesContext();
     MockUIComponent  component = MockUtils.buildMockUIComponent();
 
-    UIViewRoot root   = new UIViewRoot();
-    Locale mockLocale = new Locale("xx", "MOCK");
-    root.setLocale(mockLocale);
     component.setupGetId("test");
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
     try
     {
-      MockUtils.setFacesContext(context);
-      validator.validate(context, component, "not-a-date");
+      MockUtils.setFacesContext(facesContext);
+      validator.validate(facesContext, component, "not-a-date");
       fail("ValidatorException not thrown");
     }
     catch (IllegalArgumentException iae)
@@ -112,8 +118,6 @@
     {
       MockUtils.setFacesContext(null);
     }
-
-    context.verify();
     component.verify();
   }
 
@@ -128,33 +132,24 @@
     DateTimeRangeValidator validator = new DateTimeRangeValidator();
     validator.setMaximum(new Date(millis));
 
-    MockFacesContext context   = new MockFacesContext();
     MockUIComponent  component = MockUtils.buildMockUIComponent();
 
-    UIViewRoot root   = new UIViewRoot();
-    Locale mockLocale = new Locale("xx", "MOCK");
-    root.setLocale(mockLocale);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-
     try
     {
-      MockUtils.setFacesContext(context);
-      validator.validate(context, component, new Date(millis - 1));
+      MockUtils.setFacesContext(facesContext);
+      validator.validate(facesContext, component, new Date(millis - 1));
     }
     finally
     {
       MockUtils.setFacesContext(null);
     }
-
-    context.verify();
     component.verify();
   }
 
   protected void setMockCreateConverter(MockApplication app)
   {
     DateTimeConverter dtc = new DateTimeConverter();
-    app.setupCreateConverterString(dtc);
+    app.addConverter(DateTimeConverter.CONVERTER_ID, dtc.getClass().getName());
   }
 
   /**
@@ -166,27 +161,15 @@
     DateTimeRangeValidator validator = new DateTimeRangeValidator();
     validator.setMaximum(new Date(millis));
 
-    MockFacesContext context   = new MockFacesContext();
     MockUIComponent component = MockUtils.buildMockUIComponent(4);
-
     setMockLabelForComponent(component);
 
-    UIViewRoot root   = new UIViewRoot();
-    Locale mockLocale = new Locale("xx", "MOCK");
-
-    root.setLocale(mockLocale);
-    for (int i = 0; i < 4; i++)
-      context.setupGetViewRoot(root);
-
-    MockApplication  app      = new MockApplication();
-    setMockCreateConverter(app);
-    context.setupGetApplication(app);
-
+    setMockCreateConverter(application);
     try
     {
-      MockUtils.setFacesContext(context);
+      MockUtils.setFacesContext(facesContext);
       validator.setMaximumMessageDetail("max set");
-      validator.validate(context, component, new Date(millis + 1));
+      validator.validate(facesContext, component, new Date(millis + 1));
       fail("ValidatorException not thrown");
     }
     catch (ValidatorException e)
@@ -200,7 +183,6 @@
       MockUtils.setFacesContext(null);
     }
 
-    context.verify();
     component.verify();
   }
 
@@ -215,12 +197,10 @@
     DateTimeRangeValidator validator = new DateTimeRangeValidator();
     validator.setMinimum(new Date(millis));
 
-    MockFacesContext context   = new MockFacesContext();
     MockUIComponent  component = MockUtils.buildMockUIComponent();
 
-    validator.validate(context, component, new Date(millis + 1));
+    validator.validate(facesContext, component, new Date(millis + 1));
 
-    context.verify();
     component.verify();
   }
 
@@ -233,28 +213,17 @@
     DateTimeRangeValidator validator = new DateTimeRangeValidator();
     validator.setMinimum(new Date(millis));
 
-    MockFacesContext context   = new MockFacesContext();
     MockUIComponent  component = MockUtils.buildMockUIComponent();
 
     setMockLabelForComponent(component);
-    UIViewRoot root   = new UIViewRoot();
-    Locale mockLocale = new Locale("xx", "MOCK");
-
-    root.setLocale(mockLocale);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-
-    MockApplication  app      = new MockApplication();
-    setMockCreateConverter(app);
-    context.setupGetApplication(app);
+    
+    setMockCreateConverter(application);
 
     try
     {
-      MockUtils.setFacesContext(context);
+      MockUtils.setFacesContext(facesContext);
       validator.setMinimumMessageDetail("min set");
-      validator.validate(context, component, new Date(millis - 1));
+      validator.validate(facesContext, component, new Date(millis - 1));
       fail("ValidatorException not thrown");
     }
     catch (ValidatorException e)
@@ -268,7 +237,6 @@
       MockUtils.setFacesContext(null);
     }
 
-    context.verify();
     component.verify();
   }
 
@@ -284,21 +252,18 @@
     validator.setMinimum(new Date(millis));
     validator.setMaximum(new Date(millis + 2));
 
-    MockFacesContext context = new MockFacesContext();
     MockUIComponent  component = MockUtils.buildMockUIComponent();
 
-
     try
     {
-      MockUtils.setFacesContext(context);
-      validator.validate(context, component, new Date(millis + 1));
+      MockUtils.setFacesContext(facesContext);
+      validator.validate(facesContext, component, new Date(millis + 1));
     }
     finally
     {
       MockUtils.setFacesContext(null);
     }
 
-    context.verify();
     component.verify();
   }
 
@@ -312,28 +277,17 @@
     validator.setMinimum(new Date(millis));
     validator.setMaximum(new Date(millis + 10));
 
-    MockFacesContext context = new MockFacesContext();
     MockUIComponent  component = MockUtils.buildMockUIComponent();
 
     setMockLabelForComponent(component);
-    UIViewRoot root = new UIViewRoot();
-    Locale mockLocale = new Locale("xx", "MOCK");
-    root.setLocale(mockLocale);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-
-    MockApplication  app      = new MockApplication();
-    setMockCreateConverter(app);
-    context.setupGetApplication(app);
+
+    setMockCreateConverter(application);
 
     try
     {
-      MockUtils.setFacesContext(context);
+      MockUtils.setFacesContext(facesContext);
       validator.setMinimumMessageDetail("min");
-      validator.validate(context, component, new Date(millis - 1));
+      validator.validate(facesContext, component, new Date(millis - 1));
       fail("ValidatorException not thrown");
     }
     catch (ValidatorException e)
@@ -346,7 +300,6 @@
       MockUtils.setFacesContext(null);
     }
 
-    context.verify();
     component.verify();
   }
 
@@ -360,28 +313,16 @@
     validator.setMinimum(new Date(millis));
     validator.setMaximum(new Date(millis + 10));
 
-    MockFacesContext context = new MockFacesContext();
     MockUIComponent  component = MockUtils.buildMockUIComponent();
     setMockLabelForComponent(component);
 
-    UIViewRoot root = new UIViewRoot();
-    Locale mockLocale = new Locale("xx", "MOCK");
-    root.setLocale(mockLocale);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
-
-    MockApplication  app      = new MockApplication();
-    setMockCreateConverter(app);
-    context.setupGetApplication(app);
+    setMockCreateConverter(application);
 
     try
     {
-      MockUtils.setFacesContext(context);
+      MockUtils.setFacesContext(facesContext);
       validator.setNotInRangeMessageDetail("not in range is set");
-      validator.validate(context, component, new Date(millis + 20));
+      validator.validate(facesContext, component, new Date(millis + 20));
       fail("ValidatorException not thrown");
     }
     catch (ValidatorException e)
@@ -395,7 +336,6 @@
       MockUtils.setFacesContext(null);
     }
 
-    context.verify();
     component.verify();
   }
 
@@ -414,15 +354,12 @@
     originalValidator.setMaximumMessageDetail("max");
     originalValidator.setNotInRangeMessageDetail("not in range");
 
-    MockFacesContext context   = new MockFacesContext();
     MockUIComponent  component = MockUtils.buildMockUIComponent();
 
-    Object state = originalValidator.saveState(context);
-
     DateTimeRangeValidator restoredValidator = new DateTimeRangeValidator();
 
     doTestStateHolderSaveRestore(originalValidator, restoredValidator,
-                                 context, component);
+                                 facesContext, component);
   }
 
-}
+}
\ 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/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=419080&r1=419079&r2=419080&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  4 13:04:03 2006
@@ -15,16 +15,14 @@
  */
 
 package org.apache.myfaces.adf.validator;
-import java.util.Locale;
 
-import javax.faces.component.UIViewRoot;
 import javax.faces.validator.ValidatorException;
-
-import org.apache.myfaces.adf.validator.RegExpValidator;
-
 import javax.faces.component.MockUIComponent;
-import javax.faces.context.MockFacesContext;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.adf.validator.RegExpValidator;
 import org.apache.myfaces.adfbuild.test.MockUtils;
 
 /**
@@ -38,6 +36,21 @@
   {
     super(testName);
   }
+  
+  public void setUp()
+  {
+    super.setUp();
+  }
+  
+  public void tearDown()
+  {
+    super.tearDown();
+  }
+  
+  public static Test suite()
+  {
+    return new TestSuite(RegExpValidatorTest.class);
+  }
 
   /**
    * Tests that null returns immediately.
@@ -46,11 +59,10 @@
    */
   public void testNull() throws ValidatorException
   {
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = MockUtils.buildMockUIComponent();
     RegExpValidator validator = new RegExpValidator();
 
-    doTestNull(context, component, validator);
+    doTestNull(facesContext, component, validator);
   }
 
   /**
@@ -66,10 +78,9 @@
 
   public void testNullComponent()
   {
-    MockFacesContext context  = new MockFacesContext();
     RegExpValidator validator = new RegExpValidator();
 
-    doTestNullComponent(context, validator);
+    doTestNullComponent(facesContext, validator);
   }
 
   /**
@@ -87,13 +98,12 @@
   {
     // since the pattern has not been set it will be null
     // let us push some arbitary value
-    MockFacesContext context   = new MockFacesContext();
     MockUIComponent component = MockUtils.buildMockUIComponent();
 
     try
     {
       RegExpValidator validator = new RegExpValidator();
-      validator.validate(context, component, "someValue");
+      validator.validate(facesContext, component, "someValue");
       // test fails if it is here
 
       fail("Expected Null pointer exception");
@@ -102,7 +112,6 @@
     {
       // suppress it - this is as expected
     }
-    context.verify();
     component.verify();
   }
 
@@ -112,21 +121,15 @@
   public void testBlankValueOnPattern()
   {
     // some very basic sanity test
-    MockFacesContext context   = new MockFacesContext();
     MockUIComponent component = MockUtils.buildMockUIComponent();
     setMockLabelForComponent(component);
-    UIViewRoot root = new UIViewRoot();
-    Locale mockLocale = new Locale("xx", "MOCK");
-    root.setLocale(mockLocale);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
 
     try
     {
       RegExpValidator validator = new RegExpValidator();
       String value = "999999";
       validator.setPattern("");
-      validator.validate(context, component, value);
+      validator.validate(facesContext, component, value);
       fail("Expected ValidatorException");
     }
     catch (ValidatorException ve)
@@ -134,7 +137,6 @@
       // if exception then fine.
     }
 
-    context.verify();
     component.verify();
   }
 
@@ -149,7 +151,6 @@
     //some very basic sanity test
     //
     RegExpValidator validator = new RegExpValidator();
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = MockUtils.buildMockUIComponent();
 
     String values[]   = {"9123456","9x"};
@@ -157,7 +158,7 @@
     for (int i = 0; i < values.length ; i++)
     {
       validator.setPattern(patterns[i]);
-      doTestValidate(validator, context, component, values[i]);
+      doTestValidate(validator, facesContext, component, values[i]);
     }
   }
 
@@ -167,7 +168,6 @@
   public void testStateHolderSaveRestore()
   {
     RegExpValidator validator = new RegExpValidator();
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = MockUtils.buildMockUIComponent();
 
     validator.setPattern("TestSaveRestore");
@@ -175,7 +175,7 @@
     RegExpValidator restoreValidator = new  RegExpValidator();
 
     doTestStateHolderSaveRestore(validator, restoreValidator,
-                                 context, component);
+                                 facesContext, component);
   }
 
   /**
@@ -184,8 +184,6 @@
   public void testIsEqual()
   {
     RegExpValidator validator = new RegExpValidator();
-    MockFacesContext context  = new MockFacesContext();
-    MockUIComponent component = MockUtils.buildMockUIComponent();
     RegExpValidator otherValidator = new RegExpValidator();
     doTestEquals(validator, otherValidator, true);
     assertEquals(validator.hashCode(), otherValidator.hashCode());
@@ -204,13 +202,7 @@
 
   public void testCustomMessageIsSet()
   {
-    MockFacesContext context      = new MockFacesContext();
     MockUIComponent component     = MockUtils.buildMockUIComponent();
-    UIViewRoot root = new UIViewRoot();
-    Locale usLoc =  Locale.US;
-    root.setLocale(usLoc);
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
     setMockLabelForComponent(component);
     RegExpValidator validator = new RegExpValidator();
 
@@ -220,7 +212,7 @@
 
     try
     {
-      validator.validate(context, component, "9123456");
+      validator.validate(facesContext, component, "9123456");
     }
     catch (ValidatorException ve)
     {
@@ -237,4 +229,4 @@
   // 3. specify the behaviour of the Mock Object (record state)
   // 4. activate the MockObject via the control  (replay state)
   //
-  //////////////////////////////////////////////////////////////////////////////
+  //////////////////////////////////////////////////////////////////////////////
\ 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/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=419080&r1=419079&r2=419080&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  4 13:04:03 2006
@@ -15,26 +15,24 @@
  */
 
 package org.apache.myfaces.adf.validator;
-import java.util.HashMap;
-import java.util.Locale;
 
+import java.util.HashMap;
 import java.util.Map;
+
 import javax.faces.component.StateHolder;
-import javax.faces.component.UIViewRoot;
 import javax.faces.validator.Validator;
 import javax.faces.validator.ValidatorException;
-
-import junit.framework.TestCase;
-
 import javax.faces.component.MockUIComponent;
-import javax.faces.context.MockFacesContext;
+
+import org.apache.shale.test.base.AbstractJsfTestCase;
+import org.apache.shale.test.mock.MockFacesContext;
 
 /**
  * Base class for unit tests for Validators
  *
  * @author vijay venkatarman
  */
-public abstract class ValidatorTestCase extends TestCase
+public abstract class ValidatorTestCase extends AbstractJsfTestCase
 {
   public ValidatorTestCase(String testName)
   {
@@ -61,7 +59,6 @@
   {
     validator.validate(context, component, null);
 
-    context.verify();
     component.verify();
   }
 
@@ -115,7 +112,6 @@
     )  throws ValidatorException
   {
     validator.validate(context, component, value );
-    context.verify();
     component.verify();
   }
 
@@ -152,24 +148,17 @@
     ((StateHolder)otherValidator).restoreState(context, state);
     // do all actions of save and restore
     doTestEquals(thisValidator, otherValidator, true);
-    context.verify();
     component.verify();
   }
 
   public void doTestIsNotString(Validator validator)
   {
-    MockFacesContext context  = new MockFacesContext();
     MockUIComponent component = new MockUIComponent();
 
-    UIViewRoot root = new UIViewRoot();
-    Locale mockLocale = new Locale("xx", "MOCK");
-    root.setLocale(mockLocale);
     component.setupGetId("test");
-    context.setupGetViewRoot(root);
-    context.setupGetViewRoot(root);
     try
     {
-      validator.validate(context, component, new Integer(1));
+      validator.validate(facesContext, component, new Integer(1));
       // if exception is not thrown - mark it as an failure
       fail("Expected Validator Exception");
     }
@@ -187,4 +176,4 @@
   // 3. specify the behaviour of the Mock Object (record state)
   // 4. activate the MockObject via the control  (replay state)
   //
-  //////////////////////////////////////////////////////////////////////////////
+  //////////////////////////////////////////////////////////////////////////////
\ No newline at end of file



Mime
View raw message