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/08/28 20:59:24 UTC
svn commit: r990408 [7/10] - in /myfaces/test/trunk:
test12/src/main/java/org/apache/myfaces/test/base/
test12/src/main/java/org/apache/myfaces/test/base/junit4/
test12/src/main/java/org/apache/myfaces/test/cargo/
test12/src/main/java/org/apache/myface...
Modified: myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java (original)
+++ myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/el/MockValueExpressionTest.java Sat Aug 28 18:59:21 2010
@@ -32,13 +32,13 @@ import org.apache.myfaces.test.base.Abst
*/
public class MockValueExpressionTest extends AbstractJsfTestCase
{
-
- public MockValueExpressionTest(String name)
+
+ public MockValueExpressionTest(String name)
{
super(name);
}
- public void testSetValue()
+ public void testSetValue()
{
// set value of #{foo} to BAR via ValueExpression
ELContext elContext = facesContext.getELContext();
@@ -48,7 +48,7 @@ public class MockValueExpressionTest ext
assertEquals("BAR", externalContext.getRequestMap().get("foo"));
}
- public void testGetValue()
+ public void testGetValue()
{
// set value of #{foo} to BAR in request scope
externalContext.getRequestMap().put("foo", "BAR");
Modified: myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/MockBean.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/MockBean.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/MockBean.java (original)
+++ myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/MockBean.java Sat Aug 28 18:59:21 2010
@@ -24,37 +24,51 @@ import java.io.Serializable;
*
* $Id$
*/
-public class MockBean implements Serializable {
+public class MockBean implements Serializable
+{
private static final long serialVersionUID = 8879968751506858610L;
private String command;
- public String getCommand() {
+
+ public String getCommand()
+ {
return (this.command);
}
- public void setCommand(String command) {
+
+ public void setCommand(String command)
+ {
this.command = command;
}
private String input;
- public String getInput() {
+
+ public String getInput()
+ {
return (this.input);
}
- public void setInput(String input) {
+
+ public void setInput(String input)
+ {
this.input = input;
}
private String output;
- public String getOutput() {
+
+ public String getOutput()
+ {
return (this.output);
}
- public void setOutput(String output) {
+
+ public void setOutput(String output)
+ {
this.output = output;
}
- public String combine() {
- return ((command == null ? "" : command) + ":" +
- (input == null ? "" : input) + ":" +
- (output == null ? "" : output));
+ public String combine()
+ {
+ return ((command == null ? "" : command) + ":"
+ + (input == null ? "" : input) + ":" + (output == null ? ""
+ : output));
}
}
Modified: myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/MockHttpSessionTest.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/MockHttpSessionTest.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/MockHttpSessionTest.java (original)
+++ myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/MockHttpSessionTest.java Sat Aug 28 18:59:21 2010
@@ -32,32 +32,32 @@ import org.apache.myfaces.test.base.Abst
public class MockHttpSessionTest extends AbstractJsfTestCase
{
- public static Test suite()
+ public static Test suite()
{
return (new TestSuite(MockHttpSessionTest.class));
}
-
+
private MockHttpSession session;
-
+
public MockHttpSessionTest(String name)
{
super(name);
}
-
- protected void setUp() throws Exception
+
+ protected void setUp() throws Exception
{
super.setUp();
-
+
session = new MockHttpSession();
}
- protected void tearDown() throws Exception
+ protected void tearDown() throws Exception
{
super.tearDown();
-
+
session = null;
}
-
+
/**
* Tests if the session is correctly invalidated.
*/
@@ -66,59 +66,59 @@ public class MockHttpSessionTest extends
// first store a value in the session and retrieve it again
session.setAttribute("someAttribute", "someValue");
assertEquals("someValue", session.getAttribute("someAttribute"));
-
+
// invalidate the session
session.invalidate();
-
+
try
{
session.getAttribute("someAttribute");
fail("Session was already invalidated, getAttribute() has to throw an IllegalStateException.");
}
- catch(IllegalStateException e)
+ catch (IllegalStateException e)
{
// expected Exception
}
-
+
try
{
session.setAttribute("someAttribute", "anotherValue");
fail("Session was already invalidated, setAttribute() has to throw an IllegalStateException.");
}
- catch(IllegalStateException e)
+ catch (IllegalStateException e)
{
// expected Exception
}
-
+
try
{
session.removeAttribute("someAttribute");
fail("Session was already invalidated, removeAttribute() has to throw an IllegalStateException.");
}
- catch(IllegalStateException e)
+ catch (IllegalStateException e)
{
// expected Exception
}
-
+
try
{
session.invalidate();
fail("Session was already invalidated, invalidate() has to throw an IllegalStateException.");
}
- catch(IllegalStateException e)
+ catch (IllegalStateException e)
{
// expected Exception
}
-
+
try
{
session.getAttributeNames();
fail("Session was already invalidated, getAttributeNames() has to throw an IllegalStateException.");
}
- catch(IllegalStateException e)
+ catch (IllegalStateException e)
{
// expected Exception
}
}
-
+
}
Modified: myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/MockObjectsTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/MockObjectsTestCase.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/MockObjectsTestCase.java (original)
+++ myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/MockObjectsTestCase.java Sat Aug 28 18:59:21 2010
@@ -29,23 +29,22 @@ import org.apache.myfaces.test.base.Abst
* <p>Simple unit tests for Mock Objects that have behavior.</p>
*/
-public class MockObjectsTestCase extends AbstractJsfTestCase {
-
+public class MockObjectsTestCase extends AbstractJsfTestCase
+{
// ------------------------------------------------------------ Constructors
-
// Construct a new instance of this test case.
- public MockObjectsTestCase(String name) {
+ public MockObjectsTestCase(String name)
+ {
super(name);
}
-
// ---------------------------------------------------- Overall Test Methods
-
// Set up instance variables required by this test case.
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception
+ {
super.setUp();
@@ -61,37 +60,34 @@ public class MockObjectsTestCase extends
}
-
// Return the tests included in this test case.
- public static Test suite() {
+ public static Test suite()
+ {
return (new TestSuite(MockObjectsTestCase.class));
}
-
// Tear down instance variables required by this test case.
- protected void tearDown() throws Exception {
-
+ protected void tearDown() throws Exception
+ {
super.tearDown();
}
-
// ------------------------------------------------------ Instance Variables
-
// ------------------------------------------------- Individual Test Methods
-
- public void testMethodBindingGetTypePositive() throws Exception {
+ public void testMethodBindingGetTypePositive() throws Exception
+ {
Class argsString[] = new Class[] { String.class };
Class argsNone[] = new Class[0];
checkMethodBindingGetType("test.getCommand", argsNone, String.class);
- checkMethodBindingGetType("test.setCommand", argsString, null);
+ checkMethodBindingGetType("test.setCommand", argsString, null);
checkMethodBindingGetType("test.getInput", argsNone, String.class);
checkMethodBindingGetType("test.setInput", argsString, null);
checkMethodBindingGetType("test.getOutput", argsNone, String.class);
@@ -100,8 +96,8 @@ public class MockObjectsTestCase extends
}
-
- public void testMethodBindingInvokePositive() throws Exception {
+ public void testMethodBindingInvokePositive() throws Exception
+ {
MockBean bean = (MockBean) request.getAttribute("test");
MethodBinding mb = null;
@@ -124,9 +120,9 @@ public class MockObjectsTestCase extends
}
-
// Positive tests for ValueBinding.getValue()
- public void testValueBindingGetValuePositive() throws Exception {
+ public void testValueBindingGetValuePositive() throws Exception
+ {
// Implicit search
checkValueBindingGetValue("appScopeName", "appScopeValue");
@@ -136,23 +132,18 @@ public class MockObjectsTestCase extends
// Explicit scope search
checkValueBindingGetValue("applicationScope.appScopeName",
- "appScopeValue");
- checkValueBindingGetValue("applicationScope.sameKey",
- "sameKeyAppValue");
- checkValueBindingGetValue("sessionScope.sesScopeName",
- "sesScopeValue");
- checkValueBindingGetValue("sessionScope.sameKey",
- "sameKeySesValue");
- checkValueBindingGetValue("requestScope.reqScopeName",
- "reqScopeValue");
- checkValueBindingGetValue("requestScope.sameKey",
- "sameKeyReqValue");
+ "appScopeValue");
+ checkValueBindingGetValue("applicationScope.sameKey", "sameKeyAppValue");
+ checkValueBindingGetValue("sessionScope.sesScopeName", "sesScopeValue");
+ checkValueBindingGetValue("sessionScope.sameKey", "sameKeySesValue");
+ checkValueBindingGetValue("requestScope.reqScopeName", "reqScopeValue");
+ checkValueBindingGetValue("requestScope.sameKey", "sameKeyReqValue");
}
-
// Positive tests for ValueBinding.putValue()
- public void testValueBindingPutValuePositive() throws Exception {
+ public void testValueBindingPutValuePositive() throws Exception
+ {
ValueBinding vb = null;
@@ -216,34 +207,29 @@ public class MockObjectsTestCase extends
assertEquals("sameKeySesValue", session.getAttribute("sameKey"));
assertEquals("sameKeyNewValue", request.getAttribute("sameKey"));
-
}
-
// --------------------------------------------------------- Private Methods
-
private void checkMethodBindingGetType(String ref, Class params[],
- Class expected) throws Exception {
+ Class expected) throws Exception
+ {
MethodBinding mb = application.createMethodBinding(ref, params);
assertNotNull("MethodBinding[" + ref + "] exists", mb);
- assertEquals("MethodBinding[" + ref + "] type",
- expected,
- mb.getType(facesContext));
+ assertEquals("MethodBinding[" + ref + "] type", expected, mb
+ .getType(facesContext));
}
-
- private void checkValueBindingGetValue(String ref, Object expected) {
+ private void checkValueBindingGetValue(String ref, Object expected)
+ {
ValueBinding vb = application.createValueBinding(ref);
assertNotNull("ValueBinding[" + ref + "] exists", vb);
- assertEquals("ValueBinding[" + ref + "] value",
- expected,
- vb.getValue(facesContext));
+ assertEquals("ValueBinding[" + ref + "] value", expected, vb
+ .getValue(facesContext));
}
-
}
Modified: myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/ValueBindingTest.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/ValueBindingTest.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/ValueBindingTest.java (original)
+++ myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/ValueBindingTest.java Sat Aug 28 18:59:21 2010
@@ -29,52 +29,55 @@ import org.apache.myfaces.test.mock.data
public class ValueBindingTest extends AbstractJsfTestCase
{
- public ValueBindingTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- public static Test suite() {
- return (new TestSuite(ValueBindingTest.class));
- }
-
- public void testRenderButtonWithValueBinding() throws IOException {
- ValueBinding vb= facesContext.getApplication().
- createValueBinding("#{ bean.name }");
-
- Bean bean = new Bean();
- bean.setName("Matthias");
-
- facesContext.getExternalContext().getRequestMap().put("bean",
- bean);
-
- assertEquals("Matthias", vb.getValue(facesContext).toString());
-
- vb = facesContext.getApplication().createValueBinding("#{requestScope['bean']}");
-
- Bean copy = (Bean) vb.getValue(facesContext);
- assertNotNull(copy);
- assertTrue(bean == copy);
-
- facesContext.getExternalContext().getRequestMap().put("org.apache.shale.bean",
- bean);
-
- vb = facesContext.getApplication().createValueBinding("#{requestScope['org.apache.shale.bean']}");
-
- copy = (Bean) vb.getValue(facesContext);
- assertNotNull(copy);
- assertTrue(bean == copy);
+ public ValueBindingTest(String name)
+ {
+ super(name);
+ }
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
- }
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public static Test suite()
+ {
+ return (new TestSuite(ValueBindingTest.class));
+ }
+
+ public void testRenderButtonWithValueBinding() throws IOException
+ {
+ ValueBinding vb = facesContext.getApplication().createValueBinding(
+ "#{ bean.name }");
+
+ Bean bean = new Bean();
+ bean.setName("Matthias");
+
+ facesContext.getExternalContext().getRequestMap().put("bean", bean);
+
+ assertEquals("Matthias", vb.getValue(facesContext).toString());
+
+ vb = facesContext.getApplication().createValueBinding(
+ "#{requestScope['bean']}");
+
+ Bean copy = (Bean) vb.getValue(facesContext);
+ assertNotNull(copy);
+ assertTrue(bean == copy);
+
+ facesContext.getExternalContext().getRequestMap().put(
+ "org.apache.shale.bean", bean);
+
+ vb = facesContext.getApplication().createValueBinding(
+ "#{requestScope['org.apache.shale.bean']}");
+
+ copy = (Bean) vb.getValue(facesContext);
+ assertNotNull(copy);
+ assertTrue(bean == copy);
+
+ }
}
Modified: myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/data/Bean.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/data/Bean.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/data/Bean.java (original)
+++ myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/data/Bean.java Sat Aug 28 18:59:21 2010
@@ -18,27 +18,26 @@ package org.apache.myfaces.test.mock.dat
public class Bean
{
- private String name, password;
+ private String name, password;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public String getPassword()
- {
- return password;
- }
-
- public void setPassword(String password)
- {
- this.password = password;
- }
-
-
}
Modified: myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java (original)
+++ myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java Sat Aug 28 18:59:21 2010
@@ -23,8 +23,7 @@ package org.apache.myfaces.test.runner;
public class WebXmlParameter
{
public static final String PARAMETER_KEY = "PARAMETER";
-
- static final String PARAMETER = WebXmlUtils
- .getInitParameter(PARAMETER_KEY);
+
+ static final String PARAMETER = WebXmlUtils.getInitParameter(PARAMETER_KEY);
}
Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java (original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java Sat Aug 28 18:59:21 2010
@@ -73,34 +73,36 @@ import org.apache.myfaces.test.mock.life
* @since 1.0.0
*/
-public abstract class AbstractJsfTestCase extends TestCase {
-
+public abstract class AbstractJsfTestCase extends TestCase
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Construct a new instance of this test case.</p>
*
* @param name Name of this test case
*/
- public AbstractJsfTestCase(String name) {
+ public AbstractJsfTestCase(String name)
+ {
super(name);
}
-
// ---------------------------------------------------- Overall Test Methods
-
/**
* <p>Set up instance variables required by this test case.</p>
*/
- protected void setUp() throws Exception {
+ 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()));
+ threadContextClassLoader = Thread.currentThread()
+ .getContextClassLoader();
+ Thread.currentThread()
+ .setContextClassLoader(
+ new URLClassLoader(new URL[0], this.getClass()
+ .getClassLoader()));
// Set up Servlet API Objects
setUpServletObjects();
@@ -112,7 +114,7 @@ public abstract class AbstractJsfTestCas
setUpJSFObjects();
}
-
+
/**
* <p>Setup JSF object used for the test. By default it calls to the following
* methods in this order:</p>
@@ -128,7 +130,7 @@ public abstract class AbstractJsfTestCas
*
* @throws Exception
*/
- protected void setUpJSFObjects() throws Exception
+ protected void setUpJSFObjects() throws Exception
{
setUpExternalContext();
setUpLifecycle();
@@ -137,7 +139,7 @@ public abstract class AbstractJsfTestCas
setUpApplication();
setUpRenderKit();
}
-
+
/**
* <p>Setup servlet objects that will be used for the test:</p>
*
@@ -151,7 +153,7 @@ public abstract class AbstractJsfTestCas
*
* @throws Exception
*/
- protected void setUpServletObjects() throws Exception
+ protected void setUpServletObjects() throws Exception
{
servletContext = new MockServletContext();
config = new MockServletConfig(servletContext);
@@ -161,28 +163,28 @@ public abstract class AbstractJsfTestCas
request.setServletContext(servletContext);
response = new MockHttpServletResponse();
}
-
+
/**
* <p>Set JSF factories using FactoryFinder method setFactory.</p>
*
* @throws Exception
*/
- protected void setFactories() throws Exception
+ protected void setFactories() throws Exception
{
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
- "org.apache.myfaces.test.mock.MockApplicationFactory");
+ "org.apache.myfaces.test.mock.MockApplicationFactory");
FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
- "org.apache.myfaces.test.mock.MockFacesContextFactory");
+ "org.apache.myfaces.test.mock.MockFacesContextFactory");
FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY,
- "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
+ "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
- "org.apache.myfaces.test.mock.MockRenderKitFactory");
+ "org.apache.myfaces.test.mock.MockRenderKitFactory");
FactoryFinder.setFactory(FactoryFinder.EXCEPTION_HANDLER_FACTORY,
- "org.apache.myfaces.test.mock.MockExceptionHandlerFactory");
+ "org.apache.myfaces.test.mock.MockExceptionHandlerFactory");
FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
- "org.apache.myfaces.test.mock.MockPartialViewContextFactory");
+ "org.apache.myfaces.test.mock.MockPartialViewContextFactory");
FactoryFinder.setFactory(FactoryFinder.VISIT_CONTEXT_FACTORY,
- "org.apache.myfaces.test.mock.visit.MockVisitContextFactory");
+ "org.apache.myfaces.test.mock.visit.MockVisitContextFactory");
}
/**
@@ -193,8 +195,8 @@ public abstract class AbstractJsfTestCas
*/
protected void setUpExternalContext() throws Exception
{
- externalContext =
- new MockExternalContext(servletContext, request, response);
+ externalContext = new MockExternalContext(servletContext, request,
+ response);
}
/**
@@ -205,12 +207,12 @@ public abstract class AbstractJsfTestCas
*/
protected void setUpLifecycle() throws Exception
{
- lifecycleFactory = (MockLifecycleFactory)
- FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
- lifecycle = (MockLifecycle)
- lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+ lifecycleFactory = (MockLifecycleFactory) FactoryFinder
+ .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ lifecycle = (MockLifecycle) lifecycleFactory
+ .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
}
-
+
/**
* Setup the <code>facesContextFactory</code> and <code>facesContext</code>
* variable. Before end, by default it override <code>externalContext</code>
@@ -222,16 +224,14 @@ public abstract class AbstractJsfTestCas
*/
protected void setUpFacesContext() throws Exception
{
- facesContextFactory = (MockFacesContextFactory)
- FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- facesContext = (MockFacesContext)
- facesContextFactory.getFacesContext(servletContext,
- request,
- response,
- lifecycle);
+ facesContextFactory = (MockFacesContextFactory) FactoryFinder
+ .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ facesContext = (MockFacesContext) facesContextFactory.getFacesContext(
+ servletContext, request, response, lifecycle);
if (facesContext.getExternalContext() != null)
{
- externalContext = (MockExternalContext) facesContext.getExternalContext();
+ externalContext = (MockExternalContext) facesContext
+ .getExternalContext();
}
}
@@ -248,7 +248,7 @@ public abstract class AbstractJsfTestCas
root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.setViewRoot(root);
}
-
+
/**
* Setup the <code>application</code> variable and before
* the end by default it is assigned to the <code>facesContext</code>
@@ -258,12 +258,12 @@ public abstract class AbstractJsfTestCas
*/
protected void setUpApplication() throws Exception
{
- ApplicationFactory applicationFactory = (ApplicationFactory)
- FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+ ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder
+ .getFactory(FactoryFinder.APPLICATION_FACTORY);
application = (MockApplication) applicationFactory.getApplication();
facesContext.setApplication(application);
}
-
+
/**
* Setup the <code>renderKit</code> variable. This is a good place to use
* <code>ConfigParser</code> to register converters, validators, components
@@ -273,21 +273,24 @@ public abstract class AbstractJsfTestCas
*/
protected void setUpRenderKit() throws Exception
{
- RenderKitFactory renderKitFactory = (RenderKitFactory)
- FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder
+ .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
renderKit = new MockRenderKit();
- renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
+ renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT,
+ renderKit);
}
/**
* <p>Tear down instance variables required by this test case.</p>
*/
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception
+ {
application = null;
config = null;
externalContext = null;
- if (facesContext != null) {
+ if (facesContext != null)
+ {
facesContext.release();
}
facesContext = null;
@@ -305,23 +308,21 @@ public abstract class AbstractJsfTestCas
}
-
// ------------------------------------------------------ Instance Variables
-
// Mock object instances for our tests
- protected MockApplication application = null;
- protected MockServletConfig config = null;
- protected MockExternalContext externalContext = null;
- protected MockFacesContext facesContext = null;
+ protected MockApplication 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 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;
+ protected MockServletContext servletContext = null;
+ protected MockHttpSession session = null;
// Thread context class loader saved and restored after each test
private ClassLoader threadContextClassLoader = null;
Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java (original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java Sat Aug 28 18:59:21 2010
@@ -75,12 +75,11 @@ import org.junit.Before;
* @since 1.0.0
*/
-public abstract class AbstractJsfConfigurableMockTestCase {
-
+public abstract class AbstractJsfConfigurableMockTestCase
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Construct a new instance of this test case.</p>
*
@@ -90,20 +89,22 @@ public abstract class AbstractJsfConfigu
{
}
-
// ---------------------------------------------------- Overall Test Methods
-
/**
* <p>Set up instance variables required by this test case.</p>
*/
@Before
- public void setUp() throws Exception {
+ public 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()));
+ threadContextClassLoader = Thread.currentThread()
+ .getContextClassLoader();
+ Thread.currentThread()
+ .setContextClassLoader(
+ new URLClassLoader(new URL[0], this.getClass()
+ .getClassLoader()));
// Set up Servlet API Objects
setUpServletObjects();
@@ -115,7 +116,7 @@ public abstract class AbstractJsfConfigu
setUpJSFObjects();
}
-
+
/**
* <p>Setup JSF object used for the test. By default it calls to the following
* methods in this order:</p>
@@ -131,7 +132,7 @@ public abstract class AbstractJsfConfigu
*
* @throws Exception
*/
- protected void setUpJSFObjects() throws Exception
+ protected void setUpJSFObjects() throws Exception
{
setUpExternalContext();
setUpLifecycle();
@@ -140,7 +141,7 @@ public abstract class AbstractJsfConfigu
setUpApplication();
setUpRenderKit();
}
-
+
/**
* <p>Setup servlet objects that will be used for the test:</p>
*
@@ -154,7 +155,7 @@ public abstract class AbstractJsfConfigu
*
* @throws Exception
*/
- protected void setUpServletObjects() throws Exception
+ protected void setUpServletObjects() throws Exception
{
servletContext = new MockServletContext();
config = new MockServletConfig(servletContext);
@@ -164,28 +165,28 @@ public abstract class AbstractJsfConfigu
request.setServletContext(servletContext);
response = new MockHttpServletResponse();
}
-
+
/**
* <p>Set JSF factories using FactoryFinder method setFactory.</p>
*
* @throws Exception
*/
- protected void setFactories() throws Exception
+ protected void setFactories() throws Exception
{
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
- "org.apache.myfaces.test.mock.MockApplicationFactory");
+ "org.apache.myfaces.test.mock.MockApplicationFactory");
FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
- "org.apache.myfaces.test.mock.MockFacesContextFactory");
+ "org.apache.myfaces.test.mock.MockFacesContextFactory");
FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY,
- "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
+ "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
- "org.apache.myfaces.test.mock.MockRenderKitFactory");
+ "org.apache.myfaces.test.mock.MockRenderKitFactory");
FactoryFinder.setFactory(FactoryFinder.EXCEPTION_HANDLER_FACTORY,
- "org.apache.myfaces.test.mock.MockExceptionHandlerFactory");
+ "org.apache.myfaces.test.mock.MockExceptionHandlerFactory");
FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
- "org.apache.myfaces.test.mock.MockPartialViewContextFactory");
+ "org.apache.myfaces.test.mock.MockPartialViewContextFactory");
FactoryFinder.setFactory(FactoryFinder.VISIT_CONTEXT_FACTORY,
- "org.apache.myfaces.test.mock.visit.MockVisitContextFactory");
+ "org.apache.myfaces.test.mock.visit.MockVisitContextFactory");
}
/**
@@ -196,8 +197,8 @@ public abstract class AbstractJsfConfigu
*/
protected void setUpExternalContext() throws Exception
{
- externalContext =
- new MockExternalContext(servletContext, request, response);
+ externalContext = new MockExternalContext(servletContext, request,
+ response);
}
/**
@@ -208,12 +209,12 @@ public abstract class AbstractJsfConfigu
*/
protected void setUpLifecycle() throws Exception
{
- lifecycleFactory = (LifecycleFactory)
- FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
- lifecycle =
- lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+ lifecycleFactory = (LifecycleFactory) FactoryFinder
+ .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ lifecycle = lifecycleFactory
+ .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
}
-
+
/**
* Setup the <code>facesContextFactory</code> and <code>facesContext</code>
* variable. Before end, by default it override <code>externalContext</code>
@@ -225,13 +226,10 @@ public abstract class AbstractJsfConfigu
*/
protected void setUpFacesContext() throws Exception
{
- facesContextFactory = (FacesContextFactory)
- FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- facesContext = (FacesContext)
- facesContextFactory.getFacesContext(servletContext,
- request,
- response,
- lifecycle);
+ facesContextFactory = (FacesContextFactory) FactoryFinder
+ .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ facesContext = (FacesContext) facesContextFactory.getFacesContext(
+ servletContext, request, response, lifecycle);
if (facesContext.getExternalContext() != null)
{
externalContext = facesContext.getExternalContext();
@@ -251,7 +249,7 @@ public abstract class AbstractJsfConfigu
root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.setViewRoot(root);
}
-
+
/**
* Setup the <code>application</code> variable and before
* the end by default it is assigned to the <code>facesContext</code>
@@ -261,12 +259,12 @@ public abstract class AbstractJsfConfigu
*/
protected void setUpApplication() throws Exception
{
- ApplicationFactory applicationFactory = (ApplicationFactory)
- FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+ ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder
+ .getFactory(FactoryFinder.APPLICATION_FACTORY);
application = applicationFactory.getApplication();
- ((MockFacesContext)facesContext).setApplication(application);
+ ((MockFacesContext) facesContext).setApplication(application);
}
-
+
/**
* Setup the <code>renderKit</code> variable. This is a good place to use
* <code>ConfigParser</code> to register converters, validators, components
@@ -276,22 +274,25 @@ public abstract class AbstractJsfConfigu
*/
protected void setUpRenderKit() throws Exception
{
- RenderKitFactory renderKitFactory = (RenderKitFactory)
- FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder
+ .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
renderKit = new MockRenderKit();
- renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
+ renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT,
+ renderKit);
}
/**
* <p>Tear down instance variables required by this test case.</p>
*/
@After
- public void tearDown() throws Exception {
+ public void tearDown() throws Exception
+ {
application = null;
config = null;
externalContext = null;
- if (facesContext != null) {
+ if (facesContext != null)
+ {
facesContext.release();
}
facesContext = null;
@@ -309,23 +310,21 @@ public abstract class AbstractJsfConfigu
}
-
// ------------------------------------------------------ Instance Variables
-
// Mock object instances for our tests
- protected Application application = null;
- protected MockServletConfig config = null;
- protected ExternalContext externalContext = null;
- protected FacesContext facesContext = null;
- protected FacesContextFactory facesContextFactory = null;
- protected Lifecycle lifecycle = null;
- protected LifecycleFactory lifecycleFactory = null;
- protected RenderKit renderKit = null;
- protected MockHttpServletRequest request = null;
+ protected Application application = null;
+ protected MockServletConfig config = null;
+ protected ExternalContext externalContext = null;
+ protected FacesContext facesContext = null;
+ protected FacesContextFactory facesContextFactory = null;
+ protected Lifecycle lifecycle = null;
+ protected LifecycleFactory lifecycleFactory = null;
+ protected RenderKit renderKit = null;
+ protected MockHttpServletRequest request = null;
protected MockHttpServletResponse response = null;
- protected MockServletContext servletContext = null;
- protected MockHttpSession session = null;
+ protected MockServletContext servletContext = null;
+ protected MockHttpSession session = null;
// Thread context class loader saved and restored after each test
private ClassLoader threadContextClassLoader = null;
Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java (original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java Sat Aug 28 18:59:21 2010
@@ -73,12 +73,11 @@ import org.junit.Before;
* @since 1.0.0
*/
-public abstract class AbstractJsfTestCase {
-
+public abstract class AbstractJsfTestCase
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Construct a new instance of this test case.</p>
*
@@ -88,20 +87,22 @@ public abstract class AbstractJsfTestCas
{
}
-
// ---------------------------------------------------- Overall Test Methods
-
/**
* <p>Set up instance variables required by this test case.</p>
*/
@Before
- public void setUp() throws Exception {
+ public 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()));
+ threadContextClassLoader = Thread.currentThread()
+ .getContextClassLoader();
+ Thread.currentThread()
+ .setContextClassLoader(
+ new URLClassLoader(new URL[0], this.getClass()
+ .getClassLoader()));
// Set up Servlet API Objects
setUpServletObjects();
@@ -113,7 +114,7 @@ public abstract class AbstractJsfTestCas
setUpJSFObjects();
}
-
+
/**
* <p>Setup JSF object used for the test. By default it calls to the following
* methods in this order:</p>
@@ -129,7 +130,7 @@ public abstract class AbstractJsfTestCas
*
* @throws Exception
*/
- protected void setUpJSFObjects() throws Exception
+ protected void setUpJSFObjects() throws Exception
{
setUpExternalContext();
setUpLifecycle();
@@ -138,7 +139,7 @@ public abstract class AbstractJsfTestCas
setUpApplication();
setUpRenderKit();
}
-
+
/**
* <p>Setup servlet objects that will be used for the test:</p>
*
@@ -152,7 +153,7 @@ public abstract class AbstractJsfTestCas
*
* @throws Exception
*/
- protected void setUpServletObjects() throws Exception
+ protected void setUpServletObjects() throws Exception
{
servletContext = new MockServletContext();
config = new MockServletConfig(servletContext);
@@ -162,28 +163,28 @@ public abstract class AbstractJsfTestCas
request.setServletContext(servletContext);
response = new MockHttpServletResponse();
}
-
+
/**
* <p>Set JSF factories using FactoryFinder method setFactory.</p>
*
* @throws Exception
*/
- protected void setFactories() throws Exception
+ protected void setFactories() throws Exception
{
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
- "org.apache.myfaces.test.mock.MockApplicationFactory");
+ "org.apache.myfaces.test.mock.MockApplicationFactory");
FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
- "org.apache.myfaces.test.mock.MockFacesContextFactory");
+ "org.apache.myfaces.test.mock.MockFacesContextFactory");
FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY,
- "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
+ "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
- "org.apache.myfaces.test.mock.MockRenderKitFactory");
+ "org.apache.myfaces.test.mock.MockRenderKitFactory");
FactoryFinder.setFactory(FactoryFinder.EXCEPTION_HANDLER_FACTORY,
- "org.apache.myfaces.test.mock.MockExceptionHandlerFactory");
+ "org.apache.myfaces.test.mock.MockExceptionHandlerFactory");
FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
- "org.apache.myfaces.test.mock.MockPartialViewContextFactory");
+ "org.apache.myfaces.test.mock.MockPartialViewContextFactory");
FactoryFinder.setFactory(FactoryFinder.VISIT_CONTEXT_FACTORY,
- "org.apache.myfaces.test.mock.visit.MockVisitContextFactory");
+ "org.apache.myfaces.test.mock.visit.MockVisitContextFactory");
}
/**
@@ -194,8 +195,8 @@ public abstract class AbstractJsfTestCas
*/
protected void setUpExternalContext() throws Exception
{
- externalContext =
- new MockExternalContext(servletContext, request, response);
+ externalContext = new MockExternalContext(servletContext, request,
+ response);
}
/**
@@ -206,12 +207,12 @@ public abstract class AbstractJsfTestCas
*/
protected void setUpLifecycle() throws Exception
{
- lifecycleFactory = (MockLifecycleFactory)
- FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
- lifecycle = (MockLifecycle)
- lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+ lifecycleFactory = (MockLifecycleFactory) FactoryFinder
+ .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ lifecycle = (MockLifecycle) lifecycleFactory
+ .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
}
-
+
/**
* Setup the <code>facesContextFactory</code> and <code>facesContext</code>
* variable. Before end, by default it override <code>externalContext</code>
@@ -223,16 +224,14 @@ public abstract class AbstractJsfTestCas
*/
protected void setUpFacesContext() throws Exception
{
- facesContextFactory = (MockFacesContextFactory)
- FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- facesContext = (MockFacesContext)
- facesContextFactory.getFacesContext(servletContext,
- request,
- response,
- lifecycle);
+ facesContextFactory = (MockFacesContextFactory) FactoryFinder
+ .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ facesContext = (MockFacesContext) facesContextFactory.getFacesContext(
+ servletContext, request, response, lifecycle);
if (facesContext.getExternalContext() != null)
{
- externalContext = (MockExternalContext) facesContext.getExternalContext();
+ externalContext = (MockExternalContext) facesContext
+ .getExternalContext();
}
}
@@ -249,7 +248,7 @@ public abstract class AbstractJsfTestCas
root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.setViewRoot(root);
}
-
+
/**
* Setup the <code>application</code> variable and before
* the end by default it is assigned to the <code>facesContext</code>
@@ -259,12 +258,12 @@ public abstract class AbstractJsfTestCas
*/
protected void setUpApplication() throws Exception
{
- ApplicationFactory applicationFactory = (ApplicationFactory)
- FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+ ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder
+ .getFactory(FactoryFinder.APPLICATION_FACTORY);
application = (MockApplication) applicationFactory.getApplication();
facesContext.setApplication(application);
}
-
+
/**
* Setup the <code>renderKit</code> variable. This is a good place to use
* <code>ConfigParser</code> to register converters, validators, components
@@ -274,22 +273,25 @@ public abstract class AbstractJsfTestCas
*/
protected void setUpRenderKit() throws Exception
{
- RenderKitFactory renderKitFactory = (RenderKitFactory)
- FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder
+ .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
renderKit = new MockRenderKit();
- renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
+ renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT,
+ renderKit);
}
/**
* <p>Tear down instance variables required by this test case.</p>
*/
@After
- public void tearDown() throws Exception {
+ public void tearDown() throws Exception
+ {
application = null;
config = null;
externalContext = null;
- if (facesContext != null) {
+ if (facesContext != null)
+ {
facesContext.release();
}
facesContext = null;
@@ -307,23 +309,21 @@ public abstract class AbstractJsfTestCas
}
-
// ------------------------------------------------------ Instance Variables
-
// Mock object instances for our tests
- protected MockApplication application = null;
- protected MockServletConfig config = null;
- protected MockExternalContext externalContext = null;
- protected MockFacesContext facesContext = null;
+ protected MockApplication 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 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;
+ protected MockServletContext servletContext = null;
+ protected MockHttpSession session = null;
// Thread context class loader saved and restored after each test
private ClassLoader threadContextClassLoader = null;
Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/config/ConfigParser.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/config/ConfigParser.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/config/ConfigParser.java (original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/config/ConfigParser.java Sat Aug 28 18:59:21 2010
@@ -59,54 +59,42 @@ import org.xml.sax.SAXException;
*
* @since 1.0.0
*/
-public class ConfigParser {
-
+public class ConfigParser
+{
// ------------------------------------------------------------ Constructors
-
/** Creates a new instance of ConfigParser */
- public ConfigParser() {
+ public ConfigParser()
+ {
}
-
// ------------------------------------------------------ Manifest Constants
-
/**
* <p>Configuration resource URLs for the JSF RI.</p>
*/
- private static final String[] JSFRI_RESOURCES =
- { "/com/sun/faces/jsf-ri-runtime.xml",
- };
-
+ private static final String[] JSFRI_RESOURCES = { "/com/sun/faces/jsf-ri-runtime.xml", };
/**
* <p>Configuration resource URLs for Apache MyFaces.</p>
*/
- private static final String[] MYFACES_RESOURCES =
- { "/org/apache/myfaces/resource/standard-faces-config.xml",
- };
+ private static final String[] MYFACES_RESOURCES = { "/org/apache/myfaces/resource/standard-faces-config.xml", };
/**
* <p>Configuration resource URLs for Apache MyFaces 1.2.</p>
*/
- private static final String[] MYFACES_RESOURCES12 =
- { "/META-INF/standard-faces-config.xml",
- };
+ private static final String[] MYFACES_RESOURCES12 = { "/META-INF/standard-faces-config.xml", };
// ------------------------------------------------------ Instance Variables
-
/**
* <p>The <code>Digester</code> instance we will use for parsing.</p>
*/
private Digester digester = null;
-
// ------------------------------------------------------- Public Properties
-
/**
* <p>Return the URLs of the platform configuration resources for this
* application. The following platforms are currently supported:</p>
@@ -118,12 +106,15 @@ public class ConfigParser {
* <p>If MyFaces (version 1.2), currently under development, does not change
* the name of the configuration resource, it will be supported as well.</p>
*/
- public URL[] getPlatformURLs() {
+ public URL[] getPlatformURLs()
+ {
URL[] urls = translate(JSFRI_RESOURCES);
- if (urls[0] == null) {
+ if (urls[0] == null)
+ {
urls = translate(MYFACES_RESOURCES12);
- if (urls[0] == null) {
+ if (urls[0] == null)
+ {
urls = translate(MYFACES_RESOURCES);
}
}
@@ -131,10 +122,8 @@ public class ConfigParser {
}
-
// ---------------------------------------------------------- Public Methods
-
/**
* <p>Parse the specified JavaServer Faces configuration resource, causing
* the appropriate JSF artifacts to be registered with the mock object
@@ -145,25 +134,28 @@ public class ConfigParser {
* @exception IOException if an input/output error occurs
* @exception SAXException if a parsing error occurs
*/
- public void parse(URL url) throws IOException, SAXException {
+ public void parse(URL url) throws IOException, SAXException
+ {
// Acquire and configure the Digester instance we will use
Digester digester = digester();
- ApplicationFactory factory = (ApplicationFactory)
- FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+ ApplicationFactory factory = (ApplicationFactory) FactoryFinder
+ .getFactory(FactoryFinder.APPLICATION_FACTORY);
Application application = factory.getApplication();
digester.push(application);
// Perform the required parsing
- try {
+ try
+ {
digester.parse(url);
- } finally {
+ }
+ finally
+ {
digester.clear();
}
}
-
/**
* <p>Parse the specified set of JavaServer Faces configuration resources,
* in the listed order, causing the appropriate JSF artifacts to be registered
@@ -174,182 +166,229 @@ public class ConfigParser {
* @exception IOException if an input/output error occurs
* @exception SAXException if a parsing error occurs
*/
- public void parse(URL[] urls) throws IOException, SAXException {
+ public void parse(URL[] urls) throws IOException, SAXException
+ {
- for (int i = 0; i < urls.length; i++) {
+ for (int i = 0; i < urls.length; i++)
+ {
parse(urls[i]);
}
}
-
// --------------------------------------------------------- Private Methods
-
/**
* <p>Return the <code>Digester</code> instance we will use for parsing,
* creating and configuring a new instance if necessary.</p>
*/
- private Digester digester() {
+ private Digester digester()
+ {
- if (this.digester == null) {
+ if (this.digester == null)
+ {
this.digester = new Digester();
digester.addRule("faces-config/component", new ComponentRule());
- digester.addCallMethod
- ("faces-config/component/component-type", "setComponentType", 0);
- digester.addCallMethod
- ("faces-config/component/component-class", "setComponentClass", 0);
+ digester.addCallMethod("faces-config/component/component-type",
+ "setComponentType", 0);
+ digester.addCallMethod("faces-config/component/component-class",
+ "setComponentClass", 0);
digester.addRule("faces-config/converter", new ConverterRule());
- digester.addCallMethod
- ("faces-config/converter/converter-id", "setConverterId", 0);
- digester.addCallMethod
- ("faces-config/converter/converter-class", "setConverterClass", 0);
- digester.addCallMethod
- ("faces-config/converter/converter-for-class", "setConverterForClass", 0);
+ digester.addCallMethod("faces-config/converter/converter-id",
+ "setConverterId", 0);
+ digester.addCallMethod("faces-config/converter/converter-class",
+ "setConverterClass", 0);
+ digester.addCallMethod(
+ "faces-config/converter/converter-for-class",
+ "setConverterForClass", 0);
digester.addRule("faces-config/render-kit", new RenderKitRule());
- digester.addRule("faces-config/render-kit/render-kit-id", new RenderKitIdRule());
- digester.addRule("faces-config/render-kit/renderer", new RendererRule());
- digester.addCallMethod
- ("faces-config/render-kit/renderer/component-family", "setComponentFamily", 0);
- digester.addCallMethod
- ("faces-config/render-kit/renderer/renderer-class", "setRendererClass", 0);
- digester.addCallMethod
- ("faces-config/render-kit/renderer/renderer-type", "setRendererType", 0);
- digester.addRule("faces-config/render-kit/client-behavior-renderer", new ClientBehaviorRendererRule());
- digester.addCallMethod
- ("faces-config/render-kit/client-behavior-renderer/client-behavior-renderer-type", "setClientBehaviorRendererType", 0);
- digester.addCallMethod
- ("faces-config/render-kit/client-behavior-renderer/client-behavior-renderer-class", "setClientBehaviorRendererClass", 0);
+ digester.addRule("faces-config/render-kit/render-kit-id",
+ new RenderKitIdRule());
+ digester.addRule("faces-config/render-kit/renderer",
+ new RendererRule());
+ digester.addCallMethod(
+ "faces-config/render-kit/renderer/component-family",
+ "setComponentFamily", 0);
+ digester.addCallMethod(
+ "faces-config/render-kit/renderer/renderer-class",
+ "setRendererClass", 0);
+ digester.addCallMethod(
+ "faces-config/render-kit/renderer/renderer-type",
+ "setRendererType", 0);
+ digester.addRule(
+ "faces-config/render-kit/client-behavior-renderer",
+ new ClientBehaviorRendererRule());
+ digester
+ .addCallMethod(
+ "faces-config/render-kit/client-behavior-renderer/client-behavior-renderer-type",
+ "setClientBehaviorRendererType", 0);
+ digester
+ .addCallMethod(
+ "faces-config/render-kit/client-behavior-renderer/client-behavior-renderer-class",
+ "setClientBehaviorRendererClass", 0);
digester.addRule("faces-config/validator", new ValidatorRule());
- digester.addCallMethod
- ("faces-config/validator/validator-id", "setValidatorId", 0);
- digester.addCallMethod
- ("faces-config/validator/validator-class", "setValidatorClass", 0);
+ digester.addCallMethod("faces-config/validator/validator-id",
+ "setValidatorId", 0);
+ digester.addCallMethod("faces-config/validator/validator-class",
+ "setValidatorClass", 0);
digester.addRule("faces-config/behavior", new BehaviorRule());
- digester.addCallMethod
- ("faces-config/behavior/behavior-id", "setBehaviorId", 0);
- digester.addCallMethod
- ("faces-config/behavior/behavior-class", "setBehaviorClass", 0);
+ digester.addCallMethod("faces-config/behavior/behavior-id",
+ "setBehaviorId", 0);
+ digester.addCallMethod("faces-config/behavior/behavior-class",
+ "setBehaviorClass", 0);
}
return this.digester;
}
-
/**
* <p>Translate an array of resource names into an array of resource URLs.</p>
*
* @param names Resource names to translate
*/
- private URL[] translate(String[] names) {
+ private URL[] translate(String[] names)
+ {
URL[] results = new URL[names.length];
- for (int i = 0; i < names.length; i++) {
+ for (int i = 0; i < names.length; i++)
+ {
results[i] = this.getClass().getResource(names[i]);
}
return results;
-
- }
+ }
// --------------------------------------------------------- Private Classes
-
/**
* <p>Data bean that stores information related to a component.</p>
*/
- class ComponentBean {
+ class ComponentBean
+ {
private String componentClass;
- public String getComponentClass() {
+
+ public String getComponentClass()
+ {
return this.componentClass;
}
- public void setComponentClass(String componentClass) {
+
+ public void setComponentClass(String componentClass)
+ {
this.componentClass = componentClass;
}
private String componentType;
- public String getComponentType() {
+
+ public String getComponentType()
+ {
return this.componentType;
}
- public void setComponentType(String componentType) {
+
+ public void setComponentType(String componentType)
+ {
this.componentType = componentType;
}
}
-
/**
* <p>Digester <code>Rule</code> for processing components.</p>
*/
- class ComponentRule extends Rule {
+ class ComponentRule extends Rule
+ {
- public void begin(String namespace, String name, Attributes attributes) {
+ public void begin(String namespace, String name, Attributes attributes)
+ {
getDigester().push(new ComponentBean());
}
- public void end(String namespace, String name) {
+ public void end(String namespace, String name)
+ {
ComponentBean bean = (ComponentBean) getDigester().pop();
Application application = (Application) getDigester().peek();
- application.addComponent(bean.getComponentType(), bean.getComponentClass());
+ application.addComponent(bean.getComponentType(), bean
+ .getComponentClass());
}
}
-
/**
* <p>Data bean that stores information related to a converter.</p>
*/
- class ConverterBean {
+ class ConverterBean
+ {
private String converterClass;
- public String getConverterClass() {
+
+ public String getConverterClass()
+ {
return this.converterClass;
}
- public void setConverterClass(String converterClass) {
+
+ public void setConverterClass(String converterClass)
+ {
this.converterClass = converterClass;
}
private String converterForClass;
- public String getConverterForClass() {
+
+ public String getConverterForClass()
+ {
return this.converterForClass;
}
- public void setConverterForClass(String converterForClass) {
+
+ public void setConverterForClass(String converterForClass)
+ {
this.converterForClass = converterForClass;
}
private String converterId;
- public String getConverterId() {
+
+ public String getConverterId()
+ {
return this.converterId;
}
- public void setConverterId(String converterId) {
+
+ public void setConverterId(String converterId)
+ {
this.converterId = converterId;
}
}
-
/**
* <p>Digester <code>Rule</code> for processing converers.</p>
*/
- class ConverterRule extends Rule {
+ class ConverterRule extends Rule
+ {
- public void begin(String namespace, String name, Attributes attributes) {
+ public void begin(String namespace, String name, Attributes attributes)
+ {
getDigester().push(new ConverterBean());
}
- public void end(String namespace, String name) {
+ public void end(String namespace, String name)
+ {
ConverterBean bean = (ConverterBean) getDigester().pop();
Application application = (Application) getDigester().peek();
- if (bean.getConverterId() != null) {
- application.addConverter(bean.getConverterId(), bean.getConverterClass());
- } else {
+ if (bean.getConverterId() != null)
+ {
+ application.addConverter(bean.getConverterId(), bean
+ .getConverterClass());
+ }
+ else
+ {
Class clazz = null;
- try {
+ try
+ {
clazz = classForName(bean.getConverterForClass());
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException("java.lang.ClassNotFoundException: "
- + bean.getConverterForClass());
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IllegalArgumentException(
+ "java.lang.ClassNotFoundException: "
+ + bean.getConverterForClass());
}
application.addConverter(clazz, bean.getConverterClass());
}
@@ -362,48 +401,53 @@ public class ConfigParser {
try
{
// Try WebApp ClassLoader first
- return Class.forName(type,
- false, // do not initialize for faster startup
- Thread.currentThread().getContextClassLoader());
+ return Class.forName(type, false, // do not initialize for faster startup
+ Thread.currentThread().getContextClassLoader());
}
catch (ClassNotFoundException ignore)
{
// fallback: Try ClassLoader for ClassUtils (i.e. the myfaces.jar lib)
- return Class.forName(type,
- false, // do not initialize for faster startup
- this.getClass().getClassLoader());
- }
+ return Class.forName(type, false, // do not initialize for faster startup
+ this.getClass().getClassLoader());
+ }
}
-
+
/**
* <p>Digester <code>Rule</code> for processing render kits.</p>
*/
- class RenderKitRule extends Rule {
+ class RenderKitRule extends Rule
+ {
- public void begin(String namespace, String name, Attributes attributes) {
- RenderKitFactory factory = (RenderKitFactory)
- FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- getDigester().push(factory.getRenderKit(null, RenderKitFactory.HTML_BASIC_RENDER_KIT));
+ public void begin(String namespace, String name, Attributes attributes)
+ {
+ RenderKitFactory factory = (RenderKitFactory) FactoryFinder
+ .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ getDigester().push(
+ factory.getRenderKit(null,
+ RenderKitFactory.HTML_BASIC_RENDER_KIT));
}
- public void end(String namespace, String name) {
+ public void end(String namespace, String name)
+ {
getDigester().pop();
}
}
-
/**
* <p>Digester <code>Rule</code> for processing render kit identifiers.</p>
*/
- class RenderKitIdRule extends Rule {
+ class RenderKitIdRule extends Rule
+ {
- public void body(String namespace, String name, String text) {
+ public void body(String namespace, String name, String text)
+ {
String renderKitId = text.trim();
- RenderKitFactory factory = (RenderKitFactory)
- FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKitFactory factory = (RenderKitFactory) FactoryFinder
+ .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
RenderKit renderKit = factory.getRenderKit(null, renderKitId);
- if (renderKit == null) {
+ if (renderKit == null)
+ {
renderKit = new MockRenderKit();
factory.addRenderKit(renderKitId, renderKit);
}
@@ -413,105 +457,134 @@ public class ConfigParser {
}
-
/**
* <p>Data bean that stores information related to a renderer.</p>
*/
- class RendererBean {
+ class RendererBean
+ {
private String componentFamily;
- public String getComponentFamily() {
+
+ public String getComponentFamily()
+ {
return this.componentFamily;
}
- public void setComponentFamily(String componentFamily) {
+
+ public void setComponentFamily(String componentFamily)
+ {
this.componentFamily = componentFamily;
}
private String rendererClass;
- public String getRendererClass() {
+
+ public String getRendererClass()
+ {
return this.rendererClass;
}
- public void setRendererClass(String rendererClass) {
+
+ public void setRendererClass(String rendererClass)
+ {
this.rendererClass = rendererClass;
}
private String rendererType;
- public String getRendererType() {
+
+ public String getRendererType()
+ {
return this.rendererType;
}
- public void setRendererType(String rendererType) {
+
+ public void setRendererType(String rendererType)
+ {
this.rendererType = rendererType;
}
}
-
/**
* <p>Digester <code>Rule</code> for processing renderers.</p>
*/
- class RendererRule extends Rule {
+ class RendererRule extends Rule
+ {
- public void begin(String namespace, String name, Attributes attributes) {
+ public void begin(String namespace, String name, Attributes attributes)
+ {
getDigester().push(new RendererBean());
}
- public void end(String namespace, String name) {
+ public void end(String namespace, String name)
+ {
RendererBean bean = (RendererBean) getDigester().pop();
RenderKit kit = (RenderKit) getDigester().peek();
Renderer renderer = null;
Class clazz = null;
- try {
+ try
+ {
clazz = classForName(bean.getRendererClass());
renderer = (Renderer) clazz.newInstance();
- } catch (Exception e) {
- throw new IllegalArgumentException("Exception while trying to instantiate"
- + " renderer class '" + bean.getRendererClass() + "' : "
- + e.getMessage());
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException(
+ "Exception while trying to instantiate"
+ + " renderer class '" + bean.getRendererClass()
+ + "' : " + e.getMessage());
}
kit.addRenderer(bean.getComponentFamily(), bean.getRendererType(),
- renderer);
+ renderer);
}
}
-
/**
* <p>Data bean that stores information related to a validator.</p>
*/
- class ValidatorBean {
+ class ValidatorBean
+ {
private String validatorClass;
- public String getValidatorClass() {
+
+ public String getValidatorClass()
+ {
return this.validatorClass;
}
- public void setValidatorClass(String validatorClass) {
+
+ public void setValidatorClass(String validatorClass)
+ {
this.validatorClass = validatorClass;
}
private String validatorId;
- public String getValidatorId() {
+
+ public String getValidatorId()
+ {
return this.validatorId;
}
- public void setValidatorId(String validatorId) {
+
+ public void setValidatorId(String validatorId)
+ {
this.validatorId = validatorId;
}
}
-
/**
* <p>Digester <code>Rule</code> for processing validators.</p>
*/
- class ValidatorRule extends Rule {
+ class ValidatorRule extends Rule
+ {
- public void begin(String namespace, String name, Attributes attributes) {
+ public void begin(String namespace, String name, Attributes attributes)
+ {
getDigester().push(new ValidatorBean());
}
- public void end(String namespace, String name) {
+ public void end(String namespace, String name)
+ {
ValidatorBean bean = (ValidatorBean) getDigester().pop();
Application application = (Application) getDigester().peek();
- application.addValidator(bean.getValidatorId(), bean.getValidatorClass());
+ application.addValidator(bean.getValidatorId(), bean
+ .getValidatorClass());
}
}
@@ -519,15 +592,16 @@ public class ConfigParser {
class ClientBehaviorRendererBean
{
private String clientBehaviorRendererType;
-
+
private String clientBehaviorRendererClass;
-
+
public String getClientBehaviorRendererType()
{
return clientBehaviorRendererType;
}
- public void setClientBehaviorRendererType(String clientBehaviorRendererType)
+ public void setClientBehaviorRendererType(
+ String clientBehaviorRendererType)
{
this.clientBehaviorRendererType = clientBehaviorRendererType;
}
@@ -537,12 +611,13 @@ public class ConfigParser {
return clientBehaviorRendererClass;
}
- public void setClientBehaviorRendererClass(String clientBehaviorRendererClass)
+ public void setClientBehaviorRendererClass(
+ String clientBehaviorRendererClass)
{
this.clientBehaviorRendererClass = clientBehaviorRendererClass;
}
}
-
+
class ClientBehaviorRendererRule extends Rule
{
public void begin(String namespace, String name, Attributes attributes)
@@ -550,21 +625,28 @@ public class ConfigParser {
getDigester().push(new ClientBehaviorRendererBean());
}
- public void end(String namespace, String name) {
- ClientBehaviorRendererBean bean = (ClientBehaviorRendererBean) getDigester().pop();
+ public void end(String namespace, String name)
+ {
+ ClientBehaviorRendererBean bean = (ClientBehaviorRendererBean) getDigester()
+ .pop();
RenderKit kit = (RenderKit) getDigester().peek();
ClientBehaviorRenderer renderer = null;
Class clazz = null;
- try {
+ try
+ {
clazz = classForName(bean.getClientBehaviorRendererClass());
renderer = (ClientBehaviorRenderer) clazz.newInstance();
- } catch (Exception e) {
- throw new IllegalArgumentException("Exception while trying to instantiate"
- + " client behavior renderer class '" + bean.getClientBehaviorRendererClass() + "' : "
- + e.getMessage());
}
- kit.addClientBehaviorRenderer(bean.getClientBehaviorRendererType(),
- renderer);
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException(
+ "Exception while trying to instantiate"
+ + " client behavior renderer class '"
+ + bean.getClientBehaviorRendererClass()
+ + "' : " + e.getMessage());
+ }
+ kit.addClientBehaviorRenderer(bean.getClientBehaviorRendererType(),
+ renderer);
}
}
@@ -602,7 +684,6 @@ public class ConfigParser {
}
-
/**
* <p>Digester <code>Rule</code> for processing behaviors.</p>
*/
@@ -618,7 +699,8 @@ public class ConfigParser {
{
BehaviorBean bean = (BehaviorBean) getDigester().pop();
Application application = (Application) getDigester().peek();
- application.addBehavior(bean.getBehaviorId(), bean.getBehaviorClass());
+ application.addBehavior(bean.getBehaviorId(), bean
+ .getBehaviorClass());
}
}