[richfaces-svn-commits] JBoss Rich Faces SVN: r15806 - in root/framework/trunk/impl/src: main/java/org/richfaces/renderkit/html and 25 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Nov 2 06:33:51 EST 2009


Author: Alex.Kolonitsky
Date: 2009-11-02 06:33:49 -0500 (Mon, 02 Nov 2009)
New Revision: 15806

Added:
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/Test.java
   root/framework/trunk/impl/src/test/java/org/richfaces/json/Test.java
Modified:
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/AttributeParametersEncoder.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/Expression.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/RendererContributor.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/ScriptOptionsContributor.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/Base2WayGradient.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/GradientA.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ButtonDisabledBackgroundImage.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/GradientAlignment.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/GradientType.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/package-info.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/package-info.java
   root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/package-info.java
   root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
   root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractCacheableResource.java
   root/framework/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java
   root/framework/trunk/impl/src/main/java/org/richfaces/resource/CachedResourceImpl.java
   root/framework/trunk/impl/src/main/java/org/richfaces/resource/DefaultResourceCodec.java
   root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceCodec.java
   root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
   root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceUtils.java
   root/framework/trunk/impl/src/main/java/org/richfaces/skin/AbstractChainableSkinImpl.java
   root/framework/trunk/impl/src/main/java/org/richfaces/skin/BasicSkinImpl.java
   root/framework/trunk/impl/src/main/java/org/richfaces/skin/DefaultSkinImpl.java
   root/framework/trunk/impl/src/main/java/org/richfaces/skin/DummySkinConfiguration.java
   root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinBean.java
   root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
   root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinPropertyResolver.java
   root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinVariableResolver.java
   root/framework/trunk/impl/src/main/java/org/richfaces/skin/ThemeImpl.java
   root/framework/trunk/impl/src/main/java/org/richfaces/skin/package-info.java
   root/framework/trunk/impl/src/main/java/org/richfaces/util/CollectionsUtils.java
   root/framework/trunk/impl/src/main/java/org/richfaces/util/ReferenceMap.java
   root/framework/trunk/impl/src/main/java/org/richfaces/util/RequestStateManager.java
   root/framework/trunk/impl/src/main/java/org/richfaces/util/Util.java
   root/framework/trunk/impl/src/main/java/org/richfaces/util/package-info.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/BaseCacheTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/EhCacheTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/JBossCacheTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/LRUMapCacheTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/OsCacheTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/codec/CodecTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/FacesConfigTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/FrameworkConfigurationTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/MockServletContext.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/MockXmlReader.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/StateHandlerTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/WebXMLTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/WebappHandlerTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/context/InitParametersTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/css/CssCompressorTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/event/EventsQueueTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferOutputStreamTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferWriterTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/javascript/JSMinTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/renderkit/RendererUtilsTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/resource/cached/DualLRUMapTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/util/LRUMapTest.java
   root/framework/trunk/impl/src/test/java/org/ajax4jsf/util/NumericStreamsTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/component/nsutils/NSUtilsTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/component/util/ComponentUtilTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/component/util/FormUtilTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/javascript/QUnitTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/json/JsonTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/json/SerializationTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/CompositeRendererTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/html/images/GradientEnumsTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractCacheableResourceTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java
   root/framework/trunk/impl/src/test/java/org/richfaces/resource/CachedResourceImplTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/resource/EmptyStreamResource.java
   root/framework/trunk/impl/src/test/java/org/richfaces/resource/MarkerFileResourceImpl.java
   root/framework/trunk/impl/src/test/java/org/richfaces/resource/NoMarkerFileResourceImpl.java
   root/framework/trunk/impl/src/test/java/org/richfaces/resource/NonCacheableResourceImpl.java
   root/framework/trunk/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/resource/ResourceUtilsTest.java
   root/framework/trunk/impl/src/test/java/org/richfaces/resource/StateHolderResourceImpl.java
   root/framework/trunk/impl/src/test/java/org/richfaces/resource/VersionedResourceImpl.java
   root/framework/trunk/impl/src/test/java/org/richfaces/skin/Bean.java
   root/framework/trunk/impl/src/test/java/org/richfaces/skin/SkinTestCase.java
   root/framework/trunk/impl/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java
Log:
Code style policy
https://jira.jboss.org/jira/browse/RFPL-195

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/AttributeParametersEncoder.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/AttributeParametersEncoder.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/AttributeParametersEncoder.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit;
 
 import java.io.IOException;
@@ -29,8 +31,8 @@
 /**
  * @author Nick Belaevski - nbelaevski at exadel.com
  * created 30.01.2007
- * 
+ *
  */
 public interface AttributeParametersEncoder {
-	public void doEncode(FacesContext context, UIComponent component) throws IOException;
+    public void doEncode(FacesContext context, UIComponent component) throws IOException;
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,9 +19,14 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit;
 
+import org.ajax4jsf.renderkit.AjaxChildrenRenderer;
+
 import java.io.IOException;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -29,132 +34,120 @@
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 
-import org.ajax4jsf.renderkit.AjaxChildrenRenderer;
-
 /**
  * @author Nick Belaevski - nbelaevski at exadel.com
  * created 18.12.2006
- * 
+ *
  */
 public abstract class CompositeRenderer extends AjaxChildrenRenderer {
-	private List<RendererContributor> renderers = new ArrayList<RendererContributor>();
+    private static final Command MERGE_OPTIONS_COMMAND = new Command() {
+        @Override
+        protected void execute(RendererContributor renderer, FacesContext context, UIComponent component,
+                               Object argument) {
+            ScriptOptions initialOptions = (ScriptOptions) argument;
+            ScriptOptions builtOptions = renderer.buildOptions(context, component);
 
-	private List<AttributeParametersEncoder> parameterEncoders = new ArrayList<AttributeParametersEncoder>();
-	
-	private abstract static class Command {
-		protected final void execute(Iterator<?> renderers, 
-				FacesContext facesContext, 
-				UIComponent component,
-				Object argument,
-				Class<?> clazz) {
+            if (builtOptions != null) {
+                initialOptions.merge(builtOptions);
+            }
+        }
+    };
+    private static final Command GET_SCRIPT_CONTRIBUTIONS = new Command() {
+        @Override
+        protected void execute(RendererContributor renderer, FacesContext context, UIComponent component,
+                               Object argument) {
+            String contribution = renderer.getScriptContribution(context, component);
 
-			while (renderers.hasNext()) {
-				RendererContributor contributor = (RendererContributor) renderers.next();
-				Class<?> acceptableClass = contributor.getAcceptableClass();
-				if (clazz == null || acceptableClass == null || acceptableClass.isAssignableFrom(clazz)) {
-					execute(contributor, facesContext, component, argument);
-				}
-			}
-		}
+            if (contribution != null) {
+                ((List<String>) argument).add(contribution);
+            }
+        }
+    };
+    private List<RendererContributor> renderers = new ArrayList<RendererContributor>();
+    private List<AttributeParametersEncoder> parameterEncoders = new ArrayList<AttributeParametersEncoder>();
+    private final Command decodeCommand = new Command() {
+        @Override
+        protected void execute(RendererContributor renderer, FacesContext context, UIComponent component,
+                               Object argument) {
+            renderer.decode(context, component, CompositeRenderer.this);
+        }
+    };
 
-		protected abstract void execute(RendererContributor renderer, 
-				FacesContext facesContext, 
-				UIComponent component,
-				Object argument);
-	}
+    @Override
+    protected void doDecode(FacesContext context, UIComponent component) {
+        super.doDecode(context, component);
+        decodeCommand.execute(renderers.iterator(), context, component, null, component.getClass());
+    }
 
-	private final Command DECODE_COMMAND = new Command() {
+    protected void mergeScriptOptions(ScriptOptions scriptOptions, FacesContext context, UIComponent component) {
+        mergeScriptOptions(scriptOptions, context, component, null);
+    }
 
-		protected void execute(RendererContributor renderer, FacesContext context, 
-				UIComponent component, Object argument) {
+    protected void mergeScriptOptions(ScriptOptions scriptOptions, FacesContext context, UIComponent component,
+                                      Class<?> acceptableClass) {
+        MERGE_OPTIONS_COMMAND.execute(renderers.iterator(), context, component, scriptOptions, acceptableClass);
+    }
 
-			renderer.decode(context, component, CompositeRenderer.this);
-		}
-	};
+    protected String getScriptContributions(String varString, FacesContext context, UIComponent component) {
+        return getScriptContributions(varString, context, component, component.getClass());
+    }
 
-	private static final Command MERGE_OPTIONS_COMMAND = new Command() {
+    protected String getScriptContributions(String varString, FacesContext context, UIComponent component,
+            Class<?> acceptableClass) {
+        List<String> scriptContributions = new ArrayList<String>();
 
-		protected void execute(RendererContributor renderer, FacesContext context, 
-				UIComponent component, Object argument) {
+        GET_SCRIPT_CONTRIBUTIONS.execute(renderers.iterator(), context, component, scriptContributions,
+                                         acceptableClass);
 
-			ScriptOptions initialOptions = (ScriptOptions) argument;
+        StringBuffer result = new StringBuffer();
 
-			ScriptOptions builtOptions = renderer.buildOptions(context, component);
-			if (builtOptions != null) {
-				initialOptions.merge(builtOptions);
-			}
-		}
+        for (Iterator<String> itr = scriptContributions.iterator(); itr.hasNext(); ) {
+            result.append(varString);
+            result.append(itr.next());
+        }
 
-	};
+        return result.toString();
+    }
 
-	private static final Command GET_SCRIPT_CONTRIBUTIONS = new Command() {
+    protected void addContributor(RendererContributor renderer) {
+        renderers.add(renderer);
+    }
 
-		protected void execute(RendererContributor renderer,
-				FacesContext context, UIComponent component,
-				Object argument) {
+    protected RendererContributor[] getContributors() {
+        return (RendererContributor[]) renderers.toArray(new RendererContributor[renderers.size()]);
+    }
 
-			String contribution = renderer.getScriptContribution(context, component);
-			if (contribution != null) {
-				((List<String>) argument).add(contribution);
-			}
-		}
-		
-	};
+    protected void addParameterEncoder(AttributeParametersEncoder encoder) {
+        parameterEncoders.add(encoder);
+    }
 
-	protected void doDecode(FacesContext context, UIComponent component) {
-		super.doDecode(context, component);
+    protected AttributeParametersEncoder[] getParameterEncoders() {
+        return (AttributeParametersEncoder[]) parameterEncoders.toArray(
+            new AttributeParametersEncoder[renderers.size()]);
+    }
 
-		DECODE_COMMAND.execute(renderers.iterator(), context, component, null, component.getClass());
-	}
+    public void encodeAttributeParameters(FacesContext context, UIComponent component) throws IOException {
+        for (Iterator<AttributeParametersEncoder> iterator = parameterEncoders.iterator(); iterator.hasNext(); ) {
+            AttributeParametersEncoder encoder = iterator.next();
 
-	protected void mergeScriptOptions(ScriptOptions scriptOptions, FacesContext context, UIComponent component) {
-		mergeScriptOptions(scriptOptions, context, component, null);
-	}
-	
-	protected void mergeScriptOptions(ScriptOptions scriptOptions, FacesContext context, UIComponent component, Class<?> acceptableClass) {
-		MERGE_OPTIONS_COMMAND.execute(renderers.iterator(), context, component, scriptOptions, acceptableClass);
-	}
+            encoder.doEncode(context, component);
+        }
+    }
 
-	protected String getScriptContributions(String varString, FacesContext context, UIComponent component) {
-		return getScriptContributions(varString, context, component, component.getClass());
-	}
-	
-	protected String getScriptContributions(String varString, FacesContext context, UIComponent component, Class<?> acceptableClass) {
-		List<String> scriptContributions = new ArrayList<String>();
-		
-		GET_SCRIPT_CONTRIBUTIONS.execute(renderers.iterator(), context, component, scriptContributions, acceptableClass);
-	
-		StringBuffer result = new StringBuffer();
-		for (Iterator<String> itr = scriptContributions.iterator(); itr.hasNext(); ) {
-			result.append(varString);
-			result.append(itr.next());
-		}
-		
-		return result.toString();
-	}
-	
-	protected void addContributor(RendererContributor renderer) {
-		renderers.add(renderer);
-	}
-	
-	protected RendererContributor[] getContributors() {
-		return (RendererContributor[]) renderers.toArray(new RendererContributor[renderers.size()]);
-	}
-	
-	protected void addParameterEncoder(AttributeParametersEncoder encoder) {
-		parameterEncoders.add(encoder);
-	}
-	
-	protected AttributeParametersEncoder[] getParameterEncoders() {
-		return (AttributeParametersEncoder[]) parameterEncoders.toArray(new AttributeParametersEncoder[renderers.size()]);
-	}
+    private abstract static class Command {
+        protected final void execute(Iterator<?> renderers, FacesContext facesContext, UIComponent component,
+                                     Object argument, Class<?> clazz) {
+            while (renderers.hasNext()) {
+                RendererContributor contributor = (RendererContributor) renderers.next();
+                Class<?> acceptableClass = contributor.getAcceptableClass();
 
-	public void encodeAttributeParameters(FacesContext context, UIComponent component) throws IOException {
-		for (Iterator<AttributeParametersEncoder> iterator = parameterEncoders.iterator(); iterator.hasNext();) {
-			AttributeParametersEncoder encoder = iterator.next();
-			
-			encoder.doEncode(context, component);
-		}
-	}
-	
+                if ((clazz == null) || (acceptableClass == null) || acceptableClass.isAssignableFrom(clazz)) {
+                    execute(contributor, facesContext, component, argument);
+                }
+            }
+        }
+
+        protected abstract void execute(RendererContributor renderer, FacesContext facesContext, UIComponent component,
+                                        Object argument);
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/Expression.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/Expression.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/Expression.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,6 +18,9 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.richfaces.renderkit;
 
 /**
@@ -26,42 +29,53 @@
  *
  */
 public class Expression {
-	private Object expression;
+    private Object expression;
 
-	public Expression(Object expression) {
-		super();
-		this.expression = expression;
-	}
+    public Expression(Object expression) {
+        super();
+        this.expression = expression;
+    }
 
-	public Object getExpression() {
-		return expression;
-	}
-	
-	public String toString() {
-		return super.toString() + "[" + expression + "]";
-	}
+    public Object getExpression() {
+        return expression;
+    }
 
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime * result
-				+ ((expression == null) ? 0 : expression.hashCode());
-		return result;
-	}
+    public String toString() {
+        return super.toString() + "[" + expression + "]";
+    }
 
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		final Expression other = (Expression) obj;
-		if (expression == null) {
-			if (other.expression != null)
-				return false;
-		} else if (!expression.equals(other.expression))
-			return false;
-		return true;
-	}
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((expression == null) ? 0 : expression.hashCode());
+
+        return result;
+    }
+
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+
+        if (obj == null) {
+            return false;
+        }
+
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+
+        final Expression other = (Expression) obj;
+
+        if (expression == null) {
+            if (other.expression != null) {
+                return false;
+            }
+        } else if (!expression.equals(other.expression)) {
+            return false;
+        }
+
+        return true;
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,8 +19,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit;
 
+import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
+import org.ajax4jsf.util.SelectUtils;
+
 import java.util.Map;
 
 import javax.faces.component.UIComponent;
@@ -29,54 +34,55 @@
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 
-import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
-import org.ajax4jsf.util.SelectUtils;
-
 /**
  * @author Nick Belaevski - nbelaevski at exadel.com
  * created 23.01.2007
- * 
+ *
  */
 public class InputRendererBase extends AjaxComponentRendererBase {
+    protected Class getComponentClass() {
+        return UIInput.class;
+    }
 
-	protected Class getComponentClass() {
-		return UIInput.class;
-	}
-
-	protected void doDecode(FacesContext context, UIComponent component) {
-		String clientId = component.getClientId(context);
+    protected void doDecode(FacesContext context, UIComponent component) {
+        String clientId = component.getClientId(context);
         Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
         String newValue = (String) requestParameterMap.get(clientId);
+
         if (null != newValue) {
-    		UIInput input = (UIInput) component;
+            UIInput input = (UIInput) component;
+
             input.setSubmittedValue(newValue);
         }
-	}
-	
-	public Object getConvertedValue(FacesContext context, UIComponent component, Object val) throws ConverterException {
-		return SelectUtils.getConvertedUIInputValue(context, (UIInput) component, (String) val);
-	}
-	
-	public String getInputValue(FacesContext context, UIInput component){
-		UIInput input = (UIInput) component;
-		String value = (String) input.getSubmittedValue();
-		if(value == null){
-			Object curVal = input.getValue();
-			Converter converter = SelectUtils.getConverterForProperty(context, input, "value");
-			if(converter != null){
-				value = converter.getAsString(context, input, curVal);
-			} else {
-				if(curVal == null){
-					value = "";
-				} else {
-					value = curVal.toString();
-				}
-			}
-		}
-		if(value == null){
-			value = "";
-		}
-		return value;
-	}
+    }
 
+    public Object getConvertedValue(FacesContext context, UIComponent component, Object val) throws ConverterException {
+        return SelectUtils.getConvertedUIInputValue(context, (UIInput) component, (String) val);
+    }
+
+    public String getInputValue(FacesContext context, UIInput component) {
+        UIInput input = (UIInput) component;
+        String value = (String) input.getSubmittedValue();
+
+        if (value == null) {
+            Object curVal = input.getValue();
+            Converter converter = SelectUtils.getConverterForProperty(context, input, "value");
+
+            if (converter != null) {
+                value = converter.getAsString(context, input, curVal);
+            } else {
+                if (curVal == null) {
+                    value = "";
+                } else {
+                    value = curVal.toString();
+                }
+            }
+        }
+
+        if (value == null) {
+            value = "";
+        }
+
+        return value;
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,232 +18,229 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.richfaces.renderkit;
 
+import org.richfaces.javacc.RichMacroDefinition;
+import org.richfaces.json.JSContentHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
 import java.io.FilterWriter;
 import java.io.IOException;
 import java.io.StringReader;
 import java.io.Writer;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-import org.richfaces.javacc.RichMacroDefinition;
-import org.richfaces.json.JSContentHandler;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
 /**
  * @author Nick Belaevski - mailto:nbelaevski at exadel.com created 21.06.2007
- * 
+ *
  */
 public class MacroDefinitionJSContentHandler extends JSContentHandler {
-	private String prolog;
-	private String epilog;
+    private String epilog;
+    private String prolog;
 
-	/**
-	 * Writer will not output duplicate commas
-	 * @author Maksim Kaszynski
-	 *
-	 */
-	static class WellFormedWriter extends FilterWriter {
-		
-		private char lastChar;
-		
-		public WellFormedWriter(Writer out) {
-			super(out);
-		}
-		
-		public void write(char[] cbuf, int off, int len) throws IOException {
-			
-			
-			//Skip comma
-			while (cbuf[off] == lastChar && lastChar == ',' && len > 0) {
-				off++;
-				len--;
-			}
-			
-			while(len > 1 && cbuf[off] == cbuf[off+1] && cbuf[off] == ','){
-				len--;
-				off++;
-			}
-			
-			
-			super.write(cbuf, off, len);
-			
-			lastChar = cbuf[off + len - 1];
-			
-		}
+    public MacroDefinitionJSContentHandler(Writer writer, String prolog, String epilog) {
+        super(writer);
+        this.prolog = prolog;
+        this.epilog = epilog;
+    }
 
-		public void write(int c) throws IOException {
-			if (c != lastChar || lastChar != ',') {
-				super.write(c);
-				lastChar = (char) c;
-			}
-		}
-		
-	}
-	
-	public MacroDefinitionJSContentHandler(Writer writer, String prolog,
-			String epilog) {
-		super(writer);
-		this.prolog = prolog;
-		this.epilog = epilog;
-	}
+    protected List<?> parseExpressiion(String expressionString) throws SAXException {
+        try {
+            if (expressionString.length() != 0) {
+                List<?> result = new RichMacroDefinition(new StringReader(expressionString)).expression();
 
-	protected List<?> parseExpressiion(String expressionString) throws SAXException {
-		try {
-			if (expressionString.length() != 0) {
-				List<?> result = new RichMacroDefinition(new StringReader(expressionString)).expression();
+                return result;
+            } else {
+                List<Object> list = new ArrayList<Object>(1);
 
-				return result;
-			} else {
-				List<Object> list = new ArrayList<Object>(1);
-				list.add("");
-				
-				return list;
-			}
-		} catch (Exception e) {
-			throw new SAXException(e.getMessage(), e);
-		}
-	}
+                list.add("");
 
-	private void encodeExpressionString(String string) throws IOException,
-			SAXException {
-		
-		/*if (string.length() == 0) {
-			this.outputWriter.write("\'\'");
-		}*/
-		
-		List<?> parsedExpressiion = parseExpressiion(string);
+                return list;
+            }
+        } catch (Exception e) {
+            throw new SAXException(e.getMessage(), e);
+        }
+    }
 
-		boolean isExpression = false;
-		for (Iterator<?> iterator = parsedExpressiion.iterator(); iterator
-				.hasNext();) {
-			Object next = (Object) iterator.next();
-			if (next instanceof Expression) {
-				isExpression = true;
-				break;
-			}
-		}
+    private void encodeExpressionString(String string) throws IOException, SAXException {
 
-		if (isExpression) {
-			this.outputWriter.write("function (context) { return ");
-		}
+        /*
+         * if (string.length() == 0) {
+         *   this.outputWriter.write("\'\'");
+         * }
+         */
+        List<?> parsedExpressiion = parseExpressiion(string);
+        boolean isExpression = false;
 
-		boolean first = true;
-		for (Iterator<?> iterator = parsedExpressiion.iterator(); iterator
-				.hasNext();) {
-			Object next = (Object) iterator.next();
+        for (Iterator<?> iterator = parsedExpressiion.iterator(); iterator.hasNext(); ) {
+            Object next = (Object) iterator.next();
 
-			if (next == null) {
-				continue;
-			}
+            if (next instanceof Expression) {
+                isExpression = true;
 
-			if (!first) {
-				this.outputWriter.write('+');
-			}
+                break;
+            }
+        }
 
-			if (next instanceof Expression) {
-				Expression macroExpression = (Expression) next;
+        if (isExpression) {
+            this.outputWriter.write("function (context) { return ");
+        }
 
-				this.outputWriter.write(prolog);
-				this.encode(macroExpression.getExpression().toString());
-				this.outputWriter.write(epilog);
-			} else {
-				this.outputWriter.write('\'');
-				this.encode(next.toString());
-				this.outputWriter.write('\'');
-			}
+        boolean first = true;
 
-			first = false;
-		}
+        for (Iterator<?> iterator = parsedExpressiion.iterator(); iterator.hasNext(); ) {
+            Object next = (Object) iterator.next();
 
-		if (isExpression) {
-			this.outputWriter.write(";}");
-		}
-	}
+            if (next == null) {
+                continue;
+            }
 
-	protected void encodeAttributeValue(Attributes attributes, int idx)
-			throws SAXException, IOException {
+            if (!first) {
+                this.outputWriter.write('+');
+            }
 
-		String value = attributes.getValue(idx);
-		encodeExpressionString(value);
-	}
+            if (next instanceof Expression) {
+                Expression macroExpression = (Expression) next;
 
-	public void characters(char[] ch, int start, int length)
-			throws SAXException {
-		if (isProcessingCdata()) {
-			super.characters(ch, start, length);
-		} else {
-			Writer oldWriter = outputWriter;
-			outputWriter = new WellFormedWriter(oldWriter);
-			
-			try {
-				List<?> parsedExpression = parseExpressiion(new String(ch, start,
-						length));
-				for (Iterator<?> iterator = parsedExpression.iterator(); iterator
-						.hasNext();) {
+                this.outputWriter.write(prolog);
+                this.encode(macroExpression.getExpression().toString());
+                this.outputWriter.write(epilog);
+            } else {
+                this.outputWriter.write('\'');
+                this.encode(next.toString());
+                this.outputWriter.write('\'');
+            }
 
-					Object next = iterator.next();
+            first = false;
+        }
 
-					if (next instanceof Expression) {
-						Expression expression = (Expression) next;
+        if (isExpression) {
+            this.outputWriter.write(";}");
+        }
+    }
 
-						if (this.isBeforeDocumentStart() || level < 0)
-							return;
-						try {
-							if (level != 0 && !this.closeElement(false)
-									&& this.isProcessingCdata() == false) {
-								this.outputWriter.write(',');
-							}
+    protected void encodeAttributeValue(Attributes attributes, int idx) throws SAXException, IOException {
+        String value = attributes.getValue(idx);
 
-							if (this.isProcessingCdata() == false) {
-								this.outputWriter.write("new ET(");
-							}
+        encodeExpressionString(value);
+    }
 
-							this.outputWriter
-									.write("function (context) { return ");
-							this.outputWriter.write(prolog);
-							this.encode(expression.getExpression().toString());
-							this.outputWriter.write(epilog);
-							this.outputWriter.write("}");
+    public void characters(char[] ch, int start, int length) throws SAXException {
+        if (isProcessingCdata()) {
+            super.characters(ch, start, length);
+        } else {
+            Writer oldWriter = outputWriter;
 
-							if (this.isProcessingCdata() == false) {
-								this.outputWriter.write(")");
-							}
-						} catch (IOException e) {
-							throw new SAXException("Write error", e);
-						}
+            outputWriter = new WellFormedWriter(oldWriter);
 
-					} else {
-						char[] cs = next.toString().toCharArray();
-						super.characters(cs, 0, cs.length);
-					}
+            try {
+                List<?> parsedExpression = parseExpressiion(new String(ch, start, length));
 
-					if (iterator.hasNext()) {
-						try {
-							this.outputWriter.write(',');
-						} catch (IOException e) {
-							// TODO Auto-generated catch block
-							e.printStackTrace();
-						}
-					}
-				}
-			} finally {
-				outputWriter = oldWriter;
-			}
-		}
-	}
+                for (Iterator<?> iterator = parsedExpression.iterator(); iterator.hasNext(); ) {
+                    Object next = iterator.next();
 
-	protected void encodeText(char[] chars, int start, int length)
-			throws SAXException, IOException {
-		if (!isProcessingCdata()) {
-			String str = new String(chars, start, length);
-			encodeExpressionString(str);
-		} else {
-			super.encodeText(chars, start, length);
-		}
-	}
+                    if (next instanceof Expression) {
+                        Expression expression = (Expression) next;
 
+                        if (this.isBeforeDocumentStart() || (level < 0)) {
+                            return;
+                        }
+
+                        try {
+                            if ((level != 0) && !this.closeElement(false) && !this.isProcessingCdata()) {
+                                this.outputWriter.write(',');
+                            }
+
+                            if (!this.isProcessingCdata()) {
+                                this.outputWriter.write("new ET(");
+                            }
+
+                            this.outputWriter.write("function (context) { return ");
+                            this.outputWriter.write(prolog);
+                            this.encode(expression.getExpression().toString());
+                            this.outputWriter.write(epilog);
+                            this.outputWriter.write("}");
+
+                            if (!this.isProcessingCdata()) {
+                                this.outputWriter.write(")");
+                            }
+                        } catch (IOException e) {
+                            throw new SAXException("Write error", e);
+                        }
+                    } else {
+                        char[] cs = next.toString().toCharArray();
+
+                        super.characters(cs, 0, cs.length);
+                    }
+
+                    if (iterator.hasNext()) {
+                        try {
+                            this.outputWriter.write(',');
+                        } catch (IOException e) {
+
+                            // TODO Auto-generated catch block
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            } finally {
+                outputWriter = oldWriter;
+            }
+        }
+    }
+
+    protected void encodeText(char[] chars, int start, int length) throws SAXException, IOException {
+        if (!isProcessingCdata()) {
+            String str = new String(chars, start, length);
+
+            encodeExpressionString(str);
+        } else {
+            super.encodeText(chars, start, length);
+        }
+    }
+
+    /**
+     * Writer will not output duplicate commas
+     * @author Maksim Kaszynski
+     *
+     */
+    static class WellFormedWriter extends FilterWriter {
+        private char lastChar;
+
+        public WellFormedWriter(Writer out) {
+            super(out);
+        }
+
+        public void write(char[] cbuf, int off, int len) throws IOException {
+
+            // Skip comma
+            while ((cbuf[off] == lastChar) && (lastChar == ',') && (len > 0)) {
+                off++;
+                len--;
+            }
+
+            while ((len > 1) && (cbuf[off] == cbuf[off + 1]) && (cbuf[off] == ',')) {
+                len--;
+                off++;
+            }
+
+            super.write(cbuf, off, len);
+            lastChar = cbuf[off + len - 1];
+        }
+
+        public void write(int c) throws IOException {
+            if ((c != lastChar) || (lastChar != ',')) {
+                super.write(c);
+                lastChar = (char) c;
+            }
+        }
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/RendererContributor.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/RendererContributor.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/RendererContributor.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit;
 
 import javax.faces.component.UIComponent;
@@ -27,13 +29,16 @@
 /**
  * @author Nick Belaevski - nbelaevski at exadel.com
  * created 18.12.2006
- * 
+ *
  */
 public interface RendererContributor extends ScriptOptionsContributor {
-	public String getScriptContribution(FacesContext context, UIComponent component);
-	
-	public void decode(FacesContext context, UIComponent component, CompositeRenderer compositeRenderer);
-	public String[] getScriptDependencies();
-	public String[] getStyleDependencies();
-	public Class<?> getAcceptableClass();
+    public String getScriptContribution(FacesContext context, UIComponent component);
+
+    public void decode(FacesContext context, UIComponent component, CompositeRenderer compositeRenderer);
+
+    public String[] getScriptDependencies();
+
+    public String[] getStyleDependencies();
+
+    public Class<?> getAcceptableClass();
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,8 +19,14 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit;
 
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.ScriptStringBase;
+import org.ajax4jsf.javascript.ScriptUtils;
+
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -28,79 +34,78 @@
 
 import javax.faces.component.UIComponent;
 
-import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.javascript.ScriptStringBase;
-import org.ajax4jsf.javascript.ScriptUtils;
-
 /**
  * @author Maksim Kaszynski
  *
  */
 public class ScriptOptions extends ScriptStringBase {
+    protected Map<String, Object> opts = new HashMap<String, Object>();
+    private UIComponent component;
 
-	private UIComponent component;
-	protected Map<String, Object> opts = new HashMap<String, Object>();
-	
-	public ScriptOptions(UIComponent component) {
-		this.component = component;
-	}
-	public void appendScript(StringBuffer functionString) {
-		functionString.append(ScriptUtils.toScript(opts));
-	}
-	
-	public void addOption(String name) {
-		if (name != null) {
-			Object value = component.getAttributes().get(name);
-			addOption(name, value);
-		}
-	}
-	
-	@SuppressWarnings("unchecked")
-	public void addOption(String name, Object value) {
-		if (value != null) {
-			Object object = opts.get(name);
-			if (object instanceof Map && value instanceof Map) {
-				((Map) object).putAll((Map) value);
-			} else {
-				opts.put(name, value);
-			}
-		}
-	}
-	public void addEventHandler(String event, String handler) {
-		if (event != null &&  handler != null) {
-			JSFunctionDefinition functionDefinition = 
-				new JSFunctionDefinition("event");
-			
-			functionDefinition.addToBody(handler);
-			functionDefinition.addToBody(";return true;");
-			addEventHandler(event, functionDefinition);
-		}
-	}
-	
-	public void addEventHandler(String event) {
-		if (event != null) {
-			String handler = (String) component.getAttributes().get(event);
-			addEventHandler(event, handler);
-		}
-	}
-	
-	public void addEventHandler(String event, JSFunctionDefinition definition) {
-		if (event != null && definition != null) {
-			opts.put(event, definition);
-		}
-	}
-	public Map<String,Object> getMap() {
-		return opts;
-	}
+    public ScriptOptions(UIComponent component) {
+        this.component = component;
+    }
 
-	public void merge(ScriptOptions anotherOptions) {
-		Iterator<Entry<String, Object>> entrySetIterator = anotherOptions.opts.entrySet().iterator();
-		while (entrySetIterator.hasNext()) {
-			Entry<String, Object> entry = entrySetIterator.next();
-			
-			addOption(entry.getKey(), entry.getValue());
-		}
-	}
+    public void appendScript(StringBuffer functionString) {
+        functionString.append(ScriptUtils.toScript(opts));
+    }
 
+    public void addOption(String name) {
+        if (name != null) {
+            Object value = component.getAttributes().get(name);
 
+            addOption(name, value);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void addOption(String name, Object value) {
+        if (value != null) {
+            Object object = opts.get(name);
+
+            if ((object instanceof Map) && (value instanceof Map)) {
+                ((Map) object).putAll((Map) value);
+            } else {
+                opts.put(name, value);
+            }
+        }
+    }
+
+    public void addEventHandler(String event, String handler) {
+        if ((event != null) && (handler != null)) {
+            JSFunctionDefinition functionDefinition = new JSFunctionDefinition("event");
+
+            functionDefinition.addToBody(handler);
+            functionDefinition.addToBody(";return true;");
+            addEventHandler(event, functionDefinition);
+        }
+    }
+
+    public void addEventHandler(String event) {
+        if (event != null) {
+            String handler = (String) component.getAttributes().get(event);
+
+            addEventHandler(event, handler);
+        }
+    }
+
+    public void addEventHandler(String event, JSFunctionDefinition definition) {
+        if ((event != null) && (definition != null)) {
+            opts.put(event, definition);
+        }
+    }
+
+    public Map<String, Object> getMap() {
+        return opts;
+    }
+
+    public void merge(ScriptOptions anotherOptions) {
+        Iterator<Entry<String, Object>> entrySetIterator = anotherOptions.opts.entrySet().iterator();
+
+        while (entrySetIterator.hasNext()) {
+            Entry<String, Object> entry = entrySetIterator.next();
+
+            addOption(entry.getKey(), entry.getValue());
+        }
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/ScriptOptionsContributor.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/ScriptOptionsContributor.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/ScriptOptionsContributor.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit;
 
 import javax.faces.component.UIComponent;
@@ -27,14 +29,15 @@
 /**
  * @author Nick Belaevski - nbelaevski at exadel.com
  * created 18.12.2006
- * 
+ *
  */
 public interface ScriptOptionsContributor {
-	/**
-	 * Create script options if component class is known for renderer to contribute
-	 * @param context
-	 * @param component
-	 * @return Built {@link ScriptOptions} instance or null if component is not acceptable
-	 */
-	public ScriptOptions buildOptions(FacesContext context, UIComponent component);
+
+    /**
+     * Create script options if component class is known for renderer to contribute
+     * @param context
+     * @param component
+     * @return Built {@link ScriptOptions} instance or null if component is not acceptable
+     */
+    public ScriptOptions buildOptions(FacesContext context, UIComponent component);
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,8 +18,18 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.richfaces.renderkit;
 
+import org.ajax4jsf.io.SAXResponseWriter;
+import org.ajax4jsf.renderkit.RendererBase;
+
+import org.richfaces.component.TemplateComponent;
+
+import org.xml.sax.ContentHandler;
+
 import java.io.IOException;
 import java.io.Writer;
 
@@ -27,73 +37,68 @@
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 
-import org.ajax4jsf.io.SAXResponseWriter;
-import org.ajax4jsf.renderkit.RendererBase;
-import org.richfaces.component.TemplateComponent;
-import org.xml.sax.ContentHandler;
-
 /**
  * @author Nick Belaevski - mailto:nbelaevski at exadel.com
  * created 22.06.2007
  *
  */
 public abstract class TemplateEncoderRendererBase extends RendererBase {
-	
-	public final boolean getRendersChildren() {
-		return true;
-	}
+    public final boolean getRendersChildren() {
+        return true;
+    }
 
-	protected void writeScriptBody(FacesContext context, UIComponent component, boolean children)
-		throws IOException {
-		ResponseWriter writer = context.getResponseWriter();
-		ContentHandler handler = createContentHandler(writer);
-		SAXResponseWriter saxResponseWriter = new SAXResponseWriter(handler);
-		context.setResponseWriter(saxResponseWriter);
-		
-		TemplateComponent templateComponent = null;
-		if (component instanceof TemplateComponent) {
-			templateComponent = (TemplateComponent) component;
-		}
-		
-		try {
-			if (templateComponent != null) {
-				templateComponent.startTemplateEncode();
-			}
-			saxResponseWriter.startDocument();
-			
-			//TODO - how to handle extra "root" element? 
-			saxResponseWriter.startElement("root", component);
+    protected void writeScriptBody(FacesContext context, UIComponent component, boolean children) throws IOException {
+        ResponseWriter writer = context.getResponseWriter();
+        ContentHandler handler = createContentHandler(writer);
+        SAXResponseWriter saxResponseWriter = new SAXResponseWriter(handler);
 
-			if (children) {
-				this.renderChildren(context, component);
-			} else {
-				this.renderChild(context, component);
-			}
-			
-			saxResponseWriter.endElement("root");
-			saxResponseWriter.endDocument();
-		} finally {
-			if (templateComponent != null) {
-				templateComponent.endTemplateEncode();
-			}
+        context.setResponseWriter(saxResponseWriter);
 
-			context.setResponseWriter(writer);
-		}
-	}
-	
-	public void encodeChildren(FacesContext context, UIComponent component)
-	throws IOException {
-		ResponseWriter writer = context.getResponseWriter();
-		writer.startElement("script", component);
-		writer.write("var evaluator = ");
-		writeScriptBody(context, component, true);
-		writer.write(";\n new Insertion.Top($('" + component.getClientId(context) + "'), evaluator.invoke('getContent', window).join(''));");
-		writer.endElement("script");
-	}
-	
-	
-	protected ContentHandler createContentHandler(Writer writer) {
-		return new MacroDefinitionJSContentHandler(writer, "Richfaces.evalMacro(\"", "\", context)");
-	}
+        TemplateComponent templateComponent = null;
 
+        if (component instanceof TemplateComponent) {
+            templateComponent = (TemplateComponent) component;
+        }
+
+        try {
+            if (templateComponent != null) {
+                templateComponent.startTemplateEncode();
+            }
+
+            saxResponseWriter.startDocument();
+
+            // TODO - how to handle extra "root" element?
+            saxResponseWriter.startElement("root", component);
+
+            if (children) {
+                this.renderChildren(context, component);
+            } else {
+                this.renderChild(context, component);
+            }
+
+            saxResponseWriter.endElement("root");
+            saxResponseWriter.endDocument();
+        } finally {
+            if (templateComponent != null) {
+                templateComponent.endTemplateEncode();
+            }
+
+            context.setResponseWriter(writer);
+        }
+    }
+
+    public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
+        ResponseWriter writer = context.getResponseWriter();
+
+        writer.startElement("script", component);
+        writer.write("var evaluator = ");
+        writeScriptBody(context, component, true);
+        writer.write(";\n new Insertion.Top($('" + component.getClientId(context)
+                     + "'), evaluator.invoke('getContent', window).join(''));");
+        writer.endElement("script");
+    }
+
+    protected ContentHandler createContentHandler(Writer writer) {
+        return new MacroDefinitionJSContentHandler(writer, "Richfaces.evalMacro(\"", "\", context)");
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/Base2WayGradient.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/Base2WayGradient.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/Base2WayGradient.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,211 +1,192 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.renderkit.html;
 
-import java.awt.Dimension;
-import java.awt.GradientPaint;
-import java.awt.Graphics2D;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-
-import org.richfaces.renderkit.html.BaseGradient;
 import org.richfaces.renderkit.html.images.GradientType;
 import org.richfaces.renderkit.html.images.GradientType.BiColor;
 
+import java.awt.*;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
 /**
  * @author asmirnov
  *
  */
 public class Base2WayGradient extends BaseGradient {
 
+    /**
+     * @param horizontal
+     */
+    public Base2WayGradient(boolean horizontal) {
+        super(horizontal);
 
+        // TODO Auto-generated constructor stub
+    }
 
+    /**
+     * @param width
+     * @param height
+     */
+    public Base2WayGradient(int width, int height) {
+        super(width, height);
 
-	/**
-	 * @param horizontal
-	 */
-	public Base2WayGradient(boolean horizontal) {
-		super(horizontal);
-		// TODO Auto-generated constructor stub
-	}
+        // TODO Auto-generated constructor stub
+    }
 
-	/**
-	 * @param width
-	 * @param height
-	 * @param horizontal
-	 */
-	public Base2WayGradient(int width, int height, boolean horizontal) {
-		super(width, height, horizontal);
-		// TODO Auto-generated constructor stub
-	}
+    /**
+     * @param baseColor
+     * @param gradientColor
+     */
+    public Base2WayGradient(String baseColor, String gradientColor) {
+        super(baseColor, gradientColor);
 
-	/**
-	 * @param width
-	 * @param height
-	 * @param gradientHeight
-	 * @param horizontal
-	 */
-	public Base2WayGradient(int width, int height, int gradientHeight,
-			boolean horizontal) {
-		super(width, height, gradientHeight, horizontal);
-		// TODO Auto-generated constructor stub
-	}
+        // TODO Auto-generated constructor stub
+    }
 
-	/**
-	 * @param width
-	 * @param height
-	 * @param gradientHeight
-	 * @param baseColor
-	 * @param gradientColor
-	 * @param horizontal
-	 */
-	public Base2WayGradient(int width, int height, int gradientHeight,
-			String baseColor, String gradientColor, boolean horizontal) {
-		super(width, height, gradientHeight, baseColor, gradientColor, horizontal);
-		// TODO Auto-generated constructor stub
-	}
+    /**
+     * @param width
+     * @param height
+     * @param horizontal
+     */
+    public Base2WayGradient(int width, int height, boolean horizontal) {
+        super(width, height, horizontal);
 
-	/**
-	 * @param width
-	 * @param height
-	 * @param gradientHeight
-	 * @param baseColor
-	 * @param gradientColor
-	 */
-	public Base2WayGradient(int width, int height, int gradientHeight,
-			String baseColor, String gradientColor) {
-		super(width, height, gradientHeight, baseColor, gradientColor);
-		// TODO Auto-generated constructor stub
-	}
+        // TODO Auto-generated constructor stub
+    }
 
-	/**
-	 * @param width
-	 * @param height
-	 * @param gradientHeight
-	 */
-	public Base2WayGradient(int width, int height, int gradientHeight) {
-		super(width, height, gradientHeight);
-		// TODO Auto-generated constructor stub
-	}
+    /**
+     * @param width
+     * @param height
+     * @param gradientHeight
+     */
+    public Base2WayGradient(int width, int height, int gradientHeight) {
+        super(width, height, gradientHeight);
 
-	/**
-	 * @param width
-	 * @param height
-	 * @param baseColor
-	 * @param gradientColor
-	 * @param horizontal
-	 */
-	public Base2WayGradient(int width, int height, String baseColor,
-			String gradientColor, boolean horizontal) {
-		super(width, height, baseColor, gradientColor, horizontal);
-		// TODO Auto-generated constructor stub
-	}
+        // TODO Auto-generated constructor stub
+    }
 
-	/**
-	 * @param width
-	 * @param height
-	 * @param baseColor
-	 * @param gradientColor
-	 */
-	public Base2WayGradient(int width, int height, String baseColor,
-			String gradientColor) {
-		super(width, height, baseColor, gradientColor);
-		// TODO Auto-generated constructor stub
-	}
+    /**
+     * @param baseColor
+     * @param gradientColor
+     * @param horizontal
+     */
+    public Base2WayGradient(String baseColor, String gradientColor, boolean horizontal) {
+        super(baseColor, gradientColor, horizontal);
 
-	/**
-	 * @param width
-	 * @param height
-	 */
-	public Base2WayGradient(int width, int height) {
-		super(width, height);
-		// TODO Auto-generated constructor stub
-	}
+        // TODO Auto-generated constructor stub
+    }
 
-	/**
-	 * @param baseColor
-	 * @param gradientColor
-	 * @param horizontal
-	 */
-	public Base2WayGradient(String baseColor, String gradientColor,
-			boolean horizontal) {
-		super(baseColor, gradientColor, horizontal);
-		// TODO Auto-generated constructor stub
-	}
+    /**
+     * @param width
+     * @param height
+     * @param gradientHeight
+     * @param horizontal
+     */
+    public Base2WayGradient(int width, int height, int gradientHeight, boolean horizontal) {
+        super(width, height, gradientHeight, horizontal);
 
-	/**
-	 * @param baseColor
-	 * @param gradientColor
-	 */
-	public Base2WayGradient(String baseColor, String gradientColor) {
-		super(baseColor, gradientColor);
-		// TODO Auto-generated constructor stub
-	}
+        // TODO Auto-generated constructor stub
+    }
 
+    /**
+     * @param width
+     * @param height
+     * @param baseColor
+     * @param gradientColor
+     */
+    public Base2WayGradient(int width, int height, String baseColor, String gradientColor) {
+        super(width, height, baseColor, gradientColor);
 
-	protected void drawBackGradient(Graphics2D g2d, Rectangle2D rectangle, BiColor colors, int height) {
-		if (colors != null) {
-			GradientPaint gragient = new GradientPaint(0, (float)(rectangle.getHeight()-height), colors.getBottomColor(), 0, (float) rectangle.getHeight(), colors.getTopColor());
-			g2d.setPaint(gragient);
-			g2d.fill(rectangle);
-		}
-	}
+        // TODO Auto-generated constructor stub
+    }
 
+    /**
+     * @param width
+     * @param height
+     * @param gradientHeight
+     * @param baseColor
+     * @param gradientColor
+     */
+    public Base2WayGradient(int width, int height, int gradientHeight, String baseColor, String gradientColor) {
+        super(width, height, gradientHeight, baseColor, gradientColor);
 
-	@Override
-	protected void paintGradient(Graphics2D g2d, Dimension dim) {
-		if (headerBackgroundColor != null && headerGradientColor != null) {
-			BiColor biColor = new GradientType.BiColor(headerBackgroundColor, headerGradientColor);
-			BiColor firstLayer = gradientType.getFirstLayerColors(biColor);
-			BiColor secondLayer = gradientType.getSecondLayerColors(biColor);
+        // TODO Auto-generated constructor stub
+    }
 
-			if (isHorizontal()) {
-				//x -> y, y -> x
-				g2d.transform(new AffineTransform(0, 1, 1, 0, 0, 0));
-				dim.setSize(dim.height, dim.width);
-			}
+    /**
+     * @param width
+     * @param height
+     * @param baseColor
+     * @param gradientColor
+     * @param horizontal
+     */
+    public Base2WayGradient(int width, int height, String baseColor, String gradientColor, boolean horizontal) {
+        super(width, height, baseColor, gradientColor, horizontal);
 
-			int localGradientHeight = getGradientHeight();
-			if (localGradientHeight < 0) {
-				localGradientHeight = dim.height/2;
-			}
+        // TODO Auto-generated constructor stub
+    }
 
-			Rectangle2D rect = new Rectangle2D.Float(
-					0, 
-					0, 
-					dim.width, 
-					localGradientHeight);
+    /**
+     * @param width
+     * @param height
+     * @param gradientHeight
+     * @param baseColor
+     * @param gradientColor
+     * @param horizontal
+     */
+    public Base2WayGradient(int width, int height, int gradientHeight, String baseColor, String gradientColor,
+                            boolean horizontal) {
+        super(width, height, gradientHeight, baseColor, gradientColor, horizontal);
 
-			drawGradient(g2d, rect, firstLayer, localGradientHeight);
+        // TODO Auto-generated constructor stub
+    }
 
-			rect = new Rectangle2D.Float(
-					0, 
-					localGradientHeight, 
-					dim.width, 
-					dim.height);
+    protected void drawBackGradient(Graphics2D g2d, Rectangle2D rectangle, BiColor colors, int height) {
+        if (colors != null) {
+            GradientPaint gragient = new GradientPaint(0, (float) (rectangle.getHeight() - height),
+                                         colors.getBottomColor(), 0, (float) rectangle.getHeight(),
+                                         colors.getTopColor());
 
-			drawBackGradient(g2d, rect, firstLayer, localGradientHeight);
+            g2d.setPaint(gragient);
+            g2d.fill(rectangle);
+        }
+    }
 
-			int smallGradientHeight = localGradientHeight / 2;
+    @Override
+    protected void paintGradient(Graphics2D g2d, Dimension dim) {
+        if ((headerBackgroundColor != null) && (headerGradientColor != null)) {
+            BiColor biColor = new GradientType.BiColor(headerBackgroundColor, headerGradientColor);
+            BiColor firstLayer = gradientType.getFirstLayerColors(biColor);
+            BiColor secondLayer = gradientType.getSecondLayerColors(biColor);
 
-			rect = new Rectangle2D.Float(
-					0, 
-					0, 
-					dim.width, 
-					smallGradientHeight);
+            if (isHorizontal()) {
 
-			drawGradient(g2d, rect, secondLayer, smallGradientHeight);
+                // x -> y, y -> x
+                g2d.transform(new AffineTransform(0, 1, 1, 0, 0, 0));
+                dim.setSize(dim.height, dim.width);
+            }
 
-			rect = new Rectangle2D.Float(
-					0, 
-					dim.height-smallGradientHeight, 
-					dim.width, 
-					dim.height);
+            int localGradientHeight = getGradientHeight();
 
-			drawBackGradient(g2d, rect, secondLayer, smallGradientHeight);
-		}
-	}
+            if (localGradientHeight < 0) {
+                localGradientHeight = dim.height / 2;
+            }
 
+            Rectangle2D rect = new Rectangle2D.Float(0, 0, dim.width, localGradientHeight);
 
+            drawGradient(g2d, rect, firstLayer, localGradientHeight);
+            rect = new Rectangle2D.Float(0, localGradientHeight, dim.width, dim.height);
+            drawBackGradient(g2d, rect, firstLayer, localGradientHeight);
+
+            int smallGradientHeight = localGradientHeight / 2;
+
+            rect = new Rectangle2D.Float(0, 0, dim.width, smallGradientHeight);
+            drawGradient(g2d, rect, secondLayer, smallGradientHeight);
+            rect = new Rectangle2D.Float(0, dim.height - smallGradientHeight, dim.width, dim.height);
+            drawBackGradient(g2d, rect, secondLayer, smallGradientHeight);
+        }
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/GradientA.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/GradientA.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/GradientA.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,10 +19,12 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit.html;
 
 public class GradientA extends BaseGradient {
-	public GradientA() {
-		super(30, 50, 20, "headerGradientColor", "headerBackgroundColor");
-	}
-}
\ No newline at end of file
+    public GradientA() {
+        super(30, 50, 20, "headerGradientColor", "headerBackgroundColor");
+    }
+}

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ButtonDisabledBackgroundImage.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ButtonDisabledBackgroundImage.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ButtonDisabledBackgroundImage.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,16 +19,16 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit.html.images;
 
-
 /**
  * @author Nick Belaevski
  * @since 3.2
  */
-
 public class ButtonDisabledBackgroundImage extends BaseControlBackgroundImage {
-	public ButtonDisabledBackgroundImage() {
-		super("tableSubfooterBackgroundColor", "tableFooterBackgroundColor", 1);
-	}
+    public ButtonDisabledBackgroundImage() {
+        super("tableSubfooterBackgroundColor", "tableFooterBackgroundColor", 1);
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/GradientAlignment.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/GradientAlignment.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/GradientAlignment.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,67 +19,60 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
-package org.richfaces.renderkit.html.images;
 
-import static java.lang.Math.max;
 
+package org.richfaces.renderkit.html.images;
+
 import java.util.Locale;
 
+import static java.lang.Math.max;
 
 /**
  * Created 22.04.2008
  * @author Nick Belaevski
  * @since 3.2
  */
-
 public enum GradientAlignment {
     TOP {
-	@Override
-	public int getBottomRectangleHeight(int imageHeight, int gradientHeight) {
-	    return max(imageHeight - gradientHeight, 0);
-	}
-
-	@Override
-	public int getTopRectangleHeight(int imageHeight, int gradientHeight) {
-	    return 0;
-	}
+        @Override
+        public int getBottomRectangleHeight(int imageHeight, int gradientHeight) {
+            return max(imageHeight - gradientHeight, 0);
+        }
+        @Override
+        public int getTopRectangleHeight(int imageHeight, int gradientHeight) {
+            return 0;
+        }
     },
-    
     MIDDLE {
-	@Override
-	public int getBottomRectangleHeight(int imageHeight, int gradientHeight) {
-	    return max((imageHeight - gradientHeight) / 2, 0);
-	}
-
-	@Override
-	public int getTopRectangleHeight(int imageHeight, int gradientHeight) {
-	    return getBottomRectangleHeight(imageHeight, gradientHeight);
-	}
+        @Override
+        public int getBottomRectangleHeight(int imageHeight, int gradientHeight) {
+            return max((imageHeight - gradientHeight) / 2, 0);
+        }
+        @Override
+        public int getTopRectangleHeight(int imageHeight, int gradientHeight) {
+            return getBottomRectangleHeight(imageHeight, gradientHeight);
+        }
     },
-    
     BOTTOM {
-	@Override
-	public int getBottomRectangleHeight(int imageHeight, int gradientHeight) {
-	    return 0;
-	}
-
-	@Override
-	public int getTopRectangleHeight(int imageHeight, int gradientHeight) {
-	    return max(imageHeight - gradientHeight, 0);
-	}
+        @Override
+        public int getBottomRectangleHeight(int imageHeight, int gradientHeight) {
+            return 0;
+        }
+        @Override
+        public int getTopRectangleHeight(int imageHeight, int gradientHeight) {
+            return max(imageHeight - gradientHeight, 0);
+        }
     };
 
     public static final GradientAlignment getByParameter(String string) {
-	if (string == null || string.length() == 0) {
-	    return MIDDLE;
-	}
-	return GradientAlignment.valueOf(string.toUpperCase(Locale.US));
+        if ((string == null) || (string.length() == 0)) {
+            return MIDDLE;
+        }
+
+        return GradientAlignment.valueOf(string.toUpperCase(Locale.US));
     }
-    
+
     public abstract int getTopRectangleHeight(int imageHeight, int gradientHeight);
-    
+
     public abstract int getBottomRectangleHeight(int imageHeight, int gradientHeight);
-    
-    
-    
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/GradientType.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/GradientType.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/GradientType.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,9 +18,13 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.richfaces.renderkit.html.images;
 
 import java.awt.Color;
+
 import java.util.Locale;
 
 /**
@@ -30,129 +34,117 @@
  *
  */
 public enum GradientType {
-
     GLASS {
+        @Override
+        public BiColor getFirstLayerColors(BiColor biColor) {
+            Color bottomColor = biColor.getBottomColor();
 
-	@Override
-	public BiColor getFirstLayerColors(BiColor biColor) {
-	    Color bottomColor = biColor.getBottomColor();
-	    if (bottomColor != null) {
-		float[] hsb = Color.RGBtoHSB(bottomColor.getRed(), bottomColor.getGreen(), bottomColor.getBlue(), null);
+            if (bottomColor != null) {
+                float[] hsb = Color.RGBtoHSB(bottomColor.getRed(), bottomColor.getGreen(), bottomColor.getBlue(), null);
 
-		hsb[2] = 0.2f * hsb[2] + 0.80f; //(hsb[2] * 2) / 10 + 80;
-		hsb[1] = 0.5f * hsb[1];
+                hsb[2] = 0.2f * hsb[2] + 0.80f; // (hsb[2] * 2) / 10 + 80;
+                hsb[1] = 0.5f * hsb[1];
 
-		Color topColor = new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]));
+                Color topColor = new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]));
 
-		return new BiColor(bottomColor, topColor);
-	    } else {
-		return null;
-	    }
-	}
-
-	@Override
-	public BiColor getSecondLayerColors(BiColor biColor) {
-	    if (biColor.getBottomColor() != null) {
-		return WHITE;
-	    } else {
-		return null;
-	    }
-	}
-	
+                return new BiColor(bottomColor, topColor);
+            } else {
+                return null;
+            }
+        }
+        @Override
+        public BiColor getSecondLayerColors(BiColor biColor) {
+            if (biColor.getBottomColor() != null) {
+                return WHITE;
+            } else {
+                return null;
+            }
+        }
     },
-    
     PLASTIC {
+        @Override
+        public BiColor getFirstLayerColors(BiColor biColor) {
+            Color bottomColor = biColor.getBottomColor();
 
-	@Override
-	public BiColor getFirstLayerColors(BiColor biColor) {
-	    Color bottomColor = biColor.getBottomColor();
-	    if (bottomColor != null) {
-		float[] hsb = Color.RGBtoHSB(bottomColor.getRed(), bottomColor.getGreen(), bottomColor.getBlue(), null);
+            if (bottomColor != null) {
+                float[] hsb = Color.RGBtoHSB(bottomColor.getRed(), bottomColor.getGreen(), bottomColor.getBlue(), null);
 
-		hsb[2] = 0.25f * hsb[2] + 0.75f; //(100 - hsb[2]) * 0.75f + hsb[2];
-		hsb[1] = 0.75f * hsb[1];
+                hsb[2] = 0.25f * hsb[2] + 0.75f; // (100 - hsb[2]) * 0.75f + hsb[2];
+                hsb[1] = 0.75f * hsb[1];
 
-		Color topColor = new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]));
+                Color topColor = new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]));
 
-		return new BiColor(topColor, bottomColor);
-	    } else {
-		return null;
-	    }
-	}
-
-	@Override
-	public BiColor getSecondLayerColors(BiColor biColor) {
-	    if (biColor.getBottomColor() != null) {
-		return WHITE;
-	    } else {
-		return null;
-	    }
-	}
-	
+                return new BiColor(topColor, bottomColor);
+            } else {
+                return null;
+            }
+        }
+        @Override
+        public BiColor getSecondLayerColors(BiColor biColor) {
+            if (biColor.getBottomColor() != null) {
+                return WHITE;
+            } else {
+                return null;
+            }
+        }
     },
-    
     PLAIN {
+        @Override
+        public BiColor getFirstLayerColors(BiColor biColor) {
+            if ((biColor.getBottomColor() != null) && (biColor.getTopColor() != null)) {
+                return biColor;
+            } else {
+                return null;
+            }
+        }
+        @Override
+        public BiColor getSecondLayerColors(BiColor biColor) {
+            return null;
+        }
+    };
 
-	@Override
-	public BiColor getFirstLayerColors(BiColor biColor) {
-	    if (biColor.getBottomColor() != null && biColor.getTopColor() != null) {
-		return biColor;
-	    } else {
-		return null;
-	    }
-	}
+    private static final BiColor WHITE = new BiColor(new Color(0xff, 0xff, 0xff, (int) (0.65f * 0xff)),
+                                             new Color(0xff, 0xff, 0xff, (int) (0.20f * 0xff)));
 
-	@Override
-	public BiColor getSecondLayerColors(BiColor biColor) {
-	    return null;
-	}
-	
-    };
-    
     public static final GradientType getByParameter(String string) {
-	if (string == null || string.length() == 0) {
-	    return PLAIN;
-	}
-	
-	return GradientType.valueOf(string.toUpperCase(Locale.US));
+        if ((string == null) || (string.length() == 0)) {
+            return PLAIN;
+        }
+
+        return GradientType.valueOf(string.toUpperCase(Locale.US));
     }
-    
+
     public abstract BiColor getFirstLayerColors(BiColor biColor);
+
     public abstract BiColor getSecondLayerColors(BiColor biColor);
-    
-    private static final BiColor WHITE = new BiColor(new Color(0xff, 0xff, 0xff, (int) (0.65f * 0xff)),
-	    new Color(0xff, 0xff, 0xff, (int) (0.20f * 0xff)));
-	
+
     public static class BiColor {
-	private Color topColor;
-	private Color bottomColor;
+        private Color bottomColor;
+        private Color topColor;
 
-	public BiColor(Color topColor, Color bottomColor) {
-	    super();
+        public BiColor(Color topColor, Color bottomColor) {
+            super();
+            this.topColor = topColor;
+            this.bottomColor = bottomColor;
+        }
 
-	    this.topColor = topColor;
-	    this.bottomColor = bottomColor;
-	}
+        public BiColor(Integer topColor, Integer bottomColor) {
+            super();
+            this.topColor = (topColor != null) ? new Color(topColor.intValue()) : null;
+            this.bottomColor = (bottomColor != null) ? new Color(bottomColor.intValue()) : null;
+        }
 
-	public BiColor(Integer topColor, Integer bottomColor) {
-	    super();
+        public Color getTopColor() {
+            return topColor;
+        }
 
-	    this.topColor = topColor != null ? new Color(topColor.intValue()) : null;
-	    this.bottomColor = bottomColor != null ? new Color(bottomColor.intValue()) : null;
-	}
-	
-	public Color getTopColor() {
-	    return topColor;
-	}
+        public Color getBottomColor() {
+            return bottomColor;
+        }
 
-	public Color getBottomColor() {
-	    return bottomColor;
-	}
-
-	@Override
-	public String toString() {
-	    return "BiColor: [" + topColor + " -> " + bottomColor + "]";
-	}
-    };
-    
+        @Override
+        public String toString() {
+            return "BiColor: [" + topColor + " -> " + bottomColor + "]";
+        }
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,14 +19,15 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit.html.images;
 
+import org.richfaces.skin.Skin;
+
 import javax.faces.context.FacesContext;
 
-import org.richfaces.skin.Skin;
-
 public class StandardButtonBgImage extends BaseControlBackgroundImage {
-
     public StandardButtonBgImage() {
         super(Skin.ADDITIONAL_BACKGROUND_COLOR, "trimColor", 9);
     }
@@ -34,5 +35,4 @@
     protected Integer getHeight(FacesContext context) {
         return (int) (1.7 * super.getHeight(context, Skin.BUTTON_SIZE_FONT));
     }
-
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,14 +19,15 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit.html.images;
 
+import org.richfaces.skin.Skin;
+
 import javax.faces.context.FacesContext;
 
-import org.richfaces.skin.Skin;
-
 public class StandardButtonPressedBgImage extends BaseControlBackgroundImage {
-
     public StandardButtonPressedBgImage() {
         super("trimColor", Skin.ADDITIONAL_BACKGROUND_COLOR, 9);
     }
@@ -34,5 +35,4 @@
     protected Integer getHeight(FacesContext context) {
         return (int) (1.7 * super.getHeight(context, Skin.BUTTON_SIZE_FONT));
     }
-
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/package-info.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/package-info.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/package-info.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,3 +1,4 @@
+
 /**
  * Control and background images
  */

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/package-info.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/package-info.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/package-info.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,3 +1,4 @@
+
 /**
  * HTML-specific renderer classes
  */

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/package-info.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/package-info.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/package-info.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,3 +1,4 @@
+
 /**
  * Classes participating in components rendering
  */

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,15 +19,30 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
+import org.ajax4jsf.resource.InternetResource;
+
+import org.richfaces.context.SingletonsContext;
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.util.Util;
+
+import org.slf4j.Logger;
+
+import static org.richfaces.resource.ResourceUtils.*;
+
 import java.io.IOException;
 import java.io.InputStream;
+
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLStreamHandler;
+
 import java.text.MessageFormat;
+
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -37,52 +52,38 @@
 import javax.faces.component.StateHolder;
 import javax.faces.context.FacesContext;
 
-import org.ajax4jsf.resource.InternetResource;
-import org.richfaces.context.SingletonsContext;
-import org.richfaces.log.RichfacesLogger;
-import org.richfaces.util.Util;
-import org.slf4j.Logger;
-
-import static org.richfaces.resource.ResourceUtils.*;
-
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public abstract class AbstractBaseResource extends AbstractCacheableResource implements VersionedResource {
+    public static final String URL_PROTOCOL = "jsfresource";
+    private static final Logger LOGGER = RichfacesLogger.RESOURCE.getLogger();
+    private boolean cacheable = true;
+    private Date lastModified = null;
+    private String version;
 
-	private static final Logger LOGGER = RichfacesLogger.RESOURCE.getLogger();
+    protected AbstractBaseResource() {
+        super();
+        this.setResourceName(getClass().getName());
+    }
 
-	public static final String URL_PROTOCOL = "jsfresource";
-	
-	private boolean cacheable = true;
-	
-	private String version;
-	
-	private Date lastModified = null;
+    // TODO remove FacesContext argument?
+    protected int getContentLength(FacesContext context) {
+        return -1;
+    }
 
-    protected AbstractBaseResource() {
-		super();
-		
-		this.setResourceName(getClass().getName());
-	}
-	
-	//TODO remove FacesContext argument?
-	protected int getContentLength(FacesContext context) {
-		return -1;
-	}
-
-	/**
-	 * <b>IMPORTANT:</b> this method returned TTL in RF 3.x, now it returns expiration time
+    /**
+     * <b>IMPORTANT:</b> this method returned TTL in RF 3.x, now it returns expiration time
      * @return Returns the expired.
-	 */
-	protected Date getExpires(FacesContext context) {
-		return null;
-	}
+     */
+    protected Date getExpires(FacesContext context) {
+        return null;
+    }
 
-	protected int getTimeToLive(FacesContext context) {
-		return 0;
-	}
+    protected int getTimeToLive(FacesContext context) {
+        return 0;
+    }
 
     /**
      * TODO optimize/review?
@@ -94,14 +95,17 @@
             lastModified = getLastModifiedBySource();
         }
 
-        //TODO - originally lastModified was set during resource creation.
-        //as resources can be managed beans this approach does not seem good
+        // TODO - originally lastModified was set during resource creation.
+        // as resources can be managed beans this approach does not seem good
         if (lastModified == null) {
-            lastModified = (Date) SingletonsContext.APPLICATION.get(context).
-                    getAttribute(ResourceHandlerImpl.HANDLER_START_TIME_ATTRIBUTE);
+            lastModified = (Date) SingletonsContext.APPLICATION.get(context).getAttribute(
+                ResourceHandlerImpl.HANDLER_START_TIME_ATTRIBUTE);
 
             if (LOGGER.isDebugEnabled()) {
-                LOGGER.debug(MessageFormat.format("Using resource handler start time as last modified date: {0,date,dd MMM yyyy HH:mm:ss zzz}", lastModified));
+                LOGGER.debug(
+                    MessageFormat.format(
+                        "Using resource handler start time as last modified date: {0,date,dd MMM yyyy HH:mm:ss zzz}",
+                        lastModified));
             }
         }
 
@@ -110,11 +114,13 @@
 
     private Date getLastModifiedBySource() {
         ClassLoader classLoader = getClassLoader();
+
         if (classLoader == null) {
             return null;
         }
 
         URL classResource = classLoader.getResource(getClass().getName().replace('.', '/') + ".class");
+
         if (classResource != null) {
             if (LOGGER.isDebugEnabled()) {
                 LOGGER.debug(MessageFormat.format("Located source for the resource class: {0}", classResource));
@@ -122,8 +128,11 @@
 
             try {
                 URLConnection connection = classResource.openConnection();
+
                 connection.setUseCaches(false);
+
                 long classLastModifiedDate = connection.getLastModified();
+
                 if (classLastModifiedDate > 0) {
                     lastModified = new Date(classLastModifiedDate);
 
@@ -132,6 +141,7 @@
                     }
                 }
             } catch (IOException e) {
+
                 // TODO Auto-generated catch block
                 e.printStackTrace();
             }
@@ -147,30 +157,32 @@
     private ClassLoader getClassLoader() {
         Class<? extends AbstractBaseResource> thisClass = getClass();
         ClassLoader classLoader = thisClass.getClassLoader();
+
         if (classLoader == null) {
             classLoader = ClassLoader.getSystemClassLoader();
         }
+
         return classLoader;
     }
 
     /**
-	 * @return Returns the cacheable.
-	 */
-	@Override
+     * @return Returns the cacheable.
+     */
+    @Override
     public boolean isCacheable(FacesContext context) {
-		return cacheable;
-	}
-	
-	protected void setCacheable(boolean cacheable) {
-		this.cacheable = cacheable;
-	}
+        return cacheable;
+    }
 
+    protected void setCacheable(boolean cacheable) {
+        this.cacheable = cacheable;
+    }
+
     @Override
     protected String getEntityTag(FacesContext context) {
         int contentLength = getContentLength(context);
         Date lastModified = getLastModified(context);
 
-        if (contentLength < 0 || lastModified == null) {
+        if ((contentLength < 0) || (lastModified == null)) {
             return null;
         }
 
@@ -178,128 +190,136 @@
     }
 
     @Override
-	public abstract InputStream getInputStream();
+    public abstract InputStream getInputStream();
 
-	@Override
-	public String getRequestPath() {
-		//TODO - cache resource request path in request scope
-		
-		FacesContext context = FacesContext.getCurrentInstance();
-		ResourceCodec resourceCodec = ResourceHandlerImpl.getResourceCodec(context);
+    @Override
+    public String getRequestPath() {
 
-		String resourceName = getResourceName();
-		Object resourceData = null;
-		if (this instanceof StateHolder) {
-			StateHolder stateHolder = (StateHolder) this;
-			if (!stateHolder.isTransient()) {
-				resourceData = stateHolder.saveState(context);
-			}
-		}
+        // TODO - cache resource request path in request scope
+        FacesContext context = FacesContext.getCurrentInstance();
+        ResourceCodec resourceCodec = ResourceHandlerImpl.getResourceCodec(context);
+        String resourceName = getResourceName();
+        Object resourceData = null;
 
-		String resourceVersion = getVersion();
-		
-		String resourceUri = ResourceHandlerImpl.RICHFACES_RESOURCE_IDENTIFIER + 
-			resourceCodec.encodeResource(resourceName, resourceData, resourceVersion);
-		
-		resourceUri = Util.encodeResourceURL(context, resourceUri);
+        if (this instanceof StateHolder) {
+            StateHolder stateHolder = (StateHolder) this;
 
-		if (LOGGER.isDebugEnabled()) {
-			LOGGER.debug(MessageFormat.format("Request path for {0} resource is: {1}", 
-				String.valueOf(resourceName), String.valueOf(resourceUri)));
-		}
-		
-		return resourceUri;
-	}
+            if (!stateHolder.isTransient()) {
+                resourceData = stateHolder.saveState(context);
+            }
+        }
 
-	public String getVersion() {
-		return version;
-	}
-	
-	protected void setVersion(String version) {
-		this.version = version;
-	}
-	
+        String resourceVersion = getVersion();
+        String resourceUri = ResourceHandlerImpl.RICHFACES_RESOURCE_IDENTIFIER
+                             + resourceCodec.encodeResource(resourceName, resourceData, resourceVersion);
+
+        resourceUri = Util.encodeResourceURL(context, resourceUri);
+
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug(MessageFormat.format("Request path for {0} resource is: {1}", String.valueOf(resourceName),
+                                              String.valueOf(resourceUri)));
+        }
+
+        return resourceUri;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    protected void setVersion(String version) {
+        this.version = version;
+    }
+
     boolean isResourceRequest() {
         FacesContext facesContext = FacesContext.getCurrentInstance();
-    	return (facesContext.getApplication().getResourceHandler().isResourceRequest(facesContext));
+
+        return facesContext.getApplication().getResourceHandler().isResourceRequest(facesContext);
     }
 
     long getCurrentTime() {
-    	return System.currentTimeMillis();
+        return System.currentTimeMillis();
     }
-    
-	@Override
-	public Map<String, String> getResponseHeaders() {
-		Map<String, String> headers = new HashMap<String, String>();
+
+    @Override
+    public Map<String, String> getResponseHeaders() {
+        Map<String, String> headers = new HashMap<String, String>();
         FacesContext facesContext = FacesContext.getCurrentInstance();
-		
-		if (isResourceRequest()) {
-			int contentLength = getContentLength(facesContext);
-			if (contentLength >= 0) {
-				headers.put("Content-Length", String.valueOf(contentLength));
-			}
-			
-			String contentType = getContentType();
-			if (contentType != null) {
-				//TODO add content-encoding?
-				headers.put("Content-Type", contentType);
-			}
-			
-			Date lastModified = getLastModified(facesContext);
-			if (lastModified != null) {
-				headers.put("Last-Modified", Util.formatHttpDate(lastModified));
-			}
 
-			if (isCacheable(facesContext)) {
-				long currentTime = getCurrentTime();
+        if (isResourceRequest()) {
+            int contentLength = getContentLength(facesContext);
 
-				String formattedExpireDate;
-				long maxAge = getTimeToLive(facesContext);
-				
-				if (maxAge > 0) {
-					formattedExpireDate = Util.formatHttpDate(currentTime + secondToMillis(maxAge));
-				} else {
-					Date expired = getExpires(facesContext);
-					if (expired != null) {
-						formattedExpireDate = Util.formatHttpDate(expired);
-						maxAge = millisToSecond(expired.getTime() - currentTime);
-					} else {
-						maxAge = InternetResource.DEFAULT_TTL;
-						formattedExpireDate = Util.formatHttpDate(currentTime + secondToMillis(maxAge));
-					}
-				}
-				
-				if (formattedExpireDate != null) {
-					headers.put("Expires", formattedExpireDate);
-				}
-				if (maxAge > 0) {
-					headers.put("Cache-Control", "max-age=" + maxAge);
-				}
-				
-				String entityTag = getEntityTag(facesContext);
-				if (entityTag != null) {
-					headers.put("ETag", entityTag);
-				}
-			} else {
-				headers.put("Expires", "0");
-				headers.put("Cache-Control", "max-age=0, no-store, no-cache");
-				headers.put("Pragma", "no-cache");
-			}
-			
-			headers.put("Date", Util.formatHttpDate(getCurrentTime()));
-			
-			if (LOGGER.isDebugEnabled()) {
-				LOGGER.debug("Created set of response headers");
-				//TODO - security - can we log header values?
-				for (Entry<String, String> entry : headers.entrySet()) {
-					LOGGER.debug(MessageFormat.format("\t{0}={1}", entry.getKey(), entry.getValue()));
-				}
-			}
-		}
-		
-		return headers;
-	}
+            if (contentLength >= 0) {
+                headers.put("Content-Length", String.valueOf(contentLength));
+            }
 
+            String contentType = getContentType();
+
+            if (contentType != null) {
+
+                // TODO add content-encoding?
+                headers.put("Content-Type", contentType);
+            }
+
+            Date lastModified = getLastModified(facesContext);
+
+            if (lastModified != null) {
+                headers.put("Last-Modified", Util.formatHttpDate(lastModified));
+            }
+
+            if (isCacheable(facesContext)) {
+                long currentTime = getCurrentTime();
+                String formattedExpireDate;
+                long maxAge = getTimeToLive(facesContext);
+
+                if (maxAge > 0) {
+                    formattedExpireDate = Util.formatHttpDate(currentTime + secondToMillis(maxAge));
+                } else {
+                    Date expired = getExpires(facesContext);
+
+                    if (expired != null) {
+                        formattedExpireDate = Util.formatHttpDate(expired);
+                        maxAge = millisToSecond(expired.getTime() - currentTime);
+                    } else {
+                        maxAge = InternetResource.DEFAULT_TTL;
+                        formattedExpireDate = Util.formatHttpDate(currentTime + secondToMillis(maxAge));
+                    }
+                }
+
+                if (formattedExpireDate != null) {
+                    headers.put("Expires", formattedExpireDate);
+                }
+
+                if (maxAge > 0) {
+                    headers.put("Cache-Control", "max-age=" + maxAge);
+                }
+
+                String entityTag = getEntityTag(facesContext);
+
+                if (entityTag != null) {
+                    headers.put("ETag", entityTag);
+                }
+            } else {
+                headers.put("Expires", "0");
+                headers.put("Cache-Control", "max-age=0, no-store, no-cache");
+                headers.put("Pragma", "no-cache");
+            }
+
+            headers.put("Date", Util.formatHttpDate(getCurrentTime()));
+
+            if (LOGGER.isDebugEnabled()) {
+                LOGGER.debug("Created set of response headers");
+
+                // TODO - security - can we log header values?
+                for (Entry<String, String> entry : headers.entrySet()) {
+                    LOGGER.debug(MessageFormat.format("\t{0}={1}", entry.getKey(), entry.getValue()));
+                }
+            }
+        }
+
+        return headers;
+    }
+
     @Override
     public URL getURL() {
         try {
@@ -309,26 +329,18 @@
         }
     }
 
-    private class MyURLStreamHandler extends URLStreamHandler {
-
-        @Override
-        protected URLConnection openConnection(URL u) throws IOException {
-            return new MyURLConnection(u);
-        }
-    }
-
     private class MyURLConnection extends URLConnection {
         MyURLConnection(URL u) {
             super(u);
         }
 
         @Override
-        public void connect() throws IOException {
-        }
+        public void connect() throws IOException {}
 
         @Override
         public int getContentLength() {
             FacesContext facesContext = FacesContext.getCurrentInstance();
+
             return AbstractBaseResource.this.getContentLength(facesContext);
         }
 
@@ -341,11 +353,13 @@
         public long getExpiration() {
             FacesContext facesContext = FacesContext.getCurrentInstance();
             long ttl = AbstractBaseResource.this.getTimeToLive(facesContext);
+
             if (ttl > 0) {
                 return System.currentTimeMillis() + secondToMillis(ttl);
             }
 
             Date date = AbstractBaseResource.this.getExpires(facesContext);
+
             if (date != null) {
                 return date.getTime();
             }
@@ -357,6 +371,7 @@
         public long getLastModified() {
             FacesContext facesContext = FacesContext.getCurrentInstance();
             Date date = AbstractBaseResource.this.getLastModified(facesContext);
+
             if (date != null) {
                 return date.getTime();
             }
@@ -369,4 +384,12 @@
             return AbstractBaseResource.this.getInputStream();
         }
     }
+
+
+    private class MyURLStreamHandler extends URLStreamHandler {
+        @Override
+        protected URLConnection openConnection(URL u) throws IOException {
+            return new MyURLConnection(u);
+        }
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractCacheableResource.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractCacheableResource.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractCacheableResource.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,8 +18,16 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.richfaces.resource;
 
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.util.Util;
+
+import org.slf4j.Logger;
+
 import java.util.Date;
 import java.util.Map;
 
@@ -27,16 +35,11 @@
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 
-import org.richfaces.log.RichfacesLogger;
-import org.richfaces.util.Util;
-import org.slf4j.Logger;
-
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public abstract class AbstractCacheableResource extends Resource {
-
     private static final Logger LOGGER = RichfacesLogger.RESOURCE.getLogger();
 
     protected abstract Date getLastModified(FacesContext context);
@@ -45,9 +48,9 @@
 
     protected abstract String getEntityTag(FacesContext context);
 
-    //TODO add getExpired(FacesContext) for HTTP matching headers?
+    // TODO add getExpired(FacesContext) for HTTP matching headers?
+    private static boolean isUserCopyActual(Date lastModified, Date modifiedCondition) {
 
-    private static boolean isUserCopyActual(Date lastModified, Date modifiedCondition) {
         // 1000 ms due to round modification time to seconds.
         return (lastModified.getTime() - modifiedCondition.getTime()) <= 1000;
     }
@@ -67,6 +70,7 @@
 
     protected boolean isMatchesLastModified(FacesContext context, String modifiedCondition) {
         Date lastModified = getLastModified(context);
+
         if (lastModified == null) {
             return false;
         }
@@ -86,8 +90,10 @@
 
         return isMatchesEntityTag(context, matchHeaderValue);
     }
+
     protected boolean isMatchesEntityTag(FacesContext context, String matchHeaderValue) {
         String resourceEntityTag = getEntityTag(context);
+
         if (resourceEntityTag == null) {
             return false;
         }
@@ -110,14 +116,15 @@
         String modifiedCondition = requestHeaderMap.get("If-Modified-Since");
         String matchHeaderValue = requestHeaderMap.get("If-None-Match");
 
-        if (modifiedCondition == null && matchHeaderValue == null) {
+        if ((modifiedCondition == null) && (matchHeaderValue == null)) {
             if (LOGGER.isDebugEnabled()) {
                 LOGGER.debug("User agent cache check: no cache information was provided in request");
             }
+
             return true;
         }
 
-        if (matchHeaderValue != null && !isMatchesEntityTag(context, matchHeaderValue)) {
+        if ((matchHeaderValue != null) && !isMatchesEntityTag(context, matchHeaderValue)) {
             if (LOGGER.isDebugEnabled()) {
                 LOGGER.debug("User agent cache check: entity tags don't match");
             }
@@ -125,14 +132,14 @@
             return true;
         }
 
-        if (modifiedCondition != null && !isMatchesLastModified(context, modifiedCondition)) {
+        if ((modifiedCondition != null) && !isMatchesLastModified(context, modifiedCondition)) {
             if (LOGGER.isDebugEnabled()) {
                 LOGGER.debug("User agent cache check: resource was modified since the last request");
             }
+
             return true;
         }
 
         return false;
     }
-
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,15 +19,21 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
+import org.w3c.dom.Node;
+
 import java.awt.*;
 import java.awt.color.ColorSpace;
 import java.awt.image.BufferedImage;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+
 import java.util.Iterator;
 
 import javax.imageio.IIOImage;
@@ -39,32 +45,29 @@
 import javax.imageio.metadata.IIOMetadataNode;
 import javax.imageio.stream.ImageOutputStream;
 
-import org.w3c.dom.Node;
-
 public class AnimatedTestResource extends TestResource2 {
+    private static final int DELAY_TIME = 50;
+    private static final int FRAMES_COUNT = 10;
 
-	private static final int FRAMES_COUNT = 10;
+    private static ImageWriter getImageWriter() {
+        ImageWriter result = null;
+        Iterator<ImageWriter> imageWriters = ImageIO.getImageWritersByFormatName("gif");
 
-	private static final int DELAY_TIME = 50;
+        while (imageWriters.hasNext() && (result == null)) {
+            ImageWriter imageWriter = imageWriters.next();
 
-    private static ImageWriter getImageWriter() {
-		ImageWriter result = null;
-		
-		Iterator<ImageWriter> imageWriters = ImageIO.getImageWritersByFormatName("gif");
-		while (imageWriters.hasNext() && result == null) {
-			ImageWriter imageWriter = imageWriters.next();
-			if (imageWriter.canWriteSequence()) {
-				result = imageWriter;
-			}
-		}
-		
-		return result;
-	}
+            if (imageWriter.canWriteSequence()) {
+                result = imageWriter;
+            }
+        }
 
+        return result;
+    }
+
     private static Node getOrCreateChild(Node root, String name) {
         Node result = null;
 
-        for (Node node = root.getFirstChild(); node != null && result == null; node = node.getNextSibling()) {
+        for (Node node = root.getFirstChild(); (node != null) && (result == null); node = node.getNextSibling()) {
             if (name.equals(node.getNodeName())) {
                 result = node;
             }
@@ -77,88 +80,89 @@
 
         return result;
     }
-    
-	@Override
-	public String getContentType() {
-		return "image/gif";
-	}
 
-	@Override
-	public InputStream getInputStream() {
-		GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
+    @Override
+    public String getContentType() {
+        return "image/gif";
+    }
+
+    @Override
+    public InputStream getInputStream() {
+        GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
         Dimension dimension = getDimension();
         BufferedImage image = new BufferedImage(dimension.width, dimension.height, ColorSpace.TYPE_RGB);
-		Graphics2D g2d = environment.createGraphics(image);
+        Graphics2D g2d = environment.createGraphics(image);
+        ImageWriter sequenceCapableImageWriter = getImageWriter();
 
-		ImageWriter sequenceCapableImageWriter = getImageWriter();
-		if (sequenceCapableImageWriter == null) {
-			throw new IllegalStateException("No sequence-capable image writers exit");
-		}
-		
-		ByteArrayOutputStream baos = new ByteArrayOutputStream();
-		ImageOutputStream imageOutputStream = null;
-		
-		try {
-			imageOutputStream = ImageIO.createImageOutputStream(baos);
-			sequenceCapableImageWriter.setOutput(imageOutputStream);
-			ImageWriteParam defaultImageWriteParam = sequenceCapableImageWriter.getDefaultWriteParam();
-			ImageTypeSpecifier imageTypeSpecifier = ImageTypeSpecifier.createFromBufferedImageType(image.getType());
-			IIOMetadata imageMetaData = sequenceCapableImageWriter.
-				getDefaultImageMetadata(imageTypeSpecifier, defaultImageWriteParam);
-			
-			String metaFormatName = imageMetaData.getNativeMetadataFormatName();
-			Node root = imageMetaData.getAsTree(metaFormatName);
-			IIOMetadataNode graphicsControlExtensionNode = (IIOMetadataNode) getOrCreateChild(root, "GraphicControlExtension");
+        if (sequenceCapableImageWriter == null) {
+            throw new IllegalStateException("No sequence-capable image writers exit");
+        }
 
-			// http://java.sun.com/javase/6/docs/api/javax/imageio/metadata/doc-files/gif_metadata.html
-			graphicsControlExtensionNode.setAttribute("disposalMethod", "none");
-			graphicsControlExtensionNode.setAttribute("userInputFlag", "FALSE");
-			graphicsControlExtensionNode.setAttribute("transparentColorFlag", "FALSE");
-			graphicsControlExtensionNode.setAttribute("delayTime", Integer.toString(DELAY_TIME));
-			graphicsControlExtensionNode.setAttribute("transparentColorIndex", "0");
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ImageOutputStream imageOutputStream = null;
 
-			boolean loopContinuously = false;
-			Node applicationExtensionsNode = getOrCreateChild(root, "ApplicationExtensions");
-			IIOMetadataNode netscapeExtension = new IIOMetadataNode("ApplicationExtension");
+        try {
+            imageOutputStream = ImageIO.createImageOutputStream(baos);
+            sequenceCapableImageWriter.setOutput(imageOutputStream);
 
-			netscapeExtension.setAttribute("applicationID", "NETSCAPE");
-			netscapeExtension.setAttribute("authenticationCode", "2.0");
+            ImageWriteParam defaultImageWriteParam = sequenceCapableImageWriter.getDefaultWriteParam();
+            ImageTypeSpecifier imageTypeSpecifier = ImageTypeSpecifier.createFromBufferedImageType(image.getType());
+            IIOMetadata imageMetaData = sequenceCapableImageWriter.getDefaultImageMetadata(imageTypeSpecifier,
+                                            defaultImageWriteParam);
+            String metaFormatName = imageMetaData.getNativeMetadataFormatName();
+            Node root = imageMetaData.getAsTree(metaFormatName);
+            IIOMetadataNode graphicsControlExtensionNode = (IIOMetadataNode) getOrCreateChild(root,
+                                                               "GraphicControlExtension");
 
-			byte numLoops = (byte) (loopContinuously ? 0x0 : 0x1);
+            // http://java.sun.com/javase/6/docs/api/javax/imageio/metadata/doc-files/gif_metadata.html
+            graphicsControlExtensionNode.setAttribute("disposalMethod", "none");
+            graphicsControlExtensionNode.setAttribute("userInputFlag", "FALSE");
+            graphicsControlExtensionNode.setAttribute("transparentColorFlag", "FALSE");
+            graphicsControlExtensionNode.setAttribute("delayTime", Integer.toString(DELAY_TIME));
+            graphicsControlExtensionNode.setAttribute("transparentColorIndex", "0");
+
+            boolean loopContinuously = false;
+            Node applicationExtensionsNode = getOrCreateChild(root, "ApplicationExtensions");
+            IIOMetadataNode netscapeExtension = new IIOMetadataNode("ApplicationExtension");
+
+            netscapeExtension.setAttribute("applicationID", "NETSCAPE");
+            netscapeExtension.setAttribute("authenticationCode", "2.0");
+
+            byte numLoops = (byte) (loopContinuously ? 0x0 : 0x1);
+
             netscapeExtension.setUserObject(new byte[] {0x1, numLoops, 0x0});
-			applicationExtensionsNode.appendChild(netscapeExtension);
-			
-			imageMetaData.setFromTree(metaFormatName, root);
-			
-			sequenceCapableImageWriter.prepareWriteSequence(null);
+            applicationExtensionsNode.appendChild(netscapeExtension);
+            imageMetaData.setFromTree(metaFormatName, root);
+            sequenceCapableImageWriter.prepareWriteSequence(null);
 
             for (int i = 1; i <= FRAMES_COUNT; i++) {
-				g2d.setPaint(new GradientPaint(0, i * dimension.height / FRAMES_COUNT, Color.WHITE, 0, dimension.height, getColor()));
-				g2d.fillRect(0, 0, dimension.width, dimension.height);
-			
-				sequenceCapableImageWriter.writeToSequence(new IIOImage(image, null, imageMetaData), 
-					defaultImageWriteParam);
-			}
-			
-			sequenceCapableImageWriter.endWriteSequence();
-			
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		} finally {
-			if (imageOutputStream != null) {
-				try {
-					imageOutputStream.close();
-				} catch (IOException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
-			}
-			g2d.dispose();
-			sequenceCapableImageWriter.dispose();
-		}
+                g2d.setPaint(new GradientPaint(0, i * dimension.height / FRAMES_COUNT, Color.WHITE, 0,
+                                               dimension.height, getColor()));
+                g2d.fillRect(0, 0, dimension.width, dimension.height);
+                sequenceCapableImageWriter.writeToSequence(new IIOImage(image, null, imageMetaData),
+                        defaultImageWriteParam);
+            }
 
-		return new ByteArrayInputStream(baos.toByteArray());
-	}
+            sequenceCapableImageWriter.endWriteSequence();
+        } catch (IOException e) {
 
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } finally {
+            if (imageOutputStream != null) {
+                try {
+                    imageOutputStream.close();
+                } catch (IOException e) {
+
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+
+            g2d.dispose();
+            sequenceCapableImageWriter.dispose();
+        }
+
+        return new ByteArrayInputStream(baos.toByteArray());
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/CachedResourceImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/CachedResourceImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/CachedResourceImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,12 +18,18 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.richfaces.resource;
 
 import java.io.IOException;
 import java.io.InputStream;
+
 import java.net.URL;
+
 import java.text.MessageFormat;
+
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Locale;
@@ -38,8 +44,10 @@
 import org.ajax4jsf.io.ByteBuffer;
 import org.ajax4jsf.io.FastBufferInputStream;
 import org.ajax4jsf.io.FastBufferOutputStream;
+
 import org.richfaces.log.RichfacesLogger;
 import org.richfaces.util.Util;
+
 import org.slf4j.Logger;
 
 import static org.richfaces.resource.ResourceUtils.*;
@@ -50,173 +58,174 @@
  */
 class CachedResourceImpl extends AbstractCacheableResource {
 
-	//[0..1]
-	private static final float CACHE_EXPIRATION_COEFFICIENT = 0.9f;
-	
-	private static final Logger LOGGER = RichfacesLogger.RESOURCE.getLogger();
-	
-	private static final int SMAX_AGE_GROUP = 1;
+    // [0..1]
+    private static final float CACHE_EXPIRATION_COEFFICIENT = 0.9f;
+    private static final Logger LOGGER = RichfacesLogger.RESOURCE.getLogger();
+    private static final int MAX_AGE_VALUE_GROUP = 2;
+    private static final int SMAX_AGE_GROUP = 1;
+    private static final Pattern MAX_AGE = Pattern.compile("^(?:(s-maxage)|max-age)=(\\d+)$", Pattern.CASE_INSENSITIVE);
+    private ByteBuffer content;
+    private String entityTag;
 
-	private static final int MAX_AGE_VALUE_GROUP = 2;
-
-	private static final Pattern MAX_AGE = Pattern.compile("^(?:(s-maxage)|max-age)=(\\d+)$", 
-			Pattern.CASE_INSENSITIVE);
-	
-	private Map<String, String> headers;
-	
-	private ByteBuffer content;
-	
-	private String entityTag;
-	
-	private Date lastModified;
-
-    /***
+    /**
      * serves only to define server cache entry expiration time only
      * browser cache expiration is controlled by stored HTTP headers value
      */
-	private Date expired;
-	
-	private void initializeFromHeaders() {
-		this.entityTag = null;
-		this.lastModified = null;
-		this.expired = null;
-		
-		Date expiredFromHeader = null;
-		//TODO what if maxAge = 0 in header?
-		int maxAge = 0;
+    private Date expired;
+    private Map<String, String> headers;
+    private Date lastModified;
 
-		for (Entry<String, String> headerEntry: headers.entrySet()) {
-			String headerKey = headerEntry.getKey().toLowerCase(Locale.US);
-			if ("etag".equals(headerKey)) {
-				this.entityTag = headerEntry.getValue();
-			}
+    private void initializeFromHeaders() {
+        this.entityTag = null;
+        this.lastModified = null;
+        this.expired = null;
 
+        Date expiredFromHeader = null;
+
+        // TODO what if maxAge = 0 in header?
+        int maxAge = 0;
+
+        for (Entry<String, String> headerEntry : headers.entrySet()) {
+            String headerKey = headerEntry.getKey().toLowerCase(Locale.US);
+
+            if ("etag".equals(headerKey)) {
+                this.entityTag = headerEntry.getValue();
+            }
+
             if ("last-modified".equals(headerKey)) {
-				this.lastModified = Util.parseHttpDate(headerEntry.getValue());
-			}
+                this.lastModified = Util.parseHttpDate(headerEntry.getValue());
+            }
 
             if ("expires".equals(headerKey)) {
-				expiredFromHeader = Util.parseHttpDate(headerEntry.getValue());
-			}
+                expiredFromHeader = Util.parseHttpDate(headerEntry.getValue());
+            }
 
             if ("cache-control".equals(headerKey)) {
-				String[] values = headerEntry.getValue().split(",");
+                String[] values = headerEntry.getValue().split(",");
 
-				for (String value : values) {
-					Matcher matcher = MAX_AGE.matcher(value.trim());
-					if (matcher.find()) {
-						boolean isSMaxAge = matcher.group(SMAX_AGE_GROUP) != null;
-						if (maxAge <= 0 || isSMaxAge) { // s-maxage overrides max-age
-							try {
-								maxAge = (int) secondToMillis(Integer.parseInt(matcher.group(MAX_AGE_VALUE_GROUP)));
-							} catch (NumberFormatException e) {
-								// TODO: handle exception
-								e.printStackTrace();
-							}
-						}
-					}
-				}
-			}
-		}
+                for (String value : values) {
+                    Matcher matcher = MAX_AGE.matcher(value.trim());
 
-		long currentTime = getCurrentTime();
-		if (maxAge > 0) {
-			this.expired = new Date((long) (currentTime + CACHE_EXPIRATION_COEFFICIENT * maxAge));
-		} else if (expiredFromHeader != null) {
-			// ttl = expireTime - currentTime
-			// CACHE_EXPIRATION_COEFFICIENT * ttl + currentTime
-			this.expired = new Date((long) (CACHE_EXPIRATION_COEFFICIENT * expiredFromHeader.getTime() + 
-				(1 - CACHE_EXPIRATION_COEFFICIENT) * currentTime));
-		} else {
-			//TODO throw exception or modify headers?
-		}
-	}
-	
-	long getCurrentTime() {
-		return System.currentTimeMillis();
-	}
-	
-	private static ByteBuffer readContent(InputStream is) throws IOException {
-		if (is == null) {
-			throw new NullPointerException("Resource input stream is null");
-		}
-		
-		FastBufferOutputStream os = new FastBufferOutputStream();
-		try {
-			Util.copyStreamContent(is, os);
-		} finally {
-			try {
-				is.close();
-			} catch (IOException e) {
-				if (LOGGER.isDebugEnabled()) {
-					LOGGER.debug(e.getMessage(), e);
-				}
-			}
+                    if (matcher.find()) {
+                        boolean isSMaxAge = matcher.group(SMAX_AGE_GROUP) != null;
 
-			try {
-				os.close();
-			} catch (IOException e) {
-				if (LOGGER.isDebugEnabled()) {
-					LOGGER.debug(e.getMessage(), e);
-				}
-			}
-		}
-		
-		ByteBuffer buffer = os.getFirstBuffer();
-		buffer.compact();
-		return buffer;
-	}
-	
-	public void initialize(Resource resource) throws IOException {
-		setResourceName(resource.getResourceName());
-		setContentType(resource.getContentType());
-		this.headers = resource.getResponseHeaders();
+                        if (maxAge <= 0 || isSMaxAge) { // s-maxage overrides max-age
+                            try {
+                                maxAge = (int) secondToMillis(Integer.parseInt(matcher.group(MAX_AGE_VALUE_GROUP)));
+                            } catch (NumberFormatException e) {
 
-		initializeFromHeaders();
-		this.content = readContent(resource.getInputStream());
-	}
-	
-	@Override
-	public InputStream getInputStream() {
-		return new FastBufferInputStream(content);
-	}
+                                // TODO: handle exception
+                                e.printStackTrace();
+                            }
+                        }
+                    }
+                }
+            }
+        }
 
-	@Override
-	public String getRequestPath() {
-		throw new UnsupportedOperationException();
-	}
+        long currentTime = getCurrentTime();
 
-	@Override
-	public Map<String, String> getResponseHeaders() {
-		return new HashMap<String, String>(headers);
-	}
+        if (maxAge > 0) {
+            this.expired = new Date((long) (currentTime + CACHE_EXPIRATION_COEFFICIENT * maxAge));
+        } else if (expiredFromHeader != null) {
 
-	@Override
-	public URL getURL() {
-		throw new UnsupportedOperationException();
-	}
+            // ttl = expireTime - currentTime
+            // CACHE_EXPIRATION_COEFFICIENT * ttl + currentTime
+            this.expired = new Date((long) (CACHE_EXPIRATION_COEFFICIENT * expiredFromHeader.getTime()
+                                            + (1 - CACHE_EXPIRATION_COEFFICIENT) * currentTime));
+        } else {
 
-	@Override
-	public boolean isCacheable(FacesContext context) {
-		return true;
-	}
-	
-	@Override
-	protected String getEntityTag(FacesContext context) {
-		return entityTag;
-	}
-	
-	@Override
-	protected Date getLastModified(FacesContext context) {
-		return lastModified;
-	}
-	
-	public Date getExpired(FacesContext context) {
-		return expired;
-	}
-	
-	@Override
-	public String toString() {
-		return MessageFormat.format("Cached resource: {0}", getResourceName());
-	}
+            // TODO throw exception or modify headers?
+        }
+    }
+
+    long getCurrentTime() {
+        return System.currentTimeMillis();
+    }
+
+    private static ByteBuffer readContent(InputStream is) throws IOException {
+        if (is == null) {
+            throw new NullPointerException("Resource input stream is null");
+        }
+
+        FastBufferOutputStream os = new FastBufferOutputStream();
+
+        try {
+            Util.copyStreamContent(is, os);
+        } finally {
+            try {
+                is.close();
+            } catch (IOException e) {
+                if (LOGGER.isDebugEnabled()) {
+                    LOGGER.debug(e.getMessage(), e);
+                }
+            }
+
+            try {
+                os.close();
+            } catch (IOException e) {
+                if (LOGGER.isDebugEnabled()) {
+                    LOGGER.debug(e.getMessage(), e);
+                }
+            }
+        }
+
+        ByteBuffer buffer = os.getFirstBuffer();
+
+        buffer.compact();
+
+        return buffer;
+    }
+
+    public void initialize(Resource resource) throws IOException {
+        setResourceName(resource.getResourceName());
+        setContentType(resource.getContentType());
+        this.headers = resource.getResponseHeaders();
+        initializeFromHeaders();
+        this.content = readContent(resource.getInputStream());
+    }
+
+    @Override
+    public InputStream getInputStream() {
+        return new FastBufferInputStream(content);
+    }
+
+    @Override
+    public String getRequestPath() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Map<String, String> getResponseHeaders() {
+        return new HashMap<String, String>(headers);
+    }
+
+    @Override
+    public URL getURL() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public boolean isCacheable(FacesContext context) {
+        return true;
+    }
+
+    @Override
+    protected String getEntityTag(FacesContext context) {
+        return entityTag;
+    }
+
+    @Override
+    protected Date getLastModified(FacesContext context) {
+        return lastModified;
+    }
+
+    public Date getExpired(FacesContext context) {
+        return expired;
+    }
+
+    @Override
+    public String toString() {
+        return MessageFormat.format("Cached resource: {0}", getResourceName());
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/DefaultResourceCodec.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/DefaultResourceCodec.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/DefaultResourceCodec.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,37 +19,34 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
 import org.richfaces.util.Util;
 
 final class DefaultResourceCodec implements ResourceCodec {
+    private static final ResourceCodec CODEC = new DefaultResourceCodec();
 
-	private static final ResourceCodec CODEC = new DefaultResourceCodec();
+    private DefaultResourceCodec() {}
 
-	private DefaultResourceCodec() {
-		
-	}
-	
-	public String decodeResourceName(String resourceKey) {
-		return Util.getResourceName(resourceKey);
-	}
+    public String decodeResourceName(String resourceKey) {
+        return Util.getResourceName(resourceKey);
+    }
 
-	public Object decodeResourceData(String resourceKey) {
-		return Util.getResourceData(resourceKey);
-	}
+    public Object decodeResourceData(String resourceKey) {
+        return Util.getResourceData(resourceKey);
+    }
 
-	public static ResourceCodec getInstance() {
-		return CODEC;
-	}
+    public static ResourceCodec getInstance() {
+        return CODEC;
+    }
 
-	public String decodeResourceVersion(String resourceKey) {
-		return Util.getResourceVersion(resourceKey);
-	}
+    public String decodeResourceVersion(String resourceKey) {
+        return Util.getResourceVersion(resourceKey);
+    }
 
-	public String encodeResource(String resourceName, Object resourceData,
-			String resourceVersion) {
-		return Util.encodeResourceData(resourceName, resourceData, resourceVersion);
-	}
-
-}
\ No newline at end of file
+    public String encodeResource(String resourceName, Object resourceData, String resourceVersion) {
+        return Util.encodeResourceData(resourceName, resourceData, resourceVersion);
+    }
+}

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceCodec.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceCodec.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceCodec.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.resource;
 
@@ -8,12 +9,11 @@
  * @since 4.0
  */
 public interface ResourceCodec {
+    public String encodeResource(String resourceName, Object resourceData, String resourceVersion);
 
-	public String encodeResource(String resourceName, Object resourceData, String resourceVersion);
-	
-	public String decodeResourceName(String resourceKey);
+    public String decodeResourceName(String resourceKey);
 
-	public Object decodeResourceData(String resourceKey);
+    public Object decodeResourceData(String resourceKey);
 
-	public String decodeResourceVersion(String resourceKey);
+    public String decodeResourceVersion(String resourceKey);
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,13 +19,29 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
+import org.ajax4jsf.cache.Cache;
+import org.ajax4jsf.cache.CacheManager;
+
+import org.richfaces.context.AttributesContext;
+import org.richfaces.context.SingletonsContext;
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.util.RequestStateManager.BooleanRequestStateVariable;
+import org.richfaces.util.Util;
+
+import org.slf4j.Logger;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+
 import java.net.URL;
+
 import java.text.MessageFormat;
+
 import java.util.Date;
 import java.util.Locale;
 import java.util.Map;
@@ -37,437 +53,447 @@
 import javax.faces.component.StateHolder;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
+
 import javax.imageio.ImageIO;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.ajax4jsf.cache.Cache;
-import org.ajax4jsf.cache.CacheManager;
-import org.richfaces.context.AttributesContext;
-import org.richfaces.context.SingletonsContext;
-import org.richfaces.log.RichfacesLogger;
-import org.richfaces.util.Util;
-import org.richfaces.util.RequestStateManager.BooleanRequestStateVariable;
-import org.slf4j.Logger;
-
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public class ResourceHandlerImpl extends ResourceHandler {
+    public static final String RICHFACES_RESOURCE_IDENTIFIER = "/rfRes/";
+    public static final String RESOURCE_CACHE_NAME = ResourceHandlerImpl.class.getName() + ":CACHE";
+    public static final String HANDLER_START_TIME_ATTRIBUTE = ResourceHandlerImpl.class.getName() + ":StartTime";
 
-	public static final String RICHFACES_RESOURCE_IDENTIFIER = "/rfRes/";
+    private static final String RESOURCE_CODEC_ATTRIBUTE_NAME = ResourceHandlerImpl.class.getName() + ":ResourceCodec";
+    private static final Logger LOGGER = RichfacesLogger.RESOURCE.getLogger();
 
-	public static final String HANDLER_START_TIME_ATTRIBUTE = ResourceHandlerImpl.class.getName() + 
-		":StartTime";
-	
-	public static final String RESOURCE_CACHE_NAME = ResourceHandlerImpl.class.getName() + ":CACHE";
-	
-	private static final Logger LOGGER = RichfacesLogger.RESOURCE.getLogger();
+    // TODO - review - do we need this?
+    static {
 
-	//TODO - review - do we need this?
-	static {
-		// set in-memory caching ImageIO
-		Thread thread = Thread.currentThread();
-		ClassLoader initialTCCL = thread.getContextClassLoader();
-		
-		try {
-			ClassLoader systemCL = ClassLoader.getSystemClassLoader();
-			thread.setContextClassLoader(systemCL);
-			ImageIO.setUseCache(false);
-		} finally {
-			thread.setContextClassLoader(initialTCCL);
-		}
-	}
+        // set in-memory caching ImageIO
+        Thread thread = Thread.currentThread();
+        ClassLoader initialTCCL = thread.getContextClassLoader();
 
-	
-	private ResourceHandler defaultHandler;
+        try {
+            ClassLoader systemCL = ClassLoader.getSystemClassLoader();
 
-	private Cache cache;
-	
-	public ResourceHandlerImpl(ResourceHandler defaultHandler) {
-		this.defaultHandler = defaultHandler;
+            thread.setContextClassLoader(systemCL);
+            ImageIO.setUseCache(false);
+        } finally {
+            thread.setContextClassLoader(initialTCCL);
+        }
+    }
 
-		if (LOGGER.isDebugEnabled()) {
-			LOGGER.debug(MessageFormat.format("Instance of {0} resource handler created", 
-				getClass().getName()));
-		}
-		
-		FacesContext facesContext = FacesContext.getCurrentInstance();
-		initializeCache(facesContext);
-		markStartTime(facesContext);
-	}
+    private Cache cache;
+    private ResourceHandler defaultHandler;
 
-	private void initializeCache(FacesContext facesContext) {
-		Map<?,?> envMap = facesContext.getExternalContext().getInitParameterMap();
-		cache = CacheManager.getInstance().getNewCache(RESOURCE_CACHE_NAME, envMap);
-	}
+    public ResourceHandlerImpl(ResourceHandler defaultHandler) {
+        this.defaultHandler = defaultHandler;
 
-	private static void markStartTime(FacesContext facesContext) {
-		AttributesContext applicationContext = SingletonsContext.APPLICATION.get(facesContext);
-		applicationContext.setAttribute(HANDLER_START_TIME_ATTRIBUTE, new Date());
-	}
-	
-	private static final String RESOURCE_CODEC_ATTRIBUTE_NAME = 
-		ResourceHandlerImpl.class.getName() + ":ResourceCodec";
-	
-	protected static void setResourceCodec(ResourceCodec codec) {
-		FacesContext facesContext = FacesContext.getCurrentInstance();
-		Map<String, Object> applicationMap = facesContext.getExternalContext().getApplicationMap();
-		Object oldCodec = applicationMap.put(RESOURCE_CODEC_ATTRIBUTE_NAME, codec);
-	
-		if (oldCodec != null && codec != null && !oldCodec.equals(codec) &&
-				facesContext.isProjectStage(ProjectStage.Development)) {
-			
-			LOGGER.warn("Resource codec should be typically set once per application lifetime");
-		}
-	}
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug(MessageFormat.format("Instance of {0} resource handler created", getClass().getName()));
+        }
 
-	public static ResourceCodec getResourceCodec(FacesContext context) {
-		Map<String, Object> applicationMap = context.getExternalContext().getApplicationMap();
-		ResourceCodec resourceCodec = (ResourceCodec) applicationMap.get(RESOURCE_CODEC_ATTRIBUTE_NAME);
-		if (resourceCodec == null) {
-			resourceCodec = DefaultResourceCodec.getInstance();
-		}
-		return resourceCodec;
-	}
-	
-	protected static String getResourceKey(FacesContext context) {
-		String resourceName = Util.decodeResourceURL(context);
-		if (resourceName != null) {
-			if (resourceName.startsWith(RICHFACES_RESOURCE_IDENTIFIER)) {
-				return resourceName.substring(RICHFACES_RESOURCE_IDENTIFIER.length());
-			} else {
-				return null;
-			}
-		} else {
-			//TODO log
-			return null;
-		}
-	}
+        FacesContext facesContext = FacesContext.getCurrentInstance();
 
-	protected boolean isThisHandlerResourceRequest(FacesContext context) {
-		Boolean resourceRequest = BooleanRequestStateVariable.ResourceRequest.get(context);
-		if (resourceRequest == null) {
-			String resourceKey = getResourceKey(context);
-			//TODO handle exclusions
-			resourceRequest = resourceKey != null && resourceKey.length() > 0;
-			BooleanRequestStateVariable.ResourceRequest.set(context, resourceRequest);
+        initializeCache(facesContext);
+        markStartTime(facesContext);
+    }
 
-			if (LOGGER.isDebugEnabled() && resourceRequest) {
-				LOGGER.debug(MessageFormat.format("Resource request detected: {0}", resourceKey));
-			}
-		}
+    private void initializeCache(FacesContext facesContext) {
+        Map<?, ?> envMap = facesContext.getExternalContext().getInitParameterMap();
 
-		return resourceRequest;
-	}
-	
-	@Override
+        cache = CacheManager.getInstance().getNewCache(RESOURCE_CACHE_NAME, envMap);
+    }
+
+    private static void markStartTime(FacesContext facesContext) {
+        AttributesContext applicationContext = SingletonsContext.APPLICATION.get(facesContext);
+
+        applicationContext.setAttribute(HANDLER_START_TIME_ATTRIBUTE, new Date());
+    }
+
+    protected static void setResourceCodec(ResourceCodec codec) {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        Map<String, Object> applicationMap = facesContext.getExternalContext().getApplicationMap();
+        Object oldCodec = applicationMap.put(RESOURCE_CODEC_ATTRIBUTE_NAME, codec);
+
+        if ((oldCodec != null) && (codec != null) && !oldCodec.equals(codec)
+                && facesContext.isProjectStage(ProjectStage.Development)) {
+            LOGGER.warn("Resource codec should be typically set once per application lifetime");
+        }
+    }
+
+    public static ResourceCodec getResourceCodec(FacesContext context) {
+        Map<String, Object> applicationMap = context.getExternalContext().getApplicationMap();
+        ResourceCodec resourceCodec = (ResourceCodec) applicationMap.get(RESOURCE_CODEC_ATTRIBUTE_NAME);
+
+        if (resourceCodec == null) {
+            resourceCodec = DefaultResourceCodec.getInstance();
+        }
+
+        return resourceCodec;
+    }
+
+    protected static String getResourceKey(FacesContext context) {
+        String resourceName = Util.decodeResourceURL(context);
+
+        if (resourceName != null) {
+            if (resourceName.startsWith(RICHFACES_RESOURCE_IDENTIFIER)) {
+                return resourceName.substring(RICHFACES_RESOURCE_IDENTIFIER.length());
+            } else {
+                return null;
+            }
+        } else {
+
+            // TODO log
+            return null;
+        }
+    }
+
+    protected boolean isThisHandlerResourceRequest(FacesContext context) {
+        Boolean resourceRequest = BooleanRequestStateVariable.ResourceRequest.get(context);
+
+        if (resourceRequest == null) {
+            String resourceKey = getResourceKey(context);
+
+            // TODO handle exclusions
+            resourceRequest = (resourceKey != null) && (resourceKey.length() > 0);
+            BooleanRequestStateVariable.ResourceRequest.set(context, resourceRequest);
+
+            if (LOGGER.isDebugEnabled() && resourceRequest) {
+                LOGGER.debug(MessageFormat.format("Resource request detected: {0}", resourceKey));
+            }
+        }
+
+        return resourceRequest;
+    }
+
+    @Override
     public boolean isResourceRequest(FacesContext context) {
-		return isThisHandlerResourceRequest(context) || defaultHandler.isResourceRequest(context);
-	}
+        return isThisHandlerResourceRequest(context) || defaultHandler.isResourceRequest(context);
+    }
 
-	private Resource lookupInCache(FacesContext context, String resourceKey) {
-		Resource resource = (Resource) cache.get(resourceKey);
+    private Resource lookupInCache(FacesContext context, String resourceKey) {
+        Resource resource = (Resource) cache.get(resourceKey);
 
-		if (LOGGER.isDebugEnabled()) {
-			if (resource == null) {
-				LOGGER.debug("Resource was not located in cache");
-			} else {
-				LOGGER.debug("Resource was located in cache");
-			}
-		}
+        if (LOGGER.isDebugEnabled()) {
+            if (resource == null) {
+                LOGGER.debug("Resource was not located in cache");
+            } else {
+                LOGGER.debug("Resource was located in cache");
+            }
+        }
 
-		return resource;
-	}
-	
-	private static void sendNotModified(FacesContext context) {
-		if (LOGGER.isDebugEnabled()) {
-			LOGGER.debug("User agent has actual resource copy - sending 304 status code");
-		}
-		
-		//TODO send cacheable resource headers (ETag + LastModified)?
-		context.getExternalContext().setResponseStatus(HttpServletResponse.SC_NOT_MODIFIED);
-	}
+        return resource;
+    }
 
-	private void logResourceProblem(FacesContext context, Throwable throwable, String messagePattern, Object... arguments) {
-		boolean isProductionStage = context.isProjectStage(ProjectStage.Production); 
-		if (LOGGER.isWarnEnabled() || (!isProductionStage && LOGGER.isInfoEnabled())) {
-			String formattedMessage = MessageFormat.format(messagePattern, arguments);
+    private static void sendNotModified(FacesContext context) {
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("User agent has actual resource copy - sending 304 status code");
+        }
 
-			if (throwable != null) {
-				LOGGER.warn(formattedMessage, throwable);
-			} else {
-				if (isProductionStage) {
-					LOGGER.info(formattedMessage);
-				} else {
-					LOGGER.warn(formattedMessage);
-				}
-			}
-		}
-	}
-	
-	private void logMissingResource(FacesContext context, String resourceData) {
-		logResourceProblem(context, null, "Resource {0} was not found", resourceData);
-	}
-	
-	private static void sendResourceNotFound(FacesContext context) {
-		context.getExternalContext().setResponseStatus(HttpServletResponse.SC_NOT_FOUND);
-	}
-	
-	@Override
+        // TODO send cacheable resource headers (ETag + LastModified)?
+        context.getExternalContext().setResponseStatus(HttpServletResponse.SC_NOT_MODIFIED);
+    }
+
+    private void logResourceProblem(FacesContext context, Throwable throwable, String messagePattern,
+                                    Object... arguments) {
+        boolean isProductionStage = context.isProjectStage(ProjectStage.Production);
+
+        if (LOGGER.isWarnEnabled() || (!isProductionStage && LOGGER.isInfoEnabled())) {
+            String formattedMessage = MessageFormat.format(messagePattern, arguments);
+
+            if (throwable != null) {
+                LOGGER.warn(formattedMessage, throwable);
+            } else {
+                if (isProductionStage) {
+                    LOGGER.info(formattedMessage);
+                } else {
+                    LOGGER.warn(formattedMessage);
+                }
+            }
+        }
+    }
+
+    private void logMissingResource(FacesContext context, String resourceData) {
+        logResourceProblem(context, null, "Resource {0} was not found", resourceData);
+    }
+
+    private static void sendResourceNotFound(FacesContext context) {
+        context.getExternalContext().setResponseStatus(HttpServletResponse.SC_NOT_FOUND);
+    }
+
+    @Override
     public void handleResourceRequest(FacesContext context) throws IOException {
-		if (isThisHandlerResourceRequest(context)) {
-			String resourceKey = getResourceKey(context);
-			
-			assert (resourceKey != null && resourceKey.length() != 0);
-			
-			Resource resource = lookupInCache(context, resourceKey);
-			if (resource == null) {
-				ResourceCodec resourceCodec = ResourceHandlerImpl.getResourceCodec(context);
-				String resourceName = resourceCodec.decodeResourceName(resourceKey);
-				if (resourceName == null || resourceName.length() == 0) {
-					logMissingResource(context, resourceKey);
-					sendResourceNotFound(context);
-					return;
-				}
-				
-				if (isResourceExists(resourceName)) {
-					resource = createHandlerDependentResource(resourceName);
-				}
+        if (isThisHandlerResourceRequest(context)) {
+            String resourceKey = getResourceKey(context);
 
-				if (resource == null) {
-					logMissingResource(context, resourceName);
-					sendResourceNotFound(context);
-					return;
-				}
-				
-				if (resource instanceof VersionedResource) {
-					VersionedResource versionedResource = (VersionedResource) resource;
-					String existingVersion = versionedResource.getVersion();
-					String requestedVersion = resourceCodec.decodeResourceVersion(resourceKey);
-					
-					if (LOGGER.isDebugEnabled()) {
-						LOGGER.debug(MessageFormat.format("Client requested {0} version of resource, server has {1} version", 
-							String.valueOf(requestedVersion), String.valueOf(existingVersion)));
-					}
-					
-					if (existingVersion != null && requestedVersion != null && 
-							!existingVersion.equals(requestedVersion)) {
-						
-						logResourceProblem(context, null, "Resource {0} of version {1} was not found", 
-							resourceName, requestedVersion);
-						
-						sendResourceNotFound(context);
-						return;
-					}
-				}
-				
-				if (resource instanceof StateHolder) {
-					StateHolder stateHolder = (StateHolder) resource;
-					Object decodedData = resourceCodec.decodeResourceData(resourceKey);
+            assert (resourceKey != null) && (resourceKey.length() != 0);
 
-					if (LOGGER.isDebugEnabled()) {
-						if (decodedData != null) {
-							LOGGER.debug("Resource state data succesfully decoded");
-						} else {
-							LOGGER.debug("Resource state data decoded as null");
-						}
-					}
-					
-					if (decodedData != null) {
-						stateHolder.restoreState(context, decodedData);
-					} else {
-						//resource was transient and didn't store data
-					}
-				}
-				
-				if (resource instanceof AbstractCacheableResource) {
-					AbstractCacheableResource cacheableResource = (AbstractCacheableResource) resource;
-					
-					if (cacheableResource.isCacheable(context)) {
-						//TODO - we could move this part of code to ConcurrentMap so that 
-						//only single thread does resource put
-						CachedResourceImpl cachedResource = new CachedResourceImpl();
-						cachedResource.initialize(resource);
+            Resource resource = lookupInCache(context, resourceKey);
 
-						//someone may provided this resource for us
-						//while we were reading it, check once again
-						resource = lookupInCache(context, resourceKey);
-						if (resource == null) {
-							Date cacheExpirationDate = cachedResource.getExpired(context);
-							
-							if (LOGGER.isDebugEnabled()) {
-								LOGGER.debug(new MessageFormat("Storing {0} resource in cache until {1,date,dd MMM yyyy HH:mm:ss zzz}", 
-									Locale.US).format(new Object[]{resourceKey, cacheExpirationDate}));
-							}
-							
-							cache.put(resourceKey, cachedResource, cacheExpirationDate);
-							resource = cachedResource;
-						}
-					}
-				}
-			}
-			
-			if (resource.userAgentNeedsUpdate(context)) {
-				if (LOGGER.isDebugEnabled()) {
-					LOGGER.debug("User agent needs resource update, encoding resource");
-				}
-				
-				ExternalContext externalContext = context.getExternalContext();
-				Map<String, String> headers = resource.getResponseHeaders();
-				for (Entry<String, String> headerEntry : headers.entrySet()) {
-					String headerName = headerEntry.getKey();
-					String headerValue = headerEntry.getValue();
-					
-					//TODO should external context handles this itself?
-					if ("content-length".equals(headerName.toLowerCase(Locale.US))) {
-						try {
-							externalContext.setResponseContentLength(Integer.parseInt(headerValue));
-						} catch (NumberFormatException e) {
-							// TODO: handle exception
-						}
-					}/* else if ("content-type".equals(headerName.toLowerCase(Locale.US))) {
-						externalContext.setResponseContentType(headerValue);
-					}*/ else {
-						externalContext.setResponseHeader(headerName, headerValue);
-					}
-				}
+            if (resource == null) {
+                ResourceCodec resourceCodec = ResourceHandlerImpl.getResourceCodec(context);
+                String resourceName = resourceCodec.decodeResourceName(resourceKey);
 
-				//TODO null content type?
-				String contentType = resource.getContentType();
-				if (contentType != null) {
-					externalContext.setResponseContentType(contentType);
-				}
-			
-				//TODO - portlets
-				HttpServletRequest httpServletRequest = (HttpServletRequest) externalContext.getRequest();
-				if (!"HEAD".equals(httpServletRequest.getMethod())) {
-					//TODO 'HEAD' HTTP method resources - ?
-					//TODO setup output buffer size according to configuration parameter
-					InputStream is = resource.getInputStream();
-					OutputStream os = externalContext.getResponseOutputStream();
+                if ((resourceName == null) || (resourceName.length() == 0)) {
+                    logMissingResource(context, resourceKey);
+                    sendResourceNotFound(context);
 
-					try {
-						Util.copyStreamContent(is, os);
-					} finally {
-						if (is != null) {
-							try {
-								is.close();
-							} catch (IOException e) {
-								if (LOGGER.isDebugEnabled()) {
-									LOGGER.debug(e.getMessage(), e);
-								}
-							}
-						}
-						//TODO flush resource
-						//TODO dispose resource
-					}
-				}
+                    return;
+                }
 
-				if (LOGGER.isDebugEnabled()) {
-					LOGGER.debug("Resource succesfully encoded");
-				}
-				
-			} else {
-				sendNotModified(context);
-			}
-		} else {
-			if (LOGGER.isDebugEnabled()) {
-				LOGGER.debug("Passing request to the next resource handler in chain");
-			}
-			defaultHandler.handleResourceRequest(context);
-		}
-	}
+                if (isResourceExists(resourceName)) {
+                    resource = createHandlerDependentResource(resourceName);
+                }
 
-	protected static boolean isResourceExists(String resourceName) {
-		boolean result = false;
-		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-		if (contextClassLoader != null) {
-			//TODO resource marker extension name?
-			URL resourceMarkerUrl = contextClassLoader.getResource("META-INF/" + resourceName + ".resource.properties");
-			result = (resourceMarkerUrl != null);
-			
-			if (LOGGER.isDebugEnabled()) {
-				if (result) {
-					LOGGER.debug(MessageFormat.format("Marker file for {0} resource found in classpath", resourceName));
-				} else {
-					LOGGER.debug(MessageFormat.format("Marker file for {0} resource does not exist", resourceName));
-				}
-			}
-		}
-		
-		return result;
-	}
-	
-	/**
-	 * Should be called only if {@link #isResourceExists(String)} returns <code>true</code>
-	 * @param resourceName
-	 * @return
-	 */
-	protected Resource createHandlerDependentResource(String resourceName) {
-		
-		Resource resource = null;
-		
-		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-		if (contextClassLoader != null) {
-			try {
-				Class<?> resourceClass = Class.forName(resourceName, false, contextClassLoader);
-				if (Resource.class.isAssignableFrom(resourceClass)) {
-					resource = (Resource) resourceClass.newInstance();
-					resource.setResourceName(resourceName);
-				
-					if (LOGGER.isDebugEnabled()) {
-						LOGGER.debug(MessageFormat.format(
-							"Successfully created instance of {0} resource", resourceName));
-					}
-				} else {
-					throw new ClassCastException(resourceClass.getName());
-				}
-			} catch (Throwable t) {
-				logResourceProblem(FacesContext.getCurrentInstance(), t, 
-					"Error creating resource {0}", resourceName);
-			}
-		}
-		
-		return resource;
-	}
-	
-	@Override
-    public Resource createResource(String resourceName, String libraryName,
-			String contentType) {
+                if (resource == null) {
+                    logMissingResource(context, resourceName);
+                    sendResourceNotFound(context);
 
-		Resource result;
+                    return;
+                }
 
-		if (resourceName != null && (libraryName == null || libraryName.length() == 0)
-				&& isResourceExists(resourceName)) {
+                if (resource instanceof VersionedResource) {
+                    VersionedResource versionedResource = (VersionedResource) resource;
+                    String existingVersion = versionedResource.getVersion();
+                    String requestedVersion = resourceCodec.decodeResourceVersion(resourceKey);
 
-			result = createHandlerDependentResource(resourceName);
-		} else {
-			result = defaultHandler.createResource(resourceName, libraryName, contentType);
-		}
-		
-		return result;
-	}
+                    if (LOGGER.isDebugEnabled()) {
+                        LOGGER.debug(
+                            MessageFormat.format(
+                                "Client requested {0} version of resource, server has {1} version",
+                                String.valueOf(requestedVersion), String.valueOf(existingVersion)));
+                    }
 
-	@Override
+                    if ((existingVersion != null) && (requestedVersion != null)
+                            && !existingVersion.equals(requestedVersion)) {
+                        logResourceProblem(context, null, "Resource {0} of version {1} was not found", resourceName,
+                                           requestedVersion);
+                        sendResourceNotFound(context);
+
+                        return;
+                    }
+                }
+
+                if (resource instanceof StateHolder) {
+                    StateHolder stateHolder = (StateHolder) resource;
+                    Object decodedData = resourceCodec.decodeResourceData(resourceKey);
+
+                    if (LOGGER.isDebugEnabled()) {
+                        if (decodedData != null) {
+                            LOGGER.debug("Resource state data succesfully decoded");
+                        } else {
+                            LOGGER.debug("Resource state data decoded as null");
+                        }
+                    }
+
+                    if (decodedData != null) {
+                        stateHolder.restoreState(context, decodedData);
+                    } else {
+
+                        // resource was transient and didn't store data
+                    }
+                }
+
+                if (resource instanceof AbstractCacheableResource) {
+                    AbstractCacheableResource cacheableResource = (AbstractCacheableResource) resource;
+
+                    if (cacheableResource.isCacheable(context)) {
+
+                        // TODO - we could move this part of code to ConcurrentMap so that
+                        // only single thread does resource put
+                        CachedResourceImpl cachedResource = new CachedResourceImpl();
+
+                        cachedResource.initialize(resource);
+
+                        // someone may provided this resource for us
+                        // while we were reading it, check once again
+                        resource = lookupInCache(context, resourceKey);
+
+                        if (resource == null) {
+                            Date cacheExpirationDate = cachedResource.getExpired(context);
+
+                            if (LOGGER.isDebugEnabled()) {
+                                LOGGER.debug(new MessageFormat(
+                                    "Storing {0} resource in cache until {1,date,dd MMM yyyy HH:mm:ss zzz}", Locale.US).
+                                        format(new Object[] {resourceKey, cacheExpirationDate}));
+                            }
+
+                            cache.put(resourceKey, cachedResource, cacheExpirationDate);
+                            resource = cachedResource;
+                        }
+                    }
+                }
+            }
+
+            if (resource.userAgentNeedsUpdate(context)) {
+                if (LOGGER.isDebugEnabled()) {
+                    LOGGER.debug("User agent needs resource update, encoding resource");
+                }
+
+                ExternalContext externalContext = context.getExternalContext();
+                Map<String, String> headers = resource.getResponseHeaders();
+
+                for (Entry<String, String> headerEntry : headers.entrySet()) {
+                    String headerName = headerEntry.getKey();
+                    String headerValue = headerEntry.getValue();
+
+                    // TODO should external context handles this itself?
+                    if ("content-length".equals(headerName.toLowerCase(Locale.US))) {
+                        try {
+                            externalContext.setResponseContentLength(Integer.parseInt(headerValue));
+                        } catch (NumberFormatException e) {
+
+                            // TODO: handle exception
+                        }
+                    } else {
+                        externalContext.setResponseHeader(headerName, headerValue);
+                    }
+                }
+
+                // TODO null content type?
+                String contentType = resource.getContentType();
+
+                if (contentType != null) {
+                    externalContext.setResponseContentType(contentType);
+                }
+
+                // TODO - portlets
+                HttpServletRequest httpServletRequest = (HttpServletRequest) externalContext.getRequest();
+
+                if (!"HEAD".equals(httpServletRequest.getMethod())) {
+
+                    // TODO 'HEAD' HTTP method resources - ?
+                    // TODO setup output buffer size according to configuration parameter
+                    InputStream is = resource.getInputStream();
+                    OutputStream os = externalContext.getResponseOutputStream();
+
+                    try {
+                        Util.copyStreamContent(is, os);
+                    } finally {
+                        if (is != null) {
+                            try {
+                                is.close();
+                            } catch (IOException e) {
+                                if (LOGGER.isDebugEnabled()) {
+                                    LOGGER.debug(e.getMessage(), e);
+                                }
+                            }
+                        }
+
+                        // TODO flush resource
+                        // TODO dispose resource
+                    }
+                }
+
+                if (LOGGER.isDebugEnabled()) {
+                    LOGGER.debug("Resource succesfully encoded");
+                }
+            } else {
+                sendNotModified(context);
+            }
+        } else {
+            if (LOGGER.isDebugEnabled()) {
+                LOGGER.debug("Passing request to the next resource handler in chain");
+            }
+
+            defaultHandler.handleResourceRequest(context);
+        }
+    }
+
+    protected static boolean isResourceExists(String resourceName) {
+        boolean result = false;
+        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+
+        if (contextClassLoader != null) {
+
+            // TODO resource marker extension name?
+            URL resourceMarkerUrl = contextClassLoader.getResource("META-INF/" + resourceName + ".resource.properties");
+
+            result = resourceMarkerUrl != null;
+
+            if (LOGGER.isDebugEnabled()) {
+                if (result) {
+                    LOGGER.debug(MessageFormat.format("Marker file for {0} resource found in classpath", resourceName));
+                } else {
+                    LOGGER.debug(MessageFormat.format("Marker file for {0} resource does not exist", resourceName));
+                }
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * Should be called only if {@link #isResourceExists(String)} returns <code>true</code>
+     * @param resourceName
+     * @return
+     */
+    protected Resource createHandlerDependentResource(String resourceName) {
+        Resource resource = null;
+        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+
+        if (contextClassLoader != null) {
+            try {
+                Class<?> resourceClass = Class.forName(resourceName, false, contextClassLoader);
+
+                if (Resource.class.isAssignableFrom(resourceClass)) {
+                    resource = (Resource) resourceClass.newInstance();
+                    resource.setResourceName(resourceName);
+
+                    if (LOGGER.isDebugEnabled()) {
+                        LOGGER.debug(MessageFormat.format("Successfully created instance of {0} resource",
+                                                          resourceName));
+                    }
+                } else {
+                    throw new ClassCastException(resourceClass.getName());
+                }
+            } catch (Throwable t) {
+                logResourceProblem(FacesContext.getCurrentInstance(), t, "Error creating resource {0}", resourceName);
+            }
+        }
+
+        return resource;
+    }
+
+    @Override
+    public Resource createResource(String resourceName, String libraryName, String contentType) {
+        Resource result;
+
+        if ((resourceName != null) && ((libraryName == null) || (libraryName.length() == 0))
+                && isResourceExists(resourceName)) {
+            result = createHandlerDependentResource(resourceName);
+        } else {
+            result = defaultHandler.createResource(resourceName, libraryName, contentType);
+        }
+
+        return result;
+    }
+
+    @Override
     public Resource createResource(String resourceName, String libraryName) {
-		return createResource(resourceName, libraryName, null);
-	}
+        return createResource(resourceName, libraryName, null);
+    }
 
-	@Override
+    @Override
     public Resource createResource(String resourceName) {
-		return createResource(resourceName, null, null);
-	}
+        return createResource(resourceName, null, null);
+    }
 
-	@Override
+    @Override
     public String getRendererTypeForResourceName(String resourceName) {
-		//TODO add support for dynamic resources
-		return defaultHandler.getRendererTypeForResourceName(resourceName);
-	}
 
-	@Override
+        // TODO add support for dynamic resources
+        return defaultHandler.getRendererTypeForResourceName(resourceName);
+    }
+
+    @Override
     public boolean libraryExists(String libraryName) {
-		return defaultHandler.libraryExists(libraryName);
-	}
+        return defaultHandler.libraryExists(libraryName);
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceUtils.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceUtils.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,75 +19,74 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public final class ResourceUtils {
-
-	private ResourceUtils() {}
-	
-	private static final String QUOTED_STRING_REGEX = "(?:\\\\[\\x00-\\x7F]|[^\"\\\\])+";
-	
-	private static final Pattern ETAG_PATTERN = Pattern.compile("(?:W/)?\"(" + QUOTED_STRING_REGEX + ")\"(?:,\\s*)?");
-	
     private static final long MILLISECOND_IN_SECOND = 1000L;
+    private static final String QUOTED_STRING_REGEX = "(?:\\\\[\\x00-\\x7F]|[^\"\\\\])+";
+    private static final Pattern ETAG_PATTERN = Pattern.compile("(?:W/)?\"(" + QUOTED_STRING_REGEX + ")\"(?:,\\s*)?");
 
-	public static String formatWeakTag(String eTag) {
-		String formattedTag = formatTag(eTag);
-		if (formattedTag == null) {
-			return null;
-		}
-		
-		return "W/" + formattedTag;
-	}
+    private ResourceUtils() {}
 
-	public static String formatTag(String eTag) {
-		if (eTag == null) {
-			return null;
-		}
-		
-		if (!eTag.matches(QUOTED_STRING_REGEX)) {
-			throw new IllegalArgumentException("tag must matches to regexp '" + QUOTED_STRING_REGEX + '\'');
-		}
+    public static String formatWeakTag(String eTag) {
+        String formattedTag = formatTag(eTag);
 
-		return '\"' + eTag + '\"';
-	}
-	
-	public static boolean matchTag(String eTag, String eTagHeaderValue) {
-		if (eTag == null || eTagHeaderValue == null) {
-			throw new IllegalArgumentException("tag and tagHeaderValue must be not null");
-		}
+        if (formattedTag == null) {
+            return null;
+        }
 
-		Matcher eTagMatcher = ETAG_PATTERN.matcher(eTag);
-		if (!eTagMatcher.find()) {
-			throw new IllegalArgumentException();
-		}
+        return "W/" + formattedTag;
+    }
 
+    public static String formatTag(String eTag) {
+        if (eTag == null) {
+            return null;
+        }
+
+        if (!eTag.matches(QUOTED_STRING_REGEX)) {
+            throw new IllegalArgumentException("tag must matches to regexp '" + QUOTED_STRING_REGEX + '\'');
+        }
+
+        return '\"' + eTag + '\"';
+    }
+
+    public static boolean matchTag(String eTag, String eTagHeaderValue) {
+        if ((eTag == null) || (eTagHeaderValue == null)) {
+            throw new IllegalArgumentException("tag and tagHeaderValue must be not null");
+        }
+
+        Matcher eTagMatcher = ETAG_PATTERN.matcher(eTag);
+
+        if (!eTagMatcher.find()) {
+            throw new IllegalArgumentException();
+        }
+
         String tag = eTagMatcher.group(1);
+        Matcher eTagHeaderMatcher = ETAG_PATTERN.matcher(eTagHeaderValue);
 
+        while (eTagHeaderMatcher.find()) {
+            if (tag.equals(eTagHeaderMatcher.group(1))) {
+                return true;
+            }
+        }
 
-		Matcher eTagHeaderMatcher = ETAG_PATTERN.matcher(eTagHeaderValue);
-		while (eTagHeaderMatcher.find()) {
-			if (tag.equals(eTagHeaderMatcher.group(1))) {
-				return true;
-			}
-		}
-		
-		return false;
-	}
+        return false;
+    }
 
     public static long millisToSecond(long millisecond) {
-        return  millisecond / MILLISECOND_IN_SECOND;
+        return millisecond / MILLISECOND_IN_SECOND;
     }
 
     public static long secondToMillis(long second) {
-        return  second * MILLISECOND_IN_SECOND;
+        return second * MILLISECOND_IN_SECOND;
     }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/skin/AbstractChainableSkinImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/skin/AbstractChainableSkinImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/skin/AbstractChainableSkinImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,141 +19,140 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.skin;
 
+import org.ajax4jsf.Messages;
+
 import java.util.Map;
 
 import javax.faces.FacesException;
 import javax.faces.context.FacesContext;
 
-import org.ajax4jsf.Messages;
-
 /**
  * @author nick belaevski
  * @since 3.2
  */
-
 public abstract class AbstractChainableSkinImpl extends BasicSkinImpl {
+    private static final Operation RESOLVE = new Operation() {
+        public Object doExternalCall(FacesContext context, Skin impl, String name) {
 
+            // TODO add warning because substitution can work incorrect and cyclic references
+            // won't be caught
+            return impl.getParameter(context, name);
+        }
+        public Object doLocalCall(FacesContext context, AbstractChainableSkinImpl impl, String name) {
+            return impl.localResolveSkinParameter(context, name);
+        }
+    };
+    private static final Operation CONTAINS = new Operation() {
+        private Object wrapBoolean(boolean value) {
+            return value ? Boolean.TRUE : null;
+        }
+        public Object doExternalCall(FacesContext context, Skin impl, String name) {
+            return wrapBoolean(impl.containsProperty(name));
+        }
+        public Object doLocalCall(FacesContext context, AbstractChainableSkinImpl impl, String name) {
+            return wrapBoolean(impl.localContainsProperty(context, name));
+        }
+    };
+
     AbstractChainableSkinImpl(Map properties) {
-	super(properties);
+        super(properties);
     }
 
     protected abstract Skin getBaseSkin(FacesContext context);
-    
+
     protected Object localResolveSkinParameter(FacesContext context, String name) {
-	return getSkinParams().get(name);
+        return getSkinParams().get(name);
     }
-    
+
     protected boolean localContainsProperty(FacesContext context, String name) {
-	return getSkinParams().containsKey(name);
+        return getSkinParams().containsKey(name);
     }
 
-    private static abstract class Operation {
-	public Object doChainedCall(FacesContext context, AbstractChainableSkinImpl impl, String name, int[] singleInt) {
-	    return impl.executeOperation(context, this, name, singleInt);
-	}
-	
-	public abstract Object doLocalCall(FacesContext context, AbstractChainableSkinImpl impl, String name);
+    protected Object executeOperation(FacesContext context, Operation operation, String name, int[] singleInt) {
+        if (singleInt[0]++ > 1000) {
+            throw new FacesException(Messages.getMessage(Messages.SKIN_CYCLIC_REFERENCE, name));
+        }
 
-	public abstract Object doExternalCall(FacesContext context, Skin impl, String name);
-    }
+        Object object = operation.doLocalCall(context, this, name);
 
-    private static final Operation RESOLVE = new Operation() {
+        if (object == null) {
+            Skin baseSkin = getBaseSkin(context);
 
-	public Object doExternalCall(FacesContext context, Skin impl, String name) {
-	    //TODO add warning because substitution can work incorrect and cyclic references
-	    //won't be caught
-	    return impl.getParameter(context, name);
-	}
+            if (baseSkin != null) {
+                if (baseSkin instanceof AbstractChainableSkinImpl) {
+                    AbstractChainableSkinImpl skinImpl = (AbstractChainableSkinImpl) baseSkin;
 
-	public Object doLocalCall(FacesContext context, AbstractChainableSkinImpl impl, String name) {
-	    return impl.localResolveSkinParameter(context, name);
-	}
-	
-    };
-    
-    private static final Operation CONTAINS = new Operation() {
+                    object = operation.doChainedCall(context, skinImpl, name, singleInt);
+                } else {
+                    object = operation.doExternalCall(context, baseSkin, name);
+                }
+            }
+        }
 
-	private Object wrapBoolean(boolean value) {
-	    return value ? Boolean.TRUE : null;
-	}
-	
-	public Object doExternalCall(FacesContext context, Skin impl, String name) {
-	    return wrapBoolean(impl.containsProperty(name));
-	}
-
-	public Object doLocalCall(FacesContext context, AbstractChainableSkinImpl impl, String name) {
-	    return wrapBoolean(impl.localContainsProperty(context, name));
-	}
-	
-    };
-
-    protected Object executeOperation(FacesContext context, Operation operation, String name, int[] singleInt) {
-	if (singleInt[0]++ > 1000) {
-	    throw new FacesException(Messages.getMessage(
-		    Messages.SKIN_CYCLIC_REFERENCE, name));
-	}
-
-	Object object = operation.doLocalCall(context, this, name);
-	if (object == null) {
-	    Skin baseSkin = getBaseSkin(context);
-	    if (baseSkin != null) {
-		if (baseSkin instanceof AbstractChainableSkinImpl) {
-		    AbstractChainableSkinImpl skinImpl = (AbstractChainableSkinImpl) baseSkin;
-		    object = operation.doChainedCall(context, skinImpl, name, singleInt);
-		} else {
-		    object = operation.doExternalCall(context, baseSkin, name);
-		}
-	    }
-	}
-	
-	return object;
+        return object;
     }
-    
+
     protected Object resolveSkinParameter(FacesContext context, String name, int[] singleInt) {
-	return executeOperation(context, RESOLVE, name, singleInt);
+        return executeOperation(context, RESOLVE, name, singleInt);
     }
-    
+
     protected boolean containsProperty(FacesContext context, String name, int[] singleInt) {
-	return Boolean.TRUE.equals(executeOperation(context, CONTAINS, name, singleInt));
+        return Boolean.TRUE.equals(executeOperation(context, CONTAINS, name, singleInt));
     }
 
     protected Object resolveSkinParameter(FacesContext context, String name) {
-	int[] singleInt = new int[] {0};
-	Object resolvedParameter = resolveSkinParameter(context, name, singleInt);
-	
-	while (resolvedParameter instanceof String) {
-	    String string = (String) resolvedParameter;
-	    if (string.length() > 0 && string.charAt(0) == '&') {
-		resolvedParameter = resolveSkinParameter(context, string.substring(1), singleInt);
-		if (resolvedParameter == null) {
-		    throw new FacesException(Messages.getMessage(
-			    Messages.SKIN_ILLEGAL_REFERENCE, name));
-		}
-	    } else {
-		break;
-	    }
-	}
-	
-	return resolvedParameter;
+        int[] singleInt = new int[] {0};
+        Object resolvedParameter = resolveSkinParameter(context, name, singleInt);
+
+        while (resolvedParameter instanceof String) {
+            String string = (String) resolvedParameter;
+
+            if ((string.length() > 0) && (string.charAt(0) == '&')) {
+                resolvedParameter = resolveSkinParameter(context, string.substring(1), singleInt);
+
+                if (resolvedParameter == null) {
+                    throw new FacesException(Messages.getMessage(Messages.SKIN_ILLEGAL_REFERENCE, name));
+                }
+            } else {
+                break;
+            }
+        }
+
+        return resolvedParameter;
     }
 
-    /* (non-Javadoc)
+    /*
+     *  (non-Javadoc)
      * @see org.richfaces.skin.Skin#containsProperty(java.lang.String)
      */
     public boolean containsProperty(String name) {
-	return containsProperty(FacesContext.getCurrentInstance(), name, new int[] {0});
+        return containsProperty(FacesContext.getCurrentInstance(), name, new int[] {0});
     }
 
+    @Override
     protected int computeHashCode(FacesContext context) {
-	int hash = super.computeHashCode(context);
-	Skin baseSkin = getBaseSkin(context);
-	if (baseSkin != null) {
-	    hash = 31*hash + baseSkin.hashCode(context);
-	}
+        int hash = super.computeHashCode(context);
+        Skin baseSkin = getBaseSkin(context);
 
+        if (baseSkin != null) {
+            hash = 31 * hash + baseSkin.hashCode(context);
+        }
+
         return hash;
     }
-    
+
+    private abstract static class Operation {
+        public Object doChainedCall(FacesContext context, AbstractChainableSkinImpl impl, String name,
+                                    int[] singleInt) {
+            return impl.executeOperation(context, this, name, singleInt);
+        }
+
+        public abstract Object doLocalCall(FacesContext context, AbstractChainableSkinImpl impl, String name);
+
+        public abstract Object doExternalCall(FacesContext context, Skin impl, String name);
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/skin/BasicSkinImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/skin/BasicSkinImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/skin/BasicSkinImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.skin;
 
 import java.util.HashMap;
@@ -28,67 +30,70 @@
 import java.util.concurrent.ConcurrentMap;
 
 import javax.el.ValueExpression;
+
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 
 /**
  * Singleton ( in respect as collection of different skins ) for produce
  * instances properties for all used skins.
- * 
+ *
  * @author shura (latest modification by $Author: alexsmirnov $)
  * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:41 $
- * 
+ *
  */
 public abstract class BasicSkinImpl implements Skin {
-
     public static final String RENDER_KIT_PARAMETER = "render.kit";
-
-    public static final String REQUEST_HASH_CODES_MAP_PARAMETER = "org.ajax4jsf.skin.HASH_CODES_MAP"; 
-
+    public static final String REQUEST_HASH_CODES_MAP_PARAMETER = "org.ajax4jsf.skin.HASH_CODES_MAP";
     private Map<String, Object> skinParams = new HashMap<String, Object>();
 
     /**
      * Skin can instantiate only by factory method.
-     * 
+     *
      * @param skinName
      */
     BasicSkinImpl(Map properties) {
-	this.skinParams = properties;
+        this.skinParams = properties;
     }
-    
+
     protected Map<String, Object> getSkinParams() {
-	return skinParams;
+        return skinParams;
     }
 
-    /* (non-Javadoc)
+    /*
+     *  (non-Javadoc)
      * @see org.richfaces.skin.Skin#getRenderKitId(javax.faces.context.FacesContext)
      */
     public String getRenderKitId(FacesContext context) {
-	return (String) getValueReference(context, resolveSkinParameter(context, RENDER_KIT_PARAMETER));
+        return (String) getValueReference(context, resolveSkinParameter(context, RENDER_KIT_PARAMETER));
     }
 
-    /* (non-Javadoc)
+    /*
+     *  (non-Javadoc)
      * @see org.richfaces.skin.Skin#getParameter(javax.faces.context.FacesContext, java.lang.String)
      */
     public Object getParameter(FacesContext context, String name) {
-	return getValueReference(context, resolveSkinParameter(context, name));
+        return getValueReference(context, resolveSkinParameter(context, name));
     }
 
-    /* (non-Javadoc)
+    /*
+     *  (non-Javadoc)
      * @see org.richfaces.skin.Skin#getParameter(javax.faces.context.FacesContext, java.lang.String, java.lang.String, java.lang.Object)
      */
-    public Object getParameter(FacesContext context, String name,  Object defaultValue) {
-	Object value = getValueReference(context, resolveSkinParameter(context, name));
-	if(null == value){
-	    value = defaultValue;
-	}
-	return value;
+    public Object getParameter(FacesContext context, String name, Object defaultValue) {
+        Object value = getValueReference(context, resolveSkinParameter(context, name));
+
+        if (null == value) {
+            value = defaultValue;
+        }
+
+        return value;
     }
 
     protected Object getLocalParameter(FacesContext context, String name) {
-	return getValueReference(context, skinParams.get(name));
+        return getValueReference(context, skinParams.get(name));
     }
-    
+
     protected abstract Object resolveSkinParameter(FacesContext context, String name);
 
     /**
@@ -99,52 +104,60 @@
      * @return
      */
     protected Object getValueReference(FacesContext context, Object property) {
-	if (property instanceof ValueExpression) {
-	    ValueExpression value = (ValueExpression) property;
-	    return value.getValue(context.getELContext());
-	}
-	return property;
+        if (property instanceof ValueExpression) {
+            ValueExpression value = (ValueExpression) property;
+
+            return value.getValue(context.getELContext());
+        }
+
+        return property;
     }
 
-
     public String toString() {
-	return this.getClass().getSimpleName() + ": " + skinParams.toString();
+        return this.getClass().getSimpleName() + ": " + skinParams.toString();
     }
-    
+
     protected int computeHashCode(FacesContext context) {
-	int hash = 0;
-	for (Iterator iter = skinParams.keySet().iterator(); iter.hasNext();) {
-	    String key = (String) iter.next();
-	    Object parameter = getLocalParameter(context, key);
-	    hash = 31*hash + key.hashCode();
-	    hash = 31*hash + (parameter != null ? parameter.hashCode() : 0);
-	}
+        int hash = 0;
 
-	return hash;
+        for (Iterator iter = skinParams.keySet().iterator(); iter.hasNext(); ) {
+            String key = (String) iter.next();
+            Object parameter = getLocalParameter(context, key);
+
+            hash = 31 * hash + key.hashCode();
+            hash = 31 * hash + ((parameter != null) ? parameter.hashCode() : 0);
+        }
+
+        return hash;
     }
 
-    /* (non-Javadoc)
+    /*
+     *  (non-Javadoc)
      * @see org.richfaces.skin.Skin#hashCode(javax.faces.context.FacesContext)
      */
     public int hashCode(FacesContext context) {
-	ExternalContext externalContext = context.getExternalContext();
-	Map<String, Object> requestMap = externalContext.getRequestMap();
-	ConcurrentMap<Skin, Integer> map;
-	synchronized (requestMap) {
-	    map = (ConcurrentMap<Skin, Integer>) requestMap.get(REQUEST_HASH_CODES_MAP_PARAMETER);
-	    if (map == null) {
-		map = new ConcurrentHashMap<Skin, Integer>();
-		requestMap.put(REQUEST_HASH_CODES_MAP_PARAMETER, map);
-	    }
-	}
+        ExternalContext externalContext = context.getExternalContext();
+        Map<String, Object> requestMap = externalContext.getRequestMap();
+        ConcurrentMap<Skin, Integer> map;
 
-	Integer requestCode = (Integer) map.get(this);
-	if(null == requestCode){
-	    requestCode = new Integer(computeHashCode(context));
-	    // store hash for this skin as request-skope parameter - not calculate on next calls for same request
-	    map.putIfAbsent(this, requestCode);
-	}
-	return requestCode.intValue();
+        synchronized (requestMap) {
+            map = (ConcurrentMap<Skin, Integer>) requestMap.get(REQUEST_HASH_CODES_MAP_PARAMETER);
+
+            if (map == null) {
+                map = new ConcurrentHashMap<Skin, Integer>();
+                requestMap.put(REQUEST_HASH_CODES_MAP_PARAMETER, map);
+            }
+        }
+
+        Integer requestCode = (Integer) map.get(this);
+
+        if (null == requestCode) {
+            requestCode = new Integer(computeHashCode(context));
+
+            // store hash for this skin as request-skope parameter - not calculate on next calls for same request
+            map.putIfAbsent(this, requestCode);
+        }
+
+        return requestCode.intValue();
     }
-
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/skin/DefaultSkinImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/skin/DefaultSkinImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/skin/DefaultSkinImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.skin;
 
 import java.util.Map;
@@ -29,11 +31,9 @@
  * @author nick belaevski
  * @since 3.2
  */
-
 public class DefaultSkinImpl extends AbstractChainableSkinImpl {
-
     DefaultSkinImpl(Map properties) {
-	super(properties);
+        super(properties);
     }
 
     protected Skin getBaseSkin(FacesContext context) {

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/skin/DummySkinConfiguration.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/skin/DummySkinConfiguration.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/skin/DummySkinConfiguration.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,53 +19,54 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.skin;
 
 import javax.faces.context.FacesContext;
 
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinConfiguration;
-
 /**
  * @author shura
  *
  */
 public class DummySkinConfiguration implements SkinConfiguration {
-	
-	private Skin _skin;
+    private Skin skin;
 
-	/**
-	 * @param skin
-	 */
-	public DummySkinConfiguration(Skin skin) {
-		super();
-		_skin = skin;
-	}
+    /**
+     * @param skin
+     */
+    public DummySkinConfiguration(Skin skin) {
+        super();
+        this.skin = skin;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.skin.SkinConfiguration#containsParameter(java.lang.String)
-	 */
-	public boolean containsParameter(String name) {
-		return _skin.containsProperty(name);
-	}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.skin.SkinConfiguration#containsParameter(java.lang.String)
+     */
+    public boolean containsParameter(String name) {
+        return skin.containsProperty(name);
+    }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.skin.SkinConfiguration#getParameter(javax.faces.context.FacesContext, java.lang.String)
-	 */
-	public Object getParameter(FacesContext context, String name) {
-		return _skin.getParameter(context, name);
-	}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.skin.SkinConfiguration#getParameter(javax.faces.context.FacesContext, java.lang.String)
+     */
+    public Object getParameter(FacesContext context, String name) {
+        return skin.getParameter(context, name);
+    }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.skin.SkinConfiguration#getParameter(javax.faces.context.FacesContext, java.lang.String, java.lang.String, java.lang.Object)
-	 */
-	public Object getParameter(FacesContext context, String name,
-			String skinName, Object defaultValue) {
-		Object parameter = _skin.getParameter(context, name);
-		if(null == parameter){
-			parameter = defaultValue;
-		}
-		return parameter;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.skin.SkinConfiguration#getParameter(javax.faces.context.FacesContext, String, String, Object)
+     */
+    public Object getParameter(FacesContext context, String name, String skinName, Object defaultValue) {
+        Object parameter = skin.getParameter(context, name);
 
+        if (null == parameter) {
+            parameter = defaultValue;
+        }
+
+        return parameter;
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinBean.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinBean.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinBean.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,18 +19,18 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.skin;
 
+import javax.faces.context.FacesContext;
+
 import java.nio.ByteBuffer;
+
 import java.util.AbstractMap;
 import java.util.Collections;
 import java.util.Set;
 
-import javax.faces.context.FacesContext;
-
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
 /**
  * @author shura (latest modification by $Author: alexsmirnov $)
  * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:40 $
@@ -38,102 +38,113 @@
  */
 public class SkinBean extends AbstractMap implements Skin {
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.skin.Skin#hashCode(javax.faces.context.FacesContext)
-	 */
-	public int hashCode(FacesContext context) {
-		// TODO Auto-generated method stub
-		return getSkin().hashCode(context);
-	}
-	
-	
-	
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.skin.Skin#hashCode(javax.faces.context.FacesContext)
+     */
+    public int hashCode(FacesContext context) {
 
-	/* (non-Javadoc)
-	 * @see java.util.AbstractMap#entrySet()
-	 */
-	public Set entrySet() {
-		// TODO Auto-generated method stub
-		return Collections.EMPTY_SET;
-	}
+        // TODO Auto-generated method stub
+        return getSkin().hashCode(context);
+    }
 
-	/* (non-Javadoc)
-	 * @see java.util.AbstractMap#containsKey(java.lang.Object)
-	 */
-	public boolean containsKey(Object key) {
-		if(null == key) {
-			return false;
-		}
-		return getSkin().containsProperty(key.toString());
-	}
+    /*
+     *  (non-Javadoc)
+     * @see java.util.AbstractMap#entrySet()
+     */
+    @Override
+    public Set entrySet() {
 
-	/* (non-Javadoc)
-	 * @see java.util.AbstractMap#get(java.lang.Object)
-	 */
-	public Object get(Object key) {
-		if(null == key) {
-			return null;
-		}
-		return getSkin().getParameter(FacesContext.getCurrentInstance(),key.toString());
-	}
+        // TODO Auto-generated method stub
+        return Collections.EMPTY_SET;
+    }
 
-	private Skin getSkin() {
-		FacesContext context = FacesContext.getCurrentInstance();
-		return SkinFactory.getInstance().getSkin(context);
-	}
+    /*
+     *  (non-Javadoc)
+     * @see java.util.AbstractMap#containsKey(java.lang.Object)
+     */
+    @Override
+    public boolean containsKey(Object key) {
+        if (null == key) {
+            return false;
+        }
 
-	/* (non-Javadoc)
-	 * @see java.util.AbstractMap#toString()
-	 */
-	public String toString() {
-		return getSkin().toString();
-	}
+        return getSkin().containsProperty(key.toString());
+    }
 
-	/* (non-Javadoc)
-	 * @see java.util.AbstractMap#isEmpty()
-	 */
-	public boolean isEmpty() {
-		// TODO Auto-generated method stub
-		return false;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see java.util.AbstractMap#get(java.lang.Object)
+     */
+    @Override
+    public Object get(Object key) {
+        if (null == key) {
+            return null;
+        }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.skin.Skin#getRenderKitId(javax.faces.context.FacesContext)
-	 */
-	public String getRenderKitId(FacesContext context) {
-		return getSkin().getRenderKitId(context);
-	}
+        return getSkin().getParameter(FacesContext.getCurrentInstance(), key.toString());
+    }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.skin.Skin#getParameter(javax.faces.context.FacesContext, java.lang.String)
-	 */
-	public Object getParameter(FacesContext context, String name) {
-		return getSkin().getParameter(context,name);
-	}
+    private Skin getSkin() {
+        FacesContext context = FacesContext.getCurrentInstance();
 
-	
-	public Object getParameter(FacesContext context, String name, Object defaultValue) {
-		
-		return getSkin().getParameter(context, name, defaultValue);
-	}
+        return SkinFactory.getInstance().getSkin(context);
+    }
 
+    /*
+     *  (non-Javadoc)
+     * @see java.util.AbstractMap#toString()
+     */
+    @Override
+    public String toString() {
+        return getSkin().toString();
+    }
 
+    /*
+     *  (non-Javadoc)
+     * @see java.util.AbstractMap#isEmpty()
+     */
+    @Override
+    public boolean isEmpty() {
 
+        // TODO Auto-generated method stub
+        return false;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.skin.Skin#containsProperty(java.lang.String)
-	 */
-	public boolean containsProperty(String name) {
-		return getSkin().containsProperty(name);
-	}
-	
-	/* Static methods for manipulate skins */
-	
-	public static Object skinHashCode(){
-		FacesContext context = FacesContext.getCurrentInstance();
-		int hashCode = SkinFactory.getInstance().getSkin(context).hashCode(context);
-		byte[] bs = ByteBuffer.allocate(4).putInt(hashCode).array();
-		return bs;
-	}
-	
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.skin.Skin#getRenderKitId(javax.faces.context.FacesContext)
+     */
+    public String getRenderKitId(FacesContext context) {
+        return getSkin().getRenderKitId(context);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.skin.Skin#getParameter(javax.faces.context.FacesContext, java.lang.String)
+     */
+    public Object getParameter(FacesContext context, String name) {
+        return getSkin().getParameter(context, name);
+    }
+
+    public Object getParameter(FacesContext context, String name, Object defaultValue) {
+        return getSkin().getParameter(context, name, defaultValue);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.skin.Skin#containsProperty(java.lang.String)
+     */
+    public boolean containsProperty(String name) {
+        return getSkin().containsProperty(name);
+    }
+
+    /* Static methods for manipulate skins */
+    public static Object skinHashCode() {
+        FacesContext context = FacesContext.getCurrentInstance();
+        int hashCode = SkinFactory.getInstance().getSkin(context).hashCode(context);
+        byte[] bs = ByteBuffer.allocate(4).putInt(hashCode).array();
+
+        return bs;
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,365 +19,393 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.skin;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Map.Entry;
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.util.URLToStreamHelper;
+import org.ajax4jsf.util.ELUtils;
 
+import org.richfaces.log.RichfacesLogger;
+
+import org.slf4j.Logger;
+
 import javax.el.ELContext;
 import javax.el.ExpressionFactory;
 import javax.el.ValueExpression;
-import javax.faces.FacesException;
+
 import javax.faces.FactoryFinder;
 import javax.faces.application.Application;
 import javax.faces.application.ApplicationFactory;
 import javax.faces.context.FacesContext;
 
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.ajax4jsf.util.ELUtils;
-import org.richfaces.log.RichfacesLogger;
-import org.slf4j.Logger;
+import java.io.IOException;
+import java.io.InputStream;
 
+import java.net.URL;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+
 /**
  * Implementation of {@link SkinFactory} with building skins from properties
  * files.
- * 
+ *
  * @author shura
- * 
+ *
  */
 public class SkinFactoryImpl extends SkinFactory {
+    private static final String A4J_BASE_SKIN_PARAMETER = "org.ajax4jsf.BASE_SKIN";
+    private static final String A4J_SKIN_PARAMETER = "org.ajax4jsf.SKIN";
 
+    // private static final String DEFAULT_CONFIGURATION_RESOURCE = "META-INF/skins/DEFAULT.configuration.properties";
 
-	/**
-	 * Name of web application init parameter for current default
-	 * {@link javax.faces.render.RenderKit } interaction. by default -
-	 * org.exadel.chameleon.RENDERKIT_DEFINITION . TODO Possible Values
-	 */
-	public static final String RENDER_KIT_PARAMETER = "org.ajax4jsf.RENDERKIT_DEFINITION";
+    /**
+     * Name of default skin . "DEFAULT" in this realisation.
+     */
+    private static final String DEFAULT_SKIN_NAME = "DEFAULT";
 
-	/**
-	 * Resource Uri for properties file with default values of skin parameters.
-	 */
-	private static final String DEFAULT_SKIN_PATH = "META-INF/skins/%s.skin.properties";
+    /**
+     * Resource Uri for properties file with default values of skin parameters.
+     */
+    private static final String DEFAULT_SKIN_PATH = "META-INF/skins/%s.skin.properties";
 
-	private static final String USER_SKIN_PATH = "%s.skin.properties";
+    /**
+     * Name of web application init parameter for current default
+     * {@link javax.faces.render.RenderKit } interaction. by default -
+     * org.exadel.chameleon.RENDERKIT_DEFINITION . TODO Possible Values
+     */
+    public static final String RENDER_KIT_PARAMETER = "org.ajax4jsf.RENDERKIT_DEFINITION";
+    private static final String[] THEME_PATHS = {"META-INF/themes/%s.theme.properties", "%s.theme.properties"};
 
-	//	private static final String DEFAULT_CONFIGURATION_RESOURCE = "META-INF/skins/DEFAULT.configuration.properties";
-	/**
-	 * Name of default skin . "DEFAULT" in this realisation.
-	 */
-	private static final String DEFAULT_SKIN_NAME = "DEFAULT";
+//  private static final String[] DEFAULT_SKIN_PATHS = { DEFAULT_SKIN_PATH };
+    private static final String USER_SKIN_PATH = "%s.skin.properties";
 
-	/**
-	 * Path in jar to pre-defined vendor and custom user-defined skins
-	 * definitions. in this realisation "META-INF/skins/" for vendor , "" -
-	 * user-defined.
-	 */
-	private static final String[] SKINS_PATHS = {
-			DEFAULT_SKIN_PATH, USER_SKIN_PATH };
-	private static final String[] THEME_PATHS = {
-		"META-INF/themes/%s.theme.properties", "%s.theme.properties" };
-//	private static final String[] DEFAULT_SKIN_PATHS = { DEFAULT_SKIN_PATH };
+    /**
+     * Path in jar to pre-defined vendor and custom user-defined skins
+     * definitions. in this realisation "META-INF/skins/" for vendor , "" -
+     * user-defined.
+     */
+    private static final String[] SKINS_PATHS = {DEFAULT_SKIN_PATH, USER_SKIN_PATH};
+    private static final Logger LOG = RichfacesLogger.APPLICATION.getLogger();
+    private ValueExpression baseSkinBinding = null;
+    private String baseSkinName = null;
+    private ValueExpression skinBinding = null;
 
-//	private static final String[] CONFIGURATIONS_PATHS = {
-//			"META-INF/skins/%s.configuration.properties",
-//			"%s.configuration.properties" };
-//	private static final String[] DEFAULT_CONFIGURATION_PATHS = { "META-INF/skins/DEFAULT.configuration.properties" };
+//  private Properties defaultSkinProperties = null;
+    private String skinName = null;
 
-	private Map<String,Skin> skins = new HashMap<String,Skin>();
-	private Map<String,Skin> baseSkins = new HashMap<String,Skin>();
-	private Map<String,Properties> sourceProperties = new HashMap<String,Properties>();
-	private Map<String,Theme> themes = new HashMap<String,Theme>();
+//  private static final String[] CONFIGURATIONS_PATHS = {
+//          "META-INF/skins/%s.configuration.properties",
+//          "%s.configuration.properties" };
+//  private static final String[] DEFAULT_CONFIGURATION_PATHS = { "META-INF/skins/DEFAULT.configuration.properties" };
+    private Map<String, Skin> skins = new HashMap<String, Skin>();
+    private Map<String, Skin> baseSkins = new HashMap<String, Skin>();
+    private Map<String, Properties> sourceProperties = new HashMap<String, Properties>();
+    private Map<String, Theme> themes = new HashMap<String, Theme>();
 
-//	private Properties defaultSkinProperties = null;
-	private String skinName = null;
-	private ValueExpression skinBinding = null;
-	private String baseSkinName = null;
-	private ValueExpression baseSkinBinding = null;
-	private static final Logger log = RichfacesLogger.APPLICATION.getLogger();
+    protected Skin getSkinByName(FacesContext facesContext, Object currentSkinOrName, boolean isBase) {
+        if (null == currentSkinOrName) {
+            throw new SkinNotFoundException(Messages.getMessage(Messages.NULL_SKIN_NAME_ERROR));
+        }
 
-	private static final String A4J_BASE_SKIN_PARAMETER = "org.ajax4jsf.BASE_SKIN";
+        Skin currentSkin = null;
 
-	private static final String A4J_SKIN_PARAMETER = "org.ajax4jsf.SKIN";
+        // user binding return skin instance.
+        if (currentSkinOrName instanceof Skin) {
+            currentSkin = (Skin) currentSkinOrName;
+        } else {
+            String currentSkinName = currentSkinOrName.toString();
+            Map<String, Skin> skinsMap = isBase ? baseSkins : skins;
 
-	protected Skin getSkinByName(FacesContext facesContext, Object currentSkinOrName, boolean isBase) {
-		if (null == currentSkinOrName) {
-			throw new SkinNotFoundException(Messages
-					.getMessage(Messages.NULL_SKIN_NAME_ERROR));
-		}
-		Skin currentSkin = null;
-		// user binding return skin instance.
-		if (currentSkinOrName instanceof Skin) {
-			currentSkin = (Skin) currentSkinOrName;
-		} else {
-			String currentSkinName = currentSkinOrName.toString();
+            synchronized (skinsMap) {
+                currentSkin = skinsMap.get(currentSkinName);
 
-			Map<String, Skin> skinsMap = (isBase ? baseSkins : skins);
-			synchronized (skinsMap) {
-				currentSkin = (Skin) skinsMap.get(currentSkinName);
-				// LAZY creation for skins, since, in case of EL expressions
-				// for skin name, we don't can know all names of existing skins.
-				if (currentSkin == null) {
-					if (log.isDebugEnabled()) {
-						log.debug(Messages.getMessage(
-								Messages.CREATE_SKIN_INFO, currentSkinName));
-					}
-					currentSkin = buildSkin(facesContext, currentSkinName,
-							isBase);
-					skinsMap.put(currentSkinName, currentSkin);
-				}
-			}
-		}
-		return currentSkin;
-	}
+                // LAZY creation for skins, since, in case of EL expressions
+                // for skin name, we don't can know all names of existing skins.
+                if (currentSkin == null) {
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug(Messages.getMessage(Messages.CREATE_SKIN_INFO, currentSkinName));
+                    }
 
-	public Skin getDefaultSkin(FacesContext context) {
-		return getSkinByName(context, DEFAULT_SKIN_NAME, false);
-	}
+                    currentSkin = buildSkin(facesContext, currentSkinName, isBase);
+                    skinsMap.put(currentSkinName, currentSkin);
+                }
+            }
+        }
 
-	public Skin getSkin(FacesContext context) {
-		// TODO - cache skin for current thread ? or for current Faces Lifecycle
-		// Phase ?
-		Object currentSkinOrName = getSkinOrName(context, false);
-		return getSkinByName(context, currentSkinOrName, false);
-	}
+        return currentSkin;
+    }
 
-	public Skin getBaseSkin(FacesContext context) {
-		Object currentSkinOrName = getSkinOrName(context, true);
-		return getSkinByName(context, currentSkinOrName, true);
-	}
+    public Skin getDefaultSkin(FacesContext context) {
+        return getSkinByName(context, DEFAULT_SKIN_NAME, false);
+    }
 
-//	protected Properties getDefaultSkinProperties() {
-//		if (defaultSkinProperties == null) {
-//			defaultSkinProperties = loadProperties(DEFAULT_SKIN_NAME,DEFAULT_SKIN_PATHS);
-//		}
-//		return defaultSkinProperties;
-//	}
+    public Skin getSkin(FacesContext context) {
 
-	/**
-	 * Calculate name for current skin. For EL init parameter store value
-	 * binding for speed calculations.
-	 * 
-	 * @param context
-	 * @param useBase
-	 * @return name of currens skin from init parameter ( "DEFAULT" if no
-	 *         parameter ) or {@link Skin } as result of evaluation EL
-	 *         expression.
-	 */
-	protected Object getSkinOrName(FacesContext context, boolean useBase) {
-		// Detect skin name
-		ValueExpression binding;
-		String skin;
+        // TODO - cache skin for current thread ? or for current Faces Lifecycle
+        // Phase ?
+        Object currentSkinOrName = getSkinOrName(context, false);
 
-		synchronized (this) {
-			if (useBase) {
-				binding = baseSkinBinding;
-				skin = baseSkinName;
-			} else {
-				binding = skinBinding;
-				skin = skinName;
-			}
+        return getSkinByName(context, currentSkinOrName, false);
+    }
 
-			if (binding == null && skin == null) {
-				String currentSkinName = context.getExternalContext()
-						.getInitParameter(
-								useBase ? BASE_SKIN_PARAMETER : SKIN_PARAMETER);
-				if (null == currentSkinName) {
-					// Check for a old ( deprecated ) parameter name.
-					currentSkinName = context.getExternalContext()
-							.getInitParameter(
-									useBase ? A4J_BASE_SKIN_PARAMETER
-											: A4J_SKIN_PARAMETER);
-					if (null != currentSkinName) {
-						log.warn("Init parameter for a skin name changed to "+ (useBase ? BASE_SKIN_PARAMETER
-											: SKIN_PARAMETER));
-					}
+    public Skin getBaseSkin(FacesContext context) {
+        Object currentSkinOrName = getSkinOrName(context, true);
 
-				}
-				if (currentSkinName == null) {
-					// not set - usr default.
-					return DEFAULT_SKIN_NAME;
-				}
-				if (ELUtils.isValueReference(currentSkinName)) {
-					// For EL expression as skin name
-					binding = context.getApplication().getExpressionFactory().
-						createValueExpression(context.getELContext(), 
-							currentSkinName, Object.class);
-				} else {
-					skin = currentSkinName;
-				}
+        return getSkinByName(context, currentSkinOrName, true);
+    }
 
-				if (useBase) {
-					baseSkinBinding = binding;
-					baseSkinName = skin;
-				} else {
-					skinBinding = binding;
-					skinName = skin;
-				}
-			}
+//  protected Properties getDefaultSkinProperties() {
+//      if (defaultSkinProperties == null) {
+//          defaultSkinProperties = loadProperties(DEFAULT_SKIN_NAME,DEFAULT_SKIN_PATHS);
+//      }
+//      return defaultSkinProperties;
+//  }
 
-			// }
-		}
-		if (binding != null) {
-			return binding.getValue(context.getELContext());
-		} else {
-			return skin;
-		}
-	}
+    /**
+     * Calculate name for current skin. For EL init parameter store value
+     * binding for speed calculations.
+     *
+     * @param context
+     * @param useBase
+     * @return name of currens skin from init parameter ( "DEFAULT" if no
+     *         parameter ) or {@link Skin } as result of evaluation EL
+     *         expression.
+     */
+    protected Object getSkinOrName(FacesContext context, boolean useBase) {
 
-	private void processProperties(FacesContext context, Map<Object, Object> properties) {
-	    ELContext elContext = context.getELContext();
-	    // replace all EL-expressions by prepared ValueBinding ?
-	    ApplicationFactory factory = (ApplicationFactory) FactoryFinder
-	    .getFactory(FactoryFinder.APPLICATION_FACTORY);
-	    Application app = factory.getApplication();
-	    
-	    for (Entry<Object, Object> entry : properties.entrySet()) {
-		Object propertyObject = entry.getValue();
-		if (propertyObject instanceof String) {
-		    String property = (String) propertyObject;
-		    if (ELUtils.isValueReference(property)) {
-			ExpressionFactory expressionFactory = app.getExpressionFactory();
-			entry.setValue(expressionFactory.createValueExpression(elContext, property, Object.class));
-		    } else {
-			entry.setValue(property);
-		    }
-		}
-	    }
-	}
-	
-	/**
-	 * Factory method for build skin from properties files. for given skin name,
-	 * search in classpath all resources with name 'name'.skin.properties and
-	 * append in content to default properties. First, get it from
-	 * META-INF/skins/ , next - from root package. for any place search order
-	 * determined by {@link java.lang.ClassLoader } realisation.
-	 * @param name
-	 *            name for builded skin.
-	 * @param defaultProperties
-	 * 
-	 * @return skin instance for current name
-	 * @throws SkinNotFoundException -
-	 *             if no skin properies found for name.
-	 */
-	protected Skin buildSkin(FacesContext context, String name, boolean isBase)
-			throws SkinNotFoundException {
-		Properties skinParams;
-		synchronized (sourceProperties) {
-			skinParams = sourceProperties.get(name);
-			if (skinParams == null) {
-				skinParams = loadProperties(name, SKINS_PATHS);
-				processProperties(context, skinParams);
-				// skinParams = Collections.unmodifiableMap(skinParams);
-				sourceProperties.put(name, skinParams);
-			}
-		}	    
-	    BasicSkinImpl skinImpl;
-	    if (DEFAULT_SKIN_NAME.equals(name)) {
-		skinImpl = new DefaultSkinImpl(skinParams);
-	    } else if (isBase) {
-		skinImpl = new BaseSkinImpl(skinParams, this);
-	    } else {
-		skinImpl = new SkinImpl(skinParams, this);
-	    }
+        // Detect skin name
+        ValueExpression binding;
+        String skin;
 
-	    return skinImpl;
-	}
+        synchronized (this) {
+            if (useBase) {
+                binding = baseSkinBinding;
+                skin = baseSkinName;
+            } else {
+                binding = skinBinding;
+                skin = skinName;
+            }
 
-	/**
-	 * @param name
-	 * @param defaultProperties
-	 * @return
-	 * @throws SkinNotFoundException
-	 * @throws FacesException
-	 */
-	protected Properties loadProperties(String name, String[] paths) throws SkinNotFoundException, FacesException {
-		ClassLoader loader = getClassLoader();
-		// Get properties for concrete skin.
-		Properties skinProperties = new Properties();
-		int loadedPropertiesCount = 0;
-		for (int i = 0; i < paths.length; i++) {
-			String skinPropertiesLocation = paths[i].replaceAll("%s", name);
-			if(loadProperties(loader, skinProperties, skinPropertiesLocation)){
-				loadedPropertiesCount++;
-			}
-		}
-		if (loadedPropertiesCount == 0) {
-			throw new SkinNotFoundException(Messages.getMessage(
-					Messages.SKIN_NOT_FOUND_ERROR, name));
-		}
-		return skinProperties;
-	}
+            if ((binding == null) && (skin == null)) {
+                String currentSkinName = context.getExternalContext().getInitParameter(useBase
+                                             ? BASE_SKIN_PARAMETER : SKIN_PARAMETER);
 
-	/**
-	 * @return
-	 */
-	protected ClassLoader getClassLoader() {
-		return Thread.currentThread().getContextClassLoader();
-	}
+                if (null == currentSkinName) {
 
-	/**
-	 * @param loader
-	 * @param properties
-	 * @param location
-	 */
-	protected boolean loadProperties(ClassLoader loader, Properties properties,
-			String location) {
-		boolean loaded = false;
-		try {
-			Enumeration<URL> resources = loader
-					.getResources(location);
-			while (resources.hasMoreElements()) {
-				URL url = (URL) resources.nextElement();
-				InputStream propertyStream = null;
-				try {
-					propertyStream = URLToStreamHelper.urlToStream(url);
-					properties.load(propertyStream);
-						loaded=true;
-				} catch (IOException e) {
-					log.warn(Messages
-							.getMessage(Messages.SKIN_PROPERTIES_IO_ERROR),
-							e);
-					continue;
-				} finally {
-					if (null != propertyStream) {
-						propertyStream.close();
-					}
-				}
-			}
-		} catch (IOException e) {
-			// Do nothing - we can only log error, and continue to load next
-			// property.
-			if (log.isInfoEnabled()) {
-				log.info(Messages
-						.getMessage(Messages.SKIN_PROPERTIES_IO_ERROR), e);
-			}
-		}
-		return loaded;
-	}
+                    // Check for a old ( deprecated ) parameter name.
+                    currentSkinName = context.getExternalContext().getInitParameter(useBase
+                            ? A4J_BASE_SKIN_PARAMETER : A4J_SKIN_PARAMETER);
 
-	@Override
-	public Theme getTheme(FacesContext facesContext, String name) {
-		Theme theme = themes.get(name);
-		if(null == theme){
-			Properties properties;
-			try {
-				properties = loadProperties(name, THEME_PATHS);
-			} catch (SkinNotFoundException e) {
-				throw new ThemeNotFoundException(Messages.getMessage(
-						Messages.THEME_NOT_FOUND_ERROR, name), e.getCause());
-			}
-			processProperties(facesContext, properties);
-			theme = new ThemeImpl(properties);
-			themes.put(name, theme);
-		}
-		return theme;
-	}
+                    if (null != currentSkinName) {
+                        LOG.warn("Init parameter for a skin name changed to "
+                                 + (useBase ? BASE_SKIN_PARAMETER : SKIN_PARAMETER));
+                    }
+                }
+
+                if (currentSkinName == null) {
+
+                    // not set - usr default.
+                    return DEFAULT_SKIN_NAME;
+                }
+
+                if (ELUtils.isValueReference(currentSkinName)) {
+
+                    // For EL expression as skin name
+                    binding =
+                        context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(),
+                            currentSkinName, Object.class);
+                } else {
+                    skin = currentSkinName;
+                }
+
+                if (useBase) {
+                    baseSkinBinding = binding;
+                    baseSkinName = skin;
+                } else {
+                    skinBinding = binding;
+                    skinName = skin;
+                }
+            }
+
+            // }
+        }
+
+        if (binding != null) {
+            return binding.getValue(context.getELContext());
+        } else {
+            return skin;
+        }
+    }
+
+    private void processProperties(FacesContext context, Map<Object, Object> properties) {
+        ELContext elContext = context.getELContext();
+
+        // replace all EL-expressions by prepared ValueBinding ?
+        ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+        Application app = factory.getApplication();
+
+        for (Entry<Object, Object> entry : properties.entrySet()) {
+            Object propertyObject = entry.getValue();
+
+            if (propertyObject instanceof String) {
+                String property = (String) propertyObject;
+
+                if (ELUtils.isValueReference(property)) {
+                    ExpressionFactory expressionFactory = app.getExpressionFactory();
+
+                    entry.setValue(expressionFactory.createValueExpression(elContext, property, Object.class));
+                } else {
+                    entry.setValue(property);
+                }
+            }
+        }
+    }
+
+    /**
+     * Factory method for build skin from properties files. for given skin name,
+     * search in classpath all resources with name 'name'.skin.properties and
+     * append in content to default properties. First, get it from
+     * META-INF/skins/ , next - from root package. for any place search order
+     * determined by {@link java.lang.ClassLoader } realisation.
+     * @param name
+     *            name for builded skin.
+     * @param defaultProperties
+     *
+     * @return skin instance for current name
+     * @throws SkinNotFoundException -
+     *             if no skin properies found for name.
+     */
+    protected Skin buildSkin(FacesContext context, String name, boolean isBase) throws SkinNotFoundException {
+        Properties skinParams;
+
+        synchronized (sourceProperties) {
+            skinParams = sourceProperties.get(name);
+
+            if (skinParams == null) {
+                skinParams = loadProperties(name, SKINS_PATHS);
+                processProperties(context, skinParams);
+
+                // skinParams = Collections.unmodifiableMap(skinParams);
+                sourceProperties.put(name, skinParams);
+            }
+        }
+
+        BasicSkinImpl skinImpl;
+
+        if (DEFAULT_SKIN_NAME.equals(name)) {
+            skinImpl = new DefaultSkinImpl(skinParams);
+        } else if (isBase) {
+            skinImpl = new BaseSkinImpl(skinParams, this);
+        } else {
+            skinImpl = new SkinImpl(skinParams, this);
+        }
+
+        return skinImpl;
+    }
+
+    /**
+     * @param name
+     * @param paths
+     *
+     * @return
+     *
+     * @throws SkinNotFoundException
+     */
+    protected Properties loadProperties(String name, String[] paths) throws SkinNotFoundException {
+        ClassLoader loader = getClassLoader();
+
+        // Get properties for concrete skin.
+        Properties skinProperties = new Properties();
+        int loadedPropertiesCount = 0;
+
+        for (int i = 0; i < paths.length; i++) {
+            String skinPropertiesLocation = paths[i].replaceAll("%s", name);
+
+            if (loadProperties(loader, skinProperties, skinPropertiesLocation)) {
+                loadedPropertiesCount++;
+            }
+        }
+
+        if (loadedPropertiesCount == 0) {
+            throw new SkinNotFoundException(Messages.getMessage(Messages.SKIN_NOT_FOUND_ERROR, name));
+        }
+
+        return skinProperties;
+    }
+
+    /**
+     * @return
+     */
+    protected ClassLoader getClassLoader() {
+        return Thread.currentThread().getContextClassLoader();
+    }
+
+    /**
+     * @param loader
+     * @param properties
+     * @param location
+     */
+    protected boolean loadProperties(ClassLoader loader, Properties properties, String location) {
+        boolean loaded = false;
+
+        try {
+            Enumeration<URL> resources = loader.getResources(location);
+
+            while (resources.hasMoreElements()) {
+                URL url = (URL) resources.nextElement();
+                InputStream propertyStream = null;
+
+                try {
+                    propertyStream = URLToStreamHelper.urlToStream(url);
+                    properties.load(propertyStream);
+                    loaded = true;
+                } catch (IOException e) {
+                    LOG.warn(Messages.getMessage(Messages.SKIN_PROPERTIES_IO_ERROR), e);
+
+                    continue;
+                } finally {
+                    if (null != propertyStream) {
+                        propertyStream.close();
+                    }
+                }
+            }
+        } catch (IOException e) {
+
+            // Do nothing - we can only log error, and continue to load next
+            // property.
+            if (LOG.isInfoEnabled()) {
+                LOG.info(Messages.getMessage(Messages.SKIN_PROPERTIES_IO_ERROR), e);
+            }
+        }
+
+        return loaded;
+    }
+
+    @Override
+    public Theme getTheme(FacesContext facesContext, String name) {
+        Theme theme = themes.get(name);
+
+        if (null == theme) {
+            Properties properties;
+
+            try {
+                properties = loadProperties(name, THEME_PATHS);
+            } catch (SkinNotFoundException e) {
+                throw new ThemeNotFoundException(Messages.getMessage(Messages.THEME_NOT_FOUND_ERROR, name),
+                                                 e.getCause());
+            }
+
+            processProperties(facesContext, properties);
+            theme = new ThemeImpl(properties);
+            themes.put(name, theme);
+        }
+
+        return theme;
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinPropertyResolver.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinPropertyResolver.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinPropertyResolver.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,17 +19,20 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.skin;
 
+import org.ajax4jsf.Messages;
+
+import org.richfaces.log.RichfacesLogger;
+
+import org.slf4j.Logger;
+
 import javax.faces.context.FacesContext;
 import javax.faces.el.EvaluationException;
-import javax.faces.el.PropertyNotFoundException;
 import javax.faces.el.PropertyResolver;
 
-import org.ajax4jsf.Messages;
-import org.richfaces.log.RichfacesLogger;
-import org.slf4j.Logger;
-
 /**
  * Resolve Skin propertyes.
  * @author asmirnov at exadel.com (latest modification by $Author: alexsmirnov $)
@@ -37,116 +40,145 @@
  *
  */
 public class SkinPropertyResolver extends PropertyResolver {
-	
-	private static final Logger log = RichfacesLogger.APPLICATION.getLogger();
-	private PropertyResolver parent = null;
+    private static final Logger LOG = RichfacesLogger.APPLICATION.getLogger();
+    private PropertyResolver parent = null;
 
-	/**
-	 * @param parent
-	 */
-	public SkinPropertyResolver(PropertyResolver parent) {
-		this.parent = parent;
-	}
+    /**
+     * @param parent
+     */
+    public SkinPropertyResolver(PropertyResolver parent) {
+        this.parent = parent;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.faces.el.PropertyResolver#getType(java.lang.Object, int)
-	 */
-	public Class getType(Object base, int index) throws EvaluationException, PropertyNotFoundException {
-		if (base instanceof Skin) {
-			if(log.isDebugEnabled()){
-				log.debug(Messages.getMessage(Messages.ACESSING_SKIN_PROPERTY_AS_ARRAY_ERROR));
-			}
-			return null;
-		}
-		return parent.getType(base, index);
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.faces.el.PropertyResolver#getType(java.lang.Object, int)
+     */
+    @Override
+    public Class getType(Object base, int index) {
+        if (base instanceof Skin) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug(Messages.getMessage(Messages.ACESSING_SKIN_PROPERTY_AS_ARRAY_ERROR));
+            }
 
-	/* (non-Javadoc)
-	 * @see javax.faces.el.PropertyResolver#getType(java.lang.Object, java.lang.Object)
-	 */
-	public Class getType(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
-		if (base instanceof Skin) {
-			Skin skin = (Skin) base;
-			if(property instanceof String){
-				return skin.getParameter(FacesContext.getCurrentInstance(),(String) property).getClass();
-			}
-			if(log.isDebugEnabled()){
-				log.debug(Messages.getMessage(Messages.ACESSING_SKIN_PROPERTY_ERROR));
-			}
-			return null;
-		}
-		return parent.getType(base, property);
-	}
+            return null;
+        }
 
-	/* (non-Javadoc)
-	 * @see javax.faces.el.PropertyResolver#getValue(java.lang.Object, int)
-	 */
-	public Object getValue(Object base, int index) throws EvaluationException, PropertyNotFoundException {
-		if (base instanceof Skin) {
-			if(log.isDebugEnabled()){
-				log.debug(Messages.getMessage(Messages.ACESSING_SKIN_PROPERTY_AS_ARRAY_ERROR));
-			}
-			return null;
-		}
-		return parent.getValue(base, index);
-	}
+        return parent.getType(base, index);
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.faces.el.PropertyResolver#getValue(java.lang.Object, java.lang.Object)
-	 */
-	public Object getValue(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
-		if (base instanceof Skin) {
-			Skin skin = (Skin) base;
-			if(property instanceof String){
-				return skin.getParameter(FacesContext.getCurrentInstance(),(String) property);
-			}
-			if(log.isDebugEnabled()){
-				log.debug(Messages.getMessage(Messages.ACESSING_SKIN_PROPERTY_ERROR));
-			}
-			return null;
-		}
-		return parent.getValue(base, property);
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.faces.el.PropertyResolver#getType(java.lang.Object, java.lang.Object)
+     */
+    @Override
+    public Class getType(Object base, Object property) {
+        if (base instanceof Skin) {
+            Skin skin = (Skin) base;
 
-	/* (non-Javadoc)
-	 * @see javax.faces.el.PropertyResolver#isReadOnly(java.lang.Object, int)
-	 */
-	public boolean isReadOnly(Object base, int arg1) throws EvaluationException, PropertyNotFoundException {
-		if (base instanceof Skin) {
-			return true;
-		}
-		return parent.isReadOnly(base, arg1);
-	}
+            if (property instanceof String) {
+                return skin.getParameter(FacesContext.getCurrentInstance(), (String) property).getClass();
+            }
 
-	/* (non-Javadoc)
-	 * @see javax.faces.el.PropertyResolver#isReadOnly(java.lang.Object, java.lang.Object)
-	 */
-	public boolean isReadOnly(Object base, Object arg1) throws EvaluationException, PropertyNotFoundException {
-		if (base instanceof Skin) {
-			return true;
-		}
-		return parent.isReadOnly(base, arg1);
-	}
+            if (LOG.isDebugEnabled()) {
+                LOG.debug(Messages.getMessage(Messages.ACESSING_SKIN_PROPERTY_ERROR));
+            }
 
-	/* (non-Javadoc)
-	 * @see javax.faces.el.PropertyResolver#setValue(java.lang.Object, int, java.lang.Object)
-	 */
-	public void setValue(Object base, int index, Object value) throws EvaluationException, PropertyNotFoundException {
-		if (base instanceof Skin) {
-			throw new EvaluationException(Messages.getMessage(Messages.SKIN_PROPERTIES_READ_ONLY_ERROR));
-		}
-		parent.setValue(base, index, value);
-	}
+            return null;
+        }
 
-	/* (non-Javadoc)
-	 * @see javax.faces.el.PropertyResolver#setValue(java.lang.Object, java.lang.Object, java.lang.Object)
-	 */
-	public void setValue(Object base, Object property, Object value) throws EvaluationException, PropertyNotFoundException {
-		if (base instanceof Skin) {
-			throw new EvaluationException(Messages.getMessage(Messages.SKIN_PROPERTIES_READ_ONLY_ERROR));
-		}
-		parent.setValue(base, property, value);
-	}
+        return parent.getType(base, property);
+    }
 
+    /*
+     *  (non-Javadoc)
+     * @see javax.faces.el.PropertyResolver#getValue(java.lang.Object, int)
+     */
+    @Override
+    public Object getValue(Object base, int index) {
+        if (base instanceof Skin) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug(Messages.getMessage(Messages.ACESSING_SKIN_PROPERTY_AS_ARRAY_ERROR));
+            }
 
+            return null;
+        }
+
+        return parent.getValue(base, index);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.faces.el.PropertyResolver#getValue(java.lang.Object, java.lang.Object)
+     */
+    @Override
+    public Object getValue(Object base, Object property) {
+        if (base instanceof Skin) {
+            Skin skin = (Skin) base;
+
+            if (property instanceof String) {
+                return skin.getParameter(FacesContext.getCurrentInstance(), (String) property);
+            }
+
+            if (LOG.isDebugEnabled()) {
+                LOG.debug(Messages.getMessage(Messages.ACESSING_SKIN_PROPERTY_ERROR));
+            }
+
+            return null;
+        }
+
+        return parent.getValue(base, property);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.faces.el.PropertyResolver#isReadOnly(java.lang.Object, int)
+     */
+    @Override
+    public boolean isReadOnly(Object base, int arg1) {
+        if (base instanceof Skin) {
+            return true;
+        }
+
+        return parent.isReadOnly(base, arg1);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.faces.el.PropertyResolver#isReadOnly(java.lang.Object, java.lang.Object)
+     */
+    @Override
+    public boolean isReadOnly(Object base, Object arg1) {
+        if (base instanceof Skin) {
+            return true;
+        }
+
+        return parent.isReadOnly(base, arg1);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.faces.el.PropertyResolver#setValue(java.lang.Object, int, java.lang.Object)
+     */
+    @Override
+    public void setValue(Object base, int index, Object value) {
+        if (base instanceof Skin) {
+            throw new EvaluationException(Messages.getMessage(Messages.SKIN_PROPERTIES_READ_ONLY_ERROR));
+        }
+
+        parent.setValue(base, index, value);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.faces.el.PropertyResolver#setValue(java.lang.Object, java.lang.Object, java.lang.Object)
+     */
+    @Override
+    public void setValue(Object base, Object property, Object value) {
+        if (base instanceof Skin) {
+            throw new EvaluationException(Messages.getMessage(Messages.SKIN_PROPERTIES_READ_ONLY_ERROR));
+        }
+
+        parent.setValue(base, property, value);
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinVariableResolver.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinVariableResolver.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/skin/SkinVariableResolver.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,15 +19,16 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.skin;
 
+import org.richfaces.VersionBean;
+
 import javax.faces.context.FacesContext;
 import javax.faces.el.EvaluationException;
 import javax.faces.el.VariableResolver;
 
-import org.richfaces.VersionBean;
-import org.richfaces.skin.SkinFactory;
-
 /**
  * Resolve current skin as EL Variable. e.g. #{chameleonSkin['color'] } #{chameleonSkin.color}
  * must be evaluated as Skin.getProperty(context,"color");
@@ -36,36 +37,31 @@
  *
  */
 public class SkinVariableResolver extends VariableResolver {
+    public static final String CHAMELEON_VARIABLE_NAME = "vcp";
+    public static final String SKIN_VARIABLE_NAME = "vcpSkin";
+    private VariableResolver parent = null;
 
+    public SkinVariableResolver(VariableResolver parent) {
+        this.parent = parent;
+    }
 
-	public static final String SKIN_VARIABLE_NAME = "vcpSkin";
+    /*
+     *  (non-Javadoc)
+     * @see javax.faces.el.VariableResolver#resolveVariable(javax.faces.context.FacesContext, java.lang.String)
+     */
+    public Object resolveVariable(FacesContext context, String name) throws EvaluationException {
 
-	public static final String CHAMELEON_VARIABLE_NAME = "vcp";
+        // TODO: Why do we need this?
+        if (SKIN_VARIABLE_NAME.equals(name)) {
+            return SkinFactory.getInstance().getSkin(context);
+        } else if (CHAMELEON_VARIABLE_NAME.equals(name)) {
+            return new VersionBean();
+        }
 
-	private VariableResolver parent = null;
-
-	public SkinVariableResolver(VariableResolver parent){
-		this.parent = parent;
-	}
-	/* (non-Javadoc)
-	 * @see javax.faces.el.VariableResolver#resolveVariable(javax.faces.context.FacesContext, java.lang.String)
-	 */
-	public Object resolveVariable(FacesContext context, String name)
-			throws EvaluationException {
-		
-		// TODO: Why do we need this?
-		if(SKIN_VARIABLE_NAME.equals(name)){
-			return SkinFactory.getInstance().getSkin(context);
-		} else if(CHAMELEON_VARIABLE_NAME.equals(name)){
-			return new VersionBean();
-		}
-		if (parent!=null) {
-			Object ret = null;
-			ret = parent.resolveVariable(context,name);
-			return ret;
-		} else {
-			return null;
-		}
-	}
-
+        if (parent != null) {
+            return parent.resolveVariable(context, name);
+        } else {
+            return null;
+        }
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/skin/ThemeImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/skin/ThemeImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/skin/ThemeImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,11 +1,13 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.skin;
 
 import java.util.Properties;
 
 import javax.el.ValueExpression;
+
 import javax.faces.context.FacesContext;
 
 /**
@@ -13,47 +15,52 @@
  *
  */
 public class ThemeImpl implements Theme {
-	
-	private final Properties themeProperties;
+    private final Properties themeProperties;
 
-	/**
-	 * @param themeProperties
-	 */
-	public ThemeImpl(Properties themeProperties) {
-		this.themeProperties = themeProperties;
-	}
+    /**
+     * @param themeProperties
+     */
+    public ThemeImpl(Properties themeProperties) {
+        this.themeProperties = themeProperties;
+    }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.skin.Theme#getProperty(java.lang.String)
-	 */
-	public Object getProperty(String name) {
-		Object property = themeProperties.get(name);
-		if (property instanceof ValueExpression) {
-			ValueExpression ve = (ValueExpression) property;
-			property = ve.getValue(FacesContext.getCurrentInstance().getELContext());
-		}
-		return property;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.skin.Theme#getProperty(java.lang.String)
+     */
+    public Object getProperty(String name) {
+        Object property = themeProperties.get(name);
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.skin.Theme#getRendererType()
-	 */
-	public String getRendererType() {
-		return (String) getProperty("rendererType");
-	}
+        if (property instanceof ValueExpression) {
+            ValueExpression ve = (ValueExpression) property;
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.skin.Theme#getScript()
-	 */
-	public String getScript() {
-		return (String) getProperty("script");
-	}
+            property = ve.getValue(FacesContext.getCurrentInstance().getELContext());
+        }
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.skin.Theme#getStyle()
-	 */
-	public String getStyle() {
-		return (String) getProperty("styleSheet");
-	}
+        return property;
+    }
 
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.skin.Theme#getRendererType()
+     */
+    public String getRendererType() {
+        return (String) getProperty("rendererType");
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.skin.Theme#getScript()
+     */
+    public String getScript() {
+        return (String) getProperty("script");
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.skin.Theme#getStyle()
+     */
+    public String getStyle() {
+        return (String) getProperty("styleSheet");
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/skin/package-info.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/skin/package-info.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/skin/package-info.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,3 +1,4 @@
+
 /**
  * Implementation of RichFaces skinning
  */

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/util/CollectionsUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/util/CollectionsUtils.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/util/CollectionsUtils.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,8 +1,7 @@
+
 /*
- * $Id$
+* $Id$
  */
-
-
 package org.richfaces.util;
 
 import java.util.Arrays;
@@ -18,50 +17,52 @@
  * @author asmirnov at exadel.com
  *
  */
-public class CollectionsUtils {
+public final class CollectionsUtils {
+    private CollectionsUtils() {
 
-	private CollectionsUtils() {
-		// this class contains static methods only.
-	}
-	
-	public static <T> T[] ar(T...ts){
-		return ts;
-	}
-	
-	public static <T> T[] ar(){
-		return null;
-	}
+        // this class contains static methods only.
+    }
 
-	public static <T,V> ConstMap<T,V> map() {
-		return new ConstMap<T, V>();
-	}
-	
-	public <T> Set<T> set(T...ts) {
-		LinkedHashSet<T> set = new LinkedHashSet<T>(ts.length);
-		for (T t : ts) {
-			set.add(t);
-		}
-		return Collections.unmodifiableSet(set);
-	}
-	
-	public <T> List<T> list(T...ts) {
-		return Collections.unmodifiableList(Arrays.asList(ts));
-	}
-	
-	@SuppressWarnings("serial")
-	public static class ConstMap<T,V> extends LinkedHashMap<T,V> {
-		
-		public ConstMap() {
-			super(50, 1.0F);
-		}
-		
-		public ConstMap<T, V> add(T key, V value) {
-			put(key, value);
-			return this;
-		}
-		
-		public Map<T,V> fix() {
-			return Collections.unmodifiableMap(this);
-		}
-	}
+    public static <T> T[] ar(T... ts) {
+        return ts;
+    }
+
+    public static <T> T[] ar() {
+        return null;
+    }
+
+    public static <T, V> ConstMap<T, V> map() {
+        return new ConstMap<T, V>();
+    }
+
+    public <T> Set<T> set(T... ts) {
+        LinkedHashSet<T> set = new LinkedHashSet<T>(ts.length);
+
+        for (T t : ts) {
+            set.add(t);
+        }
+
+        return Collections.unmodifiableSet(set);
+    }
+
+    public <T> List<T> list(T... ts) {
+        return Collections.unmodifiableList(Arrays.asList(ts));
+    }
+
+    @SuppressWarnings("serial")
+    public static class ConstMap<T, V> extends LinkedHashMap<T, V> {
+        public ConstMap() {
+            super(50, 1.0F);
+        }
+
+        public ConstMap<T, V> add(T key, V value) {
+            put(key, value);
+
+            return this;
+        }
+
+        public Map<T, V> fix() {
+            return Collections.unmodifiableMap(this);
+        }
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/util/ReferenceMap.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/util/ReferenceMap.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/util/ReferenceMap.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,11 +19,14 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.util;
 
 import java.lang.ref.Reference;
 import java.lang.ref.ReferenceQueue;
 import java.lang.ref.SoftReference;
+
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -32,144 +35,146 @@
 
 /**
  * Created 17.03.2008
+ *
  * @author Nick Belaevski
  * @since 3.2
  */
-
 public class ReferenceMap<K, V> implements Map<K, V> {
+    private ReferenceQueue<V> queue = new ReferenceQueue<V>();
+    private Map<K, Reference<V>> map;
 
-	private Map<K, Reference<V>> map;
+    public ReferenceMap() {
+        this(Collections.synchronizedMap(new HashMap<K, Reference<V>>()));
+    }
 
-	private ReferenceQueue<V> queue = new ReferenceQueue<V>();
+    public ReferenceMap(Map<K, Reference<V>> map) {
+        super();
+        this.map = map;
+    }
 
-	protected static class ReferenceMapSoftReference<K, V> extends SoftReference<V> {
-		private K key;
+    private void purge() {
+        Reference<? extends V> reference = null;
 
-		public K getKey() {
-			return key;
-		}
+        while ((reference = queue.poll()) != null) {
+            ReferenceMapSoftReference<?, ?> entry = (ReferenceMapSoftReference<?, ?>) reference;
 
-		public ReferenceMapSoftReference(K key, V value, ReferenceQueue<? super V> queue) {
-			super(value, queue);
-			this.key = key;
-		}
-	}	
-	
-	public ReferenceMap() {
-		this(Collections.synchronizedMap(new HashMap<K, Reference<V>>()));
-	}
-	
-	public ReferenceMap(Map<K, Reference<V>> map) {
-		super();
-		
-		this.map = map;
-	}
-	
-	private void purge() {
-		Reference<? extends V> reference = null;
-		while ((reference = queue.poll()) != null) {
-			ReferenceMapSoftReference<?, ?> entry = (ReferenceMapSoftReference<?, ?>) reference;
-			entry.clear();
-			map.remove(entry.getKey());
-		}
-	}
+            entry.clear();
+            map.remove(entry.getKey());
+        }
+    }
 
-	public void clear() {
-		map.clear();
-		
-		Reference<? extends V> reference = null;
-		while ((reference = queue.poll()) != null) {
-			//release queue entries
-			reference.clear();
-		}
-	}
+    public void clear() {
+        map.clear();
 
-	public boolean containsKey(Object key) {
-		purge();
+        Reference<? extends V> reference = null;
 
-		return map.containsKey(key);
-	}
+        while ((reference = queue.poll()) != null) {
 
-	public boolean containsValue(Object value) {
-		throw new UnsupportedOperationException();
-	}
+            // release queue entries
+            reference.clear();
+        }
+    }
 
-	public Set<java.util.Map.Entry<K, V>> entrySet() {
-		throw new UnsupportedOperationException();
-	}
+    public boolean containsKey(Object key) {
+        purge();
 
-	public V get(Object key) {
-		purge();
+        return map.containsKey(key);
+    }
 
-		Reference<V> reference = map.get(key);
-		if (reference != null) {
-			return reference.get();
-		}
+    public boolean containsValue(Object value) {
+        throw new UnsupportedOperationException();
+    }
 
-		return null;
-	}
+    public Set<java.util.Map.Entry<K, V>> entrySet() {
+        throw new UnsupportedOperationException();
+    }
 
-	public boolean isEmpty() {
-		purge();
+    public V get(Object key) {
+        purge();
 
-		return map.isEmpty();
-	}
+        Reference<V> reference = map.get(key);
 
-	public Set<K> keySet() {
-		purge();
+        if (reference != null) {
+            return reference.get();
+        }
 
-		return map.keySet();
-	}
+        return null;
+    }
 
-	private V doPut(K key, V value) {
-		Reference<V> reference = map.put(key, new ReferenceMapSoftReference<K, V>(key, value, queue));
+    public boolean isEmpty() {
+        purge();
 
-		if (reference != null) {
-			return reference.get();
-		}
+        return map.isEmpty();
+    }
 
-		return null;
-	}
+    public Set<K> keySet() {
+        purge();
 
-	public V put(K key, V value) {
-		purge();
+        return map.keySet();
+    }
 
-		V v = doPut(key, value);
-	
-		purge();
-		
-		return v;
-	}
+    private V doPut(K key, V value) {
+        Reference<V> reference = map.put(key, new ReferenceMapSoftReference<K, V>(key, value, queue));
 
-	public void putAll(Map<? extends K, ? extends V> t) {
-		purge();
+        if (reference != null) {
+            return reference.get();
+        }
 
-		for (Map.Entry<? extends K, ? extends V> entry: t.entrySet()) {
-			doPut(entry.getKey(), entry.getValue());
-		}
-		
-		purge();
-	}
+        return null;
+    }
 
-	public V remove(Object key) {
-		purge();
+    public V put(K key, V value) {
+        purge();
 
-		Reference<V> reference = map.remove(key);
-		if (reference != null) {
-			return reference.get();
-		}
+        V v = doPut(key, value);
 
-		return null;
-	}
+        purge();
 
-	public int size() {
-		purge();
+        return v;
+    }
 
-		return map.size();
-	}
+    public void putAll(Map<? extends K, ? extends V> t) {
+        purge();
 
-	public Collection<V> values() {
-		throw new UnsupportedOperationException();
-	}
-	
-}
\ No newline at end of file
+        for (Map.Entry<? extends K, ? extends V> entry : t.entrySet()) {
+            doPut(entry.getKey(), entry.getValue());
+        }
+
+        purge();
+    }
+
+    public V remove(Object key) {
+        purge();
+
+        Reference<V> reference = map.remove(key);
+
+        if (reference != null) {
+            return reference.get();
+        }
+
+        return null;
+    }
+
+    public int size() {
+        purge();
+
+        return map.size();
+    }
+
+    public Collection<V> values() {
+        throw new UnsupportedOperationException();
+    }
+
+    protected static class ReferenceMapSoftReference<K, V> extends SoftReference<V> {
+        private K key;
+
+        public ReferenceMapSoftReference(K key, V value, ReferenceQueue<? super V> queue) {
+            super(value, queue);
+            this.key = key;
+        }
+
+        public K getKey() {
+            return key;
+        }
+    }
+}

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/util/RequestStateManager.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/util/RequestStateManager.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/util/RequestStateManager.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.util;
 
 import java.util.HashMap;
@@ -31,98 +33,98 @@
  * @since 4.0
  */
 public final class RequestStateManager {
+    private static final String CONTEXT_ATTRIBUTE_NAME = RequestStateManager.class.getName();
 
-	private static final String CONTEXT_ATTRIBUTE_NAME = RequestStateManager.class.getName();
-	
-	private RequestStateManager() {}
+    private RequestStateManager() {}
 
-	//TODO remove this stuff
-	public static enum BooleanRequestStateVariable {
-		
-		LegacyResourceRequest("org.richfaces.LEGACY_RESOURCE_REQUEST"),
+    // TODO remove this stuff
+    public static enum BooleanRequestStateVariable {
+        LegacyResourceRequest("org.richfaces.LEGACY_RESOURCE_REQUEST"),
+        ResourceRequest("org.richfaces.RESOURCE_REQUEST");
 
-		ResourceRequest("org.richfaces.RESOURCE_REQUEST");
-		
-		private String attributeName;
-		
-		private BooleanRequestStateVariable(String attributeName) {
-			this.attributeName = attributeName;
-		}
-		
-		public Boolean get(FacesContext context) {
-			return (Boolean) RequestStateManager.get(context, this.attributeName);
-		}
-		
-		public void set(FacesContext context, Boolean value) {
-			RequestStateManager.set(context, this.attributeName, value);
-		}
-	}
-	
-	
-	@SuppressWarnings("unchecked")
-	private static Map<String, Object> getStateMap(FacesContext context, boolean create) {
-		Map<Object, Object> attributesMap = context.getAttributes();
-		
-		Map<String, Object> result = (Map<String, Object>) attributesMap.get(CONTEXT_ATTRIBUTE_NAME);
-		if (create && result == null) {
-			result = new HashMap<String, Object>();
-			attributesMap.put(CONTEXT_ATTRIBUTE_NAME, result);
-		}
-		
-		return result;
-	}
-	
-	public static boolean containsKey(FacesContext context, String key) {
-		if (context == null) {
-			throw new NullPointerException("context");
-		}
+        private String attributeName;
 
-		if (key == null) {
-			throw new NullPointerException("key");
-		}
-		
-		Map<String, Object> stateMap = getStateMap(context, false);
-		if (stateMap != null) {
-			return stateMap.containsKey(key);
-		} else {
-			return false;
-		}
-	}
-	
-	public static Object get(FacesContext context, String key) {
-		if (context == null) {
-			throw new NullPointerException("context");
-		}
+        private BooleanRequestStateVariable(String attributeName) {
+            this.attributeName = attributeName;
+        }
 
-		if (key == null) {
-			throw new NullPointerException("key");
-		}
-		
-		Map<String, Object> stateMap = getStateMap(context, false);
-		if (stateMap != null) {
-			return stateMap.get(key);
-		}
+        public Boolean get(FacesContext context) {
+            return (Boolean) RequestStateManager.get(context, this.attributeName);
+        }
 
+        public void set(FacesContext context, Boolean value) {
+            RequestStateManager.set(context, this.attributeName, value);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private static Map<String, Object> getStateMap(FacesContext context, boolean create) {
+        Map<Object, Object> attributesMap = context.getAttributes();
+        Map<String, Object> result = (Map<String, Object>) attributesMap.get(CONTEXT_ATTRIBUTE_NAME);
+
+        if (create && (result == null)) {
+            result = new HashMap<String, Object>();
+            attributesMap.put(CONTEXT_ATTRIBUTE_NAME, result);
+        }
+
+        return result;
+    }
+
+    public static boolean containsKey(FacesContext context, String key) {
+        if (context == null) {
+            throw new NullPointerException("context");
+        }
+
+        if (key == null) {
+            throw new NullPointerException("key");
+        }
+
+        Map<String, Object> stateMap = getStateMap(context, false);
+
+        if (stateMap != null) {
+            return stateMap.containsKey(key);
+        } else {
+            return false;
+        }
+    }
+
+    public static Object get(FacesContext context, String key) {
+        if (context == null) {
+            throw new NullPointerException("context");
+        }
+
+        if (key == null) {
+            throw new NullPointerException("key");
+        }
+
+        Map<String, Object> stateMap = getStateMap(context, false);
+
+        if (stateMap != null) {
+            return stateMap.get(key);
+        }
+
         return null;
-	}
-	
-	public static void set(FacesContext context, String key, Object value) {
-		if (context == null) {
-			throw new NullPointerException("context");
-		}
+    }
 
-		if (key == null) {
-			throw new NullPointerException("key");
-		}
-		
-		if (value != null) {
-			Map<String, Object> stateMap = getStateMap(context, true);
-			stateMap.put(key, value);
-		} else {
-			Map<String, Object> stateMap = getStateMap(context, false);
-			if (stateMap != null) {
-				stateMap.remove(key);
-			}
-		}
-	}
+    public static void set(FacesContext context, String key, Object value) {
+        if (context == null) {
+            throw new NullPointerException("context");
+        }
+
+        if (key == null) {
+            throw new NullPointerException("key");
+        }
+
+        if (value != null) {
+            Map<String, Object> stateMap = getStateMap(context, true);
+
+            stateMap.put(key, value);
+        } else {
+            Map<String, Object> stateMap = getStateMap(context, false);
+
+            if (stateMap != null) {
+                stateMap.remove(key);
+            }
+        }
+    }
 }

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/util/Util.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/util/Util.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/util/Util.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,8 +1,8 @@
 /*
  * 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
@@ -10,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
@@ -19,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
@@ -32,23 +32,35 @@
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
- * 
+ *
  * Portions Copyrighted 2009 Exadel, Inc.
- * 
- * Exadel. Inc, elects to include this software in this distribution under the 
+ *
+ * Exadel. Inc, elects to include this software in this distribution under the
  * GPL Version 2 license.
  */
 
+
+
 package org.richfaces.util;
 
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.util.base64.Codec;
+
+import org.richfaces.log.RichfacesLogger;
+
+import org.slf4j.Logger;
+
 import java.io.*;
+
 import java.nio.ByteBuffer;
 import java.nio.channels.Channels;
 import java.nio.channels.ReadableByteChannel;
 import java.nio.channels.WritableByteChannel;
+
 import java.text.Format;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+
 import java.util.Date;
 import java.util.Locale;
 import java.util.TimeZone;
@@ -62,37 +74,41 @@
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.util.base64.Codec;
-import org.richfaces.log.RichfacesLogger;
-import org.slf4j.Logger;
-
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public final class Util {
+    private static final String DATA_BYTES_SEPARATOR = "/DATB/";
+    private static final String DATA_SEPARATOR = "/DATA/";
 
+    // index of capturing group denoting version
+    private static final int DATA_SEPARATOR_DATA_GROUP_INDEX = 2;
+
+    // index of capturing group denoting data type encoded
+    private static final int DATA_SEPARATOR_TYPE_GROUP_INDEX = 1;
     private static final Logger RESOURCE_LOGGER = RichfacesLogger.RESOURCE.getLogger();
 
-    private Util() {
-    }
-
     /* HTTP Date format required by the HTTP/1.1 RFC */
     private static final String RFC1123_DATE_PATTERN = "EEE, dd MMM yyyy HH:mm:ss zzz";
 
+    // TODO codec have settings
+    private static final Codec CODEC = new Codec();
+    private static final String VERSION_SEPARATOR = "/VER";
+    private static final Pattern DATA_SEPARATOR_PATTERN = Pattern.compile("/DAT(A|B)/([^/]*)");
     private static final SimpleDateFormat RFC1123_DATE_FORMATTER;
 
     static {
         SimpleDateFormat format = new SimpleDateFormat(RFC1123_DATE_PATTERN, Locale.US);
+
         format.setTimeZone(TimeZone.getTimeZone("GMT"));
-
         RFC1123_DATE_FORMATTER = format;
     }
 
+    private Util() {}
+
     public static String getMappingForRequest(FacesContext context) {
         ExternalContext externalContext = context.getExternalContext();
-
         String servletPath = externalContext.getRequestServletPath();
 
         if (servletPath == null) {
@@ -104,11 +120,13 @@
         }
 
         String pathInfo = externalContext.getRequestPathInfo();
+
         if (pathInfo != null) {
             return servletPath;
         }
 
         int idx = servletPath.lastIndexOf('.');
+
         if (idx < 0) {
             return servletPath;
         } else {
@@ -123,6 +141,7 @@
             try {
                 result = (Date) ((Format) RFC1123_DATE_FORMATTER.clone()).parseObject(s);
             } catch (ParseException e) {
+
                 // TODO Auto-generated catch block
                 e.printStackTrace();
             }
@@ -139,32 +158,20 @@
         }
     }
 
-    //TODO codec have settings
-    private static final Codec CODEC = new Codec();
-
-    private static final String DATA_SEPARATOR = "/DATA/";
-    private static final String DATA_BYTES_SEPARATOR = "/DATB/";
-    private static final String VERSION_SEPARATOR = "/VER";
-
-    private static final Pattern DATA_SEPARATOR_PATTERN = Pattern
-            .compile("/DAT(A|B)/([^/]*)");
-
-    //index of capturing group denoting data type encoded
-    private static final int DATA_SEPARATOR_TYPE_GROUP_INDEX = 1;
-
-    //index of capturing group denoting version
-    private static final int DATA_SEPARATOR_DATA_GROUP_INDEX = 2;
-
     protected static byte[] encrypt(byte[] src) {
         try {
             Deflater compressor = new Deflater(Deflater.BEST_SPEED);
             byte[] compressed = new byte[src.length + 100];
+
             compressor.setInput(src);
             compressor.finish();
+
             int totalOut = compressor.deflate(compressed);
             byte[] zipsrc = new byte[totalOut];
+
             System.arraycopy(compressed, 0, zipsrc, 0, totalOut);
             compressor.end();
+
             return CODEC.encode(zipsrc);
         } catch (Exception e) {
             throw new FacesException("Error encode resource data", e);
@@ -176,32 +183,38 @@
             byte[] zipsrc = CODEC.decode(src);
             Inflater decompressor = new Inflater();
             byte[] uncompressed = new byte[zipsrc.length * 5];
+
             decompressor.setInput(zipsrc);
+
             int totalOut = decompressor.inflate(uncompressed);
             byte[] out = new byte[totalOut];
+
             System.arraycopy(uncompressed, 0, out, 0, totalOut);
             decompressor.end();
+
             return out;
         } catch (Exception e) {
             throw new FacesException("Error decode resource data", e);
         }
     }
 
-    public static String encodeResourceData(String resourceName, Object storeData,
-                                            String resourceVersion) {
+    public static String encodeResourceData(String resourceName, Object storeData, String resourceVersion) {
+        StringBuilder uri = new StringBuilder(); // ResourceServlet.DEFAULT_SERVLET_PATH).append("/");
 
-        StringBuilder uri = new StringBuilder();// ResourceServlet.DEFAULT_SERVLET_PATH).append("/");
         uri.append(resourceName);
+
         // append serialized data as Base-64 encoded request string.
         if (storeData != null) {
             try {
                 byte[] objectData;
+
                 if (storeData instanceof byte[]) {
                     objectData = (byte[]) storeData;
                     uri.append(DATA_BYTES_SEPARATOR);
                 } else {
                     ByteArrayOutputStream dataSteram = new ByteArrayOutputStream(1024);
                     ObjectOutputStream objStream = new ObjectOutputStream(dataSteram);
+
                     objStream.writeObject(storeData);
                     objStream.flush();
                     objStream.close();
@@ -209,7 +222,9 @@
                     objectData = dataSteram.toByteArray();
                     uri.append(DATA_SEPARATOR);
                 }
+
                 byte[] dataArray = encrypt(objectData);
+
                 uri.append(new String(dataArray, "ISO-8859-1"));
 
                 // / byte[] objectData = dataSteram.toByteArray();
@@ -221,33 +236,37 @@
             }
         }
 
-        if (resourceVersion != null && resourceVersion.length() != 0) {
+        if ((resourceVersion != null) && (resourceVersion.length() != 0)) {
             uri.append(VERSION_SEPARATOR);
             uri.append(resourceVersion);
         }
-//boolean isGlobal = !resource.isSessionAware();
 
-//		String resourceURL = getFacesResourceURL(context,
-//				uri.toString(), false /*isGlobal*/);// context.getApplication().getViewHandler().getResourceURL(context,uri.toString());
-        //if (!isGlobal) {
-        //	resourceURL = context.getExternalContext().encodeResourceURL(
-        //			resourceURL);
-        //}
-//		if (log.isDebugEnabled()) {
-//			log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_URI_INFO,
-//					resource.getKey(), resourceURL));
-//		}
-        return uri.toString();// context.getExternalContext().encodeResourceURL(resourceURL);
+//      boolean isGlobal = !resource.isSessionAware();
+//      String resourceURL = getFacesResourceURL(context,
+//              uri.toString(), false /*isGlobal*/);// context.getApplication().getViewHandler()
+// .getResourceURL(context,uri.toString());
+        // if (!isGlobal) {
+        // resourceURL = context.getExternalContext().encodeResourceURL(
+        // resourceURL);
+        // }
+//      if (log.isDebugEnabled()) {
+//          log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_URI_INFO,
+//                  resource.getKey(), resourceURL));
+//      }
+        return uri.toString(); // context.getExternalContext().encodeResourceURL(resourceURL);
     }
 
     public static String getResourceName(String resourceUri) {
         String resourceName = resourceUri;
         Matcher matcher = DATA_SEPARATOR_PATTERN.matcher(resourceName);
+
         if (matcher.find()) {
             int data = matcher.start();
+
             resourceName = resourceName.substring(0, data);
         } else {
             int idx = resourceName.indexOf(VERSION_SEPARATOR);
+
             if (idx > 0) {
                 resourceName = resourceName.substring(0, idx);
             }
@@ -258,6 +277,7 @@
 
     public static String getResourceVersion(String resourceUri) {
         int idx = resourceUri.indexOf(VERSION_SEPARATOR);
+
         if (idx > 0) {
             return resourceUri.substring(idx + VERSION_SEPARATOR.length());
         }
@@ -268,31 +288,33 @@
     public static Object getResourceData(String resourceUri) {
         Object data = null;
         Matcher matcher = DATA_SEPARATOR_PATTERN.matcher(resourceUri);
+
         if (!matcher.find()) {
             return data;
         }
 
         if (RESOURCE_LOGGER.isDebugEnabled()) {
-            RESOURCE_LOGGER.debug(Messages.getMessage(
-                    Messages.RESTORE_DATA_FROM_RESOURCE_URI_INFO, resourceUri, null));
+            RESOURCE_LOGGER.debug(Messages.getMessage(Messages.RESTORE_DATA_FROM_RESOURCE_URI_INFO, resourceUri, null));
         }
 
         String dataString = matcher.group(DATA_SEPARATOR_DATA_GROUP_INDEX);
         byte[] objectArray = null;
+
         try {
             byte[] dataArray = dataString.getBytes("ISO-8859-1");
+
             objectArray = decrypt(dataArray);
         } catch (UnsupportedEncodingException e1) {
+
             // default encoding always presented.
         }
-        
 
         if ("B".equals(matcher.group(DATA_SEPARATOR_TYPE_GROUP_INDEX))) {
             data = objectArray;
         } else {
             try {
-                ObjectInputStream in = new ObjectInputStream(
-                        new ByteArrayInputStream(objectArray));
+                ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(objectArray));
+
                 data = in.readObject();
             } catch (StreamCorruptedException e) {
                 RESOURCE_LOGGER.error(Messages.getMessage(Messages.STREAM_CORRUPTED_ERROR), e);
@@ -308,8 +330,8 @@
 
     public static String encodeResourceURL(FacesContext context, String url) {
         String mapping = Util.getMappingForRequest(context);
+        String resourcePath = url;
 
-        String resourcePath = url;
         if (mapping.startsWith("/")) {
             if (mapping.length() != 1) {
                 resourcePath = mapping + url;
@@ -319,22 +341,24 @@
         }
 
         ViewHandler viewHandler = context.getApplication().getViewHandler();
+
         return viewHandler.getResourceURL(context, resourcePath);
     }
 
     public static String decodeResourceURL(FacesContext context) {
         ExternalContext externalContext = context.getExternalContext();
         String resourceName = null;
+        String facesMapping = Util.getMappingForRequest(context);
 
-        String facesMapping = Util.getMappingForRequest(context);
         if (facesMapping != null) {
             if (facesMapping.startsWith("/")) {
-                //prefix mapping
+
+                // prefix mapping
                 resourceName = externalContext.getRequestPathInfo();
             } else {
                 String requestServletPath = externalContext.getRequestServletPath();
-                resourceName = requestServletPath.substring(0,
-                        requestServletPath.length() - facesMapping.length());
+
+                resourceName = requestServletPath.substring(0, requestServletPath.length() - facesMapping.length());
             }
         }
 
@@ -345,7 +369,7 @@
         ReadableByteChannel inChannel = Channels.newChannel(is);
         WritableByteChannel outChannel = Channels.newChannel(os);
 
-        //TODO make this configurable
+        // TODO make this configurable
         ByteBuffer buffer = ByteBuffer.allocate(8192);
         int read;
 

Modified: root/framework/trunk/impl/src/main/java/org/richfaces/util/package-info.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/util/package-info.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/util/package-info.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,3 +1,4 @@
+
 /**
  * Utility classes
  */

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/BaseCacheTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/BaseCacheTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/BaseCacheTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.ajax4jsf.cache;
 
 import java.util.Date;
@@ -26,79 +28,72 @@
 
 import org.richfaces.test.AbstractFacesTest;
 
-
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public abstract class BaseCacheTest extends AbstractFacesTest {
+    private Cache cache;
+    private String cacheManagerFactoryClassName;
 
-	private String cacheManagerFactoryClassName;
-	
-	private Cache cache;
-	
-	public BaseCacheTest(String cacheManagerFactoryClassName) {
-		super();
-		this.cacheManagerFactoryClassName = cacheManagerFactoryClassName;
-	}
+    public BaseCacheTest(String cacheManagerFactoryClassName) {
+        super();
+        this.cacheManagerFactoryClassName = cacheManagerFactoryClassName;
+    }
 
-	@Override
-	protected void setupJsfInitParameters() {
-		super.setupJsfInitParameters();
-	
-		this.facesServer.addInitParameter(CacheManager.CACHE_MANAGER_FACTORY_CLASS, 
-			cacheManagerFactoryClassName);
-	}
-	
-	@Override
-	public void setUp() throws Exception {
-		super.setUp();
+    @Override
+    protected void setupJsfInitParameters() {
+        super.setupJsfInitParameters();
+        this.facesServer.addInitParameter(CacheManager.CACHE_MANAGER_FACTORY_CLASS, cacheManagerFactoryClassName);
+    }
 
-		setupFacesRequest();
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        setupFacesRequest();
 
-		CacheManager cacheManager = CacheManager.getInstance();
-		Map<?, ?> initParameterMap = facesContext.getExternalContext().getInitParameterMap();
-		this.cache = cacheManager.getCacheFactory(initParameterMap).createCache(initParameterMap);
-		this.cache.start();
-	}
-	
-	@Override
-	public void tearDown() throws Exception {
-		super.tearDown();
+        CacheManager cacheManager = CacheManager.getInstance();
+        Map<?, ?> initParameterMap = facesContext.getExternalContext().getInitParameterMap();
 
-		if (this.cache != null) {
-			this.cache.stop();
-			this.cache = null;
-		}
-	}
-	
-	public void testBasic() throws Exception {
-		assertNull(cache.get("a"));
-		cache.put("a", "value-a", null);
-		assertEquals("value-a", cache.get("a"));
-	}
-	
-	public void testExpiration() throws Exception {
-		assertNull(cache.get("a"));
+        this.cache = cacheManager.getCacheFactory(initParameterMap).createCache(initParameterMap);
+        this.cache.start();
+    }
 
-		long sleepTime = 0;
-		long expirationTime = System.currentTimeMillis() + 3000;
-		
-		cache.put("a", "value-a", new Date(expirationTime));
-		assertEquals("value-a", cache.get("a"));
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
 
-		//interval to reach 1 second before expiration time
-		sleepTime = expirationTime - 1000 - System.currentTimeMillis();
-		assertTrue(sleepTime > 0);
-		Thread.sleep(sleepTime);
+        if (this.cache != null) {
+            this.cache.stop();
+            this.cache = null;
+        }
+    }
 
-		assertEquals("value-a", cache.get("a"));
+    public void testBasic() throws Exception {
+        assertNull(cache.get("a"));
+        cache.put("a", "value-a", null);
+        assertEquals("value-a", cache.get("a"));
+    }
 
-		//interval to reach 1 second after expiration time
-		sleepTime = expirationTime + 1000 - System.currentTimeMillis();
-		assertTrue(sleepTime > 0);
+    public void testExpiration() throws Exception {
+        assertNull(cache.get("a"));
 
-		Thread.sleep(sleepTime);
-		assertNull(cache.get("a"));
-	}
+        long sleepTime = 0;
+        long expirationTime = System.currentTimeMillis() + 3000;
+
+        cache.put("a", "value-a", new Date(expirationTime));
+        assertEquals("value-a", cache.get("a"));
+
+        // interval to reach 1 second before expiration time
+        sleepTime = expirationTime - 1000 - System.currentTimeMillis();
+        assertTrue(sleepTime > 0);
+        Thread.sleep(sleepTime);
+        assertEquals("value-a", cache.get("a"));
+
+        // interval to reach 1 second after expiration time
+        sleepTime = expirationTime + 1000 - System.currentTimeMillis();
+        assertTrue(sleepTime > 0);
+        Thread.sleep(sleepTime);
+        assertNull(cache.get("a"));
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/EhCacheTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/EhCacheTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/EhCacheTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,19 +19,16 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
-package org.ajax4jsf.cache;
 
 
+package org.ajax4jsf.cache;
 
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public class EhCacheTest extends BaseCacheTest {
-
-	public EhCacheTest() {
-		super(EhCacheCacheFactory.class.getName());
-	}
-
-	
+    public EhCacheTest() {
+        super(EhCacheCacheFactory.class.getName());
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/JBossCacheTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/JBossCacheTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/JBossCacheTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,19 +19,16 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
-package org.ajax4jsf.cache;
 
 
+package org.ajax4jsf.cache;
 
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public class JBossCacheTest extends BaseCacheTest {
-
-	public JBossCacheTest() {
-		super(JBossCacheCacheFactory.class.getName());
-	}
-
-	
+    public JBossCacheTest() {
+        super(JBossCacheCacheFactory.class.getName());
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/LRUMapCacheTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/LRUMapCacheTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/LRUMapCacheTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.ajax4jsf.cache;
 
 import java.util.Date;
@@ -28,186 +30,176 @@
 import org.ajax4jsf.cache.lru.CacheMap;
 import org.ajax4jsf.cache.lru.LRUMapCache;
 import org.ajax4jsf.cache.lru.CacheEntry;
+
 import org.junit.Assert;
 import org.junit.Test;
 
-
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public class LRUMapCacheTest {
+    @Test
+    public void testBasic() throws Exception {
+        LRUMapCache cache = new LRUMapCache();
 
-	@Test
-	public void testBasic() throws Exception {
-		LRUMapCache cache = new LRUMapCache();
-		cache.start();
-		
-		Assert.assertNull(cache.get("key"));
-		cache.put("key", "value", null);
-		Assert.assertEquals("value", cache.get("key"));
+        cache.start();
+        Assert.assertNull(cache.get("key"));
+        cache.put("key", "value", null);
+        Assert.assertEquals("value", cache.get("key"));
+        cache.stop();
+    }
 
-		cache.stop();
-	}
-	
-	@Test
-	public void testLRUEviction() throws Exception {
-		LRUMapCache cache = new LRUMapCache(3);
-		cache.start();
+    @Test
+    public void testLRUEviction() throws Exception {
+        LRUMapCache cache = new LRUMapCache(3);
 
-		cache.put("key1", "value1", null);
-		cache.put("key2", "value2", null);
-		cache.put("key3", "value3", null);
-		
-		Assert.assertEquals("value1", cache.get("key1"));
-		Assert.assertEquals("value2", cache.get("key2"));
-		Assert.assertEquals("value3", cache.get("key3"));
-		
-		cache.get("key1");
-		cache.get("key3");
+        cache.start();
+        cache.put("key1", "value1", null);
+        cache.put("key2", "value2", null);
+        cache.put("key3", "value3", null);
+        Assert.assertEquals("value1", cache.get("key1"));
+        Assert.assertEquals("value2", cache.get("key2"));
+        Assert.assertEquals("value3", cache.get("key3"));
+        cache.get("key1");
+        cache.get("key3");
+        cache.put("key4", "value4", null);
+        Assert.assertEquals("value1", cache.get("key1"));
+        Assert.assertNull(cache.get("key2"));
+        Assert.assertEquals("value3", cache.get("key3"));
+        Assert.assertEquals("value4", cache.get("key4"));
+        cache.stop();
+    }
 
-		cache.put("key4", "value4", null);
+    @Test
+    public void testCacheMap() throws Exception {
+        CacheMap cacheMap = new CacheMap();
 
-		Assert.assertEquals("value1", cache.get("key1"));
-		Assert.assertNull(cache.get("key2"));
-		Assert.assertEquals("value3", cache.get("key3"));
-		Assert.assertEquals("value4", cache.get("key4"));
+        Assert.assertTrue(cacheMap.getExpirationQueue().isEmpty());
 
-		cache.stop();
-	}
+        CacheEntry cacheEntry = new CacheEntry("key", "value", new Date(System.currentTimeMillis() + 1000));
 
-	@Test
-	public void testCacheMap() throws Exception {
-		CacheMap cacheMap = new CacheMap();
-		Assert.assertTrue(cacheMap.getExpirationQueue().isEmpty());
-		
-		CacheEntry cacheEntry = new CacheEntry("key", "value", new Date(System.currentTimeMillis() + 1000));
-		cacheMap.put("key", cacheEntry);
-	
-		Assert.assertNotNull(cacheMap.get("key"));
-		Assert.assertSame(cacheEntry, cacheMap.get("key"));
-		Assert.assertFalse(cacheMap.getExpirationQueue().isEmpty());
-		
-		cacheMap.clear();
-		Assert.assertTrue(cacheMap.getExpirationQueue().isEmpty());
+        cacheMap.put("key", cacheEntry);
+        Assert.assertNotNull(cacheMap.get("key"));
+        Assert.assertSame(cacheEntry, cacheMap.get("key"));
+        Assert.assertFalse(cacheMap.getExpirationQueue().isEmpty());
+        cacheMap.clear();
+        Assert.assertTrue(cacheMap.getExpirationQueue().isEmpty());
+        cacheMap.put("key2", new CacheEntry("key2", "value2", new Date(System.currentTimeMillis() + 1000)));
+        Assert.assertNotNull(cacheMap.get("key2"));
+        cacheMap.remove("key2");
+        Assert.assertTrue(cacheMap.getExpirationQueue().isEmpty());
+    }
 
-		cacheMap.put("key2", new CacheEntry("key2", "value2", new Date(System.currentTimeMillis() + 1000)));
-		Assert.assertNotNull(cacheMap.get("key2"));
-		cacheMap.remove("key2");
-		Assert.assertTrue(cacheMap.getExpirationQueue().isEmpty());
-	}
+    @Test
+    public void testExpiration() throws Exception {
 
-	@Test
-	public void testExpiration() throws Exception {
-		//this test uses Thread.sleep, so may fail if debugged
-		
-		LRUMapCache cache = new LRUMapCache();
-		cache.start();
-		
-		long baseTime = System.currentTimeMillis();
-		cache.put("key", "value", new Date(baseTime + 2000));
-		cache.put("key2", "value2", new Date(baseTime + 3000));
-		cache.put("key3", "value3", new Date(baseTime + 1000));
-		cache.put("key4", "value4", new Date(baseTime + 1000));
-		
-		Assert.assertEquals("value", cache.get("key"));
-		Assert.assertEquals("value2", cache.get("key2"));
-		Assert.assertEquals("value3", cache.get("key3"));
-		Assert.assertEquals("value4", cache.get("key4"));
+        // this test uses Thread.sleep, so may fail if debugged
+        LRUMapCache cache = new LRUMapCache();
 
-		//prolong key4
-		cache.put("key4", "new value", new Date(baseTime + 2000));
-		
-		Thread.sleep(1500);
+        cache.start();
 
-		Assert.assertEquals("value", cache.get("key"));
-		Assert.assertEquals("value2", cache.get("key2"));
-		Assert.assertNull(cache.get("key3"));
-		Assert.assertEquals("new value", cache.get("key4"));
-		
-		Thread.sleep(1000);
+        long baseTime = System.currentTimeMillis();
 
-		Assert.assertNull(cache.get("key"));
-		Assert.assertEquals("value2", cache.get("key2"));
-		Assert.assertNull(cache.get("key3"));
-		Assert.assertNull(cache.get("key4"));
+        cache.put("key", "value", new Date(baseTime + 2000));
+        cache.put("key2", "value2", new Date(baseTime + 3000));
+        cache.put("key3", "value3", new Date(baseTime + 1000));
+        cache.put("key4", "value4", new Date(baseTime + 1000));
+        Assert.assertEquals("value", cache.get("key"));
+        Assert.assertEquals("value2", cache.get("key2"));
+        Assert.assertEquals("value3", cache.get("key3"));
+        Assert.assertEquals("value4", cache.get("key4"));
 
-		Thread.sleep(1000);
+        // prolong key4
+        cache.put("key4", "new value", new Date(baseTime + 2000));
+        Thread.sleep(1500);
+        Assert.assertEquals("value", cache.get("key"));
+        Assert.assertEquals("value2", cache.get("key2"));
+        Assert.assertNull(cache.get("key3"));
+        Assert.assertEquals("new value", cache.get("key4"));
+        Thread.sleep(1000);
+        Assert.assertNull(cache.get("key"));
+        Assert.assertEquals("value2", cache.get("key2"));
+        Assert.assertNull(cache.get("key3"));
+        Assert.assertNull(cache.get("key4"));
+        Thread.sleep(1000);
+        Assert.assertNull(cache.get("key"));
+        Assert.assertNull(cache.get("key2"));
+        Assert.assertNull(cache.get("key3"));
+        cache.stop();
+    }
 
-		Assert.assertNull(cache.get("key"));
-		Assert.assertNull(cache.get("key2"));
-		Assert.assertNull(cache.get("key3"));
+    @Test
+    public void testThreads() throws Exception {
+        final AtomicBoolean failure = new AtomicBoolean();
+        final LRUMapCache cache = new LRUMapCache();
 
-		cache.stop();
-	}
-	
-	@Test
-	public void testThreads() throws Exception {
-		final AtomicBoolean failure = new AtomicBoolean();
-		
-		final LRUMapCache cache = new LRUMapCache();
-		cache.start();
+        cache.start();
 
-		Thread[] writerThreads = new Thread[10];
-		
-		for (int i = 0; i < writerThreads.length; i++) {
-			writerThreads[i] = new Thread() {
-				public void run() {
-					final String key = UUID.randomUUID().toString();
-					final String value = UUID.randomUUID().toString();
+        Thread[] writerThreads = new Thread[10];
 
-					cache.put(key, value, null);
-					
-					Thread[] threads = new Thread[25];
-					for (int j = 0; j < threads.length; j++) {
-						threads[j] = new Thread() {
-							@Override
-							public void run() {
-								int retries = 1000;
-							
-								for (int k = 0; k < retries; k++) {
-									if (!value.equals(cache.get(key))) {
-										failure.set(true);
-										return ;
-									}
-								}
-							}
-						};
-					}
+        for (int i = 0; i < writerThreads.length; i++) {
+            writerThreads[i] = new Thread() {
+                public void run() {
+                    final String key = UUID.randomUUID().toString();
+                    final String value = UUID.randomUUID().toString();
 
-					for (Thread thread : threads) {
-						thread.start();
-					}
-					int retries = 1000;
-					
-					for (int k = 0; k < retries; k++) {
-						if (!value.equals(cache.get(key))) {
-							failure.set(true);
-						}
-					}
+                    cache.put(key, value, null);
 
-					for (Thread thread : threads) {
-						try {
-							thread.join();
-						} catch (InterruptedException e) {
-							// TODO Auto-generated catch block
-							failure.set(true);
-						}
-					}
-				};
-			};
-		}
-		
-		for (Thread thread : writerThreads) {
-			thread.start();
-		}
-		
-		for (Thread thread : writerThreads) {
-			thread.join();
-		}
+                    Thread[] threads = new Thread[25];
 
-		Assert.assertFalse(failure.get());
-		
-		cache.stop();
-	}
+                    for (int j = 0; j < threads.length; j++) {
+                        threads[j] = new Thread() {
+                            @Override
+                            public void run() {
+                                int retries = 1000;
+
+                                for (int k = 0; k < retries; k++) {
+                                    if (!value.equals(cache.get(key))) {
+                                        failure.set(true);
+
+                                        return;
+                                    }
+                                }
+                            }
+                        };
+                    }
+
+                    for (Thread thread : threads) {
+                        thread.start();
+                    }
+
+                    int retries = 1000;
+
+                    for (int k = 0; k < retries; k++) {
+                        if (!value.equals(cache.get(key))) {
+                            failure.set(true);
+                        }
+                    }
+
+                    for (Thread thread : threads) {
+                        try {
+                            thread.join();
+                        } catch (InterruptedException e) {
+
+                            // TODO Auto-generated catch block
+                            failure.set(true);
+                        }
+                    }
+                }
+                ;
+            };
+        }
+
+        for (Thread thread : writerThreads) {
+            thread.start();
+        }
+
+        for (Thread thread : writerThreads) {
+            thread.join();
+        }
+
+        Assert.assertFalse(failure.get());
+        cache.stop();
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/OsCacheTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/OsCacheTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/OsCacheTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,19 +19,16 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
-package org.ajax4jsf.cache;
 
 
+package org.ajax4jsf.cache;
 
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public class OsCacheTest extends BaseCacheTest {
-
-	public OsCacheTest() {
-		super(OSCacheCacheFactory.class.getName());
-	}
-
-	
+    public OsCacheTest() {
+        super(OSCacheCacheFactory.class.getName());
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/codec/CodecTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/codec/CodecTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/codec/CodecTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,63 +19,73 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.ajax4jsf.codec;
 
 import org.ajax4jsf.util.base64.Codec;
+
 import org.richfaces.test.AbstractThreadedTest;
 
 public class CodecTest extends AbstractThreadedTest {
-	Codec c;
+    Codec c;
 
-	public void setUp() throws Exception {
-		super.setUp();
-		String message = "";
-		try {
-			c = new Codec("anbshsquycwuudyft");
-		} catch (Exception e) {
-			message = "Cannot create Codec instance " + e.getMessage();
-		}
-		assertNotNull(message, c);
-	}
+    public void setUp() throws Exception {
+        super.setUp();
 
-	public void tearDown() throws Exception {
-		super.tearDown();
-	}
+        String message = "";
 
-	public void testCodec() {
-		CodecTestRunnable[] runnables = new CodecTestRunnable[100];
-		for (int i = 0; i < runnables.length; i++) {
-			runnables[i] = new CodecTestRunnable(c, generateRandomString(), i);
-		}
-		runTestCaseRunnables(runnables);
-	}
-	
-	private String generateRandomString() {
-		StringBuffer ss = new StringBuffer();
-		for (int i = 0; i < 50000; i++) {
-			char c = (char)(96 + Math.random() * 26);
-			ss.append(c);
-		}
-		return ss.toString();
-	}
-	
-	class CodecTestRunnable extends TestCaseRunnable {
-		Codec c;
-		String s;
-		int id;
-		
-		public CodecTestRunnable(Codec c, String s, int id) {
-			this.c = c;
-			this.s = s;
-			this.id = id;
-		}
+        try {
+            c = new Codec("anbshsquycwuudyft");
+        } catch (Exception e) {
+            message = "Cannot create Codec instance " + e.getMessage();
+        }
 
-		public void runTestCase() throws Throwable {
-			String s1 = c.encode(s);
-			String s2 = c.decode(s1);
-			assertEquals("Failure in thread " + id, s2, s);
-		}
-		
-	}
+        assertNotNull(message, c);
+    }
 
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testCodec() {
+        CodecTestRunnable[] runnables = new CodecTestRunnable[100];
+
+        for (int i = 0; i < runnables.length; i++) {
+            runnables[i] = new CodecTestRunnable(c, generateRandomString(), i);
+        }
+
+        runTestCaseRunnables(runnables);
+    }
+
+    private String generateRandomString() {
+        StringBuffer ss = new StringBuffer();
+
+        for (int i = 0; i < 50000; i++) {
+            char c = (char) (96 + Math.random() * 26);
+
+            ss.append(c);
+        }
+
+        return ss.toString();
+    }
+
+    class CodecTestRunnable extends TestCaseRunnable {
+        Codec c;
+        int id;
+        String s;
+
+        public CodecTestRunnable(Codec c, String s, int id) {
+            this.c = c;
+            this.s = s;
+            this.id = id;
+        }
+
+        public void runTestCase() throws Throwable {
+            String s1 = c.encode(s);
+            String s2 = c.decode(s1);
+
+            assertEquals("Failure in thread " + id, s2, s);
+        }
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/FacesConfigTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/FacesConfigTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/FacesConfigTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,15 +18,21 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.ajax4jsf.config;
 
 import java.io.IOException;
 import java.io.InputStream;
+
 import java.net.URL;
+
 import java.util.Enumeration;
 import java.util.Vector;
 
 import javax.faces.webapp.FacesServlet;
+
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 
@@ -40,144 +46,154 @@
  */
 public class FacesConfigTest extends TestCase {
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#setUp()
-	 */
-	protected void setUp() throws Exception {
-		super.setUp();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-	/**
-	 * Test method for {@link org.jboss.portletbridge.util.FacesConfig#parse(javax.portlet.PortletContext)}.
-	 */
-	public void testParsePortletContext() {
-		FacesConfig config = new FacesConfig();
-		MockServletContext context = new MockServletContext(){
-			@Override
-			public InputStream getResourceAsStream(String path) {
-				return this.getClass().getResourceAsStream(path);
-			}
-			
-			@Override
-			public String getInitParameter(String name) {
-				if(FacesServlet.CONFIG_FILES_ATTR.equals(name)){
-					return "/WEB-INF/a-faces-config.xml ,/WEB-INF/b-faces-config.xml";
-				}
-				return super.getInitParameter(name);
-			}
-		};
-		config.parse(context);
-		assertEquals(6, config.getExcludedAttributes().size());
-	}
+    /**
+     * Test method for {@link org.jboss.portletbridge.util.FacesConfig#parse(javax.portlet.PortletContext)}.
+     */
+    public void testParsePortletContext() {
+        FacesConfig config = new FacesConfig();
+        MockServletContext context = new MockServletContext() {
+            @Override
+            public InputStream getResourceAsStream(String path) {
+                return this.getClass().getResourceAsStream(path);
+            }
+            @Override
+            public String getInitParameter(String name) {
+                if (FacesServlet.CONFIG_FILES_ATTR.equals(name)) {
+                    return "/WEB-INF/a-faces-config.xml ,/WEB-INF/b-faces-config.xml";
+                }
 
-	/**
-	 * Test method for {@link org.jboss.portletbridge.util.FacesConfig#parseDefault(javax.portlet.PortletContext)}.
-	 */
-	public void testParseDefault() throws Exception {
-		FacesConfig config = new FacesConfig();
-		MockServletContext context = new MockServletContext(){
-			@Override
-			public InputStream getResourceAsStream(String path) {
-				return this.getClass().getResourceAsStream(path);
-			}
-			
-			@Override
-			public String getInitParameter(String name) {
-				if(FacesServlet.CONFIG_FILES_ATTR.equals(name)){
-					return "/WEB-INF/a-faces-config.xml ,/WEB-INF/b-faces-config.xml";
-				}
-				return super.getInitParameter(name);
-			}
-		};
-		config.parseDefault(context);
-		assertEquals(2, config.getExcludedAttributes().size());
-	}
+                return super.getInitParameter(name);
+            }
+        };
 
-	/**
-	 * Test method for {@link org.jboss.portletbridge.util.FacesConfig#parseOptional(javax.portlet.PortletContext)}.
-	 */
-	public void testParseOptional() throws Exception {
-		FacesConfig config = new FacesConfig();
-		MockServletContext context = new MockServletContext(){
-			@Override
-			public InputStream getResourceAsStream(String path) {
-				return this.getClass().getResourceAsStream(path);
-			}
-			
-			@Override
-			public String getInitParameter(String name) {
-				if(FacesServlet.CONFIG_FILES_ATTR.equals(name)){
-					return "/WEB-INF/a-faces-config.xml ,/WEB-INF/b-faces-config.xml";
-				}
-				return super.getInitParameter(name);
-			}
-		};
-		config.parseOptional(context);
-		assertEquals(4, config.getExcludedAttributes().size());
-	}
+        config.parse(context);
+        assertEquals(6, config.getExcludedAttributes().size());
+    }
 
-	/**
-	 * Test method for {@link org.jboss.portletbridge.util.FacesConfig#parseClasspath(javax.portlet.PortletContext)}.
-	 * @throws Exception 
-	 */
-	public void testParseClasspath() throws Exception {
-		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-		try{
-		ClassLoader classLoader = this.getClass().getClassLoader();
-		ClassLoader classLoaderWrapper = new ClassLoader(classLoader){
-			
-			@Override
-			public Enumeration<URL> getResources(String name)
-					throws IOException {
-				if("META-INF/faces-config.xml".equals(name)){
-					Vector<URL> configs = new Vector<URL>(2);
-					configs.add(getResource("WEB-INF/a-faces-config.xml"));
-					configs.add(getResource("WEB-INF/b-faces-config.xml"));
-					return configs.elements();
-				}
-				return super.getResources(name);
-			}
-		};
-		Thread.currentThread().setContextClassLoader(classLoaderWrapper);
-		FacesConfig config = new FacesConfig();
-		MockServletContext context = new MockServletContext();
-		config.parseClasspath(context);
-		assertEquals(4, config.getExcludedAttributes().size());
-		} finally {
-			Thread.currentThread().setContextClassLoader(contextClassLoader);
-		}
-		
-	}
+    /**
+     * Test method for {@link org.jboss.portletbridge.util.FacesConfig#parseDefault(javax.portlet.PortletContext)}.
+     */
+    public void testParseDefault() throws Exception {
+        FacesConfig config = new FacesConfig();
+        MockServletContext context = new MockServletContext() {
+            @Override
+            public InputStream getResourceAsStream(String path) {
+                return this.getClass().getResourceAsStream(path);
+            }
+            @Override
+            public String getInitParameter(String name) {
+                if (FacesServlet.CONFIG_FILES_ATTR.equals(name)) {
+                    return "/WEB-INF/a-faces-config.xml ,/WEB-INF/b-faces-config.xml";
+                }
 
-	/**
-	 * Test method for {@link org.jboss.portletbridge.util.FacesConfig#parse(java.io.InputStream)}.
-	 * @throws ParsingException 
-	 */
-	public void testParseInputStream() throws Exception {
-		InputStream facesConfigResource = this.getClass().getResourceAsStream("/WEB-INF/faces-config.xml");
-		FacesConfig config = new FacesConfig();
-		config.parse(facesConfigResource);
-		assertEquals(2, config.getExcludedAttributes().size());
-		assertTrue(config.getExcludedAttributes().contains("foo.bar"));
-		assertTrue(config.getExcludedAttributes().contains("foo.baz.*"));
-	}
+                return super.getInitParameter(name);
+            }
+        };
 
-	/**
-	 * Test method for {@link org.jboss.portletbridge.util.FacesConfig#getParser()}.
-	 * @throws SAXException 
-	 * @throws ParserConfigurationException 
-	 */
-	public void testGetParser() throws Exception {
-		FacesConfig config = new FacesConfig();
-		SAXParser parser = config.getParser();
-		assertNotSame(parser, config.getParser());
-	}
+        config.parseDefault(context);
+        assertEquals(2, config.getExcludedAttributes().size());
+    }
 
+    /**
+     * Test method for {@link org.jboss.portletbridge.util.FacesConfig#parseOptional(javax.portlet.PortletContext)}.
+     */
+    public void testParseOptional() throws Exception {
+        FacesConfig config = new FacesConfig();
+        MockServletContext context = new MockServletContext() {
+            @Override
+            public InputStream getResourceAsStream(String path) {
+                return this.getClass().getResourceAsStream(path);
+            }
+            @Override
+            public String getInitParameter(String name) {
+                if (FacesServlet.CONFIG_FILES_ATTR.equals(name)) {
+                    return "/WEB-INF/a-faces-config.xml ,/WEB-INF/b-faces-config.xml";
+                }
+
+                return super.getInitParameter(name);
+            }
+        };
+
+        config.parseOptional(context);
+        assertEquals(4, config.getExcludedAttributes().size());
+    }
+
+    /**
+     * Test method for {@link org.jboss.portletbridge.util.FacesConfig#parseClasspath(javax.portlet.PortletContext)}.
+     * @throws Exception
+     */
+    public void testParseClasspath() throws Exception {
+        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+
+        try {
+            ClassLoader classLoader = this.getClass().getClassLoader();
+            ClassLoader classLoaderWrapper = new ClassLoader(classLoader) {
+                @Override
+                public Enumeration<URL> getResources(String name) throws IOException {
+                    if ("META-INF/faces-config.xml".equals(name)) {
+                        Vector<URL> configs = new Vector<URL>(2);
+
+                        configs.add(getResource("WEB-INF/a-faces-config.xml"));
+                        configs.add(getResource("WEB-INF/b-faces-config.xml"));
+
+                        return configs.elements();
+                    }
+
+                    return super.getResources(name);
+                }
+            };
+
+            Thread.currentThread().setContextClassLoader(classLoaderWrapper);
+
+            FacesConfig config = new FacesConfig();
+            MockServletContext context = new MockServletContext();
+
+            config.parseClasspath(context);
+            assertEquals(4, config.getExcludedAttributes().size());
+        } finally {
+            Thread.currentThread().setContextClassLoader(contextClassLoader);
+        }
+    }
+
+    /**
+     * Test method for {@link org.jboss.portletbridge.util.FacesConfig#parse(java.io.InputStream)}.
+     * @throws ParsingException
+     */
+    public void testParseInputStream() throws Exception {
+        InputStream facesConfigResource = this.getClass().getResourceAsStream("/WEB-INF/faces-config.xml");
+        FacesConfig config = new FacesConfig();
+
+        config.parse(facesConfigResource);
+        assertEquals(2, config.getExcludedAttributes().size());
+        assertTrue(config.getExcludedAttributes().contains("foo.bar"));
+        assertTrue(config.getExcludedAttributes().contains("foo.baz.*"));
+    }
+
+    /**
+     * Test method for {@link org.jboss.portletbridge.util.FacesConfig#getParser()}.
+     * @throws SAXException
+     * @throws ParserConfigurationException
+     */
+    public void testGetParser() throws Exception {
+        FacesConfig config = new FacesConfig();
+        SAXParser parser = config.getParser();
+
+        assertNotSame(parser, config.getParser());
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/FrameworkConfigurationTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/FrameworkConfigurationTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/FrameworkConfigurationTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -6,108 +6,107 @@
 import javax.faces.context.ExternalContext;
 
 import org.ajax4jsf.config.FrameworkConfiguration.InitParam;
+
 import org.richfaces.test.AbstractFacesTest;
 
 /**
  * @author Anton Belevich
  *
  */
-public class FrameworkConfigurationTest extends AbstractFacesTest{
-	
-	private MockInitializationBean mockBean;
-	
-	private FrameworkConfiguration configuration;
+public class FrameworkConfigurationTest extends AbstractFacesTest {
+    private FrameworkConfiguration configuration;
+    Map<String, String> localInitParams;
+    private MockInitializationBean mockBean;
+    Map<String, String> refenceInitParams;
 
-	Map <String, String> localInitParams;
-	
-	Map <String, String> refenceInitParams;
-	
-	
-	public class MockInitializationBean {
-		
-		private String styleStrategy = "ALL";
-		private boolean encryptResourceData = true;
-	
-		
-		public boolean getEncryptResourceData() {
-			return encryptResourceData;
-		}
-		
-		public void setEncryptResourceData(boolean encryptResourceData) {
-			this.encryptResourceData = encryptResourceData;
-		}
-		
-		public String getStyleStrategy() {
-			return styleStrategy;
-		}
-		
-		public void setStyleStrategy(String styleStrategy) {
-			this.styleStrategy = styleStrategy;
-		}
-		
-	}
-	
-	public void testBooleanOption() {
-		boolean actual = configuration.isOptionEnabled(InitParam.COMPRESS_SCRIPT);
-		boolean expected = Boolean.parseBoolean(localInitParams.get(InitParam.COMPRESS_SCRIPT.name())); 
-		assertEquals(expected, actual);
-	}
-	
-	public void testBooleanOptionValueReference() {
-		boolean actual = configuration.isOptionEnabled(InitParam.ENCRYPT_RESOURCE_DATA);
-		boolean expected = mockBean.getEncryptResourceData(); 
-		assertEquals(expected, actual);
-	}
-	
-	public void testNumberOption (){
-		int actual = configuration.getOptionNumber(InitParam.DEFAULT_EXPIRE);
-		int expected = Integer.parseInt(localInitParams.get(InitParam.DEFAULT_EXPIRE.name()));
-		assertEquals(expected, actual);	
-	}
-	
-	public void testStringOption() {
-		String  actual =  configuration.getOption(InitParam.SKIN);
-		String expected = (String)localInitParams.get(InitParam.SKIN.name());
-		assertEquals(expected, actual);
-	}
-	
-	public void testStringOptionValueReference() {
-		String actual = configuration.getOptionValue(InitParam.LoadStyleStrategy);
-		String expected = mockBean.getStyleStrategy();
-		assertEquals(expected, actual);
-	}
- 	
-	@Override
-	public void setUp() throws Exception {
-		super.setUp();
-		mockBean = new MockInitializationBean();
-		setupFacesRequest();
-		ExternalContext externalContext = facesContext.getExternalContext();
-		configuration = FrameworkConfiguration.getInstance(externalContext);
-		facesContext.getExternalContext().getRequestMap().put("mockBean", mockBean);
-	}
+    public void testBooleanOption() {
+        boolean actual = configuration.isOptionEnabled(InitParam.COMPRESS_SCRIPT);
+        boolean expected = Boolean.parseBoolean(localInitParams.get(InitParam.COMPRESS_SCRIPT.name()));
 
-	@Override
-	protected void setupJsfInitParameters() {
-		super.setupJsfInitParameters();
-		localInitParams = new HashMap<String, String>();
-		
-		localInitParams.put(InitParam.SKIN.name(), "blueSky");
-		localInitParams.put(InitParam.COMPRESS_SCRIPT.name(), "false");
-		localInitParams.put(InitParam.DEFAULT_EXPIRE.name(), "8500");
-		
-		facesServer.addInitParameter(FrameworkConfiguration.InitParam.SKIN.getQualifiedName(), "blueSky");
-		facesServer.addInitParameter(FrameworkConfiguration.InitParam.LoadScriptStrategy.getQualifiedName(), "ALL");
-		facesServer.addInitParameter(FrameworkConfiguration.InitParam.COMPRESS_SCRIPT.getQualifiedName(), "false");
-		facesServer.addInitParameter(FrameworkConfiguration.InitParam.DEFAULT_EXPIRE.getQualifiedName(), "8500");
-		facesServer.addInitParameter(FrameworkConfiguration.InitParam.ENCRYPT_RESOURCE_DATA.getQualifiedName(), "#{mockBean.encryptResourceData}");
-		facesServer.addInitParameter(FrameworkConfiguration.InitParam.LoadStyleStrategy.getQualifiedName(), "#{mockBean.styleStrategy}");
-	}
-	
-	@Override
-	public void tearDown() throws Exception {
-		super.tearDown();
-		mockBean = null;
-	}
-	
+        assertEquals(expected, actual);
+    }
+
+    public void testBooleanOptionValueReference() {
+        boolean actual = configuration.isOptionEnabled(InitParam.ENCRYPT_RESOURCE_DATA);
+        boolean expected = mockBean.getEncryptResourceData();
+
+        assertEquals(expected, actual);
+    }
+
+    public void testNumberOption() {
+        int actual = configuration.getOptionNumber(InitParam.DEFAULT_EXPIRE);
+        int expected = Integer.parseInt(localInitParams.get(InitParam.DEFAULT_EXPIRE.name()));
+
+        assertEquals(expected, actual);
+    }
+
+    public void testStringOption() {
+        String actual = configuration.getOption(InitParam.SKIN);
+        String expected = (String) localInitParams.get(InitParam.SKIN.name());
+
+        assertEquals(expected, actual);
+    }
+
+    public void testStringOptionValueReference() {
+        String actual = configuration.getOptionValue(InitParam.LoadStyleStrategy);
+        String expected = mockBean.getStyleStrategy();
+
+        assertEquals(expected, actual);
+    }
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        mockBean = new MockInitializationBean();
+        setupFacesRequest();
+
+        ExternalContext externalContext = facesContext.getExternalContext();
+
+        configuration = FrameworkConfiguration.getInstance(externalContext);
+        facesContext.getExternalContext().getRequestMap().put("mockBean", mockBean);
+    }
+
+    @Override
+    protected void setupJsfInitParameters() {
+        super.setupJsfInitParameters();
+        localInitParams = new HashMap<String, String>();
+        localInitParams.put(InitParam.SKIN.name(), "blueSky");
+        localInitParams.put(InitParam.COMPRESS_SCRIPT.name(), "false");
+        localInitParams.put(InitParam.DEFAULT_EXPIRE.name(), "8500");
+        facesServer.addInitParameter(FrameworkConfiguration.InitParam.SKIN.getQualifiedName(), "blueSky");
+        facesServer.addInitParameter(FrameworkConfiguration.InitParam.LoadScriptStrategy.getQualifiedName(), "ALL");
+        facesServer.addInitParameter(FrameworkConfiguration.InitParam.COMPRESS_SCRIPT.getQualifiedName(), "false");
+        facesServer.addInitParameter(FrameworkConfiguration.InitParam.DEFAULT_EXPIRE.getQualifiedName(), "8500");
+        facesServer.addInitParameter(FrameworkConfiguration.InitParam.ENCRYPT_RESOURCE_DATA.getQualifiedName(),
+                                     "#{mockBean.encryptResourceData}");
+        facesServer.addInitParameter(FrameworkConfiguration.InitParam.LoadStyleStrategy.getQualifiedName(),
+                                     "#{mockBean.styleStrategy}");
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+        mockBean = null;
+    }
+
+    public class MockInitializationBean {
+        private String styleStrategy = "ALL";
+        private boolean encryptResourceData = true;
+
+        public boolean getEncryptResourceData() {
+            return encryptResourceData;
+        }
+
+        public void setEncryptResourceData(boolean encryptResourceData) {
+            this.encryptResourceData = encryptResourceData;
+        }
+
+        public String getStyleStrategy() {
+            return styleStrategy;
+        }
+
+        public void setStyleStrategy(String styleStrategy) {
+            this.styleStrategy = styleStrategy;
+        }
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/MockServletContext.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/MockServletContext.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/MockServletContext.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,11 +18,16 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.ajax4jsf.config;
 
 import java.io.InputStream;
+
 import java.net.MalformedURLException;
 import java.net.URL;
+
 import java.util.Enumeration;
 import java.util.Set;
 
@@ -37,203 +42,246 @@
  */
 public class MockServletContext implements ServletContext {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getAttribute(java.lang.String)
-	 */
-	public Object getAttribute(String name) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name) {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getAttributeNames()
-	 */
-	public Enumeration getAttributeNames() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getContext(java.lang.String)
-	 */
-	public ServletContext getContext(String uripath) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getAttributeNames()
+     */
+    public Enumeration getAttributeNames() {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getContextPath()
-	 */
-	public String getContextPath() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getInitParameter(java.lang.String)
-	 */
-	public String getInitParameter(String name) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getContext(java.lang.String)
+     */
+    public ServletContext getContext(String uripath) {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getInitParameterNames()
-	 */
-	public Enumeration getInitParameterNames() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getMajorVersion()
-	 */
-	public int getMajorVersion() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getContextPath()
+     */
+    public String getContextPath() {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getMimeType(java.lang.String)
-	 */
-	public String getMimeType(String file) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getMinorVersion()
-	 */
-	public int getMinorVersion() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getInitParameter(java.lang.String)
+     */
+    public String getInitParameter(String name) {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
-	 */
-	public RequestDispatcher getNamedDispatcher(String name) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getRealPath(java.lang.String)
-	 */
-	public String getRealPath(String path) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getInitParameterNames()
+     */
+    public Enumeration getInitParameterNames() {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getRequestDispatcher(java.lang.String)
-	 */
-	public RequestDispatcher getRequestDispatcher(String path) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getResource(java.lang.String)
-	 */
-	public URL getResource(String path) throws MalformedURLException {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getMajorVersion()
+     */
+    public int getMajorVersion() {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
-	 */
-	public InputStream getResourceAsStream(String path) {
-		return getClass().getResourceAsStream(path);
-	}
+        // TODO Auto-generated method stub
+        return 0;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
-	 */
-	public Set getResourcePaths(String path) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getMimeType(java.lang.String)
+     */
+    public String getMimeType(String file) {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getServerInfo()
-	 */
-	public String getServerInfo() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getServlet(java.lang.String)
-	 */
-	public Servlet getServlet(String name) throws ServletException {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getMinorVersion()
+     */
+    public int getMinorVersion() {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getServletContextName()
-	 */
-	public String getServletContextName() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        // TODO Auto-generated method stub
+        return 0;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getServletNames()
-	 */
-	public Enumeration getServletNames() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
+     */
+    public RequestDispatcher getNamedDispatcher(String name) {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#getServlets()
-	 */
-	public Enumeration getServlets() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#log(java.lang.String)
-	 */
-	public void log(String msg) {
-		// TODO Auto-generated method stub
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getRealPath(java.lang.String)
+     */
+    public String getRealPath(String path) {
 
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#log(java.lang.Exception, java.lang.String)
-	 */
-	public void log(Exception exception, String msg) {
-		// TODO Auto-generated method stub
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getRequestDispatcher(java.lang.String)
+     */
+    public RequestDispatcher getRequestDispatcher(String path) {
 
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#log(java.lang.String, java.lang.Throwable)
-	 */
-	public void log(String message, Throwable throwable) {
-		// TODO Auto-generated method stub
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getResource(java.lang.String)
+     */
+    public URL getResource(String path) throws MalformedURLException {
 
-	}
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#removeAttribute(java.lang.String)
-	 */
-	public void removeAttribute(String name) {
-		// TODO Auto-generated method stub
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
+     */
+    public InputStream getResourceAsStream(String path) {
+        return getClass().getResourceAsStream(path);
+    }
 
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
+     */
+    public Set getResourcePaths(String path) {
 
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletContext#setAttribute(java.lang.String, java.lang.Object)
-	 */
-	public void setAttribute(String name, Object object) {
-		// TODO Auto-generated method stub
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	}
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getServerInfo()
+     */
+    public String getServerInfo() {
 
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getServlet(java.lang.String)
+     */
+    public Servlet getServlet(String name) throws ServletException {
+
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getServletContextName()
+     */
+    public String getServletContextName() {
+
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getServletNames()
+     */
+    public Enumeration getServletNames() {
+
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#getServlets()
+     */
+    public Enumeration getServlets() {
+
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#log(java.lang.String)
+     */
+    public void log(String msg) {
+
+        // TODO Auto-generated method stub
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#log(java.lang.Exception, java.lang.String)
+     */
+    public void log(Exception exception, String msg) {
+
+        // TODO Auto-generated method stub
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#log(java.lang.String, java.lang.Throwable)
+     */
+    public void log(String message, Throwable throwable) {
+
+        // TODO Auto-generated method stub
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#removeAttribute(java.lang.String)
+     */
+    public void removeAttribute(String name) {
+
+        // TODO Auto-generated method stub
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see javax.servlet.ServletContext#setAttribute(java.lang.String, java.lang.Object)
+     */
+    public void setAttribute(String name, Object object) {
+
+        // TODO Auto-generated method stub
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/MockXmlReader.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/MockXmlReader.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/MockXmlReader.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,6 +18,9 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.ajax4jsf.config;
 
 import java.io.IOException;
@@ -33,80 +36,47 @@
 import org.xml.sax.XMLReader;
 
 final class MockXmlReader implements XMLReader {
-	
-	ContentHandler contentHandler;
-	
-	public ContentHandler getContentHandler() {
-		return contentHandler;
-	}
+    ContentHandler contentHandler;
 
-	public DTDHandler getDTDHandler() {
+    public ContentHandler getContentHandler() {
+        return contentHandler;
+    }
 
-		return null;
-	}
+    public DTDHandler getDTDHandler() {
+        return null;
+    }
 
-	public EntityResolver getEntityResolver() {
+    public EntityResolver getEntityResolver() {
+        return null;
+    }
 
-		return null;
-	}
+    public ErrorHandler getErrorHandler() {
+        return null;
+    }
 
-	public ErrorHandler getErrorHandler() {
+    public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+        return false;
+    }
 
-		return null;
-	}
+    public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+        return null;
+    }
 
-	public boolean getFeature(String name)
-			throws SAXNotRecognizedException, SAXNotSupportedException {
+    public void parse(InputSource input) throws IOException, SAXException {}
 
-		return false;
-	}
+    public void parse(String systemId) throws IOException, SAXException {}
 
-	public Object getProperty(String name)
-			throws SAXNotRecognizedException, SAXNotSupportedException {
+    public void setContentHandler(ContentHandler handler) {
+        contentHandler = handler;
+    }
 
-		return null;
-	}
+    public void setDTDHandler(DTDHandler handler) {}
 
-	public void parse(InputSource input) throws IOException,
-			SAXException {
+    public void setEntityResolver(EntityResolver resolver) {}
 
-		
-	}
+    public void setErrorHandler(ErrorHandler handler) {}
 
-	public void parse(String systemId) throws IOException, SAXException {
+    public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {}
 
-		
-	}
-
-	public void setContentHandler(ContentHandler handler) {
-		contentHandler = handler;
-		
-	}
-
-	public void setDTDHandler(DTDHandler handler) {
-
-		
-	}
-
-	public void setEntityResolver(EntityResolver resolver) {
-
-		
-	}
-
-	public void setErrorHandler(ErrorHandler handler) {
-
-		
-	}
-
-	public void setFeature(String name, boolean value)
-			throws SAXNotRecognizedException, SAXNotSupportedException {
-
-		
-	}
-
-	public void setProperty(String name, Object value)
-			throws SAXNotRecognizedException, SAXNotSupportedException {
-
-		
-	}
-}
\ No newline at end of file
+    public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {}
+}

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/StateHandlerTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/StateHandlerTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/StateHandlerTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,9 +18,11 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.ajax4jsf.config;
 
-
 import junit.framework.TestCase;
 
 import org.xml.sax.Attributes;
@@ -34,56 +36,55 @@
  *
  */
 public class StateHandlerTest extends TestCase {
-	
-	private static final String PREFIX = "foo:";
-	private static final String BAR = "bar";
-	private static final String NS = "http://foo.com/";
+    private static final String BAR = "bar";
+    private static final String NS = "http://foo.com/";
+    private static final String PREFIX = "foo:";
+    private XMLReader reader;
 
-	private XMLReader reader;
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        reader = new MockXmlReader();
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#setUp()
-	 */
-	protected void setUp() throws Exception {
-		super.setUp();
-		reader = new MockXmlReader();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
-	
-	public void testReturnBack() throws Exception {
-		ContentHandler parentHandler = new DefaultHandler() {
-			@Override
-			public void startElement(String uri, String localName, String name,
-					Attributes attributes) throws SAXException {
-				throw new SAXException();
-			}
-			@Override
-			public void endElement(String uri, String localName, String name)
-					throws SAXException {
-				throw new SAXException();
-			}
-		};		
-		StateHandler handler = new StateHandler(parentHandler){
-			@Override
-			protected XMLReader getReader() {
-				return reader;
-			}
-		};
-		reader.setContentHandler(handler);
-		handler.startElement(NS, BAR, PREFIX+BAR, null);
-		handler.startElement(NS, BAR, PREFIX+BAR, null);
-		handler.endElement(NS, BAR, PREFIX+BAR);
-		assertSame(handler, reader.getContentHandler());
-		handler.endElement(NS, BAR, PREFIX+BAR);
-		assertSame(handler, reader.getContentHandler());
-		handler.endElement(NS, BAR, PREFIX+BAR);
-		assertSame(parentHandler, reader.getContentHandler());
-	}
+    public void testReturnBack() throws Exception {
+        ContentHandler parentHandler = new DefaultHandler() {
+            @Override
+            public void startElement(String uri, String localName, String name, Attributes attributes)
+                    throws SAXException {
+                throw new SAXException();
+            }
+            @Override
+            public void endElement(String uri, String localName, String name) throws SAXException {
+                throw new SAXException();
+            }
+        };
+        StateHandler handler = new StateHandler(parentHandler) {
+            @Override
+            protected XMLReader getReader() {
+                return reader;
+            }
+        };
 
+        reader.setContentHandler(handler);
+        handler.startElement(NS, BAR, PREFIX + BAR, null);
+        handler.startElement(NS, BAR, PREFIX + BAR, null);
+        handler.endElement(NS, BAR, PREFIX + BAR);
+        assertSame(handler, reader.getContentHandler());
+        handler.endElement(NS, BAR, PREFIX + BAR);
+        assertSame(handler, reader.getContentHandler());
+        handler.endElement(NS, BAR, PREFIX + BAR);
+        assertSame(parentHandler, reader.getContentHandler());
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/WebXMLTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/WebXMLTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/WebXMLTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,9 +18,13 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.ajax4jsf.config;
 
 import java.io.InputStream;
+
 import java.util.List;
 
 import junit.framework.TestCase;
@@ -31,34 +35,38 @@
  */
 public class WebXMLTest extends TestCase {
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#setUp()
-	 */
-	protected void setUp() throws Exception {
-		super.setUp();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-	/**
-	 * Test method for {@link org.WebXMLParser.portletbridge.util.WebXML#init(java.io.InputStream, String)}.
-	 */
-	public void testParse() throws Exception {
-		WebXMLParser webXml = new WebXMLParser();
-		InputStream inputStream = this.getClass().getResourceAsStream("/WEB-INF/web.xml");
-		webXml.init(inputStream, "foo");
-		inputStream.close();
-		List<String> facesServletMappings = webXml.getFacesServletMappings();
-		assertEquals(2, facesServletMappings.size());
-		assertEquals("*.jsf", webXml.getFacesServletMappings().get(1));
-		assertEquals("/faces/*", webXml.getFacesServletMappings().get(0));
-		assertEquals(".jsf", webXml.getFacesServletSuffix());
-		assertEquals("/faces", webXml.getFacesServletPrefix());
-	}
+    /**
+     * Test method for {@link org.WebXMLParser.portletbridge.util.WebXML#init(java.io.InputStream, String)}.
+     */
+    public void testParse() throws Exception {
+        WebXMLParser webXml = new WebXMLParser();
+        InputStream inputStream = this.getClass().getResourceAsStream("/WEB-INF/web.xml");
 
+        webXml.init(inputStream, "foo");
+        inputStream.close();
+
+        List<String> facesServletMappings = webXml.getFacesServletMappings();
+
+        assertEquals(2, facesServletMappings.size());
+        assertEquals("*.jsf", webXml.getFacesServletMappings().get(1));
+        assertEquals("/faces/*", webXml.getFacesServletMappings().get(0));
+        assertEquals(".jsf", webXml.getFacesServletSuffix());
+        assertEquals("/faces", webXml.getFacesServletPrefix());
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/WebappHandlerTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/WebappHandlerTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/config/WebappHandlerTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,6 +18,9 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.ajax4jsf.config;
 
 import java.util.List;
@@ -25,6 +28,7 @@
 import junit.framework.TestCase;
 
 import org.ajax4jsf.config.WebappHandler.ServletMappingHandler;
+
 import org.xml.sax.ContentHandler;
 
 /**
@@ -32,71 +36,82 @@
  *
  */
 public class WebappHandlerTest extends TestCase {
+    private static final char[] FACES_SERVLET = "Faces Servlet".toCharArray();
+    private static final char[] FACES_SERVLET_CLASS = "javax.faces.webapp.FacesServlet".toCharArray();
+    private static final String SERVLET = "servlet";
+    private static final String SERVLET_CLASS = "servlet-class";
+    private static final String SERVLET_MAPPING = "servlet-mapping";
+    private static final String SERVLET_NAME = "servlet-name";
+    private static final String WEBAPP = "web-app";
+    private MockXmlReader reader;
 
-	private static final char[] FACES_SERVLET = "Faces Servlet".toCharArray();
-	private static final char[] FACES_SERVLET_CLASS = "javax.faces.webapp.FacesServlet".toCharArray();
-	private static final String SERVLET = "servlet";
-	private static final String WEBAPP = "web-app";
-	private static final String SERVLET_NAME = "servlet-name";
-	private static final String SERVLET_CLASS = "servlet-class";
-	private static final String SERVLET_MAPPING = "servlet-mapping";
-	private MockXmlReader reader;
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        reader = new MockXmlReader();
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#setUp()
-	 */
-	protected void setUp() throws Exception {
-		super.setUp();
-		reader = new MockXmlReader();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
-	
-	public void testServletElement() throws Exception {
-		WebappHandler handler = new WebappHandler(reader);
-		reader.setContentHandler(handler);
-		handler.startElement(null, WEBAPP, WEBAPP, null);
-		assertEquals(handler, reader.getContentHandler());
-		handler.startElement(null, SERVLET, SERVLET, null);
-		ContentHandler servletHandler = reader.getContentHandler();
-		assertSame(WebappHandler.ServletHandler.class, reader.getContentHandler().getClass());
-		servletHandler.startElement(null, SERVLET_NAME, SERVLET_NAME, null);
-		assertSame(StringContentHandler.class, reader.getContentHandler().getClass());
-		ContentHandler servletNameHandler = reader.getContentHandler();
-		servletNameHandler.characters(FACES_SERVLET, 0, FACES_SERVLET.length);
-		servletNameHandler.endElement(null, SERVLET_NAME, SERVLET_NAME);
-		assertSame(servletHandler, reader.getContentHandler());
-		servletHandler.startElement(null, SERVLET_CLASS, SERVLET_CLASS, null);
-		assertSame(StringContentHandler.class, reader.getContentHandler().getClass());
-		ContentHandler servletClassHandler = reader.getContentHandler();
-		servletClassHandler.characters(FACES_SERVLET_CLASS, 0, FACES_SERVLET_CLASS.length);
-		servletClassHandler.endElement(null, SERVLET_CLASS, SERVLET_CLASS);
-		assertSame(servletHandler, reader.getContentHandler());
-		servletHandler.endElement(null, SERVLET, SERVLET);
-		assertEquals(handler, reader.getContentHandler());
-		handler.endElement(null, WEBAPP, WEBAPP);
-		handler.endDocument();
-		List<ServletBean> servlets = handler.getServlets();
-		assertEquals(1, servlets.size());
-		assertEquals(0, servlets.indexOf(new ServletBean("Faces Servlet",null)));
-	}
-	
-	public void testMappingElement() throws Exception {
-		WebappHandler handler = new WebappHandler(reader);
-		reader.setContentHandler(handler);
-		handler.startElement(null, WEBAPP, WEBAPP, null);
-		assertEquals(handler, reader.getContentHandler());
-		handler.startElement(null, SERVLET_MAPPING, SERVLET_MAPPING, null);
-		ContentHandler servletHandler = reader.getContentHandler();
-		assertSame(ServletMappingHandler.class, reader.getContentHandler().getClass());
-		servletHandler.startElement(null, SERVLET_NAME, SERVLET_NAME, null);
-		assertSame(StringContentHandler.class, reader.getContentHandler().getClass());
-		
-	}
+    public void testServletElement() throws Exception {
+        WebappHandler handler = new WebappHandler(reader);
 
+        reader.setContentHandler(handler);
+        handler.startElement(null, WEBAPP, WEBAPP, null);
+        assertEquals(handler, reader.getContentHandler());
+        handler.startElement(null, SERVLET, SERVLET, null);
+
+        ContentHandler servletHandler = reader.getContentHandler();
+
+        assertSame(WebappHandler.ServletHandler.class, reader.getContentHandler().getClass());
+        servletHandler.startElement(null, SERVLET_NAME, SERVLET_NAME, null);
+        assertSame(StringContentHandler.class, reader.getContentHandler().getClass());
+
+        ContentHandler servletNameHandler = reader.getContentHandler();
+
+        servletNameHandler.characters(FACES_SERVLET, 0, FACES_SERVLET.length);
+        servletNameHandler.endElement(null, SERVLET_NAME, SERVLET_NAME);
+        assertSame(servletHandler, reader.getContentHandler());
+        servletHandler.startElement(null, SERVLET_CLASS, SERVLET_CLASS, null);
+        assertSame(StringContentHandler.class, reader.getContentHandler().getClass());
+
+        ContentHandler servletClassHandler = reader.getContentHandler();
+
+        servletClassHandler.characters(FACES_SERVLET_CLASS, 0, FACES_SERVLET_CLASS.length);
+        servletClassHandler.endElement(null, SERVLET_CLASS, SERVLET_CLASS);
+        assertSame(servletHandler, reader.getContentHandler());
+        servletHandler.endElement(null, SERVLET, SERVLET);
+        assertEquals(handler, reader.getContentHandler());
+        handler.endElement(null, WEBAPP, WEBAPP);
+        handler.endDocument();
+
+        List<ServletBean> servlets = handler.getServlets();
+
+        assertEquals(1, servlets.size());
+        assertEquals(0, servlets.indexOf(new ServletBean("Faces Servlet", null)));
+    }
+
+    public void testMappingElement() throws Exception {
+        WebappHandler handler = new WebappHandler(reader);
+
+        reader.setContentHandler(handler);
+        handler.startElement(null, WEBAPP, WEBAPP, null);
+        assertEquals(handler, reader.getContentHandler());
+        handler.startElement(null, SERVLET_MAPPING, SERVLET_MAPPING, null);
+
+        ContentHandler servletHandler = reader.getContentHandler();
+
+        assertSame(ServletMappingHandler.class, reader.getContentHandler().getClass());
+        servletHandler.startElement(null, SERVLET_NAME, SERVLET_NAME, null);
+        assertSame(StringContentHandler.class, reader.getContentHandler().getClass());
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/context/InitParametersTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/context/InitParametersTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/context/InitParametersTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.ajax4jsf.context;
 
@@ -12,104 +13,123 @@
  *
  */
 public class InitParametersTest extends AbstractFacesTest {
+    private static final int INT_PARAM = 367;
+    private static final String NO = "no";
+    private static final String ORG_AJAX4JSF_FALSE = "org.ajax4jsf.FALSE";
+    private static final String ORG_AJAX4JSF_INT = "org.ajax4jsf.INT";
+    private static final String ORG_AJAX4JSF_STRING = "org.ajax4jsf.STRING";
+    private static final String ORG_AJAX4JSF_TRUE = "org.ajax4jsf.TRUE";
+    private static final String STRING_PARAM = "init";
+    private static final String TRUE = "true";
 
-	private static final String STRING_PARAM = "init";
-	private static final int INT_PARAM = 367;
-	private static final String NO = "no";
-	private static final String TRUE = "true";
-	private static final String ORG_AJAX4JSF_STRING = "org.ajax4jsf.STRING";
-	private static final String ORG_AJAX4JSF_INT = "org.ajax4jsf.INT";
-	private static final String ORG_AJAX4JSF_FALSE = "org.ajax4jsf.FALSE";
-	private static final String ORG_AJAX4JSF_TRUE = "org.ajax4jsf.TRUE";
+    /*
+     *  (non-Javadoc)
+     * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+     */
+    public void setUp() throws Exception {
+        super.setUp();
+        setupFacesRequest();
+    }
 
-	/* (non-Javadoc)
-	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
-	 */
-	public void setUp() throws Exception {
-		super.setUp();
-		setupFacesRequest();
-	}
+    @Override
+    protected void setupJsfInitParameters() {
+        super.setupJsfInitParameters();
+        facesServer.addInitParameter(ORG_AJAX4JSF_TRUE, TRUE);
+        facesServer.addInitParameter(ORG_AJAX4JSF_FALSE, NO);
+        facesServer.addInitParameter(ORG_AJAX4JSF_INT, String.valueOf(INT_PARAM));
+        facesServer.addInitParameter(ORG_AJAX4JSF_STRING, STRING_PARAM);
+    }
 
-	@Override
-	protected void setupJsfInitParameters() {
-		super.setupJsfInitParameters();
-		
-		facesServer.addInitParameter(ORG_AJAX4JSF_TRUE, TRUE);
-		facesServer.addInitParameter(ORG_AJAX4JSF_FALSE, NO);
-		facesServer.addInitParameter(ORG_AJAX4JSF_INT, String.valueOf(INT_PARAM));
-		facesServer.addInitParameter(ORG_AJAX4JSF_STRING, STRING_PARAM);
-	}
-	
-	/* (non-Javadoc)
-	 * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
-	 */
-	public void tearDown() throws Exception {
-		super.tearDown();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+     */
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-	/**
-	 * Test method for {@link org.ajax4jsf.context.ContextInitParameters#getInteger(javax.faces.context.FacesContext, java.lang.String[], int)}.
-	 */
-	public void testGetInteger() {
-		String[] params = {"foo.bar",ORG_AJAX4JSF_INT};
-		int value = ContextInitParameters.getInteger(facesContext, params, 12);
-		assertEquals(INT_PARAM, value);
-		String[] params2 = {"foo.bar"};
-		value = ContextInitParameters.getInteger(facesContext, params2, 12);
-		assertEquals(12, value);
-		String[] params3 = {"foo.bar",ORG_AJAX4JSF_STRING};
-		try {
-			value = ContextInitParameters.getInteger(facesContext, params3, 12);			
-		} catch (FacesException e) {
-			return;
-		}
-		assertFalse("No exception on invalid parameter",true);
-	}
+    /**
+     * Test method for {@link org.ajax4jsf.context.ContextInitParameters#getInteger(javax.faces.context.FacesContext, java.lang.String[], int)}.
+     */
+    public void testGetInteger() {
+        String[] params = {"foo.bar", ORG_AJAX4JSF_INT};
+        int value = ContextInitParameters.getInteger(facesContext, params, 12);
 
-	/**
-	 * Test method for {@link org.ajax4jsf.context.ContextInitParameters#getString(javax.faces.context.FacesContext, java.lang.String[], java.lang.String)}.
-	 */
-	public void testGetString() {
-		String[] params = {"foo.bar",ORG_AJAX4JSF_STRING};
-		String value = ContextInitParameters.getString(facesContext, params, "foo");
-		assertEquals(STRING_PARAM, value);
-		String[] params2 = {"foo.bar"};
-		value = ContextInitParameters.getString(facesContext, params2, "foo");
-		assertEquals("foo", value);
-	}
+        assertEquals(INT_PARAM, value);
 
-	/**
-	 * Test method for {@link org.ajax4jsf.context.ContextInitParameters#getBoolean(javax.faces.context.FacesContext, java.lang.String[], boolean)}.
-	 */
-	public void testGetBoolean() {
-		String[] params = {"foo.bar",ORG_AJAX4JSF_TRUE};
-		boolean value = ContextInitParameters.getBoolean(facesContext, params, false);
-		assertTrue(value);
-		String[] params2 = {"foo.bar"};
-		value = ContextInitParameters.getBoolean(facesContext, params2, true);
-		assertTrue(value);
-		String[] params3 = {"foo.bar",ORG_AJAX4JSF_FALSE};
-		value = ContextInitParameters.getBoolean(facesContext, params3, true);
-		assertFalse(value);
-		String[] params4 = {"foo.bar",ORG_AJAX4JSF_STRING};
-		try {
-			value = ContextInitParameters.getBoolean(facesContext, params4, false);			
-		} catch (FacesException e) {
-			return;
-		}
-		assertFalse("No exception on invalid parameter",true);
-	}
+        String[] params2 = {"foo.bar"};
 
-	/**
-	 * Test method for {@link org.ajax4jsf.context.ContextInitParameters#getInitParameter(javax.faces.context.FacesContext, java.lang.String[])}.
-	 */
-	public void testGetInitParameter() {
-		String[] params = {"foo.bar",ORG_AJAX4JSF_STRING};
-		String value = ContextInitParameters.getInitParameter(facesContext, params);
-		assertEquals(STRING_PARAM, value);
-		String[] params2 = {"foo.bar"};
-		value = ContextInitParameters.getInitParameter(facesContext, params2);
-		assertNull(value);
-	}
+        value = ContextInitParameters.getInteger(facesContext, params2, 12);
+        assertEquals(12, value);
 
+        String[] params3 = {"foo.bar", ORG_AJAX4JSF_STRING};
+
+        try {
+            value = ContextInitParameters.getInteger(facesContext, params3, 12);
+        } catch (FacesException e) {
+            return;
+        }
+
+        assertFalse("No exception on invalid parameter", true);
+    }
+
+    /**
+     * Test method for {@link org.ajax4jsf.context.ContextInitParameters#getString(javax.faces.context.FacesContext, java.lang.String[], java.lang.String)}.
+     */
+    public void testGetString() {
+        String[] params = {"foo.bar", ORG_AJAX4JSF_STRING};
+        String value = ContextInitParameters.getString(facesContext, params, "foo");
+
+        assertEquals(STRING_PARAM, value);
+
+        String[] params2 = {"foo.bar"};
+
+        value = ContextInitParameters.getString(facesContext, params2, "foo");
+        assertEquals("foo", value);
+    }
+
+    /**
+     * Test method for {@link org.ajax4jsf.context.ContextInitParameters#getBoolean(javax.faces.context.FacesContext, java.lang.String[], boolean)}.
+     */
+    public void testGetBoolean() {
+        String[] params = {"foo.bar", ORG_AJAX4JSF_TRUE};
+        boolean value = ContextInitParameters.getBoolean(facesContext, params, false);
+
+        assertTrue(value);
+
+        String[] params2 = {"foo.bar"};
+
+        value = ContextInitParameters.getBoolean(facesContext, params2, true);
+        assertTrue(value);
+
+        String[] params3 = {"foo.bar", ORG_AJAX4JSF_FALSE};
+
+        value = ContextInitParameters.getBoolean(facesContext, params3, true);
+        assertFalse(value);
+
+        String[] params4 = {"foo.bar", ORG_AJAX4JSF_STRING};
+
+        try {
+            value = ContextInitParameters.getBoolean(facesContext, params4, false);
+        } catch (FacesException e) {
+            return;
+        }
+
+        assertFalse("No exception on invalid parameter", true);
+    }
+
+    /**
+     * Test method for {@link org.ajax4jsf.context.ContextInitParameters#getInitParameter(javax.faces.context.FacesContext, java.lang.String[])}.
+     */
+    public void testGetInitParameter() {
+        String[] params = {"foo.bar", ORG_AJAX4JSF_STRING};
+        String value = ContextInitParameters.getInitParameter(facesContext, params);
+
+        assertEquals(STRING_PARAM, value);
+
+        String[] params2 = {"foo.bar"};
+
+        value = ContextInitParameters.getInitParameter(facesContext, params2);
+        assertNull(value);
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/css/CssCompressorTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/css/CssCompressorTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/css/CssCompressorTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,9 +1,9 @@
+
 /*
- * CssCompressorTest.java		Date created: 21.11.2007
- * Last modified by: $Author$
- * $Revision$	$Date$
+* CssCompressorTest.java       Date created: 21.11.2007
+* Last modified by: $Author$
+* $Revision$   $Date$
  */
-
 package org.ajax4jsf.css;
 
 import java.io.IOException;
@@ -19,87 +19,85 @@
  *
  */
 public class CssCompressorTest extends TestCase {
-    
+
+    /** css example to be comressed */
+    private static final String cssExample =
+        "HTML { \n" + "MARGIN-BOTTOM: 0.01em; HEIGHT: 100%; BACKGROUND-COLOR: #ffffff;\n" + "}\n" + "TD {\n"
+        + "FONT-SIZE: 10px; COLOR: #000000; FONT-FAMILY: verdana, arial\n" + "}\n" + "TH {\n"
+        + "FONT-WEIGHT: bold; FONT-SIZE: 10px; COLOR: #336699; FONT-FAMILY: verdana, arial; BACKGROUND-COLOR: #ffffff; text-align:left;\n"
+        + "}\n" + ".header {\n" + "FONT-WEIGHT: bold; FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: verdana, arial\n"
+        + "}\n";
+
     /** Length of correctly compressed css example */
     private static final int lengthCompressed = 305;
-    
-    /** css example to be comressed */
-    private static final String cssExample = 
-	    "HTML { \n"+
-	    "MARGIN-BOTTOM: 0.01em; HEIGHT: 100%; BACKGROUND-COLOR: #ffffff;\n" +
-	    "}\n" +
-	    "TD {\n" +
-	    "FONT-SIZE: 10px; COLOR: #000000; FONT-FAMILY: verdana, arial\n" +
-    	    "}\n" +
-    	    "TH {\n" +
-            "FONT-WEIGHT: bold; FONT-SIZE: 10px; COLOR: #336699; FONT-FAMILY: verdana, arial; BACKGROUND-COLOR: #ffffff; text-align:left;\n" +
-            "}\n" +
-    	    ".header {\n" +
-    	    "FONT-WEIGHT: bold; FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: verdana, arial\n" +
-    	    "}\n"; 
-    
+
     /**
      * Constructor
      * @param name
      */
     public CssCompressorTest(String name) {
-	super(name);
-	// TODO Auto-generated constructor stub
+        super(name);
+
+        // TODO Auto-generated constructor stub
     }
 
-    /* (non-Javadoc)
+    /*
+     *  (non-Javadoc)
      * @see junit.framework.TestCase#setUp()
      */
     @Override
     protected void setUp() throws Exception {
-	// TODO Auto-generated method stub
-	super.setUp();
+
+        // TODO Auto-generated method stub
+        super.setUp();
     }
 
-    /* (non-Javadoc)
+    /*
+     *  (non-Javadoc)
      * @see junit.framework.TestCase#tearDown()
      */
     @Override
     protected void tearDown() throws Exception {
-	// TODO Auto-generated method stub
-	super.tearDown();
+
+        // TODO Auto-generated method stub
+        super.tearDown();
     }
-    
-    
+
     /**
      * Test method
      * @throws IOException
      */
-    public void testCssCompressor () throws IOException {
-	
-	StringBuffer cssBuffer = new StringBuffer(cssExample);
-	CssCompressor compressor = new CssCompressor(cssBuffer);
-	CountingOutputWriter writer = new CountingOutputWriter();
-	compressor.compress(writer, -1);
-	
-	// compressed length should equal
-	assertEquals(writer.getWritten(), lengthCompressed);
-	
-   }
-    
+    public void testCssCompressor() throws IOException {
+        StringBuffer cssBuffer = new StringBuffer(cssExample);
+        CssCompressor compressor = new CssCompressor(cssBuffer);
+        CountingOutputWriter writer = new CountingOutputWriter();
+
+        compressor.compress(writer, -1);
+
+        // compressed length should equal
+        assertEquals(writer.getWritten(), lengthCompressed);
+    }
+
     public void testSequentialComments() throws Exception {
-    	StringBuffer cssBuffer = new StringBuffer("/* copyright */ body { color: red; } /* abc *//* cde */ html { color: red; } /* copyright end */");
-    	CssCompressor compressor = new CssCompressor(cssBuffer);
-    	StringWriter stringWriter = new StringWriter();
-    	compressor.compress(stringWriter, -1);
-    	stringWriter.close();
-    	assertEquals("body{color:red;}html{color:red;}", stringWriter.toString());
-    } 
-    
-    public void testFakeComment() throws Exception {
-    	//this test won't go as our CSS compressor is not aware of possible /**/ in url 
-    	
-    	//StringBuffer cssBuffer = new StringBuffer("/* copyright */ body { /* my style */ background-image: url(/*/); color: red; background-image: url(/****/); } /* copyright end */");
-    	//CssCompressor compressor = new CssCompressor(cssBuffer);
-    	//StringWriter stringWriter = new StringWriter();
-    	//compressor.compress(stringWriter, -1);
-    	//stringWriter.close();
-    	//assertEquals("body{background-image:url(/*/);color:red;background-image:url(/****/);}", stringWriter.toString());
+        StringBuffer cssBuffer =
+            new StringBuffer(
+                "/* copyright */ body { color: red; } /* abc *//* cde */ html { color: red; } /* copyright end */");
+        CssCompressor compressor = new CssCompressor(cssBuffer);
+        StringWriter stringWriter = new StringWriter();
+
+        compressor.compress(stringWriter, -1);
+        stringWriter.close();
+        assertEquals("body{color:red;}html{color:red;}", stringWriter.toString());
     }
 
+    public void testFakeComment() throws Exception {
+
+        // this test won't go as our CSS compressor is not aware of possible /**/ in url
+        // StringBuffer cssBuffer = new StringBuffer("/* copyright */ body { /* my style */ background-image: url(/*/); color: red; background-image: url(/****/); } /* copyright end */");
+        // CssCompressor compressor = new CssCompressor(cssBuffer);
+        // StringWriter stringWriter = new StringWriter();
+        // compressor.compress(stringWriter, -1);
+        // stringWriter.close();
+        // assertEquals("body{background-image:url(/*/);color:red;background-image:url(/****/);}", stringWriter.toString());
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/event/EventsQueueTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/event/EventsQueueTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/event/EventsQueueTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,10 +18,11 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
-package org.ajax4jsf.event;
 
 
 
+package org.ajax4jsf.event;
+
 import java.util.NoSuchElementException;
 
 import javax.faces.component.UICommand;
@@ -35,73 +36,84 @@
  */
 public class EventsQueueTest extends TestCase {
 
-	/**
-	 * @param name
-	 */
-	public EventsQueueTest(String name) {
-		super(name);
-	}
+    /**
+     * @param name
+     */
+    public EventsQueueTest(String name) {
+        super(name);
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#setUp()
-	 */
-	protected void setUp() throws Exception {
-		super.setUp();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-	/**
-	 * Test method for {@link org.ajax4jsf.event.EventsQueue#remove()}.
-	 */
-	public void testRemove() {
-		ActionEvent event = new ActionEvent(new UICommand());
-		EventsQueue queue = new EventsQueue();
-		queue.offer(event);
-		assertFalse(queue.isEmpty());
-		ActionEvent event2 = new ActionEvent(new UICommand());
-		queue.offer(event2);
-		assertSame(event, queue.remove());
-		assertSame(event2, queue.remove());
-		assertTrue(queue.isEmpty());
-		try {
-			queue.remove();
-		} catch (NoSuchElementException e) {
-			return;
-		}
-		assertTrue("exception not thrown",false);
-	}
+    /**
+     * Test method for {@link org.ajax4jsf.event.EventsQueue#remove()}.
+     */
+    public void testRemove() {
+        ActionEvent event = new ActionEvent(new UICommand());
+        EventsQueue queue = new EventsQueue();
 
-	/**
-	 * Test method for {@link org.ajax4jsf.event.EventsQueue#offer(javax.faces.event.FacesEvent)}.
-	 */
-	public void testAdd() {
-		ActionEvent event = new ActionEvent(new UICommand());
-		EventsQueue queue = new EventsQueue();
-		queue.offer(event);
-		assertFalse(queue.isEmpty());
-		ActionEvent event2 = new ActionEvent(new UICommand());
-		queue.offer(event2);
-	}
+        queue.offer(event);
+        assertFalse(queue.isEmpty());
 
-	/**
-	 * Test method for {@link org.ajax4jsf.event.EventsQueue#clear()}.
-	 */
-	public void testClear() {
-		ActionEvent event = new ActionEvent(new UICommand());
-		EventsQueue queue = new EventsQueue();
-		queue.offer(event);
-		assertFalse(queue.isEmpty());
-		ActionEvent event2 = new ActionEvent(new UICommand());
-		queue.offer(event2);
-		queue.clear();
-		assertTrue(queue.isEmpty());		
-	}
+        ActionEvent event2 = new ActionEvent(new UICommand());
 
+        queue.offer(event2);
+        assertSame(event, queue.remove());
+        assertSame(event2, queue.remove());
+        assertTrue(queue.isEmpty());
 
+        try {
+            queue.remove();
+        } catch (NoSuchElementException e) {
+            return;
+        }
+
+        assertTrue("exception not thrown", false);
+    }
+
+    /**
+     * Test method for {@link org.ajax4jsf.event.EventsQueue#offer(javax.faces.event.FacesEvent)}.
+     */
+    public void testAdd() {
+        ActionEvent event = new ActionEvent(new UICommand());
+        EventsQueue queue = new EventsQueue();
+
+        queue.offer(event);
+        assertFalse(queue.isEmpty());
+
+        ActionEvent event2 = new ActionEvent(new UICommand());
+
+        queue.offer(event2);
+    }
+
+    /**
+     * Test method for {@link org.ajax4jsf.event.EventsQueue#clear()}.
+     */
+    public void testClear() {
+        ActionEvent event = new ActionEvent(new UICommand());
+        EventsQueue queue = new EventsQueue();
+
+        queue.offer(event);
+        assertFalse(queue.isEmpty());
+
+        ActionEvent event2 = new ActionEvent(new UICommand());
+
+        queue.offer(event2);
+        queue.clear();
+        assertTrue(queue.isEmpty());
+    }
 }

Copied: root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/Test.java (from rev 15745, root/framework/trunk/impl/src/main/java/org/ajax4jsf/io/Test.java)
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/Test.java	                        (rev 0)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/Test.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -0,0 +1,340 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+
+
+package org.ajax4jsf.io;
+
+import org.junit.Ignore;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+ at Ignore
+public final class Test {
+    private static final int ARRAY_LENGTH = 27;
+    private static final int READ_LENGTH = 22;
+    private static final int READ_OFF = 4;
+    private static final boolean OUT_STRING = true;
+    private static final boolean BUILD_STRING = false;
+
+    private Test() {}
+
+    static void testStreams() throws IOException {
+        String s = "This is a senseless text to test streams.\n";
+
+        for (int i = 0; i < 10; i++) {
+            s = s + s; // repeated 16 times
+        }
+
+        byte[] bytes = s.getBytes();
+        FastBufferOutputStream output = new FastBufferOutputStream(16);
+
+        // write it several times.
+        for (int i = 0; i < 4; i++) {
+            output.write(bytes);
+        }
+
+        // write it one more time by one byte
+        for (int i = 0; i < bytes.length; i++) {
+            output.write(bytes[i]);
+        }
+
+        FastBufferInputStream input = new FastBufferInputStream(output);
+        StringBuffer sb = new StringBuffer();
+
+        // use for reading unconvenient array length.
+        byte[] bs = new byte[ARRAY_LENGTH];
+        int l = 0;
+
+        while ((l = input.read(bs, READ_OFF, READ_LENGTH)) >= 0) {
+            if (BUILD_STRING) {
+                sb.append(new String(bs, READ_OFF, l));
+            }
+        }
+
+        if (BUILD_STRING && OUT_STRING) {
+            System.out.println(sb);
+            System.out.println("Length=" + output.getLength());
+        }
+    }
+
+    static void testStandardStreams() throws IOException {
+        String s = "This is a senseless text to test streams.\n";
+
+        for (int i = 0; i < 10; i++) {
+            s = s + s; // repeated 16 times
+        }
+
+        byte[] bytes = s.getBytes();
+        ByteArrayOutputStream output = new ByteArrayOutputStream(16);
+
+        // write it several times.
+        for (int i = 0; i < 4; i++) {
+            output.write(bytes);
+        }
+
+        // write it one more time by one byte
+        for (int i = 0; i < bytes.length; i++) {
+            output.write(bytes[i]);
+        }
+
+        ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
+        StringBuffer sb = new StringBuffer();
+
+        // use for reading unconvenient array length.
+        byte[] bs = new byte[ARRAY_LENGTH];
+        int l = 0;
+
+        while ((l = input.read(bs, READ_OFF, READ_LENGTH)) >= 0) {
+            if (BUILD_STRING) {
+                sb.append(new String(bs, READ_OFF, l));
+            }
+        }
+
+        if (BUILD_STRING && OUT_STRING) {
+            System.out.println(sb);
+        }
+    }
+
+    static void testReaders() throws IOException {
+        String s = "This is a senseless text to test readers.\n";
+
+        for (int i = 0; i < 10; i++) {
+            s = s + s; // repeated 16 times
+        }
+
+        char[] bytes = s.toCharArray();
+        FastBufferWriter output = new FastBufferWriter(16);
+
+        // write it several times.
+        for (int i = 0; i < 4; i++) {
+            output.write(bytes);
+        }
+
+        // write it one more time by one byte
+        for (int i = 0; i < bytes.length; i++) {
+            output.write(bytes[i]);
+        }
+
+        FastBufferReader input = new FastBufferReader(output);
+        StringBuffer sb = new StringBuffer();
+
+        // use for reading unconvenient array length.
+        char[] bs = new char[ARRAY_LENGTH];
+        int l = 0;
+
+        while ((l = input.read(bs, READ_OFF, READ_LENGTH)) >= 0) {
+            if (BUILD_STRING) {
+                sb.append(new String(bs, READ_OFF, l));
+            }
+        }
+
+        if (BUILD_STRING && OUT_STRING) {
+            System.out.println(sb);
+        }
+    }
+
+    static void testStandardReaders() throws IOException {
+        String s = "This is a senseless text to test readers.\n";
+
+        for (int i = 0; i < 10; i++) {
+            s = s + s; // repeated 16 times
+        }
+
+        char[] bytes = s.toCharArray();
+        StringWriter output = new StringWriter(16);
+
+        // write it several times.
+        for (int i = 0; i < 4; i++) {
+            output.write(bytes);
+        }
+
+        // write it one more time by one byte
+        for (int i = 0; i < bytes.length; i++) {
+            output.write(bytes[i]);
+        }
+
+        StringReader input = new StringReader(output.toString());
+        StringBuffer sb = new StringBuffer();
+
+        // use for reading unconvenient array length.
+        char[] bs = new char[ARRAY_LENGTH];
+        int l = 0;
+
+        while ((l = input.read(bs, READ_OFF, READ_LENGTH)) >= 0) {
+            if (BUILD_STRING) {
+                sb.append(new String(bs, READ_OFF, l));
+            }
+        }
+
+        if (BUILD_STRING && OUT_STRING) {
+            System.out.println(sb);
+        }
+    }
+
+    static void testTransitionFromWriterToStream() throws IOException {
+        String s = "This is a senseless text to test transform from writer to stream.\n";
+
+        for (int i = 0; i < 10; i++) {
+            s = s + s; // repeated 16 times
+        }
+
+        char[] bytes = s.toCharArray();
+        FastBufferWriter output = new FastBufferWriter(16);
+
+        // write it several times.
+        for (int i = 0; i < 4; i++) {
+            output.write(bytes);
+        }
+
+        // write it one more time by one byte
+        for (int i = 0; i < bytes.length; i++) {
+            output.write(bytes[i]);
+        }
+
+        FastBufferOutputStream output2 = output.convertToOutputStream("UTF-8");
+        FastBufferInputStream input = new FastBufferInputStream(output2);
+        StringBuffer sb = new StringBuffer();
+
+        // use for reading unconvenient array length.
+        byte[] bs = new byte[ARRAY_LENGTH];
+        int l = 0;
+
+        while ((l = input.read(bs, READ_OFF, READ_LENGTH)) >= 0) {
+            if (BUILD_STRING) {
+                sb.append(new String(bs, READ_OFF, l));
+            }
+        }
+
+        if (BUILD_STRING && OUT_STRING) {
+            System.out.println(sb);
+        }
+    }
+
+    static void testStandardTransitionFromWriterToStream() throws IOException {
+        String s = "This is a senseless text to test transform from writer to stream.\n";
+
+        for (int i = 0; i < 10; i++) {
+            s = s + s; // repeated 16 times
+        }
+
+        char[] bytes = s.toCharArray();
+        StringWriter output = new StringWriter(16);
+
+        // write it several times.
+        for (int i = 0; i < 4; i++) {
+            output.write(bytes);
+        }
+
+        // write it one more time by one byte
+        for (int i = 0; i < bytes.length; i++) {
+            output.write(bytes[i]);
+        }
+
+        String str = output.toString();
+        ByteArrayInputStream input = new ByteArrayInputStream(str.getBytes());
+        StringBuffer sb = new StringBuffer();
+
+        // use for reading unconvenient array length.
+        byte[] bs = new byte[ARRAY_LENGTH];
+        int l = 0;
+
+        while ((l = input.read(bs, READ_OFF, READ_LENGTH)) >= 0) {
+            if (BUILD_STRING) {
+                sb.append(new String(bs, READ_OFF, l));
+            }
+        }
+
+        if (BUILD_STRING && OUT_STRING) {
+            System.out.println(sb);
+        }
+    }
+
+    static void testTransitionFromStreamToWriter() throws IOException {
+        String s = "This is a senseless text to test transform from stream to writer.\n";
+
+        for (int i = 0; i < 10; i++) {
+            s = s + s; // repeated 16 times
+        }
+
+        byte[] bytes = s.getBytes();
+        FastBufferOutputStream output = new FastBufferOutputStream(16);
+
+        // write it several times.
+        for (int i = 0; i < 4; i++) {
+            output.write(bytes);
+        }
+
+        // write it one more time by one byte
+        for (int i = 0; i < bytes.length; i++) {
+            output.write(bytes[i]);
+        }
+
+        FastBufferWriter output2 = output.convertToWriter("UTF-8");
+        FastBufferReader input = new FastBufferReader(output2);
+        StringBuffer sb = new StringBuffer();
+
+        // use for reading unconvenient array length.
+        char[] bs = new char[ARRAY_LENGTH];
+        int l = 0;
+
+        while ((l = input.read(bs, READ_OFF, READ_LENGTH)) >= 0) {
+            if (BUILD_STRING) {
+                sb.append(new String(bs, READ_OFF, l));
+            }
+        }
+
+        if (BUILD_STRING && OUT_STRING) {
+            System.out.println(sb);
+        }
+    }
+
+    /**
+     * @param args
+     */
+    public static void main(String[] args) {
+        long t = System.currentTimeMillis();
+
+        try {
+            for (int i = 0; i < 10; i++) {
+
+//              testStreams();
+//              testStandardStreams();
+//              testReaders();
+//                  testStandardReaders();
+//              testTransitionFromWriterToStream();
+                testStandardTransitionFromWriterToStream();
+
+//              testTransitionFromStreamToWriter();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        long dt = System.currentTimeMillis() - t;
+
+        System.out.println(dt);
+    }
+}

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferOutputStreamTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferOutputStreamTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferOutputStreamTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.ajax4jsf.io.parser;
 
 import junit.framework.TestCase;
@@ -30,53 +32,53 @@
  * @author Nick Belaevski
  * @since 3.3.0
  */
-
 public class FastBufferOutputStreamTest extends TestCase {
 
-	/**
-	 * Test method for {@link org.ajax4jsf.io.FastBufferOutputStream#reset()}.
-	 */
-	public void testResetOneBuffer() throws Exception {
-		FastBufferOutputStream stream = new FastBufferOutputStream(256);
-		for (int i = 0; i < 255; i++) {
-			stream.write(i);
-		}
-		
-		assertEquals(255, stream.getLength());
-		ByteBuffer firstBuffer = stream.getFirstBuffer();
-		assertNull(firstBuffer.getNext());
-		assertNull(firstBuffer.getPrevious());
+    /**
+     * Test method for {@link org.ajax4jsf.io.FastBufferOutputStream#reset()}.
+     */
+    public void testResetOneBuffer() throws Exception {
+        FastBufferOutputStream stream = new FastBufferOutputStream(256);
 
-		stream.reset();
-		
-		assertEquals(0, stream.getLength());
-		firstBuffer = stream.getFirstBuffer();
-		assertEquals(0, firstBuffer.getUsedSize());
-		assertNull(firstBuffer.getNext());
-		assertNull(firstBuffer.getPrevious());
-	}
-	
-	/**
-	 * Test method for {@link org.ajax4jsf.io.FastBufferOutputStream#reset()}.
-	 */
-	public void testResetTwoBuffers() throws Exception {
-		FastBufferOutputStream stream = new FastBufferOutputStream(256);
-		for (int i = 0; i < 257; i++) {
-			stream.write(i);
-		}
+        for (int i = 0; i < 255; i++) {
+            stream.write(i);
+        }
 
-		assertEquals(257, stream.getLength());
-		ByteBuffer firstBuffer = stream.getFirstBuffer();
-		assertNotNull(firstBuffer.getNext());
-		assertNull(firstBuffer.getPrevious());
+        assertEquals(255, stream.getLength());
 
-		stream.reset();
-		
-		assertEquals(0, stream.getLength());
-		firstBuffer = stream.getFirstBuffer();
-		assertEquals(0, firstBuffer.getUsedSize());
-		assertNull(firstBuffer.getNext());
-		assertNull(firstBuffer.getPrevious());
-	}
+        ByteBuffer firstBuffer = stream.getFirstBuffer();
 
+        assertNull(firstBuffer.getNext());
+        assertNull(firstBuffer.getPrevious());
+        stream.reset();
+        assertEquals(0, stream.getLength());
+        firstBuffer = stream.getFirstBuffer();
+        assertEquals(0, firstBuffer.getUsedSize());
+        assertNull(firstBuffer.getNext());
+        assertNull(firstBuffer.getPrevious());
+    }
+
+    /**
+     * Test method for {@link org.ajax4jsf.io.FastBufferOutputStream#reset()}.
+     */
+    public void testResetTwoBuffers() throws Exception {
+        FastBufferOutputStream stream = new FastBufferOutputStream(256);
+
+        for (int i = 0; i < 257; i++) {
+            stream.write(i);
+        }
+
+        assertEquals(257, stream.getLength());
+
+        ByteBuffer firstBuffer = stream.getFirstBuffer();
+
+        assertNotNull(firstBuffer.getNext());
+        assertNull(firstBuffer.getPrevious());
+        stream.reset();
+        assertEquals(0, stream.getLength());
+        firstBuffer = stream.getFirstBuffer();
+        assertEquals(0, firstBuffer.getUsedSize());
+        assertNull(firstBuffer.getNext());
+        assertNull(firstBuffer.getPrevious());
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferWriterTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferWriterTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferWriterTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.ajax4jsf.io.parser;
 
 import junit.framework.TestCase;
@@ -31,84 +33,86 @@
  * @author Nick Belaevski
  * @since 3.3.0
  */
-
 public class FastBufferWriterTest extends TestCase {
 
-	/**
-	 * Test method for {@link org.ajax4jsf.io.FastBufferWriter#reset()}.
-	 */
-	public void testResetOneBuffer() throws Exception {
-		FastBufferWriter stream = new FastBufferWriter(256);
-		for (int i = 0; i < 255; i++) {
-			stream.write(i);
-		}
-		
-		assertEquals(255, stream.getLength());
-		CharBuffer firstBuffer = stream.getFirstBuffer();
-		assertNull(firstBuffer.getNext());
-		assertNull(firstBuffer.getPrevious());
+    /**
+     * Test method for {@link org.ajax4jsf.io.FastBufferWriter#reset()}.
+     */
+    public void testResetOneBuffer() throws Exception {
+        FastBufferWriter stream = new FastBufferWriter(256);
 
-		stream.reset();
-		
-		assertEquals(0, stream.getLength());
-		firstBuffer = stream.getFirstBuffer();
-		assertEquals(0, firstBuffer.getUsedSize());
-		assertNull(firstBuffer.getNext());
-		assertNull(firstBuffer.getPrevious());
-	}
-	
-	/**
-	 * Test method for {@link org.ajax4jsf.io.FastBufferWriter#reset()}.
-	 */
-	public void testResetTwoBuffers() throws Exception {
-		FastBufferWriter stream = new FastBufferWriter(256);
-		for (int i = 0; i < 257; i++) {
-			stream.write(i);
-		}
+        for (int i = 0; i < 255; i++) {
+            stream.write(i);
+        }
 
-		assertEquals(257, stream.getLength());
-		CharBuffer firstBuffer = stream.getFirstBuffer();
-		assertNotNull(firstBuffer.getNext());
-		assertNull(firstBuffer.getPrevious());
+        assertEquals(255, stream.getLength());
 
-		stream.reset();
-		
-		assertEquals(0, stream.getLength());
-		firstBuffer = stream.getFirstBuffer();
-		assertEquals(0, firstBuffer.getUsedSize());
-		assertNull(firstBuffer.getNext());
-		assertNull(firstBuffer.getPrevious());
-	}
-	
-	public void testCompact() throws Exception {
-		int itemsTowWrite = 16384 + 16000;
+        CharBuffer firstBuffer = stream.getFirstBuffer();
 
-		FastBufferWriter writer = new FastBufferWriter(16384);
-		for (int i = 0; i < itemsTowWrite; i++) {
-			writer.write(i);
-		}
-		writer.close();
-		
-		CharBuffer firstBuffer = writer.getFirstBuffer();
-		assertNotNull(firstBuffer);
+        assertNull(firstBuffer.getNext());
+        assertNull(firstBuffer.getPrevious());
+        stream.reset();
+        assertEquals(0, stream.getLength());
+        firstBuffer = stream.getFirstBuffer();
+        assertEquals(0, firstBuffer.getUsedSize());
+        assertNull(firstBuffer.getNext());
+        assertNull(firstBuffer.getPrevious());
+    }
 
-		CharBuffer nextBuffer = firstBuffer.getNext();
-		assertNotNull(nextBuffer);
-		assertNull(nextBuffer.getNext());
+    /**
+     * Test method for {@link org.ajax4jsf.io.FastBufferWriter#reset()}.
+     */
+    public void testResetTwoBuffers() throws Exception {
+        FastBufferWriter stream = new FastBufferWriter(256);
 
-		assertTrue(firstBuffer.getUsedSize() == firstBuffer.getCacheSize());
-		assertTrue(nextBuffer.getUsedSize() < nextBuffer.getCacheSize());
-	
-		firstBuffer.compact();
+        for (int i = 0; i < 257; i++) {
+            stream.write(i);
+        }
 
-		assertTrue(firstBuffer.getUsedSize() == firstBuffer.getCacheSize());
-		assertTrue(nextBuffer.getUsedSize() == nextBuffer.getCacheSize());
+        assertEquals(257, stream.getLength());
 
-		FastBufferReader reader = new FastBufferReader(firstBuffer);
-		for (int i = 0; i < itemsTowWrite; i++) {
-			assertEquals(i, reader.read());
-		}
-		reader.close();
-	}
+        CharBuffer firstBuffer = stream.getFirstBuffer();
 
+        assertNotNull(firstBuffer.getNext());
+        assertNull(firstBuffer.getPrevious());
+        stream.reset();
+        assertEquals(0, stream.getLength());
+        firstBuffer = stream.getFirstBuffer();
+        assertEquals(0, firstBuffer.getUsedSize());
+        assertNull(firstBuffer.getNext());
+        assertNull(firstBuffer.getPrevious());
+    }
+
+    public void testCompact() throws Exception {
+        int itemsTowWrite = 16384 + 16000;
+        FastBufferWriter writer = new FastBufferWriter(16384);
+
+        for (int i = 0; i < itemsTowWrite; i++) {
+            writer.write(i);
+        }
+
+        writer.close();
+
+        CharBuffer firstBuffer = writer.getFirstBuffer();
+
+        assertNotNull(firstBuffer);
+
+        CharBuffer nextBuffer = firstBuffer.getNext();
+
+        assertNotNull(nextBuffer);
+        assertNull(nextBuffer.getNext());
+        assertTrue(firstBuffer.getUsedSize() == firstBuffer.getCacheSize());
+        assertTrue(nextBuffer.getUsedSize() < nextBuffer.getCacheSize());
+        firstBuffer.compact();
+        assertTrue(firstBuffer.getUsedSize() == firstBuffer.getCacheSize());
+        assertTrue(nextBuffer.getUsedSize() == nextBuffer.getCacheSize());
+
+        FastBufferReader reader = new FastBufferReader(firstBuffer);
+
+        for (int i = 0; i < itemsTowWrite; i++) {
+            assertEquals(i, reader.read());
+        }
+
+        reader.close();
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/javascript/JSMinTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/javascript/JSMinTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/javascript/JSMinTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,6 +18,9 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.ajax4jsf.javascript;
 
 import java.io.ByteArrayInputStream;
@@ -35,54 +38,53 @@
  */
 public class JSMinTest extends TestCase {
 
-	/**
-	 * @param name
-	 */
-	public JSMinTest(String name) {
-		super(name);
-	}
+    /**
+     * @param name
+     */
+    public JSMinTest(String name) {
+        super(name);
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#setUp()
-	 */
-	protected void setUp() throws Exception {
-		super.setUp();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-	/**
-	 * Test method for {@link org.ajax4jsf.javascript.JSMin#jsmin()}.
-	 * @throws UnterminatedStringLiteralException 
-	 * @throws UnterminatedCommentException 
-	 * @throws UnterminatedRegExpLiteralException 
-	 * @throws IOException 
-	 */
-	public void testJsmin() throws IOException, UnterminatedRegExpLiteralException, UnterminatedCommentException, UnterminatedStringLiteralException {
-		String script ="  patterns: {\n" + 
-				"    // combinators must be listed first\n" + 
-				"    // (and descendant needs to be last combinator)\n" + 
-				"    laterSibling: /^\\s*~\\s*/,\n" + 
-				"    child:        /^\\s*>\\s*/,\n" + 
-				"    adjacent:     /^\\s*\\+\\s*/,\n" + 
-				"    descendant:   /^\\s/,\n" + 
-				"\n" + 
-				"    // selectors follow\n" + 
-				"    tagName:      /^\\s*(\\*|[\\w\\-]+)(\\b|$)?/,\n" + 
-				"    id:           /^#([\\w\\-\\*]+)(\\b|$)/,\n" + 
-				"    className:    /^\\.([\\w\\-\\*]+)(\\b|$)/,\n" + 
-				"    pseudo:       /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\\((.*?)\\))?(\\b|$|\\s|(?=:))/,\n" + 
-				"    attrPresence: /^\\[([\\w]+)\\]/,\n" + 
-				"    attr:         /\\[((?:[\\w-]*:)?[\\w-]+)\\s*(?:([!^$*~|]?=)\\s*(([\'\"])([^\\]]*?)\\4|([^\'\"][^\\]]*?)))?\\]/\n" + 
-				"  }";
-		ByteArrayInputStream in = new ByteArrayInputStream(script.getBytes());
-		JSMin jsmin = new JSMin(in,System.out);
-		jsmin.jsmin();
-	}
+    /**
+     * Test method for {@link org.ajax4jsf.javascript.JSMin#jsmin()}.
+     * @throws UnterminatedStringLiteralException
+     * @throws UnterminatedCommentException
+     * @throws UnterminatedRegExpLiteralException
+     * @throws IOException
+     */
+    public void testJsmin()
+            throws IOException, UnterminatedRegExpLiteralException, UnterminatedCommentException,
+                   UnterminatedStringLiteralException {
+        String script =
+            "  patterns: {\n" + "    // combinators must be listed first\n"
+            + "    // (and descendant needs to be last combinator)\n" + "    laterSibling: /^\\s*~\\s*/,\n"
+            + "    child:        /^\\s*>\\s*/,\n" + "    adjacent:     /^\\s*\\+\\s*/,\n"
+            + "    descendant:   /^\\s/,\n" + "\n" + "    // selectors follow\n"
+            + "    tagName:      /^\\s*(\\*|[\\w\\-]+)(\\b|$)?/,\n" + "    id:           /^#([\\w\\-\\*]+)(\\b|$)/,\n"
+            + "    className:    /^\\.([\\w\\-\\*]+)(\\b|$)/,\n"
+            + "    pseudo:       /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\\((.*?)\\))?(\\b|$|\\s|(?=:))/,\n"
+            + "    attrPresence: /^\\[([\\w]+)\\]/,\n"
+            + "    attr:         /\\[((?:[\\w-]*:)?[\\w-]+)\\s*(?:([!^$*~|]?=)\\s*(([\'\"])([^\\]]*?)\\4|([^\'\"][^\\]]*?)))?\\]/\n"
+            + "  }";
+        ByteArrayInputStream in = new ByteArrayInputStream(script.getBytes());
+        JSMin jsmin = new JSMin(in, System.out);
 
+        jsmin.jsmin();
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/renderkit/RendererUtilsTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/renderkit/RendererUtilsTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/renderkit/RendererUtilsTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,6 +18,9 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.ajax4jsf.renderkit;
 
 import java.util.ArrayList;
@@ -36,131 +39,108 @@
  * @since 3.3.2
  */
 public class RendererUtilsTest extends TestCase {
+    public void testIsEmpty() throws Exception {
+        RendererUtils utils = RendererUtils.getInstance();
 
-	public void testIsEmpty() throws Exception {
-		RendererUtils utils = RendererUtils.getInstance();
-		
-		assertTrue(utils.isEmpty(null));
-		assertFalse(utils.isEmpty(new Object()));
-		assertFalse(utils.isEmpty(Boolean.FALSE));
-		assertFalse(utils.isEmpty(Long.valueOf(0)));
-		assertFalse(utils.isEmpty(Integer.valueOf(0)));
-		assertFalse(utils.isEmpty(Short.valueOf((short) 0)));
-		assertFalse(utils.isEmpty(Byte.valueOf((byte) 0)));
-		
-		assertTrue(utils.isEmpty(""));
-		assertFalse(utils.isEmpty("s"));
-		
-		assertTrue(utils.isEmpty(new ArrayList<Object>()));
-		assertTrue(utils.isEmpty(Collections.EMPTY_LIST));
-		
-		List<Object> testList = new ArrayList<Object>();
-		testList.add("x");
-		assertFalse(utils.isEmpty(testList));
+        assertTrue(utils.isEmpty(null));
+        assertFalse(utils.isEmpty(new Object()));
+        assertFalse(utils.isEmpty(Boolean.FALSE));
+        assertFalse(utils.isEmpty(Long.valueOf(0)));
+        assertFalse(utils.isEmpty(Integer.valueOf(0)));
+        assertFalse(utils.isEmpty(Short.valueOf((short) 0)));
+        assertFalse(utils.isEmpty(Byte.valueOf((byte) 0)));
+        assertTrue(utils.isEmpty(""));
+        assertFalse(utils.isEmpty("s"));
+        assertTrue(utils.isEmpty(new ArrayList<Object>()));
+        assertTrue(utils.isEmpty(Collections.EMPTY_LIST));
 
-		assertTrue(utils.isEmpty(new HashMap<String, Object>()));
-		assertTrue(utils.isEmpty(Collections.EMPTY_MAP));
+        List<Object> testList = new ArrayList<Object>();
 
-		Map<String, Object> testMap = new HashMap<String, Object>();
-		testMap.put("x", "y");
-		assertFalse(utils.isEmpty(testMap));
-		
-		assertTrue(utils.isEmpty(new Object[0]));
-		assertTrue(utils.isEmpty(new int[0]));
+        testList.add("x");
+        assertFalse(utils.isEmpty(testList));
+        assertTrue(utils.isEmpty(new HashMap<String, Object>()));
+        assertTrue(utils.isEmpty(Collections.EMPTY_MAP));
 
-		assertFalse(utils.isEmpty(new Object[1]));
-		assertFalse(utils.isEmpty(new int[1]));
-	}
-	
-	public void testScriptHashVariableWrapper() throws Exception {
-		assertEquals("abc", RendererUtils.ScriptHashVariableWrapper.DEFAULT.wrap("abc"));
+        Map<String, Object> testMap = new HashMap<String, Object>();
 
-		Object eventHandler = RendererUtils.ScriptHashVariableWrapper.EVENT_HANDLER.wrap("abc");
-		assertTrue(eventHandler instanceof JSFunctionDefinition);
+        testMap.put("x", "y");
+        assertFalse(utils.isEmpty(testMap));
+        assertTrue(utils.isEmpty(new Object[0]));
+        assertTrue(utils.isEmpty(new int[0]));
+        assertFalse(utils.isEmpty(new Object[1]));
+        assertFalse(utils.isEmpty(new int[1]));
+    }
 
-		JSFunctionDefinition handlerFunction = (JSFunctionDefinition) eventHandler;
-		assertEquals("function(event){abc}", handlerFunction.toScript().replaceAll("\\s", ""));
-	}
-	
-	public void testAddToScriptHash() throws Exception {
-		Map<String,Object> hash = new HashMap<String, Object>();
-		RendererUtils utils = RendererUtils.getInstance();
-		
-		utils.addToScriptHash(hash, "x", "y", null, null);
-		assertEquals("y", hash.get("x"));
-		
-		utils.addToScriptHash(hash, "y", "", null, null);
-		assertNull(hash.get("y"));
-		assertFalse(hash.containsKey("y"));
-		
-		utils.addToScriptHash(hash, "y1", null, null, null);
-		assertNull(hash.get("y1"));
-		assertFalse(hash.containsKey("y1"));
+    public void testScriptHashVariableWrapper() throws Exception {
+        assertEquals("abc", RendererUtils.ScriptHashVariableWrapper.DEFAULT.wrap("abc"));
 
-		utils.addToScriptHash(hash, "st", "server", "", null);
-		assertEquals("server", hash.get("st"));
+        Object eventHandler = RendererUtils.ScriptHashVariableWrapper.EVENT_HANDLER.wrap("abc");
 
-		utils.addToScriptHash(hash, "st1", "ajax", "ajax", null);
-		assertNull(hash.get("st1"));
-		assertFalse(hash.containsKey("st1"));
+        assertTrue(eventHandler instanceof JSFunctionDefinition);
 
-		utils.addToScriptHash(hash, "st2", "", "ajax", null);
-		assertNull(hash.get("st2"));
-		assertFalse(hash.containsKey("st2"));
-		
-		utils.addToScriptHash(hash, "null", null, "server", null);
-		assertNull(hash.get("null"));
-		assertFalse(hash.containsKey("null"));
+        JSFunctionDefinition handlerFunction = (JSFunctionDefinition) eventHandler;
 
-		utils.addToScriptHash(hash, "b", false, null, null);
-		assertNull(hash.get("b"));
-		assertFalse(hash.containsKey("b"));
-		
-		utils.addToScriptHash(hash, "b1", true, null, null);
-		assertEquals(Boolean.TRUE, hash.get("b1"));
-		
-		utils.addToScriptHash(hash, "b2", true, "true", null);
-		assertNull(hash.get("b2"));
-		assertFalse(hash.containsKey("b2"));
+        assertEquals("function(event){abc}", handlerFunction.toScript().replaceAll("\\s", ""));
+    }
 
-		utils.addToScriptHash(hash, "b3", false, "true", null);
-		assertEquals(Boolean.FALSE, hash.get("b3"));
-			
-		utils.addToScriptHash(hash, "b4", true, "false", null);
-		assertEquals(Boolean.TRUE, hash.get("b4"));
-		
-		utils.addToScriptHash(hash, "b5", false, "false", null);
-		assertNull(hash.get("b5"));
-		assertFalse(hash.containsKey("b5"));
-		
-		utils.addToScriptHash(hash, "i", Integer.valueOf(0), null, null);
-		assertEquals(Integer.valueOf(0), hash.get("i"));
-	
-		utils.addToScriptHash(hash, "i1", Integer.valueOf(0), "0", null);
-		assertNull(hash.get("i1"));
-		assertFalse(hash.containsKey("i1"));
+    public void testAddToScriptHash() throws Exception {
+        Map<String, Object> hash = new HashMap<String, Object>();
+        RendererUtils utils = RendererUtils.getInstance();
 
-		utils.addToScriptHash(hash, "i2", Integer.valueOf(0), "1", null);
-		assertEquals(Integer.valueOf(0), hash.get("i2"));
-	
-		utils.addToScriptHash(hash, "i3", Integer.MIN_VALUE, null, null);
-		assertNull(hash.get("i3"));
-		assertFalse(hash.containsKey("i3"));
-		
-		utils.addToScriptHash(hash, "i4", Integer.MIN_VALUE, "0", null);
-		assertNull(hash.get("i4"));
-		assertFalse(hash.containsKey("i4"));
-
-		utils.addToScriptHash(hash, "plain", "test", null, ScriptHashVariableWrapper.DEFAULT);
-		assertEquals("test", hash.get("plain"));
-		
-		utils.addToScriptHash(hash, "plain1", "newtest", "blank", ScriptHashVariableWrapper.DEFAULT);
-		assertEquals("newtest", hash.get("plain1"));
-		
-		utils.addToScriptHash(hash, "onclick", "alert(1)", null, ScriptHashVariableWrapper.EVENT_HANDLER);
-		assertTrue(hash.get("onclick") instanceof JSFunctionDefinition);
-
-		utils.addToScriptHash(hash, "onclick1", "alert(1)", "no-val", ScriptHashVariableWrapper.EVENT_HANDLER);
-		assertTrue(hash.get("onclick1") instanceof JSFunctionDefinition);
-	}
+        utils.addToScriptHash(hash, "x", "y", null, null);
+        assertEquals("y", hash.get("x"));
+        utils.addToScriptHash(hash, "y", "", null, null);
+        assertNull(hash.get("y"));
+        assertFalse(hash.containsKey("y"));
+        utils.addToScriptHash(hash, "y1", null, null, null);
+        assertNull(hash.get("y1"));
+        assertFalse(hash.containsKey("y1"));
+        utils.addToScriptHash(hash, "st", "server", "", null);
+        assertEquals("server", hash.get("st"));
+        utils.addToScriptHash(hash, "st1", "ajax", "ajax", null);
+        assertNull(hash.get("st1"));
+        assertFalse(hash.containsKey("st1"));
+        utils.addToScriptHash(hash, "st2", "", "ajax", null);
+        assertNull(hash.get("st2"));
+        assertFalse(hash.containsKey("st2"));
+        utils.addToScriptHash(hash, "null", null, "server", null);
+        assertNull(hash.get("null"));
+        assertFalse(hash.containsKey("null"));
+        utils.addToScriptHash(hash, "b", false, null, null);
+        assertNull(hash.get("b"));
+        assertFalse(hash.containsKey("b"));
+        utils.addToScriptHash(hash, "b1", true, null, null);
+        assertEquals(Boolean.TRUE, hash.get("b1"));
+        utils.addToScriptHash(hash, "b2", true, "true", null);
+        assertNull(hash.get("b2"));
+        assertFalse(hash.containsKey("b2"));
+        utils.addToScriptHash(hash, "b3", false, "true", null);
+        assertEquals(Boolean.FALSE, hash.get("b3"));
+        utils.addToScriptHash(hash, "b4", true, "false", null);
+        assertEquals(Boolean.TRUE, hash.get("b4"));
+        utils.addToScriptHash(hash, "b5", false, "false", null);
+        assertNull(hash.get("b5"));
+        assertFalse(hash.containsKey("b5"));
+        utils.addToScriptHash(hash, "i", Integer.valueOf(0), null, null);
+        assertEquals(Integer.valueOf(0), hash.get("i"));
+        utils.addToScriptHash(hash, "i1", Integer.valueOf(0), "0", null);
+        assertNull(hash.get("i1"));
+        assertFalse(hash.containsKey("i1"));
+        utils.addToScriptHash(hash, "i2", Integer.valueOf(0), "1", null);
+        assertEquals(Integer.valueOf(0), hash.get("i2"));
+        utils.addToScriptHash(hash, "i3", Integer.MIN_VALUE, null, null);
+        assertNull(hash.get("i3"));
+        assertFalse(hash.containsKey("i3"));
+        utils.addToScriptHash(hash, "i4", Integer.MIN_VALUE, "0", null);
+        assertNull(hash.get("i4"));
+        assertFalse(hash.containsKey("i4"));
+        utils.addToScriptHash(hash, "plain", "test", null, ScriptHashVariableWrapper.DEFAULT);
+        assertEquals("test", hash.get("plain"));
+        utils.addToScriptHash(hash, "plain1", "newtest", "blank", ScriptHashVariableWrapper.DEFAULT);
+        assertEquals("newtest", hash.get("plain1"));
+        utils.addToScriptHash(hash, "onclick", "alert(1)", null, ScriptHashVariableWrapper.EVENT_HANDLER);
+        assertTrue(hash.get("onclick") instanceof JSFunctionDefinition);
+        utils.addToScriptHash(hash, "onclick1", "alert(1)", "no-val", ScriptHashVariableWrapper.EVENT_HANDLER);
+        assertTrue(hash.get("onclick1") instanceof JSFunctionDefinition);
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/resource/cached/DualLRUMapTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/resource/cached/DualLRUMapTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/resource/cached/DualLRUMapTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.ajax4jsf.resource.cached;
 
 import junit.framework.TestCase;
@@ -27,52 +29,41 @@
  * @author Nick Belaevski
  * @since 3.3.0
  */
-
 public class DualLRUMapTest extends TestCase {
+    public void testBasic() throws Exception {
+        DualLRUMap<String, String> map = new DualLRUMap<String, String>(16);
 
-	public void testBasic() throws Exception {
-		DualLRUMap<String, String> map = new DualLRUMap<String, String>(16);
-		
-		map.put("1", "a");
-		map.put("2", "b");
-		map.put("3", "c");
-		
-		assertEquals("a", map.get("1"));
-		assertEquals("b", map.get("2"));
-		assertEquals("c", map.get("3"));
+        map.put("1", "a");
+        map.put("2", "b");
+        map.put("3", "c");
+        assertEquals("a", map.get("1"));
+        assertEquals("b", map.get("2"));
+        assertEquals("c", map.get("3"));
+        assertEquals("1", map.getKey("a"));
+        assertEquals("2", map.getKey("b"));
+        assertEquals("3", map.getKey("c"));
+        assertTrue(map.containsKey("1"));
+        assertTrue(map.containsValue("a"));
+        assertTrue(map.containsKey("2"));
+        assertTrue(map.containsValue("b"));
+        assertTrue(map.containsKey("3"));
+        assertTrue(map.containsValue("c"));
+        map.remove("2");
+        assertNull(map.get("2"));
+        assertNull(map.getKey("b"));
+        assertFalse(map.containsKey("2"));
+        assertFalse(map.containsValue("b"));
+    }
 
-		assertEquals("1", map.getKey("a"));
-		assertEquals("2", map.getKey("b"));
-		assertEquals("3", map.getKey("c"));
+    public void testRemoveEldest() throws Exception {
+        DualLRUMap<String, String> map = new DualLRUMap<String, String>(2);
 
-		assertTrue(map.containsKey("1"));
-		assertTrue(map.containsValue("a"));
-		assertTrue(map.containsKey("2"));
-		assertTrue(map.containsValue("b"));
-		assertTrue(map.containsKey("3"));
-		assertTrue(map.containsValue("c"));
-		
-		map.remove("2");
-		assertNull(map.get("2"));
-		assertNull(map.getKey("b"));
-
-		assertFalse(map.containsKey("2"));
-		assertFalse(map.containsValue("b"));
-	}
-	
-	public void testRemoveEldest() throws Exception {
-		DualLRUMap<String,String> map = new DualLRUMap<String, String>(2);
-		
-		map.put("1", "a");
-		map.put("2", "b");
-	
-		assertNotNull(map.get("2"));
-		assertNotNull(map.get("1"));
-		
-		map.put("3", "c");
-		
-		assertNull(map.get("2"));
-		assertNull(map.getKey("b"));
-	}
-
+        map.put("1", "a");
+        map.put("2", "b");
+        assertNotNull(map.get("2"));
+        assertNotNull(map.get("1"));
+        map.put("3", "c");
+        assertNull(map.get("2"));
+        assertNull(map.getKey("b"));
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/util/LRUMapTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/util/LRUMapTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/util/LRUMapTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,6 +18,9 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.ajax4jsf.util;
 
 import java.util.Iterator;
@@ -31,84 +34,99 @@
  */
 public class LRUMapTest extends TestCase {
 
-	/**
-	 * @param name
-	 */
-	public LRUMapTest(String name) {
-		super(name);
-	}
+    /**
+     * @param name
+     */
+    public LRUMapTest(String name) {
+        super(name);
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#setUp()
-	 */
-	protected void setUp() throws Exception {
-		super.setUp();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-	/**
-	 * Test method for {@link org.ajax4jsf.util.LRUMap#LRUMap(int)}.
-	 */
-	public void testLRUMap() {
-		LRUMap map = new LRUMap(5);
-		for (int i = 0; i < 10; i++) {
-			map.put(new Integer(i), "Val"+(new Integer(i)));
-		}
-		assertEquals(map.size(), 5);
-	}
+    /**
+     * Test method for {@link org.ajax4jsf.util.LRUMap#LRUMap(int)}.
+     */
+    public void testLRUMap() {
+        LRUMap map = new LRUMap(5);
 
-	/**
-	 * Test method for {@link org.ajax4jsf.util.LRUMap#removeEldestEntry(java.util.Map.Entry)}.
-	 */
-	public void testRemoveEldestEntryEntry() {
-		
-		LRUMap map = new LRUMap(5){
-			protected boolean removeEldestEntry(Entry arg0) {
-				boolean eldestEntry = super.removeEldestEntry(arg0);
-				assertTrue(eldestEntry ^ size()<=5);
-				return false;
-			}
-		};
-		for (int i = 0; i < 10; i++) {
-			map.put(new Integer(i), "Val"+(new Integer(i)));
-		}
-	}
+        for (int i = 0; i < 10; i++) {
+            map.put(new Integer(i), "Val" + (new Integer(i)));
+        }
 
-	/**
-	 * Test method for {@link java.util.HashMap#put(K, V)}.
-	 */
-	public void testPut() {
-		LRUMap map = new LRUMap(5);
-		for (int i = 0; i < 10; i++) {
-			map.put(new Integer(i), "Val"+(new Integer(i)));
-		}
-		assertEquals(map.size(), 5);
-		Iterator iterator = map.values().iterator();
-		for (int i = 5; i < 10; i++) {
-			assertTrue(iterator.hasNext());
-			assertEquals("Val"+(new Integer(i)), iterator.next());
-		}
-		assertFalse(iterator.hasNext());
-	}
+        assertEquals(map.size(), 5);
+    }
 
-	public void testGetMostRecent() throws Exception {
-		LRUMap map = new LRUMap(5);
-		for (int i = 0; i < 10; i++) {
-			String last = "Val"+(new Integer(i));
-			map.put(new Integer(i), last);
-			assertSame(last, map.getMostRecent());
-		}
-		assertEquals(map.size(), 5);
-		for (int i = 5; i < 10; i++) {
-			Object lastGet = map.get(new Integer(i));
-			assertSame(lastGet, map.getMostRecent());
-		}
-		
-	}
+    /**
+     * Test method for {@link org.ajax4jsf.util.LRUMap#removeEldestEntry(java.util.Map.Entry)}.
+     */
+    public void testRemoveEldestEntryEntry() {
+        LRUMap map = new LRUMap(5) {
+            protected boolean removeEldestEntry(Entry arg0) {
+                boolean eldestEntry = super.removeEldestEntry(arg0);
+
+                assertTrue(eldestEntry ^ size() <= 5);
+
+                return false;
+            }
+        };
+
+        for (int i = 0; i < 10; i++) {
+            map.put(new Integer(i), "Val" + (new Integer(i)));
+        }
+    }
+
+    /**
+     * Test method for {@link java.util.HashMap#put(K, V)}.
+     */
+    public void testPut() {
+        LRUMap map = new LRUMap(5);
+
+        for (int i = 0; i < 10; i++) {
+            map.put(new Integer(i), "Val" + (new Integer(i)));
+        }
+
+        assertEquals(map.size(), 5);
+
+        Iterator iterator = map.values().iterator();
+
+        for (int i = 5; i < 10; i++) {
+            assertTrue(iterator.hasNext());
+            assertEquals("Val" + (new Integer(i)), iterator.next());
+        }
+
+        assertFalse(iterator.hasNext());
+    }
+
+    public void testGetMostRecent() throws Exception {
+        LRUMap map = new LRUMap(5);
+
+        for (int i = 0; i < 10; i++) {
+            String last = "Val" + (new Integer(i));
+
+            map.put(new Integer(i), last);
+            assertSame(last, map.getMostRecent());
+        }
+
+        assertEquals(map.size(), 5);
+
+        for (int i = 5; i < 10; i++) {
+            Object lastGet = map.get(new Integer(i));
+
+            assertSame(lastGet, map.getMostRecent());
+        }
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/util/NumericStreamsTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/util/NumericStreamsTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/util/NumericStreamsTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.ajax4jsf.util;
 
 import java.awt.Color;
@@ -29,47 +31,44 @@
  * @author Nick Belaevski
  * @since 4.0
  */
-
 public class NumericStreamsTest extends TestCase {
+    public void testByte() throws Exception {
+        byte[] bytes = new NumericDataOutputStream().writeByte((byte) 0xDF).writeByte((byte) 0x90).writeByte(
+                           (byte) 0xAA).getBytes();
+        NumericDataInputStream inputStream = new NumericDataInputStream(bytes);
 
-	public void testByte() throws Exception {
-		byte[] bytes = new NumericDataOutputStream().writeByte((byte) 0xDF).writeByte((byte) 0x90).
-			writeByte((byte) 0xAA).getBytes();
+        assertEquals((byte) 0xDF, inputStream.readByte());
+        assertEquals((byte) 0x90, inputStream.readByte());
+        assertEquals((byte) 0xAA, inputStream.readByte());
+    }
 
-		NumericDataInputStream inputStream = new NumericDataInputStream(bytes);
-		assertEquals((byte) 0xDF, inputStream.readByte());
-		assertEquals((byte) 0x90, inputStream.readByte());
-		assertEquals((byte) 0xAA, inputStream.readByte());
-	}
+    public void testShort() throws Exception {
+        byte[] bytes = new NumericDataOutputStream().writeShort((short) 0xA7DF).writeShort((short) 0xFE90).writeShort(
+                           (short) 0x34AA).getBytes();
+        NumericDataInputStream inputStream = new NumericDataInputStream(bytes);
 
-	public void testShort() throws Exception {
-		byte[] bytes = new NumericDataOutputStream().writeShort((short) 0xA7DF).writeShort((short) 0xFE90).
-			writeShort((short) 0x34AA).getBytes();
+        assertEquals((short) 0xA7DF, inputStream.readShort());
+        assertEquals((short) 0xFE90, inputStream.readShort());
+        assertEquals((short) 0x34AA, inputStream.readShort());
+    }
 
-		NumericDataInputStream inputStream = new NumericDataInputStream(bytes);
-		assertEquals((short) 0xA7DF, inputStream.readShort());
-		assertEquals((short) 0xFE90, inputStream.readShort());
-		assertEquals((short) 0x34AA, inputStream.readShort());
-	}
-	
-	public void testColor() throws Exception {
-		byte[] bytes = new NumericDataOutputStream().writeColor(new Color(0xA7DFE0)).
-			writeIntColor(0xE2349A).writeColor(new Color(0x4812F9)).getBytes();
-		
-		NumericDataInputStream inputStream = new NumericDataInputStream(bytes);
-		assertEquals(0xA7DFE0, inputStream.readIntColor());
-		assertEquals(new Color(0xE2349A), inputStream.readColor());
-		assertEquals(0x4812F9, inputStream.readIntColor());
-	}
-	
-	public void testInt() throws Exception {
-		byte[] bytes = new NumericDataOutputStream().writeInt(0x12A7DFE0).writeInt(0x67E2349A).
-			writeInt(0xBD4812F9).getBytes();
-		
-		NumericDataInputStream inputStream = new NumericDataInputStream(bytes);
-		assertEquals(0x12A7DFE0, inputStream.readInt());
-		assertEquals(0x67E2349A, inputStream.readInt());
-		assertEquals(0xBD4812F9, inputStream.readInt());
-	}
+    public void testColor() throws Exception {
+        byte[] bytes = new NumericDataOutputStream().writeColor(new Color(0xA7DFE0)).writeIntColor(0xE2349A).writeColor(
+                           new Color(0x4812F9)).getBytes();
+        NumericDataInputStream inputStream = new NumericDataInputStream(bytes);
 
+        assertEquals(0xA7DFE0, inputStream.readIntColor());
+        assertEquals(new Color(0xE2349A), inputStream.readColor());
+        assertEquals(0x4812F9, inputStream.readIntColor());
+    }
+
+    public void testInt() throws Exception {
+        byte[] bytes =
+            new NumericDataOutputStream().writeInt(0x12A7DFE0).writeInt(0x67E2349A).writeInt(0xBD4812F9).getBytes();
+        NumericDataInputStream inputStream = new NumericDataInputStream(bytes);
+
+        assertEquals(0x12A7DFE0, inputStream.readInt());
+        assertEquals(0x67E2349A, inputStream.readInt());
+        assertEquals(0xBD4812F9, inputStream.readInt());
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,107 +19,102 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.component;
 
 import org.richfaces.test.AbstractFacesTest;
 
-
 public class UIRangedNumberInputTest extends AbstractFacesTest {
+    private UIRangedNumberInput input;
 
-	private UIRangedNumberInput input;
-	
-	public void setUp() throws Exception {
-		super.setUp();
-		setupFacesRequest();
-		
-		input = new UIRangedNumberInput() {
-			private String minValue;
-			private String maxValue;
-			private boolean disabled;
-			
-			public String getMinValue() {
-				return minValue;
-			}
-			public void setMinValue(String minValue) {
-				this.minValue = minValue;
-			}
-			public String getMaxValue() {
-				return maxValue;
-			}
-			public void setMaxValue(String maxValue) {
-				this.maxValue = maxValue;
-			}
-			public boolean isDisabled() {
-				return disabled;
-			}
-			public void setDisabled(boolean disabled) {
-				this.disabled = disabled;
-			}
-		};
+    public void setUp() throws Exception {
+        super.setUp();
+        setupFacesRequest();
+        input = new UIRangedNumberInput() {
+            private String minValue;
+            private String maxValue;
+            private boolean disabled;
+            public String getMinValue() {
+                return minValue;
+            }
+            public void setMinValue(String minValue) {
+                this.minValue = minValue;
+            }
+            public String getMaxValue() {
+                return maxValue;
+            }
+            public void setMaxValue(String maxValue) {
+                this.maxValue = maxValue;
+            }
+            public boolean isDisabled() {
+                return disabled;
+            }
+            public void setDisabled(boolean disabled) {
+                this.disabled = disabled;
+            }
+        };
+        input.setMaxValue("100");
+        input.setMinValue("0");
+        input.setValid(true);
+    }
 
-		input.setMaxValue("100");
-		input.setMinValue("0");
-		input.setValid(true);
-	}
+    public void tearDown() throws Exception {
+        super.tearDown();
+        this.input = null;
+    }
 
-	public void tearDown() throws Exception {
-		super.tearDown();
+    private void checkValid() {
+        assertTrue(input.isValid());
+        assertFalse(facesContext.getMessages().hasNext());
+    }
 
-		this.input = null;
-	}
+    private void checkInvalid() {
+        assertFalse(input.isValid());
+        assertTrue(facesContext.getMessages().hasNext());
+    }
 
-	private void checkValid() {
-		assertTrue(input.isValid());
-		assertFalse(facesContext.getMessages().hasNext());
-	}
-	
-	private void checkInvalid() {
-		assertFalse(input.isValid());
-		assertTrue(facesContext.getMessages().hasNext());
-	}
+    public void testValidateValueFacesContextObject() {
+        checkValid();
+        input.validateValue(facesContext, new Double(23.45));
+        checkValid();
+    }
 
-	public void testValidateValueFacesContextObject() {
-		checkValid();
-		input.validateValue(facesContext, new Double(23.45));
-		checkValid();
-	}
+    public void testValidateNullValue() throws Exception {
+        checkValid();
+        input.validateValue(facesContext, null);
+        checkValid();
+    }
 
-	public void testValidateNullValue() throws Exception {
-		checkValid();
-		input.validateValue(facesContext, null);
-		checkValid();
-	}
+    public void testValidateMinValue() throws Exception {
+        checkValid();
+        input.validateValue(facesContext, new Double(-23.45));
+        checkInvalid();
+    }
 
-	public void testValidateMinValue() throws Exception {
-		checkValid();
-		input.validateValue(facesContext, new Double(-23.45));
-		checkInvalid();
-	}
+    public void testValidateMaxValue() throws Exception {
+        checkValid();
+        input.validateValue(facesContext, new Double(223.45));
+        checkInvalid();
+    }
 
-	public void testValidateMaxValue() throws Exception {
-		checkValid();
-		input.validateValue(facesContext, new Double(223.45));
-		checkInvalid();
-	}
+    public void testValidateMinNullMinValue() throws Exception {
+        input.setMinValue(null);
+        checkValid();
+        input.validateValue(facesContext, new Double(-23.45));
+        checkInvalid();
+    }
 
+    public void testValidateMaxNullMaxValue() throws Exception {
+        input.setMaxValue(null);
+        checkValid();
+        input.validateValue(facesContext, new Double(223.45));
+        checkInvalid();
+    }
 
-	public void testValidateMinNullMinValue() throws Exception {
-		input.setMinValue(null);
-		checkValid();
-		input.validateValue(facesContext, new Double(-23.45));
-		checkInvalid();
-	}
-
-	public void testValidateMaxNullMaxValue() throws Exception {
-		input.setMaxValue(null);
-		checkValid();
-		input.validateValue(facesContext, new Double(223.45));
-		checkInvalid();
-	}
-
-	public void testValidateIllegalValue() throws Exception {
-		checkValid();
-		input.validateValue(facesContext, "string");
-		checkInvalid();
-	}
+    public void testValidateIllegalValue() throws Exception {
+        checkValid();
+        input.validateValue(facesContext, "string");
+        checkInvalid();
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/component/nsutils/NSUtilsTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/component/nsutils/NSUtilsTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/component/nsutils/NSUtilsTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.component.nsutils;
 
 import java.io.StringWriter;
@@ -29,32 +31,31 @@
 import org.richfaces.test.AbstractFacesTest;
 
 public class NSUtilsTest extends AbstractFacesTest {
+    public void setUp() throws Exception {
+        super.setUp();
+        setupFacesRequest();
+    }
 
-	public void setUp() throws Exception {
-		super.setUp();
-		setupFacesRequest();
-	}
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-	public void tearDown() throws Exception {
-		super.tearDown();
-	}
+    public void testWriteNameSpace() throws Exception {
+        final StringWriter stringWriter = new StringWriter();
+        ResponseWriter writer = facesContext.getRenderKit().createResponseWriter(stringWriter, "text/html", "UTF-8");
 
-	public void testWriteNameSpace() throws Exception {
-		final StringWriter stringWriter = new StringWriter();
-		ResponseWriter writer = facesContext.getRenderKit().createResponseWriter(stringWriter, "text/html", "UTF-8");
-		facesContext.setResponseWriter(writer);
-		
-		UIInput input = new UIInput();
-		
-		writer.startDocument();
-		writer.startElement("span", input);
-		
-		NSUtils.writeNameSpace(facesContext, input);
-		
-		writer.endElement("span");
-		writer.endDocument();
+        facesContext.setResponseWriter(writer);
 
-		String result = stringWriter.getBuffer().toString();
-		assertTrue(result.contains("span xmlns:rich=\"http://richfaces.ajax4jsf.org/rich\""));
-	}
+        UIInput input = new UIInput();
+
+        writer.startDocument();
+        writer.startElement("span", input);
+        NSUtils.writeNameSpace(facesContext, input);
+        writer.endElement("span");
+        writer.endDocument();
+
+        String result = stringWriter.getBuffer().toString();
+
+        assertTrue(result.contains("span xmlns:rich=\"http://richfaces.ajax4jsf.org/rich\""));
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/component/util/ComponentUtilTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/component/util/ComponentUtilTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/component/util/ComponentUtilTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -18,6 +18,9 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
+
+
+
 package org.richfaces.component.util;
 
 import java.util.ArrayList;
@@ -34,53 +37,57 @@
  *
  */
 public class ComponentUtilTest extends TestCase {
+    public void testAsArray() {
+        assertNull(ComponentUtil.asArray(null));
+    }
 
-	public void testAsArray() {
-		assertNull(ComponentUtil.asArray(null));
-	}
+    public void testAsArray1() {
+        String[] strings = new String[] {"a", "b"};
+        String[] array = ComponentUtil.asArray(strings);
 
-	public void testAsArray1() {
-		String[] strings = new String[] {"a", "b"};
-		String[] array = ComponentUtil.asArray(strings);
-		assertSame(strings, array);
-	}
+        assertSame(strings, array);
+    }
 
-	public void testAsArray2() {
-		Object[] objects = new Object[] {
-			Integer.valueOf(12), null, Integer.valueOf(22), Integer.valueOf(42)
-		};
-		String[] array = ComponentUtil.asArray(objects);
-		String[] etalon = new String[] {"12", null, "22", "42"};
-		assertTrue(Arrays.equals(etalon, array));
-	}
+    public void testAsArray2() {
+        Object[] objects = new Object[] {Integer.valueOf(12), null, Integer.valueOf(22), Integer.valueOf(42)};
+        String[] array = ComponentUtil.asArray(objects);
+        String[] etalon = new String[] {"12", null, "22", "42"};
 
-	public void testAsArray3() {
-		ArrayList list = new ArrayList();
-		list.add(new Integer(12));
-		list.add(null);
-		list.add(new Integer(22));
-		list.add(new Integer(42));
+        assertTrue(Arrays.equals(etalon, array));
+    }
 
-		String[] array = ComponentUtil.asArray(list);
-		String[] etalon = new String[] {"12", null, "22", "42"};
-		assertTrue(Arrays.equals(etalon, array));
-	}
+    public void testAsArray3() {
+        ArrayList list = new ArrayList();
 
-	public void testAsArray31() {
-		Set set = new TreeSet();
-		set.add(new Integer(12));
-		set.add(new Integer(22));
-		set.add(new Integer(42));
+        list.add(new Integer(12));
+        list.add(null);
+        list.add(new Integer(22));
+        list.add(new Integer(42));
 
-		String[] array = ComponentUtil.asArray(set);
-		String[] etalon = new String[] {"12", "22", "42"};
-		assertTrue(Arrays.equals(etalon, array));
-	}
+        String[] array = ComponentUtil.asArray(list);
+        String[] etalon = new String[] {"12", null, "22", "42"};
 
-	public void testAsArray4() {
-		String string = " a , \t\n b  \n , c ";
-		String[] strings = ComponentUtil.asArray(string);
-		String[] etalon = new String[] {"a", "b", "c"};
-		assertTrue(Arrays.equals(etalon, strings));
-	}
-}
\ No newline at end of file
+        assertTrue(Arrays.equals(etalon, array));
+    }
+
+    public void testAsArray31() {
+        Set set = new TreeSet();
+
+        set.add(new Integer(12));
+        set.add(new Integer(22));
+        set.add(new Integer(42));
+
+        String[] array = ComponentUtil.asArray(set);
+        String[] etalon = new String[] {"12", "22", "42"};
+
+        assertTrue(Arrays.equals(etalon, array));
+    }
+
+    public void testAsArray4() {
+        String string = " a , \t\n b  \n , c ";
+        String[] strings = ComponentUtil.asArray(string);
+        String[] etalon = new String[] {"a", "b", "c"};
+
+        assertTrue(Arrays.equals(etalon, strings));
+    }
+}

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/component/util/FormUtilTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/component/util/FormUtilTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/component/util/FormUtilTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.component.util;
 
 import javax.faces.component.UIComponent;
@@ -32,54 +34,50 @@
 /**
  * @author Nick Belaevski - nbelaevski at exadel.com
  * created 11.04.2007
- * 
+ *
  */
 public class FormUtilTest extends AbstractFacesTest {
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        setupFacesRequest();
+    }
 
-	@Override
-	public void setUp() throws Exception {
-		super.setUp();
-		setupFacesRequest();
-	}
-	
-	@Override
-	public void tearDown() throws Exception {
-		super.tearDown();
-	}
-	
-	public void testThrowEnclFormReqExceptionIfNeed() throws Exception {
-		UIViewRoot viewRoot = facesContext.getViewRoot();
-		UIComponent form = application.createComponent(UIForm.COMPONENT_TYPE);
-		viewRoot.getChildren().add(form);
-		
-		UIComponent testComponent = application.createComponent(UIOutput.COMPONENT_TYPE);
-		form.getChildren().add(testComponent);
-		
-		FormUtil.throwEnclFormReqExceptionIfNeed(facesContext, testComponent);
-	}
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-	public void testThrowEnclFormReqExceptionIfNeedNoForm() throws Exception {
-		UIViewRoot viewRoot = facesContext.getViewRoot();
+    public void testThrowEnclFormReqExceptionIfNeed() throws Exception {
+        UIViewRoot viewRoot = facesContext.getViewRoot();
+        UIComponent form = application.createComponent(UIForm.COMPONENT_TYPE);
 
-		UIComponent testComponent = application.createComponent(UIOutput.COMPONENT_TYPE);
-		viewRoot.getChildren().add(testComponent);
-		
-		try {
-			FormUtil.throwEnclFormReqExceptionIfNeed(facesContext, testComponent);
+        viewRoot.getChildren().add(form);
 
-			fail();
-		} catch (EnclosingFormRequiredException e) {
+        UIComponent testComponent = application.createComponent(UIOutput.COMPONENT_TYPE);
 
-		}
-	}
+        form.getChildren().add(testComponent);
+        FormUtil.throwEnclFormReqExceptionIfNeed(facesContext, testComponent);
+    }
 
-	public void testThrowEnclFormReqExceptionIfNeedClient() throws Exception {
-		UIViewRoot viewRoot = facesContext.getViewRoot();
-		
-		UIComponent testComponent = application.createComponent(UIOutput.COMPONENT_TYPE);
-		testComponent.getAttributes().put("switchType", "CLIENT");
-		viewRoot.getChildren().add(testComponent);
-		
-		FormUtil.throwEnclFormReqExceptionIfNeed(facesContext, testComponent);
-	}
+    public void testThrowEnclFormReqExceptionIfNeedNoForm() throws Exception {
+        UIViewRoot viewRoot = facesContext.getViewRoot();
+        UIComponent testComponent = application.createComponent(UIOutput.COMPONENT_TYPE);
+
+        viewRoot.getChildren().add(testComponent);
+
+        try {
+            FormUtil.throwEnclFormReqExceptionIfNeed(facesContext, testComponent);
+            fail();
+        } catch (EnclosingFormRequiredException e) {}
+    }
+
+    public void testThrowEnclFormReqExceptionIfNeedClient() throws Exception {
+        UIViewRoot viewRoot = facesContext.getViewRoot();
+        UIComponent testComponent = application.createComponent(UIOutput.COMPONENT_TYPE);
+
+        testComponent.getAttributes().put("switchType", "CLIENT");
+        viewRoot.getChildren().add(testComponent);
+        FormUtil.throwEnclFormReqExceptionIfNeed(facesContext, testComponent);
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/component/util/HtmlUtilTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/component/util/HtmlUtilTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.component.util;
 
 import javax.faces.component.UIComponent;
@@ -30,83 +32,81 @@
 /**
  * @author Nick Belaevski - nbelaevski at exadel.com
  * created 11.04.2007
- * 
+ *
  */
 public class HtmlUtilTest extends TestCase {
-	
-	public HtmlUtilTest(String name) {
-		super(name);
-	}
-	
-	public void setUp() throws Exception {
-		super.setUp();
-	}
-	
-	public void tearDown() throws Exception {
-		super.tearDown();
-	}
-	
-	public void testQualifySize() throws Exception {
-		assertEquals("", HtmlUtil.qualifySize(""));
+    public HtmlUtilTest(String name) {
+        super(name);
+    }
 
-		assertEquals("100px", HtmlUtil.qualifySize("100px"));
-		assertEquals("100px", HtmlUtil.qualifySize("100"));
-		assertEquals("100pt", HtmlUtil.qualifySize("100pt"));
+    public void setUp() throws Exception {
+        super.setUp();
+    }
 
-		assertEquals("100in", HtmlUtil.qualifySize("100in"));
-		assertEquals("100cm", HtmlUtil.qualifySize("100cm"));
-		assertEquals("100em", HtmlUtil.qualifySize("100em"));
-		assertEquals("100%", HtmlUtil.qualifySize("100%"));
-	}
-	
-	public void testAddToSize() throws Exception {
-		assertEquals("120px", HtmlUtil.addToSize("100", "20px"));
-		assertEquals("120px", HtmlUtil.addToSize("100px", "20"));
-		assertEquals("120px", HtmlUtil.addToSize("100", "20"));
-		assertEquals("120px", HtmlUtil.addToSize("100px", "20px"));
-	}
-	
-	public void testExpandIdSelector() {
-		String selector = ".class_form+#-Test .class2 #_aaaa";
-		
-		UIComponent component = new UIComponentBase() {
-			public String getFamily() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-			public UIComponent findComponent(String expr) {
-				if ("-Test".equals(expr)) {
-					return new UIComponentBase() {
-						public String getClientId(FacesContext context) {
-							return "component1";
-						}
-						public String getFamily() {
-							// TODO Auto-generated method stub
-							return null;
-						}
-					};
-				} else if ("_aaaa".equals(expr)) {
-					return new UIComponentBase() {
-						public String getClientId(FacesContext context) {
-							return "component2";
-						}
-						public String getFamily() {
-							// TODO Auto-generated method stub
-							return null;
-						}
-					};
-				}
-				
-				return null;
-			}
-		};
-		
-		String string = 
-			HtmlUtil.expandIdSelector(selector, component, null);
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-		assertEquals(".class_form+#component1 .class2 #component2", string);
-		
-		String s = ".class_form+.component1 .class2 #1component2";
-		assertEquals(s, HtmlUtil.expandIdSelector(s, component, null));
-	}
+    public void testQualifySize() throws Exception {
+        assertEquals("", HtmlUtil.qualifySize(""));
+        assertEquals("100px", HtmlUtil.qualifySize("100px"));
+        assertEquals("100px", HtmlUtil.qualifySize("100"));
+        assertEquals("100pt", HtmlUtil.qualifySize("100pt"));
+        assertEquals("100in", HtmlUtil.qualifySize("100in"));
+        assertEquals("100cm", HtmlUtil.qualifySize("100cm"));
+        assertEquals("100em", HtmlUtil.qualifySize("100em"));
+        assertEquals("100%", HtmlUtil.qualifySize("100%"));
+    }
+
+    public void testAddToSize() throws Exception {
+        assertEquals("120px", HtmlUtil.addToSize("100", "20px"));
+        assertEquals("120px", HtmlUtil.addToSize("100px", "20"));
+        assertEquals("120px", HtmlUtil.addToSize("100", "20"));
+        assertEquals("120px", HtmlUtil.addToSize("100px", "20px"));
+    }
+
+    public void testExpandIdSelector() {
+        String selector = ".class_form+#-Test .class2 #_aaaa";
+        UIComponent component = new UIComponentBase() {
+            public String getFamily() {
+
+                // TODO Auto-generated method stub
+                return null;
+            }
+            public UIComponent findComponent(String expr) {
+                if ("-Test".equals(expr)) {
+                    return new UIComponentBase() {
+                        public String getClientId(FacesContext context) {
+                            return "component1";
+                        }
+                        public String getFamily() {
+
+                            // TODO Auto-generated method stub
+                            return null;
+                        }
+                    };
+                } else if ("_aaaa".equals(expr)) {
+                    return new UIComponentBase() {
+                        public String getClientId(FacesContext context) {
+                            return "component2";
+                        }
+                        public String getFamily() {
+
+                            // TODO Auto-generated method stub
+                            return null;
+                        }
+                    };
+                }
+
+                return null;
+            }
+        };
+        String string = HtmlUtil.expandIdSelector(selector, component, null);
+
+        assertEquals(".class_form+#component1 .class2 #component2", string);
+
+        String s = ".class_form+.component1 .class2 #1component2";
+
+        assertEquals(s, HtmlUtil.expandIdSelector(s, component, null));
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/javascript/QUnitTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/javascript/QUnitTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/javascript/QUnitTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,11 +19,14 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.javascript;
 
 import static org.junit.Assert.fail;
 
 import java.net.URL;
+
 import java.util.Iterator;
 
 import org.junit.After;
@@ -41,14 +44,13 @@
  * @author Konstantin Mishin
  */
 public class QUnitTest {
-
     private WebClient webClient_;
 
     @Before
     public void setUp() {
-    	webClient_ = new WebClient();
+        webClient_ = new WebClient();
     }
-    
+
     @After
     public void tearDown() {
         webClient_.closeAllWindows();
@@ -60,33 +62,45 @@
         HtmlElement doc = page.getDocumentElement();
         HtmlElement tests = (HtmlElement) doc.getElementById("tests");
         Iterator<HtmlElement> iter = tests.getChildElements().iterator();
+
         if (!iter.hasNext()) {
             fail("No result found");
         }
+
         StringBuilder sb = new StringBuilder();
-		int i = 1;
-		while (iter.hasNext()) {
+        int i = 1;
+
+        while (iter.hasNext()) {
             final HtmlListItem testNode = (HtmlListItem) iter.next();
-			if (testNode.getAttribute("class").contains("fail")) {
-				sb.append(i).append(".  ").append(testNode.<HtmlElement>getFirstByXPath("./strong").getFirstChild().getTextContent()).append("\n");
-				int j = 1;
-				for(HtmlElement li : testNode.<HtmlElement>getFirstByXPath("./ol").getChildElements()) {
-					if (li.getAttribute("class").contains("fail")) {
-						sb.append("     ").append(j).append(". ").append(li.getTextContent()).append("\n");
-					}
-					j++;
-				}
-			}
-			i++;
+
+            if (testNode.getAttribute("class").contains("fail")) {
+                sb.append(i).append(".  ").append(
+                    testNode.<HtmlElement>getFirstByXPath("./strong").getFirstChild().getTextContent()).append("\n");
+
+                int j = 1;
+
+                for (HtmlElement li : testNode.<HtmlElement>getFirstByXPath("./ol").getChildElements()) {
+                    if (li.getAttribute("class").contains("fail")) {
+                        sb.append("     ").append(j).append(". ").append(li.getTextContent()).append("\n");
+                    }
+
+                    j++;
+                }
+            }
+
+            i++;
         }
-		if(sb.length() > 0) {
-			fail("Failures:\n" + sb + "User Agent: " + doc.getElementById("userAgent").getTextContent());
-		}
+
+        if (sb.length() > 0) {
+            fail("Failures:\n" + sb + "User Agent: " + doc.getElementById("userAgent").getTextContent());
+        }
     }
 
     protected HtmlPage loadPage(URL url) throws Exception {
         HtmlPage page = webClient_.getPage(url);
+
         webClient_.waitForBackgroundJavaScriptStartingBefore(4 * 60 * 1000);
+
         return page;
     }
 

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/json/JsonTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/json/JsonTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/json/JsonTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -1,5 +1,6 @@
+
 /**
- * 
+ *
  */
 package org.richfaces.json;
 
@@ -15,152 +16,156 @@
 /**
  * @author Nick Belaevski - nbelaevski at exadel.com
  * created 12.04.2007
- * 
+ *
  */
 public class JsonTest extends TestCase {
 
-	/**
-	 * @param name
-	 */
-	public JsonTest(String name) {
-		super(name);
-	}
+    /**
+     * @param name
+     */
+    public JsonTest(String name) {
+        super(name);
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#setUp()
-	 */
-	protected void setUp() throws Exception {
-		super.setUp();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
 
-	/* (non-Javadoc)
-	 * @see junit.framework.TestCase#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
+    /*
+     *  (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-	public void testMap() throws Exception {
-		JSONMap map = new JSONMap("{text: 12, moreData: { key: value, key1: 23.04 }}");
-		assertEquals(12, ((Integer) map.get("text")).intValue());
-		assertEquals(2, map.size());
-		
-		Map innerMap = (Map) map.get("moreData");
-		assertEquals("value", innerMap.get("key"));
-		assertEquals(23.04, ((Double) innerMap.get("key1")).doubleValue(), 0);
-		assertEquals(2, innerMap.size());
-	}
+    public void testMap() throws Exception {
+        JSONMap map = new JSONMap("{text: 12, moreData: { key: value, key1: 23.04 }}");
 
-	public void testCollection() throws Exception {
-		JSONCollection collection = new JSONCollection("[text, { key: value, key1: 23.04 }, [1, a, 3]]");
-		assertEquals(3, collection.size());
+        assertEquals(12, ((Integer) map.get("text")).intValue());
+        assertEquals(2, map.size());
 
-		Iterator iterator = collection.iterator();
-		assertTrue(iterator.hasNext());
-		
-		assertEquals("text", iterator.next());
-		assertTrue(iterator.hasNext());
-		
-		Map innerMap = (Map) iterator.next();
-		assertTrue(iterator.hasNext());
+        Map innerMap = (Map) map.get("moreData");
 
-		assertEquals("value", innerMap.get("key"));
-		assertEquals(23.04, ((Double) innerMap.get("key1")).doubleValue(), 0);
-		assertEquals(2, innerMap.size());
-		
-		Collection innerCollection = (Collection) iterator.next();
-		assertEquals(3, innerCollection.size());
-		Iterator innerIterator = innerCollection.iterator();
-		
-		assertTrue(innerIterator.hasNext());
-		assertEquals(1, ((Integer) innerIterator.next()).intValue());
-		assertTrue(innerIterator.hasNext());
-		assertEquals("a", innerIterator.next());
-		assertTrue(innerIterator.hasNext());
-		assertEquals(3, ((Integer) innerIterator.next()).intValue());
-		assertFalse(innerIterator.hasNext());
-		
-		assertFalse(iterator.hasNext());
-	}
+        assertEquals("value", innerMap.get("key"));
+        assertEquals(23.04, ((Double) innerMap.get("key1")).doubleValue(), 0);
+        assertEquals(2, innerMap.size());
+    }
 
-	public void testNewCollection() throws Exception {
-		JSONCollection collection = new JSONCollection();
-		assertTrue(collection.isEmpty());
-	}
+    public void testCollection() throws Exception {
+        JSONCollection collection = new JSONCollection("[text, { key: value, key1: 23.04 }, [1, a, 3]]");
 
-	public void testNewMap() throws Exception {
-		JSONMap map = new JSONMap();
-		assertTrue(map.isEmpty());
-	}
-	
-	public void testMapAddiition() throws Exception {
-		JSONMap map = new JSONMap();
-		Set set = map.entrySet();
-		set.add(new JsonTestMockMapEntry("boolean", new Boolean(true)));
-		set.add(new JsonTestMockMapEntry("double", new Double(23.45)));
-		set.add(new JsonTestMockMapEntry("integer", new Integer(56)));
-		set.add(new JsonTestMockMapEntry("long", new Long(89)));
-		set.add(new JsonTestMockMapEntry("string", "testString"));
+        assertEquals(3, collection.size());
 
-		HashSet hashSet = new HashSet();
+        Iterator iterator = collection.iterator();
 
-		hashSet.add("15");
-		hashSet.add(new Double(45.01));
-	
-		HashSet etalonSet = (HashSet) hashSet.clone();
+        assertTrue(iterator.hasNext());
+        assertEquals("text", iterator.next());
+        assertTrue(iterator.hasNext());
 
-	
-		HashMap hashMap = new HashMap();
+        Map innerMap = (Map) iterator.next();
 
-		hashMap.put("16", new Boolean(false));
-		hashMap.put("key", new Double(145.01));
-	
-		HashMap etalonMap = (HashMap) hashMap.clone();
+        assertTrue(iterator.hasNext());
+        assertEquals("value", innerMap.get("key"));
+        assertEquals(23.04, ((Double) innerMap.get("key1")).doubleValue(), 0);
+        assertEquals(2, innerMap.size());
 
-		set.add(new JsonTestMockMapEntry("collection", hashSet));
-		set.add(new JsonTestMockMapEntry("map", hashMap));
-	
-		assertEquals(Boolean.TRUE, map.get("boolean"));
-		assertEquals(new Double(23.45), map.get("double"));
-		assertEquals(new Integer(56), map.get("integer"));
-		assertEquals(new Long(89), map.get("long"));
-		assertEquals("testString", map.get("string"));
-		
-		Collection collection = (Collection) map.get("collection");
-		assertTrue(etalonSet.containsAll(collection));
-		etalonSet.removeAll(collection);
-		assertTrue(etalonSet.isEmpty());
-		
-		assertEquals(etalonMap, map.get("map"));
-	}
+        Collection innerCollection = (Collection) iterator.next();
 
+        assertEquals(3, innerCollection.size());
+
+        Iterator innerIterator = innerCollection.iterator();
+
+        assertTrue(innerIterator.hasNext());
+        assertEquals(1, ((Integer) innerIterator.next()).intValue());
+        assertTrue(innerIterator.hasNext());
+        assertEquals("a", innerIterator.next());
+        assertTrue(innerIterator.hasNext());
+        assertEquals(3, ((Integer) innerIterator.next()).intValue());
+        assertFalse(innerIterator.hasNext());
+        assertFalse(iterator.hasNext());
+    }
+
+    public void testNewCollection() throws Exception {
+        JSONCollection collection = new JSONCollection();
+
+        assertTrue(collection.isEmpty());
+    }
+
+    public void testNewMap() throws Exception {
+        JSONMap map = new JSONMap();
+
+        assertTrue(map.isEmpty());
+    }
+
+    public void testMapAddiition() throws Exception {
+        JSONMap map = new JSONMap();
+        Set set = map.entrySet();
+
+        set.add(new JsonTestMockMapEntry("boolean", new Boolean(true)));
+        set.add(new JsonTestMockMapEntry("double", new Double(23.45)));
+        set.add(new JsonTestMockMapEntry("integer", new Integer(56)));
+        set.add(new JsonTestMockMapEntry("long", new Long(89)));
+        set.add(new JsonTestMockMapEntry("string", "testString"));
+
+        HashSet hashSet = new HashSet();
+
+        hashSet.add("15");
+        hashSet.add(new Double(45.01));
+
+        HashSet etalonSet = (HashSet) hashSet.clone();
+        HashMap hashMap = new HashMap();
+
+        hashMap.put("16", new Boolean(false));
+        hashMap.put("key", new Double(145.01));
+
+        HashMap etalonMap = (HashMap) hashMap.clone();
+
+        set.add(new JsonTestMockMapEntry("collection", hashSet));
+        set.add(new JsonTestMockMapEntry("map", hashMap));
+        assertEquals(Boolean.TRUE, map.get("boolean"));
+        assertEquals(new Double(23.45), map.get("double"));
+        assertEquals(new Integer(56), map.get("integer"));
+        assertEquals(new Long(89), map.get("long"));
+        assertEquals("testString", map.get("string"));
+
+        Collection collection = (Collection) map.get("collection");
+
+        assertTrue(etalonSet.containsAll(collection));
+        etalonSet.removeAll(collection);
+        assertTrue(etalonSet.isEmpty());
+        assertEquals(etalonMap, map.get("map"));
+    }
 }
 
+
 class JsonTestMockMapEntry implements Map.Entry {
+    private Object key;
+    private Object value;
 
-	private Object key;
-	private Object value;
-	
-	
-	
-	public JsonTestMockMapEntry(Object key, Object value) {
-		super();
-		this.key = key;
-		this.value = value;
-	}
+    public JsonTestMockMapEntry(Object key, Object value) {
+        super();
+        this.key = key;
+        this.value = value;
+    }
 
-	public Object getKey() {
-		return key;
-	}
+    public Object getKey() {
+        return key;
+    }
 
-	public Object getValue() {
-		return value;
-	}
+    public Object getValue() {
+        return value;
+    }
 
-	public Object setValue(Object newValue) {
-		Object oldValue = value;
-		value = newValue;
-		return oldValue;
-	}
-	
-}
\ No newline at end of file
+    public Object setValue(Object newValue) {
+        Object oldValue = value;
+
+        value = newValue;
+
+        return oldValue;
+    }
+}

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/json/SerializationTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/json/SerializationTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/json/SerializationTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.json;
 
 import java.io.ByteArrayInputStream;
@@ -26,6 +28,7 @@
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+
 import java.util.Iterator;
 
 import junit.framework.TestCase;
@@ -34,78 +37,81 @@
  * @author Nick Belaevski
  * @since 3.3.0
  */
-
 public class SerializationTest extends TestCase {
-	
-	private <T> T saveRestore(T t) throws IOException, ClassNotFoundException {
-		ByteArrayOutputStream baos = new ByteArrayOutputStream();
-		ObjectOutputStream oos = new ObjectOutputStream(baos);
-		oos.writeObject(t);
-		oos.close();
-		
-		ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
-		T restoredT = (T) t.getClass().cast(ois.readObject());
-	
-		return restoredT;
-	}
-	
-	public void testJSONObject() throws Exception {
-		JSONObject restoredObject = saveRestore(
-			new JSONObject("{a:null, b:'abc', c: {d: 'e', f: 'g'}, h: ['i', 'j']}"));
+    private <T> T saveRestore(T t) throws IOException, ClassNotFoundException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream oos = new ObjectOutputStream(baos);
 
-		assertSame(JSONObject.NULL, restoredObject.get("a"));
-		assertEquals("abc", restoredObject.get("b"));
-		
-		JSONObject nestedObject = (JSONObject) restoredObject.get("c");
-		assertEquals("e", nestedObject.get("d"));
-		assertEquals("g", nestedObject.get("f"));
-		
-		JSONArray array = (JSONArray) restoredObject.get("h");
-		assertEquals(2, array.length());
-		assertEquals("i", array.get(0));
-		assertEquals("j", array.get(1));
-		
-	}
-	
-	public void testJSONCollection() throws Exception {
-		JSONCollection restored = saveRestore(new JSONCollection("[1, '2', null, [3, 4], {a: 'b', c: 'd'}]"));
-		Iterator iterator = restored.iterator();
-		
-		assertEquals(Integer.valueOf(1), iterator.next());
-		assertEquals("2", iterator.next());
-		assertSame(JSONObject.NULL, iterator.next());
+        oos.writeObject(t);
+        oos.close();
 
-		JSONCollection nestedCollection = (JSONCollection) iterator.next();
-		Iterator nestedIterator = nestedCollection.iterator();
-		assertEquals(Integer.valueOf(3), nestedIterator.next());
-		assertEquals(Integer.valueOf(4), nestedIterator.next());
-		assertFalse(nestedIterator.hasNext());
-		
-		JSONMap nestedMap = (JSONMap) iterator.next();
-		assertEquals("b", nestedMap.get("a"));
-		assertEquals("d", nestedMap.get("c"));
-		assertEquals(2, nestedMap.size());
-		
-		assertFalse(iterator.hasNext());
-	}
-	
-	public void testJSONMap() throws Exception {
-		JSONMap restored = saveRestore(new JSONMap("{a: 'b', c: 3, d: null, e: [5, 'v'], f: {x: 'y', z: 2}}"));
-		assertEquals("b", restored.get("a"));
-		assertEquals(Integer.valueOf(3), restored.get("c"));
-		assertSame(JSONObject.NULL, restored.get("d"));
-		
-		JSONCollection nestedCollection = (JSONCollection) restored.get("e");
-		Iterator nestedIterator = nestedCollection.iterator();
-		assertEquals(Integer.valueOf(5), nestedIterator.next());
-		assertEquals("v", nestedIterator.next());
-		assertFalse(nestedIterator.hasNext());
-		
-		JSONMap nestedObject = (JSONMap) restored.get("f");
-		assertEquals("y", nestedObject.get("x"));
-		assertEquals(Integer.valueOf(2), nestedObject.get("z"));
-		assertEquals(2, nestedObject.size());
-		
-		assertEquals(5, restored.size());
-	}
+        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+        T restoredT = (T) t.getClass().cast(ois.readObject());
+
+        return restoredT;
+    }
+
+    public void testJSONObject() throws Exception {
+        JSONObject restoredObject =
+            saveRestore(new JSONObject("{a:null, b:'abc', c: {d: 'e', f: 'g'}, h: ['i', 'j']}"));
+
+        assertSame(JSONObject.NULL, restoredObject.get("a"));
+        assertEquals("abc", restoredObject.get("b"));
+
+        JSONObject nestedObject = (JSONObject) restoredObject.get("c");
+
+        assertEquals("e", nestedObject.get("d"));
+        assertEquals("g", nestedObject.get("f"));
+
+        JSONArray array = (JSONArray) restoredObject.get("h");
+
+        assertEquals(2, array.length());
+        assertEquals("i", array.get(0));
+        assertEquals("j", array.get(1));
+    }
+
+    public void testJSONCollection() throws Exception {
+        JSONCollection restored = saveRestore(new JSONCollection("[1, '2', null, [3, 4], {a: 'b', c: 'd'}]"));
+        Iterator iterator = restored.iterator();
+
+        assertEquals(Integer.valueOf(1), iterator.next());
+        assertEquals("2", iterator.next());
+        assertSame(JSONObject.NULL, iterator.next());
+
+        JSONCollection nestedCollection = (JSONCollection) iterator.next();
+        Iterator nestedIterator = nestedCollection.iterator();
+
+        assertEquals(Integer.valueOf(3), nestedIterator.next());
+        assertEquals(Integer.valueOf(4), nestedIterator.next());
+        assertFalse(nestedIterator.hasNext());
+
+        JSONMap nestedMap = (JSONMap) iterator.next();
+
+        assertEquals("b", nestedMap.get("a"));
+        assertEquals("d", nestedMap.get("c"));
+        assertEquals(2, nestedMap.size());
+        assertFalse(iterator.hasNext());
+    }
+
+    public void testJSONMap() throws Exception {
+        JSONMap restored = saveRestore(new JSONMap("{a: 'b', c: 3, d: null, e: [5, 'v'], f: {x: 'y', z: 2}}"));
+
+        assertEquals("b", restored.get("a"));
+        assertEquals(Integer.valueOf(3), restored.get("c"));
+        assertSame(JSONObject.NULL, restored.get("d"));
+
+        JSONCollection nestedCollection = (JSONCollection) restored.get("e");
+        Iterator nestedIterator = nestedCollection.iterator();
+
+        assertEquals(Integer.valueOf(5), nestedIterator.next());
+        assertEquals("v", nestedIterator.next());
+        assertFalse(nestedIterator.hasNext());
+
+        JSONMap nestedObject = (JSONMap) restored.get("f");
+
+        assertEquals("y", nestedObject.get("x"));
+        assertEquals(Integer.valueOf(2), nestedObject.get("z"));
+        assertEquals(2, nestedObject.size());
+        assertEquals(5, restored.size());
+    }
 }

Copied: root/framework/trunk/impl/src/test/java/org/richfaces/json/Test.java (from rev 15745, root/framework/trunk/impl/src/main/java/org/richfaces/json/Test.java)
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/json/Test.java	                        (rev 0)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/json/Test.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -0,0 +1,410 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+
+
+package org.richfaces.json;
+
+import junit.framework.TestCase;
+
+import java.io.StringWriter;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.junit.Ignore;
+
+/**
+ * Test class. This file is not formally a member of the org.json library.
+ * It is just a casual test tool.
+ *
+ * TODO Refactoring
+ */
+ at Ignore
+public class Test extends TestCase {
+    public void testMain() {
+        Iterator it;
+        JSONArray a;
+        JSONObject j;
+        JSONStringer jj;
+        String s;
+
+//      Obj is a typical class that implements JSONString.        
+        try {
+            String[] sa = {"aString", "aNumber", "aBoolean"};
+            Obj obj = new Obj("A string, a number, and a boolean", 42, true);
+
+            j = XML.toJSONObject("<![CDATA[This is a collection of test patterns and examples for org.json.]]>");
+            System.out.println(j.toString());
+            jj = new JSONStringer();
+            s = jj.object().key("foo").value("bar").key("baz").array().object().key("quux").value(
+                "Thanks, Josh!").endObject().endArray().endObject().toString();
+            System.out.println(s);
+            System.out.println(
+                new JSONStringer().object().key("a").array().array().array().value(
+                    "b").endArray().endArray().endArray().endObject().toString());
+            jj = new JSONStringer();
+            jj.array();
+            jj.value(1);
+            jj.array();
+            jj.value(null);
+            jj.array();
+            jj.object();
+            jj.key("empty-array").array().endArray();
+            jj.key("answer").value(42);
+            jj.key("null").value(null);
+            jj.key("false").value(false);
+            jj.key("true").value(true);
+            jj.key("big").value(123456789e+88);
+            jj.key("small").value(123456789e-88);
+            jj.key("empty-object").object().endObject();
+            jj.key("long");
+            jj.value(9223372036854775807L);
+            jj.endObject();
+            jj.value("two");
+            jj.endArray();
+            jj.value(true);
+            jj.endArray();
+            jj.value(98.6);
+            jj.value(-100.0);
+            jj.object();
+            jj.endObject();
+            jj.object();
+            jj.key("one");
+            jj.value(1.00);
+            jj.endObject();
+            jj.value(obj);
+            jj.endArray();
+            System.out.println(jj.toString());
+            System.out.println(new JSONArray(jj.toString()).toString(4));
+            j = new JSONObject(obj, sa);
+            j.put("test", obj);
+            j.put("comment", "This object contains a test object that implements JSONString");
+            System.out.println(j.toString(4));
+            j = new JSONObject(
+                "{slashes: '///', closetag: '</script>', backslash:'\\\\', ei: {quotes: '\"\\''},eo: {a: '\"quoted\"', b:\"don't\"}, quotes: [\"'\", '\"']}");
+            System.out.println(j.toString(2));
+            System.out.println(XML.toString(j));
+            System.out.println("");
+            j = new JSONObject(
+                "/*comment*/{foo: [true, false,9876543210,    0.0, 1.00000001,  1.000000000001, 1.00000000000000001,"
+                + " .00000000000000001, 2.00, 0.1, 2e100, -32,[],{}, \"string\"], " + "  to   : null, op : 'Good',"
+                + "ten:10} postfix comment");
+            j.put("String", "98.6");
+            j.put("JSONObject", new JSONObject());
+            j.put("JSONArray", new JSONArray());
+            j.put("int", 57);
+            j.put("double", 123456789012345678901234567890.);
+            j.put("true", true);
+            j.put("false", false);
+            j.put("null", JSONObject.NULL);
+            j.put("bool", "true");
+            j.put("zero", -0.0);
+            a = j.getJSONArray("foo");
+            a.put(666);
+            a.put(2001.99);
+            a.put("so \"fine\".");
+            a.put("so <fine>.");
+            a.put(true);
+            a.put(false);
+            a.put(new JSONArray());
+            a.put(new JSONObject());
+            System.out.println(j.toString(4));
+            System.out.println(XML.toString(j));
+            System.out.println("String: " + j.getDouble("String"));
+            System.out.println("  bool: " + j.getBoolean("bool"));
+            System.out.println("    to: " + j.getString("to"));
+            System.out.println("  true: " + j.getString("true"));
+            System.out.println("   foo: " + j.getJSONArray("foo"));
+            System.out.println("    op: " + j.getString("op"));
+            System.out.println("   ten: " + j.getInt("ten"));
+            System.out.println("  oops: " + j.optBoolean("oops"));
+            j = XML.toJSONObject(
+                "<xml one = 1 two=' \"2\" '><five></five>First \u0009&lt;content&gt;<five></five> This is \"content\". <three>  3  </three>JSON does not preserve the sequencing of elements and contents.<three>  III  </three>  <three>  T H R E E</three><four/>Content text is an implied structure in XML. <six content=\"6\"/>JSON does not have implied structure:<seven>7</seven>everything is explicit.<![CDATA[CDATA blocks<are><supported>!]]></xml>");
+            System.out.println(j.toString(2));
+            System.out.println(XML.toString(j));
+            System.out.println("");
+            j = XML.toJSONObject(
+                "<mapping><empty/>   <class name = \"Customer\">      <field name = \"ID\" type = \"string\">         <bind-xml name=\"ID\" node=\"attribute\"/>      </field>      <field name = \"FirstName\" type = \"FirstName\"/>      <field name = \"MI\" type = \"MI\"/>      <field name = \"LastName\" type = \"LastName\"/>   </class>   <class name = \"FirstName\">      <field name = \"text\">         <bind-xml name = \"text\" node = \"text\"/>      </field>   </class>   <class name = \"MI\">      <field name = \"text\">         <bind-xml name = \"text\" node = \"text\"/>      </field>   </class>   <class name = \"LastName\">      <field name = \"text\">         <bind-xml name = \"text\" node = \"text\"/>      </field>   </class></mapping>");
+            System.out.println(j.toString(2));
+            System.out.println(XML.toString(j));
+            System.out.println("");
+            j = XML.toJSONObject(
+                "<?xml version=\"1.0\" ?><Book Author=\"Anonymous\"><Title>Sample Book</Title><Chapter id=\"1\">This is chapter 1. It is not very long or interesting.</Chapter><Chapter id=\"2\">This is chapter 2. Although it is longer than chapter 1, it is not any more interesting.</Chapter></Book>");
+            System.out.println(j.toString(2));
+            System.out.println(XML.toString(j));
+            System.out.println("");
+            j = XML.toJSONObject(
+                "<!DOCTYPE bCard 'http://www.cs.caltech.edu/~adam/schemas/bCard'><bCard><?xml default bCard        firstname = ''        lastname  = '' company   = '' email = '' homepage  = ''?><bCard        firstname = 'Rohit'        lastname  = 'Khare'        company   = 'MCI'        email     = 'khare at mci.net'        homepage  = 'http://pest.w3.org/'/><bCard        firstname = 'Adam'        lastname  = 'Rifkin'        company   = 'Caltech Infospheres Project'        email     = 'adam at cs.caltech.edu'        homepage  = 'http://www.cs.caltech.edu/~adam/'/></bCard>");
+            System.out.println(j.toString(2));
+            System.out.println(XML.toString(j));
+            System.out.println("");
+            j = XML.toJSONObject(
+                "<?xml version=\"1.0\"?><customer>    <firstName>        <text>Fred</text>    </firstName>    <ID>fbs0001</ID>    <lastName> <text>Scerbo</text>    </lastName>    <MI>        <text>B</text>    </MI></customer>");
+            System.out.println(j.toString(2));
+            System.out.println(XML.toString(j));
+            System.out.println("");
+            j = XML.toJSONObject(
+                "<!ENTITY tp-address PUBLIC '-//ABC University::Special Collections Library//TEXT (titlepage: name and address)//EN' 'tpspcoll.sgm'><list type='simple'><head>Repository Address </head><item>Special Collections Library</item><item>ABC University</item><item>Main Library, 40 Circle Drive</item><item>Ourtown, Pennsylvania</item><item>17654 USA</item></list>");
+            System.out.println(j.toString());
+            System.out.println(XML.toString(j));
+            System.out.println("");
+            j = XML.toJSONObject(
+                "<test intertag status=ok><empty/>deluxe<blip sweet=true>&amp;&quot;toot&quot;&toot;&#x41;</blip><x>eks</x><w>bonus</w><w>bonus2</w></test>");
+            System.out.println(j.toString(2));
+            System.out.println(XML.toString(j));
+            System.out.println("");
+            j = HTTP.toJSONObject(
+                "GET / HTTP/1.0\nAccept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*\nAccept-Language: en-us\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90; T312461; Q312461)\nHost: www.nokko.com\nConnection: keep-alive\nAccept-encoding: gzip, deflate\n");
+            System.out.println(j.toString(2));
+            System.out.println(HTTP.toString(j));
+            System.out.println("");
+            j = HTTP.toJSONObject(
+                "HTTP/1.1 200 Oki Doki\nDate: Sun, 26 May 2002 17:38:52 GMT\nServer: Apache/1.3.23 (Unix) mod_perl/1.26\nKeep-Alive: timeout=15, max=100\nConnection: Keep-Alive\nTransfer-Encoding: chunked\nContent-Type: text/html\n");
+            System.out.println(j.toString(2));
+            System.out.println(HTTP.toString(j));
+            System.out.println("");
+            j = new JSONObject(
+                "{nix: null, nux: false, null: 'null', 'Request-URI': '/', Method: 'GET', 'HTTP-Version': 'HTTP/1.0'}");
+            System.out.println(j.toString(2));
+            System.out.println("isNull: " + j.isNull("nix"));
+            System.out.println("   has: " + j.has("nix"));
+            System.out.println(XML.toString(j));
+            System.out.println(HTTP.toString(j));
+            System.out.println("");
+            j = XML.toJSONObject("<?xml version='1.0' encoding='UTF-8'?>" + "\n\n" + "<SOAP-ENV:Envelope"
+                                 + " xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\""
+                                 + " xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\""
+                                 + " xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\">"
+                                 + "<SOAP-ENV:Body><ns1:doGoogleSearch" + " xmlns:ns1=\"urn:GoogleSearch\""
+                                 + " SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
+                                 + "<key xsi:type=\"xsd:string\">GOOGLEKEY</key> <q"
+                                 + " xsi:type=\"xsd:string\">'+search+'</q> <start"
+                                 + " xsi:type=\"xsd:int\">0</start> <maxResults"
+                                 + " xsi:type=\"xsd:int\">10</maxResults> <filter"
+                                 + " xsi:type=\"xsd:boolean\">true</filter> <restrict"
+                                 + " xsi:type=\"xsd:string\"></restrict> <safeSearch"
+                                 + " xsi:type=\"xsd:boolean\">false</safeSearch> <lr"
+                                 + " xsi:type=\"xsd:string\"></lr> <ie" + " xsi:type=\"xsd:string\">latin1</ie> <oe"
+                                 + " xsi:type=\"xsd:string\">latin1</oe>" + "</ns1:doGoogleSearch>"
+                                 + "</SOAP-ENV:Body></SOAP-ENV:Envelope>");
+            System.out.println(j.toString(2));
+            System.out.println(XML.toString(j));
+            System.out.println("");
+            j = new JSONObject(
+                "{Envelope: {Body: {\"ns1:doGoogleSearch\": {oe: \"latin1\", filter: true, q: \"'+search+'\", key: \"GOOGLEKEY\", maxResults: 10, \"SOAP-ENV:encodingStyle\": \"http://schemas.xmlsoap.org/soap/encoding/\", start: 0, ie: \"latin1\", safeSearch:false, \"xmlns:ns1\": \"urn:GoogleSearch\"}}}}");
+            System.out.println(j.toString(2));
+            System.out.println(XML.toString(j));
+            System.out.println("");
+            j = CookieList.toJSONObject("  f%oo = b+l=ah  ; o;n%40e = t.wo ");
+            System.out.println(j.toString(2));
+            System.out.println(CookieList.toString(j));
+            System.out.println("");
+            j = Cookie.toJSONObject("f%oo=blah; secure ;expires = April 24, 2002");
+            System.out.println(j.toString(2));
+            System.out.println(Cookie.toString(j));
+            System.out.println("");
+            j = new JSONObject(
+                "{script: 'It is not allowed in HTML to send a close script tag in a string<script>because it confuses browsers</script>so we insert a backslash before the /'}");
+            System.out.println(j.toString());
+            System.out.println("");
+
+            JSONTokener jt = new JSONTokener("{op:'test', to:'session', pre:1}{op:'test', to:'session', pre:2}");
+
+            j = new JSONObject(jt);
+            System.out.println(j.toString());
+            System.out.println("pre: " + j.optInt("pre"));
+
+            int i = jt.skipTo('{');
+
+            System.out.println(i);
+            j = new JSONObject(jt);
+            System.out.println(j.toString());
+            System.out.println("");
+            a = CDL.toJSONArray(
+                "No quotes, 'Single Quotes', \"Double Quotes\"\n1,'2',\"3\"\n,'It is \"good,\"', \"It works.\"\n\n");
+            System.out.println(CDL.toString(a));
+            System.out.println("");
+            System.out.println(a.toString(4));
+            System.out.println("");
+            a = new JSONArray(" [\"<escape>\", next is an implied null , , ok,] ");
+            System.out.println(a.toString());
+            System.out.println("");
+            System.out.println(XML.toString(a));
+            System.out.println("");
+            j = new JSONObject(
+                "{ fun => with non-standard forms ; forgiving => This package can be used to parse formats that are similar to but not stricting conforming to JSON; why=To make it easier to migrate existing data to JSON,one = [[1.00]]; uno=[[{1=>1}]];'+':+6e66 ;pluses=+++;empty = '' , 'double':0.666,true: TRUE, false: FALSE, null=NULL;[true] = [[!,@;*]]; string=>  o. k. ; # comment\r oct=0666; hex=0x666; dec=666; o=0999; noh=0x0x}");
+            System.out.println(j.toString(4));
+            System.out.println("");
+
+            if (j.getBoolean("true") && !j.getBoolean("false")) {
+                System.out.println("It's all good");
+            }
+
+            System.out.println("");
+            j = new JSONObject(j, new String[] {"dec", "oct", "hex", "missing"});
+            System.out.println(j.toString(4));
+            System.out.println("");
+            System.out.println(new JSONStringer().array().value(a).value(j).endArray());
+            j = new JSONObject(
+                "{string: \"98.6\", long: 2147483648, int: 2147483647, longer: 9223372036854775807, double: 9223372036854775808}");
+            System.out.println(j.toString(4));
+            System.out.println("\ngetInt");
+            System.out.println("int    " + j.getInt("int"));
+            System.out.println("long   " + j.getInt("long"));
+            System.out.println("longer " + j.getInt("longer"));
+            System.out.println("double " + j.getInt("double"));
+            System.out.println("string " + j.getInt("string"));
+            System.out.println("\ngetLong");
+            System.out.println("int    " + j.getLong("int"));
+            System.out.println("long   " + j.getLong("long"));
+            System.out.println("longer " + j.getLong("longer"));
+            System.out.println("double " + j.getLong("double"));
+            System.out.println("string " + j.getLong("string"));
+            System.out.println("\ngetDouble");
+            System.out.println("int    " + j.getDouble("int"));
+            System.out.println("long   " + j.getDouble("long"));
+            System.out.println("longer " + j.getDouble("longer"));
+            System.out.println("double " + j.getDouble("double"));
+            System.out.println("string " + j.getDouble("string"));
+            j.put("good sized", 9223372036854775807L);
+            System.out.println(j.toString(4));
+            a = new JSONArray("[2147483647, 2147483648, 9223372036854775807, 9223372036854775808]");
+            System.out.println(a.toString(4));
+            System.out.println("\nKeys: ");
+            it = j.keys();
+
+            while (it.hasNext()) {
+                s = (String) it.next();
+                System.out.println(s + ": " + j.getString(s));
+            }
+
+            System.out.println("\naccumulate: ");
+            j = new JSONObject();
+            j.accumulate("stooge", "Curly");
+            j.accumulate("stooge", "Larry");
+            j.accumulate("stooge", "Moe");
+            a = j.getJSONArray("stooge");
+            a.put(5, "Shemp");
+            System.out.println(j.toString(4));
+            System.out.println("\nwrite:");
+            System.out.println(j.write(new StringWriter()));
+            s = "<xml empty><a></a><a>1</a><a>22</a><a>333</a></xml>";
+            j = XML.toJSONObject(s);
+            System.out.println(j.toString(4));
+            System.out.println(XML.toString(j));
+            s = "<book><chapter>Content of the first chapter</chapter><chapter>Content of the second chapter      <chapter>Content of the first subchapter</chapter>      <chapter>Content of the second subchapter</chapter></chapter><chapter>Third Chapter</chapter></book>";
+            j = XML.toJSONObject(s);
+            System.out.println(j.toString(4));
+            System.out.println(XML.toString(j));
+
+            Collection c = null;
+            Map m = null;
+
+            j = new JSONObject(m);
+            a = new JSONArray(c);
+            j.append("stooge", "Joe DeRita");
+            j.append("stooge", "Shemp");
+            j.accumulate("stooges", "Curly");
+            j.accumulate("stooges", "Larry");
+            j.accumulate("stooges", "Moe");
+            j.accumulate("stoogearray", j.get("stooges"));
+            j.put("map", m);
+            j.put("collection", c);
+            j.put("array", a);
+            a.put(m);
+            a.put(c);
+            System.out.println(j.toString(4));
+            System.out.println("\nTesting Exceptions: ");
+            System.out.print("Exception: ");
+
+            try {
+                System.out.println(j.getDouble("stooge"));
+            } catch (Exception e) {
+                System.out.println(e);
+            }
+
+            System.out.print("Exception: ");
+
+            try {
+                System.out.println(j.getDouble("howard"));
+            } catch (Exception e) {
+                System.out.println(e);
+            }
+
+            System.out.print("Exception: ");
+
+            try {
+                System.out.println(j.put(null, "howard"));
+            } catch (Exception e) {
+                System.out.println(e);
+            }
+
+            System.out.print("Exception: ");
+
+            try {
+                System.out.println(a.getDouble(0));
+            } catch (Exception e) {
+                System.out.println(e);
+            }
+
+            System.out.print("Exception: ");
+
+            try {
+                System.out.println(a.get(-1));
+            } catch (Exception e) {
+                System.out.println(e);
+            }
+
+            System.out.print("Exception: ");
+
+            try {
+                System.out.println(a.put(Double.NaN));
+            } catch (Exception e) {
+                System.out.println(e);
+            }
+        } catch (Exception e) {
+            System.out.println(e.toString());
+        }
+    }
+
+    class Obj implements JSONString {
+        private boolean aBoolean;
+        private double aNumber;
+        private String aString;
+
+        public Obj(String string, double n, boolean b) {
+            this.aString = string;
+            this.aNumber = n;
+            this.aBoolean = b;
+        }
+
+        public String toJSONString() {
+            return "{" + JSONObject.quote(this.aString) + ":" + JSONObject.doubleToString(this.aNumber) + "}";
+        }
+
+        @Override
+        public String toString() {
+            return this.aString + " " + this.aNumber + " " + this.aBoolean;
+        }
+    }
+}

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/CompositeRendererTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/CompositeRendererTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/CompositeRendererTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 import java.io.StringWriter;
+
 import java.util.Arrays;
 import java.util.Map;
 
@@ -15,369 +16,354 @@
 import org.richfaces.test.AbstractFacesTest;
 
 public class CompositeRendererTest extends AbstractFacesTest {
+    private CompositeRenderer compositeRenderer;
 
-	private CompositeRenderer compositeRenderer;
-	
-	public void setUp() throws Exception {
-		super.setUp();
-		setupFacesRequest();
-		
-		this.compositeRenderer = new CompositeRenderer() {
+    public void setUp() throws Exception {
+        super.setUp();
+        setupFacesRequest();
+        this.compositeRenderer = new CompositeRenderer() {
+            protected Class getComponentClass() {
+                return UIComponent.class;
+            }
+        };
+    }
 
-			protected Class getComponentClass() {
-				return UIComponent.class;
-			}
-		};
-	}
+    public void tearDown() throws Exception {
+        super.tearDown();
+        this.compositeRenderer = null;
+    }
 
-	public void tearDown() throws Exception {
-		super.tearDown();
+    public final void testDoDecodeFacesContextUIComponent() {
+        MockDecodeContributor[] contributors = new MockDecodeContributor[5];
 
-		this.compositeRenderer = null;
-	}
+        for (int i = 0; i < contributors.length; i++) {
+            contributors[i] = new MockDecodeContributor();
+            compositeRenderer.addContributor(contributors[i]);
+        }
 
-	public final void testDoDecodeFacesContextUIComponent() {
-		MockDecodeContributor[] contributors = new MockDecodeContributor[5];
-		for (int i = 0; i < contributors.length; i++) {
-			contributors[i] = new MockDecodeContributor();
-			compositeRenderer.addContributor(contributors[i]);
-		}
-		
-		UIInput component = new UIInput();
-		compositeRenderer.doDecode(facesContext, component);
+        UIInput component = new UIInput();
 
-		for (int i = 0; i < contributors.length; i++) {
-			assertSame(compositeRenderer, contributors[i].getRenderer());
-			assertSame(facesContext, contributors[i].getContext());
-			assertSame(component, contributors[i].getComponent());
-		}
-	}
+        compositeRenderer.doDecode(facesContext, component);
 
-	public final void testMergeScriptOptionsScriptOptionsFacesContextUIComponent() {
-		UIInput input = new UIInput();
+        for (int i = 0; i < contributors.length; i++) {
+            assertSame(compositeRenderer, contributors[i].getRenderer());
+            assertSame(facesContext, contributors[i].getContext());
+            assertSame(component, contributors[i].getComponent());
+        }
+    }
 
-		ScriptOptions inputOptions = new ScriptOptions(input);
-		inputOptions.addOption("input", "1");
-		
-		ScriptOptions formOptions = new ScriptOptions(input);
-		formOptions.addOption("form", "2");
-		
-		ScriptOptions options = new ScriptOptions(input);
-		options.addOption("generic", "3");
-		
-		MockDecodeContributor inputContributor;
-		MockDecodeContributor formContributor;
-		MockDecodeContributor contributor;
-		MockDecodeContributor nullContributor;
+    public final void testMergeScriptOptionsScriptOptionsFacesContextUIComponent() {
+        UIInput input = new UIInput();
+        ScriptOptions inputOptions = new ScriptOptions(input);
 
-		inputContributor = new MockDecodeContributor(UIComponent.class, inputOptions);
-		formContributor = new MockDecodeContributor(UIComponent.class, formOptions);
-		contributor = new MockDecodeContributor(UIComponent.class, options);
-		nullContributor = new MockDecodeContributor(UIComponent.class, (ScriptOptions) null);
-		
-		compositeRenderer.addContributor(contributor);
-		compositeRenderer.addContributor(formContributor);
-		compositeRenderer.addContributor(inputContributor);
-		compositeRenderer.addContributor(nullContributor);
-		
-		ScriptOptions scriptOptions = new ScriptOptions(input);
-		compositeRenderer.mergeScriptOptions(scriptOptions, facesContext, input);
-		Map map = scriptOptions.getMap();
-		
-		assertEquals(3, map.size());
-		assertEquals("1", map.get("input"));
-		assertEquals("2", map.get("form"));
-		assertEquals("3", map.get("generic"));
-	}
+        inputOptions.addOption("input", "1");
 
-	public final void testMergeScriptOptionsScriptOptionsFacesContextUIComponentClass() {
-		UIInput input = new UIInput();
+        ScriptOptions formOptions = new ScriptOptions(input);
 
-		ScriptOptions inputOptions = new ScriptOptions(input);
-		inputOptions.addOption("input", "1");
-		
-		ScriptOptions formOptions = new ScriptOptions(input);
-		formOptions.addOption("form", "2");
-		
-		ScriptOptions options = new ScriptOptions(input);
-		options.addOption("generic", "3");
+        formOptions.addOption("form", "2");
 
-		MockDecodeContributor inputContributor;
-		MockDecodeContributor formContributor;
-		MockDecodeContributor contributor;
-		MockDecodeContributor nullContributor;
+        ScriptOptions options = new ScriptOptions(input);
 
-		inputContributor = new MockDecodeContributor(UIInput.class, inputOptions);
-		formContributor = new MockDecodeContributor(NamingContainer.class, formOptions);
-		contributor = new MockDecodeContributor(UIComponent.class, options);
-		nullContributor = new MockDecodeContributor(UIForm.class, (ScriptOptions) null);
-		
-		compositeRenderer.addContributor(contributor);
-		compositeRenderer.addContributor(formContributor);
-		compositeRenderer.addContributor(inputContributor);
-		compositeRenderer.addContributor(nullContributor);
-	
-		ScriptOptions scriptOptions = new ScriptOptions(input);
-		compositeRenderer.mergeScriptOptions(scriptOptions, facesContext, input, UIForm.class);
-		Map map = scriptOptions.getMap();
+        options.addOption("generic", "3");
 
-		assertEquals(2, map.size());
-		assertEquals("2", map.get("form"));
-		assertEquals("3", map.get("generic"));
-	}
+        MockDecodeContributor inputContributor;
+        MockDecodeContributor formContributor;
+        MockDecodeContributor contributor;
+        MockDecodeContributor nullContributor;
 
-	public final void testGetScriptContributionsStringFacesContextUIComponent() {
-		MockDecodeContributor inputContributor;
-		MockDecodeContributor formContributor;
-		MockDecodeContributor contributor;
-		MockDecodeContributor nullContributor;
+        inputContributor = new MockDecodeContributor(UIComponent.class, inputOptions);
+        formContributor = new MockDecodeContributor(UIComponent.class, formOptions);
+        contributor = new MockDecodeContributor(UIComponent.class, options);
+        nullContributor = new MockDecodeContributor(UIComponent.class, (ScriptOptions) null);
+        compositeRenderer.addContributor(contributor);
+        compositeRenderer.addContributor(formContributor);
+        compositeRenderer.addContributor(inputContributor);
+        compositeRenderer.addContributor(nullContributor);
 
-		inputContributor = new MockDecodeContributor(UIComponent.class, ".1;");
-		formContributor = new MockDecodeContributor(UIComponent.class, ".2;");
-		contributor = new MockDecodeContributor(UIComponent.class, ".3;");
-		nullContributor = new MockDecodeContributor(UIForm.class, (String) null);
-		
-		compositeRenderer.addContributor(contributor);
-		compositeRenderer.addContributor(formContributor);
-		compositeRenderer.addContributor(inputContributor);
-		compositeRenderer.addContributor(nullContributor);
-	
-		UIInput input = new UIInput();
-		input.getAttributes().put("test", ".testValue");
+        ScriptOptions scriptOptions = new ScriptOptions(input);
 
-		String contributions = compositeRenderer.getScriptContributions("theVar", facesContext, input);
-	
-		assertEquals("theVar.testValue.3;theVar.testValue.2;theVar.testValue.1;", contributions);
-	}
+        compositeRenderer.mergeScriptOptions(scriptOptions, facesContext, input);
 
-	public final void testGetScriptContributionsStringFacesContextUIComponentClass() {
-		MockDecodeContributor inputContributor;
-		MockDecodeContributor formContributor;
-		MockDecodeContributor contributor;
-		MockDecodeContributor nullContributor;
+        Map map = scriptOptions.getMap();
 
-		inputContributor = new MockDecodeContributor(UIInput.class, ".input;");
-		formContributor = new MockDecodeContributor(NamingContainer.class, ".namingContainer;");
-		contributor = new MockDecodeContributor(UIComponent.class, ".generic;");
-		nullContributor = new MockDecodeContributor(UIForm.class, (String) null);
-		
-		compositeRenderer.addContributor(contributor);
-		compositeRenderer.addContributor(formContributor);
-		compositeRenderer.addContributor(inputContributor);
-		compositeRenderer.addContributor(nullContributor);
-	
-		UIInput input = new UIInput();
-		input.getAttributes().put("test", ".testValue");
-		
-		String contributions = compositeRenderer.getScriptContributions("theVar", facesContext, input, 
-				UIForm.class);
-	
-		assertEquals("theVar.testValue.generic;theVar.testValue.namingContainer;", contributions);
-	}
+        assertEquals(3, map.size());
+        assertEquals("1", map.get("input"));
+        assertEquals("2", map.get("form"));
+        assertEquals("3", map.get("generic"));
+    }
 
-	public final void testAddContributor() {
-		MockDecodeContributor[] contributors = new MockDecodeContributor[5];
-		for (int i = 0; i < contributors.length; i++) {
-			contributors[i] = new MockDecodeContributor();
-			compositeRenderer.addContributor(contributors[i]);
-		}
+    public final void testMergeScriptOptionsScriptOptionsFacesContextUIComponentClass() {
+        UIInput input = new UIInput();
+        ScriptOptions inputOptions = new ScriptOptions(input);
 
-		assertTrue(Arrays.deepEquals(contributors, compositeRenderer.getContributors()));
-	}
+        inputOptions.addOption("input", "1");
 
-	public final void testContributorDecodeCallback() {
-		MockDecodeContributor inputContributor;
-		MockDecodeContributor formContributor;
+        ScriptOptions formOptions = new ScriptOptions(input);
 
-		formContributor = new MockDecodeContributor(NamingContainer.class);
-		inputContributor = new MockDecodeContributor(UIInput.class);
+        formOptions.addOption("form", "2");
 
-		compositeRenderer.addContributor(inputContributor);
-		compositeRenderer.addContributor(formContributor);
-		
-		UIComponent component = new UIInput();
-		compositeRenderer.doDecode(facesContext, component);
+        ScriptOptions options = new ScriptOptions(input);
 
-		assertSame(compositeRenderer, inputContributor.getRenderer());
-		assertSame(facesContext, inputContributor.getContext());
-		assertSame(component, inputContributor.getComponent());
-		
-		assertNull(formContributor.getRenderer());
-		assertNull(formContributor.getContext());
-		assertNull(formContributor.getComponent());
+        options.addOption("generic", "3");
 
-		inputContributor.reset();
-		formContributor.reset();
+        MockDecodeContributor inputContributor;
+        MockDecodeContributor formContributor;
+        MockDecodeContributor contributor;
+        MockDecodeContributor nullContributor;
 
-		assertNull(inputContributor.getRenderer());
-		assertNull(inputContributor.getContext());
-		assertNull(inputContributor.getComponent());
+        inputContributor = new MockDecodeContributor(UIInput.class, inputOptions);
+        formContributor = new MockDecodeContributor(NamingContainer.class, formOptions);
+        contributor = new MockDecodeContributor(UIComponent.class, options);
+        nullContributor = new MockDecodeContributor(UIForm.class, (ScriptOptions) null);
+        compositeRenderer.addContributor(contributor);
+        compositeRenderer.addContributor(formContributor);
+        compositeRenderer.addContributor(inputContributor);
+        compositeRenderer.addContributor(nullContributor);
 
-		assertNull(formContributor.getRenderer());
-		assertNull(formContributor.getContext());
-		assertNull(formContributor.getComponent());
+        ScriptOptions scriptOptions = new ScriptOptions(input);
 
-		component = new UIForm();
-		compositeRenderer.doDecode(facesContext, component);
+        compositeRenderer.mergeScriptOptions(scriptOptions, facesContext, input, UIForm.class);
 
-		assertSame(compositeRenderer, formContributor.getRenderer());
-		assertSame(facesContext, formContributor.getContext());
-		assertSame(component, formContributor.getComponent());
-		
-		assertNull(inputContributor.getRenderer());
-		assertNull(inputContributor.getContext());
-		assertNull(inputContributor.getComponent());
-	}
+        Map map = scriptOptions.getMap();
 
-	public final void testAddParameterEncoder() {
-		MockAttributeParameterEncoder[] encoders = new MockAttributeParameterEncoder[5];
-		for (int i = 0; i < encoders.length; i++) {
-			encoders[i] = new MockAttributeParameterEncoder("aaa");
-			compositeRenderer.addParameterEncoder(encoders[i]);
-		}
+        assertEquals(2, map.size());
+        assertEquals("2", map.get("form"));
+        assertEquals("3", map.get("generic"));
+    }
 
-		assertTrue(Arrays.deepEquals(encoders, compositeRenderer.getParameterEncoders()));
-	}
+    public final void testGetScriptContributionsStringFacesContextUIComponent() {
+        MockDecodeContributor inputContributor;
+        MockDecodeContributor formContributor;
+        MockDecodeContributor contributor;
+        MockDecodeContributor nullContributor;
 
-	public final void testEncodeAttributeParameters() throws IOException {
+        inputContributor = new MockDecodeContributor(UIComponent.class, ".1;");
+        formContributor = new MockDecodeContributor(UIComponent.class, ".2;");
+        contributor = new MockDecodeContributor(UIComponent.class, ".3;");
+        nullContributor = new MockDecodeContributor(UIForm.class, (String) null);
+        compositeRenderer.addContributor(contributor);
+        compositeRenderer.addContributor(formContributor);
+        compositeRenderer.addContributor(inputContributor);
+        compositeRenderer.addContributor(nullContributor);
 
-		MockAttributeParameterEncoder encoder1 = new MockAttributeParameterEncoder("Attribute");
-		MockAttributeParameterEncoder encoder2 = new MockAttributeParameterEncoder("MoreAttribute");
-		
-		compositeRenderer.addParameterEncoder(encoder1);
-		compositeRenderer.addParameterEncoder(encoder2);
+        UIInput input = new UIInput();
 
-		UIInput input = new UIInput();
-		input.getAttributes().put("Attribute", "testValue1");
-		input.getAttributes().put("MoreAttribute", "testValue2");
-		
-		//ResponseWriter responseWriter = facesContext.getResponseWriter();
-		StringWriter stringWriter = new StringWriter();
-		ResponseWriter responseWriter = facesContext.getRenderKit().createResponseWriter(stringWriter, "text/html", "UTF8");
-		facesContext.setResponseWriter(responseWriter);
+        input.getAttributes().put("test", ".testValue");
 
-		responseWriter.startDocument();
-		responseWriter.startElement("span", input);
-		compositeRenderer.encodeAttributeParameters(facesContext, input);
-		responseWriter.endElement("span");
-		responseWriter.endDocument();
-		
-		responseWriter.flush();
-		
-		String result = stringWriter.getBuffer().toString();
-		assertTrue(result.contains("testAttribute=\"testValue1\""));
-		assertTrue(result.contains("testMoreAttribute=\"testValue2\""));
-	}
-}
+        String contributions = compositeRenderer.getScriptContributions("theVar", facesContext, input);
 
-class MockDecodeContributor implements RendererContributor {
+        assertEquals("theVar.testValue.3;theVar.testValue.2;theVar.testValue.1;", contributions);
+    }
 
-	private String[] scriptDependencies;
-	private String[] styleDependencies;
-	
-	private String scriptContribution;
-	
-	private Class componentClass;
-	private FacesContext context;
-	private UIComponent component;
-	private CompositeRenderer renderer;
-	private ScriptOptions options;
-	
-	public MockDecodeContributor(Class componentClass, ScriptOptions options) {
-		super();
+    public final void testGetScriptContributionsStringFacesContextUIComponentClass() {
+        MockDecodeContributor inputContributor;
+        MockDecodeContributor formContributor;
+        MockDecodeContributor contributor;
+        MockDecodeContributor nullContributor;
 
-		this.componentClass = componentClass;
-		this.options = options;
-	}
+        inputContributor = new MockDecodeContributor(UIInput.class, ".input;");
+        formContributor = new MockDecodeContributor(NamingContainer.class, ".namingContainer;");
+        contributor = new MockDecodeContributor(UIComponent.class, ".generic;");
+        nullContributor = new MockDecodeContributor(UIForm.class, (String) null);
+        compositeRenderer.addContributor(contributor);
+        compositeRenderer.addContributor(formContributor);
+        compositeRenderer.addContributor(inputContributor);
+        compositeRenderer.addContributor(nullContributor);
 
-	public MockDecodeContributor() {
-		this(UIComponent.class);
-	}
-	
-	public MockDecodeContributor(Class componentClass) {
-		super();
-		this.componentClass = componentClass;
-	}
+        UIInput input = new UIInput();
 
-	public MockDecodeContributor(Class componentClass, String scriptContribution) {
-		super();
+        input.getAttributes().put("test", ".testValue");
 
-		this.componentClass = componentClass;
-		this.scriptContribution = scriptContribution;
-	}
+        String contributions = compositeRenderer.getScriptContributions("theVar", facesContext, input, UIForm.class);
 
-	public MockDecodeContributor(Class componentClass, String[] scriptDependencies,
-			String[] styleDependencies) {
-		super();
-		
-		this.componentClass = componentClass;
-		this.scriptDependencies = scriptDependencies;
-		this.styleDependencies = styleDependencies;
-	}
+        assertEquals("theVar.testValue.generic;theVar.testValue.namingContainer;", contributions);
+    }
 
-	public void decode(FacesContext context, UIComponent component,
-			CompositeRenderer compositeRenderer) {
+    public final void testAddContributor() {
+        MockDecodeContributor[] contributors = new MockDecodeContributor[5];
 
-		this.component = component;
-		this.context = context;
-		this.renderer = compositeRenderer;
-	}
+        for (int i = 0; i < contributors.length; i++) {
+            contributors[i] = new MockDecodeContributor();
+            compositeRenderer.addContributor(contributors[i]);
+        }
 
-	public Class getAcceptableClass() {
-		return componentClass;
-	}
+        assertTrue(Arrays.deepEquals(contributors, compositeRenderer.getContributors()));
+    }
 
-	public String getScriptContribution(FacesContext context,
-			UIComponent component) {
-		return scriptContribution != null ? component.getAttributes().get("test") + scriptContribution :
-			null;
-	}
+    public final void testContributorDecodeCallback() {
+        MockDecodeContributor inputContributor;
+        MockDecodeContributor formContributor;
 
-	public String[] getScriptDependencies() {
-		return scriptDependencies;
-	}
+        formContributor = new MockDecodeContributor(NamingContainer.class);
+        inputContributor = new MockDecodeContributor(UIInput.class);
+        compositeRenderer.addContributor(inputContributor);
+        compositeRenderer.addContributor(formContributor);
 
-	public String[] getStyleDependencies() {
-		return styleDependencies;
-	}
+        UIComponent component = new UIInput();
 
-	public ScriptOptions buildOptions(FacesContext context,
-			UIComponent component) {
-		return options;
-	}
-	
-	public UIComponent getComponent() {
-		return component;
-	}
-	
-	public FacesContext getContext() {
-		return context;
-	}
-	
-	public CompositeRenderer getRenderer() {
-		return renderer;
-	}
-	
-	public void reset() {
-		this.component = null;
-		this.context = null;
-		this.renderer = null;
-	}
+        compositeRenderer.doDecode(facesContext, component);
+        assertSame(compositeRenderer, inputContributor.getRenderer());
+        assertSame(facesContext, inputContributor.getContext());
+        assertSame(component, inputContributor.getComponent());
+        assertNull(formContributor.getRenderer());
+        assertNull(formContributor.getContext());
+        assertNull(formContributor.getComponent());
+        inputContributor.reset();
+        formContributor.reset();
+        assertNull(inputContributor.getRenderer());
+        assertNull(inputContributor.getContext());
+        assertNull(inputContributor.getComponent());
+        assertNull(formContributor.getRenderer());
+        assertNull(formContributor.getContext());
+        assertNull(formContributor.getComponent());
+        component = new UIForm();
+        compositeRenderer.doDecode(facesContext, component);
+        assertSame(compositeRenderer, formContributor.getRenderer());
+        assertSame(facesContext, formContributor.getContext());
+        assertSame(component, formContributor.getComponent());
+        assertNull(inputContributor.getRenderer());
+        assertNull(inputContributor.getContext());
+        assertNull(inputContributor.getComponent());
+    }
+
+    public final void testAddParameterEncoder() {
+        MockAttributeParameterEncoder[] encoders = new MockAttributeParameterEncoder[5];
+
+        for (int i = 0; i < encoders.length; i++) {
+            encoders[i] = new MockAttributeParameterEncoder("aaa");
+            compositeRenderer.addParameterEncoder(encoders[i]);
+        }
+
+        assertTrue(Arrays.deepEquals(encoders, compositeRenderer.getParameterEncoders()));
+    }
+
+    public final void testEncodeAttributeParameters() throws IOException {
+        MockAttributeParameterEncoder encoder1 = new MockAttributeParameterEncoder("Attribute");
+        MockAttributeParameterEncoder encoder2 = new MockAttributeParameterEncoder("MoreAttribute");
+
+        compositeRenderer.addParameterEncoder(encoder1);
+        compositeRenderer.addParameterEncoder(encoder2);
+
+        UIInput input = new UIInput();
+
+        input.getAttributes().put("Attribute", "testValue1");
+        input.getAttributes().put("MoreAttribute", "testValue2");
+
+        // ResponseWriter responseWriter = facesContext.getResponseWriter();
+        StringWriter stringWriter = new StringWriter();
+        ResponseWriter responseWriter = facesContext.getRenderKit().createResponseWriter(stringWriter, "text/html",
+                                            "UTF8");
+
+        facesContext.setResponseWriter(responseWriter);
+        responseWriter.startDocument();
+        responseWriter.startElement("span", input);
+        compositeRenderer.encodeAttributeParameters(facesContext, input);
+        responseWriter.endElement("span");
+        responseWriter.endDocument();
+        responseWriter.flush();
+
+        String result = stringWriter.getBuffer().toString();
+
+        assertTrue(result.contains("testAttribute=\"testValue1\""));
+        assertTrue(result.contains("testMoreAttribute=\"testValue2\""));
+    }
 }
 
+
 class MockAttributeParameterEncoder implements AttributeParametersEncoder {
+    private String attributeName;
 
-	private String attributeName;
-	
-	public MockAttributeParameterEncoder(String attributeName) {
-		super();
-		this.attributeName = attributeName;
-	}
+    public MockAttributeParameterEncoder(String attributeName) {
+        super();
+        this.attributeName = attributeName;
+    }
 
-	public void doEncode(FacesContext context, UIComponent component)
-			throws IOException {
+    public void doEncode(FacesContext context, UIComponent component) throws IOException {
+        context.getResponseWriter().writeAttribute("test" + attributeName,
+                component.getAttributes().get(attributeName), null);
+    }
+}
 
-		context.getResponseWriter().writeAttribute("test" + attributeName, component.getAttributes().get(attributeName)
-				, null);
-	}
+
+class MockDecodeContributor implements RendererContributor {
+    private UIComponent component;
+    private Class componentClass;
+    private FacesContext context;
+    private ScriptOptions options;
+    private CompositeRenderer renderer;
+    private String scriptContribution;
+    private String[] scriptDependencies;
+    private String[] styleDependencies;
+
+    public MockDecodeContributor() {
+        this(UIComponent.class);
+    }
+
+    public MockDecodeContributor(Class componentClass) {
+        super();
+        this.componentClass = componentClass;
+    }
+
+    public MockDecodeContributor(Class componentClass, ScriptOptions options) {
+        super();
+        this.componentClass = componentClass;
+        this.options = options;
+    }
+
+    public MockDecodeContributor(Class componentClass, String scriptContribution) {
+        super();
+        this.componentClass = componentClass;
+        this.scriptContribution = scriptContribution;
+    }
+
+    public MockDecodeContributor(Class componentClass, String[] scriptDependencies, String[] styleDependencies) {
+        super();
+        this.componentClass = componentClass;
+        this.scriptDependencies = scriptDependencies;
+        this.styleDependencies = styleDependencies;
+    }
+
+    public void decode(FacesContext context, UIComponent component, CompositeRenderer compositeRenderer) {
+        this.component = component;
+        this.context = context;
+        this.renderer = compositeRenderer;
+    }
+
+    public Class getAcceptableClass() {
+        return componentClass;
+    }
+
+    public String getScriptContribution(FacesContext context, UIComponent component) {
+        return scriptContribution != null ? component.getAttributes().get("test") + scriptContribution : null;
+    }
+
+    public String[] getScriptDependencies() {
+        return scriptDependencies;
+    }
+
+    public String[] getStyleDependencies() {
+        return styleDependencies;
+    }
+
+    public ScriptOptions buildOptions(FacesContext context, UIComponent component) {
+        return options;
+    }
+
+    public UIComponent getComponent() {
+        return component;
+    }
+
+    public FacesContext getContext() {
+        return context;
+    }
+
+    public CompositeRenderer getRenderer() {
+        return renderer;
+    }
+
+    public void reset() {
+        this.component = null;
+        this.context = null;
+        this.renderer = null;
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit;
 
 import java.io.StringWriter;
@@ -35,75 +37,74 @@
  * @author Nick Belaevski - mailto:nbelaevski at exadel.com
  * @since 3.2
  */
-
 public class TemplateEncoderRendererBaseTest extends AbstractFacesTest {
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        setupFacesRequest();
+    }
 
-	@Override
-	public void setUp() throws Exception {
-		super.setUp();
-		setupFacesRequest();
-	}
-	
-	@Override
-	public void tearDown() throws Exception {
-		super.tearDown();
-	}
-	
-	public void testEncodeNonRendered() throws Exception {
-		ResponseWriter responseWriter = facesContext.getRenderKit().createResponseWriter(new StringWriter(), "text/html", "UTF-8");
-		facesContext.setResponseWriter(responseWriter);
-		
-		TemplateEncoderRendererBase rendererBase = new TemplateEncoderRendererBase() {
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-			@Override
-			protected Class<? extends UIComponent> getComponentClass() {
-				return UIOutput.class;
-			}
-		};
-		
-		UIOutput output = new UIOutput();
+    public void testEncodeNonRendered() throws Exception {
+        ResponseWriter responseWriter = facesContext.getRenderKit().createResponseWriter(new StringWriter(),
+                                            "text/html", "UTF-8");
 
-		UIOutput c = new UIOutput();
-		c.setRendered(false);
-		c.setValue("");
-		output.getChildren().add(c);
-		
-		//that should not fail
-		rendererBase.writeScriptBody(facesContext, c, true);
-	}
+        facesContext.setResponseWriter(responseWriter);
 
-	public void testEncode() throws Exception {
-		StringWriter controlWriter = new StringWriter();
-		ResponseWriter responseWriter = facesContext.getRenderKit().createResponseWriter(controlWriter, "text/html", "UTF-8");
-		facesContext.setResponseWriter(responseWriter);
-		
-		TemplateEncoderRendererBase rendererBase = new TemplateEncoderRendererBase() {
+        TemplateEncoderRendererBase rendererBase = new TemplateEncoderRendererBase() {
+            @Override
+            protected Class<? extends UIComponent> getComponentClass() {
+                return UIOutput.class;
+            }
+        };
+        UIOutput output = new UIOutput();
+        UIOutput c = new UIOutput();
 
-			@Override
-			protected Class<? extends UIComponent> getComponentClass() {
-				return UIOutput.class;
-			}
-		};
-		
-		HtmlPanelGroup c = new HtmlPanelGroup();
+        c.setRendered(false);
+        c.setValue("");
+        output.getChildren().add(c);
 
-		for (int i = 0; i < 3; i++) {
-			HtmlPanelGroup c1 = new HtmlPanelGroup();
-			c1.setId("panel" + i);
-			
-			UIOutput text = new UIOutput();
-			text.setValue("some text");
-			
-			c1.getChildren().add(text);
-			UIOutput text2 = new UIOutput();
-			text2.setValue("some text");
-			c.getChildren().add(text2);
-			c.getChildren().add(c1);
+        // that should not fail
+        rendererBase.writeScriptBody(facesContext, c, true);
+    }
 
-		}
-		
-		rendererBase.writeScriptBody(facesContext, c, false);
-		System.out.println(controlWriter.toString());
-	}
+    public void testEncode() throws Exception {
+        StringWriter controlWriter = new StringWriter();
+        ResponseWriter responseWriter = facesContext.getRenderKit().createResponseWriter(controlWriter, "text/html",
+                                            "UTF-8");
 
+        facesContext.setResponseWriter(responseWriter);
+
+        TemplateEncoderRendererBase rendererBase = new TemplateEncoderRendererBase() {
+            @Override
+            protected Class<? extends UIComponent> getComponentClass() {
+                return UIOutput.class;
+            }
+        };
+        HtmlPanelGroup c = new HtmlPanelGroup();
+
+        for (int i = 0; i < 3; i++) {
+            HtmlPanelGroup c1 = new HtmlPanelGroup();
+
+            c1.setId("panel" + i);
+
+            UIOutput text = new UIOutput();
+
+            text.setValue("some text");
+            c1.getChildren().add(text);
+
+            UIOutput text2 = new UIOutput();
+
+            text2.setValue("some text");
+            c.getChildren().add(text2);
+            c.getChildren().add(c1);
+        }
+
+        rendererBase.writeScriptBody(facesContext, c, false);
+        System.out.println(controlWriter.toString());
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,9 +19,12 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit;
 
 import java.io.StringReader;
+
 import java.util.List;
 
 import junit.framework.TestCase;
@@ -34,12 +37,11 @@
  *
  */
 public class TemplateUtilTest extends TestCase {
+    public void testAntlr() throws Exception {
+        List result = new RichMacroDefinition(new StringReader("{aa{b\\}}a}\\\\ a\\}b\\{c")).expression();
+        Expression holder = (Expression) result.get(0);
 
-
-	public void testAntlr() throws Exception {
-		List result = new RichMacroDefinition(new StringReader("{aa{b\\}}a}\\\\ a\\}b\\{c")).expression();
-		Expression holder = (Expression) result.get(0);
-		assertEquals("aa{b}}a", holder.getExpression());
-		assertEquals("\\ a}b{c", result.get(1));
-	}
+        assertEquals("aa{b}}a", holder.getExpression());
+        assertEquals("\\ a}b{c", result.get(1));
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/html/images/GradientEnumsTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/html/images/GradientEnumsTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/html/images/GradientEnumsTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.renderkit.html.images;
 
 import java.util.Locale;
@@ -29,19 +31,17 @@
  * Covers https://jira.jboss.org/jira/browse/RF-4142
  */
 public class GradientEnumsTest extends TestCase {
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        Locale.setDefault(new Locale("tr", "TR"));
+    }
 
-	@Override
-	protected void setUp() throws Exception {
-		super.setUp();
+    public void testAlignment() throws Exception {
+        GradientAlignment.MIDDLE.equals(GradientAlignment.getByParameter("middle"));
+    }
 
-		Locale.setDefault(new Locale("tr", "TR"));
-	}
-	
-	public void testAlignment() throws Exception {
-		GradientAlignment.MIDDLE.equals(GradientAlignment.getByParameter("middle"));
-	}
-	
-	public void testType() throws Exception {
-		GradientType.PLAIN.equals(GradientType.getByParameter("plain"));
-	}
+    public void testType() throws Exception {
+        GradientType.PLAIN.equals(GradientType.getByParameter("plain"));
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,12 +19,16 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
+
 import java.net.URL;
 import java.net.URLConnection;
+
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.Date;
@@ -35,361 +39,351 @@
 import javax.faces.context.FacesContext;
 
 import org.easymock.EasyMock;
+
 import org.richfaces.test.AbstractFacesTest;
 import org.richfaces.util.Util;
 
-
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public class AbstractBaseResourceTest extends AbstractFacesTest {
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        setupFacesRequest();
+    }
 
-	@Override
-	public void setUp() throws Exception {
-		super.setUp();
-		setupFacesRequest();
-	}
-	
-	@Override
-	public void tearDown() throws Exception {
-		super.tearDown();
-	}
-	
-	private class ResourceImpl extends AbstractBaseResource {
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-		@Override
-		public InputStream getInputStream() {
-			throw new UnsupportedOperationException();
-		}
+    public void testGetHeaders() throws Exception {
+        MockResourceImpl mockResource = new MockResourceImpl();
 
-		public ResourceImpl() {
-			super();
-			
-			setResourceName("org.richfaces.resource.ResourceImpl");
-		}
-	}
-	
-	private class MockStateAwareResourceImpl extends MockResourceImpl implements StateHolder {
+        mockResource.setCacheable(true);
+        mockResource.setEntityTag("\"etag0\"");
+        mockResource.setContentLength(80);
+        mockResource.setContentType("image/png");
 
-		private Object resourceState;
-		
-		private boolean _transient = false;
-		
-		public MockStateAwareResourceImpl() {
-			super();
-			
-			setResourceName("org.richfaces.resource.MockStateAwareResource");
-		}
-		
-		public boolean isTransient() {
-			return _transient;
-		}
+        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
 
-		public void setTransient(boolean newTransientValue) {
-			this._transient = newTransientValue;
-		}
+        calendar.clear();
+        calendar.set(2009, Calendar.JULY, 13, 12, 45, 9);
+        mockResource.setLastModified(calendar.getTime());
+        calendar.add(Calendar.DATE, 1);
+        mockResource.setCurrentTime(calendar.getTimeInMillis());
+        calendar.add(Calendar.DATE, 7);
+        mockResource.setExpired(calendar.getTime());
 
-		public Object saveState(FacesContext context) {
-			return resourceState;
-		}
-		
-		public void restoreState(FacesContext context, Object state) {
-			this.resourceState = state;
-		}
-		
-	}
-	
-	private class MockResourceImpl extends AbstractBaseResource {
+        Map<String, String> headers = mockResource.getResponseHeaders();
 
-		private String version;
-		
-		private int contentLength = -1;
-		
-		private InputStream inputStream;
-		
-		private Date lastModified;
-		
-		private Date expired;
-		
-		private long currentTime;
-		
-		private String entityTag;
-		
-		private int ttl;
-		
-		public MockResourceImpl() {
-			super();
-			
-			setResourceName("org.richfaces.resource.MockResource");
-		}
-		
-		@Override
-		protected int getContentLength(FacesContext context) {
-			return contentLength;
-		}
-		
-		@Override
-		public InputStream getInputStream() {
-			return inputStream;
-		}
+        assertEquals("Tue, 21 Jul 2009 12:45:09 GMT", headers.get("Expires"));
+        assertEquals("Mon, 13 Jul 2009 12:45:09 GMT", headers.get("Last-Modified"));
+        assertEquals("Tue, 14 Jul 2009 12:45:09 GMT", headers.get("Date"));
+        assertEquals("\"etag0\"", headers.get("ETag"));
+        assertEquals("max-age=604800", headers.get("Cache-Control"));
+        assertEquals("80", headers.get("Content-Length"));
+        assertEquals("image/png", headers.get("Content-Type"));
+        assertEquals(7, headers.size());
+        mockResource.setTimeToLive(14 * 24 * 60 * 60 /* 14 days */);
+        headers = mockResource.getResponseHeaders();
+        assertEquals("Tue, 28 Jul 2009 12:45:09 GMT", headers.get("Expires"));
+        assertEquals("Mon, 13 Jul 2009 12:45:09 GMT", headers.get("Last-Modified"));
+        assertEquals("Tue, 14 Jul 2009 12:45:09 GMT", headers.get("Date"));
+        assertEquals("max-age=1209600", headers.get("Cache-Control"));
+    }
 
-		/* (non-Javadoc)
-		 * @see org.richfaces.resource.ResourceImpl#getVersion()
-		 */
-		@Override
-		public String getVersion() {
-			return version;
-		}
-		
-		public void setVersion(String version) {
-			this.version = version;
-		}
+    public void testGetHeadersNonCacheable() throws Exception {
+        MockResourceImpl mockResource = new MockResourceImpl();
 
-		public void setContentLength(int contentLength) {
-			this.contentLength = contentLength;
-		}
+        mockResource.setCacheable(false);
+        mockResource.setContentLength(120);
+        mockResource.setContentType("image/jpg");
+        mockResource.setEntityTag("\"etag1\"");
 
-		public void setInputStream(InputStream inputStream) {
-			this.inputStream = inputStream;
-		}
+        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
 
-		@Override
-		protected Date getLastModified(FacesContext context) {
-			return lastModified;
-		}
-		
-		public void setLastModified(Date lastModified) {
-			this.lastModified = lastModified;
-		}
-		
-		@Override
-		protected Date getExpires(FacesContext context) {
-			return expired;
-		}
-		
-		public void setExpired(Date expired) {
-			this.expired = expired;
-		}
-		
-		@Override
-		protected String getEntityTag(FacesContext context) {
-			return entityTag;
-		}
-		
-		/**
-		 * @param entityTag the entityTag to set
-		 */
-		public void setEntityTag(String entityTag) {
-			this.entityTag = entityTag;
-		}
-		
-		@Override
-		boolean isResourceRequest() {
-			return true;
-		}
-		
-		@Override
-		protected long getCurrentTime() {
-			return currentTime;
-		}
-		
-		void setCurrentTime(long currentTime) {
-			this.currentTime = currentTime;
-		}
-		
-		@Override
-		protected int getTimeToLive(FacesContext context) {
-			return ttl;
-		}
-		
-		public void setTimeToLive(int ttl) {
-			this.ttl = ttl;
-		}
-	}
-	
-	public void testGetHeaders() throws Exception {
-		MockResourceImpl mockResource = new MockResourceImpl();
-		mockResource.setCacheable(true);
-		mockResource.setEntityTag("\"etag0\"");
-		
-		mockResource.setContentLength(80);
-		mockResource.setContentType("image/png");
-		
-		Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
-		calendar.clear();
-		calendar.set(2009, Calendar.JULY, 13, 12, 45, 9);
-		
-		mockResource.setLastModified(calendar.getTime());
-		calendar.add(Calendar.DATE, 1);
-		mockResource.setCurrentTime(calendar.getTimeInMillis());
-		calendar.add(Calendar.DATE, 7);
-		mockResource.setExpired(calendar.getTime());
-		
-		Map<String, String> headers = mockResource.getResponseHeaders();
-		assertEquals("Tue, 21 Jul 2009 12:45:09 GMT", headers.get("Expires"));
-		assertEquals("Mon, 13 Jul 2009 12:45:09 GMT", headers.get("Last-Modified"));
-		assertEquals("Tue, 14 Jul 2009 12:45:09 GMT", headers.get("Date"));
+        calendar.clear();
+        calendar.set(2009, Calendar.JULY, 13, 12, 45, 9);
+        mockResource.setLastModified(calendar.getTime());
+        calendar.add(Calendar.DATE, 1);
+        mockResource.setCurrentTime(calendar.getTimeInMillis());
+        calendar.add(Calendar.DATE, 7);
+        mockResource.setExpired(calendar.getTime());
 
-		assertEquals("\"etag0\"", headers.get("ETag"));
-		assertEquals("max-age=604800", headers.get("Cache-Control"));
-	
-		assertEquals("80", headers.get("Content-Length"));
-		assertEquals("image/png", headers.get("Content-Type"));
-		
-		assertEquals(7, headers.size());
+        Map<String, String> headers = mockResource.getResponseHeaders();
 
-		mockResource.setTimeToLive(14 * 24 * 60 * 60 /* 14 days */);
-		headers = mockResource.getResponseHeaders();
-		assertEquals("Tue, 28 Jul 2009 12:45:09 GMT", headers.get("Expires"));
-		assertEquals("Mon, 13 Jul 2009 12:45:09 GMT", headers.get("Last-Modified"));
-		assertEquals("Tue, 14 Jul 2009 12:45:09 GMT", headers.get("Date"));
-		assertEquals("max-age=1209600", headers.get("Cache-Control"));
-	}
-	
-	public void testGetHeadersNonCacheable() throws Exception {
-		MockResourceImpl mockResource = new MockResourceImpl();
-		mockResource.setCacheable(false);
-		
-		mockResource.setContentLength(120);
-		mockResource.setContentType("image/jpg");
-		mockResource.setEntityTag("\"etag1\"");
-		
-		Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
-		calendar.clear();
-		calendar.set(2009, Calendar.JULY, 13, 12, 45, 9);
-		
-		mockResource.setLastModified(calendar.getTime());
-		calendar.add(Calendar.DATE, 1);
-		mockResource.setCurrentTime(calendar.getTimeInMillis());
-		calendar.add(Calendar.DATE, 7);
-		mockResource.setExpired(calendar.getTime());
-		
-		Map<String, String> headers = mockResource.getResponseHeaders();
-		assertEquals("0", headers.get("Expires"));
-		assertEquals("max-age=0, no-store, no-cache", headers.get("Cache-Control"));
-		assertEquals("no-cache", headers.get("Pragma"));
-		assertEquals("120", headers.get("Content-Length"));
-		assertEquals("image/jpg", headers.get("Content-Type"));
-		assertEquals("Mon, 13 Jul 2009 12:45:09 GMT", headers.get("Last-Modified"));
-		assertEquals("Tue, 14 Jul 2009 12:45:09 GMT", headers.get("Date"));
+        assertEquals("0", headers.get("Expires"));
+        assertEquals("max-age=0, no-store, no-cache", headers.get("Cache-Control"));
+        assertEquals("no-cache", headers.get("Pragma"));
+        assertEquals("120", headers.get("Content-Length"));
+        assertEquals("image/jpg", headers.get("Content-Type"));
+        assertEquals("Mon, 13 Jul 2009 12:45:09 GMT", headers.get("Last-Modified"));
+        assertEquals("Tue, 14 Jul 2009 12:45:09 GMT", headers.get("Date"));
+        assertEquals(7, headers.size());
+    }
 
-		assertEquals(7, headers.size());
-	}
+    public void testGetRequestPath() throws Exception {
+        Object resourceState = new Object();
+        ResourceCodec resourceCodec = EasyMock.createMock(ResourceCodec.class);
 
-	public void testGetRequestPath() throws Exception {
-		Object resourceState = new Object();
-		
-		ResourceCodec resourceCodec = EasyMock.createMock(ResourceCodec.class);
-		EasyMock.expect(resourceCodec.encodeResource(EasyMock.eq("org.richfaces.resource.MockStateAwareResource"), 
-			EasyMock.same(resourceState), EasyMock.eq("4_0_alpha"))).andReturn("Resource0/4_0_alpha/data");
+        EasyMock.expect(resourceCodec.encodeResource(EasyMock.eq("org.richfaces.resource.MockStateAwareResource"),
+                EasyMock.same(resourceState), EasyMock.eq("4_0_alpha"))).andReturn("Resource0/4_0_alpha/data");
+        EasyMock.expect(resourceCodec.encodeResource(EasyMock.eq("org.richfaces.resource.MockStateAwareResource"),
+                EasyMock.eq(null), EasyMock.eq("4_0_alpha"))).andReturn("Resource1/4_0_alpha");
+        EasyMock.expect(resourceCodec.encodeResource(EasyMock.eq("org.richfaces.resource.MockResource"),
+                EasyMock.eq(null), EasyMock.eq("4_0_alpha"))).andReturn("Resource2/4_0_alpha");
+        EasyMock.replay(resourceCodec);
+        ResourceHandlerImpl.setResourceCodec(resourceCodec);
 
-		EasyMock.expect(resourceCodec.encodeResource(EasyMock.eq("org.richfaces.resource.MockStateAwareResource"), 
-				EasyMock.eq(null), EasyMock.eq("4_0_alpha"))).andReturn("Resource1/4_0_alpha");
-		
-		EasyMock.expect(resourceCodec.encodeResource(EasyMock.eq("org.richfaces.resource.MockResource"), 
-				EasyMock.eq(null), EasyMock.eq("4_0_alpha"))).andReturn("Resource2/4_0_alpha");
+        MockStateAwareResourceImpl stateAwareResourceImpl = new MockStateAwareResourceImpl();
 
-		EasyMock.replay(resourceCodec);
-		ResourceHandlerImpl.setResourceCodec(resourceCodec);
+        stateAwareResourceImpl.setVersion("4_0_alpha");
+        stateAwareResourceImpl.restoreState(facesContext, resourceState);
+        assertEquals("org.richfaces.resource.MockStateAwareResource", stateAwareResourceImpl.getResourceName());
+        assertEquals("/rfRes/Resource0/4_0_alpha/data.jsf", stateAwareResourceImpl.getRequestPath());
+        stateAwareResourceImpl.setTransient(true);
+        assertEquals("/rfRes/Resource1/4_0_alpha.jsf", stateAwareResourceImpl.getRequestPath());
 
-		MockStateAwareResourceImpl stateAwareResourceImpl = new MockStateAwareResourceImpl();
-		stateAwareResourceImpl.setVersion("4_0_alpha");
-		stateAwareResourceImpl.restoreState(facesContext, resourceState);
-		
-		assertEquals("org.richfaces.resource.MockStateAwareResource", stateAwareResourceImpl.getResourceName());
-		assertEquals("/rfRes/Resource0/4_0_alpha/data.jsf", stateAwareResourceImpl.getRequestPath());
+        MockResourceImpl resourceImpl = new MockResourceImpl();
 
-		stateAwareResourceImpl.setTransient(true);
+        resourceImpl.setVersion("4_0_alpha");
+        assertEquals("org.richfaces.resource.MockResource", resourceImpl.getResourceName());
+        assertEquals("/rfRes/Resource2/4_0_alpha.jsf", resourceImpl.getRequestPath());
+        EasyMock.verify(resourceCodec);
+    }
 
-		assertEquals("/rfRes/Resource1/4_0_alpha.jsf", stateAwareResourceImpl.getRequestPath());
-		
-		MockResourceImpl resourceImpl = new MockResourceImpl();
-		resourceImpl.setVersion("4_0_alpha");
-		
-		assertEquals("org.richfaces.resource.MockResource", resourceImpl.getResourceName());
+    public void testGetURL() throws Exception {
+        InputStream stream = new ByteArrayInputStream(new byte[0]);
+        MockResourceImpl mockResource = new MockResourceImpl();
 
-		assertEquals("/rfRes/Resource2/4_0_alpha.jsf", resourceImpl.getRequestPath());
-		EasyMock.verify(resourceCodec);
-	}
-	
-	public void testGetURL() throws Exception {
-		InputStream stream = new ByteArrayInputStream(new byte[0]);
-		MockResourceImpl mockResource = new MockResourceImpl();
-		mockResource.setContentLength(130);
-		mockResource.setContentType("image/gif");
-		mockResource.setInputStream(stream);
-		
-		Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
-		calendar.clear();
-		calendar.set(2009, Calendar.JUNE, 12, 21, 38, 59);
-		Date lastModified = calendar.getTime();
-		mockResource.setLastModified(lastModified);
-		calendar.add(Calendar.MONTH, 1);
-		
-		Date expired = calendar.getTime();
-		mockResource.setExpired(expired);
-		
-		URL url = mockResource.getURL();
-		
-		assertNotNull(url);
-		assertEquals("jsfresource:org.richfaces.resource.MockResource", url.toExternalForm());
+        mockResource.setContentLength(130);
+        mockResource.setContentType("image/gif");
+        mockResource.setInputStream(stream);
 
-		URLConnection urlConnection = url.openConnection();
-		assertNotNull(urlConnection);
-		
-		urlConnection.connect();
-		assertEquals(130, urlConnection.getContentLength());
-		assertEquals("image/gif", urlConnection.getContentType());
-		assertEquals(lastModified.getTime(), urlConnection.getLastModified());
-		assertEquals(expired.getTime(), urlConnection.getExpiration());
-		assertSame(stream, urlConnection.getInputStream());
-		assertSame(url, urlConnection.getURL());
+        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
 
-		MockResourceImpl mockResource2 = new MockResourceImpl();
-		URLConnection urlConnection2 = mockResource2.getURL().openConnection();
-		urlConnection2.connect();
-		assertEquals(-1, urlConnection2.getContentLength());
-		assertNull(urlConnection2.getContentType());
-		assertEquals(0, urlConnection2.getLastModified());
-		assertTrue(urlConnection2.getExpiration() > 0);
-	}
-	
-	public void testDefaults() throws Exception {
-		ResourceImpl defaultResource = new ResourceImpl();
-		assertTrue(defaultResource.isCacheable(facesContext));
-		assertEquals("org.richfaces.resource.ResourceImpl", defaultResource.getResourceName());
-		assertEquals(-1, defaultResource.getContentLength(facesContext));
-		assertNull(defaultResource.getEntityTag(facesContext));
-		assertNull(defaultResource.getVersion());
-		assertNull(defaultResource.getExpires(facesContext));
-		Date lastModified = defaultResource.getLastModified(facesContext);
-		assertNotNull(lastModified);
-		assertTrue(System.currentTimeMillis() >= lastModified.getTime());
+        calendar.clear();
+        calendar.set(2009, Calendar.JUNE, 12, 21, 38, 59);
 
-		ResourceImpl defaultETagResource = new ResourceImpl() {
-			protected Date getLastModified(FacesContext context) { return new Date(12471234567890l); };
-			
-			protected int getContentLength(FacesContext context) { return 1297; };
-		};
-		
-		assertEquals("W/\"1297-12471234567890\"", defaultETagResource.getEntityTag(facesContext));
-	}
+        Date lastModified = calendar.getTime();
 
-	public void testUserAgentNeedsUpdate() throws Exception {
-		long currentTime = System.currentTimeMillis();
-		
-		MockResourceImpl actualResource = new MockResourceImpl();
-		actualResource.setLastModified(new Date(currentTime - 30000));
+        mockResource.setLastModified(lastModified);
+        calendar.add(Calendar.MONTH, 1);
 
-		MockResourceImpl expiredResource = new MockResourceImpl();
-		expiredResource.setLastModified(new Date(currentTime - 10000));
-	
-		this.connection.addRequestHeaders(Collections.singletonMap("If-Modified-Since", 
-			Util.formatHttpDate(new Date(currentTime - 20000))));
-	
-		assertTrue(expiredResource.userAgentNeedsUpdate(facesContext));
-		assertFalse(actualResource.userAgentNeedsUpdate(facesContext));
-	}
-}
+        Date expired = calendar.getTime();
 
+        mockResource.setExpired(expired);
+
+        URL url = mockResource.getURL();
+
+        assertNotNull(url);
+        assertEquals("jsfresource:org.richfaces.resource.MockResource", url.toExternalForm());
+
+        URLConnection urlConnection = url.openConnection();
+
+        assertNotNull(urlConnection);
+        urlConnection.connect();
+        assertEquals(130, urlConnection.getContentLength());
+        assertEquals("image/gif", urlConnection.getContentType());
+        assertEquals(lastModified.getTime(), urlConnection.getLastModified());
+        assertEquals(expired.getTime(), urlConnection.getExpiration());
+        assertSame(stream, urlConnection.getInputStream());
+        assertSame(url, urlConnection.getURL());
+
+        MockResourceImpl mockResource2 = new MockResourceImpl();
+        URLConnection urlConnection2 = mockResource2.getURL().openConnection();
+
+        urlConnection2.connect();
+        assertEquals(-1, urlConnection2.getContentLength());
+        assertNull(urlConnection2.getContentType());
+        assertEquals(0, urlConnection2.getLastModified());
+        assertTrue(urlConnection2.getExpiration() > 0);
+    }
+
+    public void testDefaults() throws Exception {
+        ResourceImpl defaultResource = new ResourceImpl();
+
+        assertTrue(defaultResource.isCacheable(facesContext));
+        assertEquals("org.richfaces.resource.ResourceImpl", defaultResource.getResourceName());
+        assertEquals(-1, defaultResource.getContentLength(facesContext));
+        assertNull(defaultResource.getEntityTag(facesContext));
+        assertNull(defaultResource.getVersion());
+        assertNull(defaultResource.getExpires(facesContext));
+
+        Date lastModified = defaultResource.getLastModified(facesContext);
+
+        assertNotNull(lastModified);
+        assertTrue(System.currentTimeMillis() >= lastModified.getTime());
+
+        ResourceImpl defaultETagResource = new ResourceImpl() {
+            protected Date getLastModified(FacesContext context) {
+                return new Date(12471234567890l);
+            }
+            ;
+            protected int getContentLength(FacesContext context) {
+                return 1297;
+            }
+            ;
+        };
+
+        assertEquals("W/\"1297-12471234567890\"", defaultETagResource.getEntityTag(facesContext));
+    }
+
+    public void testUserAgentNeedsUpdate() throws Exception {
+        long currentTime = System.currentTimeMillis();
+        MockResourceImpl actualResource = new MockResourceImpl();
+
+        actualResource.setLastModified(new Date(currentTime - 30000));
+
+        MockResourceImpl expiredResource = new MockResourceImpl();
+
+        expiredResource.setLastModified(new Date(currentTime - 10000));
+        this.connection.addRequestHeaders(Collections.singletonMap("If-Modified-Since",
+                Util.formatHttpDate(new Date(currentTime - 20000))));
+        assertTrue(expiredResource.userAgentNeedsUpdate(facesContext));
+        assertFalse(actualResource.userAgentNeedsUpdate(facesContext));
+    }
+
+    private class MockResourceImpl extends AbstractBaseResource {
+        private int contentLength = -1;
+        private long currentTime;
+        private String entityTag;
+        private Date expired;
+        private InputStream inputStream;
+        private Date lastModified;
+        private int ttl;
+        private String version;
+
+        public MockResourceImpl() {
+            super();
+            setResourceName("org.richfaces.resource.MockResource");
+        }
+
+        @Override
+        protected int getContentLength(FacesContext context) {
+            return contentLength;
+        }
+
+        @Override
+        public InputStream getInputStream() {
+            return inputStream;
+        }
+
+        /*
+         *  (non-Javadoc)
+         * @see org.richfaces.resource.ResourceImpl#getVersion()
+         */
+        @Override
+        public String getVersion() {
+            return version;
+        }
+
+        public void setVersion(String version) {
+            this.version = version;
+        }
+
+        public void setContentLength(int contentLength) {
+            this.contentLength = contentLength;
+        }
+
+        public void setInputStream(InputStream inputStream) {
+            this.inputStream = inputStream;
+        }
+
+        @Override
+        protected Date getLastModified(FacesContext context) {
+            return lastModified;
+        }
+
+        public void setLastModified(Date lastModified) {
+            this.lastModified = lastModified;
+        }
+
+        @Override
+        protected Date getExpires(FacesContext context) {
+            return expired;
+        }
+
+        public void setExpired(Date expired) {
+            this.expired = expired;
+        }
+
+        @Override
+        protected String getEntityTag(FacesContext context) {
+            return entityTag;
+        }
+
+        /**
+         * @param entityTag the entityTag to set
+         */
+        public void setEntityTag(String entityTag) {
+            this.entityTag = entityTag;
+        }
+
+        @Override
+        boolean isResourceRequest() {
+            return true;
+        }
+
+        @Override
+        protected long getCurrentTime() {
+            return currentTime;
+        }
+
+        void setCurrentTime(long currentTime) {
+            this.currentTime = currentTime;
+        }
+
+        @Override
+        protected int getTimeToLive(FacesContext context) {
+            return ttl;
+        }
+
+        public void setTimeToLive(int ttl) {
+            this.ttl = ttl;
+        }
+    }
+
+
+    private class MockStateAwareResourceImpl extends MockResourceImpl implements StateHolder {
+        private boolean _transient = false;
+        private Object resourceState;
+
+        public MockStateAwareResourceImpl() {
+            super();
+            setResourceName("org.richfaces.resource.MockStateAwareResource");
+        }
+
+        public boolean isTransient() {
+            return _transient;
+        }
+
+        public void setTransient(boolean newTransientValue) {
+            this._transient = newTransientValue;
+        }
+
+        public Object saveState(FacesContext context) {
+            return resourceState;
+        }
+
+        public void restoreState(FacesContext context, Object state) {
+            this.resourceState = state;
+        }
+    }
+
+
+    private class ResourceImpl extends AbstractBaseResource {
+        public ResourceImpl() {
+            super();
+            setResourceName("org.richfaces.resource.ResourceImpl");
+        }
+
+        @Override
+        public InputStream getInputStream() {
+            throw new UnsupportedOperationException();
+        }
+    }
+}

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractCacheableResourceTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractCacheableResourceTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractCacheableResourceTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,12 +19,17 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
 import java.io.IOException;
 import java.io.InputStream;
+
 import java.net.URL;
+
 import java.text.SimpleDateFormat;
+
 import java.util.Collections;
 import java.util.Date;
 import java.util.Locale;
@@ -35,279 +40,277 @@
 
 import org.easymock.IAnswer;
 import org.easymock.classextension.EasyMock;
+
 import org.richfaces.test.AbstractFacesTest;
 
-
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public class AbstractCacheableResourceTest extends AbstractFacesTest {
+    private static final int MILLISECONDS_IN_HOUR = 60 * 60 * 1000;
 
-	private static final int MILLISECONDS_IN_HOUR = 60 * 60 * 1000;
-
-	/* HTTP Date format required by the HTTP/1.1 RFC */
+    /* HTTP Date format required by the HTTP/1.1 RFC */
     private static final String RFC1123_DATE_PATTERN = "EEE, dd MMM yyyy HH:mm:ss zzz";
-	
     private static final SimpleDateFormat RFC1123_DATE_FORMATTER;
-    
+
     static {
-    	SimpleDateFormat format = new SimpleDateFormat(RFC1123_DATE_PATTERN, Locale.US);
-    	format.setTimeZone(TimeZone.getTimeZone("GMT"));
+        SimpleDateFormat format = new SimpleDateFormat(RFC1123_DATE_PATTERN, Locale.US);
 
-    	RFC1123_DATE_FORMATTER = format;
+        format.setTimeZone(TimeZone.getTimeZone("GMT"));
+        RFC1123_DATE_FORMATTER = format;
     }
 
     @Override
-	public void setUp() throws Exception {
-		super.setUp();
-		setupFacesRequest();
-	}
-	
-	/* (non-Javadoc)
-	 * @see org.richfaces.test.AbstractFacesTest#tearDown()
-	 */
-	@Override
-	public void tearDown() throws Exception {
-		super.tearDown();
-	}
+    public void setUp() throws Exception {
+        super.setUp();
+        setupFacesRequest();
+    }
 
-	public void testInitialRequest() throws Exception {
-		MockAbstractResource defaultResource = new MockAbstractResource();
-		
-		assertNull(defaultResource.isMatchesEntityTag(facesContext));
-		assertNull(defaultResource.isMatchesLastModified(facesContext));
-		
-		MockAbstractResource entityTaggedResource = new MockAbstractResource();
-		entityTaggedResource.setEntityTag("3456");
-		assertNull(entityTaggedResource.isMatchesEntityTag(facesContext));
-		assertNull(entityTaggedResource.isMatchesLastModified(facesContext));
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.test.AbstractFacesTest#tearDown()
+     */
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-		MockAbstractResource timeKnownResource = new MockAbstractResource();
-		timeKnownResource.setLastModified(new Date(System.currentTimeMillis() - MILLISECONDS_IN_HOUR));
-		assertNull(timeKnownResource.isMatchesEntityTag(facesContext));
-		assertNull(timeKnownResource.isMatchesLastModified(facesContext));
-	}
-	
-	public void testEntityTag() throws Exception {
-		this.connection.addRequestHeaders(Collections.singletonMap("If-None-Match", "\"3456\""));
+    public void testInitialRequest() throws Exception {
+        MockAbstractResource defaultResource = new MockAbstractResource();
 
-		MockAbstractResource defaultResource = new MockAbstractResource();
-		assertFalse(defaultResource.isMatchesEntityTag(facesContext));
+        assertNull(defaultResource.isMatchesEntityTag(facesContext));
+        assertNull(defaultResource.isMatchesLastModified(facesContext));
 
-		MockAbstractResource entityTaggedResource = new MockAbstractResource();
-		entityTaggedResource.setEntityTag("\"3456\"");
-		assertTrue(entityTaggedResource.isMatchesEntityTag(facesContext));
+        MockAbstractResource entityTaggedResource = new MockAbstractResource();
 
-		MockAbstractResource unmatchedTaggedResource = new MockAbstractResource();
-		unmatchedTaggedResource.setEntityTag("\"123\"");
-		assertFalse(unmatchedTaggedResource.isMatchesEntityTag(facesContext));
-	}
+        entityTaggedResource.setEntityTag("3456");
+        assertNull(entityTaggedResource.isMatchesEntityTag(facesContext));
+        assertNull(entityTaggedResource.isMatchesLastModified(facesContext));
 
-	public void testWeakEntityTag() throws Exception {
-		this.connection.addRequestHeaders(Collections.singletonMap("If-None-Match", "W/\"3456\""));
+        MockAbstractResource timeKnownResource = new MockAbstractResource();
 
-		MockAbstractResource defaultResource = new MockAbstractResource();
-		assertEquals(Boolean.FALSE, defaultResource.isMatchesEntityTag(facesContext));
+        timeKnownResource.setLastModified(new Date(System.currentTimeMillis() - MILLISECONDS_IN_HOUR));
+        assertNull(timeKnownResource.isMatchesEntityTag(facesContext));
+        assertNull(timeKnownResource.isMatchesLastModified(facesContext));
+    }
 
-		MockAbstractResource entityTaggedResource = new MockAbstractResource();
-		entityTaggedResource.setEntityTag("\"3456\"");
-		assertEquals(Boolean.TRUE, entityTaggedResource.isMatchesEntityTag(facesContext));
+    public void testEntityTag() throws Exception {
+        this.connection.addRequestHeaders(Collections.singletonMap("If-None-Match", "\"3456\""));
 
-		MockAbstractResource unmatchedTaggedResource = new MockAbstractResource();
-		unmatchedTaggedResource.setEntityTag("\"123\"");
-		assertEquals(Boolean.FALSE, unmatchedTaggedResource.isMatchesEntityTag(facesContext));
-	}
+        MockAbstractResource defaultResource = new MockAbstractResource();
 
-	public void testMultiEntityTags() throws Exception {
-		this.connection.addRequestHeaders(Collections.singletonMap("If-None-Match", "W/\"3456\", \"012\""));
+        assertFalse(defaultResource.isMatchesEntityTag(facesContext));
 
-		MockAbstractResource defaultResource = new MockAbstractResource();
-		assertEquals(Boolean.FALSE, defaultResource.isMatchesEntityTag(facesContext));
+        MockAbstractResource entityTaggedResource = new MockAbstractResource();
 
-		MockAbstractResource entityTaggedResource = new MockAbstractResource();
-		entityTaggedResource.setEntityTag("\"3456\"");
-		assertEquals(Boolean.TRUE, entityTaggedResource.isMatchesEntityTag(facesContext));
+        entityTaggedResource.setEntityTag("\"3456\"");
+        assertTrue(entityTaggedResource.isMatchesEntityTag(facesContext));
 
-		MockAbstractResource anotherTaggedResource = new MockAbstractResource();
-		anotherTaggedResource.setEntityTag("W/\"012\"");
-		assertEquals(Boolean.TRUE, anotherTaggedResource.isMatchesEntityTag(facesContext));
-		
-		MockAbstractResource unmatchedTaggedResource = new MockAbstractResource();
-		unmatchedTaggedResource.setEntityTag("\"123\"");
-		assertEquals(Boolean.FALSE, unmatchedTaggedResource.isMatchesEntityTag(facesContext));
-	}
-	
-	public void testIfModified() throws Exception {
-		Date baseDate = new Date();
-		Date beforeBaseDate = new Date(baseDate.getTime() - MILLISECONDS_IN_HOUR);
-		Date afterBaseDate = new Date(baseDate.getTime() + MILLISECONDS_IN_HOUR);
+        MockAbstractResource unmatchedTaggedResource = new MockAbstractResource();
 
-		this.connection.addRequestHeaders(Collections.singletonMap("If-Modified-Since", RFC1123_DATE_FORMATTER.format(baseDate)));
+        unmatchedTaggedResource.setEntityTag("\"123\"");
+        assertFalse(unmatchedTaggedResource.isMatchesEntityTag(facesContext));
+    }
 
-		MockAbstractResource defaultResource = new MockAbstractResource();
-		assertEquals(Boolean.FALSE, defaultResource.isMatchesLastModified(facesContext));
-	
-		MockAbstractResource actualResource = new MockAbstractResource();
-		actualResource.setLastModified(beforeBaseDate);
-		assertEquals(Boolean.TRUE, actualResource.isMatchesLastModified(facesContext));
+    public void testWeakEntityTag() throws Exception {
+        this.connection.addRequestHeaders(Collections.singletonMap("If-None-Match", "W/\"3456\""));
 
-		MockAbstractResource expiredResource = new MockAbstractResource();
-		expiredResource.setLastModified(afterBaseDate);
-		assertEquals(Boolean.FALSE, expiredResource.isMatchesLastModified(facesContext));
-	}
+        MockAbstractResource defaultResource = new MockAbstractResource();
 
-	private static class BooleanAnswer implements IAnswer<Boolean> {
-		private Boolean value;
-		
-		public Boolean answer() throws Throwable {
-			return value;
-		}
+        assertEquals(Boolean.FALSE, defaultResource.isMatchesEntityTag(facesContext));
 
-		public void setValue(Boolean value) {
-			this.value = value;
-		}
-	}
-	
-	private static abstract class AbstractTestResource extends AbstractCacheableResource {
-		@Override
-		public String toString() {
-			return "mock";
-		}
-		
-		@Override
-		public boolean isCacheable(FacesContext context) {
-			return false;
-		}
-		
-		@Override
-		protected boolean isMatchesEntityTag(FacesContext context, String matchHeaderValue) {
-			return super.isMatchesEntityTag(context, matchHeaderValue);
-		}
+        MockAbstractResource entityTaggedResource = new MockAbstractResource();
 
-        @Override
-        protected boolean isMatchesLastModified(FacesContext context, String modifiedCondition) {
-            return super.isMatchesLastModified(context, modifiedCondition); 
-        }
+        entityTaggedResource.setEntityTag("\"3456\"");
+        assertEquals(Boolean.TRUE, entityTaggedResource.isMatchesEntityTag(facesContext));
+
+        MockAbstractResource unmatchedTaggedResource = new MockAbstractResource();
+
+        unmatchedTaggedResource.setEntityTag("\"123\"");
+        assertEquals(Boolean.FALSE, unmatchedTaggedResource.isMatchesEntityTag(facesContext));
     }
 
+    public void testMultiEntityTags() throws Exception {
+        this.connection.addRequestHeaders(Collections.singletonMap("If-None-Match", "W/\"3456\", \"012\""));
+
+        MockAbstractResource defaultResource = new MockAbstractResource();
+
+        assertEquals(Boolean.FALSE, defaultResource.isMatchesEntityTag(facesContext));
+
+        MockAbstractResource entityTaggedResource = new MockAbstractResource();
+
+        entityTaggedResource.setEntityTag("\"3456\"");
+        assertEquals(Boolean.TRUE, entityTaggedResource.isMatchesEntityTag(facesContext));
+
+        MockAbstractResource anotherTaggedResource = new MockAbstractResource();
+
+        anotherTaggedResource.setEntityTag("W/\"012\"");
+        assertEquals(Boolean.TRUE, anotherTaggedResource.isMatchesEntityTag(facesContext));
+
+        MockAbstractResource unmatchedTaggedResource = new MockAbstractResource();
+
+        unmatchedTaggedResource.setEntityTag("\"123\"");
+        assertEquals(Boolean.FALSE, unmatchedTaggedResource.isMatchesEntityTag(facesContext));
+    }
+
+    public void testIfModified() throws Exception {
+        Date baseDate = new Date();
+        Date beforeBaseDate = new Date(baseDate.getTime() - MILLISECONDS_IN_HOUR);
+        Date afterBaseDate = new Date(baseDate.getTime() + MILLISECONDS_IN_HOUR);
+
+        this.connection.addRequestHeaders(Collections.singletonMap("If-Modified-Since",
+                RFC1123_DATE_FORMATTER.format(baseDate)));
+
+        MockAbstractResource defaultResource = new MockAbstractResource();
+
+        assertEquals(Boolean.FALSE, defaultResource.isMatchesLastModified(facesContext));
+
+        MockAbstractResource actualResource = new MockAbstractResource();
+
+        actualResource.setLastModified(beforeBaseDate);
+        assertEquals(Boolean.TRUE, actualResource.isMatchesLastModified(facesContext));
+
+        MockAbstractResource expiredResource = new MockAbstractResource();
+
+        expiredResource.setLastModified(afterBaseDate);
+        assertEquals(Boolean.FALSE, expiredResource.isMatchesLastModified(facesContext));
+    }
+
     public void testUserAgentNeedsUpdate() throws Exception {
         BooleanAnswer tagMatches = new BooleanAnswer();
         BooleanAnswer lastModifiedMatches = new BooleanAnswer();
         BooleanAnswer cacheable = new BooleanAnswer();
-
         AbstractCacheableResource resource = EasyMock.createNiceMock(AbstractTestResource.class,
-                AbstractTestResource.class.getDeclaredMethods());
+                                                 AbstractTestResource.class.getDeclaredMethods());
 
         EasyMock.expect(resource.isCacheable(facesContext)).andStubAnswer(cacheable);
 
         String matchHeaderValue = RFC1123_DATE_FORMATTER.format(new Date());
+
         this.connection.addRequestHeaders(Collections.singletonMap("If-None-Match", matchHeaderValue));
         EasyMock.expect(resource.isMatchesEntityTag(facesContext, matchHeaderValue)).andStubAnswer(tagMatches);
 
         String modifiedCondition = "\"1234\"";
+
         this.connection.addRequestHeaders(Collections.singletonMap("If-Modified-Since", modifiedCondition));
-        EasyMock.expect(resource.isMatchesLastModified(facesContext, modifiedCondition)).andStubAnswer(lastModifiedMatches);
-
+        EasyMock.expect(resource.isMatchesLastModified(facesContext,
+                modifiedCondition)).andStubAnswer(lastModifiedMatches);
         EasyMock.replay(resource);
-
         cacheable.setValue(false);
         assertTrue(resource.userAgentNeedsUpdate(facesContext));
-
-
         cacheable.setValue(true);
-
         tagMatches.setValue(Boolean.TRUE);
         lastModifiedMatches.setValue(Boolean.TRUE);
         assertFalse(resource.userAgentNeedsUpdate(facesContext));
-
         tagMatches.setValue(Boolean.FALSE);
         lastModifiedMatches.setValue(Boolean.FALSE);
         assertTrue(resource.userAgentNeedsUpdate(facesContext));
-
         tagMatches.setValue(Boolean.FALSE);
         lastModifiedMatches.setValue(Boolean.TRUE);
         assertTrue(resource.userAgentNeedsUpdate(facesContext));
-
         tagMatches.setValue(Boolean.TRUE);
         lastModifiedMatches.setValue(Boolean.FALSE);
         assertTrue(resource.userAgentNeedsUpdate(facesContext));
-
-
-
         this.connection.addRequestHeaders(Collections.singletonMap("If-None-Match", (String) null));
         lastModifiedMatches.setValue(Boolean.FALSE);
         assertTrue(resource.userAgentNeedsUpdate(facesContext));
-
         lastModifiedMatches.setValue(Boolean.TRUE);
         assertFalse(resource.userAgentNeedsUpdate(facesContext));
-
         this.connection.addRequestHeaders(Collections.singletonMap("If-None-Match", matchHeaderValue));
         this.connection.addRequestHeaders(Collections.singletonMap("If-Modified-Since", (String) null));
         tagMatches.setValue(Boolean.FALSE);
         assertTrue(resource.userAgentNeedsUpdate(facesContext));
-
         tagMatches.setValue(Boolean.TRUE);
         assertFalse(resource.userAgentNeedsUpdate(facesContext));
-
         this.connection.addRequestHeaders(Collections.singletonMap("If-Modified-Since", (String) null));
         this.connection.addRequestHeaders(Collections.singletonMap("If-None-Match", (String) null));
         assertTrue(resource.userAgentNeedsUpdate(facesContext));
-
         cacheable.setValue(false);
         assertTrue(resource.userAgentNeedsUpdate(facesContext));
     }
+
+    private static abstract class AbstractTestResource extends AbstractCacheableResource {
+        @Override
+        public String toString() {
+            return "mock";
+        }
+
+        @Override
+        public boolean isCacheable(FacesContext context) {
+            return false;
+        }
+
+        @Override
+        protected boolean isMatchesEntityTag(FacesContext context, String matchHeaderValue) {
+            return super.isMatchesEntityTag(context, matchHeaderValue);
+        }
+
+        @Override
+        protected boolean isMatchesLastModified(FacesContext context, String modifiedCondition) {
+            return super.isMatchesLastModified(context, modifiedCondition);
+        }
+    }
+
+
+    private static class BooleanAnswer implements IAnswer<Boolean> {
+        private Boolean value;
+
+        public Boolean answer() throws Throwable {
+            return value;
+        }
+
+        public void setValue(Boolean value) {
+            this.value = value;
+        }
+    }
 }
 
 
-
 class MockAbstractResource extends AbstractCacheableResource {
+    private String entityTag;
+    private Date lastModified;
 
-	private String entityTag;
-	
-	private Date lastModified;
-	
-	public void setEntityTag(String entityTag) {
-		this.entityTag = entityTag;
-	}
+    public void setEntityTag(String entityTag) {
+        this.entityTag = entityTag;
+    }
 
-	public void setLastModified(Date lastModified) {
-		this.lastModified = lastModified;
-	}
+    public void setLastModified(Date lastModified) {
+        this.lastModified = lastModified;
+    }
 
-	@Override
-	protected String getEntityTag(FacesContext context) {
-		return entityTag;
-	}
+    @Override
+    protected String getEntityTag(FacesContext context) {
+        return entityTag;
+    }
 
-	@Override
-	protected Date getLastModified(FacesContext context) {
-		return lastModified;
-	}
+    @Override
+    protected Date getLastModified(FacesContext context) {
+        return lastModified;
+    }
 
-	@Override
-	public InputStream getInputStream() throws IOException {
-		throw new UnsupportedOperationException();
-	}
+    @Override
+    public InputStream getInputStream() throws IOException {
+        throw new UnsupportedOperationException();
+    }
 
-	@Override
-	public String getRequestPath() {
-		throw new UnsupportedOperationException();
-	}
+    @Override
+    public String getRequestPath() {
+        throw new UnsupportedOperationException();
+    }
 
-	@Override
-	public Map<String, String> getResponseHeaders() {
-		throw new UnsupportedOperationException();
-	}
+    @Override
+    public Map<String, String> getResponseHeaders() {
+        throw new UnsupportedOperationException();
+    }
 
-	@Override
-	public URL getURL() {
-		throw new UnsupportedOperationException();
-	}
+    @Override
+    public URL getURL() {
+        throw new UnsupportedOperationException();
+    }
 
-	@Override
-	public boolean isCacheable(FacesContext context) {
-		throw new UnsupportedOperationException();
-	}
-	
+    @Override
+    public boolean isCacheable(FacesContext context) {
+        throw new UnsupportedOperationException();
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,11 +19,14 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
+
 import java.util.Date;
 import java.util.Map;
 
@@ -37,47 +40,49 @@
  */
 public class CacheableResourceImpl extends AbstractBaseResource {
 
-	/* (non-Javadoc)
-	 * @see org.richfaces.resource.AbstractBaseResource#getInputStream()
-	 */
-	@Override
-	public InputStream getInputStream() {
-		return new ByteArrayInputStream(getContentToEcho());
-	}
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.resource.AbstractBaseResource#getInputStream()
+     */
+    @Override
+    public InputStream getInputStream() {
+        return new ByteArrayInputStream(getContentToEcho());
+    }
 
-	private byte[] getContentToEcho() {
-		ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
-		Map<String, String> headers = externalContext.getRequestHeaderMap();
-		Object content = headers.get(ResourceHandlerImplTest.ECHO_HEADER);
-		try {
-			return content.toString().getBytes("US-ASCII");
-		} catch (UnsupportedEncodingException e) {
-			throw new FacesException(e.getMessage(), e);
-		}
-	}
+    private byte[] getContentToEcho() {
+        ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
+        Map<String, String> headers = externalContext.getRequestHeaderMap();
+        Object content = headers.get(ResourceHandlerImplTest.ECHO_HEADER);
 
-	@Override
-	protected int getContentLength(FacesContext context) {
-		return getContentToEcho().length;
-	}
-	
-	@Override
-	public String getContentType() {
-		return "text/plain";
-	}
-	
-	@Override
-	long getCurrentTime() {
-		return ResourceHandlerImplTest.currentTime.getTime();
-	}
-	
-	@Override
-	protected Date getLastModified(FacesContext context) {
-		return ResourceHandlerImplTest.lastModified;
-	}
-	
-	@Override
-	protected Date getExpires(FacesContext context) {
-		return ResourceHandlerImplTest.expires;
-	}
+        try {
+            return content.toString().getBytes("US-ASCII");
+        } catch (UnsupportedEncodingException e) {
+            throw new FacesException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    protected int getContentLength(FacesContext context) {
+        return getContentToEcho().length;
+    }
+
+    @Override
+    public String getContentType() {
+        return "text/plain";
+    }
+
+    @Override
+    long getCurrentTime() {
+        return ResourceHandlerImplTest.currentTime.getTime();
+    }
+
+    @Override
+    protected Date getLastModified(FacesContext context) {
+        return ResourceHandlerImplTest.lastModified;
+    }
+
+    @Override
+    protected Date getExpires(FacesContext context) {
+        return ResourceHandlerImplTest.expires;
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/CachedResourceImplTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/CachedResourceImplTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/CachedResourceImplTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
 import java.io.BufferedReader;
@@ -26,7 +28,9 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+
 import java.net.URL;
+
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collections;
@@ -47,249 +51,268 @@
  */
 public class CachedResourceImplTest extends AbstractFacesTest {
 
-	/**
-	 * 
-	 */
-	private static final String EXPIRES = "Expires";
-	/**
-	 * 
-	 */
-	private static final String CACHE_CONTROL = "Cache-Control";
-	/**
-	 * 
-	 */
-	private static final String LAST_MODIFIED = "Last-Modified";
+    /**
+     *
+     */
+    private static final String CACHE_CONTROL = "Cache-Control";
 
-	@Override
-	public void setUp() throws Exception {
-		super.setUp();
-		setupFacesRequest();
-	}
+    /**
+     *
+     */
+    private static final String EXPIRES = "Expires";
 
-	@Override
-	public void tearDown() throws Exception {
-		super.tearDown();
-	}
+    /**
+     *
+     */
+    private static final String LAST_MODIFIED = "Last-Modified";
 
-	private class MockHeadersResourceImpl extends Resource {
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        setupFacesRequest();
+    }
 
-		private Map<String, String> headers;
-		
-		private InputStream stream;
-		
-		public MockHeadersResourceImpl(Map<String, String> headers,
-				InputStream stream) {
-			super();
-			setResourceName(getClass().getName());
-			setContentType("image/png");
-			this.headers = headers;
-			this.stream = stream != null ? stream : new ByteArrayInputStream(new byte[0]);
-		}
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-		@Override
-		public Map<String, String> getResponseHeaders() {
-			return headers;
-		}
+    private CachedResourceImpl createCachedResource() throws IOException {
+        return createCachedResource(createTestHeaders());
+    }
 
-		@Override
-		public InputStream getInputStream() throws IOException {
-			return stream;
-		}
+    private CachedResourceImpl createCachedResource(Map<String, String> headers) throws IOException {
+        return createCachedResource(headers, null);
+    }
 
-		@Override
-		public String getRequestPath() {
-			throw new UnsupportedOperationException();
-		}
+    private CachedResourceImpl createCachedResource(Map<String, String> headers, InputStream stream)
+            throws IOException {
+        MockHeadersResourceImpl mockResource = new MockHeadersResourceImpl(headers, stream);
+        CachedResourceImpl cachedResource = new MockCachedResourceImpl();
 
-		@Override
-		public URL getURL() {
-			throw new UnsupportedOperationException();
-		}
+        cachedResource.initialize(mockResource);
 
-		@Override
-		public boolean userAgentNeedsUpdate(FacesContext context) {
-			throw new UnsupportedOperationException();
-		}
+        return cachedResource;
+    }
 
-	};
+    private Map<String, String> createTestHeaders() {
+        Map<String, String> headers = new HashMap<String, String>();
 
-	private class MockCachedResourceImpl extends CachedResourceImpl {
-		private final long currentTime;
-		
-		@Override
-		long getCurrentTime() {
-			return currentTime;
-		}
-		
-		public MockCachedResourceImpl() {
-			super();
+        headers.put("ETag", "W/\"123\"");
+        headers.put(LAST_MODIFIED, "Tue, 21 Jul 2009 12:45:09 GMT");
+        headers.put(EXPIRES, "Tue, 28 Jul 2009 12:45:09 GMT");
+        headers.put(CACHE_CONTROL, "public, max-age=86400");
 
-			this.currentTime = createBaseDateCalendar().getTimeInMillis();
-		}
+        return headers;
+    }
 
-	}
-	
-	private CachedResourceImpl createCachedResource() throws IOException {
-		return createCachedResource(createTestHeaders());
-	}
-	
-	private CachedResourceImpl createCachedResource(Map<String, String> headers) throws IOException {
-		return createCachedResource(headers, null);
-	}
-	
-	private CachedResourceImpl createCachedResource(Map<String, String> headers, InputStream stream) throws IOException {
-		MockHeadersResourceImpl mockResource = new MockHeadersResourceImpl(headers, stream);
-		CachedResourceImpl cachedResource = new MockCachedResourceImpl();
-		cachedResource.initialize(mockResource);
-		return cachedResource;
-	}
-	
-	private Map<String, String> createTestHeaders() {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put("ETag", "W/\"123\"");
-		headers.put(LAST_MODIFIED, "Tue, 21 Jul 2009 12:45:09 GMT");
-		headers.put(EXPIRES, "Tue, 28 Jul 2009 12:45:09 GMT");
-		headers.put(CACHE_CONTROL, "public, max-age=86400");
-		return headers;
-	}
-	
-	private Calendar createBaseDateCalendar() {
-		Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
-		calendar.clear();
-		calendar.set(2009, Calendar.JULY, 21, 12, 45, 9);
-		return calendar;
-	}
-	
-	public void testInitialize() throws Exception {
-		CachedResourceImpl cachedResource = createCachedResource();
-		Calendar calendar = createBaseDateCalendar();
-		Date baseDate = calendar.getTime();
-		
-		assertEquals("W/\"123\"", cachedResource.getEntityTag(facesContext));
-		assertEquals(baseDate, cachedResource.getLastModified(facesContext));
-		assertEquals(createTestHeaders(), cachedResource.getResponseHeaders());
-		assertEquals("image/png", cachedResource.getContentType());
+    private Calendar createBaseDateCalendar() {
+        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
 
-		Date expired = cachedResource.getExpired(facesContext);
-		assertNotNull(expired);
+        calendar.clear();
+        calendar.set(2009, Calendar.JULY, 21, 12, 45, 9);
 
-		assertTrue(expired.after(baseDate));
-		calendar.add(Calendar.DATE, 1);
-		assertFalse(calendar.getTime().before(expired));
-	}
+        return calendar;
+    }
 
-	public void testInitializeExpires() throws Exception {
-		Map<String, String> headers = createTestHeaders();
-		headers.remove(CACHE_CONTROL);
-		CachedResourceImpl cachedResource = createCachedResource(headers);
+    public void testInitialize() throws Exception {
+        CachedResourceImpl cachedResource = createCachedResource();
+        Calendar calendar = createBaseDateCalendar();
+        Date baseDate = calendar.getTime();
 
-		Date expired = cachedResource.getExpired(facesContext);
-		assertNotNull(expired);
+        assertEquals("W/\"123\"", cachedResource.getEntityTag(facesContext));
+        assertEquals(baseDate, cachedResource.getLastModified(facesContext));
+        assertEquals(createTestHeaders(), cachedResource.getResponseHeaders());
+        assertEquals("image/png", cachedResource.getContentType());
 
-		Calendar calendar = createBaseDateCalendar();
-		assertTrue(expired.after(calendar.getTime()));
-		calendar.add(Calendar.DATE, 1);
-		assertFalse(expired.before(calendar.getTime()));
-		calendar.add(Calendar.DATE, 6);
-		assertTrue(expired.before(calendar.getTime()));
-	}
+        Date expired = cachedResource.getExpired(facesContext);
 
-	public void testInitializeMaxAge() throws Exception {
-		Map<String, String> headers = createTestHeaders();
-		headers.remove(EXPIRES);
-		CachedResourceImpl cachedResource = createCachedResource(headers);
+        assertNotNull(expired);
+        assertTrue(expired.after(baseDate));
+        calendar.add(Calendar.DATE, 1);
+        assertFalse(calendar.getTime().before(expired));
+    }
 
-		Date expired = cachedResource.getExpired(facesContext);
-		assertNotNull(expired);
+    public void testInitializeExpires() throws Exception {
+        Map<String, String> headers = createTestHeaders();
 
-		Calendar calendar = createBaseDateCalendar();
-		assertTrue(expired.after(calendar.getTime()));
-		calendar.add(Calendar.DATE, 1);
-		assertTrue(expired.before(calendar.getTime()));
-	}
+        headers.remove(CACHE_CONTROL);
 
-	public void testInitializeSMaxAge() throws Exception {
-		Map<String, String> headers = createTestHeaders();
-		headers.put(CACHE_CONTROL, "public, max-age=86400, s-maxage=172800");
-		CachedResourceImpl cachedResource = createCachedResource(headers);
+        CachedResourceImpl cachedResource = createCachedResource(headers);
+        Date expired = cachedResource.getExpired(facesContext);
 
-		Date expired = cachedResource.getExpired(facesContext);
-		assertNotNull(expired);
-		Calendar calendar = createBaseDateCalendar();
+        assertNotNull(expired);
 
-		assertTrue(expired.after(calendar.getTime()));
-		calendar.add(Calendar.DATE, 1);
-		assertFalse(expired.before(calendar.getTime()));
-		calendar.add(Calendar.DATE, 1);
-		assertTrue(expired.before(calendar.getTime()));
-	}
-	
-	public void testGetStream() throws Exception {
-		ByteArrayInputStream testStream = new ByteArrayInputStream("test".getBytes("US-ASCII"));
+        Calendar calendar = createBaseDateCalendar();
 
-		CachedResourceImpl cachedResource = createCachedResource(createTestHeaders(), testStream);
+        assertTrue(expired.after(calendar.getTime()));
+        calendar.add(Calendar.DATE, 1);
+        assertFalse(expired.before(calendar.getTime()));
+        calendar.add(Calendar.DATE, 6);
+        assertTrue(expired.before(calendar.getTime()));
+    }
 
-		InputStream stream = cachedResource.getInputStream();
-		assertNotNull(stream);
-		
-		BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "US-ASCII"));
-		assertEquals("test", reader.readLine());
-		assertNull(reader.readLine());
-		reader.close();
-	}
-	
-	public void testGetBigStream() throws Exception {
-		byte[] bs = new byte[127123];
-		new Random().nextBytes(bs);
+    public void testInitializeMaxAge() throws Exception {
+        Map<String, String> headers = createTestHeaders();
 
-		ByteArrayInputStream bigStream = new ByteArrayInputStream(bs);
-		CachedResourceImpl cachedResource = createCachedResource(createTestHeaders(), bigStream);
-		
-		InputStream stream = cachedResource.getInputStream();
-		byte[] testBs = new byte[bs.length];
-		assertEquals(testBs.length, stream.read(testBs));
-		assertTrue(Arrays.equals(testBs, bs));
-		assertEquals(-1, stream.read());
-		stream.close();
-	}
-	
-	public void testCacheable() throws Exception {
-		CachedResourceImpl cachedResource = createCachedResource();
-		
-		assertTrue(cachedResource.isCacheable(facesContext));
-	}
-	
-	public void testDefaults() throws Exception {
-		CachedResourceImpl cachedResource = createCachedResource();
+        headers.remove(EXPIRES);
 
-		try {
-			cachedResource.getURL();
-			
-			fail();
-		} catch (UnsupportedOperationException e) {
-			//ok
-		}
+        CachedResourceImpl cachedResource = createCachedResource(headers);
+        Date expired = cachedResource.getExpired(facesContext);
 
-		try {
-			cachedResource.getRequestPath();
-			
-			fail();
-		} catch (UnsupportedOperationException e) {
-			//ok
-		}
-	}
+        assertNotNull(expired);
 
-	public void testUserAgentNeedsUpdate() throws Exception {
-		CachedResourceImpl cachedResource = createCachedResource();
-	
-		this.connection.addRequestHeaders(Collections.singletonMap("If-Modified-Since", "Tue, 21 Jul 2009 14:45:09 GMT"));
-		assertFalse(cachedResource.userAgentNeedsUpdate(facesContext));
-	}
+        Calendar calendar = createBaseDateCalendar();
 
-	public void testUserAgentNeedsUpdate2() throws Exception {
-		CachedResourceImpl cachedResource = createCachedResource();
-	
-		this.connection.addRequestHeaders(Collections.singletonMap("If-Modified-Since", "Tue, 21 Jul 2009 09:45:09 GMT"));
-		assertTrue(cachedResource.userAgentNeedsUpdate(facesContext));
-	}
-}
\ No newline at end of file
+        assertTrue(expired.after(calendar.getTime()));
+        calendar.add(Calendar.DATE, 1);
+        assertTrue(expired.before(calendar.getTime()));
+    }
+
+    public void testInitializeSMaxAge() throws Exception {
+        Map<String, String> headers = createTestHeaders();
+
+        headers.put(CACHE_CONTROL, "public, max-age=86400, s-maxage=172800");
+
+        CachedResourceImpl cachedResource = createCachedResource(headers);
+        Date expired = cachedResource.getExpired(facesContext);
+
+        assertNotNull(expired);
+
+        Calendar calendar = createBaseDateCalendar();
+
+        assertTrue(expired.after(calendar.getTime()));
+        calendar.add(Calendar.DATE, 1);
+        assertFalse(expired.before(calendar.getTime()));
+        calendar.add(Calendar.DATE, 1);
+        assertTrue(expired.before(calendar.getTime()));
+    }
+
+    public void testGetStream() throws Exception {
+        ByteArrayInputStream testStream = new ByteArrayInputStream("test".getBytes("US-ASCII"));
+        CachedResourceImpl cachedResource = createCachedResource(createTestHeaders(), testStream);
+        InputStream stream = cachedResource.getInputStream();
+
+        assertNotNull(stream);
+
+        BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "US-ASCII"));
+
+        assertEquals("test", reader.readLine());
+        assertNull(reader.readLine());
+        reader.close();
+    }
+
+    public void testGetBigStream() throws Exception {
+        byte[] bs = new byte[127123];
+
+        new Random().nextBytes(bs);
+
+        ByteArrayInputStream bigStream = new ByteArrayInputStream(bs);
+        CachedResourceImpl cachedResource = createCachedResource(createTestHeaders(), bigStream);
+        InputStream stream = cachedResource.getInputStream();
+        byte[] testBs = new byte[bs.length];
+
+        assertEquals(testBs.length, stream.read(testBs));
+        assertTrue(Arrays.equals(testBs, bs));
+        assertEquals(-1, stream.read());
+        stream.close();
+    }
+
+    public void testCacheable() throws Exception {
+        CachedResourceImpl cachedResource = createCachedResource();
+
+        assertTrue(cachedResource.isCacheable(facesContext));
+    }
+
+    public void testDefaults() throws Exception {
+        CachedResourceImpl cachedResource = createCachedResource();
+
+        try {
+            cachedResource.getURL();
+            fail();
+        } catch (UnsupportedOperationException e) {
+
+            // ok
+        }
+
+        try {
+            cachedResource.getRequestPath();
+            fail();
+        } catch (UnsupportedOperationException e) {
+
+            // ok
+        }
+    }
+
+    public void testUserAgentNeedsUpdate() throws Exception {
+        CachedResourceImpl cachedResource = createCachedResource();
+
+        this.connection.addRequestHeaders(Collections.singletonMap("If-Modified-Since",
+                "Tue, 21 Jul 2009 14:45:09 GMT"));
+        assertFalse(cachedResource.userAgentNeedsUpdate(facesContext));
+    }
+
+    public void testUserAgentNeedsUpdate2() throws Exception {
+        CachedResourceImpl cachedResource = createCachedResource();
+
+        this.connection.addRequestHeaders(Collections.singletonMap("If-Modified-Since",
+                "Tue, 21 Jul 2009 09:45:09 GMT"));
+        assertTrue(cachedResource.userAgentNeedsUpdate(facesContext));
+    }
+
+    private class MockCachedResourceImpl extends CachedResourceImpl {
+        private final long currentTime;
+
+        public MockCachedResourceImpl() {
+            super();
+            this.currentTime = createBaseDateCalendar().getTimeInMillis();
+        }
+
+        @Override
+        long getCurrentTime() {
+            return currentTime;
+        }
+    }
+
+
+    private class MockHeadersResourceImpl extends Resource {
+        private Map<String, String> headers;
+        private InputStream stream;
+
+        public MockHeadersResourceImpl(Map<String, String> headers, InputStream stream) {
+            super();
+            setResourceName(getClass().getName());
+            setContentType("image/png");
+            this.headers = headers;
+            this.stream = stream != null ? stream : new ByteArrayInputStream(new byte[0]);
+        }
+
+        @Override
+        public Map<String, String> getResponseHeaders() {
+            return headers;
+        }
+
+        @Override
+        public InputStream getInputStream() throws IOException {
+            return stream;
+        }
+
+        @Override
+        public String getRequestPath() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public URL getURL() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public boolean userAgentNeedsUpdate(FacesContext context) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+
+    ;
+}

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/EmptyStreamResource.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/EmptyStreamResource.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/EmptyStreamResource.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
 import java.io.ByteArrayInputStream;
@@ -29,12 +31,10 @@
  * @since 4.0
  */
 public class EmptyStreamResource extends AbstractBaseResource {
+    protected InputStream EMPTY_STREAM = new ByteArrayInputStream(new byte[0]);
 
-	protected InputStream EMPTY_STREAM = new ByteArrayInputStream(new byte[0]);
-
-	@Override
-	public InputStream getInputStream() {
-		return EMPTY_STREAM;
-	}
-
+    @Override
+    public InputStream getInputStream() {
+        return EMPTY_STREAM;
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/MarkerFileResourceImpl.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/MarkerFileResourceImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/MarkerFileResourceImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,13 +19,12 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
-package org.richfaces.resource;
 
 
+package org.richfaces.resource;
+
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
-public class MarkerFileResourceImpl extends EmptyStreamResource {
-
-}
+public class MarkerFileResourceImpl extends EmptyStreamResource {}

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/NoMarkerFileResourceImpl.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/NoMarkerFileResourceImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/NoMarkerFileResourceImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,13 +19,12 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
-package org.richfaces.resource;
 
 
+package org.richfaces.resource;
+
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
-public class NoMarkerFileResourceImpl extends EmptyStreamResource {
-
-}
+public class NoMarkerFileResourceImpl extends EmptyStreamResource {}

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/NonCacheableResourceImpl.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/NonCacheableResourceImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/NonCacheableResourceImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
 import javax.faces.context.FacesContext;
@@ -28,9 +30,8 @@
  * @since 4.0
  */
 public class NonCacheableResourceImpl extends CacheableResourceImpl {
-
-	@Override
-	public boolean isCacheable(FacesContext context) {
-		return false;
-	}
+    @Override
+    public boolean isCacheable(FacesContext context) {
+        return false;
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,18 +19,24 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
 import java.io.File;
+
 import java.net.URL;
+
 import java.util.Calendar;
 import java.util.Date;
 import java.util.TimeZone;
 
 import javax.faces.application.ResourceHandler;
+
 import javax.servlet.http.HttpServletResponse;
 
 import org.easymock.classextension.EasyMock;
+
 import org.richfaces.test.AbstractFacesTest;
 import org.richfaces.test.LocalWebClient;
 import org.richfaces.util.Util;
@@ -38,207 +44,213 @@
 import com.gargoylesoftware.htmlunit.WebRequestSettings;
 import com.gargoylesoftware.htmlunit.WebResponse;
 
-
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public class ResourceHandlerImplTest extends AbstractFacesTest {
+    protected static final String ECHO_HEADER = "RichFaces-Echo";
+    private static final String IF_MODIFIED_SINCE = "If-Modified-Since";
+    private static final String RESOURCES_FOLDER_PATH = "resources/";
+    private static final String TEST_RESOURCE_NAME = RESOURCES_FOLDER_PATH + "defaultResourceHandlerResource.js";
+    protected static final Date currentTime;
+    protected static final Date expires;
+    protected static final Date lastModified;
 
-	private static final String IF_MODIFIED_SINCE = "If-Modified-Since";
+    static {
+        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
 
-	protected static final String ECHO_HEADER = "RichFaces-Echo";
+        currentTime = calendar.getTime();
+        calendar.add(Calendar.DATE, -1);
+        lastModified = calendar.getTime();
+        calendar.add(Calendar.DATE, 15);
+        expires = calendar.getTime();
+    }
 
-	protected static final Date currentTime;
+    private LocalWebClient webClient;
 
-	protected static final Date lastModified;
+    private void addClasspathResources() {
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        File testResourceFile = new File(classLoader.getResource(TEST_RESOURCE_NAME).getFile());
+        File testResourceFolder = testResourceFile.getParentFile();
 
-	protected static final Date expires;
+        facesServer.addResourcesFromDirectory("/" + RESOURCES_FOLDER_PATH, testResourceFolder);
+    }
 
-	static {
-		Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        addClasspathResources();
+        webClient = new LocalWebClient(this.facesServer);
 
-		currentTime = calendar.getTime();
-		calendar.add(Calendar.DATE, -1);
-		lastModified = calendar.getTime();
-		calendar.add(Calendar.DATE, 15);
-		expires = calendar.getTime();
-	}
+        // quick fix for https://sourceforge.net/tracker/?func=detail&aid=2821888&group_id=47038&atid=448266
+        webClient.setRedirectEnabled(false);
+    }
 
-	private LocalWebClient webClient;
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+        webClient = null;
+    }
 
-	private static final String RESOURCES_FOLDER_PATH = "resources/";
-	private static final String TEST_RESOURCE_NAME = RESOURCES_FOLDER_PATH + 
-		"defaultResourceHandlerResource.js";
+    public void testReadCacheableResource() throws Exception {
+        WebRequestSettings webRequestSettings =
+            new WebRequestSettings(new URL("http://localhost/rfRes/org.richfaces.resource.CacheableResourceImpl.jsf"));
 
-	
-	private void addClasspathResources() {
-		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-		File testResourceFile = new File(classLoader.getResource(TEST_RESOURCE_NAME).getFile());
-		File testResourceFolder = testResourceFile.getParentFile();
-		facesServer.addResourcesFromDirectory("/" + RESOURCES_FOLDER_PATH, testResourceFolder);
-	}
-	
-	@Override
-	public void setUp() throws Exception {
-		super.setUp();
+        webRequestSettings.getAdditionalHeaders().put(ECHO_HEADER, "ping?");
 
-		addClasspathResources();
-		webClient = new LocalWebClient(this.facesServer);
-		//quick fix for https://sourceforge.net/tracker/?func=detail&aid=2821888&group_id=47038&atid=448266
-		webClient.setRedirectEnabled(false);
-	}
+        WebResponse webResponse = webClient.loadWebResponse(webRequestSettings);
 
-	@Override
-	public void tearDown() throws Exception {
-		super.tearDown();
+        assertEquals(HttpServletResponse.SC_OK, webResponse.getStatusCode());
+        assertEquals(Util.formatHttpDate(lastModified.getTime()), webResponse.getResponseHeaderValue("Last-Modified"));
+        assertEquals(Util.formatHttpDate(currentTime.getTime()), webResponse.getResponseHeaderValue("Date"));
+        assertEquals(Util.formatHttpDate(expires.getTime()), webResponse.getResponseHeaderValue("Expires"));
+        assertEquals("max-age=1209600", webResponse.getResponseHeaderValue("Cache-Control"));
+        assertTrue(webResponse.getResponseHeaderValue("Content-Type").startsWith("text/plain"));
+        assertEquals("W/\"" + "ping?".length() + "-" + lastModified.getTime() + "\"",
+                     webResponse.getResponseHeaderValue("ETag"));
+        assertNull(webResponse.getResponseHeaderValue("Pragma"));
+        assertEquals("ping?", webResponse.getContentAsString("US-ASCII"));
+        webRequestSettings.getAdditionalHeaders().put(ECHO_HEADER, "pong");
 
-		webClient = null;
-	}
+        WebResponse cachedWebResponse = webClient.loadWebResponse(webRequestSettings);
 
-	public void testReadCacheableResource() throws Exception {
-		WebRequestSettings webRequestSettings = new WebRequestSettings(
-				new URL("http://localhost/rfRes/org.richfaces.resource.CacheableResourceImpl.jsf"));
-		webRequestSettings.getAdditionalHeaders().put(ECHO_HEADER, "ping?");
+        assertEquals(HttpServletResponse.SC_OK, cachedWebResponse.getStatusCode());
+        assertEquals("ping?", cachedWebResponse.getContentAsString("US-ASCII"));
+        webRequestSettings.getAdditionalHeaders().put(IF_MODIFIED_SINCE, Util.formatHttpDate(currentTime));
 
-		WebResponse webResponse = webClient.loadWebResponse(webRequestSettings);
-		assertEquals(HttpServletResponse.SC_OK, webResponse.getStatusCode());
-		assertEquals(Util.formatHttpDate(lastModified.getTime()), webResponse.getResponseHeaderValue("Last-Modified"));
-		assertEquals(Util.formatHttpDate(currentTime.getTime()), webResponse.getResponseHeaderValue("Date"));
-		assertEquals(Util.formatHttpDate(expires.getTime()), webResponse.getResponseHeaderValue("Expires"));
-		assertEquals("max-age=1209600", webResponse.getResponseHeaderValue("Cache-Control"));
-		assertTrue(webResponse.getResponseHeaderValue("Content-Type").startsWith("text/plain"));
-		assertEquals("W/\"" + "ping?".length() + "-" + lastModified.getTime() + "\"", webResponse.getResponseHeaderValue("ETag"));
-		assertNull(webResponse.getResponseHeaderValue("Pragma"));
+        WebResponse cachedWebResponse2 = webClient.loadWebResponse(webRequestSettings);
 
-		assertEquals("ping?", webResponse.getContentAsString("US-ASCII"));
+        assertEquals(HttpServletResponse.SC_NOT_MODIFIED, cachedWebResponse2.getStatusCode());
+    }
 
-		webRequestSettings.getAdditionalHeaders().put(ECHO_HEADER, "pong");
-		WebResponse cachedWebResponse = webClient.loadWebResponse(webRequestSettings);
-		assertEquals(HttpServletResponse.SC_OK, cachedWebResponse.getStatusCode());
-		assertEquals("ping?", cachedWebResponse.getContentAsString("US-ASCII"));
+    public void testReadNonCacheableResource() throws Exception {
+        WebRequestSettings webRequestSettings =
+            new WebRequestSettings(
+                new URL("http://localhost/rfRes/org.richfaces.resource.NonCacheableResourceImpl.jsf"));
 
-		webRequestSettings.getAdditionalHeaders().put(IF_MODIFIED_SINCE, Util.formatHttpDate(currentTime));
-		WebResponse cachedWebResponse2 = webClient.loadWebResponse(webRequestSettings);
-		assertEquals(HttpServletResponse.SC_NOT_MODIFIED, cachedWebResponse2.getStatusCode());
-	}
+        webRequestSettings.getAdditionalHeaders().put(ECHO_HEADER, "ping?");
 
-	public void testReadNonCacheableResource() throws Exception {
-		WebRequestSettings webRequestSettings = new WebRequestSettings(
-				new URL("http://localhost/rfRes/org.richfaces.resource.NonCacheableResourceImpl.jsf"));
-		webRequestSettings.getAdditionalHeaders().put(ECHO_HEADER, "ping?");
+        WebResponse webResponse = webClient.loadWebResponse(webRequestSettings);
 
-		WebResponse webResponse = webClient.loadWebResponse(webRequestSettings);
-		assertEquals(HttpServletResponse.SC_OK, webResponse.getStatusCode());
-		assertEquals(Util.formatHttpDate(lastModified.getTime()), webResponse.getResponseHeaderValue("Last-Modified"));
-		assertEquals(Util.formatHttpDate(currentTime.getTime()), webResponse.getResponseHeaderValue("Date"));
-		assertEquals("0", webResponse.getResponseHeaderValue("Expires"));
-		assertEquals("max-age=0, no-store, no-cache", webResponse.getResponseHeaderValue("Cache-Control"));
-		assertTrue(webResponse.getResponseHeaderValue("Content-Type").startsWith("text/plain"));
-		assertNull(webResponse.getResponseHeaderValue("ETag"));
-		assertEquals("no-cache", webResponse.getResponseHeaderValue("Pragma"));
+        assertEquals(HttpServletResponse.SC_OK, webResponse.getStatusCode());
+        assertEquals(Util.formatHttpDate(lastModified.getTime()), webResponse.getResponseHeaderValue("Last-Modified"));
+        assertEquals(Util.formatHttpDate(currentTime.getTime()), webResponse.getResponseHeaderValue("Date"));
+        assertEquals("0", webResponse.getResponseHeaderValue("Expires"));
+        assertEquals("max-age=0, no-store, no-cache", webResponse.getResponseHeaderValue("Cache-Control"));
+        assertTrue(webResponse.getResponseHeaderValue("Content-Type").startsWith("text/plain"));
+        assertNull(webResponse.getResponseHeaderValue("ETag"));
+        assertEquals("no-cache", webResponse.getResponseHeaderValue("Pragma"));
+        assertEquals("ping?", webResponse.getContentAsString("US-ASCII"));
+        webRequestSettings.getAdditionalHeaders().put(ECHO_HEADER, "pong");
 
-		assertEquals("ping?", webResponse.getContentAsString("US-ASCII"));
+        WebResponse cachedWebResponse = webClient.loadWebResponse(webRequestSettings);
 
-		webRequestSettings.getAdditionalHeaders().put(ECHO_HEADER, "pong");
-		WebResponse cachedWebResponse = webClient.loadWebResponse(webRequestSettings);
-		assertEquals(HttpServletResponse.SC_OK, cachedWebResponse.getStatusCode());
-		assertEquals("pong", cachedWebResponse.getContentAsString("US-ASCII"));
+        assertEquals(HttpServletResponse.SC_OK, cachedWebResponse.getStatusCode());
+        assertEquals("pong", cachedWebResponse.getContentAsString("US-ASCII"));
+        webRequestSettings.getAdditionalHeaders().put(IF_MODIFIED_SINCE, Util.formatHttpDate(currentTime));
 
-		webRequestSettings.getAdditionalHeaders().put(IF_MODIFIED_SINCE, Util.formatHttpDate(currentTime));
-		WebResponse cachedWebResponse2 = webClient.loadWebResponse(webRequestSettings);
-		assertEquals(HttpServletResponse.SC_OK, cachedWebResponse2.getStatusCode());
-	}
+        WebResponse cachedWebResponse2 = webClient.loadWebResponse(webRequestSettings);
 
-	public void testNonExistingResource() throws Exception {
-		WebRequestSettings emptyResourceNameSettings = new WebRequestSettings(
-				new URL("http://localhost/rfRes/x.jsf"));
+        assertEquals(HttpServletResponse.SC_OK, cachedWebResponse2.getStatusCode());
+    }
 
-		WebResponse emptyResourceNameResponse = webClient.loadWebResponse(emptyResourceNameSettings);
-		assertEquals(HttpServletResponse.SC_NOT_FOUND, emptyResourceNameResponse.getStatusCode());
-	}
+    public void testNonExistingResource() throws Exception {
+        WebRequestSettings emptyResourceNameSettings = new WebRequestSettings(new URL("http://localhost/rfRes/x.jsf"));
+        WebResponse emptyResourceNameResponse = webClient.loadWebResponse(emptyResourceNameSettings);
 
-	public void testDefaultMojarraResource() throws Exception {
-		WebRequestSettings mojarraResourceSettings = new WebRequestSettings(
-				new URL("http://localhost/javax.faces.resource/defaultResourceHandlerResource.js.jsf"));
-		WebResponse mojarraResourceNameResponse = webClient.loadWebResponse(mojarraResourceSettings);
-		assertEquals(HttpServletResponse.SC_OK, mojarraResourceNameResponse.getStatusCode());
-	}
+        assertEquals(HttpServletResponse.SC_NOT_FOUND, emptyResourceNameResponse.getStatusCode());
+    }
 
-	public void testMarkerFile() throws Exception {
-		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+    public void testDefaultMojarraResource() throws Exception {
+        WebRequestSettings mojarraResourceSettings =
+            new WebRequestSettings(
+                new URL("http://localhost/javax.faces.resource/defaultResourceHandlerResource.js.jsf"));
+        WebResponse mojarraResourceNameResponse = webClient.loadWebResponse(mojarraResourceSettings);
 
-		assertNotNull(Class.forName("org.richfaces.resource.MarkerFileResourceImpl", 
-				true, contextClassLoader));
-		assertNotNull(contextClassLoader.getResource("META-INF/org.richfaces.resource.MarkerFileResourceImpl.resource.properties"));
+        assertEquals(HttpServletResponse.SC_OK, mojarraResourceNameResponse.getStatusCode());
+    }
 
-		WebRequestSettings markerFileRequestSettings = new WebRequestSettings(
-				new URL("http://localhost/rfRes/org.richfaces.resource.MarkerFileResourceImpl.jsf"));
-		WebResponse markerFileResponse = webClient.loadWebResponse(markerFileRequestSettings);
-		assertEquals(HttpServletResponse.SC_OK, markerFileResponse.getStatusCode());
+    public void testMarkerFile() throws Exception {
+        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
 
-		assertNotNull(Class.forName("org.richfaces.resource.NoMarkerFileResourceImpl", 
-			true, contextClassLoader));
-		assertNull(contextClassLoader.getResource("META-INF/org.richfaces.resource.NoMarkerFileResourceImpl.resource.properties"));
-		
-		WebRequestSettings noMarkerFileRequestSettings = new WebRequestSettings(
-				new URL("http://localhost/rfRes/org.richfaces.resource.NoMarkerFileResourceImpl.jsf"));
-		WebResponse noMarkerResponse = webClient.loadWebResponse(noMarkerFileRequestSettings);
-		assertEquals(HttpServletResponse.SC_NOT_FOUND, noMarkerResponse.getStatusCode());
+        assertNotNull(Class.forName("org.richfaces.resource.MarkerFileResourceImpl", true, contextClassLoader));
+        assertNotNull(
+            contextClassLoader.getResource(
+                "META-INF/org.richfaces.resource.MarkerFileResourceImpl.resource.properties"));
 
-	}
-	
-	public void testStateHolder() throws Exception {
-		setupFacesRequest();
-		ResourceCodec mockedCodec = EasyMock.createNiceMock(ResourceCodec.class);
-		EasyMock.expect(mockedCodec.decodeResourceName(EasyMock.eq("StateHolderResource/DATA/1"))).andReturn("org.richfaces.resource.StateHolderResourceImpl");
-		EasyMock.expect(mockedCodec.decodeResourceData(EasyMock.eq("StateHolderResource/DATA/1"))).andReturn("test text");
-		EasyMock.expect(mockedCodec.decodeResourceVersion(EasyMock.eq("StateHolderResource/DATA/1"))).andReturn(null);
-		EasyMock.replay(mockedCodec);
-		
-		ResourceHandlerImpl.setResourceCodec(mockedCodec);
-		
-		WebRequestSettings settings = new WebRequestSettings(
-			new URL("http://localhost/rfRes/StateHolderResource/DATA/1.jsf"));
-		
-		WebResponse resourceResponse = webClient.loadWebResponse(settings);
-		assertEquals(HttpServletResponse.SC_OK, resourceResponse.getStatusCode());
-		assertEquals("test text", resourceResponse.getContentAsString("US-ASCII"));
-	}
+        WebRequestSettings markerFileRequestSettings =
+            new WebRequestSettings(new URL("http://localhost/rfRes/org.richfaces.resource.MarkerFileResourceImpl.jsf"));
+        WebResponse markerFileResponse = webClient.loadWebResponse(markerFileRequestSettings);
 
-	public void testVersionedResource() throws Exception {
-		WebRequestSettings settings = new WebRequestSettings(
-				new URL("http://localhost/rfRes/org.richfaces.resource.VersionedResourceImpl.jsf"));
-		WebResponse resourceResponse = webClient.loadWebResponse(settings);
-		assertEquals(HttpServletResponse.SC_OK, resourceResponse.getStatusCode());
+        assertEquals(HttpServletResponse.SC_OK, markerFileResponse.getStatusCode());
+        assertNotNull(Class.forName("org.richfaces.resource.NoMarkerFileResourceImpl", true, contextClassLoader));
+        assertNull(
+            contextClassLoader.getResource(
+                "META-INF/org.richfaces.resource.NoMarkerFileResourceImpl.resource.properties"));
 
-		settings = new WebRequestSettings(
-				new URL("http://localhost/rfRes/org.richfaces.resource.VersionedResourceImpl/VER1_0_2.jsf"));
-		resourceResponse = webClient.loadWebResponse(settings);
-		assertEquals(HttpServletResponse.SC_OK, resourceResponse.getStatusCode());
+        WebRequestSettings noMarkerFileRequestSettings =
+            new WebRequestSettings(
+                new URL("http://localhost/rfRes/org.richfaces.resource.NoMarkerFileResourceImpl.jsf"));
+        WebResponse noMarkerResponse = webClient.loadWebResponse(noMarkerFileRequestSettings);
 
-		settings = new WebRequestSettings(
-				new URL("http://localhost/rfRes/org.richfaces.resource.VersionedResourceImpl/VER1_0_3.jsf"));
-		resourceResponse = webClient.loadWebResponse(settings);
-		assertEquals(HttpServletResponse.SC_NOT_FOUND, resourceResponse.getStatusCode());
-	}
-	
-	public void testCreateResource() throws Exception {
-		setupFacesRequest();
-		ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
-		
-		assertNotNull(resourceHandler.createResource("org.richfaces.resource.CacheableResourceImpl"));
-		assertNotNull(resourceHandler.createResource("org.richfaces.resource.CacheableResourceImpl", ""));
-		assertNotNull(resourceHandler.createResource("org.richfaces.resource.CacheableResourceImpl", null));
+        assertEquals(HttpServletResponse.SC_NOT_FOUND, noMarkerResponse.getStatusCode());
+    }
 
-		assertNotNull(resourceHandler.createResource("defaultResourceHandlerResource.js"));
-		assertNotNull(resourceHandler.createResource("libraryResource.js", "org.richfaces.resource.test"));
-	}
-	
-	public void testLibraryExists() throws Exception {
-		setupFacesRequest();
-		ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
+    public void testStateHolder() throws Exception {
+        setupFacesRequest();
 
-		assertTrue(resourceHandler.libraryExists("org.richfaces.resource.test"));
-	}
+        ResourceCodec mockedCodec = EasyMock.createNiceMock(ResourceCodec.class);
+
+        EasyMock.expect(mockedCodec.decodeResourceName(EasyMock.eq("StateHolderResource/DATA/1"))).andReturn(
+            "org.richfaces.resource.StateHolderResourceImpl");
+        EasyMock.expect(mockedCodec.decodeResourceData(EasyMock.eq("StateHolderResource/DATA/1"))).andReturn(
+            "test text");
+        EasyMock.expect(mockedCodec.decodeResourceVersion(EasyMock.eq("StateHolderResource/DATA/1"))).andReturn(null);
+        EasyMock.replay(mockedCodec);
+        ResourceHandlerImpl.setResourceCodec(mockedCodec);
+
+        WebRequestSettings settings =
+            new WebRequestSettings(new URL("http://localhost/rfRes/StateHolderResource/DATA/1.jsf"));
+        WebResponse resourceResponse = webClient.loadWebResponse(settings);
+
+        assertEquals(HttpServletResponse.SC_OK, resourceResponse.getStatusCode());
+        assertEquals("test text", resourceResponse.getContentAsString("US-ASCII"));
+    }
+
+    public void testVersionedResource() throws Exception {
+        WebRequestSettings settings =
+            new WebRequestSettings(new URL("http://localhost/rfRes/org.richfaces.resource.VersionedResourceImpl.jsf"));
+        WebResponse resourceResponse = webClient.loadWebResponse(settings);
+
+        assertEquals(HttpServletResponse.SC_OK, resourceResponse.getStatusCode());
+        settings = new WebRequestSettings(
+            new URL("http://localhost/rfRes/org.richfaces.resource.VersionedResourceImpl/VER1_0_2.jsf"));
+        resourceResponse = webClient.loadWebResponse(settings);
+        assertEquals(HttpServletResponse.SC_OK, resourceResponse.getStatusCode());
+        settings = new WebRequestSettings(
+            new URL("http://localhost/rfRes/org.richfaces.resource.VersionedResourceImpl/VER1_0_3.jsf"));
+        resourceResponse = webClient.loadWebResponse(settings);
+        assertEquals(HttpServletResponse.SC_NOT_FOUND, resourceResponse.getStatusCode());
+    }
+
+    public void testCreateResource() throws Exception {
+        setupFacesRequest();
+
+        ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
+
+        assertNotNull(resourceHandler.createResource("org.richfaces.resource.CacheableResourceImpl"));
+        assertNotNull(resourceHandler.createResource("org.richfaces.resource.CacheableResourceImpl", ""));
+        assertNotNull(resourceHandler.createResource("org.richfaces.resource.CacheableResourceImpl", null));
+        assertNotNull(resourceHandler.createResource("defaultResourceHandlerResource.js"));
+        assertNotNull(resourceHandler.createResource("libraryResource.js", "org.richfaces.resource.test"));
+    }
+
+    public void testLibraryExists() throws Exception {
+        setupFacesRequest();
+
+        ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
+
+        assertTrue(resourceHandler.libraryExists("org.richfaces.resource.test"));
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/ResourceUtilsTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/ResourceUtilsTest.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/ResourceUtilsTest.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
 import static junit.framework.Assert.assertEquals;
@@ -29,71 +31,70 @@
 
 import org.junit.Test;
 
-
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public class ResourceUtilsTest {
+    @Test
+    public void testFormatWeakTag() throws Exception {
+        assertNull(ResourceUtils.formatWeakTag(null));
+        assertEquals("W/\"123-456789\"", ResourceUtils.formatWeakTag("123-456789"));
 
-	@Test
-	public void testFormatWeakTag() throws Exception {
-		assertNull(ResourceUtils.formatWeakTag(null));
-		assertEquals("W/\"123-456789\"", ResourceUtils.formatWeakTag("123-456789"));
-		try {
-			ResourceUtils.formatWeakTag("123\"456789");
-			
-			fail();
-		} catch (IllegalArgumentException e) {
-			//ok
-		}
-	}
+        try {
+            ResourceUtils.formatWeakTag("123\"456789");
+            fail();
+        } catch (IllegalArgumentException e) {
 
-	@Test
-	public void testFormatTag() throws Exception {
-		assertNull(ResourceUtils.formatTag(null));
-		assertEquals("\"123-456789\"", ResourceUtils.formatTag("123-456789"));
-		try {
-			ResourceUtils.formatTag("123\"456789");
-			
-			fail();
-		} catch (IllegalArgumentException e) {
-			//ok
-		}
-	}
+            // ok
+        }
+    }
 
-	@Test
-	public void testMatchTag() throws Exception {
-		assertTrue(ResourceUtils.matchTag("\"123-4567890\"", "W/\"123-4567890\""));
-		assertTrue(ResourceUtils.matchTag("\"123-4567890\"", "W/\"123-4567890\", \"123-4567891\""));
-		assertTrue(ResourceUtils.matchTag("W/\"123-4567891\"", "W/\"123-4567890\", \"123-4567891\""));
-	
-		assertFalse(ResourceUtils.matchTag("\"123-4567890\"", "W/\"023-4567890\""));
-		assertFalse(ResourceUtils.matchTag("\"123-4567890\"", "W/\"023-4567890\", \"023-4567891\""));
-		assertFalse(ResourceUtils.matchTag("W/\"123-4567891\"", "W/\"023-4567890\", \"023-4567891\""));
+    @Test
+    public void testFormatTag() throws Exception {
+        assertNull(ResourceUtils.formatTag(null));
+        assertEquals("\"123-456789\"", ResourceUtils.formatTag("123-456789"));
 
-		try {
-			ResourceUtils.matchTag(null, "W/\"123-4567890\", \"123-4567891\"");
-			
-			fail();
-		} catch (IllegalArgumentException e) {
-			//ok
-		}
+        try {
+            ResourceUtils.formatTag("123\"456789");
+            fail();
+        } catch (IllegalArgumentException e) {
 
-		try {
-			ResourceUtils.matchTag("W/\"123-4567890\"", null);
-			
-			fail();
-		} catch (IllegalArgumentException e) {
-			//ok
-		}
-		
-		try {
-			ResourceUtils.matchTag("123\"456789", "W/\"123\"");
-			
-			fail();
-		} catch (IllegalArgumentException e) {
-			//ok
-		}
-	}
+            // ok
+        }
+    }
+
+    @Test
+    public void testMatchTag() throws Exception {
+        assertTrue(ResourceUtils.matchTag("\"123-4567890\"", "W/\"123-4567890\""));
+        assertTrue(ResourceUtils.matchTag("\"123-4567890\"", "W/\"123-4567890\", \"123-4567891\""));
+        assertTrue(ResourceUtils.matchTag("W/\"123-4567891\"", "W/\"123-4567890\", \"123-4567891\""));
+        assertFalse(ResourceUtils.matchTag("\"123-4567890\"", "W/\"023-4567890\""));
+        assertFalse(ResourceUtils.matchTag("\"123-4567890\"", "W/\"023-4567890\", \"023-4567891\""));
+        assertFalse(ResourceUtils.matchTag("W/\"123-4567891\"", "W/\"023-4567890\", \"023-4567891\""));
+
+        try {
+            ResourceUtils.matchTag(null, "W/\"123-4567890\", \"123-4567891\"");
+            fail();
+        } catch (IllegalArgumentException e) {
+
+            // ok
+        }
+
+        try {
+            ResourceUtils.matchTag("W/\"123-4567890\"", null);
+            fail();
+        } catch (IllegalArgumentException e) {
+
+            // ok
+        }
+
+        try {
+            ResourceUtils.matchTag("123\"456789", "W/\"123\"");
+            fail();
+        } catch (IllegalArgumentException e) {
+
+            // ok
+        }
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/StateHolderResourceImpl.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/StateHolderResourceImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/StateHolderResourceImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
 import java.io.ByteArrayInputStream;
@@ -34,32 +36,30 @@
  * @since 4.0
  */
 public class StateHolderResourceImpl extends AbstractBaseResource implements StateHolder {
+    private Object state = "";
 
-	private Object state = "";
-	
-	@Override
-	public InputStream getInputStream() {
-		try {
-			return new ByteArrayInputStream(state.toString().getBytes("US-ASCII"));
-		} catch (UnsupportedEncodingException e) {
-			throw new FacesException(e.getMessage(), e);
-		}
-	}
+    @Override
+    public InputStream getInputStream() {
+        try {
+            return new ByteArrayInputStream(state.toString().getBytes("US-ASCII"));
+        } catch (UnsupportedEncodingException e) {
+            throw new FacesException(e.getMessage(), e);
+        }
+    }
 
-	public boolean isTransient() {
-		return false;
-	}
+    public boolean isTransient() {
+        return false;
+    }
 
-	public void restoreState(FacesContext context, Object state) {
-		this.state = state;
-	}
+    public void restoreState(FacesContext context, Object state) {
+        this.state = state;
+    }
 
-	public Object saveState(FacesContext context) {
-		return state;
-	}
+    public Object saveState(FacesContext context) {
+        return state;
+    }
 
-	public void setTransient(boolean newTransientValue) {
-		throw new UnsupportedOperationException();
-	}
-
+    public void setTransient(boolean newTransientValue) {
+        throw new UnsupportedOperationException();
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/resource/VersionedResourceImpl.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/resource/VersionedResourceImpl.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/resource/VersionedResourceImpl.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,17 +19,17 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.resource;
 
-
 /**
  * @author Nick Belaevski
  * @since 4.0
  */
 public class VersionedResourceImpl extends EmptyStreamResource {
-
-	@Override
-	public String getVersion() {
-		return "1_0_2";
-	}
+    @Override
+    public String getVersion() {
+        return "1_0_2";
+    }
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/skin/Bean.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/skin/Bean.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/skin/Bean.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -19,9 +19,16 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+
+
 package org.richfaces.skin;
 
 public class Bean {
-	 public String getName(){return "bindedtest";}
-	 public String getBean(){return "binded.string";}
-}
\ No newline at end of file
+    public String getName() {
+        return "bindedtest";
+    }
+
+    public String getBean() {
+        return "binded.string";
+    }
+}

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/skin/SkinTestCase.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/skin/SkinTestCase.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/skin/SkinTestCase.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -26,6 +26,7 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 import java.lang.reflect.Method;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -41,230 +42,256 @@
  */
 public class SkinTestCase extends AbstractFacesTest {
 
-	@Retention(RetentionPolicy.RUNTIME)
-	@Target(ElementType.METHOD)
-	private @interface SkinParameters {
-		String skinName() default "";
-		String baseSkinName() default "";
-	};
-	
-	public void setUp() throws Exception {
-		super.setUp();
-		setupFacesRequest();
-	}
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        setupFacesRequest();
+    }
 
-	public void tearDown() throws Exception {
-		SkinFactory.reset();
-		super.tearDown();
-	}
+    @Override
+    public void tearDown() throws Exception {
+        SkinFactory.reset();
+        super.tearDown();
+    }
 
-	@Override
-	protected void setupJsfInitParameters() {
-		super.setupJsfInitParameters();
-		
-		setupSkinParameters();
-	}
+    @Override
+    protected void setupJsfInitParameters() {
+        super.setupJsfInitParameters();
+        setupSkinParameters();
+    }
 
-	private void setupSkinParameters() {
-		try {
-			Method method = getClass().getMethod(getName());
-			SkinParameters skinParameters = method.getAnnotation(SkinParameters.class);
-			if (skinParameters != null) {
-				String skinName = skinParameters.skinName();
-				if (skinName != null && skinName.length() != 0) {
-					facesServer.addInitParameter(SkinFactory.SKIN_PARAMETER, skinName);
-				}
-				
-				String baseSkinName = skinParameters.baseSkinName();
-				if (baseSkinName != null && baseSkinName.length() != 0) {
-					facesServer.addInitParameter(SkinFactory.BASE_SKIN_PARAMETER, baseSkinName);
-				}
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
+    private void setupSkinParameters() {
+        try {
+            Method method = getClass().getMethod(getName());
+            SkinParameters skinParameters = method.getAnnotation(SkinParameters.class);
 
-	/*
-	 * Test method for 'org.richfaces.skin.SkinFactory.getInstance()'
-	 */
-	public void testGetInstance() {
-		SkinFactory factory = SkinFactory.getInstance();
-		SkinFactory factory1 = SkinFactory.getInstance();
-		assertSame(factory,factory1);
-	}
+            if (skinParameters != null) {
+                String skinName = skinParameters.skinName();
 
-	private void addParameters(Object[][] strings) {
-		Map<Object,Object> baseMap = new HashMap<Object, Object>();
-		for (Object[] objects : strings) {
-			baseMap.put(objects[0], objects[1]);
-		}
+                if (skinName != null && skinName.length() != 0) {
+                    facesServer.addInitParameter(SkinFactory.SKIN_PARAMETER, skinName);
+                }
 
-		facesContext.getExternalContext().getRequestMap().put("test", baseMap);
-	}
+                String baseSkinName = skinParameters.baseSkinName();
 
-	/*
-	 * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
-	 */
-	@SkinParameters(skinName = "test")
-	public void testGetSkin() {
-		addParameters(new Object[][]{new Object[] {"bean", "test.value"}});
+                if (baseSkinName != null && baseSkinName.length() != 0) {
+                    facesServer.addInitParameter(SkinFactory.BASE_SKIN_PARAMETER, baseSkinName);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 
-		SkinFactory factory = SkinFactory.getInstance();
-		// test call
-		Skin skin = factory.getSkin(facesContext);
-		assertNotNull("Null skin!",skin);
-		// test properties
-		assertEquals("string",skin.getParameter(facesContext, "string.property"));
-		assertEquals("base.string",skin.getParameter(facesContext, "base.property"));
-		assertEquals("test.value",skin.getParameter(facesContext, "bind.property"));
-		//		assertEquals("HTML_BASIC",skin.getRenderKitId(mockContext));
-	}
+    /*
+     * Test method for 'org.richfaces.skin.SkinFactory.getInstance()'
+     */
+    public void testGetInstance() {
+        SkinFactory factory = SkinFactory.getInstance();
+        SkinFactory factory1 = SkinFactory.getInstance();
 
-	/*
-	 * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
-	 */
-	@SkinParameters(skinName = "test")
-	public void testSkinReferences() {
-		SkinFactory factory = SkinFactory.getInstance();
+        assertSame(factory, factory1);
+    }
 
-		// test call
-		Skin skin = factory.getSkin(facesContext);
-		assertNotNull("Null skin!",skin);
-		assertEquals("default",skin.getParameter(facesContext, "c"));
-		assertEquals("yyy",skin.getParameter(facesContext, "y"));
-	}
+    private void addParameters(Object[][] strings) {
+        Map<Object, Object> baseMap = new HashMap<Object, Object>();
 
-	/*
-	 * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
-	 */
-	@SkinParameters(skinName = "style", baseSkinName = "style_base")
-	public void testSkinReferences1() {
-		SkinFactory factory = SkinFactory.getInstance();
-		// test call
-		Skin skin = factory.getSkin(facesContext);
-		assertNotNull("Null skin!",skin);
-		assertEquals("#F5F0E7",skin.getParameter(facesContext, "intermediateTextColor"));
-		assertEquals("10px",skin.getParameter(facesContext, "intermediateTextSize"));
-		assertEquals("#F5F0E7",skin.getParameter(facesContext, "generalTextColor"));
+        for (Object[] objects : strings) {
+            baseMap.put(objects[0], objects[1]);
+        }
 
-		assertEquals("white.textcolor",skin.getParameter(facesContext, "additionalTextColor"));
-	}
+        facesContext.getExternalContext().getRequestMap().put("test", baseMap);
+    }
 
-	@SkinParameters(skinName = "dynatest", baseSkinName = "dynatest_base")
-	public void testBaseSkin() {
-		SkinFactory factory = SkinFactory.getInstance();
-		addParameters(new Object[][]{new Object[] {"bean", "dynabase1"}});
+    /*
+     * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
+     */
+    @SkinParameters(skinName = "test")
+    public void testGetSkin() {
+        addParameters(new Object[][] {
+            new Object[] {"bean", "test.value"}
+        });
 
-		Skin skin = factory.getSkin(facesContext);
-		assertEquals("default", skin.getParameter(facesContext, "default"));
-		assertEquals("itself", skin.getParameter(facesContext, "selfValue"));
-		assertEquals("#AAA", skin.getParameter(facesContext, "customFormColor"));
+        SkinFactory factory = SkinFactory.getInstance();
 
-		Map<String, String> map = (Map<String, String>) facesContext.getExternalContext().getRequestMap().get("test");
-		map.put("bean", "dynabase2");
+        // test call
+        Skin skin = factory.getSkin(facesContext);
 
-		assertEquals("xxx", skin.getParameter(facesContext, "default"));
-		assertEquals("itself", skin.getParameter(facesContext, "selfValue"));
-		assertEquals("#AAA", skin.getParameter(facesContext, "customFormColor"));
-	}
+        assertNotNull("Null skin!", skin);
 
-	/*
-	 * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
-	 */
-	@SkinParameters(skinName = "cyclic")
-	public void testCyclicSkinReferences() {
-		SkinFactory factory = SkinFactory.getInstance();
+        // test properties
+        assertEquals("string", skin.getParameter(facesContext, "string.property"));
+        assertEquals("base.string", skin.getParameter(facesContext, "base.property"));
+        assertEquals("test.value", skin.getParameter(facesContext, "bind.property"));
 
-		try {
-			Skin skin = factory.getSkin(facesContext);
-			skin.getParameter(facesContext, "x");
-			fail();
-		} catch(FacesException e){
-			//it's ok
-		}
-	}
+        // assertEquals("HTML_BASIC",skin.getRenderKitId(mockContext));
+    }
 
-	/*
-	 * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
-	 */
-	@SkinParameters(skinName = "noref")
-	public void testBadSkinReferences() {
-		SkinFactory factory = SkinFactory.getInstance();
+    /*
+     * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
+     */
+    @SkinParameters(skinName = "test")
+    public void testSkinReferences() {
+        SkinFactory factory = SkinFactory.getInstance();
 
-		// test call
-		try {
-			Skin skin = factory.getSkin(facesContext);
-			skin.getParameter(facesContext, "x");
-			fail();
-		} catch(FacesException e){
-			//it's ok
-		}
-	}
-	/*
-	 * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
-	 */
-	@SkinParameters(skinName = "#{test.skin}")
-	public void testGetBindedSkin() {
-		SkinFactory factory = SkinFactory.getInstance();
+        // test call
+        Skin skin = factory.getSkin(facesContext);
 
-		addParameters(new Object[][] {
-				new Object[] {"skin", "bindedtest"},
-				new Object[] {"bean", "binded.test.value"}
-		});
+        assertNotNull("Null skin!", skin);
+        assertEquals("default", skin.getParameter(facesContext, "c"));
+        assertEquals("yyy", skin.getParameter(facesContext, "y"));
+    }
 
-		// test call
-		Skin skin = factory.getSkin(facesContext);
-		assertNotNull("Null skin!",skin);
-		// test properties
-		assertEquals("bindedstring",skin.getParameter(facesContext, "string.property"));
-		//		assertEquals("base.string",skin.getParameter(mockContext,"base.property"));
-		assertEquals("binded.test.value",skin.getParameter(facesContext, "bind.property"));
-		assertEquals("TEST",skin.getRenderKitId(facesContext));
-	}
+    /*
+     * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
+     */
+    @SkinParameters(skinName = "style", baseSkinName = "style_base")
+    public void testSkinReferences1() {
+        SkinFactory factory = SkinFactory.getInstance();
 
-	@SkinParameters(skinName = "#{test.skin}")
-	public void testSkinHash() {
-		SkinFactory factory = SkinFactory.getInstance();
+        // test call
+        Skin skin = factory.getSkin(facesContext);
 
-		addParameters(new Object[][] {
-				new Object[] {"skin", "bindedtest"},
-				new Object[] {"bean", "binded.test.value"}
-		});
+        assertNotNull("Null skin!", skin);
+        assertEquals("#F5F0E7", skin.getParameter(facesContext, "intermediateTextColor"));
+        assertEquals("10px", skin.getParameter(facesContext, "intermediateTextSize"));
+        assertEquals("#F5F0E7", skin.getParameter(facesContext, "generalTextColor"));
+        assertEquals("white.textcolor", skin.getParameter(facesContext, "additionalTextColor"));
+    }
 
-		Skin skin = factory.getSkin(facesContext);
-		Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
+    @SkinParameters(skinName = "dynatest", baseSkinName = "dynatest_base")
+    public void testBaseSkin() {
+        SkinFactory factory = SkinFactory.getInstance();
 
-		// test properties
-		int hash = skin.hashCode(facesContext);
-		assertTrue(requestMap.containsKey(BasicSkinImpl.REQUEST_HASH_CODES_MAP_PARAMETER));
-		assertEquals(hash,skin.hashCode(facesContext));
-		requestMap.remove(BasicSkinImpl.REQUEST_HASH_CODES_MAP_PARAMETER);
-		assertEquals(hash,skin.hashCode(facesContext));
-		// setup Value binding mock for different value - hash must differ.
-		requestMap.remove(BasicSkinImpl.REQUEST_HASH_CODES_MAP_PARAMETER);
+        addParameters(new Object[][] {
+            new Object[] {"bean", "dynabase1"}
+        });
 
-		Map map = (Map) requestMap.get("test");
-		map.put("bean", "other.test.value");
+        Skin skin = factory.getSkin(facesContext);
 
-		assertFalse( hash==skin.hashCode(facesContext) );
+        assertEquals("default", skin.getParameter(facesContext, "default"));
+        assertEquals("itself", skin.getParameter(facesContext, "selfValue"));
+        assertEquals("#AAA", skin.getParameter(facesContext, "customFormColor"));
 
-	}
-	/*
-	 * Test method for 'org.richfaces.skin.SkinFactory.getDefaultProperties()'
-	 */
-	public void testGetDefaultProperties() {
-		SkinFactory factory = (SkinFactory) SkinFactory.getInstance();
-		//		assertEquals("HTML_BASIC",defaultProps.getProperty("render.kit"));
-		// Second default config
-		assertEquals("default",factory.getDefaultSkin(facesContext).getParameter(facesContext, "a"));
-	}
+        Map<String, String> map = (Map<String, String>) facesContext.getExternalContext().getRequestMap().get("test");
 
-	/*
-	 * Test method for 'org.richfaces.skin.SkinFactory.getSkinName(FacesContext)'
-	 */
-	public void testGetSkinName() {
+        map.put("bean", "dynabase2");
+        assertEquals("xxx", skin.getParameter(facesContext, "default"));
+        assertEquals("itself", skin.getParameter(facesContext, "selfValue"));
+        assertEquals("#AAA", skin.getParameter(facesContext, "customFormColor"));
+    }
 
-	}
+    /*
+     * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
+     */
+    @SkinParameters(skinName = "cyclic")
+    public void testCyclicSkinReferences() {
+        SkinFactory factory = SkinFactory.getInstance();
 
+        try {
+            Skin skin = factory.getSkin(facesContext);
+
+            skin.getParameter(facesContext, "x");
+            fail();
+        } catch (FacesException e) {
+
+            // it's ok
+        }
+    }
+
+    /*
+     * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
+     */
+    @SkinParameters(skinName = "noref")
+    public void testBadSkinReferences() {
+        SkinFactory factory = SkinFactory.getInstance();
+
+        // test call
+        try {
+            Skin skin = factory.getSkin(facesContext);
+
+            skin.getParameter(facesContext, "x");
+            fail();
+        } catch (FacesException e) {
+
+            // it's ok
+        }
+    }
+
+    /*
+     * Test method for 'org.richfaces.skin.SkinFactory.getSkin(FacesContext)'
+     */
+    @SkinParameters(skinName = "#{test.skin}")
+    public void testGetBindedSkin() {
+        SkinFactory factory = SkinFactory.getInstance();
+
+        addParameters(new Object[][] {
+            new Object[] {"skin", "bindedtest"}, new Object[] {"bean", "binded.test.value"}
+        });
+
+        // test call
+        Skin skin = factory.getSkin(facesContext);
+
+        assertNotNull("Null skin!", skin);
+
+        // test properties
+        assertEquals("bindedstring", skin.getParameter(facesContext, "string.property"));
+
+        // assertEquals("base.string",skin.getParameter(mockContext,"base.property"));
+        assertEquals("binded.test.value", skin.getParameter(facesContext, "bind.property"));
+        assertEquals("TEST", skin.getRenderKitId(facesContext));
+    }
+
+    @SkinParameters(skinName = "#{test.skin}")
+    public void testSkinHash() {
+        SkinFactory factory = SkinFactory.getInstance();
+
+        addParameters(new Object[][] {
+            new Object[] {"skin", "bindedtest"}, new Object[] {"bean", "binded.test.value"}
+        });
+
+        Skin skin = factory.getSkin(facesContext);
+        Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
+
+        // test properties
+        int hash = skin.hashCode(facesContext);
+
+        assertTrue(requestMap.containsKey(BasicSkinImpl.REQUEST_HASH_CODES_MAP_PARAMETER));
+        assertEquals(hash, skin.hashCode(facesContext));
+        requestMap.remove(BasicSkinImpl.REQUEST_HASH_CODES_MAP_PARAMETER);
+        assertEquals(hash, skin.hashCode(facesContext));
+
+        // setup Value binding mock for different value - hash must differ.
+        requestMap.remove(BasicSkinImpl.REQUEST_HASH_CODES_MAP_PARAMETER);
+
+        Map map = (Map) requestMap.get("test");
+
+        map.put("bean", "other.test.value");
+        assertFalse(hash == skin.hashCode(facesContext));
+    }
+
+    /*
+     * Test method for 'org.richfaces.skin.SkinFactory.getDefaultProperties()'
+     */
+    public void testGetDefaultProperties() {
+        SkinFactory factory = (SkinFactory) SkinFactory.getInstance();
+
+        // assertEquals("HTML_BASIC",defaultProps.getProperty("render.kit"));
+        // Second default config
+        assertEquals("default", factory.getDefaultSkin(facesContext).getParameter(facesContext, "a"));
+    }
+
+    /*
+     * Test method for 'org.richfaces.skin.SkinFactory.getSkinName(FacesContext)'
+     */
+    public void testGetSkinName() {}
+
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target(ElementType.METHOD)
+    private @interface SkinParameters {
+        String skinName() default "";
+        String baseSkinName() default "";
+    }
+
+    ;
 }

Modified: root/framework/trunk/impl/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java	2009-11-02 11:26:36 UTC (rev 15805)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java	2009-11-02 11:33:49 UTC (rev 15806)
@@ -34,79 +34,82 @@
 // */
 //public class SkinThreadsTestCase extends AbstractThreadedAjax4JsfTestCase {
 //
-//	/**
-//	 * @param s
-//	 */
-//	public SkinThreadsTestCase(String s) {
-//		super(s);
-//		// TODO Auto-generated constructor stub
-//	}
+//  /**
+//   * @param s
+//   */
+//  public SkinThreadsTestCase(String s) {
+//      super(s);
+//      // TODO Auto-generated constructor stub
+//  }
 //
-//	/*
-//	 * (non-Javadoc)
-//	 * 
-//	 * @see com.exadel.vcp.tests.VcpJsfTestCase#setUp()
-//	 */
+//  /*
+//   * (non-Javadoc)
+//   * 
+//   * @see com.exadel.vcp.tests.VcpJsfTestCase#setUp()
+//   */
 //public void setUp() throws Exception {
-//		// TODO Auto-generated method stub
-//		super.setUp();
-//		servletContext.setAttribute("skin", new  Bean());
-//	}
-//	/*
-//	 * (non-Javadoc)
-//	 * 
-//	 * @see com.exadel.vcp.tests.VcpJsfTestCase#tearDown()
-//	 */
-//	public void tearDown() throws Exception {
-//		// TODO Auto-generated method stub
-//		super.tearDown();
-//	}
+//      // TODO Auto-generated method stub
+//      super.setUp();
+//      servletContext.setAttribute("skin", new  Bean());
+//  }
+//  /*
+//   * (non-Javadoc)
+//   * 
+//   * @see com.exadel.vcp.tests.VcpJsfTestCase#tearDown()
+//   */
+//  public void tearDown() throws Exception {
+//      // TODO Auto-generated method stub
+//      super.tearDown();
+//  }
 //
-//	
-//	public class SkinTestRunnable extends TestCaseRunnable {
+//  
+//  public class SkinTestRunnable extends TestCaseRunnable {
 //
-//		
-//		/**
-//		 * 
-//		 */
-//		public SkinTestRunnable() {
-//			// TODO Auto-generated constructor stub
-//		}
+//      
+//      /**
+//       * 
+//       */
+//      public SkinTestRunnable() {
+//          // TODO Auto-generated constructor stub
+//      }
 //
-//		/* (non-Javadoc)
-//		 * @see com.exadel.vcp.tests.ThreadedVcpJsfTestCase.TestCaseRunnable#runTestCase(javax.faces.context.FacesContext)
-//		 */
-//		public void runTestCase(FacesContext context) throws Throwable {
-//			context.getExternalContext().getRequestMap().put("test", new Bean());
-//			Skin skin = SkinFactory.getInstance().getSkin(context);
-//			assertNotNull(skin);
-//			assertEquals("TEST", skin.getRenderKitId(context));
-//			assertEquals("binded.string", skin.getParameter(context, "bind.property"));
-//			assertEquals("bindedstring", skin.getParameter(context, "string.property"));
-//			assertEquals("10", skin.getParameter(context, "int.property"));
-//			assertNull(skin.getParameter(context, "notexist"));
-//		}
-//		
-//	}
-//	
-//	/**
-//	 * Test skin factory for thread-safe.
-//	 */
-//	public void testThreadsafe() {
-//		TestCaseRunnable[] runnables = new TestCaseRunnable[20];
-//		for (int i = 0; i < runnables.length; i++) {
-//			runnables[i] = new SkinTestRunnable();
-//			
-//		}
-//		this.runTestCaseRunnables(runnables);
-//	}
-//	/*
-//	 * (non-Javadoc)
-//	 * 
-//	 * @see com.exadel.vcp.tests.VcpJsfTestCase#getSkinName()
-//	 */
-//	protected String getSkinName() {
-//		// TODO Auto-generated method stub
-//		return "#{skin.name}";
-//	}
+//      /* (non-Javadoc)
+//       * @see com.exadel.vcp.tests.ThreadedVcpJsfTestCase.TestCaseRunnable#runTestCase(javax.faces.context.FacesContext)
+//       */
+//      public void runTestCase(FacesContext context) throws Throwable {
+//          context.getExternalContext().getRequestMap().put("test", new Bean());
+//          Skin skin = SkinFactory.getInstance().getSkin(context);
+//          assertNotNull(skin);
+//          assertEquals("TEST", skin.getRenderKitId(context));
+//          assertEquals("binded.string", skin.getParameter(context, "bind.property"));
+//          assertEquals("bindedstring", skin.getParameter(context, "string.property"));
+//          assertEquals("10", skin.getParameter(context, "int.property"));
+//          assertNull(skin.getParameter(context, "notexist"));
+//      }
+//      
+//  }
+//  
+//  /**
+//   * Test skin factory for thread-safe.
+//   */
+//  public void testThreadsafe() {
+//      TestCaseRunnable[] runnables = new TestCaseRunnable[20];
+//      for (int i = 0; i < runnables.length; i++) {
+//          runnables[i] = new SkinTestRunnable();
+//          
+//      }
+//      this.runTestCaseRunnables(runnables);
+//  }
+//  /*
+//   * (non-Javadoc)
+//   * 
+//   * @see com.exadel.vcp.tests.VcpJsfTestCase#getSkinName()
+//   */
+//  protected String getSkinName() {
+//      // TODO Auto-generated method stub
+//      return "#{skin.name}";
+//  }
 //}
+
+
+



More information about the richfaces-svn-commits mailing list