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 [8/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/test20/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java (original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java Sat Aug 28 18:59:21 2010
@@ -72,34 +72,36 @@ import org.jmock.cglib.MockObjectTestCas
  * @since 1.0.0
  */
 
-public abstract class AbstractJmockJsfTestCase extends MockObjectTestCase {
-
+public abstract class AbstractJmockJsfTestCase extends MockObjectTestCase
+{
 
     // ------------------------------------------------------------ Constructors
 
-
     /**
      * <p>Construct a new instance of this test case.</p>
      *
      * @param name Name of this test case
      */
-    public AbstractJmockJsfTestCase(String name) {
+    public AbstractJmockJsfTestCase(String name)
+    {
         setName(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();
@@ -111,7 +113,7 @@ public abstract class AbstractJmockJsfTe
 
         setUpJSFObjects();
     }
-    
+
     /**
      * <p>Setup JSF object used for the test. By default it calls to the following
      * methods in this order:</p>
@@ -127,7 +129,7 @@ public abstract class AbstractJmockJsfTe
      * 
      * @throws Exception
      */
-    protected void setUpJSFObjects()  throws Exception
+    protected void setUpJSFObjects() throws Exception
     {
         setUpExternalContext();
         setUpLifecycle();
@@ -136,7 +138,7 @@ public abstract class AbstractJmockJsfTe
         setUpApplication();
         setUpRenderKit();
     }
-    
+
     /**
      * <p>Setup servlet objects that will be used for the test:</p>
      * 
@@ -150,7 +152,7 @@ public abstract class AbstractJmockJsfTe
      * 
      * @throws Exception
      */
-    protected void setUpServletObjects() throws Exception 
+    protected void setUpServletObjects() throws Exception
     {
         servletContext = new MockServletContext();
         config = new MockServletConfig(servletContext);
@@ -160,28 +162,28 @@ public abstract class AbstractJmockJsfTe
         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");
     }
 
     /**
@@ -192,8 +194,8 @@ public abstract class AbstractJmockJsfTe
      */
     protected void setUpExternalContext() throws Exception
     {
-        externalContext =
-            new MockExternalContext(servletContext, request, response);
+        externalContext = new MockExternalContext(servletContext, request,
+                response);
     }
 
     /**
@@ -204,12 +206,12 @@ public abstract class AbstractJmockJsfTe
      */
     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>
@@ -221,16 +223,14 @@ public abstract class AbstractJmockJsfTe
      */
     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();
         }
     }
 
@@ -247,7 +247,7 @@ public abstract class AbstractJmockJsfTe
         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>
@@ -257,12 +257,12 @@ public abstract class AbstractJmockJsfTe
      */
     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
@@ -272,21 +272,24 @@ public abstract class AbstractJmockJsfTe
      */
     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;
@@ -304,23 +307,21 @@ public abstract class AbstractJmockJsfTe
 
     }
 
-
     // ------------------------------------------------------ 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/mock/MockApplication20.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java (original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java Sat Aug 28 18:59:21 2010
@@ -50,13 +50,12 @@ import java.util.concurrent.CopyOnWriteA
 public class MockApplication20 extends MockApplication12
 {
 
-
     // ------------------------------------------------------------ Constructors
 
     public MockApplication20()
     {
         super();
-        
+
         // install the 2.0-ViewHandler-Mock
         this.setViewHandler(new MockViewHandler20());
         this.setResourceHandler(new MockResourceHandler());
@@ -191,11 +190,11 @@ public class MockApplication20 extends M
     // ------------------------------------------------------ Instance Variables
 
     private static final Log log = LogFactory.getLog(MockApplication20.class);
-    
+
     private final Map<Class<? extends SystemEvent>, SystemListenerEntry> _systemEventListenerClassMap = new ConcurrentHashMap<Class<? extends SystemEvent>, SystemListenerEntry>();
-    
+
     private Map<String, String> _defaultValidatorsIds = new HashMap<String, String>();
-    
+
     private ProjectStage _projectStage;
 
     private final Map<String, Class<?>> _behaviorClassMap = new ConcurrentHashMap<String, Class<?>>();
@@ -205,7 +204,7 @@ public class MockApplication20 extends M
     private ResourceHandler _resourceHandler;
 
     // ----------------------------------------------------- Mock Object Methods
-    
+
     public Map<String, String> getDefaultValidatorInfo()
     {
         return Collections.unmodifiableMap(_defaultValidatorsIds);
@@ -266,7 +265,7 @@ public class MockApplication20 extends M
 
         return event;
     }
-    
+
     private void checkNull(final Object param, final String paramName)
     {
         if (param == null)
@@ -279,11 +278,14 @@ public class MockApplication20 extends M
     {
         if (param.length() == 0)
         {
-            throw new NullPointerException("String " + paramName + " cannot be empty.");
+            throw new NullPointerException("String " + paramName
+                    + " cannot be empty.");
         }
     }
 
-    public void publishEvent(FacesContext facesContext, Class<? extends SystemEvent> systemEventClass, Class<?> sourceBaseType, Object source)
+    public void publishEvent(FacesContext facesContext,
+            Class<? extends SystemEvent> systemEventClass,
+            Class<?> sourceBaseType, Object source)
     {
         checkNull(systemEventClass, "systemEventClass");
         checkNull(source, "source");
@@ -294,18 +296,21 @@ public class MockApplication20 extends M
             if (source instanceof SystemEventListenerHolder)
             {
                 SystemEventListenerHolder holder = (SystemEventListenerHolder) source;
-    
+
                 // If the source argument implements SystemEventListenerHolder, call 
                 // SystemEventListenerHolder.getListenersForEventClass(java.lang.Class) on it, passing the systemEventClass 
                 // argument. If the list is not empty, perform algorithm traverseListenerList on the list.
-                event = _traverseListenerList(holder.getListenersForEventClass(systemEventClass), systemEventClass, source,
-                                              event);
+                event = _traverseListenerList(holder
+                        .getListenersForEventClass(systemEventClass),
+                        systemEventClass, source, event);
             }
-    
-            SystemListenerEntry systemListenerEntry = _systemEventListenerClassMap.get(systemEventClass);
+
+            SystemListenerEntry systemListenerEntry = _systemEventListenerClassMap
+                    .get(systemEventClass);
             if (systemListenerEntry != null)
             {
-                systemListenerEntry.publish(systemEventClass, sourceBaseType, source, event);
+                systemListenerEntry.publish(systemEventClass, sourceBaseType,
+                        source, event);
             }
         }
         catch (AbortProcessingException e)
@@ -317,7 +322,8 @@ public class MockApplication20 extends M
         }
     }
 
-    public void publishEvent(FacesContext facesContext, Class<? extends SystemEvent> systemEventClass, Object source)
+    public void publishEvent(FacesContext facesContext,
+            Class<? extends SystemEvent> systemEventClass, Object source)
     {
         publishEvent(facesContext, systemEventClass, source.getClass(), source);
     }
@@ -330,7 +336,8 @@ public class MockApplication20 extends M
         {
 
             FacesContext context = FacesContext.getCurrentInstance();
-            String stageName = context.getExternalContext().getInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME);
+            String stageName = context.getExternalContext().getInitParameter(
+                    ProjectStage.PROJECT_STAGE_PARAM_NAME);
 
             // If a value is found found
             if (stageName != null)
@@ -349,14 +356,13 @@ public class MockApplication20 extends M
                     //log.log(Level.SEVERE, "Couldn't discover the current project stage", e);
                 }
             }
-            
+
             _projectStage = ProjectStage.Production;
         }
 
         return _projectStage;
     }
 
-
     public void addBehavior(String behaviorId, String behaviorClass)
     {
         checkNull(behaviorId, "behaviorId");
@@ -364,9 +370,12 @@ public class MockApplication20 extends M
         checkNull(behaviorClass, "behaviorClass");
         checkEmpty(behaviorClass, "behaviorClass");
 
-        try {
+        try
+        {
             _behaviorClassMap.put(behaviorId, Class.forName(behaviorClass));
-        } catch (ClassNotFoundException ignore) {
+        }
+        catch (ClassNotFoundException ignore)
+        {
 
         }
 
@@ -385,7 +394,9 @@ public class MockApplication20 extends M
         final Class<?> behaviorClass = this._behaviorClassMap.get(behaviorId);
         if (behaviorClass == null)
         {
-            throw new FacesException("Could not find any registered behavior-class for behaviorId : " + behaviorId);
+            throw new FacesException(
+                    "Could not find any registered behavior-class for behaviorId : "
+                            + behaviorId);
         }
 
         try
@@ -395,18 +406,22 @@ public class MockApplication20 extends M
         }
         catch (Exception e)
         {
-            throw new FacesException("Could not instantiate behavior: " + behaviorClass, e);
+            throw new FacesException("Could not instantiate behavior: "
+                    + behaviorClass, e);
         }
     }
 
     @Override
-    public void addValidator(String validatorId, String validatorClass) {
+    public void addValidator(String validatorId, String validatorClass)
+    {
         super.addValidator(validatorId, validatorClass);
 
-        try {
-        _validatorClassMap.put(validatorId,
-                Class.forName(validatorClass));
-        } catch (ClassNotFoundException ex) {
+        try
+        {
+            _validatorClassMap.put(validatorId, Class.forName(validatorClass));
+        }
+        catch (ClassNotFoundException ex)
+        {
             throw new FacesException(ex.getMessage());
         }
 
@@ -416,7 +431,8 @@ public class MockApplication20 extends M
     {
         if (_validatorClassMap.containsKey(validatorId))
         {
-            _defaultValidatorsIds.put(validatorId, _validatorClassMap.get(validatorId).getName());
+            _defaultValidatorsIds.put(validatorId, _validatorClassMap.get(
+                    validatorId).getName());
         }
     }
 
@@ -432,13 +448,14 @@ public class MockApplication20 extends M
         _resourceHandler = resourceHandler;
     }
 
-    public void subscribeToEvent(Class<? extends SystemEvent> systemEventClass, SystemEventListener listener)
+    public void subscribeToEvent(Class<? extends SystemEvent> systemEventClass,
+            SystemEventListener listener)
     {
         subscribeToEvent(systemEventClass, null, listener);
     }
 
-    public void subscribeToEvent(Class<? extends SystemEvent> systemEventClass, Class<?> sourceClass,
-                                 SystemEventListener listener)
+    public void subscribeToEvent(Class<? extends SystemEvent> systemEventClass,
+            Class<?> sourceClass, SystemEventListener listener)
     {
         checkNull(systemEventClass, "systemEventClass");
         checkNull(listener, "listener");
@@ -446,29 +463,35 @@ public class MockApplication20 extends M
         SystemListenerEntry systemListenerEntry;
         synchronized (_systemEventListenerClassMap)
         {
-            systemListenerEntry = _systemEventListenerClassMap.get(systemEventClass);
+            systemListenerEntry = _systemEventListenerClassMap
+                    .get(systemEventClass);
             if (systemListenerEntry == null)
             {
                 systemListenerEntry = new SystemListenerEntry();
-                _systemEventListenerClassMap.put(systemEventClass, systemListenerEntry);
+                _systemEventListenerClassMap.put(systemEventClass,
+                        systemListenerEntry);
             }
         }
 
         systemListenerEntry.addListener(listener, sourceClass);
     }
 
-    public void unsubscribeFromEvent(Class<? extends SystemEvent> systemEventClass, SystemEventListener listener)
+    public void unsubscribeFromEvent(
+            Class<? extends SystemEvent> systemEventClass,
+            SystemEventListener listener)
     {
         unsubscribeFromEvent(systemEventClass, null, listener);
     }
 
-    public void unsubscribeFromEvent(Class<? extends SystemEvent> systemEventClass, Class<?> sourceClass,
-                                     SystemEventListener listener)
+    public void unsubscribeFromEvent(
+            Class<? extends SystemEvent> systemEventClass,
+            Class<?> sourceClass, SystemEventListener listener)
     {
         checkNull(systemEventClass, "systemEventClass");
         checkNull(listener, "listener");
 
-        SystemListenerEntry systemListenerEntry = _systemEventListenerClassMap.get(systemEventClass);
+        SystemListenerEntry systemListenerEntry = _systemEventListenerClassMap
+                .get(systemEventClass);
         if (systemListenerEntry != null)
         {
             systemListenerEntry.removeListener(listener, sourceClass);

Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockApplicationFactory.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockApplicationFactory.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockApplicationFactory.java (original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockApplicationFactory.java Sat Aug 28 18:59:21 2010
@@ -28,80 +28,101 @@ import javax.faces.application.Applicati
  * @since 1.0.0
  */
 
-public class MockApplicationFactory extends ApplicationFactory {
-
+public class MockApplicationFactory extends ApplicationFactory
+{
 
     // ------------------------------------------------------------ Constructors
 
-
     /**
      * <p>Construct a default instance.</p>
      */
-    public MockApplicationFactory() {
+    public MockApplicationFactory()
+    {
 
     }
 
-
     // ----------------------------------------------------- Mock Object Methods
 
-
     // ------------------------------------------------------ Instance Variables
 
-
     /**
      * <p>The <code>Application</code> instance to be returned by
      * this factory.</p>
      */
     private Application application = null;
 
-
     // --------------------------------------------- AppolicationFactory Methods
 
-
     /** {@inheritDoc} */
-    public Application getApplication() {
+    public Application getApplication()
+    {
 
-        if (this.application == null) {
+        if (this.application == null)
+        {
             Class clazz = null;
-            
-            try {
-                clazz = this.getClass().getClassLoader().loadClass
-                  ("org.apache.myfaces.test.mock.MockApplication20");
+
+            try
+            {
+                clazz = this.getClass().getClassLoader().loadClass(
+                        "org.apache.myfaces.test.mock.MockApplication20");
                 this.application = (MockApplication) clazz.newInstance();
-            } catch (NoClassDefFoundError e) {
+            }
+            catch (NoClassDefFoundError e)
+            {
                 clazz = null; // We are not running in a JSF 1.2 environment
-            } catch (ClassNotFoundException e) {
+            }
+            catch (ClassNotFoundException e)
+            {
                 clazz = null; // Same as above
-            } catch (RuntimeException e) {
+            }
+            catch (RuntimeException e)
+            {
                 throw e;
-            } catch (Exception e) {
+            }
+            catch (Exception e)
+            {
                 throw new FacesException(e);
             }
-            
+
             if (clazz == null)
             {
-                try {
-                    clazz = this.getClass().getClassLoader().loadClass
-                      ("org.apache.myfaces.test.mock.MockApplication12");
+                try
+                {
+                    clazz = this.getClass().getClassLoader().loadClass(
+                            "org.apache.myfaces.test.mock.MockApplication12");
                     this.application = (MockApplication) clazz.newInstance();
-                } catch (NoClassDefFoundError e) {
+                }
+                catch (NoClassDefFoundError e)
+                {
                     clazz = null; // We are not running in a JSF 1.2 environment
-                } catch (ClassNotFoundException e) {
+                }
+                catch (ClassNotFoundException e)
+                {
                     clazz = null; // Same as above
-                } catch (RuntimeException e) {
+                }
+                catch (RuntimeException e)
+                {
                     throw e;
-                } catch (Exception e) {
+                }
+                catch (Exception e)
+                {
                     throw new FacesException(e);
                 }
             }
-            if (clazz == null) {
-                try {
-                    clazz = this.getClass().getClassLoader().loadClass
-                      ("org.apache.myfaces.test.mock.MockApplication");
+            if (clazz == null)
+            {
+                try
+                {
+                    clazz = this.getClass().getClassLoader().loadClass(
+                            "org.apache.myfaces.test.mock.MockApplication");
                     this.application = (MockApplication) clazz.newInstance();
-                } catch (RuntimeException e) {
+                }
+                catch (RuntimeException e)
+                {
                     throw e;
-                } catch (Exception e) {
+                }
+                catch (Exception e)
+                {
                     throw new FacesException(e);
                 }
             }
@@ -110,13 +131,12 @@ public class MockApplicationFactory exte
 
     }
 
-
     /** {@inheritDoc} */
-    public void setApplication(Application application) {
+    public void setApplication(Application application)
+    {
 
         this.application = application;
 
     }
 
-
 }

Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockExceptionHandler.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockExceptionHandler.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockExceptionHandler.java (original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockExceptionHandler.java Sat Aug 28 18:59:21 2010
@@ -57,7 +57,8 @@ public class MockExceptionHandler extend
     @Override
     public Iterable<ExceptionQueuedEvent> getHandledExceptionQueuedEvents()
     {
-        return handled == null ? Collections.<ExceptionQueuedEvent>emptyList() : handled;
+        return handled == null ? Collections.<ExceptionQueuedEvent> emptyList()
+                : handled;
     }
 
     /**
@@ -66,13 +67,17 @@ public class MockExceptionHandler extend
     @Override
     public Throwable getRootCause(Throwable t)
     {
-        if (t == null) {
+        if (t == null)
+        {
             throw new NullPointerException("t");
         }
 
-        while (t != null) {
+        while (t != null)
+        {
             Class<?> clazz = t.getClass();
-            if (!clazz.equals(FacesException.class) && !clazz.equals(ELException.class)) {
+            if (!clazz.equals(FacesException.class)
+                    && !clazz.equals(ELException.class))
+            {
                 return t;
             }
 
@@ -88,7 +93,8 @@ public class MockExceptionHandler extend
     @Override
     public Iterable<ExceptionQueuedEvent> getUnhandledExceptionQueuedEvents()
     {
-        return unhandled == null ? Collections.<ExceptionQueuedEvent>emptyList() : unhandled;
+        return unhandled == null ? Collections
+                .<ExceptionQueuedEvent> emptyList() : unhandled;
     }
 
     /**
@@ -97,19 +103,23 @@ public class MockExceptionHandler extend
     @Override
     public void handle() throws FacesException
     {
-        if (unhandled != null && !unhandled.isEmpty()) {
-            if (handled == null) {
+        if (unhandled != null && !unhandled.isEmpty())
+        {
+            if (handled == null)
+            {
                 handled = new LinkedList<ExceptionQueuedEvent>();
             }
 
             FacesException toThrow = null;
 
-            do {
+            do
+            {
                 // For each ExceptionEvent in the list
 
                 // get the event to handle
                 ExceptionQueuedEvent event = unhandled.peek();
-                try {
+                try
+                {
                     // call its getContext() method
                     ExceptionQueuedEventContext context = event.getContext();
 
@@ -118,7 +128,8 @@ public class MockExceptionHandler extend
 
                     // Upon encountering the first such Exception that is not an instance of
                     // javax.faces.event.AbortProcessingException
-                    if (!shouldSkip(exception)) {
+                    if (!shouldSkip(exception))
+                    {
                         // set handledAndThrown so that getHandledExceptionQueuedEvent() returns this event
                         handledAndThrown = event;
 
@@ -130,22 +141,26 @@ public class MockExceptionHandler extend
                         break;
                     }
                 }
-                catch (Throwable t) {
+                catch (Throwable t)
+                {
                     // A FacesException must be thrown if a problem occurs while performing
                     // the algorithm to handle the exception
-                    throw new FacesException("Could not perform the algorithm to handle the Exception", t);
+                    throw new FacesException(
+                            "Could not perform the algorithm to handle the Exception",
+                            t);
                 }
-                finally {
+                finally
+                {
                     // if we will throw the Exception or if we just logged it,
                     // we handled it in either way --> add to handled
                     handled.add(event);
                     unhandled.remove(event);
                 }
-            }
-            while (!unhandled.isEmpty());
+            } while (!unhandled.isEmpty());
 
             // do we have to throw an Exception?
-            if (toThrow != null) {
+            if (toThrow != null)
+            {
                 throw toThrow;
             }
         }
@@ -164,9 +179,11 @@ public class MockExceptionHandler extend
      * {@inheritDoc}
      */
     @Override
-    public void processEvent(SystemEvent exceptionQueuedEvent) throws AbortProcessingException
+    public void processEvent(SystemEvent exceptionQueuedEvent)
+            throws AbortProcessingException
     {
-        if (unhandled == null) {
+        if (unhandled == null)
+        {
             unhandled = new LinkedList<ExceptionQueuedEvent>();
         }
 
@@ -178,7 +195,8 @@ public class MockExceptionHandler extend
         // Let toRethrow be either the result of calling getRootCause() on the Exception,
         // or the Exception itself, whichever is non-null
         Throwable toRethrow = getRootCause(exception);
-        if (toRethrow == null) {
+        if (toRethrow == null)
+        {
             toRethrow = exception;
         }
 
@@ -187,7 +205,8 @@ public class MockExceptionHandler extend
 
     protected FacesException wrap(Throwable exception)
     {
-        if (exception instanceof FacesException) {
+        if (exception instanceof FacesException)
+        {
             return (FacesException) exception;
         }
         return new FacesException(exception);

Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockExternalContext20.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockExternalContext20.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockExternalContext20.java (original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockExternalContext20.java Sat Aug 28 18:59:21 2010
@@ -57,21 +57,23 @@ public class MockExternalContext20 exten
 
     // ------------------------------------------------------ Instance Variables
 
-    private static final String URL_PARAM_SEPERATOR="&";
-    private static final String URL_QUERY_SEPERATOR="?";
-    private static final String URL_FRAGMENT_SEPERATOR="#";
-    private static final String URL_NAME_VALUE_PAIR_SEPERATOR="=";
+    private static final String URL_PARAM_SEPERATOR = "&";
+    private static final String URL_QUERY_SEPERATOR = "?";
+    private static final String URL_FRAGMENT_SEPERATOR = "#";
+    private static final String URL_NAME_VALUE_PAIR_SEPERATOR = "=";
 
     // ----------------------------------------------------- Mock Object Methods
 
     // ------------------------------------------------- ExternalContext Methods
 
-    public String encodeBookmarkableURL(String baseUrl, Map<String,List<String>> parameters)
+    public String encodeBookmarkableURL(String baseUrl,
+            Map<String, List<String>> parameters)
     {
         return response.encodeURL(encodeURL(baseUrl, parameters));
     }
-    
-    private String encodeURL(String baseUrl, Map<String, List<String>> parameters)
+
+    private String encodeURL(String baseUrl,
+            Map<String, List<String>> parameters)
     {
         String fragment = null;
         String queryString = null;
@@ -81,8 +83,8 @@ public class MockExternalContext20 exten
         int index = baseUrl.indexOf(URL_FRAGMENT_SEPERATOR);
         if (index != -1)
         {
-            fragment = baseUrl.substring(index+1);
-            baseUrl = baseUrl.substring(0,index);
+            fragment = baseUrl.substring(index + 1);
+            baseUrl = baseUrl.substring(0, index);
         }
 
         //extract the current query string and add the params to the paramMap
@@ -94,7 +96,8 @@ public class MockExternalContext20 exten
             String[] nameValuePairs = queryString.split(URL_PARAM_SEPERATOR);
             for (int i = 0; i < nameValuePairs.length; i++)
             {
-                String[] currentPair = nameValuePairs[i].split(URL_NAME_VALUE_PAIR_SEPERATOR);
+                String[] currentPair = nameValuePairs[i]
+                        .split(URL_NAME_VALUE_PAIR_SEPERATOR);
                 if (currentPair[1] != null)
                 {
                     ArrayList<String> value = new ArrayList<String>(1);
@@ -120,7 +123,7 @@ public class MockExternalContext20 exten
         StringBuilder newUrl = new StringBuilder(baseUrl);
 
         //now add the updated param list onto the url
-        if (paramMap.size()>0)
+        if (paramMap.size() > 0)
         {
             boolean isFirstPair = true;
             for (Map.Entry<String, List<String>> pair : paramMap.entrySet())
@@ -141,12 +144,16 @@ public class MockExternalContext20 exten
                     newUrl.append(URL_NAME_VALUE_PAIR_SEPERATOR);
                     try
                     {
-                        newUrl.append(URLEncoder.encode(value,getResponseCharacterEncoding()));
+                        newUrl.append(URLEncoder.encode(value,
+                                getResponseCharacterEncoding()));
                     }
                     catch (UnsupportedEncodingException e)
                     {
                         //shouldn't ever get here
-                        throw new UnsupportedOperationException("Encoding type=" + getResponseCharacterEncoding() + " not supported", e);
+                        throw new UnsupportedOperationException(
+                                "Encoding type="
+                                        + getResponseCharacterEncoding()
+                                        + " not supported", e);
                     }
                 }
             }
@@ -161,18 +168,20 @@ public class MockExternalContext20 exten
         return newUrl.toString();
     }
 
-    public String encodeRedirectURL(String baseUrl, Map<String,List<String>> parameters)
+    public String encodeRedirectURL(String baseUrl,
+            Map<String, List<String>> parameters)
     {
         return response.encodeRedirectURL(encodeURL(baseUrl, parameters));
     }
-    
+
     @Override
     public String encodePartialActionURL(String url)
     {
         return ((HttpServletResponse) response).encodeURL(url);
     }
 
-    public String getContextName() {
+    public String getContextName()
+    {
         return context.getServletContextName();
     }
 
@@ -181,7 +190,8 @@ public class MockExternalContext20 exten
         return context.getRealPath(path);
     }
 
-    public void responseSendError(int statusCode, String message) throws IOException
+    public void responseSendError(int statusCode, String message)
+            throws IOException
     {
         if (message == null)
         {

Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockFacesContext20.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockFacesContext20.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockFacesContext20.java (original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockFacesContext20.java Sat Aug 28 18:59:21 2010
@@ -40,22 +40,25 @@ import javax.faces.lifecycle.Lifecycle;
  * @since 1.0.0
  *
  */
-public class MockFacesContext20 extends MockFacesContext12 {
+public class MockFacesContext20 extends MockFacesContext12
+{
 
     // ------------------------------------------------------------ Constructors
-    
-    public MockFacesContext20() {
+
+    public MockFacesContext20()
+    {
         super();
         setCurrentInstance(this);
     }
 
-
-    public MockFacesContext20(ExternalContext externalContext) {
+    public MockFacesContext20(ExternalContext externalContext)
+    {
         super(externalContext);
     }
 
-
-    public MockFacesContext20(ExternalContext externalContext, Lifecycle lifecycle) {
+    public MockFacesContext20(ExternalContext externalContext,
+            Lifecycle lifecycle)
+    {
         super(externalContext, lifecycle);
     }
 
@@ -66,7 +69,7 @@ public class MockFacesContext20 extends 
     private PhaseId _currentPhaseId = PhaseId.RESTORE_VIEW;
     private boolean _postback;
     private PartialViewContext _partialViewContext = null;
-    private Map<Object,Object> attributes;
+    private Map<Object, Object> attributes;
     private boolean _validationFailed = false;
 
     // ----------------------------------------------------- Mock Object Methods   
@@ -75,17 +78,17 @@ public class MockFacesContext20 extends 
     {
         return _postback;
     }
-    
+
     public void setPostback(boolean value)
     {
         _postback = value;
     }
-    
+
     public PhaseId getCurrentPhaseId()
     {
         return _currentPhaseId;
     }
-    
+
     public void setCurrentPhaseId(PhaseId _currentPhaseId)
     {
         this._currentPhaseId = _currentPhaseId;
@@ -95,7 +98,7 @@ public class MockFacesContext20 extends 
     {
         if (attributes == null)
         {
-            attributes = new HashMap<Object,Object>();
+            attributes = new HashMap<Object, Object>();
         }
         return attributes;
     }
@@ -105,18 +108,18 @@ public class MockFacesContext20 extends 
         if (_partialViewContext == null)
         {
             //Get through factory finder
-            PartialViewContextFactory factory = (PartialViewContextFactory)
-                FactoryFinder.getFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY);
+            PartialViewContextFactory factory = (PartialViewContextFactory) FactoryFinder
+                    .getFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY);
             _partialViewContext = factory.getPartialViewContext(this);
         }
         return _partialViewContext;
     }
-    
+
     public boolean isProcessingEvents()
     {
         return _processingEvents;
     }
-    
+
     public void setProcessingEvents(boolean processingEvents)
     {
         _processingEvents = processingEvents;
@@ -137,11 +140,13 @@ public class MockFacesContext20 extends 
     {
         if (messages == null)
         {
-            return Collections.unmodifiableList(Collections.<FacesMessage>emptyList());
+            return Collections.unmodifiableList(Collections
+                    .<FacesMessage> emptyList());
         }
 
         List<FacesMessage> lst = new ArrayList<FacesMessage>();
-        for(List<FacesMessage> curLst : ((Map<String, List<FacesMessage>>) messages).values())
+        for (List<FacesMessage> curLst : ((Map<String, List<FacesMessage>>) messages)
+                .values())
         {
             lst.addAll(curLst);
         }
@@ -154,7 +159,8 @@ public class MockFacesContext20 extends 
     {
         if (messages == null || !messages.containsKey(clientId))
         {
-            return Collections.unmodifiableList(Collections.<FacesMessage>emptyList());
+            return Collections.unmodifiableList(Collections
+                    .<FacesMessage> emptyList());
         }
 
         return ((Map<String, List<FacesMessage>>) messages).get(clientId);

Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockFacesContextFactory.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockFacesContextFactory.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockFacesContextFactory.java (original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockFacesContextFactory.java Sat Aug 28 18:59:21 2010
@@ -34,105 +34,125 @@ import javax.servlet.http.HttpServletRes
  * @since 1.0.0
  */
 
-public class MockFacesContextFactory extends FacesContextFactory {
-
+public class MockFacesContextFactory extends FacesContextFactory
+{
 
     // ------------------------------------------------------------ Constructors
 
-
     /**
      * <p>Look up the constructor we will use for creating <code>MockFacesContext</code>
      * instances.</p>
      */
-    public MockFacesContextFactory() {
+    public MockFacesContextFactory()
+    {
 
         Class clazz = null;
 
         // Try to load the 2.0 version of our mock FacesContext class
-        try {
-            clazz = this.getClass().getClassLoader().loadClass("org.apache.myfaces.test.mock.MockFacesContext20");
+        try
+        {
+            clazz = this.getClass().getClassLoader().loadClass(
+                    "org.apache.myfaces.test.mock.MockFacesContext20");
             constructor = clazz.getConstructor(facesContextSignature);
             jsf20 = true;
-        } catch (NoClassDefFoundError e) {
+        }
+        catch (NoClassDefFoundError e)
+        {
             // We are not running on JSF 2.0, so go to our fallback
             clazz = null;
             constructor = null;
-        } catch (ClassNotFoundException e) {
+        }
+        catch (ClassNotFoundException e)
+        {
             // Same as above
             clazz = null;
             constructor = null;
-        } catch (RuntimeException e) {
+        }
+        catch (RuntimeException e)
+        {
             throw e;
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             throw new FacesException(e);
-        }        
-        
+        }
+
         // Try to load the 1.2 version of our mock FacesContext class
-        try {
+        try
+        {
             if (clazz == null)
             {
-                clazz = this.getClass().getClassLoader().loadClass("org.apache.myfaces.test.mock.MockFacesContext12");
+                clazz = this.getClass().getClassLoader().loadClass(
+                        "org.apache.myfaces.test.mock.MockFacesContext12");
                 constructor = clazz.getConstructor(facesContextSignature);
                 jsf12 = true;
             }
-        } catch (NoClassDefFoundError e) {
+        }
+        catch (NoClassDefFoundError e)
+        {
             // We are not running on JSF 1.2, so go to our fallback
             clazz = null;
             constructor = null;
-        } catch (ClassNotFoundException e) {
+        }
+        catch (ClassNotFoundException e)
+        {
             // Same as above
             clazz = null;
             constructor = null;
-        } catch (RuntimeException e) {
+        }
+        catch (RuntimeException e)
+        {
             throw e;
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             throw new FacesException(e);
         }
 
         // Fall back to the 1.1 version if we could not load the 1.2 version
-        try {
-            if (clazz == null) {
-                clazz = this.getClass().getClassLoader().loadClass("org.apache.myfaces.test.mock.MockFacesContext");
+        try
+        {
+            if (clazz == null)
+            {
+                clazz = this.getClass().getClassLoader().loadClass(
+                        "org.apache.myfaces.test.mock.MockFacesContext");
                 constructor = clazz.getConstructor(facesContextSignature);
                 jsf12 = false;
             }
-        } catch (RuntimeException e) {
+        }
+        catch (RuntimeException e)
+        {
             throw e;
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             throw new FacesException(e);
         }
 
     }
 
-
     // ----------------------------------------------------- Mock Object Methods
 
-
     // ------------------------------------------------------ Instance Variables
 
-
     /**
      * <p>The constructor for creating a <code>FacesContext</code> instance,
      * taking an <code>ExternalContext</code> and <code>Lifecycle</code>.</p>
      */
     private Constructor constructor = null;
 
-
     /**
      * <p>The parameter signature of the ExternalContext constructor we wish to call.</p>
      */
     private static Class[] externalContextSignature = new Class[] {
-        ServletContext.class, HttpServletRequest.class, HttpServletResponse.class
-    };
-
+            ServletContext.class, HttpServletRequest.class,
+            HttpServletResponse.class };
 
     /**
      * <p>The parameter signature of the FacesContext constructor we wish to call.</p>
      */
     private static Class[] facesContextSignature = new Class[] {
-        ExternalContext.class, Lifecycle.class
-    };
-
+            ExternalContext.class, Lifecycle.class };
 
     /**
      * <p>Flag indicating that we are running in a JSF 1.2 environment.</p>
@@ -143,72 +163,97 @@ public class MockFacesContextFactory ext
      * <p>Flag indicating that we are running in a JSF 2.0 environment.</p>
      */
     private boolean jsf20 = false;
-    
-    // --------------------------------------------- FacesContextFactory Methods
 
+    // --------------------------------------------- FacesContextFactory Methods
 
     /** {@inheritDoc} */
     public FacesContext getFacesContext(Object context, Object request,
-                                        Object response,
-                                        Lifecycle lifecycle) throws FacesException {
+            Object response, Lifecycle lifecycle) throws FacesException
+    {
 
         // Select the appropriate MockExternalContext implementation class
         Class clazz = MockExternalContext.class;
-        
-        if (jsf20) {
-            try {
-                clazz = this.getClass().getClassLoader().loadClass
-                  ("org.apache.myfaces.test.mock.MockExternalContext20");
-            } catch (RuntimeException e) {
+
+        if (jsf20)
+        {
+            try
+            {
+                clazz = this.getClass().getClassLoader().loadClass(
+                        "org.apache.myfaces.test.mock.MockExternalContext20");
+            }
+            catch (RuntimeException e)
+            {
                 throw e;
-            } catch (Exception e) {
+            }
+            catch (Exception e)
+            {
                 throw new FacesException(e);
             }
         }
-        
-        if (jsf12) {
-            try {
-                clazz = this.getClass().getClassLoader().loadClass
-                  ("org.apache.myfaces.test.mock.MockExternalContext12");
-            } catch (RuntimeException e) {
+
+        if (jsf12)
+        {
+            try
+            {
+                clazz = this.getClass().getClassLoader().loadClass(
+                        "org.apache.myfaces.test.mock.MockExternalContext12");
+            }
+            catch (RuntimeException e)
+            {
                 throw e;
-            } catch (Exception e) {
+            }
+            catch (Exception e)
+            {
                 throw new FacesException(e);
             }
         }
 
         // Select the constructor we wish to call
         Constructor mecConstructor = null;
-        try {
+        try
+        {
             mecConstructor = clazz.getConstructor(externalContextSignature);
-        } catch (RuntimeException e) {
+        }
+        catch (RuntimeException e)
+        {
             throw e;
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             throw new FacesException(e);
         }
 
         // Construct an appropriate MockExternalContext instance
         MockExternalContext externalContext = null;
-        try {
-            externalContext = (MockExternalContext) mecConstructor.newInstance
-              (new Object[] { context, request, response });
-        } catch (RuntimeException e) {
+        try
+        {
+            externalContext = (MockExternalContext) mecConstructor
+                    .newInstance(new Object[] { context, request, response });
+        }
+        catch (RuntimeException e)
+        {
             throw e;
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             throw new FacesException(e);
         }
 
         // Construct an appropriate MockFacesContext instance and return it
-        try {
-            return (MockFacesContext)
-              constructor.newInstance(new Object[] { externalContext, lifecycle });
-        } catch (RuntimeException e) {
+        try
+        {
+            return (MockFacesContext) constructor.newInstance(new Object[] {
+                    externalContext, lifecycle });
+        }
+        catch (RuntimeException e)
+        {
             throw e;
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             throw new FacesException(e);
         }
 
     }
 
-
 }

Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockFlash.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockFlash.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockFlash.java (original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/mock/MockFlash.java Sat Aug 28 18:59:21 2010
@@ -45,20 +45,21 @@ public class MockFlash extends Flash
      * Key on app map to keep current instance
      */
     static protected final String FLASH_INSTANCE = MockFlash.class.getName()
-        + ".INSTANCE";
+            + ".INSTANCE";
 
     /**
      * Key used to check if there is the current request will be or was redirected
      */
     static protected final String FLASH_REDIRECT = MockFlash.class.getName()
-        + ".REDIRECT";
+            + ".REDIRECT";
 
     /**
      * Key used to check if this request should keep messages (like tomahawk sandbox RedirectTracker.
      * Used when post-redirect-get pattern is used)
      */
-    static protected final String FLASH_KEEP_MESSAGES = MockFlash.class.getName()
-        + ".KEEP_MESSAGES";
+    static protected final String FLASH_KEEP_MESSAGES = MockFlash.class
+            .getName()
+            + ".KEEP_MESSAGES";
 
     static protected final String FLASH_KEEP_MESSAGES_LIST = "KEEPMESSAGESLIST";
 
@@ -66,19 +67,23 @@ public class MockFlash extends Flash
      * Session map prefix to flash maps
      */
     static protected final String FLASH_SCOPE_CACHE = MockFlash.class.getName()
-        + ".SCOPE";
+            + ".SCOPE";
 
-    static protected final String FLASH_CURRENT_MAP_CACHE = MockFlash.class.getName()
-        + ".CURRENTMAP.CACHE";
-
-    static protected final String FLASH_CURRENT_MAP_KEY = MockFlash.class.getName()
-        + ".CURRENTMAP.KEY";
-
-    static protected final String FLASH_POSTBACK_MAP_CACHE = MockFlash.class.getName()
-        + ".POSTBACKMAP.CACHE";
-
-    static protected final String FLASH_POSTBACK_MAP_KEY = MockFlash.class.getName()
-        + ".POSTBACKMAP.KEY";
+    static protected final String FLASH_CURRENT_MAP_CACHE = MockFlash.class
+            .getName()
+            + ".CURRENTMAP.CACHE";
+
+    static protected final String FLASH_CURRENT_MAP_KEY = MockFlash.class
+            .getName()
+            + ".CURRENTMAP.KEY";
+
+    static protected final String FLASH_POSTBACK_MAP_CACHE = MockFlash.class
+            .getName()
+            + ".POSTBACKMAP.CACHE";
+
+    static protected final String FLASH_POSTBACK_MAP_KEY = MockFlash.class
+            .getName()
+            + ".POSTBACKMAP.KEY";
 
     static private final char SEPARATOR_CHAR = '.';
 
@@ -96,11 +101,13 @@ public class MockFlash extends Flash
     private static long _getSeed()
     {
         SecureRandom rng;
-        try {
+        try
+        {
             // try SHA1 first
             rng = SecureRandom.getInstance("SHA1PRNG");
         }
-        catch (NoSuchAlgorithmException e) {
+        catch (NoSuchAlgorithmException e)
+        {
             // SHA1 not present, so try the default (which could potentially not be
             // cryptographically secure)
             rng = new SecureRandom();
@@ -137,8 +144,10 @@ public class MockFlash extends Flash
         Map<String, Object> applicationMap = context.getApplicationMap();
         Flash flash = (Flash) applicationMap.get(FLASH_INSTANCE);
 
-        synchronized (applicationMap) {
-            if (flash == null) {
+        synchronized (applicationMap)
+        {
+            if (flash == null)
+            {
                 flash = new MockFlash();
                 context.getApplicationMap().put(FLASH_INSTANCE, flash);
             }
@@ -152,7 +161,7 @@ public class MockFlash extends Flash
      */
     @SuppressWarnings("unchecked")
     private Map<String, Object> _getMapFromSession(FacesContext context,
-                                                   String token, boolean createIfNeeded)
+            String token, boolean createIfNeeded)
     {
         ExternalContext external = context.getExternalContext();
         Object session = external.getSession(true);
@@ -161,11 +170,13 @@ public class MockFlash extends Flash
 
         // Synchronize on the session object to ensure that
         // we don't ever create two different caches
-        synchronized (session) {
+        synchronized (session)
+        {
             map = (Map<String, Object>) external.getSessionMap().get(token);
-            if ((map == null) && createIfNeeded) {
+            if ((map == null) && createIfNeeded)
+            {
                 map = new MockSubKeyMap<Object>(context.getExternalContext()
-                    .getSessionMap(), token);
+                        .getSessionMap(), token);
             }
         }
 
@@ -186,9 +197,12 @@ public class MockFlash extends Flash
     @SuppressWarnings("unchecked")
     protected Map<String, Object> getCurrentRequestMap(FacesContext context)
     {
-        Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-        Map<String, Object> map = (Map<String, Object>) requestMap.get(FLASH_CURRENT_MAP_CACHE);
-        if (map == null) {
+        Map<String, Object> requestMap = context.getExternalContext()
+                .getRequestMap();
+        Map<String, Object> map = (Map<String, Object>) requestMap
+                .get(FLASH_CURRENT_MAP_CACHE);
+        if (map == null)
+        {
             String token = (String) requestMap.get(FLASH_CURRENT_MAP_KEY);
             String fullToken = FLASH_SCOPE_CACHE + SEPARATOR_CHAR + token;
             map = _getMapFromSession(context, fullToken, true);
@@ -200,11 +214,15 @@ public class MockFlash extends Flash
     @SuppressWarnings("unchecked")
     protected Map<String, Object> getPostbackRequestMap(FacesContext context)
     {
-        Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-        Map<String, Object> map = (Map<String, Object>) requestMap.get(FLASH_POSTBACK_MAP_CACHE);
-        if (map == null) {
+        Map<String, Object> requestMap = context.getExternalContext()
+                .getRequestMap();
+        Map<String, Object> map = (Map<String, Object>) requestMap
+                .get(FLASH_POSTBACK_MAP_CACHE);
+        if (map == null)
+        {
             String token = (String) requestMap.get(FLASH_POSTBACK_MAP_KEY);
-            if (token == null && isRedirect()) {
+            if (token == null && isRedirect())
+            {
                 // In post-redirect-get, request values are reset, so we need
                 // to get the postback key again.
                 token = _getPostbackMapKey(context.getExternalContext());
@@ -264,11 +282,13 @@ public class MockFlash extends Flash
     private Map<String, Object> getCurrentPhaseMap()
     {
         FacesContext facesContext = FacesContext.getCurrentInstance();
-        if (PhaseId.RENDER_RESPONSE.equals(facesContext.getCurrentPhaseId()) ||
-            !facesContext.isPostback() || isRedirect()) {
+        if (PhaseId.RENDER_RESPONSE.equals(facesContext.getCurrentPhaseId())
+                || !facesContext.isPostback() || isRedirect())
+        {
             return getCurrentRequestMap(facesContext);
         }
-        else {
+        else
+        {
             return getPostbackRequestMap(facesContext);
         }
     }
@@ -290,34 +310,42 @@ public class MockFlash extends Flash
     @Override
     public void doPrePhaseActions(FacesContext facesContext)
     {
-        Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
+        Map<String, Object> requestMap = facesContext.getExternalContext()
+                .getRequestMap();
 
-        if (PhaseId.RESTORE_VIEW.equals(facesContext.getCurrentPhaseId())) {
+        if (PhaseId.RESTORE_VIEW.equals(facesContext.getCurrentPhaseId()))
+        {
             // Generate token and put on requestMap
             // It is necessary to set this token always, because on the next request
             // it should be possible to change postback map.
             String currentToken = _getNextToken();
             requestMap.put(FLASH_CURRENT_MAP_KEY, currentToken);
 
-            if (facesContext.isPostback()) {
+            if (facesContext.isPostback())
+            {
                 //Retore token
-                String previousToken = _getPostbackMapKey(facesContext.getExternalContext());
+                String previousToken = _getPostbackMapKey(facesContext
+                        .getExternalContext());
 
-                if (previousToken != null) {
+                if (previousToken != null)
+                {
                     requestMap.put(FLASH_POSTBACK_MAP_KEY, previousToken);
                 }
             }
 
-            if (isKeepMessages()) {
+            if (isKeepMessages())
+            {
                 restoreMessages(facesContext);
             }
         }
 
         //
-        if (PhaseId.RENDER_RESPONSE.equals(facesContext.getCurrentPhaseId())) {
+        if (PhaseId.RENDER_RESPONSE.equals(facesContext.getCurrentPhaseId()))
+        {
             // Put current map on next previous map
             // but only if this request is not a redirect
-            if (!isRedirect()) {
+            if (!isRedirect())
+            {
                 _addPostbackMapKey(facesContext.getExternalContext());
             }
         }
@@ -326,22 +354,29 @@ public class MockFlash extends Flash
     @Override
     public void doPostPhaseActions(FacesContext facesContext)
     {
-        if (PhaseId.RENDER_RESPONSE.equals(facesContext.getCurrentPhaseId())) {
+        if (PhaseId.RENDER_RESPONSE.equals(facesContext.getCurrentPhaseId()))
+        {
             //Remove previous flash from session
-            Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
+            Map<String, Object> requestMap = facesContext.getExternalContext()
+                    .getRequestMap();
             String token = (String) requestMap.get(FLASH_POSTBACK_MAP_KEY);
 
-            if (token != null) {
+            if (token != null)
+            {
                 _removeAllChildren(facesContext);
             }
 
-            if (isKeepMessages()) {
+            if (isKeepMessages())
+            {
                 saveMessages(facesContext);
             }
         }
-        else if (isRedirect() &&
-            (facesContext.getResponseComplete() || facesContext.getRenderResponse())) {
-            if (isKeepMessages()) {
+        else if (isRedirect()
+                && (facesContext.getResponseComplete() || facesContext
+                        .getRenderResponse()))
+        {
+            if (isKeepMessages())
+            {
                 saveMessages(facesContext);
             }
         }
@@ -363,27 +398,37 @@ public class MockFlash extends Flash
     {
         List<MessageEntry> messageList = null;
 
-        Iterator<String> iterClientIds = facesContext.getClientIdsWithMessages();
-        while (iterClientIds.hasNext()) {
+        Iterator<String> iterClientIds = facesContext
+                .getClientIdsWithMessages();
+        while (iterClientIds.hasNext())
+        {
             String clientId = (String) iterClientIds.next();
-            Iterator<FacesMessage> iterMessages = facesContext.getMessages(clientId);
+            Iterator<FacesMessage> iterMessages = facesContext
+                    .getMessages(clientId);
 
-            while (iterMessages.hasNext()) {
+            while (iterMessages.hasNext())
+            {
                 FacesMessage message = iterMessages.next();
 
-                if (messageList == null) {
+                if (messageList == null)
+                {
                     messageList = new ArrayList<MessageEntry>();
                 }
                 messageList.add(new MessageEntry(clientId, message));
             }
         }
 
-        if (messageList != null) {
-            if (isRedirect()) {
-                getPostbackRequestMap(facesContext).put(FLASH_KEEP_MESSAGES_LIST, messageList);
-            }
-            else {
-                getCurrentRequestMap(facesContext).put(FLASH_KEEP_MESSAGES_LIST, messageList);
+        if (messageList != null)
+        {
+            if (isRedirect())
+            {
+                getPostbackRequestMap(facesContext).put(
+                        FLASH_KEEP_MESSAGES_LIST, messageList);
+            }
+            else
+            {
+                getCurrentRequestMap(facesContext).put(
+                        FLASH_KEEP_MESSAGES_LIST, messageList);
             }
         }
     }
@@ -391,22 +436,24 @@ public class MockFlash extends Flash
     protected void restoreMessages(FacesContext facesContext)
     {
         Map<String, Object> postbackMap = getPostbackRequestMap(facesContext);
-        List<MessageEntry> messageList = (List<MessageEntry>)
-            postbackMap.get(FLASH_KEEP_MESSAGES_LIST);
+        List<MessageEntry> messageList = (List<MessageEntry>) postbackMap
+                .get(FLASH_KEEP_MESSAGES_LIST);
 
-        if (messageList != null) {
+        if (messageList != null)
+        {
             Iterator iterMessages = messageList.iterator();
 
-            while (iterMessages.hasNext()) {
+            while (iterMessages.hasNext())
+            {
                 MessageEntry message = (MessageEntry) iterMessages.next();
-                facesContext.addMessage((String) message.clientId, (FacesMessage) message.message);
+                facesContext.addMessage((String) message.clientId,
+                        (FacesMessage) message.message);
             }
 
             postbackMap.remove(FLASH_KEEP_MESSAGES_LIST);
         }
     }
 
-
     //private void _addPreviousToken
 
     /**
@@ -416,14 +463,18 @@ public class MockFlash extends Flash
     {
         String token = null;
         Object response = externalContext.getResponse();
-        if (response instanceof HttpServletResponse) {
+        if (response instanceof HttpServletResponse)
+        {
             //Use a cookie
-            Cookie cookie = (Cookie) externalContext.getRequestCookieMap().get(FLASH_POSTBACK_MAP_KEY);
-            if (cookie != null) {
+            Cookie cookie = (Cookie) externalContext.getRequestCookieMap().get(
+                    FLASH_POSTBACK_MAP_KEY);
+            if (cookie != null)
+            {
                 token = cookie.getValue();
             }
         }
-        else {
+        else
+        {
             //Use HttpSession or PortletSession object
             Map<String, Object> sessionMap = externalContext.getSessionMap();
             token = (String) sessionMap.get(FLASH_POSTBACK_MAP_KEY);
@@ -439,14 +490,14 @@ public class MockFlash extends Flash
     private void _addPostbackMapKey(ExternalContext externalContext)
     {
         Object response = externalContext.getResponse();
-        String token = (String) externalContext.getRequestMap().get(FLASH_CURRENT_MAP_KEY);
+        String token = (String) externalContext.getRequestMap().get(
+                FLASH_CURRENT_MAP_KEY);
 
         //Use HttpSession or PortletSession object
         Map<String, Object> sessionMap = externalContext.getSessionMap();
         sessionMap.put(FLASH_POSTBACK_MAP_KEY, token);
     }
 
-
     /**
      * For check if there is a redirect we to take into accout this points:
      * <p/>
@@ -462,16 +513,19 @@ public class MockFlash extends Flash
         ExternalContext externalContext = facesContext.getExternalContext();
         Map<String, Object> requestMap = externalContext.getRequestMap();
         Boolean redirect = (Boolean) requestMap.get(FLASH_REDIRECT);
-        if (redirect == null) {
+        if (redirect == null)
+        {
             Object response = externalContext.getResponse();
-            if (response instanceof HttpServletResponse) {
+            if (response instanceof HttpServletResponse)
+            {
                 // Request values are lost after a redirect. We can create a
                 // temporal cookie to pass the params between redirect calls.
                 // It is better than use HttpSession object, because this cookie
                 // is never sent by the server.
                 Cookie cookie = (Cookie) externalContext.getRequestCookieMap()
-                    .get(FLASH_REDIRECT);
-                if (cookie != null) {
+                        .get(FLASH_REDIRECT);
+                if (cookie != null)
+                {
                     redirect = Boolean.TRUE;
                     HttpServletResponse httpResponse = (HttpServletResponse) response;
                     // A redirect happened, so it is safe to remove the cookie, setting
@@ -482,24 +536,28 @@ public class MockFlash extends Flash
                     httpResponse.addCookie(cookie);
                     requestMap.put(FLASH_REDIRECT, redirect);
                 }
-                else {
+                else
+                {
                     redirect = Boolean.FALSE;
                 }
             }
-            else {
+            else
+            {
                 // Note that on portlet world we can't create cookies,
                 // so we are forced to use the session map. Anyway,
                 // according to the Bridge implementation(for example see
                 // org.apache.myfaces.portlet.faces.bridge.BridgeImpl)
                 // session object is created at start faces request
                 Map<String, Object> sessionMap = externalContext
-                    .getSessionMap();
+                        .getSessionMap();
                 redirect = (Boolean) sessionMap.get(FLASH_REDIRECT);
-                if (redirect != null) {
+                if (redirect != null)
+                {
                     sessionMap.remove(FLASH_REDIRECT);
                     requestMap.put(FLASH_REDIRECT, redirect);
                 }
-                else {
+                else
+                {
                     redirect = Boolean.FALSE;
                 }
             }
@@ -515,9 +573,11 @@ public class MockFlash extends Flash
         Map<String, Object> requestMap = externalContext.getRequestMap();
 
         Boolean previousRedirect = (Boolean) requestMap.get(FLASH_REDIRECT);
-        previousRedirect = (previousRedirect == null) ? Boolean.FALSE : previousRedirect;
+        previousRedirect = (previousRedirect == null) ? Boolean.FALSE
+                : previousRedirect;
 
-        if (!previousRedirect.booleanValue() && redirect) {
+        if (!previousRedirect.booleanValue() && redirect)
+        {
             // This request contains a redirect. This condition is in general
             // triggered by a NavigationHandler. After a redirect all request scope
             // values get lost, so in order to preserve this value we need to
@@ -536,7 +596,8 @@ public class MockFlash extends Flash
     public void keep(String key)
     {
         FacesContext facesContext = FacesContext.getCurrentInstance();
-        Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
+        Map<String, Object> requestMap = facesContext.getExternalContext()
+                .getRequestMap();
         Object value = requestMap.get(key);
         getCurrentRequestMap(facesContext).put(key, value);
     }
@@ -547,7 +608,8 @@ public class MockFlash extends Flash
     @Override
     public void putNow(String key, Object value)
     {
-        FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(key, value);
+        FacesContext.getCurrentInstance().getExternalContext().getRequestMap()
+                .put(key, value);
     }
 
     @Override
@@ -557,16 +619,19 @@ public class MockFlash extends Flash
         ExternalContext externalContext = facesContext.getExternalContext();
         Map<String, Object> requestMap = externalContext.getRequestMap();
         Boolean keepMessages = (Boolean) requestMap.get(FLASH_KEEP_MESSAGES);
-        if (keepMessages == null) {
+        if (keepMessages == null)
+        {
             Object response = externalContext.getResponse();
-            if (response instanceof HttpServletResponse) {
+            if (response instanceof HttpServletResponse)
+            {
                 // Request values are lost after a redirect. We can create a
                 // temporal cookie to pass the params between redirect calls.
                 // It is better than use HttpSession object, because this cookie
                 // is never sent by the server.
                 Cookie cookie = (Cookie) externalContext.getRequestCookieMap()
-                    .get(FLASH_KEEP_MESSAGES);
-                if (cookie != null) {
+                        .get(FLASH_KEEP_MESSAGES);
+                if (cookie != null)
+                {
                     keepMessages = Boolean.TRUE;
                     HttpServletResponse httpResponse = (HttpServletResponse) response;
                     // It is safe to remove the cookie, setting
@@ -577,24 +642,28 @@ public class MockFlash extends Flash
                     httpResponse.addCookie(cookie);
                     requestMap.put(FLASH_KEEP_MESSAGES, keepMessages);
                 }
-                else {
+                else
+                {
                     keepMessages = Boolean.FALSE;
                 }
             }
-            else {
+            else
+            {
                 // Note that on portlet world we can't create cookies,
                 // so we are forced to use the session map. Anyway,
                 // according to the Bridge implementation(for example see
                 // org.apache.myfaces.portlet.faces.bridge.BridgeImpl)
                 // session object is created at start faces request
                 Map<String, Object> sessionMap = externalContext
-                    .getSessionMap();
+                        .getSessionMap();
                 keepMessages = (Boolean) sessionMap.get(FLASH_KEEP_MESSAGES);
-                if (keepMessages != null) {
+                if (keepMessages != null)
+                {
                     sessionMap.remove(FLASH_KEEP_MESSAGES);
                     requestMap.put(FLASH_KEEP_MESSAGES, keepMessages);
                 }
-                else {
+                else
+                {
                     keepMessages = Boolean.FALSE;
                 }
             }
@@ -613,11 +682,15 @@ public class MockFlash extends Flash
         ExternalContext externalContext = facesContext.getExternalContext();
         Map<String, Object> requestMap = externalContext.getRequestMap();
 
-        Boolean previousKeepMessages = (Boolean) requestMap.get(FLASH_KEEP_MESSAGES);
-        previousKeepMessages = (previousKeepMessages == null) ? Boolean.FALSE : previousKeepMessages;
+        Boolean previousKeepMessages = (Boolean) requestMap
+                .get(FLASH_KEEP_MESSAGES);
+        previousKeepMessages = (previousKeepMessages == null) ? Boolean.FALSE
+                : previousKeepMessages;
 
-        if (!previousKeepMessages.booleanValue() && keepMessages) {
-            externalContext.getSessionMap().put(FLASH_KEEP_MESSAGES, keepMessages);
+        if (!previousKeepMessages.booleanValue() && keepMessages)
+        {
+            externalContext.getSessionMap().put(FLASH_KEEP_MESSAGES,
+                    keepMessages);
         }
         requestMap.put(FLASH_KEEP_MESSAGES, keepMessages);
     }
@@ -644,14 +717,17 @@ public class MockFlash extends Flash
 
     public Object get(Object key)
     {
-        if (key == null) {
+        if (key == null)
+        {
             return null;
         }
 
-        if ("keepMessages".equals(key)) {
+        if ("keepMessages".equals(key))
+        {
             return isKeepMessages();
         }
-        else if ("redirect".equals(key)) {
+        else if ("redirect".equals(key))
+        {
             return isRedirect();
         }
 
@@ -659,7 +735,8 @@ public class MockFlash extends Flash
         Map<String, Object> postbackMap = getPostbackRequestMap(context);
         Object returnValue = null;
 
-        if (postbackMap != null) {
+        if (postbackMap != null)
+        {
             returnValue = postbackMap.get(key);
         }
 
@@ -678,21 +755,25 @@ public class MockFlash extends Flash
 
     public Object put(String key, Object value)
     {
-        if (key == null) {
+        if (key == null)
+        {
             return null;
         }
 
-        if ("keepMessages".equals(key)) {
+        if ("keepMessages".equals(key))
+        {
             Boolean booleanValue = convertToBoolean(value);
             this.setKeepMessages(booleanValue);
             return booleanValue;
         }
-        else if ("redirect".equals(key)) {
+        else if ("redirect".equals(key))
+        {
             Boolean booleanValue = convertToBoolean(value);
             this.setRedirect(booleanValue);
             return booleanValue;
         }
-        else {
+        else
+        {
             Object returnValue = getCurrentPhaseMap().put(key, value);
             return returnValue;
         }
@@ -701,10 +782,12 @@ public class MockFlash extends Flash
     private Boolean convertToBoolean(Object value)
     {
         Boolean booleanValue;
-        if (value instanceof Boolean) {
+        if (value instanceof Boolean)
+        {
             booleanValue = (Boolean) value;
         }
-        else {
+        else
+        {
             booleanValue = Boolean.parseBoolean(value.toString());
         }
         return booleanValue;