You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2006/02/20 06:37:27 UTC

svn commit: r379029 - in /myfaces/core/trunk/api/src/test/java/javax/faces: component/UISelectManyTest.java convert/DateTimeConverterTest.java

Author: dennisbyrne
Date: Sun Feb 19 21:37:24 2006
New Revision: 379029

URL: http://svn.apache.org/viewcvs?rev=379029&view=rev
Log:
refactored tests that were choking on previously set ThreadLocal FC
'mvn -Dmaven.test.failure.ignore=false test' now works

Modified:
    myfaces/core/trunk/api/src/test/java/javax/faces/component/UISelectManyTest.java
    myfaces/core/trunk/api/src/test/java/javax/faces/convert/DateTimeConverterTest.java

Modified: myfaces/core/trunk/api/src/test/java/javax/faces/component/UISelectManyTest.java
URL: http://svn.apache.org/viewcvs/myfaces/core/trunk/api/src/test/java/javax/faces/component/UISelectManyTest.java?rev=379029&r1=379028&r2=379029&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/test/java/javax/faces/component/UISelectManyTest.java (original)
+++ myfaces/core/trunk/api/src/test/java/javax/faces/component/UISelectManyTest.java Sun Feb 19 21:37:24 2006
@@ -20,27 +20,23 @@
 import java.util.List;
 import java.util.Locale;
 
-import org.apache.myfaces.AbstractTestCase;
-import org.apache.myfaces.mock.api.MockFacesContext;
-import org.apache.shale.test.mock.MockApplication;
+import org.apache.shale.test.base.AbstractJsfTestCase;
 
-import javax.faces.component.UIViewRoot;
+import junit.framework.Test;
 
-public class UISelectManyTest extends AbstractTestCase {
+public class UISelectManyTest extends AbstractJsfTestCase {
 
   public UISelectManyTest(String name) {
     super(name);
   }
 
+  public static Test suite() {
+      return null; // keep this method or maven won't run it
+  }
   
   public void testValidateRequiredNull() {
-    UIViewRoot view = new UIViewRoot();
-    view.setLocale(_TEST_LOCALE);
 
-    MockApplication application = new MockApplication();
-    MockFacesContext context = new MockFacesContext();
-    context.setViewRoot(view);
-    context.setApplication(application);
+    facesContext.getViewRoot().setLocale(_TEST_LOCALE);
 
     UISelectMany selectMany = new UISelectMany();
     selectMany.setId("selectMany");
@@ -60,19 +56,14 @@
     three.setItemValue(new Integer(3));
     children.add(three);
 
-    selectMany.validateValue(context, null);
+    selectMany.validateValue(facesContext, null);
 
     assertFalse(selectMany.isValid());
   }
 
   public void testValidateRequiredEmptyList() {
-    UIViewRoot view = new UIViewRoot();
-    view.setLocale(_TEST_LOCALE);
-
-    MockApplication application = new MockApplication();
-    MockFacesContext context = new MockFacesContext();
-    context.setViewRoot(view);
-    context.setApplication(application);
+    
+    facesContext.getViewRoot().setLocale(_TEST_LOCALE);
 
     UISelectMany selectMany = new UISelectMany();
     selectMany.setId("selectMany");
@@ -92,21 +83,15 @@
     three.setItemValue(new Integer(3));
     children.add(three);
 
-    selectMany.validateValue(context, Collections.EMPTY_LIST);
+    selectMany.validateValue(facesContext, Collections.EMPTY_LIST);
 
     assertFalse(selectMany.isValid());
   }
 
   public void testValidateIntArray() {
-    UIViewRoot view = new UIViewRoot();
-    view.setLocale(_TEST_LOCALE);
-
-    MockApplication application = new MockApplication();
-
-    MockFacesContext context = new MockFacesContext();
-    context.setViewRoot(view);
-    context.setApplication(application);
-
+    
+	facesContext.getViewRoot().setLocale(_TEST_LOCALE);
+	  
     UISelectMany selectMany = new UISelectMany();
     selectMany.setId("selectMany");
     selectMany.setRendererType(null);
@@ -124,20 +109,14 @@
     three.setItemValue(new Integer(3));
     children.add(three);
 
-    selectMany.validateValue(context, new int[] { 2, 3 });
+    selectMany.validateValue(facesContext, new int[] { 2, 3 });
 
     assertTrue(selectMany.isValid());
   }
 
   public void testValidateStringArray() {
-    UIViewRoot view = new UIViewRoot();
-    view.setLocale(_TEST_LOCALE);
-
-    MockApplication application = new MockApplication();
 
-    MockFacesContext context = new MockFacesContext();
-    context.setViewRoot(view);
-    context.setApplication(application);
+	facesContext.getViewRoot().setLocale(_TEST_LOCALE);
 
     UISelectMany selectMany = new UISelectMany();
     selectMany.setId("selectMany");
@@ -156,21 +135,15 @@
     three.setItemValue("3");
     children.add(three);
 
-    selectMany.validateValue(context, new String[] { "2", "3" });
+    selectMany.validateValue(facesContext, new String[] { "2", "3" });
 
     assertTrue(selectMany.isValid());
   }
 
   public void testValidateStringList() {
-    UIViewRoot view = new UIViewRoot();
-    view.setLocale(_TEST_LOCALE);
-
-    MockApplication application = new MockApplication();
-
-    MockFacesContext context = new MockFacesContext();
-    context.setViewRoot(view);
-    context.setApplication(application);
 
+	facesContext.getViewRoot().setLocale(_TEST_LOCALE);
+	  
     UISelectMany selectMany = new UISelectMany();
     selectMany.setId("selectMany");
     selectMany.setRendererType(null);
@@ -188,7 +161,7 @@
     three.setItemValue("3");
     children.add(three);
 
-    selectMany.validateValue(context, Arrays.asList(new String[] { "2", "3" }));
+    selectMany.validateValue(facesContext, Arrays.asList(new String[] { "2", "3" }));
 
     assertTrue(selectMany.isValid());
   }

Modified: myfaces/core/trunk/api/src/test/java/javax/faces/convert/DateTimeConverterTest.java
URL: http://svn.apache.org/viewcvs/myfaces/core/trunk/api/src/test/java/javax/faces/convert/DateTimeConverterTest.java?rev=379029&r1=379028&r2=379029&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/test/java/javax/faces/convert/DateTimeConverterTest.java (original)
+++ myfaces/core/trunk/api/src/test/java/javax/faces/convert/DateTimeConverterTest.java Sun Feb 19 21:37:24 2006
@@ -16,8 +16,7 @@
 
 package javax.faces.convert;
 
-import org.apache.myfaces.AbstractTestCase;
-import org.apache.myfaces.mock.api.MockFacesContext;
+import org.apache.shale.test.base.AbstractJsfTestCase;
 
 import javax.faces.component.UIInput;
 import javax.faces.context.FacesContext;
@@ -25,7 +24,9 @@
 import java.util.TimeZone;
 import java.text.SimpleDateFormat;
 
-public class DateTimeConverterTest extends AbstractTestCase
+import junit.framework.Test;
+
+public class DateTimeConverterTest extends AbstractJsfTestCase
 {
     private DateTimeConverter mock;
 
@@ -34,22 +35,25 @@
         junit.textui.TestRunner.run(DateTimeConverterTest.class);
     }
 
+    public static Test suite() {
+        return null; // keep this method or maven won't run it
+    }
+    
     public DateTimeConverterTest(String name)
     {
         super(name);
     }
 
-    protected void setUp() throws Exception
+    public void setUp()
     {
         super.setUp();
 
         mock = new DateTimeConverter();
         mock.setTimeZone(TimeZone.getDefault());
 
-        new MockFacesContext();
     }
 
-    protected void tearDown() throws Exception
+    public void tearDown()
     {
         super.tearDown();