[richfaces-svn-commits] JBoss Rich Faces SVN: r15808 - in root/framework/trunk/test-base/src: main/java/org/richfaces/test/staging and 2 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Nov 2 07:12:02 EST 2009


Author: Alex.Kolonitsky
Date: 2009-11-02 07:12:01 -0500 (Mon, 02 Nov 2009)
New Revision: 15808

Modified:
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/AbstractFacesTest.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/AbstractThreadedTest.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/LocalWebClient.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/LocalWebConnection.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/LocalWebResponse.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/TestException.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/EventInvoker.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/FilterContainer.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/HttpMethod.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/InvocationErrorEvent.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/InvocationEvent.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/InvocationListener.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/NotImplementedException.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/PageContextExtension.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/RequestChain.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerLogger.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerResource.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerResourcePath.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerResourcesDirectory.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServletContainer.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingConnection.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingHttpRequest.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingHttpResponse.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingHttpSession.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingInitialContextFactoryBuilder.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingServer.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingServletContext.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StaticServlet.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/URLScanner.java
   root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/UrlServerResource.java
   root/framework/trunk/test-base/src/test/java/org/richfaces/test/FacesServerTest.java
   root/framework/trunk/test-base/src/test/java/org/richfaces/test/HelloBean.java
   root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java
   root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/ServerResourceTest.java
   root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/ServletTest.java
   root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java
Log:
Code style policy
https://jira.jboss.org/jira/browse/RFPL-195

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/AbstractFacesTest.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/AbstractFacesTest.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/AbstractFacesTest.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,13 +1,16 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test;
 
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+
 import java.net.MalformedURLException;
 import java.net.URL;
+
 import java.util.EventListener;
 import java.util.Locale;
 import java.util.Properties;
@@ -27,310 +30,329 @@
 import javax.faces.lifecycle.LifecycleFactory;
 import javax.faces.render.RenderKitFactory;
 import javax.faces.webapp.FacesServlet;
+
 import javax.servlet.Filter;
 
 import junit.framework.TestCase;
 
 import org.junit.After;
 import org.junit.Before;
+
 import org.richfaces.test.staging.FilterContainer;
 import org.richfaces.test.staging.ServletContainer;
 import org.richfaces.test.staging.StagingConnection;
 import org.richfaces.test.staging.StagingServer;
 
 /**
- * Base class for all JSF test cases. 
+ * Base class for all JSF test cases.
  * @author asmirnov
- * 
+ *
  */
 public abstract class AbstractFacesTest extends TestCase {
 
-	private ClassLoader contextClassLoader;
+    /**
+     * JSF {@link Application} instance. Populated by the default {@link #setUp()} method.
+     */
+    protected Application application;
 
-	/**
-	 * Prepared test server instance. Populated by the default {@link #setUp()} method.
-	 */
-	protected StagingServer facesServer;
+    /**
+     * Current virtual connection. This field populated by the {@link #setupWebContent()} method only.
+     */
+    protected StagingConnection connection;
+    private ClassLoader contextClassLoader;
 
-	/**
-	 * Current virtual connection. This field populated by the {@link #setupWebContent()} method only.
-	 */
-	protected StagingConnection connection;
+    /**
+     * Current {@link FacesContext} instance. This field populated by the {@link #setupWebContent()} method only.
+     */
+    protected FacesContext facesContext;
 
-	/**
-	 * Current {@link FacesContext} instance. This field populated by the {@link #setupWebContent()} method only.
-	 */
-	protected FacesContext facesContext;
+    /**
+     * Prepared test server instance. Populated by the default {@link #setUp()} method.
+     */
+    protected StagingServer facesServer;
 
-	/**
-	 * JSF {@link Lifecycle} instance. Populated by the default {@link #setUp()} method.
-	 */
-	protected Lifecycle lifecycle;
+    /**
+     * JSF {@link Lifecycle} instance. Populated by the default {@link #setUp()} method.
+     */
+    protected Lifecycle lifecycle;
 
-	/**
-	 * JSF {@link Application} instance. Populated by the default {@link #setUp()} method.
-	 */
-	protected Application application;
+    /**
+     * Setup staging server instance with JSF implementation. First, this method creates a local test instance
+     * and calls the other template method in the next sequence:
+     * <ol>
+     * <li>{@link #setupFacesServlet()}</li>
+     * <li>{@link #setupFacesListener()}</li>
+     * <li>{@link #setupJsfInitParameters()}</li>
+     * <li>{@link #setupWebContent()}</li>
+     * </ol>
+     * After them, test server is initialized as well as fields {@link #lifecycle} and {@link #application} populated.
+     * Also, if the resource "logging.properties" is exist in the test class package, The Java {@link LogManager} will
+     * be configured with its content.
+     * @throws java.lang.Exception
+     */
+    @Before
+    public void setUp() throws Exception {
+        contextClassLoader = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
 
-	/**
-	 * Setup staging server instance with JSF implementation. First, this method creates a local test instance 
-	 * and calls the other template method in the next sequence:
-	 * <ol>
-	 * <li>{@link #setupFacesServlet()}</li>
-	 * <li>{@link #setupFacesListener()}</li>
-	 * <li>{@link #setupJsfInitParameters()}</li>
-	 * <li>{@link #setupWebContent()}</li>
-	 * </ol>
-	 * After them, test server is initialized as well as fields {@link #lifecycle} and {@link #application} populated.
-	 * Also, if the resource "logging.properties" is exist in the test class package, The Java {@link LogManager} will be configured with its content.  
-	 * @throws java.lang.Exception
-	 */
-	@Before
-	public void setUp() throws Exception {
-		contextClassLoader = Thread.currentThread().getContextClassLoader();
-		Thread.currentThread().setContextClassLoader(
-				this.getClass().getClassLoader());
-		InputStream stream = this.getClass().getResourceAsStream(
-				"logging.properties");
-		if (null != stream) {
-			try {
-				LogManager.getLogManager().readConfiguration(stream);
-			} catch (Exception e) {
-				// Ignore it.
-			} finally {
-				try {
-					stream.close();
-				} catch (IOException e) {
-					// Ignore it.
-				}
-			}
-		}
-		facesServer = new StagingServer();
-		setupFacesServlet();
-		setupFacesListener();
-		setupJsfInitParameters();
-		setupWebContent();
-		facesServer.init();
-		ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder
-				.getFactory(FactoryFinder.APPLICATION_FACTORY);
-		application = applicationFactory.getApplication();
-		LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
-				.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
-		lifecycle = lifecycleFactory
-				.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
-	}
+        InputStream stream = this.getClass().getResourceAsStream("logging.properties");
 
-	/**
-	 * This hook method called from the {@link #setUp()} should append JSF implementation
-	 * listener to the test server. Default version applends "com.sun.faces.config.ConfigureListener"
-	 * or "org.apache.myfaces.webapp.StartupServletContextListener" for the existed SUN RI or MyFaces implementation.
-	 * This metod also calls appropriate {@link #setupSunFaces()} or {@link #setupMyFaces()} methods.
-	 */
-	protected void setupFacesListener() {
-		EventListener listener = null;
-		try {
-			// Check Sun RI configuration listener class.
-			Class<? extends EventListener> listenerClass = contextClassLoader
-					.loadClass("com.sun.faces.config.ConfigureListener")
-					.asSubclass(EventListener.class);
-			listener = listenerClass.newInstance();
-			setupSunFaces();
-		} catch (ClassNotFoundException e) {
-			// No JSF RI listener, check MyFaces.
-			Class<? extends EventListener> listenerClass;
-			try {
-				listenerClass = contextClassLoader
-						.loadClass(
-								"org.apache.myfaces.webapp.StartupServletContextListener")
-						.asSubclass(EventListener.class);
-				listener = listenerClass.newInstance();
-				setupMyFaces();
-			} catch (ClassNotFoundException e1) {
-				throw new TestException("No JSF listeners have been found", e1);
-			} catch (Exception e2) {
-				throw new TestException("Error instantiate MyFaces listener",
-						e2);
-			}
-		} catch (Exception e) {
-			throw new TestException("Error instantiate JSF RI listener", e);
-		}
-		facesServer.addWebListener(listener);
-	}
+        if (null != stream) {
+            try {
+                LogManager.getLogManager().readConfiguration(stream);
+            } catch (Exception e) {
 
-	/**
-	 * This template method called from {@link #setUp()} to create {@link FacesServlet} instance.
-	 * The default implementation also tests presense of the "org.ajax4jsf.Filter" class.
-	 * If this class is avalable, these instance appended to the Faces Servlet call chain.
-	 * Default mapping to the FacesServlet instance is "*.jsf"
-	 */
-	protected void setupFacesServlet() {
-		ServletContainer facesServletContainer = new ServletContainer("*.jsf",
-				new FacesServlet());
-		facesServletContainer.setName("Faces Servlet");
-		try {
-			// Check for an ajax4jsf filter.
-			Class<? extends Filter> ajaxFilterClass = contextClassLoader
-					.loadClass("org.ajax4jsf.Filter").asSubclass(Filter.class);
-			Filter ajaxFilter = ajaxFilterClass.newInstance();
-			FilterContainer filterContainer = new FilterContainer(ajaxFilter,
-					facesServletContainer);
-			filterContainer.setName("ajax4jsf");
-			facesServer.addResource("/WEB-INF/web.xml",
-					"org/richfaces/test/ajax-web.xml");
-			facesServer.addServlet(filterContainer);
-		} catch (ClassNotFoundException e) {
-			// No Richfaces filter, uses servlet directly.
-			facesServer.addResource("/WEB-INF/web.xml",
-					"org/richfaces/test/web.xml");
-			facesServer.addServlet(facesServletContainer);
-		} catch (Exception e) {
-			throw new TestException(e);
-		}
-	}
+                // Ignore it.
+            } finally {
+                try {
+                    stream.close();
+                } catch (IOException e) {
 
-	/**
-	 * This template method called from {@link #setUp()} to append appropriate init parameters to the test server.
-	 * The default implementation sets state saving method to the "server", default jsf page suffix to the ".xhtml"
-	 * and project stage to UnitTest
-	 */
-	protected void setupJsfInitParameters() {
-		facesServer.addInitParameter(
-				StateManager.STATE_SAVING_METHOD_PARAM_NAME,
-				StateManager.STATE_SAVING_METHOD_SERVER);
-		facesServer.addInitParameter(ViewHandler.DEFAULT_SUFFIX_PARAM_NAME,
-				".xhtml");
-	
-		facesServer.addInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, 
-				ProjectStage.UnitTest.name());
-	}
+                    // Ignore it.
+                }
+            }
+        }
 
-	/**
-	 * This template method called from the {@link #setupFacesListener()} if MyFaces implementation presents.
-	 * The default implementation does nothing.
-	 */
-	protected void setupMyFaces() {
-		// Do nothing by default.
-	}
+        facesServer = new StagingServer();
+        setupFacesServlet();
+        setupFacesListener();
+        setupJsfInitParameters();
+        setupWebContent();
+        facesServer.init();
 
-	/**
-	 * This template method called from the {@link #setupFacesListener()} if Sun JSF reference implementation presents.
-	 * The default implementation sets the "com.sun.faces.validateXml" "com.sun.faces.verifyObjects" init parameters to the "true"
-	 */
-	protected void setupSunFaces() {
-		facesServer.addInitParameter("com.sun.faces.validateXml", "true");
-		facesServer.addInitParameter("com.sun.faces.verifyObjects", "true");
-	}
+        ApplicationFactory applicationFactory =
+            (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
 
-	/**
-	 * This template method called from the {@link #setUp()} to populate virtual server content.
-	 * The default implementation tries to load web content from directory pointed by the System property
-	 * "webroot" or same property from the "/webapp.properties" file.
-	 */
-	protected void setupWebContent() {
-		String webappDirectory = System.getProperty("webroot");
+        application = applicationFactory.getApplication();
+
+        LifecycleFactory lifecycleFactory =
+            (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+
+        lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+    }
+
+    /**
+     * This hook method called from the {@link #setUp()} should append JSF implementation
+     * listener to the test server. Default version applends "com.sun.faces.config.ConfigureListener"
+     * or "org.apache.myfaces.webapp.StartupServletContextListener" for the existed SUN RI or MyFaces implementation.
+     * This metod also calls appropriate {@link #setupSunFaces()} or {@link #setupMyFaces()} methods.
+     */
+    protected void setupFacesListener() {
+        EventListener listener = null;
+
+        try {
+
+            // Check Sun RI configuration listener class.
+            Class<? extends EventListener> listenerClass =
+                contextClassLoader.loadClass("com.sun.faces.config.ConfigureListener").asSubclass(EventListener.class);
+
+            listener = listenerClass.newInstance();
+            setupSunFaces();
+        } catch (ClassNotFoundException e) {
+
+            // No JSF RI listener, check MyFaces.
+            Class<? extends EventListener> listenerClass;
+
+            try {
+                listenerClass = contextClassLoader.loadClass(
+                    "org.apache.myfaces.webapp.StartupServletContextListener").asSubclass(EventListener.class);
+                listener = listenerClass.newInstance();
+                setupMyFaces();
+            } catch (ClassNotFoundException e1) {
+                throw new TestException("No JSF listeners have been found", e1);
+            } catch (Exception e2) {
+                throw new TestException("Error instantiate MyFaces listener", e2);
+            }
+        } catch (Exception e) {
+            throw new TestException("Error instantiate JSF RI listener", e);
+        }
+
+        facesServer.addWebListener(listener);
+    }
+
+    /**
+     * This template method called from {@link #setUp()} to create {@link FacesServlet} instance.
+     * The default implementation also tests presense of the "org.ajax4jsf.Filter" class.
+     * If this class is avalable, these instance appended to the Faces Servlet call chain.
+     * Default mapping to the FacesServlet instance is "*.jsf"
+     */
+    protected void setupFacesServlet() {
+        ServletContainer facesServletContainer = new ServletContainer("*.jsf", new FacesServlet());
+
+        facesServletContainer.setName("Faces Servlet");
+
+        try {
+
+            // Check for an ajax4jsf filter.
+            Class<? extends Filter> ajaxFilterClass =
+                contextClassLoader.loadClass("org.ajax4jsf.Filter").asSubclass(Filter.class);
+            Filter ajaxFilter = ajaxFilterClass.newInstance();
+            FilterContainer filterContainer = new FilterContainer(ajaxFilter, facesServletContainer);
+
+            filterContainer.setName("ajax4jsf");
+            facesServer.addResource("/WEB-INF/web.xml", "org/richfaces/test/ajax-web.xml");
+            facesServer.addServlet(filterContainer);
+        } catch (ClassNotFoundException e) {
+
+            // No Richfaces filter, uses servlet directly.
+            facesServer.addResource("/WEB-INF/web.xml", "org/richfaces/test/web.xml");
+            facesServer.addServlet(facesServletContainer);
+        } catch (Exception e) {
+            throw new TestException(e);
+        }
+    }
+
+    /**
+     * This template method called from {@link #setUp()} to append appropriate init parameters to the test server.
+     * The default implementation sets state saving method to the "server", default jsf page suffix to the ".xhtml"
+     * and project stage to UnitTest
+     */
+    protected void setupJsfInitParameters() {
+        facesServer.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME,
+                                     StateManager.STATE_SAVING_METHOD_SERVER);
+        facesServer.addInitParameter(ViewHandler.DEFAULT_SUFFIX_PARAM_NAME, ".xhtml");
+        facesServer.addInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, ProjectStage.UnitTest.name());
+    }
+
+    /**
+     * This template method called from the {@link #setupFacesListener()} if MyFaces implementation presents.
+     * The default implementation does nothing.
+     */
+    protected void setupMyFaces() {
+
+        // Do nothing by default.
+    }
+
+    /**
+     * This template method called from the {@link #setupFacesListener()} if Sun JSF reference implementation presents.
+     * The default implementation sets the "com.sun.faces.validateXml" "com.sun.faces.verifyObjects" init parameters to
+     * the "true"
+     */
+    protected void setupSunFaces() {
+        facesServer.addInitParameter("com.sun.faces.validateXml", "true");
+        facesServer.addInitParameter("com.sun.faces.verifyObjects", "true");
+    }
+
+    /**
+     * This template method called from the {@link #setUp()} to populate virtual server content.
+     * The default implementation tries to load web content from directory pointed by the System property
+     * "webroot" or same property from the "/webapp.properties" file.
+     */
+    protected void setupWebContent() {
+        String webappDirectory = System.getProperty("webroot");
         File webFile = null;
+
         if (null == webappDirectory) {
-                URL resource = this.getClass().getResource("/webapp.properties");
-                if (null != resource && "file".equals(resource.getProtocol())) {
-                	Properties webProperties = new Properties();
-                	try {
-						InputStream inputStream = resource.openStream();
-						webProperties.load(inputStream);
-						inputStream.close();
-	                    webFile = new File(resource.getPath());
-	                    webFile = new File(webFile.getParentFile(), webProperties.getProperty("webroot")).getAbsoluteFile();
-	            		facesServer.addResourcesFromDirectory("/", webFile);
-					} catch (IOException e) {
-						throw new TestException(e);
-					}
+            URL resource = this.getClass().getResource("/webapp.properties");
+
+            if (null != resource && "file".equals(resource.getProtocol())) {
+                Properties webProperties = new Properties();
+
+                try {
+                    InputStream inputStream = resource.openStream();
+
+                    webProperties.load(inputStream);
+                    inputStream.close();
+                    webFile = new File(resource.getPath());
+                    webFile = new File(webFile.getParentFile(), webProperties.getProperty("webroot")).getAbsoluteFile();
+                    facesServer.addResourcesFromDirectory("/", webFile);
+                } catch (IOException e) {
+                    throw new TestException(e);
                 }
+            }
         } else {
-                webFile = new File(webappDirectory);
-        		facesServer.addResourcesFromDirectory("/", webFile);
+            webFile = new File(webappDirectory);
+            facesServer.addResourcesFromDirectory("/", webFile);
         }
+    }
 
-	}
+    /**
+     * Setup virtual server connection to run tests inside JSF lifecycle.
+     * The default implementation setups virtual request to the "http://localhost/test.jsf" URL and creates
+     * {@link FacesContext} instance.
+     * Two template methods are called :
+     * <ol>
+     * <li>{@link #setupConnection()} to prepare request method, parameters, headers and so</li>
+     * <li>{@link #setupView()} to create default view.</li>
+     * </ol>
+     * @throws Exception
+     */
+    protected void setupFacesRequest() throws Exception {
+        String url = "http://localhost/test.jsf";
 
-	/**
-	 * Setup virtual server connection to run tests inside JSF lifecycle.
-	 * The default implementation setups virtual request to the "http://localhost/test.jsf" URL and creates {@link FacesContext} instance.
-	 * Two template methods are called :
-	 * <ol>
-	 * <li>{@link #setupConnection()} to prepare request method, parameters, headers and so</li>
-	 * <li>{@link #setupView()} to create default view.</li>
-	 * </ol>
-	 * @throws Exception
-	 */
-	protected void setupFacesRequest() throws Exception {
-		String url = "http://localhost/test.jsf";
-		setupFacesRequest(url);
-		UIViewRoot viewRoot = setupView();
-		if (null != viewRoot) {
-			facesContext.setViewRoot(viewRoot);
-		}
-	}
+        setupFacesRequest(url);
 
-	/**
-	 * <p class="changed_added_2_0"></p>
-	 * @param url
-	 * @throws MalformedURLException
-	 * @throws FacesException
-	 */
-	protected void setupFacesRequest(String url) throws MalformedURLException,
-			FacesException {
-		connection = facesServer.getConnection(new URL(
-				url));
-		setupConnection();
-		connection.start();
-		FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder
-				.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
-		facesContext = facesContextFactory.getFacesContext(facesServer
-				.getContext(), connection.getRequest(), connection
-				.getResponse(), lifecycle);
-	}
+        UIViewRoot viewRoot = setupView();
 
-	/**
-	 * This template method called from the {@link #setupFacesRequest()} to create components view tree in the virtual request. 
-	 * The default implementation is only creates {@link UIViewRoot} instance for view ID "/test.xhtml".
-	 * @return
-	 */
-	protected UIViewRoot setupView() {
-		UIViewRoot viewRoot = (UIViewRoot) application.createComponent(UIViewRoot.COMPONENT_TYPE);
-		viewRoot.setViewId("/test.xhtml");
-		viewRoot.setLocale(Locale.getDefault());
-		viewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
-		return viewRoot;
-	}
+        if (null != viewRoot) {
+            facesContext.setViewRoot(viewRoot);
+        }
+    }
 
-	/**
-	 * This template method called from the {@link #setupFacesRequest()} to setup additional virtual connection parameters.
-	 * The default implementation does nothing.
-	 */
-	protected void setupConnection() {
+    /**
+     * <p class="changed_added_2_0"></p>
+     * @param url
+     * @throws MalformedURLException
+     * @throws FacesException
+     */
+    protected void setupFacesRequest(String url) throws MalformedURLException, FacesException {
+        connection = facesServer.getConnection(new URL(url));
+        setupConnection();
+        connection.start();
 
-	}
+        FacesContextFactory facesContextFactory =
+            (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
 
-	/**
-	 * Virtual server instance cleanup.
-	 * @throws java.lang.Exception
-	 */
-	@After
-	public void tearDown() throws Exception {
-		if (null != facesContext) {
-			facesContext.release();
-			facesContext = null;
-		}
-		if (null != connection) {
-			if (!connection.isFinished()) {
-				connection.finish();
-			}
-			connection = null;
-		}
-		facesServer.destroy();
-		Thread.currentThread().setContextClassLoader(contextClassLoader);
-		facesServer = null;
-		application = null;
-		lifecycle = null;
-	}
+        facesContext = facesContextFactory.getFacesContext(facesServer.getContext(), connection.getRequest(),
+                connection.getResponse(), lifecycle);
+    }
 
+    /**
+     * This template method called from the {@link #setupFacesRequest()} to create components view tree in the virtual
+     * request.
+     * The default implementation is only creates {@link UIViewRoot} instance for view ID "/test.xhtml".
+     * @return
+     */
+    protected UIViewRoot setupView() {
+        UIViewRoot viewRoot = (UIViewRoot) application.createComponent(UIViewRoot.COMPONENT_TYPE);
+
+        viewRoot.setViewId("/test.xhtml");
+        viewRoot.setLocale(Locale.getDefault());
+        viewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+
+        return viewRoot;
+    }
+
+    /**
+     * This template method called from the {@link #setupFacesRequest()} to setup additional virtual connection
+     * parameters.
+     * The default implementation does nothing.
+     */
+    protected void setupConnection() {}
+
+    /**
+     * Virtual server instance cleanup.
+     * @throws java.lang.Exception
+     */
+    @After
+    public void tearDown() throws Exception {
+        if (null != facesContext) {
+            facesContext.release();
+            facesContext = null;
+        }
+
+        if (null != connection) {
+            if (!connection.isFinished()) {
+                connection.finish();
+            }
+
+            connection = null;
+        }
+
+        facesServer.destroy();
+        Thread.currentThread().setContextClassLoader(contextClassLoader);
+        facesServer = null;
+        application = null;
+        lifecycle = null;
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/AbstractThreadedTest.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/AbstractThreadedTest.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/AbstractThreadedTest.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test;
 
@@ -13,17 +14,19 @@
  */
 public abstract class AbstractThreadedTest extends TestCase {
 
-    /** 
-     * The threads that are executing.
+    /**
+     * The tests TestResult.
      */
-    private Thread threads[] = null;
-    /**
-     * The tests TestResult.*/
     private TestResult testResult = null;
 
+    /**
+     * The threads that are executing.
+     */
+    private Thread[] threads = null;
+
     public void interruptThreads() {
-        if(threads != null) {
-            for(int i = 0;i < threads.length;i++) {
+        if (threads != null) {
+            for (int i = 0; i < threads.length; i++) {
                 threads[i].interrupt();
             }
         }
@@ -31,7 +34,7 @@
 
     /**
      * Override run so we can squirrel away the test result.
-     * 
+     *
      */
     @Override
     public void run(final TestResult result) {
@@ -47,82 +50,90 @@
      * @throws InstantiationException
      * @throws IllegalAccessException
      */
-    protected void runTestCaseThreads(Class<?> clazz, int numThreads)  {
-    	TestCaseRunnable[] runnables = new TestCaseRunnable[numThreads];
-    	for (int i = 0; i < runnables.length; i++) {
-			try {
-				runnables[i]= (TestCaseRunnable) clazz.newInstance();
-			} catch (Exception e) {
-				testResult.addError(this, e);
-				return;
-			}
-		}
-    	runTestCaseRunnables(runnables);
+    protected void runTestCaseThreads(Class<?> clazz, int numThreads) {
+        TestCaseRunnable[] runnables = new TestCaseRunnable[numThreads];
+
+        for (int i = 0; i < runnables.length; i++) {
+            try {
+                runnables[i] = (TestCaseRunnable) clazz.newInstance();
+            } catch (Exception e) {
+                testResult.addError(this, e);
+
+                return;
+            }
+        }
+
+        runTestCaseRunnables(runnables);
     }
+
     /**
      * Run the test case threads.
      * @param runnables - array with instances of {@link TestCaseRunnable} with concrete tests
      */
-    protected void runTestCaseRunnables (final TestCaseRunnable[] runnables) {
-        if(runnables == null) {
+    protected void runTestCaseRunnables(final TestCaseRunnable[] runnables) {
+        if (runnables == null) {
             throw new IllegalArgumentException("runnables is null");
         }
+
         threads = new Thread[runnables.length];
-        for(int i = 0;i < threads.length;i++) {
+
+        for (int i = 0; i < threads.length; i++) {
             threads[i] = new Thread(runnables[i]);
         }
-        for(int i = 0;i < threads.length;i++) {
+
+        for (int i = 0; i < threads.length; i++) {
             threads[i].start();
         }
+
         try {
-            for(int i = 0;i < threads.length;i++) {
+            for (int i = 0; i < threads.length; i++) {
                 threads[i].join();
             }
-        }
-        catch(InterruptedException ignore) {
+        } catch (InterruptedException ignore) {
             System.out.println("Thread join interrupted.");
         }
+
         threads = null;
     }
-    
+
     /**
      * Handle an exception. Since multiple threads won't have their
      * exceptions caught the threads must manually catch them and call
      * <code>handleException ()</code>.
-     * @param t Exception to handle.*/
+     * @param t Exception to handle.
+     */
     private void handleException(final Throwable t) {
-        synchronized(testResult) {
-            if(t instanceof AssertionFailedError) {
-                testResult.addFailure(this, (AssertionFailedError)t);
-            }
-            else {
+        synchronized (testResult) {
+            if (t instanceof AssertionFailedError) {
+                testResult.addFailure(this, (AssertionFailedError) t);
+            } else {
                 testResult.addError(this, t);
             }
         }
     }
-    
+
     /**
      * A test case thread. Override runTestCase () and define
-     * behaviour of test in there.*/
+     * behaviour of test in there.
+     */
     public abstract class TestCaseRunnable implements Runnable {
+
         /**
-         * Override this to define the test*/
-        
-        public abstract void runTestCase()
-                              throws Throwable;
+         * Override this to define the test
+         */
+        public abstract void runTestCase() throws Throwable;
+
         /**
          * Run the test in an environment where
-         * we can handle the exceptions generated by the test method.*/
-        
+         * we can handle the exceptions generated by the test method.
+         */
         public void run() {
             try {
                 runTestCase();
-            }
-            catch(Throwable t) /* Any other exception we handle and then we interrupt the other threads.*/ {
+            } catch (Throwable t) /* Any other exception we handle and then we interrupt the other threads. */ {
                 handleException(t);
                 interruptThreads();
             }
         }
     }
-
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/LocalWebClient.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/LocalWebClient.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/LocalWebClient.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test;
 
@@ -14,57 +15,54 @@
  * Modified version of the HtmlUnit {@link WebClient}. This subclass uses {@link LocalWebConnection} by default,
  * to perform requests to the local saging server {@link StagingServer} instead of real network request.
  * It is also setup synchonous ajax controller {@link WebClient#setAjaxController(com.gargoylesoftware.htmlunit.AjaxController)},
- * to avoid thread syncronisation problem. 
+ * to avoid thread syncronisation problem.
  * @author asmirnov
  *
  */
 @SuppressWarnings("serial")
 public class LocalWebClient extends WebClient {
-	
-	private final StagingServer server;
-	
-	private transient WebConnection webConnection;
+    private final StagingServer server;
+    private transient WebConnection webConnection;
 
-	/**
-	 * Create WebConnection instance for the given {@link StagingServer}
-	 * @param server test server instance.
-	 */
-	public LocalWebClient(StagingServer server) {
-		super();
-		this.server = server;
-		setAjaxController(new NicelyResynchronizingAjaxController());
-	}
+    /**
+     * Create WebConnection instance for the given {@link StagingServer}
+     * @param server test server instance.
+     */
+    public LocalWebClient(StagingServer server) {
+        super();
+        this.server = server;
+        setAjaxController(new NicelyResynchronizingAjaxController());
+    }
 
-	/**
-	 * Create WebConnection instance for the given {@link StagingServer} and browser version.
-	 * @param server test server instance.
-	 * @param browserVersion
-	 */
-	public LocalWebClient(StagingServer server,BrowserVersion browserVersion) {
-		super(browserVersion);
-		this.server = server;
-		setAjaxController(new NicelyResynchronizingAjaxController());
-	}
+    /**
+     * Create WebConnection instance for the given {@link StagingServer} and browser version.
+     * @param server test server instance.
+     * @param browserVersion
+     */
+    public LocalWebClient(StagingServer server, BrowserVersion browserVersion) {
+        super(browserVersion);
+        this.server = server;
+        setAjaxController(new NicelyResynchronizingAjaxController());
+    }
 
-	/**
-	 * Overwride default webConnection.
-	 * @return the webConnection
-	 */
-	@Override
-	public WebConnection getWebConnection() {
-		if (this.webConnection == null) {
-			this.webConnection = new LocalWebConnection(server);			
-		}
+    /**
+     * Overwride default webConnection.
+     * @return the webConnection
+     */
+    @Override
+    public WebConnection getWebConnection() {
+        if (this.webConnection == null) {
+            this.webConnection = new LocalWebConnection(server);
+        }
 
-		return this.webConnection;
-	}
+        return this.webConnection;
+    }
 
-	/**
-	 * @param webConnection the webConnection to set
-	 */
-	@Override
-	public void setWebConnection(WebConnection webConnection) {
-		this.webConnection = webConnection;
-	}
-
+    /**
+     * @param webConnection the webConnection to set
+     */
+    @Override
+    public void setWebConnection(WebConnection webConnection) {
+        this.webConnection = webConnection;
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/LocalWebConnection.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/LocalWebConnection.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/LocalWebConnection.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,11 +1,13 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test;
 
 import java.io.IOException;
 
 import org.apache.commons.httpclient.NameValuePair;
+
 import org.richfaces.test.staging.HttpMethod;
 import org.richfaces.test.staging.StagingConnection;
 import org.richfaces.test.staging.StagingServer;
@@ -17,48 +19,58 @@
 
 /**
  * This implementation of the HtmlUnit {@link WebConnection} execute http requests on the local
- * staging server instead of the real network connection. 
+ * staging server instead of the real network connection.
  * @author asmirnov
  *
  */
 public final class LocalWebConnection implements WebConnection {
-	/**
-	 * test server instance
-	 */
-	private final StagingServer localServer;
 
-	/**
-	 * @param localServer
-	 */
-	public LocalWebConnection(StagingServer localServer) {
-		this.localServer = localServer;
-	}
+    /**
+     * test server instance
+     */
+    private final StagingServer localServer;
 
-	/* (non-Javadoc)
-	 * @see com.gargoylesoftware.htmlunit.WebConnection#getResponse(com.gargoylesoftware.htmlunit.WebRequestSettings)
-	 */
-	public WebResponse getResponse(WebRequestSettings settings)
-			throws IOException {
-		StagingConnection connection = localServer.getConnection(settings.getUrl());
-		// Propagate web request settings to the local connection.
-		for (NameValuePair param : settings.getRequestParameters()) {
-			connection.addRequestParameter(param.getName(), param.getValue());
-		}
-		HttpMethod httpMethod = HttpMethod.valueOf(settings.getHttpMethod().toString());
-		connection.setRequestMethod(httpMethod);
-		connection.setRequestCharacterEncoding(settings.getCharset());
-		String body = settings.getRequestBody();
-		String contentType = settings.getEncodingType().getName();
-		connection.setRequestBody(body);
-		connection.setRequestContentType(contentType);
-		connection.addRequestHeaders(settings.getAdditionalHeaders());
-		// HtmlUnit uses request parameters map for the form submit, but does not parse
-		// XMLHttpRequest content.
-		if(null != body && FormEncodingType.URL_ENCODED.getName().equals(contentType)){
-			connection.parseFormParameters(body);
-		}
-		long startTime = System.currentTimeMillis();
-		connection.execute();
-		return new LocalWebResponse(settings,connection,System.currentTimeMillis()-startTime);
-	}
-}
\ No newline at end of file
+    /**
+     * @param localServer
+     */
+    public LocalWebConnection(StagingServer localServer) {
+        this.localServer = localServer;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see com.gargoylesoftware.htmlunit.WebConnection#getResponse(com.gargoylesoftware.htmlunit.WebRequestSettings)
+     */
+    public WebResponse getResponse(WebRequestSettings settings) throws IOException {
+        StagingConnection connection = localServer.getConnection(settings.getUrl());
+
+        // Propagate web request settings to the local connection.
+        for (NameValuePair param : settings.getRequestParameters()) {
+            connection.addRequestParameter(param.getName(), param.getValue());
+        }
+
+        HttpMethod httpMethod = HttpMethod.valueOf(settings.getHttpMethod().toString());
+
+        connection.setRequestMethod(httpMethod);
+        connection.setRequestCharacterEncoding(settings.getCharset());
+
+        String body = settings.getRequestBody();
+        String contentType = settings.getEncodingType().getName();
+
+        connection.setRequestBody(body);
+        connection.setRequestContentType(contentType);
+        connection.addRequestHeaders(settings.getAdditionalHeaders());
+
+        // HtmlUnit uses request parameters map for the form submit, but does not parse
+        // XMLHttpRequest content.
+        if (null != body && FormEncodingType.URL_ENCODED.getName().equals(contentType)) {
+            connection.parseFormParameters(body);
+        }
+
+        long startTime = System.currentTimeMillis();
+
+        connection.execute();
+
+        return new LocalWebResponse(settings, connection, System.currentTimeMillis() - startTime);
+    }
+}

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/LocalWebResponse.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/LocalWebResponse.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/LocalWebResponse.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test;
 
@@ -7,12 +8,15 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
+
 import java.net.URL;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map.Entry;
 
 import org.apache.commons.httpclient.NameValuePair;
+
 import org.richfaces.test.staging.StagingConnection;
 
 import com.gargoylesoftware.htmlunit.WebRequestSettings;
@@ -23,7 +27,7 @@
  * connection. This class is used by the {@link LocalWebClient}, but also can be used to analise response rendering:
  * <pre>
  * ............
- * @Test 
+ * @Test
  * public void testRender() {
  * setupFacesRequest();
  * // Prepare view etc
@@ -35,196 +39,204 @@
  * assertTrue(....)
  * }
  * </pre>
- * 
+ *
  * @author asmirnov
- * 
+ *
  */
 public class LocalWebResponse implements WebResponse {
-	
-	private WebRequestSettings settings;
-	
-	private final StagingConnection serverConnection;
-	
-	private final long loadTime;
+    private final long loadTime;
+    private final StagingConnection serverConnection;
+    private WebRequestSettings settings;
 
-	public LocalWebResponse(StagingConnection serverConnection,long l) {
-		this.serverConnection = serverConnection;
-		this.loadTime = l;
-	}
+    public LocalWebResponse(StagingConnection serverConnection, long l) {
+        this.serverConnection = serverConnection;
+        this.loadTime = l;
+    }
 
-	public LocalWebResponse(WebRequestSettings settings,
-			StagingConnection connection, long l) {
-		this(connection,l);
-		this.settings = settings;
-	}
+    public LocalWebResponse(WebRequestSettings settings, StagingConnection connection, long l) {
+        this(connection, l);
+        this.settings = settings;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getContentAsStream()
-	 */
-	public InputStream getContentAsStream() throws IOException {
-		return new ByteArrayInputStream(getResponseBody());
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getContentAsStream()
+     */
+    public InputStream getContentAsStream() throws IOException {
+        return new ByteArrayInputStream(getResponseBody());
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getContentAsString()
-	 */
-	public String getContentAsString() {
-		return serverConnection.getContentAsString();
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getContentAsString()
+     */
+    public String getContentAsString() {
+        return serverConnection.getContentAsString();
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getContentCharSet()
-	 */
-	public String getContentCharSet() {
-		return serverConnection.getResponseCharacterEncoding();
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getContentCharSet()
+     */
+    public String getContentCharSet() {
+        return serverConnection.getResponseCharacterEncoding();
+    }
 
-	public String getContentType() {
-		return serverConnection.getResponseContentType();
-	}
+    public String getContentType() {
+        return serverConnection.getResponseContentType();
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * com.gargoylesoftware.htmlunit.WebResponse#getLoadTimeInMilliSeconds()
-	 */
-	public long getLoadTimeInMilliSeconds() {
-		return loadTime;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * com.gargoylesoftware.htmlunit.WebResponse#getLoadTimeInMilliSeconds()
+     */
+    public long getLoadTimeInMilliSeconds() {
+        return loadTime;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getRequestMethod()
-	 */
-	public com.gargoylesoftware.htmlunit.HttpMethod getRequestMethod() {
-		return com.gargoylesoftware.htmlunit.HttpMethod
-				.valueOf(serverConnection.getRequestMethod().toString());
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getRequestMethod()
+     */
+    public com.gargoylesoftware.htmlunit.HttpMethod getRequestMethod() {
+        return com.gargoylesoftware.htmlunit.HttpMethod.valueOf(serverConnection.getRequestMethod().toString());
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getRequestSettings()
-	 */
-	public WebRequestSettings getRequestSettings() {
-		if (settings == null) {
-			settings = new WebRequestSettings(this.getUrl(), getRequestMethod());
-		}
-		return settings;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getRequestSettings()
+     */
+    public WebRequestSettings getRequestSettings() {
+        if (settings == null) {
+            settings = new WebRequestSettings(this.getUrl(), getRequestMethod());
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getResponseBody()
-	 */
-	public byte[] getResponseBody() {
-		return serverConnection.getResponseBody();
-	}
+        return settings;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * com.gargoylesoftware.htmlunit.WebResponse#getResponseHeaderValue(java
-	 * .lang.String)
-	 */
-	public String getResponseHeaderValue(String headerName) {
-		String[] values = serverConnection.getResponseHeaders().get(headerName);
-		if(null != values && values.length >0){
-			return values[0];
-		}
-		return null;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getResponseBody()
+     */
+    public byte[] getResponseBody() {
+        return serverConnection.getResponseBody();
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getStatusCode()
-	 */
-	public int getStatusCode() {
-		return serverConnection.getResponseStatus();
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * com.gargoylesoftware.htmlunit.WebResponse#getResponseHeaderValue(java
+     * .lang.String)
+     */
+    public String getResponseHeaderValue(String headerName) {
+        String[] values = serverConnection.getResponseHeaders().get(headerName);
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getStatusMessage()
-	 */
-	public String getStatusMessage() {
-		return serverConnection.getErrorMessage();
-	}
+        if (null != values && values.length > 0) {
+            return values[0];
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getUrl()
-	 */
-	public URL getUrl() {
-		return serverConnection.getUrl();
-	}
+        return null;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getResponseHeaders()
-	 */
-	public List<NameValuePair> getResponseHeaders() {
-		ArrayList<NameValuePair> headers = new ArrayList<NameValuePair>(10);
-		for (Entry<String, String[]> entry : serverConnection
-				.getResponseHeaders().entrySet()) {
-			for (String value : entry.getValue()) {
-				headers.add(new NameValuePair(entry.getKey(), value));
-			}
-		}
-		int contentLength = serverConnection.getResponseContentLength();
-		if(contentLength>=0){
-			headers.add(new NameValuePair("Content-Length", String.valueOf(contentLength)));
-		}
-		return headers;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getStatusCode()
+     */
+    public int getStatusCode() {
+        return serverConnection.getResponseStatus();
+    }
 
-	/* (non-Javadoc)
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getContentAsBytes()
-	 */
-	public byte[] getContentAsBytes() {
-		return serverConnection.getResponseBody();
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getStatusMessage()
+     */
+    public String getStatusMessage() {
+        return serverConnection.getErrorMessage();
+    }
 
-	/* (non-Javadoc)
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getContentAsString(java.lang.String)
-	 */
-	public String getContentAsString(String encoding) {
-		byte[] body = serverConnection.getResponseBody();
-		String content;
-		try {
-			content = new String(body,encoding);
-		} catch (UnsupportedEncodingException e) {
-			content = new String(body);
-		}
-		return content;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getUrl()
+     */
+    public URL getUrl() {
+        return serverConnection.getUrl();
+    }
 
-	/* (non-Javadoc)
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getLoadTime()
-	 */
-	public long getLoadTime() {
-		return loadTime;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getResponseHeaders()
+     */
+    public List<NameValuePair> getResponseHeaders() {
+        ArrayList<NameValuePair> headers = new ArrayList<NameValuePair>(10);
 
-	/* (non-Javadoc)
-	 * @see com.gargoylesoftware.htmlunit.WebResponse#getRequestUrl()
-	 */
-	public URL getRequestUrl() {
-		// TODO Auto-generated method stub
-		return serverConnection.getUrl();
-	}
-}
\ No newline at end of file
+        for (Entry<String, String[]> entry : serverConnection.getResponseHeaders().entrySet()) {
+            for (String value : entry.getValue()) {
+                headers.add(new NameValuePair(entry.getKey(), value));
+            }
+        }
+
+        int contentLength = serverConnection.getResponseContentLength();
+
+        if (contentLength >= 0) {
+            headers.add(new NameValuePair("Content-Length", String.valueOf(contentLength)));
+        }
+
+        return headers;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getContentAsBytes()
+     */
+    public byte[] getContentAsBytes() {
+        return serverConnection.getResponseBody();
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getContentAsString(java.lang.String)
+     */
+    public String getContentAsString(String encoding) {
+        byte[] body = serverConnection.getResponseBody();
+        String content;
+
+        try {
+            content = new String(body, encoding);
+        } catch (UnsupportedEncodingException e) {
+            content = new String(body);
+        }
+
+        return content;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getLoadTime()
+     */
+    public long getLoadTime() {
+        return loadTime;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see com.gargoylesoftware.htmlunit.WebResponse#getRequestUrl()
+     */
+    public URL getRequestUrl() {
+
+        // TODO Auto-generated method stub
+        return serverConnection.getUrl();
+    }
+}

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/TestException.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/TestException.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/TestException.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,45 +1,43 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test;
 
-import org.richfaces.test.staging.StagingServer;
-
 /**
- * Internal runtame exception for the {@link StagingServer} engine.
+ * Internal runtame exception for the {@link org.richfaces.test.staging.StagingServer} engine.
  * @author asmirnov
  *
  */
 @SuppressWarnings("serial")
 public class TestException extends RuntimeException {
 
-	/**
-	 * Default constructor.
-	 */
-	public TestException() {
-		super();
-	}
+    /**
+     * Default constructor.
+     */
+    public TestException() {
+        super();
+    }
 
-	/**
-	 * @param message
-	 */
-	public TestException(String message) {
-		super(message);
-	}
+    /**
+     * @param message
+     */
+    public TestException(String message) {
+        super(message);
+    }
 
-	/**
-	 * @param cause
-	 */
-	public TestException(Throwable cause) {
-		super(cause);
-	}
+    /**
+     * @param cause
+     */
+    public TestException(Throwable cause) {
+        super(cause);
+    }
 
-	/**
-	 * @param message
-	 * @param cause
-	 */
-	public TestException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
+    /**
+     * @param message
+     * @param cause
+     */
+    public TestException(String message, Throwable cause) {
+        super(message, cause);
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/AbstractServerResource.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/AbstractServerResource.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/AbstractServerResource.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -2,71 +2,78 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+
 import java.net.URL;
 import java.net.URLConnection;
+
 import java.util.Set;
 import java.util.logging.Logger;
 
-
 /**
  * Base abstract class for an all file references in the 'virtual' staging server directory.
  * @author asmirnov
  *
  */
 public abstract class AbstractServerResource implements ServerResource {
+    private static final Logger LOG = ServerLogger.RESOURCE.getLogger();
 
-	private static final Logger log = ServerLogger.RESOURCE.getLogger();
+    public AbstractServerResource() {}
 
-	public AbstractServerResource() {
-	}
+    /**
+     * This implementation creates stream from the resource URL. I also tries to disable
+     * url connection cache, to prevent jar file locking in the windows environment.
+     * @see org.richfaces.test.staging.ServerResource#getAsStream()
+     */
+    public InputStream getAsStream() throws IOException {
+        URL url = getURL();
 
-	/** This implementation creates stream from the resource URL. I also tries to disable
-	 * url connection cache, to prevent jar file locking in the windows environment.
-	 * @see org.richfaces.test.staging.ServerResource#getAsStream()
-	 */
-	public InputStream getAsStream() throws IOException {
-		URL url = getURL();
-		if (url != null) {
-			URLConnection connection = url.openConnection();
-			try {
-				connection.setUseCaches(false);
-			} catch (IllegalArgumentException e) {
-				log.info("RESOURCE_NOT_CACHEABLE");
-			}
-			return connection.getInputStream();
-		} else {
-			return null;
-		}
-	}
+        if (url != null) {
+            URLConnection connection = url.openConnection();
 
-	/**
-	 * File-like resources do not allows resources additions.
-	 * @throws UnsupportedOperationException
-	 * @see org.richfaces.test.staging.ServerResource#addResource(org.richfaces.test.staging.ServerResourcePath, org.richfaces.test.staging.ServerResource)
-	 */
-	public void addResource(ServerResourcePath path, ServerResource resource) {
-		throw new UnsupportedOperationException();
-	}
+            try {
+                connection.setUseCaches(false);
+            } catch (IllegalArgumentException e) {
+                LOG.info("RESOURCE_NOT_CACHEABLE");
+            }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.ServerResource#getResource(org.richfaces.test.staging.ServerResourcePath)
-	 */
-	public ServerResource getResource(ServerResourcePath path) {
-		if(null == path){
-			throw new NullPointerException();
-		}
-		// If path points to the resource itself, returns this instance.
-		if(path.isFile()){
-			return this;
-		}
-		return null;
-	}
+            return connection.getInputStream();
+        } else {
+            return null;
+        }
+    }
 
-	/** File-like resources does not contain any other, so this method always returns null.
-	 * @see org.richfaces.test.staging.ServerResource#getPaths()
-	 */
-	public Set<String> getPaths() {
-		return null;//Collections.emptySet();
-	}
+    /**
+     * File-like resources do not allows resources additions.
+     * @throws UnsupportedOperationException
+     * @see org.richfaces.test.staging.ServerResource#addResource(org.richfaces.test.staging.ServerResourcePath,
+     * org.richfaces.test.staging.ServerResource)
+     */
+    public void addResource(ServerResourcePath path, ServerResource resource) {
+        throw new UnsupportedOperationException();
+    }
 
-}
\ No newline at end of file
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.ServerResource#getResource(org.richfaces.test.staging.ServerResourcePath)
+     */
+    public ServerResource getResource(ServerResourcePath path) {
+        if (null == path) {
+            throw new NullPointerException();
+        }
+
+        // If path points to the resource itself, returns this instance.
+        if (path.isFile()) {
+            return this;
+        }
+
+        return null;
+    }
+
+    /**
+     * File-like resources does not contain any other, so this method always returns null.
+     * @see org.richfaces.test.staging.ServerResource#getPaths()
+     */
+    public Set<String> getPaths() {
+        return null; // Collections.emptySet();
+    }
+}

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ClasspathServerResource.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,67 +1,64 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
 import java.net.URL;
+
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.richfaces.test.TestException;
 
-
 /**
  * This class represents file from classpath in the virtual web application
  * content.
- * 
+ *
  * @author asmirnov
- * 
+ *
  */
 public class ClasspathServerResource extends AbstractServerResource {
+    private static final Logger LOG = ServerLogger.RESOURCE.getLogger();
+    private volatile URL url = null;
+    private final String classpath;
 
-	/**
-	 * 
-	 */
-	private final String classpath;
+    /**
+     * @param classpath
+     */
+    public ClasspathServerResource(String classpath) {
+        this.classpath = classpath;
+    }
 
-	private volatile URL url = null;
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.richfaces.test.staging.ServerResource#getURL()
+     */
+    public URL getURL() {
+        if (url == null) {
 
-	private static final Logger log = ServerLogger.RESOURCE.getLogger();
+            // JDK-5 singleton-like synchronization.
+            // @see http://jeremymanson.blogspot.com/2008/05/double-checked-locking.html
+            synchronized (this) {
+                if (LOG.isLoggable(Level.FINEST)) {
+                    LOG.finest("get classpath resource from " + this.classpath);
+                }
 
-	/**
-	 * @param name
-	 * @param classpath
-	 */
-	public ClasspathServerResource(String classpath) {
-		this.classpath = classpath;
-	}
+                ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.richfaces.test.staging.ServerResource#getURL()
-	 */
-	public URL getURL() {
-		if (url == null) {
-			// JDK-5 singleton-like synchronization.
-			// @see http://jeremymanson.blogspot.com/2008/05/double-checked-locking.html
-			synchronized (this) {
-				if(log.isLoggable(Level.FINEST)){
-					log.finest("get classpath resource from "+this.classpath);
-				}
-				ClassLoader classLoader = Thread.currentThread()
-						.getContextClassLoader();
-				if (null == classLoader) {
-					classLoader = this.getClass().getClassLoader();
-				}				
-				url = classLoader.getResource(classpath);
-				if(null == url){
-					throw new TestException("Virtual server resource can't be loaded from "+classpath);
-				}
-			}
-		}
+                if (null == classLoader) {
+                    classLoader = this.getClass().getClassLoader();
+                }
 
-		return url;
-	}
+                url = classLoader.getResource(classpath);
 
+                if (null == url) {
+                    throw new TestException("Virtual server resource can't be loaded from " + classpath);
+                }
+            }
+        }
+
+        return url;
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/EventInvoker.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/EventInvoker.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/EventInvoker.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
@@ -7,11 +8,11 @@
 
 /**
  * Internal interface, used to invoke listeners of different types.
-
+ *
  * @author asmirnov
  *
  * @param <T> listener type.
  */
 interface EventInvoker<T extends EventListener> {
-	public void invoke(T listener);
-}
\ No newline at end of file
+    public void invoke(T listener);
+}

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/FilterContainer.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/FilterContainer.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/FilterContainer.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,6 +1,7 @@
 package org.richfaces.test.staging;
 
 import java.io.IOException;
+
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -15,194 +16,194 @@
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
-
 /**
  * Holds a filter instance and reference to the next executable server object (
  * filter or servlet ) in the chain.
- * 
+ *
  * @author asmirnov
- * 
+ *
  */
 public class FilterContainer implements RequestChain {
+    private static final Logger LOG = ServerLogger.SERVER.getLogger();
 
-	private static final Logger log = ServerLogger.SERVER.getLogger();
+    /**
+     * Filter name.
+     */
+    private String name = "Default";
 
-	/**
-	 * Servlet filter instance.
-	 */
-	private final Filter filter;
+    /**
+     * Initialization flag to avoid double calls.
+     */
+    private boolean initialized = false;
 
-	/**
-	 * Next object in the chain.
-	 */
-	private final RequestChain next;
+    /**
+     * Servlet filter instance.
+     */
+    private final Filter filter;
 
-	/**
-	 * Filter name.
-	 */
-	private String name = "Default";
+    /**
+     * Filter initialization parameters.
+     */
+    private final Map<String, String> initParameters;
 
-	/**
-	 * Filter initialization parameters.
-	 */
-	private final Map<String, String> initParameters;
+    /**
+     * Next object in the chain.
+     */
+    private final RequestChain next;
 
-	/**
-	 * Initialization flag to avoid double calls.
-	 */
-	private boolean initialized = false;
+    /**
+     * @param filter
+     *            instance of the web application filter.
+     * @param next
+     *            next executable object in the filter chain.
+     * @throws NullPointerException if any of parameter is null.
+     */
+    public FilterContainer(Filter filter, RequestChain next) {
+        if (null == filter || null == next) {
+            throw new NullPointerException();
+        }
 
-	/**
-	 * @param filter
-	 *            instance of the web application filter.
-	 * @param next
-	 *            next executable object in the filter chain.
-	 * @throws NullPointerException if any of parameter is null.
-	 */
-	public FilterContainer(Filter filter, RequestChain next) {
-		if(null == filter || null == next){
-			throw new NullPointerException();
-		}
-		this.filter = filter;
-		this.next = next;
-		this.initParameters = new HashMap<String, String>();
-	}
+        this.filter = filter;
+        this.next = next;
+        this.initParameters = new HashMap<String, String>();
+    }
 
-	/**
-	 * @return filter name.
-	 */
-	public String getName() {
-		return name;
-	}
+    /**
+     * @return filter name.
+     */
+    public String getName() {
+        return name;
+    }
 
-	/**
-	 * @param name
-	 *            new filter name.
-	 */
-	public void setName(String name) {
-		if (initialized) {
-			throw new IllegalStateException(
-					"Filter have already been initialized, name can't be changed");
-		}
-		this.name = name;
-	}
+    /**
+     * @param name
+     *            new filter name.
+     */
+    public void setName(String name) {
+        if (initialized) {
+            throw new IllegalStateException("Filter have already been initialized, name can't be changed");
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.richfaces.test.staging.RequestChain#execute(javax.servlet.ServletRequest
-	 * , javax.servlet.ServletResponse)
-	 */
-	public void execute(ServletRequest request, ServletResponse response)
-			throws ServletException, IOException {
-		if (!initialized) {
-			throw new IllegalStateException(
-					"Filter "+getName()+" have not been initialized, could'n execute request");
-		}
-		log.finest("Request '"+request+"' executes by the '"+getName()+"' filter");
-		FilterChain chain = new FilterChain() {
-			// Execute next object in the chain.
-			public void doFilter(ServletRequest request,
-					ServletResponse response) throws IOException,
-					ServletException {
-				next.execute(request, response);
+        this.name = name;
+    }
 
-			}
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.richfaces.test.staging.RequestChain#execute(javax.servlet.ServletRequest
+     * , javax.servlet.ServletResponse)
+     */
+    public void execute(ServletRequest request, ServletResponse response) throws ServletException, IOException {
+        if (!initialized) {
+            throw new IllegalStateException("Filter " + getName()
+                                            + " have not been initialized, could'n execute request");
+        }
 
-		};
-		filter.doFilter(request, response, chain);
+        LOG.finest("Request '" + request + "' executes by the '" + getName() + "' filter");
 
-	}
+        FilterChain chain = new FilterChain() {
 
-	/**
-	 * Append filter initialization parameter. Name and value are same as
-	 * defined in the web.xml
-	 * 
-	 * <code>
-	 * &lt;init-param&gt;
-	 *    &lt;param-name&gt;foo&lt;/param-name&gt;
-	 *    &lt;param-value&gt;bar&lt;/param-value&gt;
-	 *   &lt;/init-param&gt;
-	 * </code>
-	 * 
-	 * @param name
-	 *            name of the parameter
-	 * @param value
-	 *            its value
-	 */
-	public void addInitParameter(String name, String value) {
-		if (initialized) {
-			throw new IllegalStateException(
-					"Filter have already been initialized, init parameters can't be changed");
-		}
-		initParameters.put(name, value);
-	}
+            // Execute next object in the chain.
+            public void doFilter(ServletRequest request, ServletResponse response)
+                throws IOException, ServletException {
+                
+                next.execute(request, response);
+            }
+        };
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.RequestChain#isApplicable(java.lang.String)
-	 */
-	public boolean isApplicable(String path) {
-		// Delegate to the next object. Filter has a same mapping as target servlet.
-		return next.isApplicable(path);
-	}
+        filter.doFilter(request, response, chain);
+    }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.RequestChain#destroy()
-	 */
-	public void destroy() {
-		if (initialized) {
-			next.destroy();
-			filter.destroy();
-			initialized = false;
-		}
-	}
+    /**
+     * Append filter initialization parameter. Name and value are same as
+     * defined in the web.xml
+     *
+     * <code>
+     * &lt;init-param&gt;
+     *    &lt;param-name&gt;foo&lt;/param-name&gt;
+     *    &lt;param-value&gt;bar&lt;/param-value&gt;
+     *   &lt;/init-param&gt;
+     * </code>
+     *
+     * @param name
+     *            name of the parameter
+     * @param value
+     *            its value
+     */
+    public void addInitParameter(String name, String value) {
+        if (initialized) {
+            throw new IllegalStateException("Filter have already been initialized, init parameters can't be changed");
+        }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.RequestChain#init(org.richfaces.test.staging.StagingServletContext)
-	 */
-	public void init(final ServletContext context)
-			throws ServletException {
-		if (!initialized) {
-			filter.init(new FilterConfig() {
+        initParameters.put(name, value);
+    }
 
-				public String getFilterName() {
-					return name;
-				}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.RequestChain#isApplicable(java.lang.String)
+     */
+    public boolean isApplicable(String path) {
 
-				public String getInitParameter(String name) {
-					return initParameters.get(name);
-				}
+        // Delegate to the next object. Filter has a same mapping as target servlet.
+        return next.isApplicable(path);
+    }
 
-				@SuppressWarnings("unchecked")
-				public Enumeration getInitParameterNames() {
-					return Collections.enumeration(initParameters.keySet());
-				}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.RequestChain#destroy()
+     */
+    public void destroy() {
+        if (initialized) {
+            next.destroy();
+            filter.destroy();
+            initialized = false;
+        }
+    }
 
-				public ServletContext getServletContext() {
-					return context;
-				}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.RequestChain#init(org.richfaces.test.staging.StagingServletContext)
+     */
+    public void init(final ServletContext context) throws ServletException {
+        if (!initialized) {
+            filter.init(new FilterConfig() {
+                public String getFilterName() {
+                    return name;
+                }
+                public String getInitParameter(String name) {
+                    return initParameters.get(name);
+                }
+                @SuppressWarnings("unchecked")
+                public Enumeration getInitParameterNames() {
+                    return Collections.enumeration(initParameters.keySet());
+                }
+                public ServletContext getServletContext() {
+                    return context;
+                }
+            });
+            next.init(context);
+            initialized = true;
+        }
+    }
 
-			});
-			next.init(context);
-			initialized = true;
-		}
-	}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.RequestChain#getPathInfo(java.lang.String)
+     */
+    public String getPathInfo(String path) {
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.RequestChain#getPathInfo(java.lang.String)
-	 */
-	public String getPathInfo(String path) {
-		// Delegate to the next object. Filter has a same mapping as target servlet.
-		return next.getPathInfo(path);
-	}
+        // Delegate to the next object. Filter has a same mapping as target servlet.
+        return next.getPathInfo(path);
+    }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.RequestChain#getServletPath(java.lang.String)
-	 */
-	public String getServletPath(String path) {
-		// Delegate to the next object. Filter has a same mapping as target servlet.
-		return next.getServletPath(path);
-	}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.RequestChain#getServletPath(java.lang.String)
+     */
+    public String getServletPath(String path) {
 
+        // Delegate to the next object. Filter has a same mapping as target servlet.
+        return next.getServletPath(path);
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/HttpMethod.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/HttpMethod.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/HttpMethod.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
@@ -8,26 +9,19 @@
  *
  */
 public enum HttpMethod {
-	
-	GET("GET"),
-	POST("POST"),
-	HEAD("HEAD"),
-	PUT("PUT"),
-	OPTIONS("OPTIONS"),
-	TRACE("TRACE"),
-	DELETE("DELETE");
-	
-	/**
-	 * @param name
-	 */
-	private HttpMethod(String name) {
-		this.name = name;
-	}
+    GET("GET"), POST("POST"), HEAD("HEAD"), PUT("PUT"), OPTIONS("OPTIONS"), TRACE("TRACE"), DELETE("DELETE");
 
-	private String name;
+    private String name;
 
-	@Override
-	public String toString() {
-		return name;
-	}
+    /**
+     * @param name
+     */
+    private HttpMethod(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String toString() {
+        return name;
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/InvocationErrorEvent.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/InvocationErrorEvent.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/InvocationErrorEvent.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,51 +1,49 @@
 package org.richfaces.test.staging;
 
 import java.lang.reflect.Method;
+
 import java.util.EventObject;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
 /**
  * This event sent from the virtual server introspection method to the registered
- * {@link InvocationListener} instance after any exception thrown from calls to {@link HttpServletRequest} , {@link HttpServletResponse}, {@link HttpSession} and {@link ServletContext} objects. 
-
+ * {@link InvocationListener} instance after any exception thrown from calls to
+ * {@link javax.servlet.http.HttpServletRequest} , {@link javax.servlet.http.HttpServletResponse},
+ * {@link javax.servlet.http.HttpSession} and {@link ServletContext} objects.
+ *
  * @author asmirnov
  *
  */
 @SuppressWarnings("serial")
 public class InvocationErrorEvent extends EventObject {
-	private Object target;
-	private Method method;
-	private Object[] args;
-	private Throwable e;
+    private Object[] args;
+    private Throwable e;
+    private Method method;
+    private Object target;
 
-	public InvocationErrorEvent(Object target, Method method, Object[] args,
-			Throwable e) {
-		super(target);
-		this.target = target;
-		this.method = method;
-		this.args = args;
-		this.e = e;
-	}
+    public InvocationErrorEvent(Object target, Method method, Object[] args, Throwable e) {
+        super(target);
+        this.target = target;
+        this.method = method;
+        this.args = args;
+        this.e = e;
+    }
 
-	public Object getTarget() {
-		return target;
-	}
+    public Object getTarget() {
+        return target;
+    }
 
-	public Method getMethod() {
-		return method;
-	}
+    public Method getMethod() {
+        return method;
+    }
 
-	public Object[] getArgs() {
-		return args;
-	}
+    public Object[] getArgs() {
+        return args;
+    }
 
-	/**
-	 * @return thrown exception.
-	 */
-	public Throwable getE() {
-		return e;
-	}
-}
\ No newline at end of file
+    /**
+     * @return thrown exception.
+     */
+    public Throwable getE() {
+        return e;
+    }
+}

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/InvocationEvent.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/InvocationEvent.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/InvocationEvent.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,59 +1,58 @@
 package org.richfaces.test.staging;
 
 import java.lang.reflect.Method;
+
 import java.util.EventObject;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
 /**
  * This event sent from the staging server introspection method to the registered
- * {@link InvocationListener} instance after all calls to {@link HttpServletRequest} , {@link HttpServletResponse}, {@link HttpSession} and {@link ServletContext} objects. 
+ * {@link InvocationListener} instance after all calls to {@link javax.servlet.http.HttpServletRequest} ,
+ * {@link javax.servlet.http.HttpServletResponse}, {@link javax.servlet.http.HttpSession}
+ * and {@link ServletContext} objects.
+ *
  * @author asmirnov
  *
  */
 @SuppressWarnings("serial")
 public class InvocationEvent extends EventObject {
-	private Object target;
-	private Method method;
-	private Object[] args;
-	private Object result;
+    private Object[] args;
+    private Method method;
+    private Object result;
+    private Object target;
 
-	public InvocationEvent(Object target, Method method, Object[] args,
-			Object result) {
-		super(target);
-		this.target = target;
-		this.method = method;
-		this.args = args;
-		this.result = result;
-	}
+    public InvocationEvent(Object target, Method method, Object[] args, Object result) {
+        super(target);
+        this.target = target;
+        this.method = method;
+        this.args = args;
+        this.result = result;
+    }
 
-	/**
-	 * @return target object instance.
-	 */
-	public Object getTarget() {
-		return target;
-	}
+    /**
+     * @return target object instance.
+     */
+    public Object getTarget() {
+        return target;
+    }
 
-	/**
-	 * @return {@link Method} that was called.
-	 */
-	public Method getMethod() {
-		return method;
-	}
+    /**
+     * @return {@link Method} that was called.
+     */
+    public Method getMethod() {
+        return method;
+    }
 
-	/**
-	 * @return method arguments.
-	 */
-	public Object[] getArgs() {
-		return args;
-	}
+    /**
+     * @return method arguments.
+     */
+    public Object[] getArgs() {
+        return args;
+    }
 
-	/**
-	 * @return value returned from the invoked method.
-	 */
-	public Object getResult() {
-		return result;
-	}
-}
\ No newline at end of file
+    /**
+     * @return value returned from the invoked method.
+     */
+    public Object getResult() {
+        return result;
+    }
+}

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/InvocationListener.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/InvocationListener.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/InvocationListener.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,32 +1,30 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
 import java.util.EventListener;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-
 /**
- * Listener interface to inspect all calls to {@link HttpServletRequest} , {@link HttpServletResponse}, {@link HttpSession} and {@link ServletContext} objects.
+ * Listener interface to inspect all calls to {@link javax.servlet.http.HttpServletRequest} ,
+ * {@link javax.servlet.http.HttpServletResponse}, {@link javax.servlet.http.HttpSession} and
+ * {@link ServletContext} objects.
+ *
  * @author asmirnov
  *
  */
-public interface InvocationListener extends EventListener{
+public interface InvocationListener extends EventListener {
 
-	/**
-	 * This metod called after successful invocation on the target object.
-	 * @param invocationEvent
-	 */
-	public void afterInvoke(InvocationEvent invocationEvent);
-	
-	/**
-	 * This method called after any {@link Throwable} thrown during method invocation.
-	 * @param invocationErrorEvent
-	 */
-	public void processException(InvocationErrorEvent invocationErrorEvent);
-	
+    /**
+     * This metod called after successful invocation on the target object.
+     * @param invocationEvent
+     */
+    public void afterInvoke(InvocationEvent invocationEvent);
+
+    /**
+     * This method called after any {@link Throwable} thrown during method invocation.
+     * @param invocationErrorEvent
+     */
+    public void processException(InvocationErrorEvent invocationErrorEvent);
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/NotImplementedException.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/NotImplementedException.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/NotImplementedException.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
@@ -11,36 +12,38 @@
 @SuppressWarnings("serial")
 public class NotImplementedException extends RuntimeException {
 
-	/**
-	 * 
-	 */
-	public NotImplementedException() {
-		super("This feature not yet implemented");
-	}
+    /**
+     *
+     */
+    public NotImplementedException() {
+        super("This feature not yet implemented");
+    }
 
-	/**
-	 * @param message
-	 */
-	public NotImplementedException(String message) {
-		super(message);
-		// TODO Auto-generated constructor stub
-	}
+    /**
+     * @param message
+     */
+    public NotImplementedException(String message) {
+        super(message);
 
-	/**
-	 * @param cause
-	 */
-	public NotImplementedException(Throwable cause) {
-		super(cause);
-		// TODO Auto-generated constructor stub
-	}
+        // TODO Auto-generated constructor stub
+    }
 
-	/**
-	 * @param message
-	 * @param cause
-	 */
-	public NotImplementedException(String message, Throwable cause) {
-		super(message, cause);
-		// TODO Auto-generated constructor stub
-	}
+    /**
+     * @param cause
+     */
+    public NotImplementedException(Throwable cause) {
+        super(cause);
 
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public NotImplementedException(String message, Throwable cause) {
+        super(message, cause);
+
+        // TODO Auto-generated constructor stub
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/PageContextExtension.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/PageContextExtension.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/PageContextExtension.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,12 +1,15 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
 import java.io.IOException;
+
 import java.util.Enumeration;
 
 import javax.el.ELContext;
+
 import javax.servlet.Servlet;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
@@ -21,181 +24,183 @@
 import javax.servlet.jsp.el.VariableResolver;
 
 final class PageContextExtension extends PageContext {
-	private ServletResponse response;
-	private Servlet servlet;
-	private ServletRequest request;
-	private boolean needsSession;
-	private int bufferSize;
-	private boolean autoFlush;
+    private boolean autoFlush;
+    private int bufferSize;
+    private boolean needsSession;
+    private ServletRequest request;
+    private ServletResponse response;
+    private Servlet servlet;
 
+    @Override
+    public void forward(String relativeUrlPath) throws ServletException, IOException {
 
-	@Override
-	public void forward(String relativeUrlPath)
-			throws ServletException, IOException {
-		// TODO Auto-generated method stub
-		
-	}
+        // TODO Auto-generated method stub
+    }
 
-	@Override
-	public Exception getException() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public Exception getException() {
 
-	@Override
-	public Object getPage() {
-		return servlet;
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	@Override
-	public ServletRequest getRequest() {
-		return request;
-	}
+    @Override
+    public Object getPage() {
+        return servlet;
+    }
 
-	@Override
-	public ServletResponse getResponse() {
-		return response;
-	}
+    @Override
+    public ServletRequest getRequest() {
+        return request;
+    }
 
-	@Override
-	public ServletConfig getServletConfig() {
-		return servlet.getServletConfig();
-	}
+    @Override
+    public ServletResponse getResponse() {
+        return response;
+    }
 
-	@Override
-	public ServletContext getServletContext() {
-		return servlet.getServletConfig().getServletContext();
-	}
+    @Override
+    public ServletConfig getServletConfig() {
+        return servlet.getServletConfig();
+    }
 
-	@Override
-	public HttpSession getSession() {
-		HttpServletRequest httpRequest = (HttpServletRequest) request;
-		return httpRequest.getSession(needsSession);
-	}
+    @Override
+    public ServletContext getServletContext() {
+        return servlet.getServletConfig().getServletContext();
+    }
 
-	@Override
-	public void handlePageException(Exception e)
-			throws ServletException, IOException {
-		throw new ServletException(e);
-		
-	}
+    @Override
+    public HttpSession getSession() {
+        HttpServletRequest httpRequest = (HttpServletRequest) request;
 
-	@Override
-	public void handlePageException(Throwable t)
-			throws ServletException, IOException {
-		throw new ServletException(t);
-		
-	}
+        return httpRequest.getSession(needsSession);
+    }
 
-	@Override
-	public void include(String relativeUrlPath)
-			throws ServletException, IOException {
-		// TODO Auto-generated method stub
-		
-	}
+    @Override
+    public void handlePageException(Exception e) throws ServletException, IOException {
+        throw new ServletException(e);
+    }
 
-	@Override
-	public void include(String relativeUrlPath, boolean flush)
-			throws ServletException, IOException {
-		// TODO Auto-generated method stub
-		
-	}
+    @Override
+    public void handlePageException(Throwable t) throws ServletException, IOException {
+        throw new ServletException(t);
+    }
 
-	@Override
-	public void initialize(Servlet servlet, ServletRequest request,
-			ServletResponse response, String errorPageURL,
-			boolean needsSession, int bufferSize, boolean autoFlush)
-			throws IOException, IllegalStateException,
-			IllegalArgumentException {
-		this.response = response;
-		this.servlet = servlet;
-		this.request = request;
-		this.needsSession = needsSession;
-		this.bufferSize = bufferSize;
-		this.autoFlush = autoFlush;
-	}
+    @Override
+    public void include(String relativeUrlPath) throws ServletException, IOException {
 
-	@Override
-	public void release() {
-		// TODO Auto-generated method stub
-		
-	}
+        // TODO Auto-generated method stub
+    }
 
-	@Override
-	public Object findAttribute(String name) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public void include(String relativeUrlPath, boolean flush) throws ServletException, IOException {
 
-	@Override
-	public Object getAttribute(String name) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        // TODO Auto-generated method stub
+    }
 
-	@Override
-	public Object getAttribute(String name, int scope) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public void initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL,
+                           boolean needsSession, int bufferSize, boolean autoFlush)
+        throws IOException, IllegalStateException, IllegalArgumentException {
+        
+        this.response = response;
+        this.servlet = servlet;
+        this.request = request;
+        this.needsSession = needsSession;
+        this.bufferSize = bufferSize;
+        this.autoFlush = autoFlush;
+    }
 
-	@Override
-	public Enumeration<String> getAttributeNamesInScope(int scope) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public void release() {
 
-	@Override
-	public int getAttributesScope(String name) {
-		// TODO Auto-generated method stub
-		return 0;
-	}
+        // TODO Auto-generated method stub
+    }
 
-	@Override
-	public ELContext getELContext() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public Object findAttribute(String name) {
 
-	@Override
-	public ExpressionEvaluator getExpressionEvaluator() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	@Override
-	public JspWriter getOut() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public Object getAttribute(String name) {
 
-	@Override
-	public VariableResolver getVariableResolver() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	@Override
-	public void removeAttribute(String name) {
-		// TODO Auto-generated method stub
-		
-	}
+    @Override
+    public Object getAttribute(String name, int scope) {
 
-	@Override
-	public void removeAttribute(String name, int scope) {
-		// TODO Auto-generated method stub
-		
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	@Override
-	public void setAttribute(String name, Object value) {
-		// TODO Auto-generated method stub
-		
-	}
+    @Override
+    public Enumeration<String> getAttributeNamesInScope(int scope) {
 
-	@Override
-	public void setAttribute(String name, Object value, int scope) {
-		// TODO Auto-generated method stub
-		
-	}
-}
\ No newline at end of file
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public int getAttributesScope(String name) {
+
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public ELContext getELContext() {
+
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public ExpressionEvaluator getExpressionEvaluator() {
+
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public JspWriter getOut() {
+
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public VariableResolver getVariableResolver() {
+
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void removeAttribute(String name) {
+
+        // TODO Auto-generated method stub
+    }
+
+    @Override
+    public void removeAttribute(String name, int scope) {
+
+        // TODO Auto-generated method stub
+    }
+
+    @Override
+    public void setAttribute(String name, Object value) {
+
+        // TODO Auto-generated method stub
+    }
+
+    @Override
+    public void setAttribute(String name, Object value, int scope) {
+
+        // TODO Auto-generated method stub
+    }
+}

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/RequestChain.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/RequestChain.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/RequestChain.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -15,47 +15,45 @@
  */
 public interface RequestChain {
 
-	/**
-	 * Is this object applicable to process given path ?
-	 * @param path request path relative to web application context.
-	 * @return true if this object was configured to process given path.
-	 */
-	public abstract boolean isApplicable(String path);
+    /**
+     * Is this object applicable to process given path ?
+     * @param path request path relative to web application context.
+     * @return true if this object was configured to process given path.
+     */
+    public abstract boolean isApplicable(String path);
 
-	/**
-	 * Execute request with current object. Filter objects also delegate doFilter calls to the next object in the chain.
-	 * @param request
-	 * @param response
-	 * @throws ServletException
-	 * @throws IOException
-	 */
-	public abstract void execute(ServletRequest request,
-			ServletResponse response) throws ServletException, IOException;
+    /**
+     * Execute request with current object. Filter objects also delegate doFilter calls to the next object in the chain.
+     * @param request
+     * @param response
+     * @throws ServletException
+     * @throws IOException
+     */
+    public abstract void execute(ServletRequest request, ServletResponse response) throws ServletException, IOException;
 
-	/**
-	 * Destroy containing web server objects.
-	 */
-	public abstract void destroy();
+    /**
+     * Destroy containing web server objects.
+     */
+    public abstract void destroy();
 
-	/**
-	 * Init containing objects ( filters or servlet ).
-	 * @param servletContext
-	 * @throws ServletException
-	 */
-	public abstract void init(ServletContext servletContext) throws ServletException;
+    /**
+     * Init containing objects ( filters or servlet ).
+     * @param servletContext
+     * @throws ServletException
+     */
+    public abstract void init(ServletContext servletContext) throws ServletException;
 
-	/**
-	 * Calculate path info for a request path.
-	 * @param path request path relative to the web application context.
-	 * @return part of the path after servlet path or null for a suffix-based mapping.
-	 */
-	public abstract String getPathInfo(String path);
+    /**
+     * Calculate path info for a request path.
+     * @param path request path relative to the web application context.
+     * @return part of the path after servlet path or null for a suffix-based mapping.
+     */
+    public abstract String getPathInfo(String path);
 
-	/**
-	 * Calculate servlet path for a given request.
-	 * @param path request path relative to the web application context.
-	 * @return prefix part from servlet mapping or {@code path} for a suffix-based mapping.
-	 */
-	public abstract String getServletPath(String path);
-
-}
\ No newline at end of file
+    /**
+     * Calculate servlet path for a given request.
+     * @param path request path relative to the web application context.
+     * @return prefix part from servlet mapping or {@code path} for a suffix-based mapping.
+     */
+    public abstract String getServletPath(String path);
+}

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerLogger.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerLogger.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerLogger.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
@@ -10,32 +11,27 @@
  *
  */
 public enum ServerLogger {
-	
-	RESOURCE("resource"),
-	CONNECTION("connection"),
-	SERVER("server");	
-	
-	private static final String PREFIX="org.richfaces.test.";
-	
-	private static final String LOGGING_BUNDLE="org.richfaces.test.LogMessages";
-	private final String name;
+    RESOURCE("resource"), CONNECTION("connection"), SERVER("server");
 
-	/**
-	 * @param name
-	 */
-	private ServerLogger(String name) {
-		this.name = PREFIX+name;
-	}
+    private static final String LOGGING_BUNDLE = "org.richfaces.test.LogMessages";
+    private static final String PREFIX = "org.richfaces.test.";
+    private final String name;
 
-	/**
-	 * @return the name
-	 */
-	public String getName() {
-		return name;
-	}
-	
-	public Logger getLogger(){
-		return Logger.getLogger(name, LOGGING_BUNDLE);
-	}
+    /**
+     * @param name
+     */
+    private ServerLogger(String name) {
+        this.name = PREFIX + name;
+    }
 
+    /**
+     * @return the name
+     */
+    public String getName() {
+        return name;
+    }
+
+    public Logger getLogger() {
+        return Logger.getLogger(name, LOGGING_BUNDLE);
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerResource.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerResource.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerResource.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,11 +1,14 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
 import java.io.IOException;
 import java.io.InputStream;
+
 import java.net.URL;
+
 import java.util.Set;
 
 /**
@@ -13,38 +16,36 @@
  *
  */
 public interface ServerResource {
-	
 
-	/**
-	 * Get URL for a test server resource content. Directories should return null or "stub"
-	 * @return
-	 */
-	public URL getURL();
-	
-	/**
-	 * Create input stream to read content. Directories returns {@code null}
-	 * @return
-	 * @throws IOException
-	 */
-	public InputStream getAsStream() throws IOException;
-	
-	/**
-	 * @return strings representing directory content. File-like resources return null.
-	 */
-	public Set<String> getPaths();
-	
-	/**
-	 * Append resource to the current directory-like structure.
-	 * @param path
-	 * @param resource
-	 */
-	public void addResource(ServerResourcePath path, ServerResource resource);
-	
-	/**
-	 * Get resource from the current directory or its subdirectories.
-	 * @param path
-	 * @return
-	 */
-	public ServerResource getResource(ServerResourcePath path);
+    /**
+     * Get URL for a test server resource content. Directories should return null or "stub"
+     * @return
+     */
+    public URL getURL();
 
+    /**
+     * Create input stream to read content. Directories returns {@code null}
+     * @return
+     * @throws IOException
+     */
+    public InputStream getAsStream() throws IOException;
+
+    /**
+     * @return strings representing directory content. File-like resources return null.
+     */
+    public Set<String> getPaths();
+
+    /**
+     * Append resource to the current directory-like structure.
+     * @param path
+     * @param resource
+     */
+    public void addResource(ServerResourcePath path, ServerResource resource);
+
+    /**
+     * Get resource from the current directory or its subdirectories.
+     * @param path
+     * @return
+     */
+    public ServerResource getResource(ServerResourcePath path);
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerResourcePath.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerResourcePath.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerResourcePath.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,113 +1,120 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
 import java.util.regex.Pattern;
 
-import javax.servlet.ServletContext;
-
 /**
  * Class to represent web server resources directory path.
  * @author asmirnov
- * 
+ *
  */
 public class ServerResourcePath {
-	
-	private static final Pattern SLASH = Pattern.compile("/");
+    public static final ServerResourcePath WEB_INF = new ServerResourcePath("/WEB-INF/");
+    public static final ServerResourcePath META_INF = new ServerResourcePath("/META-INF/");
+    public static final ServerResourcePath WEB_XML = new ServerResourcePath("/WEB-INF/web.xml");
+    public static final ServerResourcePath FACES_CONFIG = new ServerResourcePath("/WEB-INF/faces-config.xml");
 
-	public static final ServerResourcePath WEB_INF=new ServerResourcePath("/WEB-INF/");
+    private static final Pattern SLASH = Pattern.compile("/");
+    
+    private final String[] pathElements;
 
-	public static final ServerResourcePath META_INF=new ServerResourcePath("/META-INF/");
-	public static final ServerResourcePath WEB_XML=new ServerResourcePath("/WEB-INF/web.xml");
-	public static final ServerResourcePath FACES_CONFIG=new ServerResourcePath("/WEB-INF/faces-config.xml");
+    /**
+     * Create path from string representation. Path have to started with training slash, as required for
+     * {@link javax.servlet.ServletContext#getResource(String)}
+     * @param path
+     */
+    public ServerResourcePath(String path) {
+        if (null == path) {
+            throw new NullPointerException();
+        }
 
+        if (!path.startsWith("/")) {
+            throw new IllegalArgumentException();
+        }
 
-	private final String[] pathElements;
+        String[] split = SLASH.split(path);
 
-	/**
-	 * Private constructor for next sub - path.
-	 * @param pathElements
-	 */
-	private ServerResourcePath(String[] pathElements) {
-		this.pathElements = pathElements;
-	}
+        if (split.length > 1 && path.endsWith("/")) {
+            pathElements = new String[split.length + 1];
+            System.arraycopy(split, 0, pathElements, 0, split.length);
+        } else {
+            pathElements = split;
+        }
+    }
 
-	/**
-	 * Create path from string representation. Path have to started with training slash, as required for
-	 * {@link ServletContext#getResource(String)} 
-	 * @param path 
-	 */
-	public ServerResourcePath(String path) {
-		if (null == path) {
-			throw new NullPointerException();
-		}
-		if (!path.startsWith("/")) {
-			throw new IllegalArgumentException();
-		}
-		String[] split = SLASH.split(path);
-		if(split.length >1 && path.endsWith("/")){
-			pathElements = new String[split.length+1];
-			System.arraycopy(split, 0, pathElements, 0, split.length);
-		} else {
-			pathElements = split;
-		}
-	}
+    /**
+     * Private constructor for next sub - path.
+     * @param pathElements
+     */
+    private ServerResourcePath(String[] pathElements) {
+        this.pathElements = pathElements;
+    }
 
-	/**
-	 * Method to detect last element in the path.
-	 * @return true for a last element in the path.
-	 */
-	public boolean isFile() {
-		return pathElements.length <= 1 || null == pathElements[1];
-	}
+    /**
+     * Method to detect last element in the path.
+     * @return true for a last element in the path.
+     */
+    public boolean isFile() {
+        return pathElements.length <= 1 || null == pathElements[1];
+    }
 
-	/**
-	 * Name of the next element ( directory or file ) name. 
-	 * For the "/foo/bar/baz" it should be "foo/" ,  /bar/baz : "bar/" , "/" : null.
-	 * @return name of the next element or null if it is last element in the chain ( file ).
-	 */
-	public String getNextElementName() {
-		if (pathElements.length > 1) {
-			String name = pathElements[1];
-			if(pathElements.length>2){
-				name+='/';
-			}
-			return name;
-		} else {
-			return null;
-		}
-	}
+    /**
+     * Name of the next element ( directory or file ) name.
+     * For the "/foo/bar/baz" it should be "foo/" ,  /bar/baz : "bar/" , "/" : null.
+     * @return name of the next element or null if it is last element in the chain ( file ).
+     */
+    public String getNextElementName() {
+        if (pathElements.length > 1) {
+            String name = pathElements[1];
 
-	/**
-	 * Create next path of the path chain.
-	 * Path /foo/bar/baz should be converted to /bar/baz , /bar/baz -> /baz -> / ( empty path )
-	 * @return next subdirectory path or null.
-	 */
-	public ServerResourcePath getNextPath() {
-		if (pathElements.length > 1 && null != pathElements[1]) {
-		String[] nextElenemts = new String[pathElements.length - 1];
-		System.arraycopy(pathElements, 1, nextElenemts, 0, nextElenemts.length);
-		return new ServerResourcePath(nextElenemts);
-		} else {
-			return null;
-		}
-	}
-	
-	@Override
-	public String toString() {
-		StringBuilder str = new StringBuilder();
-		if (pathElements.length > 1) {
-		for (int i = 1; i < pathElements.length; i++) {
-			String element = pathElements[i];
-			str.append("/");
-			if(null != element){
-				str.append(element);
-			}
-		}
-		} else {
-			str.append("/");
-		}
-		return str.toString();
-	}
+            if (pathElements.length > 2) {
+                name += '/';
+            }
+
+            return name;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Create next path of the path chain.
+     * Path /foo/bar/baz should be converted to /bar/baz , /bar/baz -> /baz -> / ( empty path )
+     * @return next subdirectory path or null.
+     */
+    public ServerResourcePath getNextPath() {
+        if (pathElements.length > 1 && null != pathElements[1]) {
+            String[] nextElenemts = new String[pathElements.length - 1];
+
+            System.arraycopy(pathElements, 1, nextElenemts, 0, nextElenemts.length);
+
+            return new ServerResourcePath(nextElenemts);
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder str = new StringBuilder();
+
+        if (pathElements.length > 1) {
+            for (int i = 1; i < pathElements.length; i++) {
+                String element = pathElements[i];
+
+                str.append("/");
+
+                if (null != element) {
+                    str.append(element);
+                }
+            }
+        } else {
+            str.append("/");
+        }
+
+        return str.toString();
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerResourcesDirectory.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerResourcesDirectory.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServerResourcesDirectory.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,10 +1,13 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
 import java.io.InputStream;
+
 import java.net.URL;
+
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -15,79 +18,90 @@
  *
  */
 public class ServerResourcesDirectory implements ServerResource {
-	
-	
 
-	/**
-	 * Directory content.
-	 */
-	private final Map<String,ServerResource> children = new HashMap<String,ServerResource>();
+    /**
+     * Directory content.
+     */
+    private final Map<String, ServerResource> children = new HashMap<String, ServerResource>();
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.ServerResource#addResource(org.richfaces.test.staging.ServerResource)
-	 */
-	public void addResource(ServerResourcePath path,ServerResource resource) {
-		
-		if(null == path || path.isFile()){
-			throw new IllegalArgumentException();
-		} else if(path.getNextPath().isFile()) {
-			// This is a last part in the path - append resource to the directory content.
-			children.put(path.getNextElementName(), resource);
-		} else {
-			// Create a next directory entry.
-			ServerResource nextDirectory = children.get(path.getNextElementName());
-			if(null == nextDirectory){
-				nextDirectory = new ServerResourcesDirectory();
-				children.put(path.getNextElementName(), nextDirectory);
-			}
-			nextDirectory.addResource(path.getNextPath(), resource);
-		}
-	}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.ServerResource#addResource(org.richfaces.test.staging.ServerResource)
+     */
+    public void addResource(ServerResourcePath path, ServerResource resource) {
+        if (null == path || path.isFile()) {
+            throw new IllegalArgumentException();
+        } else if (path.getNextPath().isFile()) {
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.ServerResource#getResource(org.richfaces.test.staging.ServerResourcePath)
-	 */
-	public ServerResource getResource(ServerResourcePath path) {
-		if(null == path){
-			throw new NullPointerException();
-		}
-		ServerResource resource = null; //children.get(path.getName());
-		if(path.isFile()){
-			// Path points to the resource itself.
-			resource=this;
-		} else {
-			resource = children.get(path.getNextElementName());
-			if(!path.getNextPath().isFile() && null!=resource){
-				// Get next resource in the tree, if exists.
-				resource = resource.getResource(path.getNextPath());
-			}			
-		}
-		return resource;
-	}
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.ServerResource#getAsStream()
-	 */
-	public InputStream getAsStream() {
-		// can't read directory.
-		return null;
-	}
+            // This is a last part in the path - append resource to the directory content.
+            children.put(path.getNextElementName(), resource);
+        } else {
 
+            // Create a next directory entry.
+            ServerResource nextDirectory = children.get(path.getNextElementName());
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.ServerResource#getPaths()
-	 */
-	public Set<String> getPaths() {
-		return children.keySet();
-	}
+            if (null == nextDirectory) {
+                nextDirectory = new ServerResourcesDirectory();
+                children.put(path.getNextElementName(), nextDirectory);
+            }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.ServerResource#getURL()
-	 */
-	public URL getURL() {
-		// Directory don't have url.
-		return null;
-	}
+            nextDirectory.addResource(path.getNextPath(), resource);
+        }
+    }
 
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.ServerResource#getResource(org.richfaces.test.staging.ServerResourcePath)
+     */
+    public ServerResource getResource(ServerResourcePath path) {
+        if (null == path) {
+            throw new NullPointerException();
+        }
 
-	
+        ServerResource resource = null; // children.get(path.getName());
+
+        if (path.isFile()) {
+
+            // Path points to the resource itself.
+            resource = this;
+        } else {
+            resource = children.get(path.getNextElementName());
+
+            if (!path.getNextPath().isFile() && null != resource) {
+
+                // Get next resource in the tree, if exists.
+                resource = resource.getResource(path.getNextPath());
+            }
+        }
+
+        return resource;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.ServerResource#getAsStream()
+     */
+    public InputStream getAsStream() {
+
+        // can't read directory.
+        return null;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.ServerResource#getPaths()
+     */
+    public Set<String> getPaths() {
+        return children.keySet();
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.ServerResource#getURL()
+     */
+    public URL getURL() {
+
+        // Directory don't have url.
+        return null;
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServletContainer.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServletContainer.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/ServletContainer.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,9 +1,11 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
 import java.io.IOException;
+
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -17,197 +19,187 @@
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
-
 /**
  * This class represens Servlet in the web application.
  * @author asmirnov
- * 
+ *
  */
 public class ServletContainer implements RequestChain {
+    private static final Logger LOG = ServerLogger.SERVER.getLogger();
+    private String name = "Default";
+    private boolean initialized = false;
+    private final Map<String, String> initParameters;
+    private final String mapping;
+    private final boolean prefixMapped;
+    private final Servlet servlet;
 
-	private static final Logger log = ServerLogger.SERVER.getLogger();
+    /**
+     * @param mapping Servlet mapping pattern, as defined in the &lt;servlet-mapping&gt; element.
+     * @param servlet servlet instance. Can't be null.
+     * @throws NullPointerException if servlet parameter is null.
+     */
+    public ServletContainer(String mapping, Servlet servlet) {
+        if (null == servlet) {
+            throw new NullPointerException();
+        }
 
-	private final Servlet servlet;
+        if (null == mapping) {
+            this.prefixMapped = true;
+            this.mapping = "";
+        } else if (mapping.startsWith("*")) {
+            this.prefixMapped = false;
+            this.mapping = mapping.substring(1);
+        } else if (mapping.endsWith("*")) {
+            this.prefixMapped = true;
+            this.mapping = mapping.substring(0, mapping.length() - 1);
+        } else {
+            throw new IllegalArgumentException("Invalid mapping " + mapping);
+        }
 
-	private final boolean prefixMapped;
+        this.servlet = servlet;
+        this.initParameters = new HashMap<String, String>();
+    }
 
-	private final String mapping;
+    /**
+     * Append filter initialization parameter. Name and value are same as
+     * defined in the web.xml
+     *
+     * <code>
+     * &lt;init-param&gt;
+     *    &lt;param-name&gt;foo&lt;/param-name&gt;
+     *    &lt;param-value&gt;bar&lt;/param-value&gt;
+     *   &lt;/init-param&gt;
+     * </code>
+     *
+     * @param name
+     * @param value
+     * @throws IllegalStateException if servlet was already initialized.
+     */
+    public void addInitParameter(String name, String value) {
+        if (initialized) {
+            throw new IllegalStateException("Servlet have already been initialized, init parameters can't be changed");
+        }
 
-	private final Map<String, String> initParameters;
+        initParameters.put(name, value);
+    }
 
-	private String name = "Default";
+    /**
+     * @return the name of servlet
+     */
+    public String getName() {
+        return name;
+    }
 
-	private boolean initialized = false;
+    /**
+     * @param name
+     *            the name to set
+     * @throws IllegalStateException if servlet was already initialized.
+     */
+    public void setName(String name) {
+        if (initialized) {
+            throw new IllegalStateException("Servlet have already been initialized, name can't be changed");
+        }
 
-	/**
-	 * @param mapping Servlet mapping pattern, as defined in the &lt;servlet-mapping&gt; element.
-	 * @param servlet servlet instance. Can't be null.
-	 * @throws NullPointerException if servlet parameter is null.
-	 */
-	public ServletContainer(String mapping, Servlet servlet) {
-		if(null == servlet){
-			throw new NullPointerException();
-		}
-		if (null == mapping) {
-			this.prefixMapped = true;
-			this.mapping = "";
-		} else if (mapping.startsWith("*")) {
-			this.prefixMapped = false;
-			this.mapping = mapping.substring(1);
-		} else if (mapping.endsWith("*")) {
-			this.prefixMapped = true;
-			this.mapping = mapping.substring(0, mapping.length() - 1);
-		} else {
-			throw new IllegalArgumentException("Invalid mapping " + mapping);
-		}
-		this.servlet = servlet;
-		this.initParameters = new HashMap<String, String>();
-	}
+        this.name = name;
+    }
 
-	/**
-	 * Append filter initialization parameter. Name and value are same as
-	 * defined in the web.xml
-	 * 
-	 * <code>
-	 * &lt;init-param&gt;
-	 *    &lt;param-name&gt;foo&lt;/param-name&gt;
-	 *    &lt;param-value&gt;bar&lt;/param-value&gt;
-	 *   &lt;/init-param&gt;
-	 * </code>
-	 * 
-	 * @param name
-	 * @param value
-	 * @throws IllegalStateException if servlet was already initialized.
-	 */
-	public void addInitParameter(String name, String value) {
-		if (initialized) {
-			throw new IllegalStateException(
-					"Servlet have already been initialized, init parameters can't be changed");
-		}
-		initParameters.put(name, value);
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.richfaces.test.staging.RequestChain#isApplicable(java.lang.String)
+     */
+    public boolean isApplicable(String path) {
+        if (prefixMapped && path.startsWith(mapping)) {
+            return true;
+        } else {
+            return !prefixMapped && path.endsWith(mapping);
+        }
+    }
 
-	/**
-	 * @return the name of servlet
-	 */
-	public String getName() {
-		return name;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.RequestChain#getServletPath(java.lang.String)
+     */
+    public String getServletPath(String path) {
+        if (!isApplicable(path)) {
+            return null;
+        }
 
-	/**
-	 * @param name
-	 *            the name to set
-	 * @throws IllegalStateException if servlet was already initialized.
-	 */
-	public void setName(String name) {
-		if (initialized) {
-			throw new IllegalStateException(
-					"Servlet have already been initialized, name can't be changed");
-		}
-		this.name = name;
-	}
+        if (prefixMapped) {
+            return mapping;
+        } else {
+            return path;
+        }
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.richfaces.test.staging.RequestChain#isApplicable(java.lang.String)
-	 */
-	public boolean isApplicable(String path) {
-		if (prefixMapped && path.startsWith(mapping)) {
-			return true;
-		} else if (!prefixMapped && path.endsWith(mapping)) {
-			return true;
-		} else {
-			return false;
-		}
-	}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.RequestChain#getPathInfo(java.lang.String)
+     */
+    public String getPathInfo(String path) {
+        if (!isApplicable(path)) {
+            return null;
+        }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.RequestChain#getServletPath(java.lang.String)
-	 */
-	public String getServletPath(String path) {
-		if (!isApplicable(path)) {
-			return null;
-		}
-		if (prefixMapped) {
-			return mapping;
-		} else {
-			return path;
-		}
-	}
+        if (prefixMapped) {
+            return path.substring(mapping.length());
+        } else {
+            return null;
+        }
+    }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.RequestChain#getPathInfo(java.lang.String)
-	 */
-	public String getPathInfo(String path) {
-		if (!isApplicable(path)) {
-			return null;
-		}
-		if (prefixMapped) {
-			return path.substring(mapping.length());
-		} else {
-			return null;
-		}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.RequestChain#init(org.richfaces.test.staging.StagingServletContext)
+     */
+    public void init(final ServletContext context) throws ServletException {
+        if (!initialized) {
+            LOG.finest("Initialize servlet " + getName());
+            servlet.init(new ServletConfig() {
+                public String getInitParameter(String name) {
+                    return initParameters.get(name);
+                }
+                @SuppressWarnings("unchecked")
+                public Enumeration getInitParameterNames() {
+                    return Collections.enumeration(initParameters.keySet());
+                }
+                public ServletContext getServletContext() {
+                    return context;
+                }
+                public String getServletName() {
+                    return name;
+                }
+            });
+            initialized = true;
+        }
+    }
 
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.richfaces.test.staging.RequestChain#execute(javax.servlet.ServletRequest
+     * , javax.servlet.ServletResponse)
+     */
+    public void execute(ServletRequest request, ServletResponse response) throws ServletException, IOException {
+        if (!initialized) {
+            throw new IllegalStateException("Servlet " + getName()
+                                            + " have not been initialized, could'n execute request");
+        }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.RequestChain#init(org.richfaces.test.staging.StagingServletContext)
-	 */
-	public void init(final ServletContext context)
-			throws ServletException {
-		if (!initialized) {
-			log.finest("Initialize servlet "+getName());
-			servlet.init(new ServletConfig() {
+        LOG.finest("Request '" + request + "' executes by the '" + getName() + "' servlet");
+        this.servlet.service(request, response);
+    }
 
-				public String getInitParameter(String name) {
-					return initParameters.get(name);
-				}
-
-				@SuppressWarnings("unchecked")
-				public Enumeration getInitParameterNames() {
-					return Collections.enumeration(initParameters.keySet());
-				}
-
-				public ServletContext getServletContext() {
-					return context;
-				}
-
-				public String getServletName() {
-					return name;
-				}
-
-			});
-			initialized = true;
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.richfaces.test.staging.RequestChain#execute(javax.servlet.ServletRequest
-	 * , javax.servlet.ServletResponse)
-	 */
-	public void execute(ServletRequest request, ServletResponse response)
-			throws ServletException, IOException {
-		if (!initialized) {
-			throw new IllegalStateException(
-					"Servlet "+getName()+" have not been initialized, could'n execute request");
-		}
-		log.finest("Request '"+request+"' executes by the '"+getName()+"' servlet");
-		this.servlet.service(request, response);
-
-	}
-
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.RequestChain#destroy()
-	 */
-	public void destroy() {
-		if (initialized) {
-			this.servlet.destroy();
-			initialized = false;
-		}
-	}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.RequestChain#destroy()
+     */
+    public void destroy() {
+        if (initialized) {
+            this.servlet.destroy();
+            initialized = false;
+        }
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StaggingJspApplicationContext.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,63 +1,64 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
 import javax.el.ELContextListener;
 import javax.el.ELResolver;
 import javax.el.ExpressionFactory;
+
 import javax.servlet.ServletContext;
 import javax.servlet.jsp.JspApplicationContext;
 
 import org.richfaces.test.TestException;
 
-
 /**
  * @author asmirnov
  *
  */
 public class StaggingJspApplicationContext implements JspApplicationContext {
-	
-	private static final String DEFAULT_EXPRESSION_FACTORY="com.sun.el.ExpressionFactoryImpl";
-	
-	private final ExpressionFactory expressionFactory ;
-	private final ServletContext servletContext;
-	
+    private static final String DEFAULT_EXPRESSION_FACTORY = "com.sun.el.ExpressionFactoryImpl";
+    private final ExpressionFactory expressionFactory;
+    private final ServletContext servletContext;
 
-	public StaggingJspApplicationContext(ServletContext servletContext) {
-		this.servletContext = servletContext;
-		String elFactoryClass = servletContext.getInitParameter("com.sun.faces.expressionFactory");
-		if(null == elFactoryClass){
-			elFactoryClass = servletContext.getInitParameter("com.sun.el.ExpressionFactoryImpl");
-		}
-		if(null == elFactoryClass){
-			elFactoryClass = DEFAULT_EXPRESSION_FACTORY;
-		}
-		try {
-			expressionFactory = Class.forName(elFactoryClass).asSubclass(ExpressionFactory.class).newInstance();
-		} catch (Exception e) {
-			throw new TestException("Couldn't instantiate EL expression factory",e);
-		}
-	}
+    public StaggingJspApplicationContext(ServletContext servletContext) {
+        this.servletContext = servletContext;
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.jsp.JspApplicationContext#addELContextListener(javax.el.ELContextListener)
-	 */
-	public void addELContextListener(ELContextListener listener) {
+        String elFactoryClass = servletContext.getInitParameter("com.sun.faces.expressionFactory");
 
-	}
+        if (null == elFactoryClass) {
+            elFactoryClass = servletContext.getInitParameter("com.sun.el.ExpressionFactoryImpl");
+        }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.jsp.JspApplicationContext#addELResolver(javax.el.ELResolver)
-	 */
-	public void addELResolver(ELResolver resolver) {
-	}
+        if (null == elFactoryClass) {
+            elFactoryClass = DEFAULT_EXPRESSION_FACTORY;
+        }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.jsp.JspApplicationContext#getExpressionFactory()
-	 */
-	public ExpressionFactory getExpressionFactory() {
-		return expressionFactory;
-	}
+        try {
+            expressionFactory = Class.forName(elFactoryClass).asSubclass(ExpressionFactory.class).newInstance();
+        } catch (Exception e) {
+            throw new TestException("Couldn't instantiate EL expression factory", e);
+        }
+    }
 
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.jsp.JspApplicationContext#addELContextListener(javax.el.ELContextListener)
+     */
+    public void addELContextListener(ELContextListener listener) {}
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.jsp.JspApplicationContext#addELResolver(javax.el.ELResolver)
+     */
+    public void addELResolver(ELResolver resolver) {}
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.jsp.JspApplicationContext#getExpressionFactory()
+     */
+    public ExpressionFactory getExpressionFactory() {
+        return expressionFactory;
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StaggingJspFactory.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
@@ -18,78 +19,75 @@
  * Stagging implementation of the {@link JspFactory} to simulate JSP processing in the stagging server.
  * TODO - implement JSP functionality.
  * @author asmirnov
- * 
+ *
  */
 public class StaggingJspFactory extends JspFactory {
+    private static final JspEngineInfo ENGINE_INFO = new JspEngineInfo() {
+        @Override
+        public String getSpecificationVersion() {
+            return "2.1";
+        }
+    };
+    private final JspApplicationContext context;
 
-	private static final JspEngineInfo engineInfo = new JspEngineInfo() {
+    public StaggingJspFactory(ServletContext servletContext) {
+        this.context = new StaggingJspApplicationContext(servletContext);
+    }
 
-		@Override
-		public String getSpecificationVersion() {
-			return "2.1";
-		}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.jsp.JspFactory#getEngineInfo()
+     */
+    @Override
+    public JspEngineInfo getEngineInfo() {
 
-	};
+        // TODO Auto-generated method stub
+        return ENGINE_INFO;
+    }
 
-	private final JspApplicationContext context;
+    /*
+     * (non-Javadoc)
+     *
+     * @seejavax.servlet.jsp.JspFactory#getJspApplicationContext(javax.servlet.
+     * ServletContext)
+     */
+    @Override
+    public JspApplicationContext getJspApplicationContext(ServletContext context) {
+        return this.context;
+    }
 
-	public StaggingJspFactory(ServletContext servletContext) {
-		this.context = new StaggingJspApplicationContext(servletContext);
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.jsp.JspFactory#getPageContext(javax.servlet.Servlet,
+     * javax.servlet.ServletRequest, javax.servlet.ServletResponse,
+     * java.lang.String, boolean, int, boolean)
+     */
+    @Override
+    public PageContext getPageContext(final Servlet servlet, final ServletRequest request,
+                                      final ServletResponse response, String errorPageURL, final boolean needsSession,
+                                      int buffer, boolean autoflush) {
+        PageContextExtension pageContextExtension = new PageContextExtension();
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.jsp.JspFactory#getEngineInfo()
-	 */
-	@Override
-	public JspEngineInfo getEngineInfo() {
-		// TODO Auto-generated method stub
-		return engineInfo;
-	}
+        try {
+            pageContextExtension.initialize(servlet, request, response, errorPageURL, needsSession, buffer, autoflush);
+        } catch (IOException e) {
+            throw new IllegalStateException(e);
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @seejavax.servlet.jsp.JspFactory#getJspApplicationContext(javax.servlet.
-	 * ServletContext)
-	 */
-	@Override
-	public JspApplicationContext getJspApplicationContext(ServletContext context) {
-		return this.context;
-	}
+        return pageContextExtension;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.jsp.JspFactory#getPageContext(javax.servlet.Servlet,
-	 * javax.servlet.ServletRequest, javax.servlet.ServletResponse,
-	 * java.lang.String, boolean, int, boolean)
-	 */
-	@Override
-	public PageContext getPageContext(final Servlet servlet, final ServletRequest request,
-			final ServletResponse response, String errorPageURL,
-			final boolean needsSession, int buffer, boolean autoflush) {
-		PageContextExtension pageContextExtension = new PageContextExtension();
-		try {
-			pageContextExtension.initialize(servlet, request, response, errorPageURL, needsSession, buffer, autoflush);
-		} catch (IOException e) {
-			throw new IllegalStateException(e);
-		}
-		return pageContextExtension;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * javax.servlet.jsp.JspFactory#releasePageContext(javax.servlet.jsp.PageContext
-	 * )
-	 */
-	@Override
-	public void releasePageContext(PageContext pc) {
-		pc.release();
-
-	}
-
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * javax.servlet.jsp.JspFactory#releasePageContext(javax.servlet.jsp.PageContext
+     * )
+     */
+    @Override
+    public void releasePageContext(PageContext pc) {
+        pc.release();
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingConnection.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingConnection.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingConnection.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,14 +1,18 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+
 import java.lang.reflect.Proxy;
+
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLDecoder;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -29,596 +33,618 @@
 import org.richfaces.test.TestException;
 
 /**
- * This class represent single connection ( request ) to the virtual server. These instance should not be created directly, but by the {@link StagingServer#getConnection(URL)}.
- * method only.
+ * This class represent single connection ( request ) to the virtual server. These instance should not be created
+ * directly, but by the {@link StagingServer#getConnection(URL)}. method only.
  * Since instance have been created, additional request parameters and headers can be set.
  * @author asmirnov
- * 
+ *
  */
 public class StagingConnection {
+    private static final Logger LOG = ServerLogger.SERVER.getLogger();
+    private static final Cookie[] COOKIE = new Cookie[] {};
 
-	private static final Logger log = ServerLogger.SERVER.getLogger();
+    final URL url;
 
-	private final StagingServer server;
+    private HttpMethod method = HttpMethod.GET;
+    private List<Cookie> cookies = new ArrayList<Cookie>();
+    private Map<String, String[]> requestParameters = new HashMap<String, String[]>();
+    private boolean finished = false;
+    private boolean started = false;
+    private final String pathInfo;
+    private String queryString;
+    private ConnectionRequest request;
+    private HttpServletRequest requestProxy;
+    private ConnectionResponse response;
+    private HttpServletResponse responseProxy;
+    private final StagingServer server;
+    private final RequestChain servlet;
+    private final String servletPath;
 
-	final URL url;
+    /**
+     * Create connection instance.
+     * @param localServer virtual server instance.
+     * @param url request URL.
+     */
+    StagingConnection(StagingServer localServer, URL url) {
+        this.server = localServer;
+        this.url = url;
 
-	private ConnectionRequest request;
+        // TODO - context path support.
+        String path = url.getPath();
 
-	private ConnectionResponse response;
+        servlet = localServer.getServlet(path);
 
-	private final RequestChain servlet;
+        if (null == servlet) {
+            throw new IllegalArgumentException();
+        }
 
-	private HttpMethod method = HttpMethod.GET;
+        this.pathInfo = servlet.getPathInfo(path);
+        this.servletPath = servlet.getServletPath(path);
+        this.request = new ConnectionRequest();
+        this.response = new ConnectionResponse();
+        this.request.setAttribute("javax.servlet.include.path_info", this.pathInfo);
+        this.request.setAttribute("javax.servlet.include.servlet_path", this.servletPath);
+        setQueryString(url.getQuery());
 
-	private static final Cookie[] COOKIE = new Cookie[] {};
+        if (null != getQueryString()) {
+            parseFormParameters(queryString);
+        }
 
-	private List<Cookie> cookies = new ArrayList<Cookie>();
+        // Create proxy objects.
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
 
-	private Map<String, String[]> requestParameters = new HashMap<String, String[]>();
+        if (null == loader) {
+            loader = this.getClass().getClassLoader();
+        }
 
-	private final String pathInfo;
+        requestProxy = (HttpServletRequest) Proxy.newProxyInstance(loader, new Class[] {HttpServletRequest.class},
+                server.getInvocationHandler(request));
+        responseProxy = (HttpServletResponse) Proxy.newProxyInstance(loader, new Class[] {HttpServletResponse.class},
+                server.getInvocationHandler(response));
+    }
 
-	private final String servletPath;
+    /**
+     * Parse 'application/x-www-form-urlencoded' string with parameters name/value pairs,
+     * as it expected after a form submit.
+     * @param queryString URL query string or POST content.
+     */
+    public void parseFormParameters(String queryString) {
+        String[] queryParams = queryString.split("&");
 
-	private boolean finished = false;
+        for (int i = 0; i < queryParams.length; i++) {
+            try {
+                String par = queryParams[i];
+                int eqIndex = par.indexOf('=');
 
-	private boolean started = false;
+                if (eqIndex >= 0) {
 
-	private String queryString;
+                    // decode url-decoded values.
+                    String name = URLDecoder.decode(par.substring(0, eqIndex), request.getCharacterEncoding());
+                    String value = URLDecoder.decode(par.substring(eqIndex + 1), request.getCharacterEncoding());
 
-	private HttpServletRequest requestProxy;
+                    addRequestParameter(name, value);
+                } else {
+                    addRequestParameter(URLDecoder.decode(par, request.getCharacterEncoding()), null);
+                }
+            } catch (UnsupportedEncodingException e) {
+                throw new TestException(e);
+            }
+        }
+    }
 
-	private HttpServletResponse responseProxy;
+    /**
+     * @return the finished
+     */
+    public boolean isFinished() {
+        return finished;
+    }
 
-	/**
-	 * Create connection instance.
-	 * @param localServer virtual server instance.
-	 * @param url request URL.
-	 */
-	StagingConnection(StagingServer localServer, URL url) {
-		this.server = localServer;
-		this.url = url;
-		// TODO - context path support.
-		String path = url.getPath();
-		servlet = localServer.getServlet(path);
-		if (null == servlet) {
-			throw new IllegalArgumentException();
-		}
-		this.pathInfo = servlet.getPathInfo(path);
-		this.servletPath = servlet.getServletPath(path);
-		this.request = new ConnectionRequest();
-		this.response = new ConnectionResponse();
-		this.request.setAttribute("javax.servlet.include.path_info",
-				this.pathInfo);
-		this.request.setAttribute("javax.servlet.include.servlet_path",
-				this.servletPath);
-		setQueryString(url.getQuery());
-		if (null != getQueryString()) {
-			parseFormParameters(queryString);
-		}
-		
-		// Create proxy objects.
-		ClassLoader loader = Thread.currentThread().getContextClassLoader();
-		if(null == loader){
-			loader = this.getClass().getClassLoader();
-		}
-		requestProxy = (HttpServletRequest) Proxy.newProxyInstance(loader, new Class[]{HttpServletRequest.class}, server.getInvocationHandler(request));
-		responseProxy = (HttpServletResponse) Proxy.newProxyInstance(loader, new Class[]{HttpServletResponse.class}, server.getInvocationHandler(response));
-	}
+    /**
+     * @return the started
+     */
+    public boolean isStarted() {
+        return started;
+    }
 
-	/**
-	 * Parse 'application/x-www-form-urlencoded' string with parameters name/value pairs,
-	 * as it expected after a form submit.
-	 * @param queryString URL query string or POST content.
-	 */
-	public void parseFormParameters(String queryString) {
-		String[] queryParams = queryString.split("&");
-		for (int i = 0; i < queryParams.length; i++) {
-			try {
-				String par = queryParams[i];
-				int eqIndex = par.indexOf('=');
-				if (eqIndex >= 0) {
-					// decode url-decoded values.
-					String name = URLDecoder.decode(par.substring(0, eqIndex),
-							request.getCharacterEncoding());
-					String value = URLDecoder.decode(
-							par.substring(eqIndex + 1), request
-									.getCharacterEncoding());
-					addRequestParameter(name, value);
-				} else {
-					addRequestParameter(URLDecoder.decode(par, request
-							.getCharacterEncoding()), null);
-				}
-			} catch (UnsupportedEncodingException e) {
-				throw new TestException(e);
-			}
-		}
-	}
+//  private void checkStarted() {
+//      if (!isFinished()) {
+//          throw new TestException("request have not been started");
+//      }
+//  }
+//  private void checkNotStarted() {
+//      if (isStarted()) {
+//          throw new TestException("request was started, no parameters changes allowed");
+//      }
+//  }
 
-	/**
-	 * @return the finished
-	 */
-	public boolean isFinished() {
-		return finished;
-	}
+    /**
+     * Execute this connection request on the associated servlet or filter chain.
+     * @throws TestException if any errors were during execution.
+     */
+    public void execute() {
+        if (isStarted() || isFinished()) {
+            throw new TestException("request have already been executed");
+        }
 
-	/**
-	 * @return the started
-	 */
-	public boolean isStarted() {
-		return started;
-	}
+        start();
 
-//	private void checkStarted() {
-//		if (!isFinished()) {
-//			throw new TestException("request have not been started");
-//		}
-//	}
+        try {
+            this.servlet.execute(request, response);
+        } catch (ServletException e) {
+            throw new TestException("Error execute request ", e);
+        } catch (IOException e) {
+            throw new TestException("IO Error during request execution", e);
+        } finally {
+            finish();
+        }
+    }
 
-//	private void checkNotStarted() {
-//		if (isStarted()) {
-//			throw new TestException("request was started, no parameters changes allowed");
-//		}
-//	}
+    /**
+     * Finish request to the this connection, inform server listeners about request status.
+     */
+    public void finish() {
+        server.requestFinished(request);
+        finished = true;
+    }
 
-	/**
-	 * Execute this connection request on the associated servlet or filter chain.
-	 * @throws TestException if any errors were during execution.
-	 */
-	public void execute() {
-		if (isStarted() || isFinished()) {
-			throw new TestException(
-					"request have already been executed");
-		}
-		start();
-		try {
-			this.servlet.execute(request, response);
-		} catch (ServletException e) {
-			throw new TestException("Error execute request ",e);
-		} catch (IOException e) {
-			throw new TestException("IO Error during request execution",e);
-		} finally {
-			finish();
-		}
-	}
+    /**
+     * Start request to the this connection, inform server listeners about request status.
+     * No request parameters changes allowed after connection start.
+     */
+    public void start() {
+        LOG.fine("start " + getRequestMethod() + " request processing for file " + url.getFile());
+        LOG.fine("request parameters: " + requestParameters);
+        server.requestStarted(request);
+        started = true;
+    }
 
-	/**
-	 * Finish request to the this connection, inform server listeners about request status.
-	 */
-	public void finish() {
-		server.requestFinished(request);
-		finished = true;
-	}
+    /**
+     * Get request HTTP methos ( GET, POST etc ).
+     * @return the method
+     */
+    public HttpMethod getRequestMethod() {
+        return method;
+    }
 
-	/**
-	 * Start request to the this connection, inform server listeners about request status.
-	 * No request parameters changes allowed after connection start.
-	 */
-	public void start() {
-		log.fine("start " + getRequestMethod() + " request processing for file "
-				+ url.getFile());
-		log.fine("request parameters: " + requestParameters);
-		server.requestStarted(request);
-		started = true;
-	}
+    /**
+     * Set request HTTP methos ( GET, POST etc ).
+     * @param method
+     *            the method to set
+     */
+    public void setRequestMethod(HttpMethod method) {
 
-	/**
-	 * Get request HTTP methos ( GET, POST etc ).
-	 * @return the method
-	 */
-	public HttpMethod getRequestMethod() {
-		return method;
-	}
+//      checkNotStarted();
+        this.method = method;
+    }
 
-	/**
-	 * Set request HTTP methos ( GET, POST etc ).
-	 * @param method
-	 *            the method to set
-	 */
-	public void setRequestMethod(HttpMethod method) {
-//		checkNotStarted();
-		this.method = method;
-	}
+    /**
+     * Get request url.
+     * @return the url
+     */
+    public URL getUrl() {
+        return url;
+    }
 
-	/**
-	 * Get request url.
-	 * @return the url
-	 */
-	public URL getUrl() {
-		return url;
-	}
+    /**
+     * Append additional request parameter.
+     * @param name
+     * @param value
+     */
+    public void addRequestParameter(String name, String value) {
 
-	/**
-	 * Append additional request parameter.
-	 * @param name
-	 * @param value
-	 */
-	public void addRequestParameter(String name, String value) {
-//		checkNotStarted();
-		String[] values = requestParameters.get(name);
-		if (null == values) {
-			values = new String[1];
-		} else {
-			String[] newValues = new String[values.length + 1];
-			System.arraycopy(values, 0, newValues, 0, values.length);
-			values = newValues;
-		}
-		values[values.length - 1] = value;
-		requestParameters.put(name, values);
-	}
+//      checkNotStarted();
+        String[] values = requestParameters.get(name);
 
-	/**
-	 * Get content of the response as String. 
-	 * @return content of the response writer or String created from the ServletOutputStream with current response encoding.
-	 * @throws TestException
-	 * 	          if has an unsupported encoding.
-	 */
-	public String getContentAsString() {
-//		checkStarted();
-		String content = response.getWriterContent();
-		if (null == content) {
-			byte[] streamContent = response.getStreamContent();
-			if (null != streamContent) {
-				String encoding = response.getCharacterEncoding();
-				if (null != encoding) {
-					try {
-						content = new String(streamContent, encoding);
-					} catch (UnsupportedEncodingException e) {
-						throw new TestException(e);
-					}
-				} else {
-					content = new String(streamContent);
-				}
-			}
-		}
-		return content;
-	}
+        if (null == values) {
+            values = new String[1];
+        } else {
+            String[] newValues = new String[values.length + 1];
 
-	/**
-	 * Get content of the response as byte array.
-	 * @return content of the ServletOutputStream or convert String, collected by response writer, with current response encoding.
-	 * @throws TestException
-	 * 	          if response has unsupported encoding.
-	 */
-	public byte[] getResponseBody() {
-//		checkStarted();
-		byte[] content = response.getStreamContent();
-		if (null == content) {
-			String writerContent = response.getWriterContent();
-			if (null != writerContent) {
-				try {
-					content = writerContent.getBytes(response
-							.getCharacterEncoding());
-				} catch (UnsupportedEncodingException e) {
-					content = writerContent.getBytes();
-				}
-			} else {
-				content = new byte[0];
-			}
-		}
-		return content;
-	}
+            System.arraycopy(values, 0, newValues, 0, values.length);
+            values = newValues;
+        }
 
-	/**
-	 * List of the {@link Cookie} used by the request or response ( There are same cookies for both request and response ). 
-	 * @return the cookies
-	 */
-	public List<Cookie> getCookies() {
-		return cookies;
-	}
+        values[values.length - 1] = value;
+        requestParameters.put(name, values);
+    }
 
-	/**
-	 * request object for the this connection.
-	 * @return the request
-	 */
-	public HttpServletRequest getRequest() {
-		return requestProxy;
-	}
+    /**
+     * Get content of the response as String.
+     * @return content of the response writer or String created from the ServletOutputStream with current response
+     * encoding.
+     *
+     * @throws TestException
+     *            if has an unsupported encoding.
+     */
+    public String getContentAsString() {
 
-	/**
-	 * response object for the this connection.
-	 * @return the response
-	 */
-	public HttpServletResponse getResponse() {
-		return responseProxy;
-	}
+//      checkStarted();
+        String content = response.getWriterContent();
 
-	/**
-	 * @return encoding used to write response.
-	 */
-	public String getResponseCharacterEncoding() {
-//		checkStarted();
-		return response.getCharacterEncoding();
-	}
+        if (null == content) {
+            byte[] streamContent = response.getStreamContent();
 
-	/**
-	 * @return content type ( eg 'text/html' ) of the response.
-	 */
-	public String getResponseContentType() {
-//		checkStarted();
-		return response.getContentType();
-	}
+            if (null != streamContent) {
+                String encoding = response.getCharacterEncoding();
 
-	/**
-	 * @return HTTP status code of the response.
-	 */
-	public int getResponseStatus() {
-//		checkStarted();
-		return response.getStatus();
-	}
+                if (null != encoding) {
+                    try {
+                        content = new String(streamContent, encoding);
+                    } catch (UnsupportedEncodingException e) {
+                        throw new TestException(e);
+                    }
+                } else {
+                    content = new String(streamContent);
+                }
+            }
+        }
 
-	/**
-	 * @return HTTP error message.
-	 */
-	public String getErrorMessage() {
-//		checkStarted();
-		return response.getErrorMessage();
-	}
+        return content;
+    }
 
-	/**
-	 * Set request Query string. This method does not parse query string, {@link #parseFormParameters(String)} should be used.
-	 * @param queryString
-	 *            the queryString to set
-	 */
-	public void setQueryString(String queryString) {
-//		checkNotStarted();
-		this.queryString = queryString;
-	}
+    /**
+     * Get content of the response as byte array.
+     * @return content of the ServletOutputStream or convert String, collected by response writer, with current
+     * response encoding.
+     *
+     * @throws TestException
+     *            if response has unsupported encoding.
+     */
+    public byte[] getResponseBody() {
 
-	/**
-	 * @return the queryString
-	 */
-	public String getQueryString() {
-		return queryString;
-	}
+//      checkStarted();
+        byte[] content = response.getStreamContent();
 
-	/**
-	 * Get HTTP response headers.
-	 * @return headers name-values map.
-	 */
-	public Map<String, String[]> getResponseHeaders() {
-//		checkStarted();
-		return response.getHeaders();
-	}
+        if (null == content) {
+            String writerContent = response.getWriterContent();
 
-	/**
-	 * Set charset for the request body.
-	 * @param charset
-	 * @throws UnsupportedEncodingException
-	 */
-	public void setRequestCharacterEncoding(String charset) throws UnsupportedEncodingException {
-//		checkNotStarted();
-		request.setCharacterEncoding(charset);		
-	}
+            if (null != writerContent) {
+                try {
+                    content = writerContent.getBytes(response.getCharacterEncoding());
+                } catch (UnsupportedEncodingException e) {
+                    content = writerContent.getBytes();
+                }
+            } else {
+                content = new byte[0];
+            }
+        }
 
-	/**
-	 * Set HTTP POST/PUT methods uploading content.
-	 * @param body
-	 */
-	public void setRequestBody(String body) {
-//		checkNotStarted();
-		request.setRequestBody(body);		
-	}
+        return content;
+    }
 
-	/**
-	 * Set HTTP request content type ( eg 'application/x-www-form-urlencoded' or 'text/xml' ).
-	 * @param contentType
-	 */
-	public void setRequestContentType(String contentType) {
-//		checkNotStarted();
-		request.setContentType(contentType);
-		
-	}
+    /**
+     * List of the {@link Cookie} used by the request or response ( There are same cookies for both request and
+     * response ).
+     *
+     * @return the cookies
+     */
+    public List<Cookie> getCookies() {
+        return cookies;
+    }
 
-	/**
-	 * Append additional HTTP request headers.
-	 * @param headers
-	 */
-	public void addRequestHeaders(Map<String, String> headers) {
-//		checkNotStarted();
-		request.addHeaders(headers);		
-	}
+    /**
+     * request object for the this connection.
+     * @return the request
+     */
+    public HttpServletRequest getRequest() {
+        return requestProxy;
+    }
 
-	private class ConnectionRequest extends StagingHttpRequest {
-	
-		public Cookie[] getCookies() {
-			return cookies.toArray(COOKIE);
-		}
-	
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see javax.servlet.http.HttpServletRequest#getMethod()
-		 */
-		public String getMethod() {
-			return method.toString();
-		}
-	
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see javax.servlet.http.HttpServletRequest#getServletPath()
-		 */
-		public String getServletPath() {
-			return servletPath;
-		}
-	
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see javax.servlet.http.HttpServletRequest#getPathInfo()
-		 */
-		public String getPathInfo() {
-			return pathInfo;
-		}
-	
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see javax.servlet.http.HttpServletRequest#getQueryString()
-		 */
-		public String getQueryString() {
-			return queryString;
-		}
-	
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see javax.servlet.http.HttpServletRequest#getRequestURI()
-		 */
-		public String getRequestURI() {
-			return url.getPath();
-		}
-		
-		/* (non-Javadoc)
-		 * @see org.richfaces.test.staging.StagingHttpRequest#getServerName()
-		 */
-		@Override
-		public String getServerName() {
-			return url.getHost();
-		}
-		
-	
-		@Override
-		public int getLocalPort() {
-			int port = url.getPort();
-			if(port < 0){
-				port = super.getLocalPort();
-			}
-			return port;
-		}
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see javax.servlet.ServletRequest#getParameter(java.lang.String)
-		 */
-		public String getParameter(String name) {
-			String[] values = requestParameters.get(name);
-			if (null != values && values.length > 0) {
-				return values[0];
-			}
-			return null;
-		}
-	
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see javax.servlet.ServletRequest#getParameterMap()
-		 */
-		@SuppressWarnings("unchecked")
-		public Map getParameterMap() {
-			return Collections.unmodifiableMap(requestParameters);
-		}
-	
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see javax.servlet.ServletRequest#getParameterNames()
-		 */
-		@SuppressWarnings("unchecked")
-		public Enumeration getParameterNames() {
-			return Collections.enumeration(requestParameters.keySet());
-		}
-	
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see
-		 * javax.servlet.ServletRequest#getParameterValues(java.lang.String)
-		 */
-		public String[] getParameterValues(String name) {
-			return requestParameters.get(name);
-		}
-	
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see javax.servlet.http.HttpServletRequest#getSession()
-		 */
-		public HttpSession getSession() {
-			return server.getSession();
-		}
-	
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see javax.servlet.http.HttpServletRequest#getSession(boolean)
-		 */
-		public HttpSession getSession(boolean create) {
-			return server.getSession(create);
-		}
-	
-		@Override
-		public RequestDispatcher getRequestDispatcher(String path) {
-			RequestDispatcher dispatcher = null;
-			if (!path.startsWith("/")) {
-				try {
-					URL absoluteUrl = new URL(url, path);
-					path = absoluteUrl.getFile();
-				} catch (MalformedURLException e) {
-					return null;
-				}
-			}
-			final RequestChain dispatchedServlet = server.getServlet(path);
-			if (null != dispatchedServlet) {
-				dispatcher = new RequestDispatcher() {
-	
-					public void forward(ServletRequest request,
-							ServletResponse response) throws ServletException,
-							IOException {
-						response.reset();
-						dispatchedServlet.execute(request, response);
-					}
-	
-					public void include(ServletRequest request,
-							ServletResponse response) throws ServletException,
-							IOException {
-						dispatchedServlet.execute(request, response);
-					}
-	
-				};
-			}
-			return dispatcher;
-		}
-	
-		@Override
-		protected void attributeAdded(String name, Object o) {
-			server.requestAttributeAdded(this, name, o);
-	
-		}
-	
-		@Override
-		protected void attributeRemoved(String name, Object removed) {
-			server.requestAttributeRemoved(this, name, removed);
-	
-		}
-	
-		@Override
-		protected void attributeReplaced(String name, Object o) {
-			server.requestAttributeReplaced(this, name, o);
-	
-		}
-	
-	}
+    /**
+     * response object for the this connection.
+     * @return the response
+     */
+    public HttpServletResponse getResponse() {
+        return responseProxy;
+    }
 
-	private class ConnectionResponse extends StagingHttpResponse {
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see
-		 * javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http
-		 * .Cookie )
-		 */
-		public void addCookie(Cookie cookie) {
-			cookies.add(cookie);
-	
-		}
-	
-	}
+    /**
+     * @return encoding used to write response.
+     */
+    public String getResponseCharacterEncoding() {
 
-	public int getResponseContentLength() {
-		return response.getContentLength();		
-	}
+//      checkStarted();
+        return response.getCharacterEncoding();
+    }
 
+    /**
+     * @return content type ( eg 'text/html' ) of the response.
+     */
+    public String getResponseContentType() {
+
+//      checkStarted();
+        return response.getContentType();
+    }
+
+    /**
+     * @return HTTP status code of the response.
+     */
+    public int getResponseStatus() {
+
+//      checkStarted();
+        return response.getStatus();
+    }
+
+    /**
+     * @return HTTP error message.
+     */
+    public String getErrorMessage() {
+
+//      checkStarted();
+        return response.getErrorMessage();
+    }
+
+    /**
+     * Set request Query string. This method does not parse query string, {@link #parseFormParameters(String)} should
+     * be used.
+     *
+     * @param queryString
+     *            the queryString to set
+     */
+    public void setQueryString(String queryString) {
+
+//      checkNotStarted();
+        this.queryString = queryString;
+    }
+
+    /**
+     * @return the queryString
+     */
+    public String getQueryString() {
+        return queryString;
+    }
+
+    /**
+     * Get HTTP response headers.
+     * @return headers name-values map.
+     */
+    public Map<String, String[]> getResponseHeaders() {
+
+//      checkStarted();
+        return response.getHeaders();
+    }
+
+    /**
+     * Set charset for the request body.
+     * @param charset
+     * @throws UnsupportedEncodingException
+     */
+    public void setRequestCharacterEncoding(String charset) throws UnsupportedEncodingException {
+
+//      checkNotStarted();
+        request.setCharacterEncoding(charset);
+    }
+
+    /**
+     * Set HTTP POST/PUT methods uploading content.
+     * @param body
+     */
+    public void setRequestBody(String body) {
+
+//      checkNotStarted();
+        request.setRequestBody(body);
+    }
+
+    /**
+     * Set HTTP request content type ( eg 'application/x-www-form-urlencoded' or 'text/xml' ).
+     * @param contentType
+     */
+    public void setRequestContentType(String contentType) {
+
+//      checkNotStarted();
+        request.setContentType(contentType);
+    }
+
+    /**
+     * Append additional HTTP request headers.
+     * @param headers
+     */
+    public void addRequestHeaders(Map<String, String> headers) {
+
+//      checkNotStarted();
+        request.addHeaders(headers);
+    }
+
+    public int getResponseContentLength() {
+        return response.getContentLength();
+    }
+
+    private class ConnectionRequest extends StagingHttpRequest {
+        public Cookie[] getCookies() {
+            return cookies.toArray(COOKIE);
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see javax.servlet.http.HttpServletRequest#getMethod()
+         */
+        public String getMethod() {
+            return method.toString();
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see javax.servlet.http.HttpServletRequest#getServletPath()
+         */
+        public String getServletPath() {
+            return servletPath;
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see javax.servlet.http.HttpServletRequest#getPathInfo()
+         */
+        public String getPathInfo() {
+            return pathInfo;
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see javax.servlet.http.HttpServletRequest#getQueryString()
+         */
+        public String getQueryString() {
+            return queryString;
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see javax.servlet.http.HttpServletRequest#getRequestURI()
+         */
+        public String getRequestURI() {
+            return url.getPath();
+        }
+
+        /*
+         *  (non-Javadoc)
+         * @see org.richfaces.test.staging.StagingHttpRequest#getServerName()
+         */
+        @Override
+        public String getServerName() {
+            return url.getHost();
+        }
+
+        @Override
+        public int getLocalPort() {
+            int port = url.getPort();
+
+            if (port < 0) {
+                port = super.getLocalPort();
+            }
+
+            return port;
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see javax.servlet.ServletRequest#getParameter(java.lang.String)
+         */
+        public String getParameter(String name) {
+            String[] values = requestParameters.get(name);
+
+            if (null != values && values.length > 0) {
+                return values[0];
+            }
+
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see javax.servlet.ServletRequest#getParameterMap()
+         */
+        @SuppressWarnings("unchecked")
+        public Map getParameterMap() {
+            return Collections.unmodifiableMap(requestParameters);
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see javax.servlet.ServletRequest#getParameterNames()
+         */
+        @SuppressWarnings("unchecked")
+        public Enumeration getParameterNames() {
+            return Collections.enumeration(requestParameters.keySet());
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see
+         * javax.servlet.ServletRequest#getParameterValues(java.lang.String)
+         */
+        public String[] getParameterValues(String name) {
+            return requestParameters.get(name);
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see javax.servlet.http.HttpServletRequest#getSession()
+         */
+        public HttpSession getSession() {
+            return server.getSession();
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see javax.servlet.http.HttpServletRequest#getSession(boolean)
+         */
+        public HttpSession getSession(boolean create) {
+            return server.getSession(create);
+        }
+
+        @Override
+        public RequestDispatcher getRequestDispatcher(String path) {
+            RequestDispatcher dispatcher = null;
+
+            if (!path.startsWith("/")) {
+                try {
+                    URL absoluteUrl = new URL(url, path);
+
+                    path = absoluteUrl.getFile();
+                } catch (MalformedURLException e) {
+                    return null;
+                }
+            }
+
+            final RequestChain dispatchedServlet = server.getServlet(path);
+
+            if (null != dispatchedServlet) {
+                dispatcher = new RequestDispatcher() {
+                    public void forward(ServletRequest request, ServletResponse response)
+                        throws ServletException, IOException {
+
+                        response.reset();
+                        dispatchedServlet.execute(request, response);
+                    }
+                    public void include(ServletRequest request, ServletResponse response)
+                        throws ServletException, IOException {
+                        
+                        dispatchedServlet.execute(request, response);
+                    }
+                };
+            }
+
+            return dispatcher;
+        }
+
+        @Override
+        protected void attributeAdded(String name, Object o) {
+            server.requestAttributeAdded(this, name, o);
+        }
+
+        @Override
+        protected void attributeRemoved(String name, Object removed) {
+            server.requestAttributeRemoved(this, name, removed);
+        }
+
+        @Override
+        protected void attributeReplaced(String name, Object o) {
+            server.requestAttributeReplaced(this, name, o);
+        }
+    }
+
+
+    private class ConnectionResponse extends StagingHttpResponse {
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see
+         * javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http
+         * .Cookie )
+         */
+        public void addCookie(Cookie cookie) {
+            cookies.add(cookie);
+        }
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingHttpRequest.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingHttpRequest.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingHttpRequest.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
@@ -8,10 +9,14 @@
 import java.io.IOException;
 import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
+
 import java.nio.charset.Charset;
+
 import java.security.Principal;
+
 import java.text.DateFormat;
 import java.text.ParseException;
+
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -26,525 +31,538 @@
 import javax.servlet.ServletInputStream;
 import javax.servlet.http.HttpServletRequest;
 
-
 /**
  * @author asmirnov
- * 
+ *
  */
 abstract class StagingHttpRequest implements HttpServletRequest {
+    public static final String HTTP = "http";
+    public static final String LOCALHOST = "localhost";
+    public static final String LOCALHOST_IP = "127.0.0.1";
+    public static final String UTF8 = "UTF-8";
+    private static final Logger LOG = ServerLogger.CONNECTION.getLogger();
+    private String requestBody = null;
+    private Collection<Locale> locales = Arrays.asList(Locale.US, Locale.GERMANY);
+    private Map<String, String> headers = new HashMap<String, String>();
+    private String characterEncoding = UTF8;
+    private Map<String, Object> attributes = new HashMap<String, Object>();
+    private String contentType;
 
-	private static final Logger log = ServerLogger.CONNECTION.getLogger();
+    /**
+     * @return the requestBody
+     */
+    String getRequestBody() {
+        return requestBody;
+    }
 
-	public static final String LOCALHOST = "localhost";
-	public static final String HTTP = "http";
-	public static final String LOCALHOST_IP = "127.0.0.1";
-	public static final String UTF8 = "UTF-8";
+    /**
+     * @param requestBody
+     *            the requestBody to set
+     */
+    void setRequestBody(String requestBody) {
+        this.requestBody = requestBody;
+    }
 
-	private String requestBody = null;
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#getAuthType()
+     */
+    public String getAuthType() {
 
-	private String contentType;
+        // TODO configure test auth.
+        LOG.info("unimplemented request method getAuthType");
 
-	private Map<String, Object> attributes = new HashMap<String, Object>();
+        return null;
+    }
 
-	private Map<String, String> headers = new HashMap<String, String>();
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#getContextPath()
+     */
+    public String getContextPath() {
+        return StagingServletContext.CONTEXT_PATH;
+    }
 
-	private Collection<Locale> locales = Arrays.asList(Locale.US,
-			Locale.GERMANY);
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * javax.servlet.http.HttpServletRequest#getDateHeader(java.lang.String)
+     */
+    public long getDateHeader(String name) {
+        String value = headers.get(name);
 
-	private String characterEncoding = UTF8;
+        if (null != value) {
+            try {
+                return DateFormat.getDateInstance(DateFormat.FULL, getLocale()).parse(value).getTime();
+            } catch (ParseException e) {
+                throw new IllegalArgumentException(e.getMessage());
+            }
+        }
 
-	/**
-	 * @return the requestBody
-	 */
-	String getRequestBody() {
-		return requestBody;
-	}
+        return -1;
+    }
 
-	/**
-	 * @param requestBody
-	 *            the requestBody to set
-	 */
-	void setRequestBody(String requestBody) {
-		this.requestBody = requestBody;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#getHeader(java.lang.String)
+     */
+    public String getHeader(String name) {
+        return headers.get(name);
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#getAuthType()
-	 */
-	public String getAuthType() {
-		// TODO configure test auth.
-		log.info("unimplemented request method getAuthType");
-		return null;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#getHeaderNames()
+     */
+    @SuppressWarnings("unchecked")
+    public Enumeration getHeaderNames() {
+        return Collections.enumeration(headers.keySet());
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#getContextPath()
-	 */
-	public String getContextPath() {
-		return StagingServletContext.CONTEXT_PATH;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#getHeaders(java.lang.String)
+     */
+    @SuppressWarnings("unchecked")
+    public Enumeration getHeaders(String name) {
+        Set<String> values;
+        String value = headers.get(name);
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * javax.servlet.http.HttpServletRequest#getDateHeader(java.lang.String)
-	 */
-	public long getDateHeader(String name) {
-		String value = headers.get(name);
-		if(null != value){
-			try {
-				return DateFormat.getDateInstance(DateFormat.FULL, getLocale()).parse(value).getTime();
-			} catch (ParseException e) {
-				throw new IllegalArgumentException(e.getMessage());
-			}
-		}
-		return -1;
-	}
+        if (null != value) {
+            values = Collections.singleton(value);
+        } else {
+            values = Collections.emptySet();
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#getHeader(java.lang.String)
-	 */
-	public String getHeader(String name) {
-		return headers.get(name);
-	}
+        return Collections.enumeration(values);
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#getHeaderNames()
-	 */
-	@SuppressWarnings("unchecked")
-	public Enumeration getHeaderNames() {
-		return Collections.enumeration(headers.keySet());
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#getIntHeader(java.lang.String)
+     */
+    public int getIntHeader(String name) {
+        String value = headers.get(name);
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#getHeaders(java.lang.String)
-	 */
-	@SuppressWarnings("unchecked")
-	public Enumeration getHeaders(String name) {
-		Set<String> values;
-		String value = headers.get(name);
-		if (null != value) {
-			values = Collections.singleton(value);
+        if (null != value) {
+            return Integer.parseInt(value);
+        }
 
-		} else {
-			values = Collections.emptySet();
-		}
-		return Collections.enumeration(values);
-	}
+        return -1;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#getIntHeader(java.lang.String)
-	 */
-	public int getIntHeader(String name) {
-		String value = headers.get(name);
-		if(null != value){
-			return Integer.parseInt(value);
-		}
-		return -1;
-	}
+    void addHeader(String name, String value) {
+        headers.put(name, value);
+    }
 
-	void addHeader(String name, String value) {
-		headers.put(name, value);
-	}
+    void addHeaders(Map<String, String> headers) {
+        this.headers.putAll(headers);
+    }
 
-	void addHeaders(Map<String, String> headers) {
-		this.headers.putAll(headers);
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#getPathTranslated()
+     */
+    public String getPathTranslated() {
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#getPathTranslated()
-	 */
-	public String getPathTranslated() {
-		// we have only 'virtual' server.
-		return null;
-	}
+        // we have only 'virtual' server.
+        return null;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#getRemoteUser()
-	 */
-	public String getRemoteUser() {
-		// TODO configure test auth.
-		log.info("unimplemented request method getRemoteUser");
-		return null;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#getRemoteUser()
+     */
+    public String getRemoteUser() {
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#getRequestURL()
-	 */
-	public StringBuffer getRequestURL() {
-		StringBuffer requestURL = new StringBuffer(HTTP + "://" + LOCALHOST
-				+ getRequestURI());
-		return requestURL;
-	}
+        // TODO configure test auth.
+        LOG.info("unimplemented request method getRemoteUser");
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#getRequestedSessionId()
-	 */
-	public String getRequestedSessionId() {
-		return StagingHttpSession.SESSION_ID;
-	}
+        return null;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
-	 */
-	public Principal getUserPrincipal() {
-		// TODO implement test auth.
-		log.info("unimplemented request method getUserPrincipal");
-		return null;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#getRequestURL()
+     */
+    public StringBuffer getRequestURL() {
+        StringBuffer requestURL = new StringBuffer(HTTP + "://" + LOCALHOST + getRequestURI());
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromCookie()
-	 */
-	public boolean isRequestedSessionIdFromCookie() {
-		// test do not supports cookie
-		return false;
-	}
+        return requestURL;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromURL()
-	 */
-	public boolean isRequestedSessionIdFromURL() {
-		return true;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#getRequestedSessionId()
+     */
+    public String getRequestedSessionId() {
+        return StagingHttpSession.SESSION_ID;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromUrl()
-	 */
-	public boolean isRequestedSessionIdFromUrl() {
-		return true;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
+     */
+    public Principal getUserPrincipal() {
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdValid()
-	 */
-	public boolean isRequestedSessionIdValid() {
-		// TODO - check session.
-		return false;
-	}
+        // TODO implement test auth.
+        LOG.info("unimplemented request method getUserPrincipal");
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletRequest#isUserInRole(java.lang.String)
-	 */
-	public boolean isUserInRole(String role) {
-		// TODO implement test auth.
-		log.info("unimplemented request method isUserInRole");
-		return false;
-	}
+        return null;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getAttribute(java.lang.String)
-	 */
-	public Object getAttribute(String name) {
-		return attributes.get(name);
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromCookie()
+     */
+    public boolean isRequestedSessionIdFromCookie() {
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getAttributeNames()
-	 */
-	@SuppressWarnings("unchecked")
-	public Enumeration getAttributeNames() {
-		return Collections.enumeration(attributes.keySet());
-	}
+        // test do not supports cookie
+        return false;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getCharacterEncoding()
-	 */
-	public String getCharacterEncoding() {
-		return characterEncoding;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromURL()
+     */
+    public boolean isRequestedSessionIdFromURL() {
+        return true;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getContentLength()
-	 */
-	public int getContentLength() {
-		String body = getRequestBody();
-		return null == body ? -1 : body.length();
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromUrl()
+     */
+    public boolean isRequestedSessionIdFromUrl() {
+        return true;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getContentType()
-	 */
-	public String getContentType() {
-		return contentType;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdValid()
+     */
+    public boolean isRequestedSessionIdValid() {
 
-	/**
-	 * @param contentType
-	 *            the contentType to set
-	 */
-	public void setContentType(String contentType) {
-		this.contentType = contentType;
-	}
+        // TODO - check session.
+        return false;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getInputStream()
-	 */
-	public ServletInputStream getInputStream() throws IOException {
-		String body = getRequestBody();
-		if(null != body){
-			final ByteArrayInputStream input = new ByteArrayInputStream(body.getBytes(getCharacterEncoding()));
-			return new ServletInputStream(){
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletRequest#isUserInRole(java.lang.String)
+     */
+    public boolean isUserInRole(String role) {
 
-				@Override
-				public int read() throws IOException {
-					// TODO Auto-generated method stub
-					return input.read();
-				}
-				
-			};
-		}
-		return null;
-	}
+        // TODO implement test auth.
+        LOG.info("unimplemented request method isUserInRole");
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getLocalAddr()
-	 */
-	public String getLocalAddr() {
-		return LOCALHOST_IP;
-	}
+        return false;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getLocalName()
-	 */
-	public String getLocalName() {
-		return LOCALHOST;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name) {
+        return attributes.get(name);
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getLocalPort()
-	 */
-	public int getLocalPort() {
-		return 80;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getAttributeNames()
+     */
+    @SuppressWarnings("unchecked")
+    public Enumeration getAttributeNames() {
+        return Collections.enumeration(attributes.keySet());
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getLocale()
-	 */
-	public Locale getLocale() {
-		return Locale.US;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getCharacterEncoding()
+     */
+    public String getCharacterEncoding() {
+        return characterEncoding;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getLocales()
-	 */
-	@SuppressWarnings("unchecked")
-	public Enumeration getLocales() {
-		return Collections.enumeration(locales);
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getContentLength()
+     */
+    public int getContentLength() {
+        String body = getRequestBody();
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getProtocol()
-	 */
-	public String getProtocol() {
-		return "HTTP/1.1";
-	}
+        return null == body ? -1 : body.length();
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getReader()
-	 */
-	public BufferedReader getReader() throws IOException {
-		String body = getRequestBody();
-		if(null != body){
-			return new BufferedReader(new StringReader(body));
-		}
-		return null;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getContentType()
+     */
+    public String getContentType() {
+        return contentType;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getRealPath(java.lang.String)
-	 */
-	public String getRealPath(String path) {
-		return null;
-	}
+    /**
+     * @param contentType
+     *            the contentType to set
+     */
+    public void setContentType(String contentType) {
+        this.contentType = contentType;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getRemoteAddr()
-	 */
-	public String getRemoteAddr() {
-		return LOCALHOST_IP;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getInputStream()
+     */
+    public ServletInputStream getInputStream() throws IOException {
+        String body = getRequestBody();
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getRemoteHost()
-	 */
-	public String getRemoteHost() {
-		return LOCALHOST;
-	}
+        if (null != body) {
+            final ByteArrayInputStream input = new ByteArrayInputStream(body.getBytes(getCharacterEncoding()));
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getRemotePort()
-	 */
-	public int getRemotePort() {
-		return 1223340;
-	}
+            return new ServletInputStream() {
+                @Override
+                public int read() throws IOException {
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getRequestDispatcher(java.lang.String)
-	 */
-	public RequestDispatcher getRequestDispatcher(String path) {
-		// TODO Auto-generated method stub
-		throw new NotImplementedException();
-		// return null;
-	}
+                    // TODO Auto-generated method stub
+                    return input.read();
+                }
+            };
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getScheme()
-	 */
-	public String getScheme() {
-		return HTTP;
-	}
+        return null;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getServerName()
-	 */
-	public String getServerName() {
-		return LOCALHOST;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getLocalAddr()
+     */
+    public String getLocalAddr() {
+        return LOCALHOST_IP;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#getServerPort()
-	 */
-	public int getServerPort() {
-		return 80;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getLocalName()
+     */
+    public String getLocalName() {
+        return LOCALHOST;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#isSecure()
-	 */
-	public boolean isSecure() {
-		return false;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getLocalPort()
+     */
+    public int getLocalPort() {
+        return 80;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#removeAttribute(java.lang.String)
-	 */
-	public void removeAttribute(String name) {
-		// TODO - inform listeners
-		Object removed = attributes.remove(name);
-		if (null != removed) {
-			attributeRemoved(name, removed);
-		}
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getLocale()
+     */
+    public Locale getLocale() {
+        return Locale.US;
+    }
 
-	protected abstract void attributeRemoved(String name, Object removed);
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getLocales()
+     */
+    @SuppressWarnings("unchecked")
+    public Enumeration getLocales() {
+        return Collections.enumeration(locales);
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#setAttribute(java.lang.String,
-	 * java.lang.Object)
-	 */
-	public void setAttribute(String name, Object o) {
-		if (null == o) {
-			removeAttribute(name);
-		} else {
-			Object oldValue = attributes.put(name, o);
-			if (null != oldValue) {
-				attributeReplaced(name, o);
-			} else {
-				attributeAdded(name, o);
-			}
-		}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getProtocol()
+     */
+    public String getProtocol() {
+        return "HTTP/1.1";
+    }
 
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getReader()
+     */
+    public BufferedReader getReader() throws IOException {
+        String body = getRequestBody();
 
-	protected abstract void attributeAdded(String name, Object o);
+        if (null != body) {
+            return new BufferedReader(new StringReader(body));
+        }
 
-	protected abstract void attributeReplaced(String name, Object o);
+        return null;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletRequest#setCharacterEncoding(java.lang.String)
-	 */
-	public void setCharacterEncoding(String env)
-			throws UnsupportedEncodingException {
-		if (!Charset.isSupported(env)) {
-			throw new UnsupportedEncodingException("Unknown charset "+env);
-		}
-		this.characterEncoding = env;
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getRealPath(java.lang.String)
+     */
+    public String getRealPath(String path) {
+        return null;
+    }
 
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getRemoteAddr()
+     */
+    public String getRemoteAddr() {
+        return LOCALHOST_IP;
+    }
 
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getRemoteHost()
+     */
+    public String getRemoteHost() {
+        return LOCALHOST;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getRemotePort()
+     */
+    public int getRemotePort() {
+        return 1223340;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getRequestDispatcher(java.lang.String)
+     */
+    public RequestDispatcher getRequestDispatcher(String path) {
+
+        // TODO Auto-generated method stub
+        throw new NotImplementedException();
+
+        // return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getScheme()
+     */
+    public String getScheme() {
+        return HTTP;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getServerName()
+     */
+    public String getServerName() {
+        return LOCALHOST;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#getServerPort()
+     */
+    public int getServerPort() {
+        return 80;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#isSecure()
+     */
+    public boolean isSecure() {
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#removeAttribute(java.lang.String)
+     */
+    public void removeAttribute(String name) {
+
+        // TODO - inform listeners
+        Object removed = attributes.remove(name);
+
+        if (null != removed) {
+            attributeRemoved(name, removed);
+        }
+    }
+
+    protected abstract void attributeRemoved(String name, Object removed);
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#setAttribute(java.lang.String,
+     * java.lang.Object)
+     */
+    public void setAttribute(String name, Object o) {
+        if (null == o) {
+            removeAttribute(name);
+        } else {
+            Object oldValue = attributes.put(name, o);
+
+            if (null != oldValue) {
+                attributeReplaced(name, o);
+            } else {
+                attributeAdded(name, o);
+            }
+        }
+    }
+
+    protected abstract void attributeAdded(String name, Object o);
+
+    protected abstract void attributeReplaced(String name, Object o);
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletRequest#setCharacterEncoding(java.lang.String)
+     */
+    public void setCharacterEncoding(String env) throws UnsupportedEncodingException {
+        if (!Charset.isSupported(env)) {
+            throw new UnsupportedEncodingException("Unknown charset " + env);
+        }
+
+        this.characterEncoding = env;
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingHttpResponse.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingHttpResponse.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingHttpResponse.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
@@ -7,6 +8,7 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Locale;
@@ -18,449 +20,443 @@
 
 /**
  * @author asmirnov
- * 
+ *
  */
 abstract class StagingHttpResponse implements HttpServletResponse {
+    private static final Logger LOG = ServerLogger.CONNECTION.getLogger();
+    private int bufferSize = 8196;
+    private String contentType = "text";
+    private String errorMessage = null;
+    private String redirectLocation = null;
+    private int status = 200;
+    private Locale locale = Locale.US;
+    private final Map<String, String[]> headers = new HashMap<String, String[]>();
+    private String encoding = StagingHttpRequest.UTF8;
+    private int contentLength = Integer.MIN_VALUE;
+    private ByteArrayOutputStream outputStream;
+    private StringWriter outputWriter;
+    private PrintWriter printWriter;
+    private ServletOutputStream servletOutputStream;
 
+    /**
+     * @return the headers
+     */
+    Map<String, String[]> getHeaders() {
+        return headers;
+    }
 
-	private static final Logger log = ServerLogger.CONNECTION.getLogger();
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * javax.servlet.http.HttpServletResponse#addDateHeader(java.lang.String,
+     * long)
+     */
+    public void addDateHeader(String name, long date) {
 
-	
-	private int status = 200;
+        // TODO - locale support ?
+        addHeader(name, new Date(date).toString());
+    }
 
-	private String redirectLocation = null;
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletResponse#addHeader(java.lang.String,
+     * java.lang.String)
+     */
+    public void addHeader(String name, String value) {
+        String[] values = headers.get(name);
 
-	private String errorMessage = null;
+        if (null == values) {
+            values = new String[1];
+        } else {
+            String[] newValues = new String[values.length + 1];
 
-	private int bufferSize = 8196;
+            System.arraycopy(values, 0, newValues, 0, values.length);
+            values = newValues;
+        }
 
-	private StringWriter outputWriter;
+        values[values.length - 1] = value;
+        headers.put(name, values);
+    }
 
-	private ByteArrayOutputStream outputStream;
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * javax.servlet.http.HttpServletResponse#addIntHeader(java.lang.String,
+     * int)
+     */
+    public void addIntHeader(String name, int value) {
+        addHeader(name, String.valueOf(value));
+    }
 
-	private PrintWriter printWriter;
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * javax.servlet.http.HttpServletResponse#containsHeader(java.lang.String)
+     */
+    public boolean containsHeader(String name) {
+        return headers.containsKey(name);
+    }
 
-	private ServletOutputStream servletOutputStream;
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * javax.servlet.http.HttpServletResponse#encodeRedirectURL(java.lang.String
+     * )
+     */
+    public String encodeRedirectURL(String url) {
+        return url;
+    }
 
-	private Locale locale = Locale.US;
-	
-	private String contentType="text";
-	
-	private int contentLength = Integer.MIN_VALUE;
-	
-	private String encoding = StagingHttpRequest.UTF8;
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * javax.servlet.http.HttpServletResponse#encodeRedirectUrl(java.lang.String
+     * )
+     */
+    public String encodeRedirectUrl(String url) {
+        return encodeRedirectURL(url);
+    }
 
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String)
+     */
+    public String encodeURL(String url) {
+        return url;
+    }
 
-	private final Map<String, String[]> headers= new HashMap<String, String[]>();
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletResponse#encodeUrl(java.lang.String)
+     */
+    public String encodeUrl(String url) {
+        return encodeURL(url);
+    }
 
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletResponse#sendError(int)
+     */
+    public void sendError(int sc) throws IOException {
+        status = sc;
+    }
 
-	/**
-	 * @return the headers
-	 */
-	Map<String, String[]> getHeaders() {
-		return headers;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletResponse#sendError(int,
+     * java.lang.String)
+     */
+    public void sendError(int sc, String msg) throws IOException {
+        status = sc;
+        errorMessage = msg;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * javax.servlet.http.HttpServletResponse#addDateHeader(java.lang.String,
-	 * long)
-	 */
-	public void addDateHeader(String name, long date) {
-		// TODO - locale support ?
-		addHeader(name, new Date(date).toString());
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * javax.servlet.http.HttpServletResponse#sendRedirect(java.lang.String)
+     */
+    public void sendRedirect(String location) throws IOException {
+        redirectLocation = location;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletResponse#addHeader(java.lang.String,
-	 * java.lang.String)
-	 */
-	public void addHeader(String name, String value) {
-		String[] values = headers.get(name);
-		if (null == values) {
-			values = new String[1];
-		} else {
-			String[] newValues = new String[values.length + 1];
-			System.arraycopy(values, 0, newValues, 0, values.length);
-			values = newValues;
-		}
-		values[values.length - 1] = value;
-		headers.put(name, values);
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * javax.servlet.http.HttpServletResponse#setDateHeader(java.lang.String,
+     * long)
+     */
+    public void setDateHeader(String name, long date) {
 
-	}
+        // TODO - locale support ?
+        setHeader(name, new Date(date).toString());
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * javax.servlet.http.HttpServletResponse#addIntHeader(java.lang.String,
-	 * int)
-	 */
-	public void addIntHeader(String name, int value) {
-		addHeader(name, String.valueOf(value));
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletResponse#setHeader(java.lang.String,
+     * java.lang.String)
+     */
+    public void setHeader(String name, String value) {
+        headers.put(name, new String[] {value});
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * javax.servlet.http.HttpServletResponse#containsHeader(java.lang.String)
-	 */
-	public boolean containsHeader(String name) {
-		return headers.containsKey(name);
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * javax.servlet.http.HttpServletResponse#setIntHeader(java.lang.String,
+     * int)
+     */
+    public void setIntHeader(String name, int value) {
+        setHeader(name, String.valueOf(value));
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * javax.servlet.http.HttpServletResponse#encodeRedirectURL(java.lang.String
-	 * )
-	 */
-	public String encodeRedirectURL(String url) {
-		return url;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletResponse#setStatus(int)
+     */
+    public void setStatus(int sc) {
+        status = sc;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * javax.servlet.http.HttpServletResponse#encodeRedirectUrl(java.lang.String
-	 * )
-	 */
-	public String encodeRedirectUrl(String url) {
-		return encodeRedirectURL(url);
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpServletResponse#setStatus(int,
+     * java.lang.String)
+     */
+    public void setStatus(int sc, String sm) {
+        status = sc;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String)
-	 */
-	public String encodeURL(String url) {
-		return url;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#flushBuffer()
+     */
+    public void flushBuffer() throws IOException {
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletResponse#encodeUrl(java.lang.String)
-	 */
-	public String encodeUrl(String url) {
-		return encodeURL(url);
-	}
+        // do nothing
+        LOG.info("unimplemented response method flushBuffer");
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletResponse#sendError(int)
-	 */
-	public void sendError(int sc) throws IOException {
-		status = sc;
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#getBufferSize()
+     */
+    public int getBufferSize() {
+        return bufferSize;
+    }
 
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#getCharacterEncoding()
+     */
+    public String getCharacterEncoding() {
+        return encoding;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletResponse#sendError(int,
-	 * java.lang.String)
-	 */
-	public void sendError(int sc, String msg) throws IOException {
-		status = sc;
-		errorMessage = msg;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#getContentType()
+     */
+    public String getContentType() {
+        return contentType;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * javax.servlet.http.HttpServletResponse#sendRedirect(java.lang.String)
-	 */
-	public void sendRedirect(String location) throws IOException {
-		redirectLocation = location;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#getLocale()
+     */
+    public Locale getLocale() {
+        return locale;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * javax.servlet.http.HttpServletResponse#setDateHeader(java.lang.String,
-	 * long)
-	 */
-	public void setDateHeader(String name, long date) {
-		// TODO - locale support ?
-		setHeader(name, new Date(date).toString());
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#getOutputStream()
+     */
+    public ServletOutputStream getOutputStream() throws IOException {
+        if (null != this.outputWriter) {
+            throw new IllegalStateException();
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletResponse#setHeader(java.lang.String,
-	 * java.lang.String)
-	 */
-	public void setHeader(String name, String value) {
-		headers.put(name, new String[]{value});
-	}
+        if (this.outputStream == null) {
+            this.outputStream = new ByteArrayOutputStream(getBufferSize());
+            servletOutputStream = new ServletOutputStream() {
+                @Override
+                public void write(int b) throws IOException {
+                    StagingHttpResponse.this.outputStream.write(b);
+                }
+            };
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * javax.servlet.http.HttpServletResponse#setIntHeader(java.lang.String,
-	 * int)
-	 */
-	public void setIntHeader(String name, int value) {
-		setHeader(name, String.valueOf(value));
-	}
+        return servletOutputStream;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletResponse#setStatus(int)
-	 */
-	public void setStatus(int sc) {
-		status = sc;
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#getWriter()
+     */
+    public PrintWriter getWriter() throws IOException {
+        if (null != this.outputStream) {
+            throw new IllegalStateException();
+        }
 
-	}
+        if (this.outputWriter == null) {
+            this.outputWriter = new StringWriter(getBufferSize());
+            printWriter = new PrintWriter(outputWriter);
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServletResponse#setStatus(int,
-	 * java.lang.String)
-	 */
-	public void setStatus(int sc, String sm) {
-		status = sc;
-	}
+        return printWriter;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#flushBuffer()
-	 */
-	public void flushBuffer() throws IOException {
-		// do nothing
-		log.info("unimplemented response method flushBuffer");
-	}
+    public String getWriterContent() {
+        if (null != this.outputWriter) {
+            return this.outputWriter.toString();
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#getBufferSize()
-	 */
-	public int getBufferSize() {
-		return bufferSize;
-	}
+        return null;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#getCharacterEncoding()
-	 */
-	public String getCharacterEncoding() {
-		return encoding;
-	}
+    public byte[] getStreamContent() {
+        if (null != outputStream) {
+            return outputStream.toByteArray();
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#getContentType()
-	 */
-	public String getContentType() {
-		return contentType;
-	}
+        return null;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#getLocale()
-	 */
-	public Locale getLocale() {
-		return locale;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#isCommitted()
+     */
+    public boolean isCommitted() {
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#getOutputStream()
-	 */
-	public ServletOutputStream getOutputStream() throws IOException {
-		if (null != this.outputWriter) {
-			throw new IllegalStateException();
-		}
-		if (this.outputStream == null) {
-			this.outputStream = new ByteArrayOutputStream(getBufferSize());
-			servletOutputStream = new ServletOutputStream(){
+        // TODO Auto-generated method stub
+        LOG.info("unimplemented response method isCommited");
 
-				@Override
-				public void write(int b) throws IOException {
-					StagingHttpResponse.this.outputStream.write(b);				
-				}
-				
-			};			
-		}
-		return servletOutputStream;
-	}
+        return false;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#getWriter()
-	 */
-	public PrintWriter getWriter() throws IOException {
-		if (null != this.outputStream) {
-			throw new IllegalStateException();
-		}
-		if (this.outputWriter == null) {
-			this.outputWriter = new StringWriter(getBufferSize());
-			printWriter = new PrintWriter(outputWriter);
-		}
-		return printWriter;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#reset()
+     */
+    public void reset() {
+        if (isCommitted()) {
+            throw new IllegalStateException();
+        }
 
-	
-	public String getWriterContent() {
-		if(null != this.outputWriter){
-			return this.outputWriter.toString();
-		}
-		return null;
-	}
-	
-	public byte[] getStreamContent() {
-		if(null!=outputStream){
-			return outputStream.toByteArray();
-		}
-		return null;
-	}
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#isCommitted()
-	 */
-	public boolean isCommitted() {
-		// TODO Auto-generated method stub
-		log.info("unimplemented response method isCommited");
-		return false;
-	}
+        resetBuffer();
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#reset()
-	 */
-	public void reset() {
-		if(isCommitted()){
-			throw new IllegalStateException();
-		}
-		resetBuffer();
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#resetBuffer()
+     */
+    public void resetBuffer() {
+        if (isCommitted()) {
+            throw new IllegalStateException();
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#resetBuffer()
-	 */
-	public void resetBuffer() {
-		if(isCommitted()){
-			throw new IllegalStateException();
-		}
-		this.servletOutputStream = null;
-		this.outputStream = null;
-		this.printWriter = null;
-		this.outputWriter = null;
-	}
+        this.servletOutputStream = null;
+        this.outputStream = null;
+        this.printWriter = null;
+        this.outputWriter = null;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#setBufferSize(int)
-	 */
-	public void setBufferSize(int size) {
-		this.bufferSize = size;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#setBufferSize(int)
+     */
+    public void setBufferSize(int size) {
+        this.bufferSize = size;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#setCharacterEncoding(java.lang.String)
-	 */
-	public void setCharacterEncoding(String charset) {
-		encoding = charset;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#setCharacterEncoding(java.lang.String)
+     */
+    public void setCharacterEncoding(String charset) {
+        encoding = charset;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#setContentLength(int)
-	 */
-	public void setContentLength(int len) {
-		this.contentLength = len;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#setContentLength(int)
+     */
+    public void setContentLength(int len) {
+        this.contentLength = len;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#setContentType(java.lang.String)
-	 */
-	public void setContentType(String type) {
-		if(null == type){
-			throw new NullPointerException();
-		}
-		int i = type.indexOf(';');
-		if(i>=0){
-			setHeader("Content-Type", type);
-			contentType = type.substring(0, i).trim();
-			i=type.lastIndexOf('=');
-			if(i>=0){
-				setCharacterEncoding(type.substring(i+1).trim());
-			}
-		} else {
-			setHeader("Content-Type", type+";charset="+getCharacterEncoding());
-			contentType = type;
-		}
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#setContentType(java.lang.String)
+     */
+    public void setContentType(String type) {
+        if (null == type) {
+            throw new NullPointerException();
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.ServletResponse#setLocale(java.util.Locale)
-	 */
-	public void setLocale(Locale loc) {
-		this.locale  = loc;
+        int i = type.indexOf(';');
 
-	}
+        if (i >= 0) {
+            setHeader("Content-Type", type);
+            contentType = type.substring(0, i).trim();
+            i = type.lastIndexOf('=');
 
-	/**
-	 * @return the status
-	 */
-	int getStatus() {
-		return status;
-	}
+            if (i >= 0) {
+                setCharacterEncoding(type.substring(i + 1).trim());
+            }
+        } else {
+            setHeader("Content-Type", type + ";charset=" + getCharacterEncoding());
+            contentType = type;
+        }
+    }
 
-	/**
-	 * @return the contentLength
-	 */
-	int getContentLength() {
-		return contentLength;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.ServletResponse#setLocale(java.util.Locale)
+     */
+    public void setLocale(Locale loc) {
+        this.locale = loc;
+    }
 
-	/**
-	 * @return the redirectLocation
-	 */
-	String getRedirectLocation() {
-		return redirectLocation;
-	}
+    /**
+     * @return the status
+     */
+    int getStatus() {
+        return status;
+    }
 
-	/**
-	 * @return the errorMessage
-	 */
-	String getErrorMessage() {
-		return errorMessage;
-	}
+    /**
+     * @return the contentLength
+     */
+    int getContentLength() {
+        return contentLength;
+    }
 
+    /**
+     * @return the redirectLocation
+     */
+    String getRedirectLocation() {
+        return redirectLocation;
+    }
+
+    /**
+     * @return the errorMessage
+     */
+    String getErrorMessage() {
+        return errorMessage;
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingHttpSession.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingHttpSession.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingHttpSession.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
@@ -16,263 +17,270 @@
 
 /**
  * @author asmirnov
- * 
+ *
  */
 @SuppressWarnings("deprecation")
 abstract class StagingHttpSession implements HttpSession {
+    private static final int DEFAULT_INACTIVE_TIME = 30;
+    public static final String SESSION_ID = "1234567890";
+    private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
+    private volatile int inactiveTime = DEFAULT_INACTIVE_TIME;
+    private final long creationTime;
+    private boolean valid;
 
-	private static final int DEFAULT_INACTIVE_TIME = 30;
+    protected StagingHttpSession() {
+        this.creationTime = System.currentTimeMillis();
+        this.valid = true;
+    }
 
-	public static final String SESSION_ID = "1234567890";
+    /**
+     *
+     */
+    void destroy() {
 
-	private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
+        // Destroy all session attributes.
+        unboundAttributes();
+    }
 
-	private final long creationTime;
+    private void unboundAttributes() {
+        for (String name : getValueNames()) {
+            removeAttribute(name);
+        }
+    }
 
-	private volatile int inactiveTime = DEFAULT_INACTIVE_TIME;
-	
-	private boolean valid;
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name) {
+        checkValid();
 
-	public StagingHttpSession() {
-		this.creationTime = System.currentTimeMillis();
-		this.valid = true;
-	}
+        return attributes.get(name);
+    }
 
-	/**
-	 * 
-	 */
-	void destroy() {
-		// Destroy all session attributes.
-		unboundAttributes();
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#getAttributeNames()
+     */
+    @SuppressWarnings("unchecked")
+    public Enumeration getAttributeNames() {
+        checkValid();
 
-	private void unboundAttributes() {
-		for (String name : getValueNames()) {
-			removeAttribute(name);
-		}
-	}
+        return Collections.enumeration(attributes.keySet());
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#getAttribute(java.lang.String)
-	 */
-	public Object getAttribute(String name) {
-		checkValid();
-		return attributes.get(name);
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#getCreationTime()
+     */
+    public long getCreationTime() {
+        checkValid();
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#getAttributeNames()
-	 */
-	@SuppressWarnings("unchecked")
-	public Enumeration getAttributeNames() {
-		checkValid();
-		return Collections.enumeration(attributes.keySet());
-	}
+        return creationTime;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#getCreationTime()
-	 */
-	public long getCreationTime() {
-		checkValid();
-		return creationTime;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#getId()
+     */
+    public String getId() {
+        return SESSION_ID;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#getId()
-	 */
-	public String getId() {
-		return SESSION_ID;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#getLastAccessedTime()
+     */
+    public long getLastAccessedTime() {
+        checkValid();
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#getLastAccessedTime()
-	 */
-	public long getLastAccessedTime() {
-		checkValid();
-		// TODO fix accessing time
-		return 0;
-	}
+        // TODO fix accessing time
+        return 0;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#getMaxInactiveInterval()
-	 */
-	public int getMaxInactiveInterval() {
-		return inactiveTime;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#getMaxInactiveInterval()
+     */
+    public int getMaxInactiveInterval() {
+        return inactiveTime;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#getSessionContext()
-	 */
-	public HttpSessionContext getSessionContext() {
-		throw new NotImplementedException("Session context is not implemented");
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#getSessionContext()
+     */
+    public HttpSessionContext getSessionContext() {
+        throw new NotImplementedException("Session context is not implemented");
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#getValue(java.lang.String)
-	 */
-	public Object getValue(String name) {
-		return getAttribute(name);
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#getValue(java.lang.String)
+     */
+    public Object getValue(String name) {
+        return getAttribute(name);
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#getValueNames()
-	 */
-	public String[] getValueNames() {
-		checkValid();
-		ArrayList<String> names = new ArrayList<String>(attributes.keySet());
-		return names.toArray(new String[names.size()]);
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#getValueNames()
+     */
+    public String[] getValueNames() {
+        checkValid();
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#invalidate()
-	 */
-	public void invalidate() {
-		checkValid();
-		destroy();
-		this.valid=false;
+        ArrayList<String> names = new ArrayList<String>(attributes.keySet());
 
-	}
+        return names.toArray(new String[names.size()]);
+    }
 
-	protected void checkValid(){
-		if(!valid){
-			throw new IllegalStateException("Session have been invalidated");
-		}
-	}
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#isNew()
-	 */
-	public boolean isNew() {
-		checkValid();
-		return false;
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#invalidate()
+     */
+    public void invalidate() {
+        checkValid();
+        destroy();
+        this.valid = false;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#putValue(java.lang.String,
-	 * java.lang.Object)
-	 */
-	public void putValue(String name, Object value) {
-		setAttribute(name, value);
+    protected void checkValid() {
+        if (!valid) {
+            throw new IllegalStateException("Session have been invalidated");
+        }
+    }
 
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#isNew()
+     */
+    public boolean isNew() {
+        checkValid();
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#removeAttribute(java.lang.String)
-	 */
-	public void removeAttribute(String name) {
-		checkValid();
-		Object removed = this.attributes.remove(name);
-		if (null != removed) {
-			removedFromSession(name, removed);
-		}
+        return false;
+    }
 
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#putValue(java.lang.String,
+     * java.lang.Object)
+     */
+    public void putValue(String name, Object value) {
+        setAttribute(name, value);
+    }
 
-	protected void removedFromSession(String name, Object removed) {
-		HttpSessionBindingEvent sessionBindingEvent = new HttpSessionBindingEvent(
-				this, name, removed);
-		if (removed instanceof HttpSessionBindingListener) {
-			HttpSessionBindingListener listener = (HttpSessionBindingListener) removed;
-			listener.valueUnbound(sessionBindingEvent);
-		}
-		valueUnbound(sessionBindingEvent);
-	}
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#removeAttribute(java.lang.String)
+     */
+    public void removeAttribute(String name) {
+        checkValid();
 
-	protected abstract void valueUnbound(
-			HttpSessionBindingEvent sessionBindingEvent);
+        Object removed = this.attributes.remove(name);
 
-	protected void boundToSession(String name, Object value) {
-		HttpSessionBindingEvent sessionBindingEvent = new HttpSessionBindingEvent(
-				this, name, value);
-		if (value instanceof HttpSessionBindingListener) {
-			HttpSessionBindingListener listener = (HttpSessionBindingListener) value;
-			listener.valueBound(sessionBindingEvent);
-		}
-		valueBound(sessionBindingEvent);
-	}
+        if (null != removed) {
+            removedFromSession(name, removed);
+        }
+    }
 
-	protected abstract void valueBound(
-			HttpSessionBindingEvent sessionBindingEvent);
+    protected void removedFromSession(String name, Object removed) {
+        HttpSessionBindingEvent sessionBindingEvent = new HttpSessionBindingEvent(this, name, removed);
 
-	protected void replacedInSession(String name, Object oldValue, Object value) {
-		HttpSessionBindingEvent sessionBindingEvent = new HttpSessionBindingEvent(
-				this, name, value);
-		if (oldValue instanceof HttpSessionBindingListener) {
-			HttpSessionBindingListener listener = (HttpSessionBindingListener) oldValue;
-			listener.valueUnbound(sessionBindingEvent);
-		}
-		if (value instanceof HttpSessionBindingListener) {
-			HttpSessionBindingListener listener = (HttpSessionBindingListener) value;
-			listener.valueBound(sessionBindingEvent);
-		}
-		valueReplaced(sessionBindingEvent);
-	}
-	
-	protected abstract void valueReplaced(
-			HttpSessionBindingEvent sessionBindingEvent);
+        if (removed instanceof HttpSessionBindingListener) {
+            HttpSessionBindingListener listener = (HttpSessionBindingListener) removed;
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#removeValue(java.lang.String)
-	 */
-	public void removeValue(String name) {
-		removeAttribute(name);
-	}
+            listener.valueUnbound(sessionBindingEvent);
+        }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#setAttribute(java.lang.String,
-	 * java.lang.Object)
-	 */
-	public void setAttribute(String name, Object value) {
-		checkValid();
-		if (null == value) {
-			removeAttribute(name);
-		} else {
-			Object oldValue = attributes.put(name, value);
-			if (null != oldValue) {
-				replacedInSession(name, oldValue, value);
-			} else {
-				boundToSession(name, value);
-			}
-		}
-	}
+        valueUnbound(sessionBindingEvent);
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpSession#setMaxInactiveInterval(int)
-	 */
-	public void setMaxInactiveInterval(int interval) {
-		this.inactiveTime = interval;
+    protected abstract void valueUnbound(HttpSessionBindingEvent sessionBindingEvent);
 
-	}
+    protected void boundToSession(String name, Object value) {
+        HttpSessionBindingEvent sessionBindingEvent = new HttpSessionBindingEvent(this, name, value);
 
+        if (value instanceof HttpSessionBindingListener) {
+            HttpSessionBindingListener listener = (HttpSessionBindingListener) value;
+
+            listener.valueBound(sessionBindingEvent);
+        }
+
+        valueBound(sessionBindingEvent);
+    }
+
+    protected abstract void valueBound(HttpSessionBindingEvent sessionBindingEvent);
+
+    protected void replacedInSession(String name, Object oldValue, Object value) {
+        HttpSessionBindingEvent sessionBindingEvent = new HttpSessionBindingEvent(this, name, value);
+
+        if (oldValue instanceof HttpSessionBindingListener) {
+            HttpSessionBindingListener listener = (HttpSessionBindingListener) oldValue;
+
+            listener.valueUnbound(sessionBindingEvent);
+        }
+
+        if (value instanceof HttpSessionBindingListener) {
+            HttpSessionBindingListener listener = (HttpSessionBindingListener) value;
+
+            listener.valueBound(sessionBindingEvent);
+        }
+
+        valueReplaced(sessionBindingEvent);
+    }
+
+    protected abstract void valueReplaced(HttpSessionBindingEvent sessionBindingEvent);
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#removeValue(java.lang.String)
+     */
+    public void removeValue(String name) {
+        removeAttribute(name);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#setAttribute(java.lang.String,
+     * java.lang.Object)
+     */
+    public void setAttribute(String name, Object value) {
+        checkValid();
+
+        if (null == value) {
+            removeAttribute(name);
+        } else {
+            Object oldValue = attributes.put(name, value);
+
+            if (null != oldValue) {
+                replacedInSession(name, oldValue, value);
+            } else {
+                boundToSession(name, value);
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.http.HttpSession#setMaxInactiveInterval(int)
+     */
+    public void setMaxInactiveInterval(int interval) {
+        this.inactiveTime = interval;
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingInitialContextFactoryBuilder.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingInitialContextFactoryBuilder.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingInitialContextFactoryBuilder.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,12 +1,8 @@
 /*
- * $Id$
- */
-
-/*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- * 
+ *
  * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- * 
+ *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
  * and Distribution License("CDDL") (collectively, the "License").  You
@@ -14,7 +10,7 @@
  * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
  * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
- * 
+ *
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
  * Sun designates this particular file as subject to the "Classpath" exception
@@ -23,9 +19,9 @@
  * Header, with the fields enclosed by brackets [] replaced by your own
  * identifying information: "Portions Copyrighted [year]
  * [name of copyright owner]"
- * 
+ *
  * Contributor(s):
- * 
+ *
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
@@ -38,6 +34,11 @@
  * holder.
  */
 
+
+
+/*
+* $Id$
+ */
 package org.richfaces.test.staging;
 
 import java.util.Hashtable;
@@ -57,193 +58,187 @@
  * @author asmirnov at exadel.com
  *
  */
-public class StagingInitialContextFactoryBuilder implements
-		InitialContextFactoryBuilder {
+public class StagingInitialContextFactoryBuilder implements InitialContextFactoryBuilder {
 
-	private static final class StagingInitialContext implements Context {
-		public Object addToEnvironment(String propName,
-				Object propVal) throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public void bind(Name name, Object obj)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			
-		}
-	
-		public void bind(String name, Object obj)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			
-		}
-	
-		public void close() throws NamingException {
-			// TODO Auto-generated method stub
-			
-		}
-	
-		public Name composeName(Name name, Name prefix)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public String composeName(String name, String prefix)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public Context createSubcontext(Name name)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public Context createSubcontext(String name)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public void destroySubcontext(Name name)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			
-		}
-	
-		public void destroySubcontext(String name)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			
-		}
-	
-		public Hashtable<?, ?> getEnvironment()
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public String getNameInNamespace() throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public NameParser getNameParser(Name name)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public NameParser getNameParser(String name)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public NamingEnumeration<NameClassPair> list(Name name)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public NamingEnumeration<NameClassPair> list(String name)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public NamingEnumeration<Binding> listBindings(Name name)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public NamingEnumeration<Binding> listBindings(String name)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public Object lookup(Name name) throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public Object lookup(String name) throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public Object lookupLink(Name name) throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public Object lookupLink(String name)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public void rebind(Name name, Object obj)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			
-		}
-	
-		public void rebind(String name, Object obj)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			
-		}
-	
-		public Object removeFromEnvironment(String propName)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	
-		public void rename(Name oldName, Name newName)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			
-		}
-	
-		public void rename(String oldName, String newName)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			
-		}
-	
-		public void unbind(Name name) throws NamingException {
-			// TODO Auto-generated method stub
-			
-		}
-	
-		public void unbind(String name) throws NamingException {
-			// TODO Auto-generated method stub
-			
-		}
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.naming.spi.InitialContextFactoryBuilder#createInitialContextFactory(java.util.Hashtable)
+     */
+    public InitialContextFactory createInitialContextFactory(Hashtable<?, ?> environment) throws NamingException {
+        return new StagingInitialContextFactory();
+    }
 
-	public static final class StagingInitialContextFactory implements
-			InitialContextFactory {
-		public Context getInitialContext(Hashtable<?, ?> environment)
-				throws NamingException {
-			// TODO Auto-generated method stub
-			return new StagingInitialContext();
-		}
-	}
+    private static final class StagingInitialContext implements Context {
+        public Object addToEnvironment(String propName, Object propVal) throws NamingException {
 
-	/* (non-Javadoc)
-	 * @see javax.naming.spi.InitialContextFactoryBuilder#createInitialContextFactory(java.util.Hashtable)
-	 */
-	public InitialContextFactory createInitialContextFactory(
-			Hashtable<?, ?> environment) throws NamingException {
-		return new StagingInitialContextFactory();
-	}
+            // TODO Auto-generated method stub
+            return null;
+        }
 
+        public void bind(Name name, Object obj) throws NamingException {
+
+            // TODO Auto-generated method stub
+        }
+
+        public void bind(String name, Object obj) throws NamingException {
+
+            // TODO Auto-generated method stub
+        }
+
+        public void close() throws NamingException {
+
+            // TODO Auto-generated method stub
+        }
+
+        public Name composeName(Name name, Name prefix) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public String composeName(String name, String prefix) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Context createSubcontext(Name name) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Context createSubcontext(String name) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public void destroySubcontext(Name name) throws NamingException {
+
+            // TODO Auto-generated method stub
+        }
+
+        public void destroySubcontext(String name) throws NamingException {
+
+            // TODO Auto-generated method stub
+        }
+
+        public Hashtable<?, ?> getEnvironment() throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public String getNameInNamespace() throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public NameParser getNameParser(Name name) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public NameParser getNameParser(String name) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Object lookup(Name name) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Object lookup(String name) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Object lookupLink(Name name) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Object lookupLink(String name) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public void rebind(Name name, Object obj) throws NamingException {
+
+            // TODO Auto-generated method stub
+        }
+
+        public void rebind(String name, Object obj) throws NamingException {
+
+            // TODO Auto-generated method stub
+        }
+
+        public Object removeFromEnvironment(String propName) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public void rename(Name oldName, Name newName) throws NamingException {
+
+            // TODO Auto-generated method stub
+        }
+
+        public void rename(String oldName, String newName) throws NamingException {
+
+            // TODO Auto-generated method stub
+        }
+
+        public void unbind(Name name) throws NamingException {
+
+            // TODO Auto-generated method stub
+        }
+
+        public void unbind(String name) throws NamingException {
+
+            // TODO Auto-generated method stub
+        }
+    }
+
+
+    public static final class StagingInitialContextFactory implements InitialContextFactory {
+        public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException {
+
+            // TODO Auto-generated method stub
+            return new StagingInitialContext();
+        }
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingServer.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingServer.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingServer.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -2,13 +2,16 @@
 
 import java.io.File;
 import java.io.IOException;
+
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.EventListener;
@@ -22,7 +25,7 @@
 
 import javax.naming.NamingException;
 import javax.naming.spi.NamingManager;
-import javax.servlet.Filter;
+
 import javax.servlet.Servlet;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextAttributeEvent;
@@ -35,8 +38,6 @@
 import javax.servlet.ServletRequestAttributeListener;
 import javax.servlet.ServletRequestEvent;
 import javax.servlet.ServletRequestListener;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import javax.servlet.http.HttpSessionAttributeListener;
 import javax.servlet.http.HttpSessionBindingEvent;
@@ -60,856 +61,868 @@
  * <li>...</li>
  * </ul>
  * It is main part of the test framework.
- * 
+ *
  */
 public class StagingServer {
+    private static final Class<ServletRequestListener> REQUEST_LISTENER_CLASS = ServletRequestListener.class;
+    private static final Class<ServletRequestAttributeListener> REQUEST_ATTRIBUTE_LISTENER_CLASS =
+        ServletRequestAttributeListener.class;
+    private static final Class<ServletContextListener> CONTEXT_LISTENER_CLASS = ServletContextListener.class;
+    private static final Class<HttpSessionListener> SESSION_LISTENER_CLASS = HttpSessionListener.class;
+    private static final Class<HttpSessionAttributeListener> SESSION_ATTRIBUTE_LISTENER_CLASS =
+        HttpSessionAttributeListener.class;
+    private static final Logger LOG = ServerLogger.SERVER.getLogger();
+    private HttpSession currentSession = null;
+    private final List<RequestChain> servlets = new ArrayList<RequestChain>();
+    private final ServerResource serverRoot = new ServerResourcesDirectory();
+    private final Map<String, String> mimeTypes = new HashMap<String, String>();
+    private final Map<String, String> initParameters = new HashMap<String, String>();
+    private RequestChain defaultServlet = new ServletContainer(null, new StaticServlet());
+    private final List<EventListener> contextListeners = new ArrayList<EventListener>();
+    private final StagingServletContext context = new LocalContext();
+    private ThreadLocal<HttpSession> sessions = new ThreadLocal<HttpSession>();
+    private boolean sessionPerThread = false;
+    private List<ServerHttpSession> sessionInstances = new ArrayList<ServerHttpSession>();
+    private boolean initialised = false;
+    private ServletContext contextProxy;
+    private InvocationListener invocationListener;
 
-	private static final Class<ServletRequestListener> REQUEST_LISTENER_CLASS = ServletRequestListener.class;
+    /**
+     *
+     */
+    @SuppressWarnings("unchecked")
+    private <T extends EventListener> void fireEvent(Class<T> listenerClass, EventInvoker<T> invoker) {
+        for (EventListener listener : contextListeners) {
+            if (listenerClass.isInstance(listener)) {
+                invoker.invoke((T) listener);
+            }
+        }
+    }
 
-	private static final Class<ServletRequestAttributeListener> REQUEST_ATTRIBUTE_LISTENER_CLASS = ServletRequestAttributeListener.class;
+    /**
+     * Append executable server object ( {@link Filter} or {@link Servlet} to
+     * the server.
+     *
+     * @param servlet
+     */
+    public void addServlet(RequestChain servlet) {
+        servlets.add(servlet);
+    }
 
-	private static final Class<ServletContextListener> CONTEXT_LISTENER_CLASS = ServletContextListener.class;
+    /**
+     * Add servlet to the server.
+     *
+     * @param mapping
+     *            servlet mapping
+     * @param servlet
+     *            {@link Servlet} instance.
+     */
+    public void addServlet(String mapping, Servlet servlet) {
+        servlets.add(new ServletContainer(mapping, servlet));
+    }
 
-	private static final Class<HttpSessionListener> SESSION_LISTENER_CLASS = HttpSessionListener.class;
+    /**
+     * Get appropriate object ( Filter or Servlet ) for a given path.
+     *
+     * @param path
+     *            request path relative to web application context.
+     * @return Appropriate Filter or Servlet executable object to serve given
+     *         request. If no servlet was registered for the given path, try to
+     *         send requested object directly.
+     */
+    public RequestChain getServlet(String path) {
+        RequestChain result = null;
 
-	private static final Class<HttpSessionAttributeListener> SESSION_ATTRIBUTE_LISTENER_CLASS = HttpSessionAttributeListener.class;
+        for (RequestChain servlet : servlets) {
+            if (servlet.isApplicable(path)) {
+                result = servlet;
 
-	private static final Logger log = ServerLogger.SERVER.getLogger();
+                break;
+            }
+        }
 
-	private final List<RequestChain> servlets = new ArrayList<RequestChain>();
+        if (null == result) {
 
-	private RequestChain defaultServlet = new ServletContainer(null,
-			new StaticServlet());
+            // Is requested object exist in the virtual content ?
+            try {
+                URL resource = context.getResource(path);
 
-	private final List<EventListener> contextListeners = new ArrayList<EventListener>();
+                if (null != resource) {
 
-	private final Map<String, String> initParameters = new HashMap<String, String>();
+                    // Serve it directly.
+                    result = defaultServlet;
+                }
+            } catch (MalformedURLException e) {
+                LOG.warning("Mailformed request URL " + e.getMessage());
+            }
+        }
 
-	private final ServerResource serverRoot = new ServerResourcesDirectory();
+        return result;
+    }
 
-	private final Map<String, String> mimeTypes = new HashMap<String, String>();
+    /**
+     * Add web application init parameter.
+     *
+     * @param name
+     * @param value
+     */
+    public void addInitParameter(String name, String value) {
+        initParameters.put(name, value);
+    }
 
-	private InvocationListener invocationListener;
+    /**
+     * Add default mime type for serve files with given extension.
+     *
+     * @param extension
+     * @param mimeType
+     */
+    public void addMimeType(String extension, String mimeType) {
+        mimeTypes.put(extension, mimeType);
+    }
 
-	private final StagingServletContext context = new LocalContext();
+    /**
+     * Add java resource to the virtual web application content. This method
+     * makes all parent directories as needed.
+     *
+     * @param path
+     *            path to the file in the virtual web server.
+     * @param resource
+     *            path to the resource in the classpath, as required by the
+     *            {@link ClassLoader#getResource(String)}.
+     */
+    public void addResource(String path, String resource) {
+        ServerResourcePath resourcePath = new ServerResourcePath(path);
 
-	private ServletContext contextProxy;
+        serverRoot.addResource(resourcePath, new ClasspathServerResource(resource));
+    }
 
-	private HttpSession currentSession = null;
-	
-	private ThreadLocal<HttpSession> sessions = new ThreadLocal<HttpSession>();
-	
-	private List<ServerHttpSession> sessionInstances = new ArrayList<ServerHttpSession>();
-	
-	private boolean sessionPerThread = false;
+    /**
+     * Add resource to the virtual veb application content. This method makes
+     * all parent directories as needed.
+     *
+     * @param path
+     *            path to the file in the virtual web server.
+     * @param resource
+     *            {@code URL} to the file content.
+     */
+    public void addResource(String path, URL resource) {
+        serverRoot.addResource(new ServerResourcePath(path), new UrlServerResource(resource));
+    }
 
+    /**
+     * Add all resources from the directory to the virtual web application
+     * content.
+     *
+     * @param path
+     *            name of the target directory in the virtual web application.
+     *            If no such directory exists, it will be created, as well as
+     *            all parent directories as needed.
+     * @param resource
+     *            {@code URL} to the source directory or any file in the source
+     *            directory. Only 'file' or 'jar' protocols are supported. If
+     *            this parameter points to a file, it will be converted to a
+     *            enclosing directory.
+     */
+    public void addResourcesFromDirectory(String path, URL resource) {
+        ServerResourcePath resourcePath = new ServerResourcePath(path);
+        ServerResource baseDirectory = serverRoot.getResource(resourcePath);
 
-	private boolean initialised = false;
+        if (null == baseDirectory) {
 
-	/**
-	 * This inner class links ServletContext calls to the server instance.
-	 * 
-	 * @author asmirnov
-	 * 
-	 */
-	private class LocalContext extends StagingServletContext {
+            // Create target directory.
+            baseDirectory = new ServerResourcesDirectory();
+            serverRoot.addResource(resourcePath, baseDirectory);
+        }
 
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see javax.servlet.ServletContext#getMimeType(java.lang.String)
-		 */
-		public String getMimeType(String file) {
-			int indexOfDot = file.lastIndexOf('.');
-			// get extension.
-			if (indexOfDot >= 0) {
-				file = file.substring(indexOfDot);
-			}
-			return mimeTypes.get(file);
-		}
+        String protocol = resource.getProtocol();
 
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see
-		 * org.richfaces.test.staging.StagingServletContext#valueBound(javax
-		 * .servlet.ServletContextAttributeEvent)
-		 */
-		@Override
-		protected void valueBound(ServletContextAttributeEvent event) {
-			// inform listeners.
-			for (EventListener listener : contextListeners) {
-				if (listener instanceof ServletContextAttributeListener) {
-					ServletContextAttributeListener contextListener = (ServletContextAttributeListener) listener;
-					contextListener.attributeAdded(event);
-				}
-			}
-		}
+        if ("jar".equals(protocol)) {
+            addResourcesFromJar(resource, baseDirectory);
+        } else if ("file".equals(protocol)) {
+            addResourcesFromFile(resource, baseDirectory);
+        } else {
+            throw new TestException("Unsupported protocol " + protocol);
+        }
+    }
 
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see
-		 * org.richfaces.test.staging.StagingServletContext#valueReplaced(javax
-		 * .servlet.ServletContextAttributeEvent)
-		 */
-		@Override
-		protected void valueReplaced(ServletContextAttributeEvent event) {
-			// inform listeners.
-			for (EventListener listener : contextListeners) {
-				if (listener instanceof ServletContextAttributeListener) {
-					ServletContextAttributeListener contextListener = (ServletContextAttributeListener) listener;
-					contextListener.attributeReplaced(event);
-				}
-			}
-		}
+    /**
+     * Add all files from the directory to the virtual web application
+     * content.
+     *
+     * @param path
+     *            name of the target directory in the virtual web application.
+     *            If no such directory exists, it will be created, as well as
+     *            all parent directories as needed.
+     * @param resource
+     *            {@code File} of the source directory or any file in the source
+     *            directory. If this parameter points to a file, it will be converted to a
+     *            enclosing directory.
+     */
+    public void addResourcesFromDirectory(String path, File directory) {
+        ServerResourcePath resourcePath = new ServerResourcePath(path);
+        ServerResource baseDirectory = serverRoot.getResource(resourcePath);
 
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see
-		 * org.richfaces.test.staging.StagingServletContext#valueUnbound(javax
-		 * .servlet.ServletContextAttributeEvent)
-		 */
-		@Override
-		protected void valueUnbound(ServletContextAttributeEvent event) {
-			// inform listeners.
-			for (EventListener listener : contextListeners) {
-				if (listener instanceof ServletContextAttributeListener) {
-					ServletContextAttributeListener contextListener = (ServletContextAttributeListener) listener;
-					contextListener.attributeRemoved(event);
-				}
-			}
-		}
+        if (null == baseDirectory) {
 
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see
-		 * org.richfaces.test.staging.StagingServletContext#getServerResource
-		 * (java.lang.String)
-		 */
-		@Override
-		protected ServerResource getServerResource(String path) {
-			return serverRoot.getResource(new ServerResourcePath(path));
-		}
+            // Create target directory.
+            baseDirectory = new ServerResourcesDirectory();
+            serverRoot.addResource(resourcePath, baseDirectory);
+        }
 
-	}
+        if (!directory.isDirectory()) {
+            directory = directory.getParentFile();
+        }
 
-	/**
-	 * This inner class links session object calls to the server instance.
-	 * 
-	 * @author asmirnov
-	 * 
-	 */
-	private class ServerHttpSession extends StagingHttpSession {
+        if (!directory.exists()) {
+            throw new TestException("directory does not exist:" + directory.getAbsolutePath());
+        }
 
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see javax.servlet.http.HttpSession#getServletContext()
-		 */
-		public ServletContext getServletContext() {
-			return context;
-		}
+        try {
+            addFiles(baseDirectory, directory);
+        } catch (MalformedURLException e) {
+            throw new TestException(e);
+        }
+    }
 
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see
-		 * org.richfaces.test.staging.StagingHttpSession#valueBound(javax.servlet
-		 * .http.HttpSessionBindingEvent)
-		 */
-		@Override
-		protected void valueBound(
-				final HttpSessionBindingEvent sessionBindingEvent) {
-			// inform session listeners.
-			fireEvent(SESSION_ATTRIBUTE_LISTENER_CLASS,
-					new EventInvoker<HttpSessionAttributeListener>() {
-						public void invoke(HttpSessionAttributeListener listener) {
-							listener.attributeAdded(sessionBindingEvent);
-						}
-					});
-		}
+    /**
+     * Internal method used by the
+     * {@link #addResourcesFromDirectory(String, URL)} to process 'file'
+     * protocol.
+     *
+     * @param resource
+     *            source directory.
+     * @param baseDirectory
+     *            target virtual directory.
+     */
+    protected void addResourcesFromFile(URL resource, ServerResource baseDirectory) {
+        File file = new File(resource.getPath());
 
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see
-		 * org.richfaces.test.staging.StagingHttpSession#valueUnbound(javax.
-		 * servlet.http.HttpSessionBindingEvent)
-		 */
-		@Override
-		protected void valueUnbound(
-				final HttpSessionBindingEvent sessionBindingEvent) {
-			// inform session listeners.
-			fireEvent(SESSION_ATTRIBUTE_LISTENER_CLASS,
-					new EventInvoker<HttpSessionAttributeListener>() {
-						public void invoke(HttpSessionAttributeListener listener) {
-							listener.attributeRemoved(sessionBindingEvent);
-						}
-					});
-		}
+        if (!file.isDirectory()) {
+            file = file.getParentFile();
+        }
 
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see
-		 * org.richfaces.test.staging.StagingHttpSession#valueReplaced(javax
-		 * .servlet.http.HttpSessionBindingEvent)
-		 */
-		@Override
-		protected void valueReplaced(
-				final HttpSessionBindingEvent sessionBindingEvent) {
-			// inform session listeners.
-			fireEvent(SESSION_ATTRIBUTE_LISTENER_CLASS,
-					new EventInvoker<HttpSessionAttributeListener>() {
-						public void invoke(HttpSessionAttributeListener listener) {
-							listener.attributeReplaced(sessionBindingEvent);
-						}
-					});
-		}
-		
-		@Override
-		public void invalidate() {
-			super.invalidate();
-			setCurrentSession(null);
-		}
-	}
+        try {
+            addFiles(baseDirectory, file);
+        } catch (MalformedURLException e) {
+            throw new TestException(e);
+        }
+    }
 
-	/**
-	 * 
-	 */
-	@SuppressWarnings("unchecked")
-	private <T extends EventListener> void fireEvent(Class<T> listenerClass,
-			EventInvoker<T> invoker) {
-		for (EventListener listener : contextListeners) {
-			if (listenerClass.isInstance(listener)) {
-				invoker.invoke((T) listener);
-			}
-		}
-		
-		
-	}
+    /**
+     * Internal method used by the
+     * {@link #addResourcesFromDirectory(String, URL)} to process 'jar'
+     * protocol.
+     *
+     * @param resource
+     *            URL to the any object in the source directory.
+     * @param baseDirectory
+     *            target virtual directory.
+     */
+    protected void addResourcesFromJar(URL resource, ServerResource baseDirectory) {
+        try {
+            String jarPath = resource.getPath();
+            String entry = jarPath.substring(jarPath.indexOf('!') + 2);
 
-	/**
-	 * Append executable server object ( {@link Filter} or {@link Servlet} to
-	 * the server.
-	 * 
-	 * @param servlet
-	 */
-	public void addServlet(RequestChain servlet) {
-		servlets.add(servlet);
-	}
+            jarPath = jarPath.substring(0, jarPath.indexOf('!'));
 
-	/**
-	 * Add servlet to the server.
-	 * 
-	 * @param mapping
-	 *            servlet mapping
-	 * @param servlet
-	 *            {@link Servlet} instance.
-	 */
-	public void addServlet(String mapping, Servlet servlet) {
-		servlets.add(new ServletContainer(mapping, servlet));
-	}
+            File file = new File(new URI(jarPath));
+            ZipFile zip = new ZipFile(file);
+            Enumeration<? extends ZipEntry> entries = zip.entries();
 
-	/**
-	 * Get appropriate object ( Filter or Servlet ) for a given path.
-	 * 
-	 * @param path
-	 *            request path relative to web application context.
-	 * @return Appropriate Filter or Servlet executable object to serve given
-	 *         request. If no servlet was registered for the given path, try to
-	 *         send requested object directly.
-	 */
-	public RequestChain getServlet(String path) {
-		RequestChain result = null;
-		for (RequestChain servlet : servlets) {
-			if (servlet.isApplicable(path)) {
-				result = servlet;
-				break;
-			}
-		}
-		if (null == result) {
-			// Is requested object exist in the virtual content ?
-			try {
-				URL resource = context.getResource(path);
-				if (null != resource) {
-					// Serve it directly.
-					result = defaultServlet;
-				}
-			} catch (MalformedURLException e) {
-				log.warning("Mailformed request URL " + e.getMessage());
-			}
-		}
-		return result;
-	}
+            entry = entry.substring(0, entry.lastIndexOf('/') + 1);
 
-	/**
-	 * Add web application init parameter.
-	 * 
-	 * @param name
-	 * @param value
-	 */
-	public void addInitParameter(String name, String value) {
-		initParameters.put(name, value);
-	}
+            while (entries.hasMoreElements()) {
+                ZipEntry zzz = (ZipEntry) entries.nextElement();
 
-	/**
-	 * Add default mime type for serve files with given extension.
-	 * 
-	 * @param extension
-	 * @param mimeType
-	 */
-	public void addMimeType(String extension, String mimeType) {
-		mimeTypes.put(extension, mimeType);
-	}
+                if (zzz.getName().startsWith(entry) && !zzz.isDirectory()) {
+                    String relativePath = zzz.getName().substring(entry.length());
+                    URL relativeResource = new URL(resource, relativePath);
 
-	/**
-	 * Add java resource to the virtual web application content. This method
-	 * makes all parent directories as needed.
-	 * 
-	 * @param path
-	 *            path to the file in the virtual web server.
-	 * @param resource
-	 *            path to the resource in the classpath, as required by the
-	 *            {@link ClassLoader#getResource(String)}.
-	 */
-	public void addResource(String path, String resource) {
-		ServerResourcePath resourcePath = new ServerResourcePath(path);
-		serverRoot.addResource(resourcePath, new ClasspathServerResource(
-				resource));
-	}
+                    baseDirectory.addResource(new ServerResourcePath("/" + relativePath),
+                                              new UrlServerResource(relativeResource));
+                }
+            }
+        } catch (IOException e) {
+            throw new TestException("Error read Jar content", e);
+        } catch (URISyntaxException e) {
+            throw new TestException(e);
+        }
+    }
 
-	/**
-	 * Add resource to the virtual veb application content. This method makes
-	 * all parent directories as needed.
-	 * 
-	 * @param path
-	 *            path to the file in the virtual web server.
-	 * @param resource
-	 *            {@code URL} to the file content.
-	 */
-	public void addResource(String path, URL resource) {
-		serverRoot.addResource(new ServerResourcePath(path),
-				new UrlServerResource(resource));
-	}
+    /**
+     * Internal reccursive method process directory content and all
+     * subdirectories.
+     *
+     * @param baseDirectory
+     * @param file
+     * @throws MalformedURLException
+     */
+    protected void addFiles(ServerResource baseDirectory, File file) throws MalformedURLException {
+        File[] files = file.listFiles();
 
-	/**
-	 * Add all resources from the directory to the virtual web application
-	 * content.
-	 * 
-	 * @param path
-	 *            name of the target directory in the virtual web application.
-	 *            If no such directory exists, it will be created, as well as
-	 *            all parent directories as needed.
-	 * @param resource
-	 *            {@code URL} to the source directory or any file in the source
-	 *            directory. Only 'file' or 'jar' protocols are supported. If
-	 *            this parameter points to a file, it will be converted to a
-	 *            enclosing directory.
-	 */
-	public void addResourcesFromDirectory(String path, URL resource) {
-		ServerResourcePath resourcePath = new ServerResourcePath(path);
-		ServerResource baseDirectory = serverRoot.getResource(resourcePath);
-		if (null == baseDirectory) {
-			// Create target directory.
-			baseDirectory = new ServerResourcesDirectory();
-			serverRoot.addResource(resourcePath, baseDirectory);
-		}
-		String protocol = resource.getProtocol();
-		if ("jar".equals(protocol)) {
-			addResourcesFromJar(resource, baseDirectory);
-		} else if ("file".equals(protocol)) {
-			addResourcesFromFile(resource, baseDirectory);
-		} else {
-			throw new TestException("Unsupported protocol " + protocol);
-		}
-	}
+        for (File subfile : files) {
+            if (subfile.isDirectory()) {
+                ServerResourcePath serverResourcePath = new ServerResourcePath("/" + subfile.getName() + "/");
+                ServerResourcesDirectory subDir = new ServerResourcesDirectory();
 
-	/**
-	 * Add all files from the directory to the virtual web application
-	 * content.
-	 * 
-	 * @param path
-	 *            name of the target directory in the virtual web application.
-	 *            If no such directory exists, it will be created, as well as
-	 *            all parent directories as needed.
-	 * @param resource
-	 *            {@code File} of the source directory or any file in the source
-	 *            directory. If this parameter points to a file, it will be converted to a
-	 *            enclosing directory.
-	 */
-	public void addResourcesFromDirectory(String path, File directory) {
-		ServerResourcePath resourcePath = new ServerResourcePath(path);
-		ServerResource baseDirectory = serverRoot.getResource(resourcePath);
-		if (null == baseDirectory) {
-			// Create target directory.
-			baseDirectory = new ServerResourcesDirectory();
-			serverRoot.addResource(resourcePath, baseDirectory);
-		}
-		if (!directory.isDirectory()) {
-			directory = directory.getParentFile();
-		}
-		if(!directory.exists()){
-			throw new TestException("directory does not exist:"+directory.getAbsolutePath());
-		}
-		try {
-			addFiles(baseDirectory, directory);
-		} catch (MalformedURLException e) {
-			throw new TestException(e);
-		}
-	}
+                baseDirectory.addResource(serverResourcePath, subDir);
+                addFiles(subDir, subfile);
+            } else {
+                ServerResourcePath serverResourcePath = new ServerResourcePath("/" + subfile.getName());
+                UrlServerResource resource = new UrlServerResource(subfile.toURL());
 
-	/**
-	 * Internal method used by the
-	 * {@link #addResourcesFromDirectory(String, URL)} to process 'file'
-	 * protocol.
-	 * 
-	 * @param resource
-	 *            source directory.
-	 * @param baseDirectory
-	 *            target virtual directory.
-	 */
-	protected void addResourcesFromFile(URL resource,
-			ServerResource baseDirectory) {
-		File file = new File(resource.getPath());
-		if (!file.isDirectory()) {
-			file = file.getParentFile();
-		}
-		try {
-			addFiles(baseDirectory, file);
-		} catch (MalformedURLException e) {
-			throw new TestException(e);
-		}
-	}
+                baseDirectory.addResource(serverResourcePath, resource);
+            }
+        }
+    }
 
-	/**
-	 * Internal method used by the
-	 * {@link #addResourcesFromDirectory(String, URL)} to process 'jar'
-	 * protocol.
-	 * 
-	 * @param resource
-	 *            URL to the any object in the source directory.
-	 * @param baseDirectory
-	 *            target virtual directory.
-	 */
-	protected void addResourcesFromJar(URL resource,
-			ServerResource baseDirectory) {
-		try {
-			String jarPath = resource.getPath();
-			String entry = jarPath.substring(jarPath.indexOf('!') + 2);
-			jarPath = jarPath.substring(0, jarPath.indexOf('!'));
-			File file = new File(new URI(jarPath));
-			ZipFile zip = new ZipFile(file);
-			Enumeration<? extends ZipEntry> entries = zip.entries();
-			entry = entry.substring(0, entry.lastIndexOf('/') + 1);
-			while (entries.hasMoreElements()) {
-				ZipEntry zzz = (ZipEntry) entries.nextElement();
-				if (zzz.getName().startsWith(entry) && !zzz.isDirectory()) {
-					String relativePath = zzz.getName().substring(
-							entry.length());
-					URL relativeResource = new URL(resource, relativePath);
-					baseDirectory.addResource(new ServerResourcePath("/"
-							+ relativePath), new UrlServerResource(
-							relativeResource));
-				}
-			}
+    /**
+     * Add web-application wide listenes, same as it is defined by the
+     * &lt;listener&gt; element in the web.xml file for a real server. Supported
+     * listener types:
+     * <ul>
+     * <li>{@link ServletContextListener}</li>
+     * <li>{@link ServletContextAttributeListener}</li>
+     * <li>{@link HttpSessionListener}</li>
+     * <li>{@link HttpSessionAttributeListener}</li>
+     * <li>{@link ServletRequestListener}</li>
+     * <li>{@link ServletRequestAttributeListener}</li>
+     * </ul>
+     *
+     * @param listener
+     *            web listener instance.
+     */
+    public void addWebListener(EventListener listener) {
+        contextListeners.add(listener);
+    }
 
-		} catch (IOException e) {
-			throw new TestException("Error read Jar content", e);
-		} catch (URISyntaxException e) {
-			throw new TestException(e);
-		}
-	}
+    /**
+     * Getter method for 'interceptor' events listener.
+     *
+     * @return the invocationListener
+     */
+    public InvocationListener getInvocationListener() {
+        return invocationListener;
+    }
 
-	/**
-	 * Internal reccursive method process directory content and all
-	 * subdirectories.
-	 * 
-	 * @param baseDirectory
-	 * @param file
-	 * @throws MalformedURLException
-	 */
-	protected void addFiles(ServerResource baseDirectory, File file)
-			throws MalformedURLException {
-		File[] files = file.listFiles();
-		for (File subfile : files) {
-			if (subfile.isDirectory()) {
-				ServerResourcePath serverResourcePath = new ServerResourcePath("/"
-						+ subfile.getName()+"/");
-				ServerResourcesDirectory subDir = new ServerResourcesDirectory();
-				baseDirectory.addResource(serverResourcePath, subDir);
-				addFiles(subDir, subfile);
-			} else {
-				ServerResourcePath serverResourcePath = new ServerResourcePath("/"
-						+ subfile.getName());
-				UrlServerResource resource = new UrlServerResource(subfile
-						.toURL());
-				baseDirectory.addResource(serverResourcePath, resource);
+    /**
+     * Set listener which gets events on all calls to any methods of the
+     * {@link ServletContext}, {@link HttpSession}, {@link javax.servlet.http.HttpServletRequest},
+     * {@link javax.servlet.http.HttpServletResponse} instances in the virtual server. this
+     * interceptor can be used to check internal calls in the tests .
+     *
+     * @param invocationListener
+     *            the invocationListener to set
+     */
+    public void setInvocationListener(InvocationListener invocationListener) {
+        this.invocationListener = invocationListener;
+    }
 
-			}
-		}
-	}
+    /**
+     * Create instance of the {@link InvocationHandler} for the proxy objects.
+     * This handler fire events to the registered {@link InvocationListener} (
+     * if present ) after target object method call.
+     *
+     * @return the invocationHandler
+     */
+    InvocationHandler getInvocationHandler(final Object target) {
+        return new InvocationHandler() {
+            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+                InvocationListener listener = getInvocationListener();
 
-	/**
-	 * Add web-application wide listenes, same as it is defined by the
-	 * &lt;listener&gt; element in the web.xml file for a real server. Supported
-	 * listener types:
-	 * <ul>
-	 * <li>{@link ServletContextListener}</li>
-	 * <li>{@link ServletContextAttributeListener}</li>
-	 * <li>{@link HttpSessionListener}</li>
-	 * <li>{@link HttpSessionAttributeListener}</li>
-	 * <li>{@link ServletRequestListener}</li>
-	 * <li>{@link ServletRequestAttributeListener}</li>
-	 * </ul>
-	 * 
-	 * @param listener
-	 *            web listener instance.
-	 */
-	public void addWebListener(EventListener listener) {
-		contextListeners.add(listener);
-	}
+                try {
+                    Object result = method.invoke(target, args);
 
-	/**
-	 * Getter method for 'interceptor' events listener.
-	 * 
-	 * @return the invocationListener
-	 */
-	public InvocationListener getInvocationListener() {
-		return invocationListener;
-	}
+                    if (null != listener) {
+                        listener.afterInvoke(new InvocationEvent(target, method, args, result));
+                    }
 
-	/**
-	 * Set listener which gets events on all calls to any methods of the
-	 * {@link ServletContext}, {@link HttpSession}, {@link HttpServletRequest},
-	 * {@link HttpServletResponse} instances in the virtual server. this
-	 * interceptor can be used to check internal calls in the tests .
-	 * 
-	 * @param invocationListener
-	 *            the invocationListener to set
-	 */
-	public void setInvocationListener(InvocationListener invocationListener) {
-		this.invocationListener = invocationListener;
-	}
+                    return result;
+                } catch (Throwable e) {
+                    if (null != listener) {
+                        listener.processException(new InvocationErrorEvent(target, method, args, e));
+                    }
 
-	/**
-	 * Create instance of the {@link InvocationHandler} for the proxy objects.
-	 * This handler fire events to the registered {@link InvocationListener} (
-	 * if present ) after target object method call.
-	 * 
-	 * @return the invocationHandler
-	 */
-	InvocationHandler getInvocationHandler(final Object target) {
-		return new InvocationHandler() {
+                    throw e;
+                }
+            }
+        };
+    }
 
-			public Object invoke(Object proxy, Method method, Object[] args)
-					throws Throwable {
-				InvocationListener listener = getInvocationListener();
-				try {
-					Object result = method.invoke(target, args);
-					if (null != listener) {
-						listener.afterInvoke(new InvocationEvent(target,
-								method, args, result));
-					}
-					return result;
-				} catch (Throwable e) {
-					if (null != listener) {
-						listener.processException(new InvocationErrorEvent(
-								target, method, args, e));
-					}
-					throw e;
-				}
-			}
+    public boolean isSessionPerThread() {
+        return sessionPerThread;
+    }
 
-		};
+    public void setSessionPerThread(boolean sessionPerThread) {
+        this.sessionPerThread = sessionPerThread;
+    }
 
-	}
+    HttpSession getCurrentSession() {
+        if (isSessionPerThread()) {
+            return sessions.get();
+        } else {
+            return currentSession;
+        }
+    }
 
-	public boolean isSessionPerThread() {
-		return sessionPerThread;
-	}
+    void setCurrentSession(HttpSession session) {
+        if (isSessionPerThread()) {
+            sessions.set(session);
+        } else {
+            this.currentSession = session;
+        }
+    }
 
-	public void setSessionPerThread(boolean sessionPerThread) {
-		this.sessionPerThread = sessionPerThread;
-	}
-	
-	
-	HttpSession getCurrentSession() {
-		if (isSessionPerThread()) {
-			return sessions.get();
-		} else {
-			return currentSession;
-		}
-	}
-	
-	void setCurrentSession(HttpSession session) {
-		if (isSessionPerThread()) {
-			sessions.set(session);
-		} else {
-			this.currentSession=session;
-		}
-		
-	}
+    /**
+     * Get virtual server session object. Create new one if necessary.
+     *
+     * @return instance of the virtual server session.
+     */
+    public HttpSession getSession() {
+        return getSession(true);
+    }
 
-	/**
-	 * Get virtual server session object. Create new one if necessary.
-	 * 
-	 * @return instance of the virtual server session.
-	 */
-	public HttpSession getSession() {
-		return getSession(true);
-	}
+    /**
+     *
+     * Returns the current <code>HttpSession</code> associated with this server
+     * or, if there is no current session and <code>create</code> is true,
+     * returns a new session. Staging server supports only one session per
+     * instance, different clients for the same server instance does not
+     * supported.
+     *
+     * <p>
+     * If <code>create</code> is <code>false</code> and the request has no valid
+     * <code>HttpSession</code>, this method returns <code>null</code>.
+     *
+     *
+     * @param create
+     *            <code>true</code> to create a new session for this request if
+     *            necessary; <code>false</code> to return <code>null</code> if
+     *            there's no current session
+     *
+     *
+     * @return the <code>HttpSession</code> associated with this server instance
+     *         or <code>null</code> if <code>create</code> is <code>false</code>
+     *         and the server has no session
+     *
+     */
+    public synchronized HttpSession getSession(boolean create) {
+        if (!initialised) {
+            throw new TestException("Staging server have not been initialised");
+        }
 
-	/**
-	 * 
-	 * Returns the current <code>HttpSession</code> associated with this server
-	 * or, if there is no current session and <code>create</code> is true,
-	 * returns a new session. Staging server supports only one session per
-	 * instance, different clients for the same server instance does not
-	 * supported.
-	 * 
-	 * <p>
-	 * If <code>create</code> is <code>false</code> and the request has no valid
-	 * <code>HttpSession</code>, this method returns <code>null</code>.
-	 * 
-	 * 
-	 * @param create
-	 *            <code>true</code> to create a new session for this request if
-	 *            necessary; <code>false</code> to return <code>null</code> if
-	 *            there's no current session
-	 * 
-	 * 
-	 * @return the <code>HttpSession</code> associated with this server instance
-	 *         or <code>null</code> if <code>create</code> is <code>false</code>
-	 *         and the server has no session
-	 * 
-	 */
-	public synchronized HttpSession getSession(boolean create) {
-		if (!initialised) {
-			throw new TestException("Staging server have not been initialised");
-		}
-		HttpSession httpSession = this.getCurrentSession();
-		if (null == httpSession && create) {
-			ServerHttpSession sessionImpl = new ServerHttpSession();
-			// Create proxy objects.
-			ClassLoader loader = Thread.currentThread().getContextClassLoader();
-			if (null == loader) {
-				loader = this.getClass().getClassLoader();
-			}
-			httpSession = (HttpSession) Proxy.newProxyInstance(loader,
-					new Class[] { HttpSession.class },
-					getInvocationHandler(sessionImpl));
-			setCurrentSession(httpSession);
-			// inform session listeners.
-			final HttpSessionEvent event = new HttpSessionEvent(httpSession);
-			fireEvent(SESSION_LISTENER_CLASS,
-					new EventInvoker<HttpSessionListener>() {
-						public void invoke(HttpSessionListener listener) {
-							listener.sessionCreated(event);
-						}
-					});
-			sessionInstances.add(sessionImpl);
-		}
-		return httpSession;
-	}
+        HttpSession httpSession = this.getCurrentSession();
 
-	/**
-	 * Virtual server initialization. This method creates instances of the
-	 * {@link ServletContext}, {@link JspFactory}, informs
-	 * {@link ServletContextListener} ind inits all {@link Filter} and
-	 * {@link Servlet} instances. It should be called from test setUp method to
-	 * prepare testing environment.
-	 */
-	public void init() {
-		log.info("Init staging server");
-		// Create Jsp factory
-		JspFactory.setDefaultFactory(new StaggingJspFactory(this.context));
-		// Create init parameters
-		context.addInitParameters(initParameters);
-		// Inform listeners
-		// Create proxy objects.
-		ClassLoader loader = Thread.currentThread().getContextClassLoader();
-		if (null == loader) {
-			loader = this.getClass().getClassLoader();
-		}
-		this.contextProxy = (ServletContext) Proxy.newProxyInstance(loader,
-				new Class[] { ServletContext.class },
-				getInvocationHandler(context));
-		// Create default servlet
-		final ServletContextEvent event = new ServletContextEvent(context);
-		fireEvent(CONTEXT_LISTENER_CLASS,
-				new EventInvoker<ServletContextListener>() {
-					public void invoke(ServletContextListener listener) {
-						listener.contextInitialized(event);
-					}
-				});
-		// Init servlets
-		try {
-			for (RequestChain servlet : servlets) {
-				// init servlet
-				servlet.init(context);
-			}
-			defaultServlet.init(context);
-		} catch (ServletException e) {
-			throw new TestException("Servlet initialisation error ", e);
-		}
-		try {
-			NamingManager.setInitialContextFactoryBuilder(new StagingInitialContextFactoryBuilder());
-		} catch (NamingException e) {
-			log.warning("Error set initial context factory builder.");
-		} catch (IllegalStateException e) {
-			log.warning("Initial context factory builder already set.");
-		}
-		this.initialised = true;
-	}
+        if (null == httpSession && create) {
+            ServerHttpSession sessionImpl = new ServerHttpSession();
 
-	/**
-	 * Stop wirtual server. This method informs {@link ServletContextListener}
-	 * ind inits all {@link Filter} and {@link Servlet} instances, as well
-	 * remove all internal objects. It should be called from the testt thearDown
-	 * method to clean up testing environment.
-	 * 
-	 */
-	public void destroy() {
-		if (!initialised) {
-			throw new TestException("Staging server have not been initialised");
-		}
-		this.initialised = false;
-		// Destroy session
-		// TODO - destroy all threads.
-		for (Iterator<ServerHttpSession> sessionIterator = sessionInstances.iterator(); sessionIterator.hasNext();) {
-			ServerHttpSession session = sessionIterator.next();
-			// inform session listeners.
-			final HttpSessionEvent event = new HttpSessionEvent(session);
-			fireEvent(SESSION_LISTENER_CLASS,
-					new EventInvoker<HttpSessionListener>() {
-						public void invoke(HttpSessionListener listener) {
-							listener.sessionDestroyed(event);
-						}
-					});
-			session.invalidate();
-			sessionIterator.remove();
-		}
-		setCurrentSession(null);
-		// Inform listeners
-		final ServletContextEvent event = new ServletContextEvent(context);
-		fireEvent(CONTEXT_LISTENER_CLASS,
-				new EventInvoker<ServletContextListener>() {
-					public void invoke(ServletContextListener listener) {
-						listener.contextDestroyed(event);
-					}
-				});
-		// Destroy servlets
-		for (RequestChain servlet : servlets) {
-			servlet.destroy();
-		}
-		defaultServlet.destroy();
-		// Create Jsp factory
-		JspFactory.setDefaultFactory(null);
-		this.contextProxy = null;
-		log.info("Staging server have been destroyed");
-	}
+            // Create proxy objects.
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
 
-	/**
-	 * Get virtual connection to the given URL. Even thought for an http request
-	 * to the external servers, only local connection to the virtual server will
-	 * be created.
-	 * 
-	 * @param url
-	 *            request url.
-	 * @return local connection to the appropriate servlet in the virtual
-	 *         server.
-	 * @throws {@link TestException} if no servlet found to process given URL.
-	 */
-	public StagingConnection getConnection(URL url) {
-		if (!initialised) {
-			throw new TestException("Staging server have not been initialised");
-		}
-		return new StagingConnection(this, url);
-	}
+            if (null == loader) {
+                loader = this.getClass().getClassLoader();
+            }
 
-	/**
-	 * Get instance of virtual web application context.
-	 * 
-	 * @return context instance.
-	 */
-	public ServletContext getContext() {
-		if (!initialised) {
-			throw new TestException("Staging server have not been initialised");
-		}
-		return contextProxy;
-	}
+            httpSession = (HttpSession) Proxy.newProxyInstance(loader, new Class[] {HttpSession.class},
+                    getInvocationHandler(sessionImpl));
+            setCurrentSession(httpSession);
 
-	/**
-	 * Inform {@link ServletRequestListener} instances. For internal use only.
-	 * 
-	 * @param request
-	 *            started request.
-	 */
-	void requestStarted(ServletRequest request) {
-		final ServletRequestEvent event = new ServletRequestEvent(context,
-				request);
-		fireEvent(REQUEST_LISTENER_CLASS,
-				new EventInvoker<ServletRequestListener>() {
-					public void invoke(ServletRequestListener listener) {
-						listener.requestInitialized(event);
+            // inform session listeners.
+            final HttpSessionEvent event = new HttpSessionEvent(httpSession);
 
-					}
-				});
-	}
+            fireEvent(SESSION_LISTENER_CLASS, new EventInvoker<HttpSessionListener>() {
+                public void invoke(HttpSessionListener listener) {
+                    listener.sessionCreated(event);
+                }
+            });
+            sessionInstances.add(sessionImpl);
+        }
 
-	/**
-	 * Inform {@link ServletRequestListener} instances. For internal use only.
-	 * 
-	 * @param request
-	 *            finished request.
-	 */
-	void requestFinished(ServletRequest request) {
-		final ServletRequestEvent event = new ServletRequestEvent(context,
-				request);
-		fireEvent(REQUEST_LISTENER_CLASS,
-				new EventInvoker<ServletRequestListener>() {
-					public void invoke(ServletRequestListener listener) {
-						listener.requestDestroyed(event);
-					}
-				});
-	}
+        return httpSession;
+    }
 
-	void requestAttributeAdded(ServletRequest request, String name, Object o) {
-		final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(
-				context, request, name, o);
-		fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS,
-				new EventInvoker<ServletRequestAttributeListener>() {
-					public void invoke(ServletRequestAttributeListener listener) {
-						listener.attributeAdded(event);
-					}
-				});
-	}
+    /**
+     * Virtual server initialization. This method creates instances of the
+     * {@link ServletContext}, {@link JspFactory}, informs
+     * {@link ServletContextListener} ind inits all {@link Filter} and
+     * {@link Servlet} instances. It should be called from test setUp method to
+     * prepare testing environment.
+     */
+    public void init() {
+        LOG.info("Init staging server");
 
-	void requestAttributeRemoved(ServletRequest request, String name,
-			Object removed) {
-		final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(
-				context, request, name, removed);
-		fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS,
-				new EventInvoker<ServletRequestAttributeListener>() {
-					public void invoke(ServletRequestAttributeListener listener) {
-						listener.attributeRemoved(event);
-					}
-				});
-	}
+        // Create Jsp factory
+        JspFactory.setDefaultFactory(new StaggingJspFactory(this.context));
 
-	void requestAttributeReplaced(ServletRequest request, String name,
-			Object value) {
-		final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(
-				context, request, name, value);
-		fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS,
-				new EventInvoker<ServletRequestAttributeListener>() {
-					public void invoke(ServletRequestAttributeListener listener) {
-						listener.attributeReplaced(event);
-					}
-				});
-	}
+        // Create init parameters
+        context.addInitParameters(initParameters);
+
+        // Inform listeners
+        // Create proxy objects.
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+        if (null == loader) {
+            loader = this.getClass().getClassLoader();
+        }
+
+        this.contextProxy = (ServletContext) Proxy.newProxyInstance(loader, new Class[] {ServletContext.class},
+                getInvocationHandler(context));
+
+        // Create default servlet
+        final ServletContextEvent event = new ServletContextEvent(context);
+
+        fireEvent(CONTEXT_LISTENER_CLASS, new EventInvoker<ServletContextListener>() {
+            public void invoke(ServletContextListener listener) {
+                listener.contextInitialized(event);
+            }
+        });
+
+        // Init servlets
+        try {
+            for (RequestChain servlet : servlets) {
+
+                // init servlet
+                servlet.init(context);
+            }
+
+            defaultServlet.init(context);
+        } catch (ServletException e) {
+            throw new TestException("Servlet initialisation error ", e);
+        }
+
+        try {
+            NamingManager.setInitialContextFactoryBuilder(new StagingInitialContextFactoryBuilder());
+        } catch (NamingException e) {
+            LOG.warning("Error set initial context factory builder.");
+        } catch (IllegalStateException e) {
+            LOG.warning("Initial context factory builder already set.");
+        }
+
+        this.initialised = true;
+    }
+
+    /**
+     * Stop wirtual server. This method informs {@link ServletContextListener}
+     * ind inits all {@link Filter} and {@link Servlet} instances, as well
+     * remove all internal objects. It should be called from the testt thearDown
+     * method to clean up testing environment.
+     *
+     */
+    public void destroy() {
+        if (!initialised) {
+            throw new TestException("Staging server have not been initialised");
+        }
+
+        this.initialised = false;
+
+        // Destroy session
+        // TODO - destroy all threads.
+        for (Iterator<ServerHttpSession> sessionIterator = sessionInstances.iterator(); sessionIterator.hasNext(); ) {
+            ServerHttpSession session = sessionIterator.next();
+
+            // inform session listeners.
+            final HttpSessionEvent event = new HttpSessionEvent(session);
+
+            fireEvent(SESSION_LISTENER_CLASS, new EventInvoker<HttpSessionListener>() {
+                public void invoke(HttpSessionListener listener) {
+                    listener.sessionDestroyed(event);
+                }
+            });
+            session.invalidate();
+            sessionIterator.remove();
+        }
+
+        setCurrentSession(null);
+
+        // Inform listeners
+        final ServletContextEvent event = new ServletContextEvent(context);
+
+        fireEvent(CONTEXT_LISTENER_CLASS, new EventInvoker<ServletContextListener>() {
+            public void invoke(ServletContextListener listener) {
+                listener.contextDestroyed(event);
+            }
+        });
+
+        // Destroy servlets
+        for (RequestChain servlet : servlets) {
+            servlet.destroy();
+        }
+
+        defaultServlet.destroy();
+
+        // Create Jsp factory
+        JspFactory.setDefaultFactory(null);
+        this.contextProxy = null;
+        LOG.info("Staging server have been destroyed");
+    }
+
+    /**
+     * Get virtual connection to the given URL. Even thought for an http request
+     * to the external servers, only local connection to the virtual server will
+     * be created.
+     *
+     * @param url
+     *            request url.
+     * @return local connection to the appropriate servlet in the virtual
+     *         server.
+     * @throws {@link TestException} if no servlet found to process given URL.
+     */
+    public StagingConnection getConnection(URL url) {
+        if (!initialised) {
+            throw new TestException("Staging server have not been initialised");
+        }
+
+        return new StagingConnection(this, url);
+    }
+
+    /**
+     * Get instance of virtual web application context.
+     *
+     * @return context instance.
+     */
+    public ServletContext getContext() {
+        if (!initialised) {
+            throw new TestException("Staging server have not been initialised");
+        }
+
+        return contextProxy;
+    }
+
+    /**
+     * Inform {@link ServletRequestListener} instances. For internal use only.
+     *
+     * @param request
+     *            started request.
+     */
+    void requestStarted(ServletRequest request) {
+        final ServletRequestEvent event = new ServletRequestEvent(context, request);
+
+        fireEvent(REQUEST_LISTENER_CLASS, new EventInvoker<ServletRequestListener>() {
+            public void invoke(ServletRequestListener listener) {
+                listener.requestInitialized(event);
+            }
+        });
+    }
+
+    /**
+     * Inform {@link ServletRequestListener} instances. For internal use only.
+     *
+     * @param request
+     *            finished request.
+     */
+    void requestFinished(ServletRequest request) {
+        final ServletRequestEvent event = new ServletRequestEvent(context, request);
+
+        fireEvent(REQUEST_LISTENER_CLASS, new EventInvoker<ServletRequestListener>() {
+            public void invoke(ServletRequestListener listener) {
+                listener.requestDestroyed(event);
+            }
+        });
+    }
+
+    void requestAttributeAdded(ServletRequest request, String name, Object o) {
+        final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(context, request, name, o);
+
+        fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS, new EventInvoker<ServletRequestAttributeListener>() {
+            public void invoke(ServletRequestAttributeListener listener) {
+                listener.attributeAdded(event);
+            }
+        });
+    }
+
+    void requestAttributeRemoved(ServletRequest request, String name, Object removed) {
+        final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(context, request, name, removed);
+
+        fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS, new EventInvoker<ServletRequestAttributeListener>() {
+            public void invoke(ServletRequestAttributeListener listener) {
+                listener.attributeRemoved(event);
+            }
+        });
+    }
+
+    void requestAttributeReplaced(ServletRequest request, String name, Object value) {
+        final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(context, request, name, value);
+
+        fireEvent(REQUEST_ATTRIBUTE_LISTENER_CLASS, new EventInvoker<ServletRequestAttributeListener>() {
+            public void invoke(ServletRequestAttributeListener listener) {
+                listener.attributeReplaced(event);
+            }
+        });
+    }
+
+    /**
+     * This inner class links ServletContext calls to the server instance.
+     *
+     * @author asmirnov
+     *
+     */
+    private class LocalContext extends StagingServletContext {
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see javax.servlet.ServletContext#getMimeType(java.lang.String)
+         */
+        public String getMimeType(String file) {
+            int indexOfDot = file.lastIndexOf('.');
+
+            // get extension.
+            if (indexOfDot >= 0) {
+                file = file.substring(indexOfDot);
+            }
+
+            return mimeTypes.get(file);
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see
+         * org.richfaces.test.staging.StagingServletContext#valueBound(javax
+         * .servlet.ServletContextAttributeEvent)
+         */
+        @Override
+        protected void valueBound(ServletContextAttributeEvent event) {
+
+            // inform listeners.
+            for (EventListener listener : contextListeners) {
+                if (listener instanceof ServletContextAttributeListener) {
+                    ServletContextAttributeListener contextListener = (ServletContextAttributeListener) listener;
+
+                    contextListener.attributeAdded(event);
+                }
+            }
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see
+         * org.richfaces.test.staging.StagingServletContext#valueReplaced(javax
+         * .servlet.ServletContextAttributeEvent)
+         */
+        @Override
+        protected void valueReplaced(ServletContextAttributeEvent event) {
+
+            // inform listeners.
+            for (EventListener listener : contextListeners) {
+                if (listener instanceof ServletContextAttributeListener) {
+                    ServletContextAttributeListener contextListener = (ServletContextAttributeListener) listener;
+
+                    contextListener.attributeReplaced(event);
+                }
+            }
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see
+         * org.richfaces.test.staging.StagingServletContext#valueUnbound(javax
+         * .servlet.ServletContextAttributeEvent)
+         */
+        @Override
+        protected void valueUnbound(ServletContextAttributeEvent event) {
+
+            // inform listeners.
+            for (EventListener listener : contextListeners) {
+                if (listener instanceof ServletContextAttributeListener) {
+                    ServletContextAttributeListener contextListener = (ServletContextAttributeListener) listener;
+
+                    contextListener.attributeRemoved(event);
+                }
+            }
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see
+         * org.richfaces.test.staging.StagingServletContext#getServerResource
+         * (java.lang.String)
+         */
+        @Override
+        protected ServerResource getServerResource(String path) {
+            return serverRoot.getResource(new ServerResourcePath(path));
+        }
+    }
+
+
+    /**
+     * This inner class links session object calls to the server instance.
+     *
+     * @author asmirnov
+     *
+     */
+    private class ServerHttpSession extends StagingHttpSession {
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see javax.servlet.http.HttpSession#getServletContext()
+         */
+        public ServletContext getServletContext() {
+            return context;
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see
+         * org.richfaces.test.staging.StagingHttpSession#valueBound(javax.servlet
+         * .http.HttpSessionBindingEvent)
+         */
+        @Override
+        protected void valueBound(final HttpSessionBindingEvent sessionBindingEvent) {
+
+            // inform session listeners.
+            fireEvent(SESSION_ATTRIBUTE_LISTENER_CLASS, new EventInvoker<HttpSessionAttributeListener>() {
+                public void invoke(HttpSessionAttributeListener listener) {
+                    listener.attributeAdded(sessionBindingEvent);
+                }
+            });
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see
+         * org.richfaces.test.staging.StagingHttpSession#valueUnbound(javax.
+         * servlet.http.HttpSessionBindingEvent)
+         */
+        @Override
+        protected void valueUnbound(final HttpSessionBindingEvent sessionBindingEvent) {
+
+            // inform session listeners.
+            fireEvent(SESSION_ATTRIBUTE_LISTENER_CLASS, new EventInvoker<HttpSessionAttributeListener>() {
+                public void invoke(HttpSessionAttributeListener listener) {
+                    listener.attributeRemoved(sessionBindingEvent);
+                }
+            });
+        }
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see
+         * org.richfaces.test.staging.StagingHttpSession#valueReplaced(javax
+         * .servlet.http.HttpSessionBindingEvent)
+         */
+        @Override
+        protected void valueReplaced(final HttpSessionBindingEvent sessionBindingEvent) {
+
+            // inform session listeners.
+            fireEvent(SESSION_ATTRIBUTE_LISTENER_CLASS, new EventInvoker<HttpSessionAttributeListener>() {
+                public void invoke(HttpSessionAttributeListener listener) {
+                    listener.attributeReplaced(sessionBindingEvent);
+                }
+            });
+        }
+
+        @Override
+        public void invalidate() {
+            super.invalidate();
+            setCurrentSession(null);
+        }
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingServletContext.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingServletContext.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StagingServletContext.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,12 +1,15 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
 import java.io.IOException;
 import java.io.InputStream;
+
 import java.net.MalformedURLException;
 import java.net.URL;
+
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -23,277 +26,318 @@
 import javax.servlet.ServletContextAttributeEvent;
 import javax.servlet.ServletException;
 
-
 /**
  * @author asmirnov
  *
  */
 abstract class StagingServletContext implements ServletContext {
-	
-	private static final Logger log = ServerLogger.SERVER.getLogger();
+    private static final String APPLICATION_NAME = "stub";
+    public static final String CONTEXT_PATH = "";
+    private static final Logger LOG = ServerLogger.SERVER.getLogger();
+    private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
+    private final Map<String, String> initParameters = new HashMap<String, String>();
 
-	public static final String CONTEXT_PATH = "";
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name) {
+        return attributes.get(name);
+    }
 
-	private static final String APPLICATION_NAME = "stub";
-	private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
-	private final Map<String,String> initParameters = new HashMap<String, String>();
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getAttributeNames()
+     */
+    @SuppressWarnings("unchecked")
+    public Enumeration getAttributeNames() {
+        return Collections.enumeration(attributes.keySet());
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getAttribute(java.lang.String)
-	 */
-	public Object getAttribute(String name) {
-		return attributes.get(name);
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getContext(java.lang.String)
+     */
+    public ServletContext getContext(String uripath) {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getAttributeNames()
-	 */
-	@SuppressWarnings("unchecked")
-	public Enumeration getAttributeNames() {
-		return Collections.enumeration(attributes.keySet());
-	}
+        // stub server has only one context.
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getContext(java.lang.String)
-	 */
-	public ServletContext getContext(String uripath) {
-		// stub server has only one context.
-		return null;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getContextPath()
+     */
+    public String getContextPath() {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getContextPath()
-	 */
-	public String getContextPath() {
-		// Test always run in the root context.
-		return CONTEXT_PATH;
-	}
+        // Test always run in the root context.
+        return CONTEXT_PATH;
+    }
 
-	public void addInitParameters(Map<String,String>parameters) {
-		initParameters.putAll(parameters);
-	}
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getInitParameter(java.lang.String)
-	 */
-	public String getInitParameter(String name) {
-		return initParameters.get(name);
-	}
+    public void addInitParameters(Map<String, String> parameters) {
+        initParameters.putAll(parameters);
+    }
 
-	
-	/**
-	 * Put new init parameter to the Map.
-	 * @param name
-	 * @param value
-	 */
-	public void setInitParameter(String name, String value) {
-		initParameters.put(name, value);
-	}
-	
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getInitParameterNames()
-	 */
-	@SuppressWarnings("unchecked")
-	public Enumeration getInitParameterNames() {
-		return Collections.enumeration(initParameters.keySet());
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getInitParameter(java.lang.String)
+     */
+    public String getInitParameter(String name) {
+        return initParameters.get(name);
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getMajorVersion()
-	 */
-	public int getMajorVersion() {
-		return 2;
-	}
+    /**
+     * Put new init parameter to the Map.
+     * @param name
+     * @param value
+     */
+    public void setInitParameter(String name, String value) {
+        initParameters.put(name, value);
+    }
 
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getInitParameterNames()
+     */
+    @SuppressWarnings("unchecked")
+    public Enumeration getInitParameterNames() {
+        return Collections.enumeration(initParameters.keySet());
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getMinorVersion()
-	 */
-	public int getMinorVersion() {
-		return 5;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getMajorVersion()
+     */
+    public int getMajorVersion() {
+        return 2;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
-	 */
-	public RequestDispatcher getNamedDispatcher(String name) {
-		// TODO create stub dispatcher.
-		log.info("unimplemented response method getNamedDispatcher");
-		return null;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getMinorVersion()
+     */
+    public int getMinorVersion() {
+        return 5;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getRealPath(java.lang.String)
-	 */
-	public String getRealPath(String path) {
-		// we always use 'virtual' configuration.
-		return null;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
+     */
+    public RequestDispatcher getNamedDispatcher(String name) {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getRequestDispatcher(java.lang.String)
-	 */
-	public RequestDispatcher getRequestDispatcher(String path) {
-		// TODO implement stub dispatcher.
-		log.info("unimplemented response method getRequestDispatcher");
-		return null;
-	}
+        // TODO create stub dispatcher.
+        LOG.info("unimplemented response method getNamedDispatcher");
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getResource(java.lang.String)
-	 */
-	public URL getResource(String path) throws MalformedURLException {
-		URL url = null;
-		ServerResource resource = getServerResource(path);
-		if(null != resource){
-			url = resource.getURL();
-		}
-		return url;
-	}
+        return null;
+    }
 
-	/**
-	 * @param path
-	 * @return
-	 */
-	protected abstract ServerResource getServerResource(String path);
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getRealPath(java.lang.String)
+     */
+    public String getRealPath(String path) {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
-	 */
-	public InputStream getResourceAsStream(String path) {
-		ServerResource resource = getServerResource(path);
-		if(null != resource){
-			try {
-				return resource.getAsStream();
-			} catch (IOException e) {
-				return null;
-			}
-		}
-		return null;
-	}
+        // we always use 'virtual' configuration.
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
-	 */
-	@SuppressWarnings("unchecked")
-	public Set getResourcePaths(String path) {
-		HashSet result=null;
-		ServerResource resource = getServerResource(path);
-		if(null == resource && !path.endsWith("/")){
-			path+="/";
-			resource = getServerResource(path);
-		}
-		if(null != resource){
-			Set<String> paths = resource.getPaths();
-			if(null != paths && paths.size()>0){
-				result = new HashSet(paths.size());
-				for (String resourcePath : paths) {
-					result.add(path+resourcePath);
-				}
-			}
-		}
-		return result;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getRequestDispatcher(java.lang.String)
+     */
+    public RequestDispatcher getRequestDispatcher(String path) {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getServerInfo()
-	 */
-	public String getServerInfo() {
-		return "Stub test server";
-	}
+        // TODO implement stub dispatcher.
+        LOG.info("unimplemented response method getRequestDispatcher");
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getServlet(java.lang.String)
-	 */
-	public Servlet getServlet(String name) throws ServletException {
-		// always return null.
-		log.info("unimplemented response method getServlet");
-		return null;
-	}
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getServletContextName()
-	 */
-	public String getServletContextName() {
-		// Stub server has no declared name.
-		return APPLICATION_NAME;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getResource(java.lang.String)
+     */
+    public URL getResource(String path) throws MalformedURLException {
+        URL url = null;
+        ServerResource resource = getServerResource(path);
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getServletNames()
-	 */
-	@SuppressWarnings("unchecked")
-	public Enumeration getServletNames() {
-		log.info("unimplemented response method getServletNames");
-		return Collections.enumeration(Collections.EMPTY_LIST);
-	}
+        if (null != resource) {
+            url = resource.getURL();
+        }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getServlets()
-	 */
-	@SuppressWarnings("unchecked")
-	public Enumeration getServlets() {
-		log.info("unimplemented response method getServlets");
-		return Collections.enumeration(Collections.EMPTY_LIST);
-	}
+        return url;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#log(java.lang.String)
-	 */
-	public void log(String msg) {
-		log.finest(msg);
+    /**
+     * @param path
+     * @return
+     */
+    protected abstract ServerResource getServerResource(String path);
 
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
+     */
+    public InputStream getResourceAsStream(String path) {
+        ServerResource resource = getServerResource(path);
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#log(java.lang.Exception, java.lang.String)
-	 */
-	public void log(Exception exception, String msg) {
-		log.log(Level.FINEST, msg, exception);
+        if (null != resource) {
+            try {
+                return resource.getAsStream();
+            } catch (IOException e) {
+                return null;
+            }
+        }
 
-	}
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#log(java.lang.String, java.lang.Throwable)
-	 */
-	public void log(String message, Throwable throwable) {
-		log.log(Level.FINEST, message, throwable);
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
+     */
+    @SuppressWarnings("unchecked")
+    public Set getResourcePaths(String path) {
+        String tmpPath = path;
+        ServerResource resource = getServerResource(tmpPath);
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#removeAttribute(java.lang.String)
-	 */
-	public void removeAttribute(String name) {
-		// TODO - inform listeners
-		Object removed = attributes.remove(name);
-		if(null != removed){
-			valueUnbound(new ServletContextAttributeEvent(this,name,removed));
-		}
-	}
+        if (null == resource && !tmpPath.endsWith("/")) {
+            tmpPath += "/";
+            resource = getServerResource(tmpPath);
+        }
 
+        Set<String> result = null;
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#setAttribute(java.lang.String, java.lang.Object)
-	 */
-	public void setAttribute(String name, Object object) {
-		// TODO - inform listeners
-		if (null == object) {
-			removeAttribute(name);
-		} else {
-			Object oldValue = attributes.put(name, object);
-			ServletContextAttributeEvent event = new ServletContextAttributeEvent(this,name,object);
-			if(null != oldValue){
-				valueReplaced(event);
-			} else {
-				valueBound(event);
-			}
-		}
-	}
+        if (null != resource) {
+            Set<String> paths = resource.getPaths();
 
-	protected abstract void valueBound(ServletContextAttributeEvent event);
+            if (null != paths && paths.size() > 0) {
+                result = new HashSet(paths.size());
 
-	protected abstract void valueReplaced(ServletContextAttributeEvent event);
+                for (String resourcePath : paths) {
+                    result.add(tmpPath + resourcePath);
+                }
+            }
+        }
 
-	protected abstract void valueUnbound(
-			ServletContextAttributeEvent servletContextAttributeEvent);
+        return result;
+    }
 
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getServerInfo()
+     */
+    public String getServerInfo() {
+        return "Stub test server";
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getServlet(java.lang.String)
+     */
+    public Servlet getServlet(String name) throws ServletException {
+
+        // always return null.
+        LOG.info("unimplemented response method getServlet");
+
+        return null;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getServletContextName()
+     */
+    public String getServletContextName() {
+
+        // Stub server has no declared name.
+        return APPLICATION_NAME;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getServletNames()
+     */
+    @SuppressWarnings("unchecked")
+    public Enumeration getServletNames() {
+        LOG.info("unimplemented response method getServletNames");
+
+        return Collections.enumeration(Collections.EMPTY_LIST);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getServlets()
+     */
+    @SuppressWarnings("unchecked")
+    public Enumeration getServlets() {
+        LOG.info("unimplemented response method getServlets");
+
+        return Collections.enumeration(Collections.EMPTY_LIST);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#log(java.lang.String)
+     */
+    public void log(String msg) {
+        LOG.finest(msg);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#log(java.lang.Exception, java.lang.String)
+     */
+    public void log(Exception exception, String msg) {
+        LOG.log(Level.FINEST, msg, exception);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#log(java.lang.String, java.lang.Throwable)
+     */
+    public void log(String message, Throwable throwable) {
+        LOG.log(Level.FINEST, message, throwable);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#removeAttribute(java.lang.String)
+     */
+    public void removeAttribute(String name) {
+
+        // TODO - inform listeners
+        Object removed = attributes.remove(name);
+
+        if (null != removed) {
+            valueUnbound(new ServletContextAttributeEvent(this, name, removed));
+        }
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#setAttribute(java.lang.String, java.lang.Object)
+     */
+    public void setAttribute(String name, Object object) {
+
+        // TODO - inform listeners
+        if (null == object) {
+            removeAttribute(name);
+        } else {
+            Object oldValue = attributes.put(name, object);
+            ServletContextAttributeEvent event = new ServletContextAttributeEvent(this, name, object);
+
+            if (null != oldValue) {
+                valueReplaced(event);
+            } else {
+                valueBound(event);
+            }
+        }
+    }
+
+    protected abstract void valueBound(ServletContextAttributeEvent event);
+
+    protected abstract void valueReplaced(ServletContextAttributeEvent event);
+
+    protected abstract void valueUnbound(ServletContextAttributeEvent servletContextAttributeEvent);
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StaticServlet.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StaticServlet.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/StaticServlet.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
@@ -18,33 +19,36 @@
  */
 @SuppressWarnings("serial")
 public class StaticServlet extends HttpServlet {
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        InputStream inputStream = getServletContext().getResourceAsStream(req.getServletPath());
 
-	@Override
-	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
-			throws ServletException, IOException {
-		InputStream inputStream = getServletContext().getResourceAsStream(req.getServletPath());
-		if(null != inputStream){
-			String fileName = req.getServletPath();
-			String mimeType = getServletContext().getMimeType(fileName);
-			if(null == mimeType){
-				mimeType = "text/plain";
-			}
-			resp.setContentType(mimeType);
-			ServletOutputStream outputStream = resp.getOutputStream();
-			int c;
-			while((c = inputStream.read())>0){
-				outputStream.write(c);
-			}
-			inputStream.close();
-			outputStream.close();
-		} else {
-			resp.sendError(404, "not found");
-		}
-	}
-	
-	@Override
-	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
-			throws ServletException, IOException {
-		doGet(req, resp);
-	}
+        if (null != inputStream) {
+            String fileName = req.getServletPath();
+            String mimeType = getServletContext().getMimeType(fileName);
+
+            if (null == mimeType) {
+                mimeType = "text/plain";
+            }
+
+            resp.setContentType(mimeType);
+
+            ServletOutputStream outputStream = resp.getOutputStream();
+            int c;
+
+            while ((c = inputStream.read()) > 0) {
+                outputStream.write(c);
+            }
+
+            inputStream.close();
+            outputStream.close();
+        } else {
+            resp.sendError(404, "not found");
+        }
+    }
+
+    @Override
+    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        doGet(req, resp);
+    }
 }

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/URLScanner.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/URLScanner.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/URLScanner.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
@@ -7,6 +8,4 @@
  * @author asmirnov
  *
  */
-public class URLScanner {
-
-}
+public class URLScanner {}

Modified: root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/UrlServerResource.java
===================================================================
--- root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/UrlServerResource.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/main/java/org/richfaces/test/staging/UrlServerResource.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,38 +1,38 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
 import java.net.URL;
+
 import java.util.logging.Logger;
 
-
 /**
  * This class represent file-like virtual web application object, loaded from the any URL.
  * @author asmirnov
  *
  */
 public class UrlServerResource extends AbstractServerResource {
+    static final Logger LOG = ServerLogger.RESOURCE.getLogger();
 
-	/**
-	 * Resource target URL
-	 */
-	private final URL resource;
-	
-	static final Logger log = ServerLogger.RESOURCE.getLogger();
+    /**
+     * Resource target URL
+     */
+    private final URL resource;
 
-	/**
-	 * @param resource url to the resource content.
-	 */
-	public UrlServerResource(URL resource) {
-		this.resource = resource;
-	}
+    /**
+     * @param resource url to the resource content.
+     */
+    public UrlServerResource(URL resource) {
+        this.resource = resource;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.staging.ServerResource#getURL()
-	 */
-	public URL getURL() {
-		return resource;
-	}
-
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.staging.ServerResource#getURL()
+     */
+    public URL getURL() {
+        return resource;
+    }
 }

Modified: root/framework/trunk/test-base/src/test/java/org/richfaces/test/FacesServerTest.java
===================================================================
--- root/framework/trunk/test-base/src/test/java/org/richfaces/test/FacesServerTest.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/test/java/org/richfaces/test/FacesServerTest.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,9 +1,11 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test;
 
 import java.io.IOException;
+
 import java.net.MalformedURLException;
 
 import javax.servlet.http.HttpSession;
@@ -11,6 +13,7 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+
 import org.w3c.dom.Element;
 
 import com.gargoylesoftware.htmlunit.WebClient;
@@ -21,73 +24,84 @@
 
 /**
  * @author asmirnov
- * 
+ *
  */
 public class FacesServerTest extends AbstractFacesTest {
 
+    /**
+     * @throws java.lang.Exception
+     */
+    @Before
+    public void setUpTest() throws Exception {}
 
-	/**
-	 * @throws java.lang.Exception
-	 */
-	@Before
-	public void setUpTest() throws Exception {
-	}
+    @Override
+    protected void setupWebContent() {
+        facesServer.addResource("/WEB-INF/faces-config.xml", "org/richfaces/test/WEB-INF/faces-config.xml");
+        facesServer.addResource("/hello.xhtml", "org/richfaces/test/hello.xhtml");
+        facesServer.addResource("/response.xhtml", "org/richfaces/test/response.xhtml");
+        facesServer.addResource("/wave.med.gif", "org/richfaces/test/wave.med.gif");
+    }
 
-	@Override
-	protected void setupWebContent() {
-		facesServer.addResource("/WEB-INF/faces-config.xml", "org/richfaces/test/WEB-INF/faces-config.xml");
-		facesServer.addResource("/hello.xhtml", "org/richfaces/test/hello.xhtml");
-		facesServer.addResource("/response.xhtml", "org/richfaces/test/response.xhtml");
-		facesServer.addResource("/wave.med.gif", "org/richfaces/test/wave.med.gif");
-	}
-	/**
-	 * @throws java.lang.Exception
-	 */
-	@After
-	public void tearDownTest() throws Exception {
-	}
+    /**
+     * @throws java.lang.Exception
+     */
+    @After
+    public void tearDownTest() throws Exception {}
 
-	/**
-	 * Test method for
-	 * {@link org.richfaces.test.staging.StagingServer#getConnection(java.net.URL)}.
-	 * 
-	 * @throws Exception
-	 */
-	@Test
-	public void testHelloFacelets() throws Exception {
-		HtmlPage page = getPage("/hello.jsf");
-		System.out.println(page.asXml());		
-		Element submitElement = page.getElementById("helloForm:submit");
-		HtmlForm htmlForm = page.getFormByName("helloForm");
-		htmlForm.getInputByName("helloForm:username");
-		assertNotNull(htmlForm);
-		HtmlInput input = htmlForm.getInputByName("helloForm:username");
-		assertNotNull(input);
-		input.setValueAttribute("foo");
-		HtmlPage responsePage = (HtmlPage) htmlForm.submit((SubmittableElement) submitElement);
-		assertNotNull(responsePage);
-		System.out.println(responsePage.asXml());		
-		HttpSession session = facesServer.getSession(false);
-		assertNotNull(session);
-		HelloBean bean = (HelloBean) session.getAttribute("HelloBean");
-		assertNotNull(bean);
-		assertEquals("foo", bean.getName());
-		Element span = responsePage.getElementById("responseform:userLabel");
-		assertNotNull(span);
-		assertEquals("foo", span.getTextContent().trim());		
-	}
+    /**
+     * Test method for
+     * {@link org.richfaces.test.staging.StagingServer#getConnection(java.net.URL)}.
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testHelloFacelets() throws Exception {
+        HtmlPage page = getPage("/hello.jsf");
 
-	/**
-	 * <p class="changed_added_2_0"></p>
-	 * @param url TODO
-	 * @return
-	 * @throws IOException
-	 * @throws MalformedURLException
-	 */
-	protected HtmlPage getPage(String url) throws Exception {
-		WebClient webClient = new LocalWebClient(facesServer);
-		HtmlPage page = webClient.getPage("http://localhost"+url);
-		return page;
-	}
+        System.out.println(page.asXml());
 
+        Element submitElement = page.getElementById("helloForm:submit");
+        HtmlForm htmlForm = page.getFormByName("helloForm");
+
+        htmlForm.getInputByName("helloForm:username");
+        assertNotNull(htmlForm);
+
+        HtmlInput input = htmlForm.getInputByName("helloForm:username");
+
+        assertNotNull(input);
+        input.setValueAttribute("foo");
+
+        HtmlPage responsePage = (HtmlPage) htmlForm.submit((SubmittableElement) submitElement);
+
+        assertNotNull(responsePage);
+        System.out.println(responsePage.asXml());
+
+        HttpSession session = facesServer.getSession(false);
+
+        assertNotNull(session);
+
+        HelloBean bean = (HelloBean) session.getAttribute("HelloBean");
+
+        assertNotNull(bean);
+        assertEquals("foo", bean.getName());
+
+        Element span = responsePage.getElementById("responseform:userLabel");
+
+        assertNotNull(span);
+        assertEquals("foo", span.getTextContent().trim());
+    }
+
+    /**
+     * <p class="changed_added_2_0"></p>
+     * @param url TODO
+     * @return
+     * @throws IOException
+     * @throws MalformedURLException
+     */
+    protected HtmlPage getPage(String url) throws Exception {
+        WebClient webClient = new LocalWebClient(facesServer);
+        HtmlPage page = webClient.getPage("http://localhost" + url);
+
+        return page;
+    }
 }

Modified: root/framework/trunk/test-base/src/test/java/org/richfaces/test/HelloBean.java
===================================================================
--- root/framework/trunk/test-base/src/test/java/org/richfaces/test/HelloBean.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/test/java/org/richfaces/test/HelloBean.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -3,13 +3,15 @@
 import java.io.Serializable;
 
 public class HelloBean implements Serializable {
+    private String name;
 
-    private String name;
-    
-   public HelloBean() {}
-    
-   public String getName() { return name;}
-   
-   public void setName(String name) { this.name = name; }
-   
+    public HelloBean() {}
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
 }

Modified: root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java
===================================================================
--- root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/ServerResourcePathTest.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,11 +1,13 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
 import static org.junit.Assert.*;
 
 import org.junit.Test;
+
 import org.richfaces.test.staging.ServerResourcePath;
 
 /**
@@ -14,81 +16,84 @@
  */
 public class ServerResourcePathTest {
 
-	/**
-	 * Test method for {@link org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
-	 */
-	@Test
-	public void testRootPath() {
-		ServerResourcePath path = new ServerResourcePath("/");
-		assertNull(path.getNextPath());
-		assertNull(path.getNextElementName());
-		assertTrue(path.isFile());
-		assertEquals("/", path.toString());
-	}
+    /**
+     * Test method for {@link org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
+     */
+    @Test
+    public void testRootPath() {
+        ServerResourcePath path = new ServerResourcePath("/");
 
-	/**
-	 * Test method for {@link org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
-	 */
-	@Test
-	public void testWebInfPath() {
-		ServerResourcePath path = ServerResourcePath.WEB_INF;
-		assertNotNull(path.getNextPath());
-		assertNotNull(path.getNextElementName());
-		assertFalse(path.isFile());
-		assertEquals("WEB-INF/", path.getNextElementName());
-		assertEquals("/WEB-INF/", path.toString());
-		path = path.getNextPath();
-		assertNotNull(path);
-		assertTrue(path.isFile());
-		path = path.getNextPath();
-		assertNull(path);
-	}
+        assertNull(path.getNextPath());
+        assertNull(path.getNextElementName());
+        assertTrue(path.isFile());
+        assertEquals("/", path.toString());
+    }
 
-	/**
-	 * Test method for {@link org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
-	 */
-	@Test
-	public void testWebInfTrainingSlashPath() {
-		ServerResourcePath path = new ServerResourcePath("/WEB-INF/");
-		assertNotNull(path.getNextPath());
-		assertNotNull(path.getNextElementName());
-		assertFalse(path.isFile());
-		assertEquals("WEB-INF/", path.getNextElementName());
-		assertEquals("/WEB-INF/", path.toString());
-		path = path.getNextPath();
-		assertNotNull(path);
-		assertTrue(path.isFile());
-		path = path.getNextPath();
-		assertNull(path);
-	}
+    /**
+     * Test method for {@link org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
+     */
+    @Test
+    public void testWebInfPath() {
+        ServerResourcePath path = ServerResourcePath.WEB_INF;
 
-	
-	/**
-	 * Test method for {@link org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
-	 */
-	@Test
-	public void testWebXmlPath() {
-		ServerResourcePath path = ServerResourcePath.WEB_XML;
-		assertFalse(path.isFile());
-		assertEquals("WEB-INF/", path.getNextElementName());
-		assertEquals("/WEB-INF/web.xml", path.toString());
-		path = path.getNextPath();
-		assertNotNull(path.getNextElementName());
-		assertFalse(path.isFile());
-		assertEquals("web.xml", path.getNextElementName());
-		assertEquals("/web.xml", path.toString());
-		path = path.getNextPath();
-		assertNotNull(path);
-		assertTrue(path.isFile());
-		path = path.getNextPath();
-		assertNull(path);
-	}
+        assertNotNull(path.getNextPath());
+        assertNotNull(path.getNextElementName());
+        assertFalse(path.isFile());
+        assertEquals("WEB-INF/", path.getNextElementName());
+        assertEquals("/WEB-INF/", path.toString());
+        path = path.getNextPath();
+        assertNotNull(path);
+        assertTrue(path.isFile());
+        path = path.getNextPath();
+        assertNull(path);
+    }
 
-	@Test
-	public void testDirPath() throws Exception {
-		ServerResourcePath path = new ServerResourcePath("/foo/bar");
-		assertEquals("foo/", path.getNextElementName());
-		assertEquals("bar", path.getNextPath().getNextElementName());
-	}
+    /**
+     * Test method for {@link org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
+     */
+    @Test
+    public void testWebInfTrainingSlashPath() {
+        ServerResourcePath path = new ServerResourcePath("/WEB-INF/");
 
+        assertNotNull(path.getNextPath());
+        assertNotNull(path.getNextElementName());
+        assertFalse(path.isFile());
+        assertEquals("WEB-INF/", path.getNextElementName());
+        assertEquals("/WEB-INF/", path.toString());
+        path = path.getNextPath();
+        assertNotNull(path);
+        assertTrue(path.isFile());
+        path = path.getNextPath();
+        assertNull(path);
+    }
+
+    /**
+     * Test method for {@link org.richfaces.test.staging.ServerResourcePath#ServerResourcePath(java.lang.String)}.
+     */
+    @Test
+    public void testWebXmlPath() {
+        ServerResourcePath path = ServerResourcePath.WEB_XML;
+
+        assertFalse(path.isFile());
+        assertEquals("WEB-INF/", path.getNextElementName());
+        assertEquals("/WEB-INF/web.xml", path.toString());
+        path = path.getNextPath();
+        assertNotNull(path.getNextElementName());
+        assertFalse(path.isFile());
+        assertEquals("web.xml", path.getNextElementName());
+        assertEquals("/web.xml", path.toString());
+        path = path.getNextPath();
+        assertNotNull(path);
+        assertTrue(path.isFile());
+        path = path.getNextPath();
+        assertNull(path);
+    }
+
+    @Test
+    public void testDirPath() throws Exception {
+        ServerResourcePath path = new ServerResourcePath("/foo/bar");
+
+        assertEquals("foo/", path.getNextElementName());
+        assertEquals("bar", path.getNextPath().getNextElementName());
+    }
 }

Modified: root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/ServerResourceTest.java
===================================================================
--- root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/ServerResourceTest.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/ServerResourceTest.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.test.staging;
 
@@ -7,10 +8,13 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+
 import java.net.URL;
+
 import java.util.Set;
 
 import org.junit.Test;
+
 import org.richfaces.test.staging.ClasspathServerResource;
 import org.richfaces.test.staging.ServerResource;
 import org.richfaces.test.staging.ServerResourcePath;
@@ -18,128 +22,132 @@
 
 /**
  * @author asmirnov
- * 
+ *
  */
 public class ServerResourceTest {
 
-	private class MockResource implements ServerResource {
+    /**
+     * Test method for
+     * {@link org.richfaces.test.staging.ServerResourcesDirectory#addResource(org.richfaces.test.staging.ServerResourcePath, org.richfaces.test.staging.ServerResource)}
+     * .
+     */
+    @Test
+    public void testAddResource() {
+        ServerResourcesDirectory root = new ServerResourcesDirectory();
+        MockResource webXml = new MockResource();
 
-		public void addResource(ServerResourcePath path, ServerResource resource) {
-		}
+        root.addResource(ServerResourcePath.WEB_XML, webXml);
+        assertEquals(1, root.getPaths().size());
 
-		public InputStream getAsStream() throws IOException {
-			return null;
-		}
+        MockResource facesConfig = new MockResource();
 
-		public Set<String> getPaths() {
-			return null;
-		}
+        root.addResource(ServerResourcePath.FACES_CONFIG, facesConfig);
+        assertEquals(1, root.getPaths().size());
 
-		public ServerResource getResource(ServerResourcePath path) {
-			if (null != path && path.isFile()) {
-				return this;
-			}
-			return null;
-		}
+        ServerResource webInf = root.getResource(ServerResourcePath.WEB_INF);
 
-		public URL getURL() {
-			return null;
-		}
+        assertNotNull(webInf);
+        assertEquals(2, webInf.getPaths().size());
+        assertSame(webXml, webInf.getResource(new ServerResourcePath("/web.xml")));
+        assertSame(facesConfig, webInf.getResource(new ServerResourcePath("/faces-config.xml")));
+    }
 
-	}
+    /**
+     * Test method for
+     * {@link org.richfaces.test.staging.ServerResourcesDirectory#getResource(org.richfaces.test.staging.ServerResourcePath)}
+     * .
+     */
+    @Test
+    public void testGetResource() {
+        ServerResourcesDirectory root = new ServerResourcesDirectory();
+        MockResource webXml = new MockResource();
 
-	/**
-	 * Test method for
-	 * {@link org.richfaces.test.staging.ServerResourcesDirectory#addResource(org.richfaces.test.staging.ServerResourcePath, org.richfaces.test.staging.ServerResource)}
-	 * .
-	 */
-	@Test
-	public void testAddResource() {
-		ServerResourcesDirectory root = new ServerResourcesDirectory();
-		MockResource webXml = new MockResource();
-		root.addResource(ServerResourcePath.WEB_XML, webXml);
-		assertEquals(1, root.getPaths().size());
-		MockResource facesConfig = new MockResource();
-		root.addResource(ServerResourcePath.FACES_CONFIG, facesConfig);
-		assertEquals(1, root.getPaths().size());
-		ServerResource webInf = root.getResource(ServerResourcePath.WEB_INF);
-		assertNotNull(webInf);
-		assertEquals(2, webInf.getPaths().size());
-		assertSame(webXml, webInf
-				.getResource(new ServerResourcePath("/web.xml")));
-		assertSame(facesConfig, webInf.getResource(new ServerResourcePath(
-				"/faces-config.xml")));
-	}
+        root.addResource(ServerResourcePath.WEB_XML, webXml);
 
-	/**
-	 * Test method for
-	 * {@link org.richfaces.test.staging.ServerResourcesDirectory#getResource(org.richfaces.test.staging.ServerResourcePath)}
-	 * .
-	 */
-	@Test
-	public void testGetResource() {
-		ServerResourcesDirectory root = new ServerResourcesDirectory();
-		MockResource webXml = new MockResource();
-		root.addResource(ServerResourcePath.WEB_XML, webXml);
-		ServerResource webInf = root.getResource(ServerResourcePath.WEB_INF);
-		assertNotNull(webInf);
-		assertNull(root.getResource(new ServerResourcePath("/foo")));
-		assertNull(root.getResource(new ServerResourcePath("/foo/baz")));
-		assertEquals(1, root.getPaths().size());
-		assertNull(root.getResource(new ServerResourcePath(
-				"/WEB-INF/web.xml/foo")));
-		assertSame(webXml, webInf.getResource(new ServerResourcePath(
-				"/web.xml")));
-	}
+        ServerResource webInf = root.getResource(ServerResourcePath.WEB_INF);
 
-	/**
-	 * Test method for
-	 * {@link org.richfaces.test.staging.ServerResourcesDirectory#getResource(org.richfaces.test.staging.ServerResourcePath)}
-	 * .
-	 */
-	@Test
-	public void testGetResourceRoot() {
-		ServerResourcesDirectory root = new ServerResourcesDirectory();
-		MockResource indexXhtml = new MockResource();
-		root.addResource(new ServerResourcePath("/index.xhtml"), indexXhtml);
-		ServerResource index = root.getResource(new ServerResourcePath("/index.xhtml"));
-		assertNotNull(index);
-		assertNull(root.getResource(new ServerResourcePath("/foo")));
-		assertNull(root.getResource(new ServerResourcePath("/foo/baz")));
-		assertEquals(1, root.getPaths().size());
-	}
-	
-	/**
-	 * Test method for
-	 * {@link org.richfaces.test.staging.ServerResourcesDirectory#getAsStream()}.
-	 * 
-	 * @throws IOException
-	 */
-	@Test
-	public void testGetAsStream() throws IOException {
-		ClasspathServerResource resource = new ClasspathServerResource(
-				"org/richfaces/test/resource.txt");
-		InputStream inputStream = resource.getAsStream();
-		assertNotNull(inputStream);
-		try {
-			byte[] buff = new byte[20];
-			assertEquals(3, inputStream.read(buff));
+        assertNotNull(webInf);
+        assertNull(root.getResource(new ServerResourcePath("/foo")));
+        assertNull(root.getResource(new ServerResourcePath("/foo/baz")));
+        assertEquals(1, root.getPaths().size());
+        assertNull(root.getResource(new ServerResourcePath("/WEB-INF/web.xml/foo")));
+        assertSame(webXml, webInf.getResource(new ServerResourcePath("/web.xml")));
+    }
 
-		} finally {
-			inputStream.close();			
-		}
-	}
+    /**
+     * Test method for
+     * {@link org.richfaces.test.staging.ServerResourcesDirectory#getResource(org.richfaces.test.staging.ServerResourcePath)}
+     * .
+     */
+    @Test
+    public void testGetResourceRoot() {
+        ServerResourcesDirectory root = new ServerResourcesDirectory();
+        MockResource indexXhtml = new MockResource();
 
+        root.addResource(new ServerResourcePath("/index.xhtml"), indexXhtml);
 
-	/**
-	 * Test method for
-	 * {@link org.richfaces.test.staging.ServerResourcesDirectory#getURL()}.
-	 */
-	@Test
-	public void testGetURL() {
-		ClasspathServerResource resource = new ClasspathServerResource(
-		"org/richfaces/test/resource.txt");
-		assertNotNull(resource.getURL());
-	}
+        ServerResource index = root.getResource(new ServerResourcePath("/index.xhtml"));
 
+        assertNotNull(index);
+        assertNull(root.getResource(new ServerResourcePath("/foo")));
+        assertNull(root.getResource(new ServerResourcePath("/foo/baz")));
+        assertEquals(1, root.getPaths().size());
+    }
+
+    /**
+     * Test method for
+     * {@link org.richfaces.test.staging.ServerResourcesDirectory#getAsStream()}.
+     *
+     * @throws IOException
+     */
+    @Test
+    public void testGetAsStream() throws IOException {
+        ClasspathServerResource resource = new ClasspathServerResource("org/richfaces/test/resource.txt");
+        InputStream inputStream = resource.getAsStream();
+
+        assertNotNull(inputStream);
+
+        try {
+            byte[] buff = new byte[20];
+
+            assertEquals(3, inputStream.read(buff));
+        } finally {
+            inputStream.close();
+        }
+    }
+
+    /**
+     * Test method for
+     * {@link org.richfaces.test.staging.ServerResourcesDirectory#getURL()}.
+     */
+    @Test
+    public void testGetURL() {
+        ClasspathServerResource resource = new ClasspathServerResource("org/richfaces/test/resource.txt");
+
+        assertNotNull(resource.getURL());
+    }
+
+    private class MockResource implements ServerResource {
+        public void addResource(ServerResourcePath path, ServerResource resource) {}
+
+        public InputStream getAsStream() throws IOException {
+            return null;
+        }
+
+        public Set<String> getPaths() {
+            return null;
+        }
+
+        public ServerResource getResource(ServerResourcePath path) {
+            if (null != path && path.isFile()) {
+                return this;
+            }
+
+            return null;
+        }
+
+        public URL getURL() {
+            return null;
+        }
+    }
 }

Modified: root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/ServletTest.java
===================================================================
--- root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/ServletTest.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/ServletTest.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -6,6 +6,7 @@
 import javax.servlet.ServletException;
 
 import org.junit.Test;
+
 import org.richfaces.test.staging.RequestChain;
 import org.richfaces.test.staging.ServerResource;
 import org.richfaces.test.staging.ServletContainer;
@@ -13,85 +14,83 @@
 import org.richfaces.test.staging.StagingServletContext;
 
 public class ServletTest {
+    @Test
+    public void testIsApplicable() {
+        StaticServlet staticServlet = new StaticServlet();
+        RequestChain servlet = new ServletContainer("/foo/*", staticServlet);
 
-	@Test
-	public void testIsApplicable() {
-		StaticServlet staticServlet = new StaticServlet();
-		RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
-		assertTrue(servlet.isApplicable("/foo/bar.jsf"));
-		assertFalse(servlet.isApplicable("/foz/bar.jsf"));
-		assertFalse(servlet.isApplicable("bar"));
-		servlet = new ServletContainer("*.jsf",staticServlet);
-		assertTrue(servlet.isApplicable("/foo/bar.jsf"));
-		assertFalse(servlet.isApplicable("bar"));
-		try {
-			servlet = new ServletContainer(".jsf",staticServlet);
-		} catch (IllegalArgumentException e) {
-			return;
-		}
-		assertFalse(true);
-	}
+        assertTrue(servlet.isApplicable("/foo/bar.jsf"));
+        assertFalse(servlet.isApplicable("/foz/bar.jsf"));
+        assertFalse(servlet.isApplicable("bar"));
+        servlet = new ServletContainer("*.jsf", staticServlet);
+        assertTrue(servlet.isApplicable("/foo/bar.jsf"));
+        assertFalse(servlet.isApplicable("bar"));
 
-	@Test
-	public void testGetServletPath() {
-		StaticServlet staticServlet = new StaticServlet();
-		RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
-		assertEquals("/foo/", servlet.getServletPath("/foo/bar.jsf"));
-		assertNull(servlet.getServletPath("/foz/bar.jsf"));
-		servlet = new ServletContainer("*.jsf",staticServlet);
-		assertEquals("/foo/bar.jsf", servlet.getServletPath("/foo/bar.jsf"));
-	}
+        try {
+            servlet = new ServletContainer(".jsf", staticServlet);
+        } catch (IllegalArgumentException e) {
+            return;
+        }
 
-	@Test
-	public void testGetPathInfo() {
-		StaticServlet staticServlet = new StaticServlet();
-		RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
-		assertEquals("bar.jsf", servlet.getPathInfo("/foo/bar.jsf"));
-		assertNull(servlet.getPathInfo("/foz/bar.jsf"));
-		servlet = new ServletContainer("*.jsf",staticServlet);
-		assertNull(servlet.getPathInfo("/foo/bar.jsf"));
+        assertFalse(true);
+    }
 
-	}
+    @Test
+    public void testGetServletPath() {
+        StaticServlet staticServlet = new StaticServlet();
+        RequestChain servlet = new ServletContainer("/foo/*", staticServlet);
 
-	@Test
-	public void testInit() throws ServletException {
-		StaticServlet staticServlet = new StaticServlet();
-		RequestChain servlet = new ServletContainer("/foo/*",staticServlet);
-		StagingServletContext context = new StagingServletContext(){
+        assertEquals("/foo/", servlet.getServletPath("/foo/bar.jsf"));
+        assertNull(servlet.getServletPath("/foz/bar.jsf"));
+        servlet = new ServletContainer("*.jsf", staticServlet);
+        assertEquals("/foo/bar.jsf", servlet.getServletPath("/foo/bar.jsf"));
+    }
 
-			@Override
-			protected ServerResource getServerResource(String path) {
-				// TODO Auto-generated method stub
-				return null;
-			}
+    @Test
+    public void testGetPathInfo() {
+        StaticServlet staticServlet = new StaticServlet();
+        RequestChain servlet = new ServletContainer("/foo/*", staticServlet);
 
-			@Override
-			protected void valueBound(ServletContextAttributeEvent event) {
-				// TODO Auto-generated method stub
-				
-			}
+        assertEquals("bar.jsf", servlet.getPathInfo("/foo/bar.jsf"));
+        assertNull(servlet.getPathInfo("/foz/bar.jsf"));
+        servlet = new ServletContainer("*.jsf", staticServlet);
+        assertNull(servlet.getPathInfo("/foo/bar.jsf"));
+    }
 
-			@Override
-			protected void valueReplaced(ServletContextAttributeEvent event) {
-				// TODO Auto-generated method stub
-				
-			}
+    @Test
+    public void testInit() throws ServletException {
+        StaticServlet staticServlet = new StaticServlet();
+        RequestChain servlet = new ServletContainer("/foo/*", staticServlet);
+        StagingServletContext context = new StagingServletContext() {
+            @Override
+            protected ServerResource getServerResource(String path) {
 
-			@Override
-			protected void valueUnbound(
-					ServletContextAttributeEvent servletContextAttributeEvent) {
-				// TODO Auto-generated method stub
-				
-			}
+                // TODO Auto-generated method stub
+                return null;
+            }
+            @Override
+            protected void valueBound(ServletContextAttributeEvent event) {
 
-			public String getMimeType(String file) {
-				// TODO Auto-generated method stub
-				return null;
-			}
-			
-		};
-		servlet.init(context);
-		assertSame(context,staticServlet.getServletContext());
-	}
+                // TODO Auto-generated method stub
+            }
+            @Override
+            protected void valueReplaced(ServletContextAttributeEvent event) {
 
+                // TODO Auto-generated method stub
+            }
+            @Override
+            protected void valueUnbound(ServletContextAttributeEvent servletContextAttributeEvent) {
+
+                // TODO Auto-generated method stub
+            }
+            public String getMimeType(String file) {
+
+                // TODO Auto-generated method stub
+                return null;
+            }
+        };
+
+        servlet.init(context);
+        assertSame(context, staticServlet.getServletContext());
+    }
 }

Modified: root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java
===================================================================
--- root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java	2009-11-02 12:03:55 UTC (rev 15807)
+++ root/framework/trunk/test-base/src/test/java/org/richfaces/test/staging/UrlResourceLoadingTest.java	2009-11-02 12:12:01 UTC (rev 15808)
@@ -3,8 +3,10 @@
 import static org.junit.Assert.*;
 
 import java.io.File;
+
 import java.net.URI;
 import java.net.URL;
+
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.zip.ZipEntry;
@@ -13,43 +15,49 @@
 import org.junit.Test;
 
 public class UrlResourceLoadingTest {
+    @Test
+    public void testAddFromJar() throws Exception {
+        URL resource = this.getClass().getClassLoader().getResource("java/util/Set.class");
 
-	@Test
-	public void testAddFromJar() throws Exception {
-		URL resource = this.getClass().getClassLoader().getResource("java/util/Set.class");
-		assertNotNull(resource);
-		StagingServer server = new StagingServer();
-		ServerResourcesDirectory baseDir = new ServerResourcesDirectory();
-		server.addResourcesFromJar(resource, baseDir);
-		assertNotNull(baseDir.getResource(new ServerResourcePath("/Map.class")));
-		assertNotNull(baseDir.getResource(new ServerResourcePath("/concurrent/atomic/AtomicBoolean.class")));
-	}
+        assertNotNull(resource);
 
-	@Test
-	public void testAddFromFile() throws Exception {
-		URL resource = this.getClass().getClassLoader().getResource("org/richfaces/test/resource.txt");
-		assertNotNull(resource);
-		StagingServer server = new StagingServer();
-		ServerResourcesDirectory baseDir = new ServerResourcesDirectory();
-		server.addResourcesFromFile(resource, baseDir);
-		assertNotNull(baseDir.getResource(new ServerResourcePath("/logging.properties")));
-		assertNotNull(baseDir.getResource(new ServerResourcePath("/WEB-INF/faces-config.xml")));
-	}
+        StagingServer server = new StagingServer();
+        ServerResourcesDirectory baseDir = new ServerResourcesDirectory();
 
-	
-	@Test
-	public void testGetDirectory()  throws Exception {
-		URL resource = this.getClass().getClassLoader().getResource("java/util/Set.class");
-		assertNotNull(resource);
-		StagingServer server = new StagingServer();
-		server.addResourcesFromDirectory("/WEB-INF/classes/java/util/", resource);
-		try {
-		server.init();
-		assertNotNull(server.getContext().getResource("/WEB-INF/classes/java/util/Map.class"));
-		} finally {
-			server.destroy();
-		}
-		
-	}
+        server.addResourcesFromJar(resource, baseDir);
+        assertNotNull(baseDir.getResource(new ServerResourcePath("/Map.class")));
+        assertNotNull(baseDir.getResource(new ServerResourcePath("/concurrent/atomic/AtomicBoolean.class")));
+    }
 
+    @Test
+    public void testAddFromFile() throws Exception {
+        URL resource = this.getClass().getClassLoader().getResource("org/richfaces/test/resource.txt");
+
+        assertNotNull(resource);
+
+        StagingServer server = new StagingServer();
+        ServerResourcesDirectory baseDir = new ServerResourcesDirectory();
+
+        server.addResourcesFromFile(resource, baseDir);
+        assertNotNull(baseDir.getResource(new ServerResourcePath("/logging.properties")));
+        assertNotNull(baseDir.getResource(new ServerResourcePath("/WEB-INF/faces-config.xml")));
+    }
+
+    @Test
+    public void testGetDirectory() throws Exception {
+        URL resource = this.getClass().getClassLoader().getResource("java/util/Set.class");
+
+        assertNotNull(resource);
+
+        StagingServer server = new StagingServer();
+
+        server.addResourcesFromDirectory("/WEB-INF/classes/java/util/", resource);
+
+        try {
+            server.init();
+            assertNotNull(server.getContext().getResource("/WEB-INF/classes/java/util/Map.class"));
+        } finally {
+            server.destroy();
+        }
+    }
 }



More information about the richfaces-svn-commits mailing list