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/02 02:31:08 UTC
svn commit: r959818 [1/2] - in /myfaces/core/trunk: ./ api/
api/src/test/java/javax/faces/application/
api/src/test/java/javax/faces/convert/ impl/
impl/src/test/java/org/apache/myfaces/view/facelets/
impl/src/test/java/org/apache/myfaces/view/facelets...
Author: lu4242
Date: Fri Jul 2 00:31:07 2010
New Revision: 959818
URL: http://svn.apache.org/viewvc?rev=959818&view=rev
Log:
MYFACESTEST-14 Update myfaces-test to use JUnit 4.x (update facelets test, use maven surefire plugin 2.5 and fix problem junit tests not run because we have TestNG tests and those are junit 3 compatible)
Modified:
myfaces/core/trunk/api/pom.xml
myfaces/core/trunk/api/src/test/java/javax/faces/application/ApplicationTest.java
myfaces/core/trunk/api/src/test/java/javax/faces/convert/NumberConverterTest.java
myfaces/core/trunk/impl/pom.xml
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/BrokenTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/EncodingTestCase.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/InstructionsTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/TagTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateClientTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/ELParserTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/TagLibraryTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/WhitespaceTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentAttributeTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentClientBehaviorTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/CoreTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValidateBeanTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/DataTableTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlOutputLabelTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlOutputScriptTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/SelectTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/TestNbsp.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jstl/core/JstlCoreTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/DefineIncludeTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/IncludeParamTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/TemplateTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/TestUserTags.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/UITestCase.java
myfaces/core/trunk/pom.xml
Modified: myfaces/core/trunk/api/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/pom.xml?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/api/pom.xml (original)
+++ myfaces/core/trunk/api/pom.xml Fri Jul 2 00:31:07 2010
@@ -314,6 +314,46 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.5</version>
+ <executions>
+ <execution>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <testNGArtifactName>none:none</testNGArtifactName>
+ <!-- Exclude all TestNG tests -->
+ <excludes>
+ <exclude>**/UIViewRootTest*</exclude>
+ <exclude>**/_MessageUtilsTest*</exclude>
+ <exclude>**/UIGraphicTest*</exclude>
+ <exclude>**/UIComponentValueExpressionTest*</exclude>
+ <exclude>**/UIComponentTest*</exclude>
+ <exclude>**/UIComponentInvokeOnComponentTest*</exclude>
+ <exclude>**/UIComponentEncodeAllTest*</exclude>
+ <exclude>**/UIComponentBaseValueBindingTest*</exclude>
+ <exclude>**/UIComponentBaseTest*</exclude>
+ <exclude>**/UIComponentBaseProcessSaveRestoreStateTest*</exclude>
+ <exclude>**/UIComponentBaseFacesListenerTest*</exclude>
+ <exclude>**/HtmlOutputLinkTest*</exclude>
+ </excludes>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-testng</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <junitArtifactName>none:none</junitArtifactName>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<profiles>
@@ -569,7 +609,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
- <version>2.4.3</version>
+ <version>2.5</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
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=959818&r1=959817&r2=959818&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 Fri Jul 2 00:31:07 2010
@@ -23,6 +23,7 @@ import javax.el.ValueExpression;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.NoOp;
+import org.apache.myfaces.test.base.junit4.AbstractJsfTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -33,19 +34,24 @@ import org.junit.Test;
* @author Mathias Broekelmann (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class ApplicationTest
+public class ApplicationTest extends AbstractJsfTestCase
{
+ public ApplicationTest()
+ {
+ }
+
private Application app;
- @Before
public void setUp() throws Exception
{
+ super.setUp();
app = (Application) Enhancer.create(Application.class, NoOp.INSTANCE);
}
- @After
public void tearDown() throws Exception
{
+ app = null;
+ super.tearDown();
}
/**
Modified: myfaces/core/trunk/api/src/test/java/javax/faces/convert/NumberConverterTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/test/java/javax/faces/convert/NumberConverterTest.java?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/test/java/javax/faces/convert/NumberConverterTest.java (original)
+++ myfaces/core/trunk/api/src/test/java/javax/faces/convert/NumberConverterTest.java Fri Jul 2 00:31:07 2010
@@ -21,9 +21,12 @@ package javax.faces.convert;
import java.util.Locale;
+import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import org.apache.myfaces.test.base.AbstractJsfTestCase;
+import org.junit.Ignore;
+import org.junit.Test;
public class NumberConverterTest extends AbstractJsfTestCase
{
@@ -46,7 +49,8 @@ public class NumberConverterTest extends
mock = new NumberConverter();
mock.setLocale(Locale.FRANCE);
- FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY);
+ FacesContext.getCurrentInstance().getViewRoot().setLocale(
+ Locale.GERMANY);
}
@@ -57,15 +61,30 @@ public class NumberConverterTest extends
mock = null;
}
+
/*
- * temporarily comment out tests that fail, until Matthias Wessendorf has time to investigate public void
- * testFranceLocaleWithNonBreakingSpace() {
- *
- * UIInput input = new UIInput(); mock.setType("currency"); Number number = (Number)
- * mock.getAsObject(FacesContext.getCurrentInstance(), input, "12\u00a0345,68 \u20ac"); assertNotNull(number); } public
- * void testFranceLocaleWithoutNonBreakingSpace() {
- *
- * UIInput input = new UIInput(); mock.setType("currency"); Number number = (Number)
- * mock.getAsObject(FacesContext.getCurrentInstance(), input, "12 345,68 \u20ac"); assertNotNull(number); }
+ * temporarily comment out tests that fail, until Matthias Wessendorf has time to investigate
*/
+ @Ignore
+ public void testFranceLocaleWithNonBreakingSpace()
+ {
+
+ UIInput input = new UIInput();
+ mock.setType("currency");
+ Number number = (Number) mock.getAsObject(FacesContext
+ .getCurrentInstance(), input, "12\u00a0345,68 \u20ac");
+ assertNotNull(number);
+ }
+
+ @Ignore
+ public void testFranceLocaleWithoutNonBreakingSpace()
+ {
+
+ UIInput input = new UIInput();
+ mock.setType("currency");
+ Number number = (Number) mock.getAsObject(FacesContext
+ .getCurrentInstance(), input, "12 345,68 \u20ac");
+ assertNotNull(number);
+ }
+
}
Modified: myfaces/core/trunk/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/pom.xml?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/impl/pom.xml (original)
+++ myfaces/core/trunk/impl/pom.xml Fri Jul 2 00:31:07 2010
@@ -284,15 +284,50 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.3.1</version>
+ <version>2.5</version>
<configuration>
<excludes>
<exclude>**/JspStateManagerImplTest*</exclude>
<exclude>**/DefaultViewHandlerSupportTest*</exclude>
<exclude>**/ApplicationImplTest*</exclude>
- <exclude>**/ApplicationImplAnnotationTest*</exclude>
</excludes>
</configuration>
+ <executions>
+ <execution>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <testNGArtifactName>none:none</testNGArtifactName>
+ <!-- Exclude all TestNG tests -->
+ <excludes>
+ <exclude>**/CompositeELResolverTest*</exclude>
+ <exclude>**/TestResourceComponent*</exclude>
+ <exclude>**/ResolverBuilderBaseTest*</exclude>
+ <exclude>**/TestLifecycleProvider*</exclude>
+ <exclude>**/TestBean*</exclude>
+ <exclude>**/TestLifecycleProvider2*</exclude>
+ <exclude>**/TestAttributeBean*</exclude>
+ <exclude>**/TestDiscoverableLifecycleProvider*</exclude>
+ <!-- Other tests to exclude -->
+ <exclude>**/JspStateManagerImplTest*</exclude>
+ <exclude>**/DefaultViewHandlerSupportTest*</exclude>
+ <exclude>**/ApplicationImplTest*</exclude>
+ </excludes>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-testng</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <junitArtifactName>none:none</junitArtifactName>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
@@ -1028,9 +1063,8 @@
<version>2.0-beta-1</version>
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>surefire-report-maven-plugin</artifactId>
- <version>2.0-beta-1</version>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <version>2.5</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/BrokenTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/BrokenTestCase.java?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/BrokenTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/BrokenTestCase.java Fri Jul 2 00:31:07 2010
@@ -20,8 +20,11 @@ package org.apache.myfaces.view.facelets
import javax.faces.component.UIViewRoot;
+import org.junit.Test;
+
public class BrokenTestCase extends FaceletTestCase {
+ @Test
public void testBroken() throws Exception {
}
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/EncodingTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/EncodingTestCase.java?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/EncodingTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/EncodingTestCase.java Fri Jul 2 00:31:07 2010
@@ -26,6 +26,7 @@ import javax.faces.component.UIViewRoot;
import org.apache.myfaces.view.facelets.util.FastWriter;
import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.junit.Test;
public class EncodingTestCase extends FaceletTestCase
{
@@ -47,6 +48,7 @@ public class EncodingTestCase extends Fa
{
}
+ @Test
public void testPattern() throws Exception
{
Pattern p = Pattern
@@ -68,9 +70,10 @@ public class EncodingTestCase extends Fa
}
}
+ @Test
public void testEncoding() throws Exception
{
- this.servletRequest.setAttribute("name", "Mr. Hookom");
+ request.setAttribute("name", "Mr. Hookom");
UIViewRoot root = facesContext.getViewRoot();
vdl.buildView(facesContext, root, "encoding.xml");
FastWriter fw = new FastWriter();
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=959818&r1=959817&r2=959818&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 Fri Jul 2 00:31:07 2010
@@ -28,19 +28,14 @@ import java.net.URL;
import javax.faces.FacesException;
import javax.faces.FactoryFinder;
-import javax.faces.application.ApplicationFactory;
import javax.faces.application.ProjectStage;
import javax.faces.application.StateManager;
+import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import javax.faces.lifecycle.LifecycleFactory;
import javax.faces.render.RenderKitFactory;
-import javax.faces.render.ResponseStateManager;
-
-import junit.framework.TestCase;
import org.apache.myfaces.application.ApplicationFactoryImpl;
-import org.apache.myfaces.application.ApplicationImpl;
import org.apache.myfaces.application.ResourceHandlerImpl;
import org.apache.myfaces.application.ViewHandlerImpl;
import org.apache.myfaces.config.FacesConfigDispenser;
@@ -55,46 +50,45 @@ import org.apache.myfaces.config.impl.di
import org.apache.myfaces.context.PartialViewContextFactoryImpl;
import org.apache.myfaces.shared_impl.application.ViewHandlerSupport;
import org.apache.myfaces.shared_impl.util.ClassUtils;
-import org.apache.myfaces.shared_impl.util.StateUtils;
-import org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory;
+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.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.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
+public abstract class FaceletTestCase extends AbstractJsfConfigurableMockTestCase
{
- private final String filePath = this.getDirectory();
- protected MockServletContext servletContext;
- protected MockHttpServletRequest servletRequest;
- protected MockHttpServletResponse servletResponse;
- protected MockExternalContext externalContext;
- protected MockFacesContext facesContext;
- protected MockFacesContextFactory facesContextFactory;
- protected MockLifecycle lifecycle;
- protected MockLifecycleFactory lifecycleFactory;
- protected ApplicationImpl application;
- protected MockRenderKit renderKit;
- protected MockFaceletViewDeclarationLanguage vdl;
-
+ private final String filePath = this.getDirectory();
protected FacesConfigDispenser<FacesConfig> dispenser = null;
+ protected MockFaceletViewDeclarationLanguage vdl;
+
+ @Override
+ protected void setUpServletObjects() throws Exception
+ {
+ URI context = this.getContext();
+ super.setUpServletObjects();
+ request.setPathElements(context.getPath(), null, context.getPath(), context.getQuery());
+ servletContext.setDocumentRoot(new File(context));
+
+ //This params are optional
+ servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME,
+ StateManager.STATE_SAVING_METHOD_CLIENT);
+ servletContext.addInitParameter("org.apache.myfaces.PRETTY_HTML","true");
+ servletContext.addInitParameter("org.apache.myfaces.ALLOW_JAVASCRIPT","true");
+ servletContext.addInitParameter("org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON","false");
+ servletContext.addInitParameter("org.apache.myfaces.SAVE_FORM_SUBMIT_LINK_IE","false");
+ servletContext.addInitParameter("org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS","true");
+ servletContext.addInitParameter("org.apache.myfaces.RENDER_VIEWSTATE_ID","true");
+ servletContext.addInitParameter("org.apache.myfaces.STRICT_XHTML_LINKS","true");
+ servletContext.addInitParameter("org.apache.myfaces.CONFIG_REFRESH_PERIOD","0");
+ servletContext.addInitParameter("org.apache.myfaces.VIEWSTATE_JAVASCRIPT","false");
+ servletContext.addInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, "UnitTest");
+ }
+
protected URI getContext()
{
try
@@ -136,88 +130,72 @@ public abstract class FaceletTestCase ex
+ "/";
}
- protected void setUp() throws Exception
+ @Override
+ protected void setFactories() throws Exception
{
- super.setUp();
- URI context = this.getContext();
-
- this.servletContext = new MockServletContext();
- //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();
+ super.setFactories();
- externalContext = new MockExternalContext(servletContext,
- servletRequest, servletResponse);
-
- this.servletContext.setDocumentRoot(new File(context));
-
- // Set up JSF API Objects
- FactoryFinder.releaseFactories();
+ 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,
+ MockViewDeclarationLanguageFactory.class.getName());
+ FactoryFinder.setFactory(FactoryFinder.TAG_HANDLER_DELEGATE_FACTORY,
+ TagHandlerDelegateFactoryImpl.class.getName());
+ FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
+ PartialViewContextFactoryImpl.class.getName());
+ FactoryFinder.setFactory(FactoryFinder.VISIT_CONTEXT_FACTORY,
+ MockVisitContextFactory.class.getName());
+ }
+
+ @Override
+ protected void setUpExternalContext() throws Exception
+ {
+ super.setUpExternalContext();
- setupRuntimeConfigAndFactories();
-
- 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, servletRequest, servletResponse, lifecycle);
- externalContext = (MockExternalContext) facesContext
- .getExternalContext();
- ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder
- .getFactory(FactoryFinder.APPLICATION_FACTORY);
- application = (ApplicationImpl) applicationFactory.getApplication();
- facesContext.setApplication(application);
- StateUtils.initSecret(servletContext);
- externalContext.getApplicationMap().put(StateUtils.SERIAL_FACTORY,
- new DefaultSerialFactory());
-
- servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME,
- StateManager.STATE_SAVING_METHOD_CLIENT);
- servletContext.addInitParameter("org.apache.myfaces.PRETTY_HTML","true");
- servletContext.addInitParameter("org.apache.myfaces.ALLOW_JAVASCRIPT","true");
- servletContext.addInitParameter("org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON","false");
- servletContext.addInitParameter("org.apache.myfaces.SAVE_FORM_SUBMIT_LINK_IE","false");
- servletContext.addInitParameter("org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS","true");
- servletContext.addInitParameter("org.apache.myfaces.RENDER_VIEWSTATE_ID","true");
- servletContext.addInitParameter("org.apache.myfaces.STRICT_XHTML_LINKS","true");
- servletContext.addInitParameter("org.apache.myfaces.CONFIG_REFRESH_PERIOD","0");
- servletContext.addInitParameter("org.apache.myfaces.VIEWSTATE_JAVASCRIPT","false");
- servletContext.addInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, "UnitTest");
-
- RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder
- .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- renderKit = new MockRenderKit()
- {
- ResponseStateManager rsm = new MockResponseStateManager();
-
- @Override
- public ResponseStateManager getResponseStateManager()
- {
- return rsm;
- }
- };
- renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT,
- renderKit);
-
+ RuntimeConfig.getCurrentInstance(externalContext).setPropertyResolver(
+ new MockPropertyResolver());
+ RuntimeConfig.getCurrentInstance(externalContext).setVariableResolver(
+ new MockVariableResolver());
+ RuntimeConfig.getCurrentInstance(externalContext).setExpressionFactory(
+ new MockExpressionFactory());
+ }
+
+ @Override
+ protected void setUpRenderKit() throws Exception
+ {
+ super.setUpRenderKit();
setupComponents();
setupConvertersAndValidators();
setupBehaviors();
setupRenderers();
-
- // Redirect resource request to the directory where the test class is,
- // to make easier test composite components.
- ((ResourceHandlerImpl)application.getResourceHandler()).
- setResourceHandlerSupport(new MockResourceHandlerSupport(this.getClass()));
- //Compiler c = new SAXCompiler();
- //c.setTrimmingWhitespace(true);
- //FaceletFactory factory = new DefaultFaceletFactory(c, this);
- //FaceletFactory.setInstance(factory);
+ //Finally set the ResponseWriter
+ ResponseWriter rw = facesContext.getRenderKit().createResponseWriter(
+ new StringWriter(), null, null);
+ facesContext.setResponseWriter(rw);
+ }
+
+ @Override
+ protected void setUpView() throws Exception
+ {
+ UIViewRoot root = new UIViewRoot();
+ root.setViewId("/test");
+ root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+ facesContext.setViewRoot(root);
+ }
+
+ @Override
+ protected void setUpApplication() throws Exception
+ {
+ super.setUpApplication();
+
ViewHandlerImpl viewHandler = (ViewHandlerImpl) facesContext.getApplication().getViewHandler();
viewHandler.setViewHandlerSupport(new ViewHandlerSupport(){
@@ -237,64 +215,26 @@ public abstract class FaceletTestCase ex
return viewId;
}
- });
+ });
- facesContext.setViewRoot(facesContext.getApplication().getViewHandler()
- .createView(facesContext, "/test"));
+ // Redirect resource request to the directory where the test class is,
+ // to make easier test composite components.
+ ((ResourceHandlerImpl)application.getResourceHandler()).
+ setResourceHandlerSupport(new MockResourceHandlerSupport(this.getClass()));
+ }
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ //facesContext.setViewRoot(facesContext.getApplication().getViewHandler()
+ // .createView(facesContext, "/test"));
vdl = (MockFaceletViewDeclarationLanguage) application.getViewHandler().
getViewDeclarationLanguage(facesContext,"/test");
- ResponseWriter rw = facesContext.getRenderKit().createResponseWriter(
- new StringWriter(), null, null);
- facesContext.setResponseWriter(rw);
}
- protected void tearDown() throws Exception
- {
- super.tearDown();
- this.servletContext = null;
- servletRequest = null;
- servletResponse = null;
- externalContext = null;
- facesContext = null;
- facesContextFactory = null;
- lifecycle = null;
- lifecycleFactory = null;
- application = null;
- renderKit = null;
- vdl = null;
- }
-
- protected void setupRuntimeConfigAndFactories()
- {
- RuntimeConfig.getCurrentInstance(externalContext).setPropertyResolver(
- new MockPropertyResolver());
- RuntimeConfig.getCurrentInstance(externalContext).setVariableResolver(
- new MockVariableResolver());
- RuntimeConfig.getCurrentInstance(externalContext).setExpressionFactory(
- new MockExpressionFactory());
- //To make work ValueExpressions
-
- 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,
- MockViewDeclarationLanguageFactory.class.getName());
- FactoryFinder.setFactory(FactoryFinder.TAG_HANDLER_DELEGATE_FACTORY,
- TagHandlerDelegateFactoryImpl.class.getName());
- FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
- PartialViewContextFactoryImpl.class.getName());
- FactoryFinder.setFactory(FactoryFinder.VISIT_CONTEXT_FACTORY,
- MockVisitContextFactory.class.getName());
- }
-
protected void loadStandardFacesConfig() throws Exception
{
if (dispenser == null)
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/InstructionsTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/InstructionsTestCase.java?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/InstructionsTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/InstructionsTestCase.java Fri Jul 2 00:31:07 2010
@@ -24,6 +24,7 @@ import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.apache.myfaces.view.facelets.util.FastWriter;
+import org.junit.Test;
public class InstructionsTestCase extends FaceletTestCase
{
@@ -45,6 +46,7 @@ public class InstructionsTestCase extend
{
}
+ @Test
public void testInstructions() throws Exception
{
UIViewRoot root = facesContext.getViewRoot();
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/TagTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/TagTestCase.java?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/TagTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/TagTestCase.java Fri Jul 2 00:31:07 2010
@@ -27,6 +27,7 @@ import javax.faces.context.FacesContext;
import org.apache.myfaces.renderkit.html.HtmlTextRenderer;
import org.apache.myfaces.view.facelets.util.FastWriter;
import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.junit.Test;
public class TagTestCase extends FaceletTestCase {
@@ -52,8 +53,9 @@ public class TagTestCase extends Facelet
"javax.faces.Text", new HtmlTextRenderer());
}
+ @Test
public void testTagBody() throws Exception {
- this.servletRequest.setAttribute("name", "Mr. Hookom");
+ request.setAttribute("name", "Mr. Hookom");
UIViewRoot root = facesContext.getViewRoot();
vdl.buildView(facesContext, root,"userTag.xhtml");
FastWriter fw = new FastWriter();
@@ -63,6 +65,7 @@ public class TagTestCase extends Facelet
//System.out.println(fw);
}
+ @Test
public void testConditionalInsert() throws Exception {
UIViewRoot root = facesContext.getViewRoot();
vdl.buildView(facesContext, root,"userTagConditional.xhtml");
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateClientTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateClientTestCase.java?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateClientTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/TemplateClientTestCase.java Fri Jul 2 00:31:07 2010
@@ -22,6 +22,7 @@ import javax.faces.component.UIViewRoot;
import org.apache.myfaces.view.facelets.util.FastWriter;
import org.apache.myfaces.test.mock.MockResponseWriter;
+import org.junit.Test;
public class TemplateClientTestCase extends FaceletTestCase {
@@ -42,8 +43,9 @@ public class TemplateClientTestCase exte
{
}
+ @Test
public void testClientClient() throws Exception {
- this.servletRequest.setAttribute("name", "Mr. Hookom");
+ request.setAttribute("name", "Mr. Hookom");
UIViewRoot root = facesContext.getViewRoot();
vdl.buildView(facesContext, root,"template-client-client.xhtml");
FastWriter fw = new FastWriter();
@@ -53,25 +55,19 @@ public class TemplateClientTestCase exte
//System.out.println(fw);
}
- /*
- public void testLayoutClient() throws Exception {
- FaceletFactory ff = FaceletFactory.getInstance();
- FacesContext faces = FacesContext.getCurrentInstance();
-
- Facelet f = ff.getFacelet("layout-client.xhtml");
-
- this.servletRequest.setAttribute("name", "Mr. Hookom");
+ @Test
+ public void testLayoutClient() throws Exception
+ {
+ request.setAttribute("name", "Mr. Hookom");
- UIViewRoot root = faces.getViewRoot();
- f.apply(faces, root);
+ UIViewRoot root = facesContext.getViewRoot();
+ vdl.buildView(facesContext, root,"layout-client.xhtml");
FastWriter fw = new FastWriter();
MockResponseWriter mrw = new MockResponseWriter(fw);
- faces.setResponseWriter(mrw);
- root.encodeAll(faces);
- System.out.println(fw);
+ facesContext.setResponseWriter(mrw);
+ root.encodeAll(facesContext);
+ //System.out.println(fw);
}
- */
-
}
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/ELParserTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/ELParserTestCase.java?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/ELParserTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/ELParserTestCase.java Fri Jul 2 00:31:07 2010
@@ -31,6 +31,7 @@ import org.apache.myfaces.view.facelets.
import org.apache.myfaces.view.facelets.FaceletFactory;
import org.apache.myfaces.view.facelets.FaceletTestCase;
import org.apache.myfaces.view.facelets.util.FastWriter;
+import org.junit.Test;
public class ELParserTestCase extends FaceletTestCase {
@@ -57,8 +58,9 @@ public class ELParserTestCase extends Fa
"javax.faces.Text", new HtmlTextRenderer());
}
+ @Test
public void testSelectOneMenu() throws Exception {
- this.servletRequest.setAttribute("test", this);
+ request.setAttribute("test", this);
UIViewRoot root = facesContext.getViewRoot();
vdl.buildView(facesContext, root, "elparser.xml");
@@ -71,7 +73,7 @@ public class ELParserTestCase extends Fa
//System.out.println(fw);
}
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
this.target = null;
}
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/TagLibraryTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/TagLibraryTestCase.java?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/TagLibraryTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/TagLibraryTestCase.java Fri Jul 2 00:31:07 2010
@@ -19,13 +19,13 @@
package org.apache.myfaces.view.facelets.compiler;
import java.io.File;
-import java.io.IOException;
import java.net.URL;
import org.apache.myfaces.shared_impl.config.MyfacesConfig;
import org.apache.myfaces.view.facelets.FaceletTestCase;
import org.apache.myfaces.view.facelets.tag.TagLibrary;
-import org.xml.sax.SAXException;
+import org.junit.Assert;
+import org.junit.Test;
public class TagLibraryTestCase extends FaceletTestCase
@@ -49,20 +49,22 @@ public class TagLibraryTestCase extends
servletContext.setDocumentRoot(documentRoot);
}
+ @Test
public void testLoadValidLibraryWithValidation() throws Exception
{
servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_VALIDATE_XML, "true");
TagLibrary lib = TagLibraryConfig.create(_validLibUrl);
- assertTrue(lib.containsNamespace("http://myfaces.apache.org/testlib"));
+ Assert.assertTrue(lib.containsNamespace("http://myfaces.apache.org/testlib"));
}
+ @Test
public void testLoadValidLibraryWithoutValidation() throws Exception
{
servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_VALIDATE_XML, "false");
TagLibrary lib = TagLibraryConfig.create(_validLibUrl);
- assertTrue(lib.containsNamespace("http://myfaces.apache.org/testlib"));
+ Assert.assertTrue(lib.containsNamespace("http://myfaces.apache.org/testlib"));
}
/*
public void testLoadInvalidLibraryWithValidation() throws Exception
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/WhitespaceTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/WhitespaceTestCase.java?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/WhitespaceTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/WhitespaceTestCase.java Fri Jul 2 00:31:07 2010
@@ -30,18 +30,16 @@ import javax.faces.component.html.HtmlFo
import javax.faces.component.html.HtmlOutputText;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.component.html.HtmlSelectOneMenu;
-import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.apache.myfaces.renderkit.html.HtmlFormRenderer;
import org.apache.myfaces.renderkit.html.HtmlGridRenderer;
import org.apache.myfaces.renderkit.html.HtmlMenuRenderer;
-import org.apache.myfaces.renderkit.html.HtmlRadioRenderer;
import org.apache.myfaces.renderkit.html.HtmlTextRenderer;
-import org.apache.myfaces.view.facelets.Facelet;
-import org.apache.myfaces.view.facelets.FaceletFactory;
import org.apache.myfaces.view.facelets.FaceletTestCase;
import org.apache.myfaces.view.facelets.util.FastWriter;
+import org.junit.Assert;
+import org.junit.Test;
public class WhitespaceTestCase extends FaceletTestCase {
@@ -83,14 +81,15 @@ public class WhitespaceTestCase extends
}
+ @Test
public void testSelectOneMenu() throws Exception {
- this.servletRequest.setAttribute("test", this);
+ request.setAttribute("test", this);
UIViewRoot root = facesContext.getViewRoot();
vdl.buildView(facesContext, root, "selectOne.xml");
- assertNotNull("target binding", target);
- assertEquals("children", 2, this.target.getChildCount());
+ Assert.assertNotNull("target binding", target);
+ Assert.assertEquals("children", 2, this.target.getChildCount());
FastWriter fw = new FastWriter();
ResponseWriter rw = facesContext.getResponseWriter();
@@ -100,14 +99,15 @@ public class WhitespaceTestCase extends
//System.out.println(fw);
}
+ @Test
public void testPanelGrid() throws Exception {
- this.servletRequest.setAttribute("test", this);
+ request.setAttribute("test", this);
UIViewRoot root = facesContext.getViewRoot();
vdl.buildView(facesContext, root, "panelGrid.xml");
- assertNotNull("target binding", target);
- assertEquals("children", 3, this.target.getChildCount());
+ Assert.assertNotNull("target binding", target);
+ Assert.assertEquals("children", 3, this.target.getChildCount());
FastWriter fw = new FastWriter();
ResponseWriter rw = facesContext.getResponseWriter();
@@ -117,7 +117,7 @@ public class WhitespaceTestCase extends
//System.out.println(fw);
}
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
this.target = null;
}
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentAttributeTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentAttributeTestCase.java?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentAttributeTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentAttributeTestCase.java Fri Jul 2 00:31:07 2010
@@ -38,6 +38,8 @@ import org.apache.myfaces.test.utils.Htm
import org.apache.myfaces.test.utils.HtmlRenderedAttr;
import org.apache.myfaces.view.facelets.FaceletTestCase;
import org.apache.myfaces.view.facelets.bean.DummyBean;
+import org.junit.Assert;
+import org.junit.Test;
public class CompositeComponentAttributeTestCase extends FaceletTestCase
{
@@ -55,6 +57,7 @@ public class CompositeComponentAttribute
*
* @throws Exception
*/
+ @Test
public void testSimpleCompositeAttribute() throws Exception
{
TestAttributeBean bean = new TestAttributeBean();
@@ -66,30 +69,30 @@ public class CompositeComponentAttribute
vdl.buildView(facesContext, root, "testSimpleAttributeVE.xhtml");
UIComponent panelGroup1 = root.findComponent("testGroup1");
- assertNotNull(panelGroup1);
+ Assert.assertNotNull(panelGroup1);
CompositeTestComponent compositeComponent1 = (CompositeTestComponent) panelGroup1.getChildren().get(0);
- assertNotNull(compositeComponent1);
+ Assert.assertNotNull(compositeComponent1);
UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME);
- assertNotNull(facet1);
+ Assert.assertNotNull(facet1);
HtmlOutputText text1 = (HtmlOutputText) facet1.findComponent("text");
- assertNotNull(text1);
+ Assert.assertNotNull(text1);
HtmlCommandButton button1 = (HtmlCommandButton) facet1.findComponent("button");
- assertNotNull(button1);
+ Assert.assertNotNull(button1);
compositeComponent1.pushComponentToEL(facesContext, compositeComponent1);
facet1.pushComponentToEL(facesContext, facet1);
text1.pushComponentToEL(facesContext, text1);
//set on tag
- assertEquals(bean.getStyleClass(), text1.getStyleClass());
+ Assert.assertEquals(bean.getStyleClass(), text1.getStyleClass());
//set as default
- assertEquals(bean.getStyle(), text1.getStyle());
+ Assert.assertEquals(bean.getStyle(), text1.getStyle());
- assertEquals(bean.getJavaProperty(), text1.getValue());
+ Assert.assertEquals(bean.getJavaProperty(), text1.getValue());
text1.popComponentFromEL(facesContext);
button1.pushComponentToEL(facesContext, button1);
MethodExpression method = button1.getActionExpression();
- assertEquals(bean.doSomethingFunny("xysj"), method.invoke(facesContext.getELContext(), new Object[]{"xysj"}));
+ Assert.assertEquals(bean.doSomethingFunny("xysj"), method.invoke(facesContext.getELContext(), new Object[]{"xysj"}));
button1.popComponentFromEL(facesContext);
facet1.popComponentFromEL(facesContext);
compositeComponent1.popComponentFromEL(facesContext);
@@ -113,6 +116,7 @@ public class CompositeComponentAttribute
*
* @throws Exception
*/
+ @Test
public void testSimpleCompositeAttributeInsertChildren() throws Exception
{
TestAttributeBean bean = new TestAttributeBean();
@@ -124,34 +128,34 @@ public class CompositeComponentAttribute
vdl.buildView(facesContext, root, "testSimpleAttributeVEInsertChildren.xhtml");
UIComponent panelGroup1 = root.findComponent("testGroup1");
- assertNotNull(panelGroup1);
+ Assert.assertNotNull(panelGroup1);
CompositeTestComponent compositeComponent1 = (CompositeTestComponent) panelGroup1.getChildren().get(0);
- assertNotNull(compositeComponent1);
+ Assert.assertNotNull(compositeComponent1);
UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME);
- assertNotNull(facet1);
+ Assert.assertNotNull(facet1);
UIComponent compositeComponent2 = facet1.getChildren().get(0);
- assertNotNull(compositeComponent2);
+ Assert.assertNotNull(compositeComponent2);
UIComponent facet2 = compositeComponent2.getFacet(UIComponent.COMPOSITE_FACET_NAME);
- assertNotNull(facet2);
+ Assert.assertNotNull(facet2);
HtmlOutputText text1 = (HtmlOutputText) facet2.findComponent("text");
- assertNotNull(text1);
+ Assert.assertNotNull(text1);
HtmlCommandButton button1 = (HtmlCommandButton) facet2.findComponent("button");
- assertNotNull(button1);
+ Assert.assertNotNull(button1);
compositeComponent1.pushComponentToEL(facesContext, compositeComponent1);
facet1.pushComponentToEL(facesContext, facet1);
text1.pushComponentToEL(facesContext, text1);
//set on tag
- assertEquals(bean.getStyleClass(), text1.getStyleClass());
+ Assert.assertEquals(bean.getStyleClass(), text1.getStyleClass());
//set as default
- assertEquals(bean.getStyle(), text1.getStyle());
+ Assert.assertEquals(bean.getStyle(), text1.getStyle());
- assertEquals(bean.getJavaProperty(), text1.getValue());
+ Assert.assertEquals(bean.getJavaProperty(), text1.getValue());
text1.popComponentFromEL(facesContext);
button1.pushComponentToEL(facesContext, button1);
MethodExpression method = button1.getActionExpression();
- assertEquals(bean.doSomethingFunny("xysj"), method.invoke(facesContext.getELContext(), new Object[]{"xysj"}));
+ Assert.assertEquals(bean.doSomethingFunny("xysj"), method.invoke(facesContext.getELContext(), new Object[]{"xysj"}));
button1.popComponentFromEL(facesContext);
facet1.popComponentFromEL(facesContext);
compositeComponent1.popComponentFromEL(facesContext);
@@ -171,6 +175,7 @@ public class CompositeComponentAttribute
}
+ @Test
public void testSimpleMethodInvocation() throws Exception
{
DummyBean dummyBean = new DummyBean();
@@ -182,27 +187,27 @@ public class CompositeComponentAttribute
vdl.buildView(facesContext, root, "testSimpleMethodInvocation.xhtml");
UIComponent panelGroup1 = root.findComponent("testGroup1");
- assertNotNull(panelGroup1);
+ Assert.assertNotNull(panelGroup1);
UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0);
- assertNotNull(compositeComponent1);
+ Assert.assertNotNull(compositeComponent1);
UIComponent facet1 = compositeComponent1.getFacet(UIComponent.COMPOSITE_FACET_NAME);
- assertNotNull(facet1);
+ Assert.assertNotNull(facet1);
UINamingContainer compositeComponent2 = (UINamingContainer) facet1.getChildren().get(0);
- assertNotNull(compositeComponent2);
+ Assert.assertNotNull(compositeComponent2);
UIComponent facet2 = compositeComponent2.getFacet(UIComponent.COMPOSITE_FACET_NAME);
- assertNotNull(facet2);
+ Assert.assertNotNull(facet2);
UIForm form = (UIForm) facet2.findComponent("mainForm");
- assertNotNull(form);
+ Assert.assertNotNull(form);
UICommand button1 = (UICommand) form.findComponent("button1");
- assertNotNull(button1);
+ Assert.assertNotNull(button1);
UICommand button2 = (UICommand) form.findComponent("button2");
- assertNotNull(button2);
+ Assert.assertNotNull(button2);
UICommand button3 = (UICommand) form.findComponent("button3");
- assertNotNull(button3);
+ Assert.assertNotNull(button3);
UIInput text1 = (UIInput) form.findComponent("text1");
- assertNotNull(text1);
+ Assert.assertNotNull(text1);
UIInput text2 = (UIInput) form.findComponent("text2");
- assertNotNull(text2);
+ Assert.assertNotNull(text2);
compositeComponent1.pushComponentToEL(facesContext, compositeComponent1);
facet1.pushComponentToEL(facesContext, facet1);
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentBeanValidationTest.java Fri Jul 2 00:31:07 2010
@@ -27,6 +27,8 @@ import javax.faces.el.CompositeComponent
import org.apache.myfaces.el.unified.resolver.CompositeComponentELResolver;
import org.apache.myfaces.view.facelets.FaceletTestCase;
+import org.junit.Assert;
+import org.junit.Test;
/**
* Tests for using BeanValidation in conjunction with Composite Components.
@@ -47,6 +49,7 @@ public class CompositeComponentBeanValid
*
* @throws IOException
*/
+ @Test
public void testCompositeComponentExpressionHolder() throws IOException
{
UIViewRoot root = facesContext.getViewRoot();
@@ -60,14 +63,14 @@ public class CompositeComponentBeanValid
Object attrs = resolver.getValue(facesContext.getELContext(), compositeComponent, "attrs");
// the resolved value has to be a CompositeComponentExpressionHolder
- assertTrue(attrs instanceof CompositeComponentExpressionHolder);
+ Assert.assertTrue(attrs instanceof CompositeComponentExpressionHolder);
// get the actual ValueExpression which is needed by the BeanValidator
ValueExpression valueExpression
= ((CompositeComponentExpressionHolder) attrs).getExpression("input");
// the expression String from the VE has to be #{myBean.input}
- assertTrue("#{myBean.input}".equals(valueExpression.getExpressionString()));
+ Assert.assertTrue("#{myBean.input}".equals(valueExpression.getExpressionString()));
}
}
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentClientBehaviorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentClientBehaviorTestCase.java?rev=959818&r1=959817&r2=959818&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentClientBehaviorTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentClientBehaviorTestCase.java Fri Jul 2 00:31:07 2010
@@ -25,9 +25,12 @@ import javax.faces.component.UIViewRoot;
import org.apache.myfaces.view.facelets.FaceletTestCase;
import org.apache.myfaces.view.facelets.bean.HelloWorld;
+import org.junit.Assert;
+import org.junit.Test;
public class CompositeComponentClientBehaviorTestCase extends FaceletTestCase
{
+ @Test
public void testSimpleClientBehavior() throws Exception
{
HelloWorld helloWorld = new HelloWorld();
@@ -39,13 +42,13 @@ public class CompositeComponentClientBeh
vdl.buildView(facesContext, root, "testSimpleClientBehavior.xhtml");
UIComponent form = root.findComponent("testForm1");
- assertNotNull(form);
+ Assert.assertNotNull(form);
UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
- assertNotNull(compositeComponent);
+ Assert.assertNotNull(compositeComponent);
UICommand button = (UICommand) compositeComponent.findComponent("button");
- assertNotNull(button);
- assertNotNull(button.getClientBehaviors().get("action"));
- assertEquals(1, button.getClientBehaviors().get("action").size());
+ Assert.assertNotNull(button);
+ Assert.assertNotNull(button.getClientBehaviors().get("action"));
+ Assert.assertEquals(1, button.getClientBehaviors().get("action").size());
//StringWriter sw = new StringWriter();
//MockResponseWriter mrw = new MockResponseWriter(sw);
@@ -56,6 +59,7 @@ public class CompositeComponentClientBeh
//System.out.print(sw.toString());
}
+ @Test
public void testSimpleClientBehaviorDefault() throws Exception
{
HelloWorld helloWorld = new HelloWorld();
@@ -67,13 +71,13 @@ public class CompositeComponentClientBeh
vdl.buildView(facesContext, root, "testSimpleClientBehaviorDefault.xhtml");
UIComponent form = root.findComponent("testForm1");
- assertNotNull(form);
+ Assert.assertNotNull(form);
UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
- assertNotNull(compositeComponent);
+ Assert.assertNotNull(compositeComponent);
UICommand button = (UICommand) compositeComponent.findComponent("button");
- assertNotNull(button);
- assertNotNull(button.getClientBehaviors().get("dblclick"));
- assertEquals(1, button.getClientBehaviors().get("dblclick").size());
+ Assert.assertNotNull(button);
+ Assert.assertNotNull(button.getClientBehaviors().get("dblclick"));
+ Assert.assertEquals(1, button.getClientBehaviors().get("dblclick").size());
//StringWriter sw = new StringWriter();
//MockResponseWriter mrw = new MockResponseWriter(sw);
@@ -84,6 +88,7 @@ public class CompositeComponentClientBeh
//System.out.print(sw.toString());
}
+ @Test
public void testSimpleClientBehaviorDefaultNoEvent() throws Exception
{
HelloWorld helloWorld = new HelloWorld();
@@ -95,13 +100,13 @@ public class CompositeComponentClientBeh
vdl.buildView(facesContext, root, "testSimpleClientBehaviorDefaultNoEvent.xhtml");
UIComponent form = root.findComponent("testForm1");
- assertNotNull(form);
+ Assert.assertNotNull(form);
UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
- assertNotNull(compositeComponent);
+ Assert.assertNotNull(compositeComponent);
UICommand button = (UICommand) compositeComponent.findComponent("button");
- assertNotNull(button);
- assertNotNull(button.getClientBehaviors().get("action"));
- assertEquals(1, button.getClientBehaviors().get("action").size());
+ Assert.assertNotNull(button);
+ Assert.assertNotNull(button.getClientBehaviors().get("action"));
+ Assert.assertEquals(1, button.getClientBehaviors().get("action").size());
//StringWriter sw = new StringWriter();
//MockResponseWriter mrw = new MockResponseWriter(sw);
@@ -112,6 +117,7 @@ public class CompositeComponentClientBeh
//System.out.print(sw.toString());
}
+ @Test
public void testSimpleClientBehaviorAjaxWrap() throws Exception
{
HelloWorld helloWorld = new HelloWorld();
@@ -123,13 +129,13 @@ public class CompositeComponentClientBeh
vdl.buildView(facesContext, root, "testSimpleClientBehaviorAjaxWrap.xhtml");
UIComponent form = root.findComponent("testForm1");
- assertNotNull(form);
+ Assert.assertNotNull(form);
UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
- assertNotNull(compositeComponent);
+ Assert.assertNotNull(compositeComponent);
UICommand button = (UICommand) compositeComponent.findComponent("button");
- assertNotNull(button);
- assertNotNull(button.getClientBehaviors().get("action"));
- assertEquals(1, button.getClientBehaviors().get("action").size());
+ Assert.assertNotNull(button);
+ Assert.assertNotNull(button.getClientBehaviors().get("action"));
+ Assert.assertEquals(1, button.getClientBehaviors().get("action").size());
//StringWriter sw = new StringWriter();
//MockResponseWriter mrw = new MockResponseWriter(sw);
@@ -140,6 +146,7 @@ public class CompositeComponentClientBeh
//System.out.print(sw.toString());
}
+ @Test
public void testSimpleClientBehaviorDefaultAjaxWrap() throws Exception
{
HelloWorld helloWorld = new HelloWorld();
@@ -151,13 +158,13 @@ public class CompositeComponentClientBeh
vdl.buildView(facesContext, root, "testSimpleClientBehaviorDefaultAjaxWrap.xhtml");
UIComponent form = root.findComponent("testForm1");
- assertNotNull(form);
+ Assert.assertNotNull(form);
UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
- assertNotNull(compositeComponent);
+ Assert.assertNotNull(compositeComponent);
UICommand button = (UICommand) compositeComponent.findComponent("button");
- assertNotNull(button);
- assertNotNull(button.getClientBehaviors().get("dblclick"));
- assertEquals(1, button.getClientBehaviors().get("dblclick").size());
+ Assert.assertNotNull(button);
+ Assert.assertNotNull(button.getClientBehaviors().get("dblclick"));
+ Assert.assertEquals(1, button.getClientBehaviors().get("dblclick").size());
//StringWriter sw = new StringWriter();
//MockResponseWriter mrw = new MockResponseWriter(sw);
@@ -168,6 +175,7 @@ public class CompositeComponentClientBeh
//System.out.print(sw.toString());
}
+ @Test
public void testSimpleClientBehaviorDefaultNoEventAjaxWrap() throws Exception
{
HelloWorld helloWorld = new HelloWorld();
@@ -179,13 +187,13 @@ public class CompositeComponentClientBeh
vdl.buildView(facesContext, root, "testSimpleClientBehaviorDefaultNoEventAjaxWrap.xhtml");
UIComponent form = root.findComponent("testForm1");
- assertNotNull(form);
+ Assert.assertNotNull(form);
UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
- assertNotNull(compositeComponent);
+ Assert.assertNotNull(compositeComponent);
UICommand button = (UICommand) compositeComponent.findComponent("button");
- assertNotNull(button);
- assertNotNull(button.getClientBehaviors().get("action"));
- assertEquals(1, button.getClientBehaviors().get("action").size());
+ Assert.assertNotNull(button);
+ Assert.assertNotNull(button.getClientBehaviors().get("action"));
+ Assert.assertEquals(1, button.getClientBehaviors().get("action").size());
//StringWriter sw = new StringWriter();
//MockResponseWriter mrw = new MockResponseWriter(sw);
@@ -196,6 +204,7 @@ public class CompositeComponentClientBeh
//System.out.print(sw.toString());
}
+ @Test
public void testCompositeClientBehavior() throws Exception
{
HelloWorld helloWorld = new HelloWorld();
@@ -207,17 +216,17 @@ public class CompositeComponentClientBeh
vdl.buildView(facesContext, root, "testCompositeClientBehavior.xhtml");
UIComponent form = root.findComponent("testForm1");
- assertNotNull(form);
+ Assert.assertNotNull(form);
UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
- assertNotNull(compositeComponent);
+ Assert.assertNotNull(compositeComponent);
UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("button3");
- assertNotNull(compositeComponent2);
+ Assert.assertNotNull(compositeComponent2);
UICommand button = (UICommand) compositeComponent2.findComponent("button");
- assertNotNull(button);
+ Assert.assertNotNull(button);
//One added in testCompositeActionSource, the other one
//inside compositeActionSource.xhtml
- assertNotNull(button.getClientBehaviors().get("action"));
- assertEquals(1, button.getClientBehaviors().get("action").size());
+ Assert.assertNotNull(button.getClientBehaviors().get("action"));
+ Assert.assertEquals(1, button.getClientBehaviors().get("action").size());
//StringWriter sw = new StringWriter();
//MockResponseWriter mrw = new MockResponseWriter(sw);
@@ -228,6 +237,7 @@ public class CompositeComponentClientBeh
//System.out.print(sw.toString());
}
+ @Test
public void testCompositeDoubleClientBehavior() throws Exception
{
HelloWorld helloWorld = new HelloWorld();
@@ -239,19 +249,19 @@ public class CompositeComponentClientBeh
vdl.buildView(facesContext, root, "testCompositeDoubleClientBehavior.xhtml");
UIComponent form = root.findComponent("testForm1");
- assertNotNull(form);
+ Assert.assertNotNull(form);
UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
- assertNotNull(compositeComponent);
+ Assert.assertNotNull(compositeComponent);
UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("compositeClientBehavior");
- assertNotNull(compositeComponent2);
+ Assert.assertNotNull(compositeComponent2);
UINamingContainer compositeComponent3 = (UINamingContainer) compositeComponent2.findComponent("button3");
- assertNotNull(compositeComponent3);
+ Assert.assertNotNull(compositeComponent3);
UICommand button = (UICommand) compositeComponent3.findComponent("button");
- assertNotNull(button);
+ Assert.assertNotNull(button);
//One added in testCompositeActionSource, the other one
//inside compositeActionSource.xhtml
- assertNotNull(button.getClientBehaviors().get("action"));
- assertEquals(1, button.getClientBehaviors().get("action").size());
+ Assert.assertNotNull(button.getClientBehaviors().get("action"));
+ Assert.assertEquals(1, button.getClientBehaviors().get("action").size());
//StringWriter sw = new StringWriter();
//MockResponseWriter mrw = new MockResponseWriter(sw);