You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/07/01 22:42:38 UTC
svn commit: r959777 - in /myfaces/core/trunk: api/
api/src/test/java/javax/faces/ api/src/test/java/javax/faces/application/
api/src/test/java/javax/faces/component/ impl/
impl/src/test/java/org/apache/myfaces/application/
impl/src/test/java/org/apache...
Author: lu4242
Date: Thu Jul 1 20:42:37 2010
New Revision: 959777
URL: http://svn.apache.org/viewvc?rev=959777&view=rev
Log:
MYFACESTEST-14 Update myfaces-test to use JUnit 4.x
Modified:
myfaces/core/trunk/api/ (props changed)
myfaces/core/trunk/api/pom.xml
myfaces/core/trunk/api/src/test/java/javax/faces/FacesExceptionTest.java
myfaces/core/trunk/api/src/test/java/javax/faces/FactoryFinderTest.java
myfaces/core/trunk/api/src/test/java/javax/faces/application/ApplicationTest.java
myfaces/core/trunk/api/src/test/java/javax/faces/component/InvokeOnComponentTest.java
myfaces/core/trunk/api/src/test/java/javax/faces/component/UISelectManyTest.java
myfaces/core/trunk/impl/pom.xml
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/ApplicationImplAnnotationTest.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/ClientBehaviorTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormRendererTest.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/test/utils/MockTestViewHandler.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/SelectTestCase.java
Propchange: myfaces/core/trunk/api/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Jul 1 20:42:37 2010
@@ -1,14 +1,13 @@
-build.local.properties
-target
-
*.iml
*.ipr
*.iws
.classpath
+.externalToolBuilders
.project
.settings
-velocity.log
-
+build.local.properties
cobertura.ser
-
+maven-eclipse.xml
+target
test-output
+velocity.log
Modified: myfaces/core/trunk/api/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/pom.xml?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/api/pom.xml (original)
+++ myfaces/core/trunk/api/pom.xml Thu Jul 1 20:42:37 2010
@@ -471,6 +471,14 @@
<version>1.0.5</version>
<scope>provided</scope>
</dependency>
+
+ <!-- TEST DEPENDENCIES -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
Modified: myfaces/core/trunk/api/src/test/java/javax/faces/FacesExceptionTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/test/java/javax/faces/FacesExceptionTest.java?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/test/java/javax/faces/FacesExceptionTest.java (original)
+++ myfaces/core/trunk/api/src/test/java/javax/faces/FacesExceptionTest.java Thu Jul 1 20:42:37 2010
@@ -19,78 +19,78 @@
package javax.faces;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-public class FacesExceptionTest extends TestCase
+public class FacesExceptionTest
{
- public static void main(String[] args)
+ public FacesExceptionTest()
{
- junit.textui.TestRunner.run(FacesExceptionTest.class);
}
- public FacesExceptionTest(String name)
+ @Before
+ public void setUp() throws Exception
{
- super(name);
}
- @Override
- protected void setUp() throws Exception
+ @After
+ public void tearDown() throws Exception
{
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
}
/*
* Test method for 'javax.faces.FacesException.FacesException()'
*/
+ @Test
public void testFacesException()
{
FacesException e = new FacesException();
- assertNull(e.getCause());
- assertNull(e.getMessage());
+ Assert.assertNull(e.getCause());
+ Assert.assertNull(e.getMessage());
}
/*
* Test method for 'javax.faces.FacesException.FacesException(Throwable)'
*/
+ @Test
public void testFacesExceptionThrowable()
{
Throwable t = new Throwable();
FacesException fe = new FacesException(t);
- assertEquals(t, fe.getCause());
+ Assert.assertEquals(t, fe.getCause());
}
/*
* Test method for 'javax.faces.FacesException.FacesException(String)'
*/
+ @Test
public void testFacesExceptionString()
{
String m = "Message";
FacesException e = new FacesException(m);
- assertEquals(e.getMessage(), m);
+ Assert.assertEquals(e.getMessage(), m);
}
/*
* Test method for 'javax.faces.FacesException.FacesException(String, Throwable)'
*/
+ @Test
public void testFacesExceptionStringThrowable()
{
String m = "Message";
Throwable t = new Throwable();
FacesException fe = new FacesException(m, t);
- assertEquals(t, fe.getCause());
- assertEquals(fe.getMessage(), m);
+ Assert.assertEquals(t, fe.getCause());
+ Assert.assertEquals(fe.getMessage(), m);
}
/*
* Test method for 'javax.faces.FacesException.getCause()'
*/
+ @Test
public void testGetCause()
{
Modified: myfaces/core/trunk/api/src/test/java/javax/faces/FactoryFinderTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/test/java/javax/faces/FactoryFinderTest.java?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/test/java/javax/faces/FactoryFinderTest.java (original)
+++ myfaces/core/trunk/api/src/test/java/javax/faces/FactoryFinderTest.java Thu Jul 1 20:42:37 2010
@@ -23,38 +23,32 @@ import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
import org.apache.myfaces.mock.api.Mock2ApplicationFactory;
import org.apache.myfaces.mock.api.MockApplicationFactory;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-public class FactoryFinderTest extends TestCase
+public class FactoryFinderTest
{
- public static void main(String[] args)
+ public FactoryFinderTest()
{
- junit.textui.TestRunner.run(FactoryFinderTest.class);
-
}
- public FactoryFinderTest(String name)
+ @Before
+ public void setUp() throws Exception
{
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
// this needs to be called *before* the first Test test is run,
// as there may be left over FactoryFinder configurations from
// that previous tests that may interfere with the first test here.
FactoryFinder.releaseFactories();
}
- @Override
- protected void tearDown() throws Exception
+ @After
+ public void tearDown() throws Exception
{
- super.tearDown();
// call this again so there is no possibility of messing up tests that will
// run after this one
FactoryFinder.releaseFactories();
@@ -109,6 +103,7 @@ public class FactoryFinderTest extends T
/*
* Test method for 'javax.faces.FactoryFinder.getFactory(String)'
*/
+ @Test
public void testGetFactory() throws Exception
{
// no catch because if this fails the test fails, i.e. not trying to test
@@ -117,18 +112,19 @@ public class FactoryFinderTest extends T
try
{
Object factory = FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
- assertNotNull(factory);
- assertTrue(factory.getClass().equals(MockApplicationFactory.class));
+ Assert.assertNotNull(factory);
+ Assert.assertTrue(factory.getClass().equals(MockApplicationFactory.class));
}
catch (IllegalStateException e)
{
- fail("Should not throw an illegal state exception");
+ Assert.fail("Should not throw an illegal state exception");
}
}
/*
* Test method for 'javax.faces.FactoryFinder.getFactory(String)'
*/
+ @Test
public void testGetFactoryTwice() throws Exception
{
// this test just makes sure that things work when the get has been called
@@ -137,22 +133,23 @@ public class FactoryFinderTest extends T
try
{
Object factory1 = FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
- assertNotNull(factory1);
- assertTrue(factory1.getClass().equals(MockApplicationFactory.class));
+ Assert.assertNotNull(factory1);
+ Assert.assertTrue(factory1.getClass().equals(MockApplicationFactory.class));
Object factory2 = FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
- assertNotNull(factory2);
- assertTrue(factory2.getClass().equals(MockApplicationFactory.class));
- assertEquals(factory1, factory2);
+ Assert.assertNotNull(factory2);
+ Assert.assertTrue(factory2.getClass().equals(MockApplicationFactory.class));
+ Assert.assertEquals(factory1, factory2);
}
catch (IllegalStateException e)
{
- fail("Should not throw an illegal state exception");
+ Assert.fail("Should not throw an illegal state exception");
}
}
/*
* Test method for 'javax.faces.FactoryFinder.getFactory(String)'
*/
+ @Test
public void testGetFactoryNoFactory() throws Exception
{
// no catch because if this fails the test fails, i.e. not trying to test
@@ -161,11 +158,11 @@ public class FactoryFinderTest extends T
try
{
FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- fail("Should have thrown an illegal state exception");
+ Assert.fail("Should have thrown an illegal state exception");
}
catch (IllegalArgumentException e)
{
- assertNotNull(e.getMessage());
+ Assert.assertNotNull(e.getMessage());
}
}
@@ -173,50 +170,53 @@ public class FactoryFinderTest extends T
* No configuration test, this should throw and deliver a useful message Test method for
* 'javax.faces.FactoryFinder.getFactory(String)'
*/
+ @Test
public void testGetFactoryNoConfiguration() throws Exception
{
try
{
FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
- fail("Should have thrown an illegal state exception");
+ Assert.fail("Should have thrown an illegal state exception");
}
catch (IllegalStateException e)
{
- assertNotNull(e.getMessage());
- assertTrue(e.getMessage().startsWith("No Factories configured for this Application"));
+ Assert.assertNotNull(e.getMessage());
+ Assert.assertTrue(e.getMessage().startsWith("No Factories configured for this Application"));
}
}
/*
* Bogus factory name test Test method for 'javax.faces.FactoryFinder.setFactory(String, String)'
*/
+ @Test
public void testSetFactoryBogusName()
{
try
{
FactoryFinder.setFactory("BogusFactoryName", MockApplicationFactory.class.getName());
- fail("Should have thrown an illegal argument exception");
+ Assert.fail("Should have thrown an illegal argument exception");
}
catch (IllegalArgumentException e)
{
- assertNotNull(e.getMessage());
+ Assert.assertNotNull(e.getMessage());
}
}
/*
* Test method for 'javax.faces.FactoryFinder.setFactory(String, String)'
*/
+ @Test
public void testSetFactory() throws Exception
{
try
{
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName());
- assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
+ Assert.assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
MockApplicationFactory.class.getName()));
}
catch (IllegalArgumentException e)
{
- fail("Should not throw an illegal argument exception");
+ Assert.fail("Should not throw an illegal argument exception");
}
}
@@ -224,28 +224,29 @@ public class FactoryFinderTest extends T
* If a factory has ever been handed out then setFactory is not supposed to change the factory layout. This test
* checks to see if that is true. Test method for 'javax.faces.FactoryFinder.setFactory(String, String)'
*/
+ @Test
public void testSetFactoryNoEffect() throws Exception
{
try
{
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName());
- assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
+ Assert.assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
MockApplicationFactory.class.getName()));
- assertFalse(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
+ Assert.assertFalse(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
Mock2ApplicationFactory.class.getName()));
// getFactory should cause setFactory to stop changing the
// registered classes
FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
// this should essentially be a no-op
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, Mock2ApplicationFactory.class.getName());
- assertFalse(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
+ Assert.assertFalse(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
Mock2ApplicationFactory.class.getName()));
- assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
+ Assert.assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
MockApplicationFactory.class.getName()));
}
catch (IllegalArgumentException e)
{
- fail("Should not throw an illegal argument exception");
+ Assert.fail("Should not throw an illegal argument exception");
}
}
@@ -253,33 +254,34 @@ public class FactoryFinderTest extends T
* Adding factories should add the class name to the list of avalable class names Test method for
* 'javax.faces.FactoryFinder.setFactory(String, String)'
*/
+ @Test
public void testSetFactoryAdditiveClassNames() throws Exception
{
try
{
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName());
- assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
+ Assert.assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
MockApplicationFactory.class.getName()));
- assertFalse(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
+ Assert.assertFalse(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
Mock2ApplicationFactory.class.getName()));
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, Mock2ApplicationFactory.class.getName());
- assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
+ Assert.assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
Mock2ApplicationFactory.class.getName()));
- assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
+ Assert.assertTrue(registeredFactoryNames(FactoryFinder.APPLICATION_FACTORY).contains(
MockApplicationFactory.class.getName()));
}
catch (IllegalArgumentException e)
{
- fail("Should not throw an illegal argument exception");
+ Assert.fail("Should not throw an illegal argument exception");
}
}
/*
* Test method for 'javax.faces.FactoryFinder.releaseFactories()'
*/
+ @Test
public void testReleaseFactories()
{
}
-
}
Modified: myfaces/core/trunk/api/src/test/java/javax/faces/application/ApplicationTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/test/java/javax/faces/application/ApplicationTest.java?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/test/java/javax/faces/application/ApplicationTest.java (original)
+++ myfaces/core/trunk/api/src/test/java/javax/faces/application/ApplicationTest.java Thu Jul 1 20:42:37 2010
@@ -18,15 +18,14 @@
*/
package javax.faces.application;
-import static org.apache.myfaces.Assert.assertException;
+import javax.el.ValueExpression;
+
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.NoOp;
-import org.apache.myfaces.TestRunner;
-
-import javax.el.ValueExpression;
-
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests for {@link Application}
@@ -34,151 +33,102 @@ import junit.framework.TestCase;
* @author Mathias Broekelmann (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class ApplicationTest extends TestCase
+public class ApplicationTest
{
private Application app;
- @Override
- protected void setUp() throws Exception
+ @Before
+ public void setUp() throws Exception
{
app = (Application) Enhancer.create(Application.class, NoOp.INSTANCE);
}
+
+ @After
+ public void tearDown() throws Exception
+ {
+ }
/**
* Test method for {@link javax.faces.application.Application#addELResolver(javax.el.ELResolver)}.
*/
- /*
+ @Test(expected=UnsupportedOperationException.class)
public void testAddELResolver()
{
- assertException(UnsupportedOperationException.class, new TestRunner()
- {
- public void run()
- {
- app.addELResolver(null);
- }
- });
- }*/
+ app.addELResolver(null);
+ }
/**
* Test method for {@link javax.faces.application.Application#getELResolver()}.
*/
- /*
+ @Test(expected=UnsupportedOperationException.class)
public void testGetELResolver()
{
- assertException(UnsupportedOperationException.class, new TestRunner()
- {
- public void run()
- {
- app.getELResolver();
- }
- });
- }*/
+ app.getELResolver();
+ }
/**
* Test method for
* {@link javax.faces.application.Application#getResourceBundle(javax.faces.context.FacesContext, java.lang.String)}.
*/
- /*
+ @Test(expected=UnsupportedOperationException.class)
public void testGetResourceBundle()
{
- assertException(UnsupportedOperationException.class, new TestRunner()
- {
- public void run()
- {
- app.getResourceBundle(null, null);
- }
- });
- }*/
+ app.getResourceBundle(null, null);
+ }
/**
* Test method for
* {@link javax.faces.application.Application#createComponent(javax.el.ValueExpression, javax.faces.context.FacesContext, java.lang.String)}.
*/
- /*
+ @Test(expected=UnsupportedOperationException.class)
public void testCreateComponentValueExpressionFacesContextString()
{
- assertException(UnsupportedOperationException.class, new TestRunner()
- {
- public void run()
- {
- app.createComponent((ValueExpression) null, null, null);
- }
- });
- }*/
+ app.createComponent((ValueExpression) null, null, null);
+ }
/**
* Test method for {@link javax.faces.application.Application#getExpressionFactory()}.
*/
- /*
+ @Test(expected=UnsupportedOperationException.class)
public void testGetExpressionFactory()
{
- assertException(UnsupportedOperationException.class, new TestRunner()
- {
- public void run()
- {
- app.getExpressionFactory();
- }
- });
- }*/
+ app.getExpressionFactory();
+ }
/**
* Test method for {@link javax.faces.application.Application#addELContextListener(javax.el.ELContextListener)}.
*/
- /*
+ @Test(expected=UnsupportedOperationException.class)
public void testAddELContextListener()
{
- assertException(UnsupportedOperationException.class, new TestRunner()
- {
- public void run()
- {
- app.addELContextListener(null);
- }
- });
- }*/
+ app.addELContextListener(null);
+ }
/**
* Test method for {@link javax.faces.application.Application#removeELContextListener(javax.el.ELContextListener)}.
*/
- /*
+ @Test(expected=UnsupportedOperationException.class)
public void testRemoveELContextListener()
{
- assertException(UnsupportedOperationException.class, new TestRunner()
- {
- public void run()
- {
- app.removeELContextListener(null);
- }
- });
- }*/
+ app.removeELContextListener(null);
+ }
/**
* Test method for {@link javax.faces.application.Application#getELContextListeners()}.
*/
- /*
+ @Test(expected=UnsupportedOperationException.class)
public void testGetELContextListeners()
{
- assertException(UnsupportedOperationException.class, new TestRunner()
- {
- public void run()
- {
- app.getELContextListeners();
- }
- });
- }*/
+ app.getELContextListeners();
+ }
/**
* Test method for
* {@link javax.faces.application.Application#evaluateExpressionGet(javax.faces.context.FacesContext, java.lang.String, java.lang.Class)}.
*/
- /*
+ @Test(expected=UnsupportedOperationException.class)
public void testEvaluateExpressionGet()
{
- assertException(UnsupportedOperationException.class, new TestRunner()
- {
- public void run()
- {
- app.evaluateExpressionGet(null, null, null);
- }
- });
- }*/
+ app.evaluateExpressionGet(null, null, null);
+ }
}
Modified: myfaces/core/trunk/api/src/test/java/javax/faces/component/InvokeOnComponentTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/test/java/javax/faces/component/InvokeOnComponentTest.java?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/test/java/javax/faces/component/InvokeOnComponentTest.java (original)
+++ myfaces/core/trunk/api/src/test/java/javax/faces/component/InvokeOnComponentTest.java Thu Jul 1 20:42:37 2010
@@ -132,60 +132,59 @@ public class InvokeOnComponentTest exten
}
-// Disabled until Myfaces test issues are resolved..
-// public void testInvokeOnCompOnUIDataChildren() throws Exception
-// {
-// // column1
-// UIColumn c1 = new UIColumn();
-// c1.setId("col1");
-//
-// UIOutput headerFacet = new UIOutput();
-// headerFacet.setValue("HEADER");
-// headerFacet.setId("header");
-// c1.setHeader(headerFacet);
-//
-// UIOutput name = new UIOutput();
-// name.setValue("#{data.username}");
-// c1.getChildren().add(name);
-//
-// // column2
-// UIColumn c2 = new UIColumn();
-// c2.setId("col2");
-//
-// UIOutput secondheaderFacet = new UIOutput();
-// secondheaderFacet.setValue("New HEADER");
-// secondheaderFacet.setId("header2");
-// c2.setHeader(secondheaderFacet);
-//
-// UIOutput passwd = new UIOutput();
-// passwd.setValue("#{data.password}");
-// c2.getChildren().add(passwd);
-//
-// // main table
-// UIData table = new UIData();
-// table.setId("table");
-//
-// table.setVar("data");
-//
-// table.getChildren().add(c1);
-// table.getChildren().add(c2);
-//
-// DataModel model = new ListDataModel(createTestData());
-// table.setValue(model);
-// this.facesContext.getViewRoot().getChildren().add(table);
-//
-// System.out.println("RC; " + table.getRowCount());
-// table.encodeBegin(facesContext);
-// System.out.println("RC; " + table.getRowCount());
-// // there should be no call on passwd yet, b/c for UIData the invokeOnComp isn't implemented yet...
-// mock.expects(never()).method("invokeContextCallback").with(eq(facesContext), eq(table));
-// mock.expects(never()).method("invokeContextCallback").with(eq(facesContext), eq(passwd));
-// mock.expects(never()).method("invokeContextCallback").with(eq(facesContext), eq(c1));
-// mock.expects(never()).method("invokeContextCallback").with(eq(facesContext), eq(name));
-//
-// this.facesContext.getViewRoot().invokeOnComponent(facesContext, passwd.getClientId(facesContext), cc);
-//
-// }
+ public void testInvokeOnCompOnUIDataChildren() throws Exception
+ {
+ // column1
+ UIColumn c1 = new UIColumn();
+ c1.setId("col1");
+
+ UIOutput headerFacet = new UIOutput();
+ headerFacet.setValue("HEADER");
+ headerFacet.setId("header");
+ c1.setHeader(headerFacet);
+
+ UIOutput name = new UIOutput();
+ name.setValue("#{data.username}");
+ c1.getChildren().add(name);
+
+ // column2
+ UIColumn c2 = new UIColumn();
+ c2.setId("col2");
+
+ UIOutput secondheaderFacet = new UIOutput();
+ secondheaderFacet.setValue("New HEADER");
+ secondheaderFacet.setId("header2");
+ c2.setHeader(secondheaderFacet);
+
+ UIOutput passwd = new UIOutput();
+ passwd.setValue("#{data.password}");
+ c2.getChildren().add(passwd);
+
+ // main table
+ UIData table = new UIData();
+ table.setId("table");
+
+ table.setVar("data");
+
+ table.getChildren().add(c1);
+ table.getChildren().add(c2);
+
+ DataModel model = new ListDataModel(createTestData());
+ table.setValue(model);
+ this.facesContext.getViewRoot().getChildren().add(table);
+
+ System.out.println("RC; " + table.getRowCount());
+ table.encodeBegin(facesContext);
+ System.out.println("RC; " + table.getRowCount());
+ // there should be no call on passwd yet, b/c for UIData the invokeOnComp isn't implemented yet...
+ mock.expects(never()).method("invokeContextCallback").with(eq(facesContext), eq(table));
+ mock.expects(never()).method("invokeContextCallback").with(eq(facesContext), eq(passwd));
+ mock.expects(never()).method("invokeContextCallback").with(eq(facesContext), eq(c1));
+ mock.expects(never()).method("invokeContextCallback").with(eq(facesContext), eq(name));
+
+ this.facesContext.getViewRoot().invokeOnComponent(facesContext, passwd.getClientId(facesContext), cc);
+
+ }
protected List<Data> createTestData()
{
Modified: myfaces/core/trunk/api/src/test/java/javax/faces/component/UISelectManyTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/test/java/javax/faces/component/UISelectManyTest.java?rev=959777&r1=959776&r2=959777&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 Thu Jul 1 20:42:37 2010
@@ -23,146 +23,159 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
-import org.apache.myfaces.test.base.AbstractJsfTestCase;
+import org.apache.myfaces.test.base.junit4.AbstractJsfTestCase;
+import org.junit.Assert;
+import org.junit.Test;
-public class UISelectManyTest extends AbstractJsfTestCase {
+public class UISelectManyTest extends AbstractJsfTestCase
+{
- public UISelectManyTest(String name) {
- super(name);
- }
-
-//Disabled until Myfaces test issues are resolved..
-// public void testValidateRequiredNull() {
-//
-// facesContext.getViewRoot().setLocale(_TEST_LOCALE);
-//
-// UISelectMany selectMany = new UISelectMany();
-// selectMany.setId("selectMany");
-// selectMany.setRendererType(null);
-// selectMany.setRequired(true);
-// List<UIComponent> children = selectMany.getChildren();
-//
-// UISelectItem one = new UISelectItem();
-// one.setItemValue(new Integer(1));
-// children.add(one);
-//
-// UISelectItem two = new UISelectItem();
-// two.setItemValue(new Integer(2));
-// children.add(two);
-//
-// UISelectItem three = new UISelectItem();
-// three.setItemValue(new Integer(3));
-// children.add(three);
-//
-// selectMany.validateValue(facesContext, null);
-//
-// assertFalse(selectMany.isValid());
-// }
-//
-// public void testValidateRequiredEmptyList() {
-//
-// facesContext.getViewRoot().setLocale(_TEST_LOCALE);
-//
-// UISelectMany selectMany = new UISelectMany();
-// selectMany.setId("selectMany");
-// selectMany.setRendererType(null);
-// selectMany.setRequired(true);
-// List<UIComponent> children = selectMany.getChildren();
-//
-// UISelectItem one = new UISelectItem();
-// one.setItemValue(new Integer(1));
-// children.add(one);
-//
-// UISelectItem two = new UISelectItem();
-// two.setItemValue(new Integer(2));
-// children.add(two);
-//
-// UISelectItem three = new UISelectItem();
-// three.setItemValue(new Integer(3));
-// children.add(three);
-//
-// selectMany.validateValue(facesContext, Collections.EMPTY_LIST);
-//
-// assertFalse(selectMany.isValid());
-// }
-//
-// public void testValidateIntArray() {
-//
-// facesContext.getViewRoot().setLocale(_TEST_LOCALE);
-//
-// UISelectMany selectMany = new UISelectMany();
-// selectMany.setId("selectMany");
-// selectMany.setRendererType(null);
-// List<UIComponent> children = selectMany.getChildren();
-//
-// UISelectItem one = new UISelectItem();
-// one.setItemValue(new Integer(1));
-// children.add(one);
-//
-// UISelectItem two = new UISelectItem();
-// two.setItemValue(new Integer(2));
-// children.add(two);
-//
-// UISelectItem three = new UISelectItem();
-// three.setItemValue(new Integer(3));
-// children.add(three);
-//
-// selectMany.validateValue(facesContext, new int[] { 2, 3 });
-//
-// assertTrue(selectMany.isValid());
-// }
-//
-// public void testValidateStringArray() {
-//
-// facesContext.getViewRoot().setLocale(_TEST_LOCALE);
-//
-// UISelectMany selectMany = new UISelectMany();
-// selectMany.setId("selectMany");
-// selectMany.setRendererType(null);
-// List<UIComponent> children = selectMany.getChildren();
-//
-// UISelectItem one = new UISelectItem();
-// one.setItemValue("1");
-// children.add(one);
-//
-// UISelectItem two = new UISelectItem();
-// two.setItemValue("2");
-// children.add(two);
-//
-// UISelectItem three = new UISelectItem();
-// three.setItemValue("3");
-// children.add(three);
-//
-// selectMany.validateValue(facesContext, new String[] { "2", "3" });
-//
-// assertTrue(selectMany.isValid());
-// }
-//
-// public void testValidateStringList() {
-//
-// facesContext.getViewRoot().setLocale(_TEST_LOCALE);
-//
-// UISelectMany selectMany = new UISelectMany();
-// selectMany.setId("selectMany");
-// selectMany.setRendererType(null);
-// List<UIComponent> children = selectMany.getChildren();
-//
-// UISelectItem one = new UISelectItem();
-// one.setItemValue("1");
-// children.add(one);
-//
-// UISelectItem two = new UISelectItem();
-// two.setItemValue("2");
-// children.add(two);
-//
-// UISelectItem three = new UISelectItem();
-// three.setItemValue("3");
-// children.add(three);
-//
-// selectMany.validateValue(facesContext, Arrays.asList(new String[] { "2", "3" }));
-//
-// assertTrue(selectMany.isValid());
-// }
+ public UISelectManyTest()
+ {
+ }
- static private final Locale _TEST_LOCALE = new Locale("xx", "TEST");
+ @Test
+ public void testValidateRequiredNull()
+ {
+
+ facesContext.getViewRoot().setLocale(_TEST_LOCALE);
+
+ UISelectMany selectMany = new UISelectMany();
+ selectMany.setId("selectMany");
+ selectMany.setRendererType(null);
+ selectMany.setRequired(true);
+ List<UIComponent> children = selectMany.getChildren();
+
+ UISelectItem one = new UISelectItem();
+ one.setItemValue(new Integer(1));
+ children.add(one);
+
+ UISelectItem two = new UISelectItem();
+ two.setItemValue(new Integer(2));
+ children.add(two);
+
+ UISelectItem three = new UISelectItem();
+ three.setItemValue(new Integer(3));
+ children.add(three);
+
+ selectMany.validateValue(facesContext, null);
+
+ Assert.assertFalse(selectMany.isValid());
+ }
+
+ @Test
+ public void testValidateRequiredEmptyList()
+ {
+
+ facesContext.getViewRoot().setLocale(_TEST_LOCALE);
+
+ UISelectMany selectMany = new UISelectMany();
+ selectMany.setId("selectMany");
+ selectMany.setRendererType(null);
+ selectMany.setRequired(true);
+ List<UIComponent> children = selectMany.getChildren();
+
+ UISelectItem one = new UISelectItem();
+ one.setItemValue(new Integer(1));
+ children.add(one);
+
+ UISelectItem two = new UISelectItem();
+ two.setItemValue(new Integer(2));
+ children.add(two);
+
+ UISelectItem three = new UISelectItem();
+ three.setItemValue(new Integer(3));
+ children.add(three);
+
+ selectMany.validateValue(facesContext, Collections.EMPTY_LIST);
+
+ Assert.assertFalse(selectMany.isValid());
+ }
+
+ @Test
+ public void testValidateIntArray()
+ {
+
+ facesContext.getViewRoot().setLocale(_TEST_LOCALE);
+
+ UISelectMany selectMany = new UISelectMany();
+ selectMany.setId("selectMany");
+ selectMany.setRendererType(null);
+ List<UIComponent> children = selectMany.getChildren();
+
+ UISelectItem one = new UISelectItem();
+ one.setItemValue(new Integer(1));
+ children.add(one);
+
+ UISelectItem two = new UISelectItem();
+ two.setItemValue(new Integer(2));
+ children.add(two);
+
+ UISelectItem three = new UISelectItem();
+ three.setItemValue(new Integer(3));
+ children.add(three);
+
+ selectMany.validateValue(facesContext, new int[] { 2, 3 });
+
+ Assert.assertTrue(selectMany.isValid());
+ }
+
+ @Test
+ public void testValidateStringArray()
+ {
+
+ facesContext.getViewRoot().setLocale(_TEST_LOCALE);
+
+ UISelectMany selectMany = new UISelectMany();
+ selectMany.setId("selectMany");
+ selectMany.setRendererType(null);
+ List<UIComponent> children = selectMany.getChildren();
+
+ UISelectItem one = new UISelectItem();
+ one.setItemValue("1");
+ children.add(one);
+
+ UISelectItem two = new UISelectItem();
+ two.setItemValue("2");
+ children.add(two);
+
+ UISelectItem three = new UISelectItem();
+ three.setItemValue("3");
+ children.add(three);
+
+ selectMany.validateValue(facesContext, new String[] { "2", "3" });
+
+ Assert.assertTrue(selectMany.isValid());
+ }
+
+ @Test
+ public void testValidateStringList()
+ {
+
+ facesContext.getViewRoot().setLocale(_TEST_LOCALE);
+
+ UISelectMany selectMany = new UISelectMany();
+ selectMany.setId("selectMany");
+ selectMany.setRendererType(null);
+ List<UIComponent> children = selectMany.getChildren();
+
+ UISelectItem one = new UISelectItem();
+ one.setItemValue("1");
+ children.add(one);
+
+ UISelectItem two = new UISelectItem();
+ two.setItemValue("2");
+ children.add(two);
+
+ UISelectItem three = new UISelectItem();
+ three.setItemValue("3");
+ children.add(three);
+
+ selectMany.validateValue(facesContext, Arrays.asList(new String[] {
+ "2", "3" }));
+
+ Assert.assertTrue(selectMany.isValid());
+ }
+
+ static private final Locale _TEST_LOCALE = new Locale("xx", "TEST");
}
Modified: myfaces/core/trunk/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/pom.xml?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/impl/pom.xml (original)
+++ myfaces/core/trunk/impl/pom.xml Thu Jul 1 20:42:37 2010
@@ -940,6 +940,14 @@
<version>1.0.CR3</version>
<optional>true</optional>
</dependency>
+
+ <!-- TEST DEPENDENCIES -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/ApplicationImplAnnotationTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/ApplicationImplAnnotationTest.java?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/ApplicationImplAnnotationTest.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/ApplicationImplAnnotationTest.java Thu Jul 1 20:42:37 2010
@@ -18,163 +18,82 @@
*/
package org.apache.myfaces.application;
-import java.net.URL;
-import java.net.URLClassLoader;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import javax.el.ValueExpression;
import javax.faces.FactoryFinder;
-import javax.faces.application.ApplicationFactory;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.component.UIOutput;
import javax.faces.component.UIPanel;
-import javax.faces.component.UIViewRoot;
import javax.faces.convert.Converter;
import javax.faces.convert.DateTimeConverter;
import javax.faces.event.ListenerFor;
import javax.faces.event.PostAddToViewEvent;
-import javax.faces.lifecycle.LifecycleFactory;
-import javax.faces.render.RenderKitFactory;
import javax.faces.render.Renderer;
-import junit.framework.TestCase;
-
import org.apache.myfaces.config.RuntimeConfig;
-import org.apache.myfaces.test.mock.MockFacesContextFactory;
+import org.apache.myfaces.test.base.junit4.AbstractJsfConfigurableMockTestCase;
import org.apache.myfaces.test.el.MockExpressionFactory;
-import org.apache.myfaces.test.mock.MockExternalContext;
-import org.apache.myfaces.test.mock.MockFacesContext;
-import org.apache.myfaces.test.mock.MockHttpServletRequest;
-import org.apache.myfaces.test.mock.MockHttpServletResponse;
-import org.apache.myfaces.test.mock.MockHttpSession;
import org.apache.myfaces.test.mock.MockPropertyResolver;
-import org.apache.myfaces.test.mock.MockRenderKit;
import org.apache.myfaces.test.mock.MockRenderKitFactory;
-import org.apache.myfaces.test.mock.MockServletConfig;
import org.apache.myfaces.test.mock.MockServletContext;
import org.apache.myfaces.test.mock.MockVariableResolver;
-import org.apache.myfaces.test.mock.lifecycle.MockLifecycle;
-import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
+import org.junit.Assert;
+import org.junit.Test;
-public class ApplicationImplAnnotationTest extends TestCase
+public class ApplicationImplAnnotationTest extends AbstractJsfConfigurableMockTestCase
{
//TODO: need mock objects for VDL/VDLFactory
//remove from excludes list in pom.xml after complete
- // Mock object instances for our tests
- protected ApplicationImpl application = null;
- protected MockServletConfig config = null;
- protected MockExternalContext externalContext = null;
- protected MockFacesContext facesContext = null;
- protected MockFacesContextFactory facesContextFactory = null;
- protected MockLifecycle lifecycle = null;
- protected MockLifecycleFactory lifecycleFactory = null;
- protected MockRenderKit renderKit = null;
- protected MockHttpServletRequest request = null;
- protected MockHttpServletResponse response = null;
- protected MockServletContext servletContext = null;
- protected MockHttpSession session = null;
-
- // Thread context class loader saved and restored after each test
- private ClassLoader threadContextClassLoader = null;
-
- public ApplicationImplAnnotationTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- // Set up a new thread context class loader
- threadContextClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(new URLClassLoader(new URL[0],
- this.getClass().getClassLoader()));
-
- // Set up Servlet API Objects
- servletContext = new MockServletContext();
- config = new MockServletConfig(servletContext);
- session = new MockHttpSession();
- session.setServletContext(servletContext);
- request = new MockHttpServletRequest(session);
- request.setServletContext(servletContext);
- response = new MockHttpServletResponse();
- externalContext =
- new MockExternalContext(servletContext, request, response);
-
- // Set up JSF API Objects
- FactoryFinder.releaseFactories();
- RuntimeConfig.getCurrentInstance(externalContext).setPropertyResolver(new MockPropertyResolver());
- RuntimeConfig.getCurrentInstance(externalContext).setVariableResolver(new MockVariableResolver());
- RuntimeConfig.getCurrentInstance(externalContext).setExpressionFactory(new MockExpressionFactory());
- //To make work ValueExpressions
-
-
+ public ApplicationImplAnnotationTest()
+ {
+ }
+
+ @Override
+ protected void setFactories() throws Exception
+ {
+ super.setFactories();
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
ApplicationFactoryImpl.class.getName());
- FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
- "org.apache.myfaces.test.mock.MockFacesContextFactory");
- FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY,
- "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
- FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
- "org.apache.myfaces.test.mock.MockRenderKitFactory");
- FactoryFinder.setFactory(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY,
+ FactoryFinder.setFactory(
+ FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY,
"org.apache.myfaces.view.ViewDeclarationLanguageFactoryImpl");
+ }
- lifecycleFactory = (MockLifecycleFactory)
- FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
- lifecycle = (MockLifecycle)
- lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
- facesContextFactory = (MockFacesContextFactory)
- FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- facesContext = (MockFacesContext)
- facesContextFactory.getFacesContext(servletContext,
- request,
- response,
- lifecycle);
- externalContext = (MockExternalContext) facesContext.getExternalContext();
- UIViewRoot root = new UIViewRoot();
- root.setViewId("/viewId");
- root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
- facesContext.setViewRoot(root);
- ApplicationFactory applicationFactory = (ApplicationFactory)
- FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
- application = (ApplicationImpl) applicationFactory.getApplication();
- facesContext.setApplication(application);
- RenderKitFactory renderKitFactory = (RenderKitFactory)
- FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- renderKit = new MockRenderKit();
- renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
-
+ @Override
+ protected void setUpExternalContext() throws Exception
+ {
+ super.setUpExternalContext();
+ //Set RuntimeConfig object properly to make work ValueExpressions
+ RuntimeConfig.getCurrentInstance(externalContext).setPropertyResolver(
+ new MockPropertyResolver());
+ RuntimeConfig.getCurrentInstance(externalContext).setVariableResolver(
+ new MockVariableResolver());
+ RuntimeConfig.getCurrentInstance(externalContext).setExpressionFactory(
+ new MockExpressionFactory());
+ }
+
+ @Override
+ protected void setUpApplication() throws Exception
+ {
+ super.setUpApplication();
//We need this two components added
- application.addComponent(UIOutput.COMPONENT_TYPE, UIOutput.class.getName());
- application.addComponent(UIPanel.COMPONENT_TYPE, UIPanel.class.getName());
-
+ application.addComponent(UIOutput.COMPONENT_TYPE, UIOutput.class
+ .getName());
+ application.addComponent(UIPanel.COMPONENT_TYPE, UIPanel.class
+ .getName());
}
+ @Override
public void tearDown() throws Exception
{
RuntimeConfig.getCurrentInstance(externalContext).purge();
- application = null;
- config = null;
- externalContext = null;
- facesContext.release();
- facesContext = null;
- lifecycle = null;
- lifecycleFactory = null;
- renderKit = null;
- request = null;
- response = null;
- servletContext = null;
- session = null;
- FactoryFinder.releaseFactories();
-
- Thread.currentThread().setContextClassLoader(threadContextClassLoader);
- threadContextClassLoader = null;
-
+ super.tearDown();
}
/**
@@ -207,6 +126,7 @@ public class ApplicationImplAnnotationTe
}
+ @Test
public void testCreateComponentRenderer() throws Exception
{
facesContext.getViewRoot().setRenderKitId(
@@ -223,10 +143,10 @@ public class ApplicationImplAnnotationTe
UITestComponentA.DEFAULT_RENDERER_TYPE);
List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
- assertEquals(1,componentResources.size());
+ Assert.assertEquals(1,componentResources.size());
Map<String,Object> attrMap = componentResources.get(0).getAttributes();
- assertEquals("testResource.js",attrMap.get("name"));
- assertEquals("testLib",attrMap.get("library"));
+ Assert.assertEquals("testResource.js",attrMap.get("name"));
+ Assert.assertEquals("testLib",attrMap.get("library"));
}
@ResourceDependency(name = "testResource.js")
@@ -248,6 +168,7 @@ public class ApplicationImplAnnotationTe
}
}
+ @Test
public void testCreateComponentAnnotation() throws Exception
{
application.addComponent(UITestComponentB.COMPONENT_TYPE,
@@ -256,11 +177,12 @@ public class ApplicationImplAnnotationTe
UITestComponentB comp = (UITestComponentB) application.createComponent(UITestComponentB.COMPONENT_TYPE);
List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
- assertEquals(1,componentResources.size());
+ Assert.assertEquals(1,componentResources.size());
Map<String,Object> attrMap = componentResources.get(0).getAttributes();
- assertEquals("testResource.js",attrMap.get("name"));
+ Assert.assertEquals("testResource.js",attrMap.get("name"));
}
+ @Test
public void testCreateComponentRendererAnnotation() throws Exception
{
facesContext.getViewRoot().setRenderKitId(
@@ -277,7 +199,7 @@ public class ApplicationImplAnnotationTe
UITestComponentB.DEFAULT_RENDERER_TYPE);
List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
- assertEquals(2,componentResources.size());
+ Assert.assertEquals(2,componentResources.size());
for (UIComponent component : componentResources)
{
if ("testResource.js".equals(component.getAttributes().get("name")))
@@ -286,11 +208,12 @@ public class ApplicationImplAnnotationTe
}
else
{
- fail("Not expected resource found"+component.getAttributes().get("name"));
+ Assert.fail("Not expected resource found"+component.getAttributes().get("name"));
}
}
}
+ @Test
public void testCreateComponentValueExpression1() throws Exception
{
@@ -305,11 +228,12 @@ public class ApplicationImplAnnotationTe
List<UIComponent> componentResources =
facesContext.getViewRoot().getComponentResources(facesContext, "head");
- assertEquals(1,componentResources.size());
+ Assert.assertEquals(1,componentResources.size());
Map<String,Object> attrMap = componentResources.get(0).getAttributes();
- assertEquals("testResource.js",attrMap.get("name"));
+ Assert.assertEquals("testResource.js",attrMap.get("name"));
}
+ @Test
public void testCreateComponentValueExpression2() throws Exception
{
@@ -325,11 +249,12 @@ public class ApplicationImplAnnotationTe
List<UIComponent> componentResources =
facesContext.getViewRoot().getComponentResources(facesContext, "head");
- assertEquals(1,componentResources.size());
+ Assert.assertEquals(1,componentResources.size());
Map<String,Object> attrMap = componentResources.get(0).getAttributes();
- assertEquals("testResource.js",attrMap.get("name"));
+ Assert.assertEquals("testResource.js",attrMap.get("name"));
}
+ @Test
public void testCreateComponentValueExpression3() throws Exception
{
@@ -350,7 +275,7 @@ public class ApplicationImplAnnotationTe
UITestComponentB.DEFAULT_RENDERER_TYPE);
List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
- assertEquals(2,componentResources.size());
+ Assert.assertEquals(2,componentResources.size());
for (UIComponent component : componentResources)
{
if ("testResource.js".equals(component.getAttributes().get("name")))
@@ -359,11 +284,12 @@ public class ApplicationImplAnnotationTe
}
else
{
- fail("Not expected resource found"+component.getAttributes().get("name"));
+ Assert.fail("Not expected resource found"+component.getAttributes().get("name"));
}
}
}
+ @Test
public void testCreateComponentValueExpression4() throws Exception
{
@@ -386,7 +312,7 @@ public class ApplicationImplAnnotationTe
UITestComponentB.DEFAULT_RENDERER_TYPE);
List<UIComponent> componentResources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
- assertEquals(2,componentResources.size());
+ Assert.assertEquals(2,componentResources.size());
for (UIComponent component : componentResources)
{
if ("testResource.js".equals(component.getAttributes().get("name")))
@@ -395,18 +321,19 @@ public class ApplicationImplAnnotationTe
}
else
{
- fail("Not expected resource found"+component.getAttributes().get("name"));
+ Assert.fail("Not expected resource found"+component.getAttributes().get("name"));
}
}
}
+ @Test
public void testDatetimeconverterDefaultTimezoneIsSystemTimezoneInitParameter()
{
- servletContext.addInitParameter(
+ ((MockServletContext)servletContext).addInitParameter(
"javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE", "true");
application.addConverter(java.util.Date.class, "javax.faces.convert.DateTimeConverter");
Converter converter = application.createConverter(java.util.Date.class);
- assertEquals(((DateTimeConverter) converter).getTimeZone(), TimeZone.getDefault());
+ Assert.assertEquals(((DateTimeConverter) converter).getTimeZone(), TimeZone.getDefault());
}
}
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/ClientBehaviorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/ClientBehaviorTestCase.java?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/ClientBehaviorTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/ClientBehaviorTestCase.java Thu Jul 1 20:42:37 2010
@@ -18,145 +18,76 @@
*/
package org.apache.myfaces.application;
-import junit.framework.TestCase;
-import org.apache.myfaces.config.RuntimeConfig;
-import org.apache.myfaces.test.el.MockExpressionFactory;
-import org.apache.myfaces.test.mock.*;
-import org.apache.myfaces.test.mock.lifecycle.MockLifecycle;
-import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
+import java.util.List;
+import java.util.Map;
import javax.faces.FactoryFinder;
-import javax.faces.application.ApplicationFactory;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
-import javax.faces.component.*;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIOutput;
+import javax.faces.component.UIPanel;
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorBase;
import javax.faces.component.behavior.FacesBehavior;
-import javax.faces.lifecycle.LifecycleFactory;
-import javax.faces.render.RenderKitFactory;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.List;
-import java.util.Map;
-public class ClientBehaviorTestCase extends TestCase
-{
-
- // Mock object instances for our tests
- protected ApplicationImpl application = null;
- protected MockServletConfig config = null;
- protected MockExternalContext externalContext = null;
- protected MockFacesContext facesContext = null;
- protected MockFacesContextFactory facesContextFactory = null;
- protected MockLifecycle lifecycle = null;
- protected MockLifecycleFactory lifecycleFactory = null;
- protected MockRenderKit renderKit = null;
- protected MockHttpServletRequest request = null;
- protected MockHttpServletResponse response = null;
- protected MockServletContext servletContext = null;
- protected MockHttpSession session = null;
-
- // Thread context class loader saved and restored after each test
- private ClassLoader threadContextClassLoader = null;
+import org.apache.myfaces.config.RuntimeConfig;
+import org.apache.myfaces.test.base.junit4.AbstractJsfConfigurableMockTestCase;
+import org.apache.myfaces.test.el.MockExpressionFactory;
+import org.apache.myfaces.test.mock.MockPropertyResolver;
+import org.apache.myfaces.test.mock.MockVariableResolver;
+import org.junit.Assert;
+import org.junit.Test;
+public class ClientBehaviorTestCase extends AbstractJsfConfigurableMockTestCase
+{
- public ClientBehaviorTestCase(String name)
+ public ClientBehaviorTestCase()
{
- super(name);
}
@Override
- protected void setUp() throws Exception
+ protected void setFactories() throws Exception
{
- super.setUp();
- // Set up a new thread context class loader
- threadContextClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(new URLClassLoader(new URL[0],
- this.getClass().getClassLoader()));
-
- // Set up Servlet API Objects
- servletContext = new MockServletContext();
- config = new MockServletConfig(servletContext);
- session = new MockHttpSession();
- session.setServletContext(servletContext);
- request = new MockHttpServletRequest(session);
- request.setServletContext(servletContext);
- response = new MockHttpServletResponse();
- externalContext =
- new MockExternalContext(servletContext, request, response);
-
- // Set up JSF API Objects
- FactoryFinder.releaseFactories();
- RuntimeConfig.getCurrentInstance(externalContext).setPropertyResolver(new MockPropertyResolver());
- RuntimeConfig.getCurrentInstance(externalContext).setVariableResolver(new MockVariableResolver());
- RuntimeConfig.getCurrentInstance(externalContext).setExpressionFactory(new MockExpressionFactory());
- //To make work ValueExpressions
-
-
+ super.setFactories();
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
ApplicationFactoryImpl.class.getName());
- FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
- "org.apache.myfaces.test.mock.MockFacesContextFactory");
- FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY,
- "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
- FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
- "org.apache.myfaces.test.mock.MockRenderKitFactory");
- FactoryFinder.setFactory(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY,
+ FactoryFinder.setFactory(
+ FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY,
"org.apache.myfaces.view.ViewDeclarationLanguageFactoryImpl");
+ }
- lifecycleFactory = (MockLifecycleFactory)
- FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
- lifecycle = (MockLifecycle)
- lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
- facesContextFactory = (MockFacesContextFactory)
- FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- facesContext = (MockFacesContext)
- facesContextFactory.getFacesContext(servletContext,
- request,
- response,
- lifecycle);
- externalContext = (MockExternalContext) facesContext.getExternalContext();
- UIViewRoot root = new UIViewRoot();
- root.setViewId("/viewId");
- root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
- facesContext.setViewRoot(root);
- ApplicationFactory applicationFactory = (ApplicationFactory)
- FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
- application = (ApplicationImpl) applicationFactory.getApplication();
- facesContext.setApplication(application);
- RenderKitFactory renderKitFactory = (RenderKitFactory)
- FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- renderKit = new MockRenderKit();
- renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
+ @Override
+ protected void setUpExternalContext() throws Exception
+ {
+ super.setUpExternalContext();
+ //Set RuntimeConfig object properly to make work ValueExpressions
+ RuntimeConfig.getCurrentInstance(externalContext).setPropertyResolver(
+ new MockPropertyResolver());
+ RuntimeConfig.getCurrentInstance(externalContext).setVariableResolver(
+ new MockVariableResolver());
+ RuntimeConfig.getCurrentInstance(externalContext).setExpressionFactory(
+ new MockExpressionFactory());
+ }
+ @Override
+ protected void setUpApplication() throws Exception
+ {
+ super.setUpApplication();
//We need this two components added
- application.addComponent(UIOutput.COMPONENT_TYPE, UIOutput.class.getName());
- application.addComponent(UIPanel.COMPONENT_TYPE, UIPanel.class.getName());
+ application.addComponent(UIOutput.COMPONENT_TYPE, UIOutput.class
+ .getName());
+ application.addComponent(UIPanel.COMPONENT_TYPE, UIPanel.class
+ .getName());
}
- @Override
- public void tearDown() throws Exception
- {
+ @Override
+ public void tearDown() throws Exception
+ {
RuntimeConfig.getCurrentInstance(externalContext).purge();
- application = null;
- config = null;
- externalContext = null;
- facesContext.release();
- facesContext = null;
- lifecycle = null;
- lifecycleFactory = null;
- renderKit = null;
- request = null;
- response = null;
- servletContext = null;
- session = null;
- FactoryFinder.releaseFactories();
-
- Thread.currentThread().setContextClassLoader(threadContextClassLoader);
- threadContextClassLoader = null;
-
- }
+ super.tearDown();
+ }
@FacesBehavior("org.apache.myfaces.component.MockClientBehavior")
@ResourceDependencies({
@@ -195,6 +126,7 @@ public class ClientBehaviorTestCase exte
}
}
+ @Test
public void testAddBehaviorWithResourceDependencies() throws Exception
{
@@ -212,12 +144,12 @@ public class ClientBehaviorTestCase exte
comp.addClientBehavior("click", behavior);
// verify that method still works
- assertTrue(comp.getClientBehaviors().get("click").contains(behavior));
+ Assert.assertTrue(comp.getClientBehaviors().get("click").contains(behavior));
// get behavior resource
List<UIComponent> resources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
- assertEquals(1, resources.size());
+ Assert.assertEquals(1, resources.size());
Map<String,Object> attrMap = resources.get(0).getAttributes();
- assertEquals("test.js", attrMap.get("name"));
+ Assert.assertEquals("test.js", attrMap.get("name"));
}
}
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java Thu Jul 1 20:42:37 2010
@@ -29,14 +29,14 @@ import java.util.Map;
import java.util.Set;
import javax.faces.FactoryFinder;
-import javax.faces.application.ApplicationFactory;
import javax.faces.application.NavigationCase;
import org.apache.myfaces.config.RuntimeConfig;
import org.apache.myfaces.config.element.NavigationRule;
import org.apache.myfaces.config.impl.digester.DigesterFacesConfigUnmarshallerImpl;
-import org.apache.myfaces.test.base.AbstractJsfTestCase;
-import org.apache.myfaces.test.mock.MockApplication;
+import org.apache.myfaces.test.base.junit4.AbstractJsfTestCase;
+import org.junit.Assert;
+import org.junit.Test;
import org.xml.sax.SAXException;
public class NavigationHandlerImplTest extends AbstractJsfTestCase
@@ -44,34 +44,32 @@ public class NavigationHandlerImplTest e
private DigesterFacesConfigUnmarshallerImpl _digesterFacesConfigUnmarshaller;
- public NavigationHandlerImplTest(String name)
+ public NavigationHandlerImplTest()
{
- super(name);
+ super();
}
-
+
@Override
- protected void setUp() throws Exception
+ public void setUp() throws Exception
{
super.setUp();
- //Set myfaces application instance instead mock
- FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
- "org.apache.myfaces.application.ApplicationFactoryImpl");
- ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder
- .getFactory(FactoryFinder.APPLICATION_FACTORY);
- application = (MockApplication) applicationFactory.getApplication();
- facesContext.setApplication(application);
- FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
- "org.apache.myfaces.context.PartialViewContextFactoryImpl");
- FactoryFinder.setFactory(FactoryFinder.EXCEPTION_HANDLER_FACTORY,
- "org.apache.myfaces.context.ExceptionHandlerFactoryImpl");
-
_digesterFacesConfigUnmarshaller = new DigesterFacesConfigUnmarshallerImpl(
externalContext);
}
+
+ @Override
+ protected void setFactories() throws Exception
+ {
+ super.setFactories();
+ FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
+ "org.apache.myfaces.context.PartialViewContextFactoryImpl");
+ }
+
@Override
- protected void tearDown() throws Exception
+ public void tearDown() throws Exception
{
+ _digesterFacesConfigUnmarshaller = null;
super.tearDown();
}
@@ -90,6 +88,7 @@ public class NavigationHandlerImplTest e
}
}
+ @Test
public void testGetSimpleExactMatchRule() throws Exception
{
loadTextFacesConfig("simple-rules-config.xml");
@@ -99,9 +98,10 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, null, "go");
- assertEquals("/b.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/b.jsp", nc.getToViewId(facesContext));
}
+ @Test
public void testHandleSimpleExactMatchRule() throws Exception
{
loadTextFacesConfig("simple-rules-config.xml");
@@ -111,9 +111,10 @@ public class NavigationHandlerImplTest e
nh.handleNavigation(facesContext, null, "go");
- assertEquals("/b.jsp", facesContext.getViewRoot().getViewId());
+ Assert.assertEquals("/b.jsp", facesContext.getViewRoot().getViewId());
}
+ @Test
public void testGetSimpleGlobalExactMatchRule() throws Exception
{
loadTextFacesConfig("simple-global-rules-config.xml");
@@ -123,9 +124,10 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, null, "go");
- assertEquals("/b.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/b.jsp", nc.getToViewId(facesContext));
}
+ @Test
public void testHandleSimpleGlobalExactMatchRule() throws Exception
{
loadTextFacesConfig("simple-global-rules-config.xml");
@@ -135,9 +137,10 @@ public class NavigationHandlerImplTest e
nh.handleNavigation(facesContext, null, "go");
- assertEquals("/b.jsp", facesContext.getViewRoot().getViewId());
+ Assert.assertEquals("/b.jsp", facesContext.getViewRoot().getViewId());
}
+ @Test
public void testGetSimpleMixExactMatchRule() throws Exception
{
loadTextFacesConfig("simple-mix-rules-config.xml");
@@ -147,15 +150,16 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, null, "go");
- assertEquals("/c.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/c.jsp", nc.getToViewId(facesContext));
facesContext.getViewRoot().setViewId("/z.jsp");
nc = nh.getNavigationCase(facesContext, null, "go");
- assertEquals("/b.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/b.jsp", nc.getToViewId(facesContext));
}
+ @Test
public void testHandleSimpleMixExactMatchRule() throws Exception
{
loadTextFacesConfig("simple-mix-rules-config.xml");
@@ -165,15 +169,16 @@ public class NavigationHandlerImplTest e
nh.handleNavigation(facesContext, null, "go");
- assertEquals("/c.jsp", facesContext.getViewRoot().getViewId());
+ Assert.assertEquals("/c.jsp", facesContext.getViewRoot().getViewId());
facesContext.getViewRoot().setViewId("/z.jsp");
nh.handleNavigation(facesContext, null, "go");
- assertEquals("/b.jsp", facesContext.getViewRoot().getViewId());
+ Assert.assertEquals("/b.jsp", facesContext.getViewRoot().getViewId());
}
+ @Test
public void testGetSimplePartialExactMatchRule() throws Exception
{
loadTextFacesConfig("simple-partial-rules-config.xml");
@@ -183,15 +188,16 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, null, "go");
- assertEquals("/cars/b.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/cars/b.jsp", nc.getToViewId(facesContext));
facesContext.getViewRoot().setViewId("/cars/z.jsp");
nc = nh.getNavigationCase(facesContext, null, "go");
- assertEquals("/cars/c.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/cars/c.jsp", nc.getToViewId(facesContext));
}
+ @Test
public void testHandleSimplePartialExactMatchRule() throws Exception
{
loadTextFacesConfig("simple-partial-rules-config.xml");
@@ -201,15 +207,16 @@ public class NavigationHandlerImplTest e
nh.handleNavigation(facesContext, null, "go");
- assertEquals("/cars/b.jsp", facesContext.getViewRoot().getViewId());
+ Assert.assertEquals("/cars/b.jsp", facesContext.getViewRoot().getViewId());
facesContext.getViewRoot().setViewId("/cars/z.jsp");
nh.handleNavigation(facesContext, null, "go");
- assertEquals("/cars/c.jsp", facesContext.getViewRoot().getViewId());
+ Assert.assertEquals("/cars/c.jsp", facesContext.getViewRoot().getViewId());
}
+ @Test
public void testGetSimpleELExactMatchRule() throws Exception
{
loadTextFacesConfig("simple-el-rules-config.xml");
@@ -220,9 +227,10 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "go");
- assertEquals("/b.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/b.jsp", nc.getToViewId(facesContext));
}
+ @Test
public void testGetSimpleELExactMatchRuleFailNullOutcome() throws Exception
{
loadTextFacesConfig("simple-el-rules-config.xml");
@@ -233,7 +241,7 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", null);
- assertNull(nc);
+ Assert.assertNull(nc);
}
public static class TestBean
@@ -249,6 +257,7 @@ public class NavigationHandlerImplTest e
}
}
+ @Test
public void testGetSimpleIfExactMatchRule() throws Exception
{
loadTextFacesConfig("simple-if-rules-config.xml");
@@ -261,9 +270,10 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, null, "go");
- assertEquals("/b.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/b.jsp", nc.getToViewId(facesContext));
}
+ @Test
public void testGetSimpleNotIfExactMatchRule() throws Exception
{
loadTextFacesConfig("simple-if-rules-config.xml");
@@ -276,9 +286,10 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, null, "go");
- assertEquals("/d.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/d.jsp", nc.getToViewId(facesContext));
}
+ @Test
public void testGetSimplePreemptiveIfExactMatchRule() throws Exception
{
loadTextFacesConfig("simple-if-rules-config.xml");
@@ -291,9 +302,10 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, null, "go");
- assertEquals("/go.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/go.jsp", nc.getToViewId(facesContext));
}
+ @Test
public void testGetSimpleGlobalPreemptiveMatchRule() throws Exception
{
loadTextFacesConfig("simple-global-preemptive-rules-config.xml");
@@ -306,9 +318,10 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, null, "go");
- assertEquals("/a.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/a.jsp", nc.getToViewId(facesContext));
}
+ @Test
public void testGetSimpleELNoCondMatchRule() throws Exception
{
loadTextFacesConfig("simple-el-nocond-rules-config.xml");
@@ -319,9 +332,10 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "go");
- assertEquals("/b.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/b.jsp", nc.getToViewId(facesContext));
}
+ @Test
public void testGetSimpleELNoCondNullOutcomeMatchRule() throws Exception
{
loadTextFacesConfig("simple-el-nocond-rules-config.xml");
@@ -332,9 +346,10 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", null);
- assertNull(nc);
+ Assert.assertNull(nc);
}
+ @Test
public void testActionOutcomePrecendeceMachRule() throws Exception
{
loadTextFacesConfig("simple-action-outcome-precedence-config.xml");
@@ -369,10 +384,11 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "go");
- assertEquals("/b.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/b.jsp", nc.getToViewId(facesContext));
}
}
+ @Test
public void testActionOutcomePrecendeceAlternateOutcomeMachRule() throws Exception
{
loadTextFacesConfig("simple-action-outcome-precedence-config.xml");
@@ -407,10 +423,11 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "nogo");
- assertEquals("/c.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/c.jsp", nc.getToViewId(facesContext));
}
}
+ @Test
public void testActionOutcomePrecendeceNoOutcomeMachRule() throws Exception
{
loadTextFacesConfig("simple-action-outcome-precedence-config.xml");
@@ -446,11 +463,11 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", null);
//If the <if> element is absent, only match a non-null outcome
- assertNull(nc);
+ Assert.assertNull(nc);
}
}
-
+ @Test
public void testActionOutcomePrecendece2MachRule() throws Exception
{
loadTextFacesConfig("simple-action-outcome-precedence-2-config.xml");
@@ -485,7 +502,7 @@ public class NavigationHandlerImplTest e
NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "go");
- assertEquals("/b.jsp", nc.getToViewId(facesContext));
+ Assert.assertEquals("/b.jsp", nc.getToViewId(facesContext));
}
}
@@ -493,6 +510,7 @@ public class NavigationHandlerImplTest e
* Tests if the URL parameters of an outcome are correctly
* added to the NavigationCase.
*/
+ @Test
public void testFacesRedirectAddsUrlParameters()
{
NavigationHandlerImpl nh = new NavigationHandlerImpl();
@@ -510,6 +528,6 @@ public class NavigationHandlerImplTest e
// note that faces-redirect and includeViewParams
// should not be added as a parameter
- assertEquals(expected, navigationCase.getParameters());
+ Assert.assertEquals(expected, navigationCase.getParameters());
}
}
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormRendererTest.java?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormRendererTest.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlFormRendererTest.java Thu Jul 1 20:42:37 2010
@@ -53,7 +53,7 @@ public class HtmlFormRendererTest extend
{
super.setUp();
- application.setViewHandler(new MockTestViewHandler());
+ //application.setViewHandler(new MockTestViewHandler());
form = new HtmlForm();
writer = new MockResponseWriter(new StringWriter(), null, null);
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/test/utils/MockTestViewHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/test/utils/MockTestViewHandler.java?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/test/utils/MockTestViewHandler.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/test/utils/MockTestViewHandler.java Thu Jul 1 20:42:37 2010
@@ -28,7 +28,10 @@ import org.apache.myfaces.test.mock.Mock
* UnsupportedOperationException inside writeState().
* This is not needed anymore once the fix for
* SHALE-468 is released.
+ *
+ * @deprecated fixed on myfaces-test
*/
+@Deprecated
public class MockTestViewHandler extends MockViewHandler
{
public void writeState(FacesContext context)
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java Thu Jul 1 20:42:37 2010
@@ -53,7 +53,6 @@ import org.apache.myfaces.config.impl.di
import org.apache.myfaces.config.impl.digester.DigesterFacesConfigUnmarshallerImpl;
import org.apache.myfaces.config.impl.digester.elements.FacesConfig;
import org.apache.myfaces.context.PartialViewContextFactoryImpl;
-import org.apache.myfaces.renderkit.html.HtmlResponseStateManager;
import org.apache.myfaces.shared_impl.application.ViewHandlerSupport;
import org.apache.myfaces.shared_impl.util.ClassUtils;
import org.apache.myfaces.shared_impl.util.StateUtils;
@@ -62,19 +61,23 @@ import org.apache.myfaces.test.el.MockEx
import org.apache.myfaces.test.mock.MockExternalContext;
import org.apache.myfaces.test.mock.MockFacesContext;
import org.apache.myfaces.test.mock.MockFacesContextFactory;
+import org.apache.myfaces.test.mock.MockHttpServletRequest;
+import org.apache.myfaces.test.mock.MockHttpServletResponse;
import org.apache.myfaces.test.mock.MockPropertyResolver;
import org.apache.myfaces.test.mock.MockRenderKit;
+import org.apache.myfaces.test.mock.MockResponseStateManager;
import org.apache.myfaces.test.mock.MockServletContext;
import org.apache.myfaces.test.mock.MockVariableResolver;
import org.apache.myfaces.test.mock.lifecycle.MockLifecycle;
import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
import org.apache.myfaces.test.mock.visit.MockVisitContextFactory;
-import org.apache.myfaces.view.facelets.mock.MockHttpServletRequest;
-import org.apache.myfaces.view.facelets.mock.MockHttpServletResponse;
import org.apache.myfaces.view.facelets.mock.MockResourceHandlerSupport;
import org.apache.myfaces.view.facelets.mock.MockViewDeclarationLanguageFactory;
import org.apache.myfaces.view.facelets.tag.jsf.TagHandlerDelegateFactoryImpl;
+//import org.apache.myfaces.view.facelets.mock.MockHttpServletRequest;
+//import org.apache.myfaces.view.facelets.mock.MockHttpServletResponse;
+
public abstract class FaceletTestCase extends TestCase
{
private final String filePath = this.getDirectory();
@@ -139,8 +142,10 @@ public abstract class FaceletTestCase ex
URI context = this.getContext();
this.servletContext = new MockServletContext();
- this.servletRequest = new MockHttpServletRequest(this.servletContext,
- context);
+ //this.servletRequest = new MockHttpServletRequest(this.servletContext,
+ // context);
+ this.servletRequest = new MockHttpServletRequest(context.getPath(), null, context.getPath(), context.getQuery());
+ servletRequest.setServletContext(this.servletContext);
this.servletResponse = new MockHttpServletResponse();
externalContext = new MockExternalContext(servletContext,
@@ -188,7 +193,7 @@ public abstract class FaceletTestCase ex
.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
renderKit = new MockRenderKit()
{
- ResponseStateManager rsm = new HtmlResponseStateManager();
+ ResponseStateManager rsm = new MockResponseStateManager();
@Override
public ResponseStateManager getResponseStateManager()
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/SelectTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/SelectTestCase.java?rev=959777&r1=959776&r2=959777&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/SelectTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/SelectTestCase.java Thu Jul 1 20:42:37 2010
@@ -84,7 +84,7 @@ public class SelectTestCase extends Face
public void testSelectOne() throws Exception
{
this.servletRequest.getSession().setAttribute("test", new TestBean());
- this.servletRequest.setParameter("testForm:alignment", "10");
+ this.servletRequest.addParameter("testForm:alignment", "10");
UIViewRoot root = new UIViewRoot();
vdl.buildView(facesContext, root,"selectOne.xml");