You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/08/28 20:59:24 UTC
svn commit: r990408 [5/10] - in /myfaces/test/trunk:
test12/src/main/java/org/apache/myfaces/test/base/
test12/src/main/java/org/apache/myfaces/test/base/junit4/
test12/src/main/java/org/apache/myfaces/test/cargo/
test12/src/main/java/org/apache/myface...
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPortletRequest.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPortletRequest.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPortletRequest.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPortletRequest.java Sat Aug 28 18:59:21 2010
@@ -37,25 +37,26 @@ import javax.portlet.WindowState;
* @since 1.0.0
*/
-public class MockPortletRequest implements PortletRequest {
+public class MockPortletRequest implements PortletRequest
+{
// ------------------------------------------------------------ Constructors
- public MockPortletRequest() {
+ public MockPortletRequest()
+ {
super();
}
-
- public MockPortletRequest(PortletSession session) {
+ public MockPortletRequest(PortletSession session)
+ {
super();
this.session = session;
}
-
// ----------------------------------------------------- Mock Object Methods
/**
@@ -64,10 +65,12 @@ public class MockPortletRequest implemen
* @param name Parameter name
* @param value Parameter value
*/
- public void addParameter(String name, String value) {
+ public void addParameter(String name, String value)
+ {
String[] values = (String[]) parameters.get(name);
- if (values == null) {
+ if (values == null)
+ {
String[] results = new String[] { value };
parameters.put(name, results);
return;
@@ -79,37 +82,37 @@ public class MockPortletRequest implemen
}
-
/**
* <p> Set the <code>PortletSession</code> associated with this request.
* </p>
*
* @param session The new session
*/
- public void setPortletSession(PortletSession session) {
+ public void setPortletSession(PortletSession session)
+ {
this.session = session;
}
-
/**
* <p> Set the <code>Locale</code> associated with this request. </p>
*
* @param locale The new locale
*/
- public void setLocale(Locale locale) {
+ public void setLocale(Locale locale)
+ {
this.locale = locale;
}
-
/**
* <p> Set the <code>Principal</code> associated with this request. </p>
*
* @param principal The new Principal
*/
- public void setUserPrincipal(Principal principal) {
+ public void setUserPrincipal(Principal principal)
+ {
this.principal = principal;
@@ -124,294 +127,303 @@ public class MockPortletRequest implemen
private Principal principal = null;
private PortletSession session = null;
-
// -------------------------------------------------- PortletRequest Methods
-
/** {@inheritDoc} */
- public String getAuthType() {
+ public String getAuthType()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public String getContextPath() {
+ public String getContextPath()
+ {
return contextPath;
}
-
/** {@inheritDoc} */
- public Object getAttribute(String name) {
+ public Object getAttribute(String name)
+ {
return attributes.get(name);
}
-
/** {@inheritDoc} */
- public Enumeration getAttributeNames() {
+ public Enumeration getAttributeNames()
+ {
return new MockEnumeration(attributes.keySet().iterator());
}
-
/** {@inheritDoc} */
- public Locale getLocale() {
+ public Locale getLocale()
+ {
return locale;
}
-
/** {@inheritDoc} */
- public Enumeration getLocales() {
+ public Enumeration getLocales()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public String getParameter(String name) {
+ public String getParameter(String name)
+ {
String[] values = (String[]) parameters.get(name);
- if (values != null) {
+ if (values != null)
+ {
return values[0];
- } else {
+ }
+ else
+ {
return null;
}
}
-
/** {@inheritDoc} */
- public Map getParameterMap() {
+ public Map getParameterMap()
+ {
return parameters;
}
-
/** {@inheritDoc} */
- public Enumeration getParameterNames() {
+ public Enumeration getParameterNames()
+ {
return new MockEnumeration(parameters.keySet().iterator());
}
-
/** {@inheritDoc} */
- public String[] getParameterValues(String name) {
+ public String[] getParameterValues(String name)
+ {
return (String[]) parameters.get(name);
}
-
/** {@inheritDoc} */
- public PortalContext getPortalContext() {
+ public PortalContext getPortalContext()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public PortletMode getPortletMode() {
+ public PortletMode getPortletMode()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public PortletSession getPortletSession() {
+ public PortletSession getPortletSession()
+ {
return getPortletSession(true);
}
-
/** {@inheritDoc} */
- public PortletSession getPortletSession(boolean create) {
+ public PortletSession getPortletSession(boolean create)
+ {
- if (create && (session == null)) {
+ if (create && (session == null))
+ {
throw new UnsupportedOperationException();
}
return session;
}
-
/** {@inheritDoc} */
- public PortletPreferences getPreferences() {
+ public PortletPreferences getPreferences()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public Enumeration getProperties(String arg0) {
+ public Enumeration getProperties(String arg0)
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public String getProperty(String arg0) {
+ public String getProperty(String arg0)
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public Enumeration getPropertyNames() {
+ public Enumeration getPropertyNames()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public String getRemoteUser() {
+ public String getRemoteUser()
+ {
- if (principal != null) {
+ if (principal != null)
+ {
return principal.getName();
- } else {
+ }
+ else
+ {
return null;
}
}
-
/** {@inheritDoc} */
- public String getRequestedSessionId() {
+ public String getRequestedSessionId()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public String getResponseContentType() {
+ public String getResponseContentType()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public Enumeration getResponseContentTypes() {
+ public Enumeration getResponseContentTypes()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public String getScheme() {
+ public String getScheme()
+ {
return ("http");
}
-
/** {@inheritDoc} */
- public String getServerName() {
+ public String getServerName()
+ {
return ("localhost");
}
-
/** {@inheritDoc} */
- public int getServerPort() {
+ public int getServerPort()
+ {
return (8080);
}
-
/** {@inheritDoc} */
- public Principal getUserPrincipal() {
+ public Principal getUserPrincipal()
+ {
return principal;
}
-
/** {@inheritDoc} */
- public WindowState getWindowState() {
+ public WindowState getWindowState()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public boolean isPortletModeAllowed(PortletMode arg0) {
+ public boolean isPortletModeAllowed(PortletMode arg0)
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public boolean isRequestedSessionIdValid() {
+ public boolean isRequestedSessionIdValid()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public boolean isSecure() {
+ public boolean isSecure()
+ {
return false;
}
-
/** {@inheritDoc} */
- public boolean isUserInRole(String arg0) {
+ public boolean isUserInRole(String arg0)
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public boolean isWindowStateAllowed(WindowState arg0) {
+ public boolean isWindowStateAllowed(WindowState arg0)
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public void removeAttribute(String name) {
+ public void removeAttribute(String name)
+ {
- if (attributes.containsKey(name)) {
+ if (attributes.containsKey(name))
+ {
attributes.remove(name);
}
}
-
/** {@inheritDoc} */
- public void setAttribute(String name, Object value) {
+ public void setAttribute(String name, Object value)
+ {
- if (name == null) {
+ if (name == null)
+ {
throw new IllegalArgumentException("Attribute name cannot be null");
}
- if (value == null) {
+ if (value == null)
+ {
removeAttribute(name);
return;
}
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPortletResponse.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPortletResponse.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPortletResponse.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPortletResponse.java Sat Aug 28 18:59:21 2010
@@ -26,35 +26,37 @@ import javax.portlet.PortletResponse;
* @since 1.0.0
*/
-public class MockPortletResponse implements PortletResponse {
+public class MockPortletResponse implements PortletResponse
+{
/**
* <p>Return a default instance.</p>
*/
- public MockPortletResponse() {
+ public MockPortletResponse()
+ {
}
-
// -------------------------------------------------- PortletContext Methods
/** {@inheritDoc} */
- public void addProperty(String name, String value) {
+ public void addProperty(String name, String value)
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public String encodeURL(String url) {
+ public String encodeURL(String url)
+ {
return url;
}
-
/** {@inheritDoc} */
- public void setProperty(String name, String value) {
+ public void setProperty(String name, String value)
+ {
throw new UnsupportedOperationException();
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPortletSession.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPortletSession.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPortletSession.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPortletSession.java Sat Aug 28 18:59:21 2010
@@ -30,34 +30,35 @@ import javax.portlet.PortletSession;
* $Id$
* @since 1.0.0
*/
-public class MockPortletSession implements PortletSession {
+public class MockPortletSession implements PortletSession
+{
// ------------------------------------------------------------ Constructors
/**
* <p> Configure a default instance. </p>
*/
- public MockPortletSession() {
+ public MockPortletSession()
+ {
super();
}
-
/**
* <p> Configure a session instance associated with the specified servlet
* context. </p>
*
* @param servletContext The associated servlet context
*/
- public MockPortletSession(PortletContext portletContext) {
+ public MockPortletSession(PortletContext portletContext)
+ {
super();
this.portletContext = portletContext;
}
-
// ----------------------------------------------------- Mock Object Methods
/**
@@ -66,7 +67,8 @@ public class MockPortletSession implemen
*
* @param servletContext The associated servlet context
*/
- public void setPortletContext(PortletContext portletContext) {
+ public void setPortletContext(PortletContext portletContext)
+ {
this.portletContext = portletContext;
@@ -79,7 +81,6 @@ public class MockPortletSession implemen
private String id = "123";
private PortletContext portletContext = null;
-
// ---------------------------------------------------------- Public Methods
/**
@@ -87,30 +88,33 @@ public class MockPortletSession implemen
*
* @param id The new session identifier
*/
- public void setId(String id) {
+ public void setId(String id)
+ {
this.id = id;
}
-
// -------------------------------------------------- PortletSession Methods
-
/** {@inheritDoc} */
- public Object getAttribute(String name) {
+ public Object getAttribute(String name)
+ {
return getAttribute(name, PORTLET_SCOPE);
}
-
/** {@inheritDoc} */
- public Object getAttribute(String name, int scope) {
+ public Object getAttribute(String name, int scope)
+ {
- if (scope == PORTLET_SCOPE) {
+ if (scope == PORTLET_SCOPE)
+ {
return portletAttributes.get(name);
- } else if (scope == APPLICATION_SCOPE) {
+ }
+ else if (scope == APPLICATION_SCOPE)
+ {
return applicationAttributes.get(name);
}
@@ -119,21 +123,24 @@ public class MockPortletSession implemen
}
-
/** {@inheritDoc} */
- public Enumeration getAttributeNames() {
+ public Enumeration getAttributeNames()
+ {
return getAttributeNames(PORTLET_SCOPE);
}
-
/** {@inheritDoc} */
- public Enumeration getAttributeNames(int scope) {
+ public Enumeration getAttributeNames(int scope)
+ {
- if (scope == PORTLET_SCOPE) {
+ if (scope == PORTLET_SCOPE)
+ {
return new MockEnumeration(portletAttributes.keySet().iterator());
- } else if (scope == APPLICATION_SCOPE) {
+ }
+ else if (scope == APPLICATION_SCOPE)
+ {
return new MockEnumeration(applicationAttributes.keySet()
.iterator());
}
@@ -143,114 +150,127 @@ public class MockPortletSession implemen
}
-
/** {@inheritDoc} */
- public long getCreationTime() {
+ public long getCreationTime()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public String getId() {
+ public String getId()
+ {
return this.id;
}
-
/** {@inheritDoc} */
- public long getLastAccessedTime() {
+ public long getLastAccessedTime()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public int getMaxInactiveInterval() {
+ public int getMaxInactiveInterval()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public PortletContext getPortletContext() {
+ public PortletContext getPortletContext()
+ {
return portletContext;
}
-
/** {@inheritDoc} */
- public void invalidate() {
+ public void invalidate()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public boolean isNew() {
+ public boolean isNew()
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public void removeAttribute(String name) {
+ public void removeAttribute(String name)
+ {
removeAttribute(name, PORTLET_SCOPE);
}
-
/** {@inheritDoc} */
- public void removeAttribute(String name, int scope) {
+ public void removeAttribute(String name, int scope)
+ {
Map attributes;
- if (scope == PORTLET_SCOPE) {
+ if (scope == PORTLET_SCOPE)
+ {
attributes = portletAttributes;
- } else if (scope == APPLICATION_SCOPE) {
+ }
+ else if (scope == APPLICATION_SCOPE)
+ {
attributes = applicationAttributes;
- } else {
+ }
+ else
+ {
throw new IllegalArgumentException("Scope constant " + scope
+ " not recognized");
}
- if (attributes.containsKey(name)) {
+ if (attributes.containsKey(name))
+ {
attributes.remove(name);
}
}
-
/** {@inheritDoc} */
- public void setAttribute(String name, Object value) {
+ public void setAttribute(String name, Object value)
+ {
setAttribute(name, value, PORTLET_SCOPE);
}
-
/** {@inheritDoc} */
- public void setAttribute(String name, Object value, int scope) {
+ public void setAttribute(String name, Object value, int scope)
+ {
- if (name == null) {
+ if (name == null)
+ {
throw new IllegalArgumentException("Attribute name cannot be null");
}
- if (value == null) {
+ if (value == null)
+ {
removeAttribute(name, scope);
return;
}
Map attributes;
- if (scope == PORTLET_SCOPE) {
+ if (scope == PORTLET_SCOPE)
+ {
attributes = portletAttributes;
- } else if (scope == APPLICATION_SCOPE) {
+ }
+ else if (scope == APPLICATION_SCOPE)
+ {
attributes = applicationAttributes;
- } else {
+ }
+ else
+ {
throw new IllegalArgumentException("Scope constant " + scope
+ " not recognized");
}
@@ -258,9 +278,9 @@ public class MockPortletSession implemen
}
-
/** {@inheritDoc} */
- public void setMaxInactiveInterval(int arg0) {
+ public void setMaxInactiveInterval(int arg0)
+ {
throw new UnsupportedOperationException();
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPrincipal.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPrincipal.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPrincipal.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPrincipal.java Sat Aug 28 18:59:21 2010
@@ -24,59 +24,54 @@ import java.security.Principal;
*
* @since 1.0.0
*/
-public class MockPrincipal implements Principal {
-
+public class MockPrincipal implements Principal
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Construct a default Principal instance.</p>
*/
- public MockPrincipal() {
+ public MockPrincipal()
+ {
this(null);
}
-
/**
* <p>Construct a Principal with the specified name.</p>
*
* @param name Name for this Principal
*/
- public MockPrincipal(String name) {
+ public MockPrincipal(String name)
+ {
this.name = name;
}
-
// ------------------------------------------------------ Instance Variables
-
/**
* <p>The name for this Principal intance.</p>
*/
private String name = null;
-
// ----------------------------------------------------- Mock Object Methods
-
/**
* <p>Set the name for this Principal.</p>
*
* @param name The new name
*/
- public void setName(String name) {
+ public void setName(String name)
+ {
this.name = name;
}
-
// ------------------------------------------------------- Principal Methods
-
/** {@inheritDoc} */
- public String getName() {
+ public String getName()
+ {
return this.name;
}
-
}
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPrintWriter.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPrintWriter.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPrintWriter.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPrintWriter.java Sat Aug 28 18:59:21 2010
@@ -20,7 +20,6 @@ package org.apache.myfaces.test.mock;
import java.io.CharArrayWriter;
import java.io.PrintWriter;
-
/**
* <p>Mock implementation of <code>PrintWriter</code>.</p>
*
@@ -28,62 +27,56 @@ import java.io.PrintWriter;
* @since 1.0.0
*/
-public class MockPrintWriter extends PrintWriter {
-
+public class MockPrintWriter extends PrintWriter
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Return a default instance.</p>
*
* @param writer Temporary buffer storage for us to use
*/
- public MockPrintWriter(CharArrayWriter writer) {
+ public MockPrintWriter(CharArrayWriter writer)
+ {
super(writer);
this.caw = writer;
}
-
// ----------------------------------------------------- Mock Object Methods
-
/**
* <p>Return the content that has been written to this writer.</p>
*/
- public char[] content() {
+ public char[] content()
+ {
return caw.toCharArray();
}
-
/**
* <p>Reset this output stream so that it appears no content has been
* written.</p>
*/
- public void reset() {
+ public void reset()
+ {
caw.reset();
}
-
/**
* <p>Return the number of characters that have been written to this writer.</p>
*/
- public int size() {
+ public int size()
+ {
return caw.size();
}
-
-
// ------------------------------------------------------ Instance Variables
-
/**
* <p>The writer we will use for buffering.</p>
*/
private CharArrayWriter caw = null;
-
// ----------------------------------------------------- PrintWriter Methods
-
}
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPropertyResolver.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPropertyResolver.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPropertyResolver.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockPropertyResolver.java Sat Aug 28 18:59:21 2010
@@ -34,101 +34,114 @@ import javax.faces.el.PropertyResolver;
* @since 1.0.0
*/
-public class MockPropertyResolver extends PropertyResolver {
-
+public class MockPropertyResolver extends PropertyResolver
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Construct a default instance.</p>
*/
- public MockPropertyResolver() {
+ public MockPropertyResolver()
+ {
}
-
// ----------------------------------------------------- Mock Object Methods
-
// ------------------------------------------------------ Instance Variables
-
// ------------------------------------------------ PropertyResolver Methods
-
/** {@inheritDoc} */
public Object getValue(Object base, Object property)
- throws EvaluationException, PropertyNotFoundException {
+ throws EvaluationException, PropertyNotFoundException
+ {
- if (base == null) {
+ if (base == null)
+ {
throw new NullPointerException();
}
- if (base instanceof Map) {
+ if (base instanceof Map)
+ {
return ((Map) base).get(property);
}
String name = property.toString();
PropertyDescriptor descriptor = descriptor(base.getClass(), name);
- try {
+ try
+ {
return descriptor.getReadMethod().invoke(base, (Object[]) null);
- } catch (IllegalAccessException e) {
+ }
+ catch (IllegalAccessException e)
+ {
throw new EvaluationException(e);
- } catch (InvocationTargetException e) {
+ }
+ catch (InvocationTargetException e)
+ {
throw new EvaluationException(e.getTargetException());
}
}
-
/** {@inheritDoc} */
public Object getValue(Object base, int index)
- throws PropertyNotFoundException {
+ throws PropertyNotFoundException
+ {
return getValue(base, "" + index);
}
-
/** {@inheritDoc} */
public void setValue(Object base, Object property, Object value)
- throws PropertyNotFoundException {
+ throws PropertyNotFoundException
+ {
- if (base == null) {
+ if (base == null)
+ {
throw new NullPointerException();
}
- if (base instanceof Map) {
+ if (base instanceof Map)
+ {
((Map) base).put(property, value);
return;
}
String name = property.toString();
PropertyDescriptor descriptor = descriptor(base.getClass(), name);
- try {
+ try
+ {
descriptor.getWriteMethod().invoke(base, new Object[] { value });
- } catch (IllegalAccessException e) {
+ }
+ catch (IllegalAccessException e)
+ {
throw new EvaluationException(e);
- } catch (InvocationTargetException e) {
+ }
+ catch (InvocationTargetException e)
+ {
throw new EvaluationException(e.getTargetException());
}
}
-
/** {@inheritDoc} */
public void setValue(Object base, int index, Object value)
- throws PropertyNotFoundException {
+ throws PropertyNotFoundException
+ {
setValue(base, "" + index, value);
}
-
/** {@inheritDoc} */
public boolean isReadOnly(Object base, Object property)
- throws PropertyNotFoundException {
+ throws PropertyNotFoundException
+ {
- if (base == null) {
+ if (base == null)
+ {
throw new NullPointerException();
}
- if (base instanceof Map) {
+ if (base instanceof Map)
+ {
return false; // We have no way to know anything more specific
}
String name = property.toString();
@@ -137,28 +150,33 @@ public class MockPropertyResolver extend
}
-
/** {@inheritDoc} */
public boolean isReadOnly(Object base, int index)
- throws PropertyNotFoundException {
+ throws PropertyNotFoundException
+ {
return isReadOnly(base, "" + index);
}
-
/** {@inheritDoc} */
public Class getType(Object base, Object property)
- throws PropertyNotFoundException {
+ throws PropertyNotFoundException
+ {
- if (base == null) {
+ if (base == null)
+ {
throw new NullPointerException();
}
- if (base instanceof Map) {
+ if (base instanceof Map)
+ {
Object value = ((Map) base).get(property);
- if (value != null) {
+ if (value != null)
+ {
return value.getClass();
- } else {
+ }
+ else
+ {
return Object.class;
}
}
@@ -168,19 +186,17 @@ public class MockPropertyResolver extend
}
-
/** {@inheritDoc} */
public Class getType(Object base, int index)
- throws PropertyNotFoundException {
+ throws PropertyNotFoundException
+ {
return getType(base, "" + index);
}
-
// --------------------------------------------------------- Private Methods
-
/**
* <p>Return the <code>PropertyDescriptor</code> for the specified
* property of the specified class.</p>
@@ -193,20 +209,28 @@ public class MockPropertyResolver extend
* @exception PropertyNotFoundException if the specified property does
* not exist on the specified class
*/
- private PropertyDescriptor descriptor(Class clazz, String name) {
+ private PropertyDescriptor descriptor(Class clazz, String name)
+ {
- System.err.println("descriptor(class=" + clazz.getName() + ", name=" + name);
+ System.err.println("descriptor(class=" + clazz.getName() + ", name="
+ + name);
BeanInfo info = null;
- try {
+ try
+ {
info = Introspector.getBeanInfo(clazz);
System.err.println(" Found BeanInfo " + info);
- } catch (IntrospectionException e) {
+ }
+ catch (IntrospectionException e)
+ {
throw new EvaluationException(e);
}
PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
- for (int i = 0; i < descriptors.length; i++) {
- if (name.equals(descriptors[i].getName())) {
- System.err.print(" Found PropertyDescriptor " + descriptors[i]);
+ for (int i = 0; i < descriptors.length; i++)
+ {
+ if (name.equals(descriptors[i].getName()))
+ {
+ System.err
+ .print(" Found PropertyDescriptor " + descriptors[i]);
return descriptors[i];
}
}
@@ -215,5 +239,4 @@ public class MockPropertyResolver extend
}
-
}
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockRenderKitFactory.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockRenderKitFactory.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockRenderKitFactory.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockRenderKitFactory.java Sat Aug 28 18:59:21 2010
@@ -32,69 +32,70 @@ import javax.faces.render.RenderKitFacto
* @since 1.0.0
*/
-public class MockRenderKitFactory extends RenderKitFactory {
-
+public class MockRenderKitFactory extends RenderKitFactory
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Return a default instance.</p>
*/
- public MockRenderKitFactory() {
+ public MockRenderKitFactory()
+ {
renderKits = new HashMap();
}
-
// ----------------------------------------------------- Mock Object Methods
-
// ------------------------------------------------------ Instance Variables
-
/**
* <p>The set of render kits that have been registered here.</p>
*/
private Map renderKits = new HashMap();
-
// ------------------------------------------------ RenderKitFactory Methods
-
/** {@inheritDoc} */
- public void addRenderKit(String renderKitId, RenderKit renderKit) {
+ public void addRenderKit(String renderKitId, RenderKit renderKit)
+ {
- if ((renderKitId == null) || (renderKit == null)) {
+ if ((renderKitId == null) || (renderKit == null))
+ {
throw new NullPointerException();
}
- if (renderKits.containsKey(renderKitId)) {
+ if (renderKits.containsKey(renderKitId))
+ {
throw new IllegalArgumentException(renderKitId);
}
renderKits.put(renderKitId, renderKit);
}
-
/** {@inheritDoc} */
- public RenderKit getRenderKit(FacesContext context, String renderKitId) {
+ public RenderKit getRenderKit(FacesContext context, String renderKitId)
+ {
- if (renderKitId == null) {
+ if (renderKitId == null)
+ {
throw new NullPointerException();
}
RenderKit renderKit = (RenderKit) renderKits.get(renderKitId);
- if (renderKit == null) {
+ if (renderKit == null)
+ {
// Issue 38294 -- We removed the automatic creation of the
// default renderkit in the constructor, allowing it to be
// added by AbstractJsfTestCase in the usual case. To preserve
// backwards compatibility, however, create one on the fly
// if the user asks for the default HTML renderkit and it has
// not been manually added yet
- if (RenderKitFactory.HTML_BASIC_RENDER_KIT.equals(renderKitId)) {
+ if (RenderKitFactory.HTML_BASIC_RENDER_KIT.equals(renderKitId))
+ {
renderKit = new MockRenderKit();
renderKits.put(RenderKitFactory.HTML_BASIC_RENDER_KIT,
- renderKit);
+ renderKit);
return renderKit;
}
throw new IllegalArgumentException(renderKitId);
@@ -103,13 +104,12 @@ public class MockRenderKitFactory extend
}
-
/** {@inheritDoc} */
- public Iterator getRenderKitIds() {
+ public Iterator getRenderKitIds()
+ {
return renderKits.keySet().iterator();
}
-
}
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java Sat Aug 28 18:59:21 2010
@@ -24,17 +24,16 @@ public class MockResponseStateManager ex
// ------------------------------------------------------------ Constructors
// ------------------------------------------------------ Instance Variables
-
+
private static final int TREE_PARAM = 0;
private static final int STATE_PARAM = 1;
private static final int VIEWID_PARAM = 2;
private static final String ZIP_CHARSET = "ISO-8859-1";
-
// ----------------------------------------------------- Mock Object Methods
// -------------------------------------------------- ResponseStateManager Methods
-
+
public Object getState(FacesContext facesContext, String viewId)
{
Object[] savedState = getSavedState(facesContext);
@@ -46,7 +45,8 @@ public class MockResponseStateManager ex
return new Object[] { savedState[TREE_PARAM], savedState[STATE_PARAM] };
}
- public Object getTreeStructureToRestore(FacesContext facesContext, String viewId)
+ public Object getTreeStructureToRestore(FacesContext facesContext,
+ String viewId)
{
// Although this method won't be called anymore,
// it has been kept for backward compatibility.
@@ -74,17 +74,19 @@ public class MockResponseStateManager ex
public boolean isPostback(FacesContext context)
{
- return context.getExternalContext().getRequestParameterMap().containsKey(ResponseStateManager.VIEW_STATE_PARAM);
+ return context.getExternalContext().getRequestParameterMap()
+ .containsKey(ResponseStateManager.VIEW_STATE_PARAM);
}
- public void writeState(FacesContext facescontext, SerializedView serializedview)
- throws IOException
+ public void writeState(FacesContext facescontext,
+ SerializedView serializedview) throws IOException
{
ResponseWriter responseWriter = facescontext.getResponseWriter();
Object[] savedState = new Object[3];
- if (facescontext.getApplication().getStateManager().isSavingStateInClient(facescontext))
+ if (facescontext.getApplication().getStateManager()
+ .isSavingStateInClient(facescontext))
{
Object treeStruct = serializedview.getStructure();
Object compStates = serializedview.getState();
@@ -121,10 +123,11 @@ public class MockResponseStateManager ex
writeRenderKitIdField(facescontext, responseWriter);
}
- private void writeViewStateField(FacesContext facesContext, ResponseWriter responseWriter, Object savedState)
- throws IOException
+ private void writeViewStateField(FacesContext facesContext,
+ ResponseWriter responseWriter, Object savedState)
+ throws IOException
{
-
+
String serializedState = construct(facesContext, savedState);
responseWriter.startElement("input", null);
responseWriter.writeAttribute("type", "hidden", null);
@@ -132,23 +135,28 @@ public class MockResponseStateManager ex
responseWriter.writeAttribute("value", serializedState, null);
responseWriter.endElement("input");
}
-
- private void writeRenderKitIdField(FacesContext facesContext, ResponseWriter responseWriter) throws IOException
+ private void writeRenderKitIdField(FacesContext facesContext,
+ ResponseWriter responseWriter) throws IOException
{
-
- String defaultRenderKitId = facesContext.getApplication().getDefaultRenderKitId();
- if (defaultRenderKitId != null && !RenderKitFactory.HTML_BASIC_RENDER_KIT.equals(defaultRenderKitId))
+
+ String defaultRenderKitId = facesContext.getApplication()
+ .getDefaultRenderKitId();
+ if (defaultRenderKitId != null
+ && !RenderKitFactory.HTML_BASIC_RENDER_KIT
+ .equals(defaultRenderKitId))
{
responseWriter.startElement("input", null);
responseWriter.writeAttribute("type", "hidden", null);
- responseWriter.writeAttribute("name", ResponseStateManager.RENDER_KIT_ID_PARAM, null);
+ responseWriter.writeAttribute("name",
+ ResponseStateManager.RENDER_KIT_ID_PARAM, null);
responseWriter.writeAttribute("value", defaultRenderKitId, null);
responseWriter.endElement("input");
}
}
-
- private String construct(FacesContext facesContext, Object savedState) throws IOException
+
+ private String construct(FacesContext facesContext, Object savedState)
+ throws IOException
{
byte[] bytes = null;
ByteArrayOutputStream baos = null;
@@ -168,7 +176,7 @@ public class MockResponseStateManager ex
{
oos.close();
}
- catch(IOException e)
+ catch (IOException e)
{
}
finally
@@ -182,7 +190,7 @@ public class MockResponseStateManager ex
{
baos.close();
}
- catch(IOException e)
+ catch (IOException e)
{
}
finally
@@ -193,19 +201,20 @@ public class MockResponseStateManager ex
}
return new String(new _Hex().encode(bytes), ZIP_CHARSET);
}
-
- private Object reconstruct(FacesContext facesContext, String encodedState) throws IOException
+
+ private Object reconstruct(FacesContext facesContext, String encodedState)
+ throws IOException
{
byte[] bytes = encodedState.getBytes(ZIP_CHARSET);
-
+
ByteArrayInputStream input = null;
ObjectInputStream s = null;
Object object = null;
-
+
try
{
input = new ByteArrayInputStream(bytes);
- s = new ObjectInputStream(input);
+ s = new ObjectInputStream(input);
object = s.readObject();
}
catch (ClassNotFoundException e)
@@ -220,7 +229,7 @@ public class MockResponseStateManager ex
{
s.close();
}
- catch(IOException e)
+ catch (IOException e)
{
}
finally
@@ -234,7 +243,7 @@ public class MockResponseStateManager ex
{
input.close();
}
- catch(IOException e)
+ catch (IOException e)
{
}
finally
@@ -246,31 +255,34 @@ public class MockResponseStateManager ex
return object;
}
- private Object[] getSavedState(FacesContext facesContext) {
- Object encodedState =
- facesContext.getExternalContext().
- getRequestParameterMap().get(VIEW_STATE_PARAM);
- if(encodedState==null || (((String) encodedState).length() == 0)) {
+ private Object[] getSavedState(FacesContext facesContext)
+ {
+ Object encodedState = facesContext.getExternalContext()
+ .getRequestParameterMap().get(VIEW_STATE_PARAM);
+ if (encodedState == null || (((String) encodedState).length() == 0))
+ {
return null;
}
Object[] savedState = null;
-
+
try
{
- savedState = (Object[])reconstruct(facesContext, (String)encodedState);
+ savedState = (Object[]) reconstruct(facesContext,
+ (String) encodedState);
}
- catch(IOException e)
+ catch (IOException e)
{
- facesContext.getExternalContext().log("Cannot reconstruct view state", e);
+ facesContext.getExternalContext().log(
+ "Cannot reconstruct view state", e);
}
if (savedState == null)
{
return null;
}
-
- String restoredViewId = (String)savedState[VIEWID_PARAM];
+
+ String restoredViewId = (String) savedState[VIEWID_PARAM];
if (restoredViewId == null)
{
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseWriter.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseWriter.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseWriter.java Sat Aug 28 18:59:21 2010
@@ -27,17 +27,18 @@ import javax.faces.context.ResponseWrite
*
* @since 1.0.0
*/
-public class MockResponseWriter extends ResponseWriter {
-
+public class MockResponseWriter extends ResponseWriter
+{
// ------------------------------------------------------------ Constructors
- public MockResponseWriter(Writer writer) {
+ public MockResponseWriter(Writer writer)
+ {
this.writer = writer;
this.contentType = "text/html";
this.characterEncoding = "UTF-8";
}
-
+
/**
* <p>Construct an instance wrapping the specified writer.</p>
*
@@ -45,56 +46,57 @@ public class MockResponseWriter extends
* @param contentType Content type to be created
* @param characterEncoding Character encoding of this response
*/
- public MockResponseWriter(Writer writer, String contentType, String characterEncoding) {
+ public MockResponseWriter(Writer writer, String contentType,
+ String characterEncoding)
+ {
this.writer = writer;
this.contentType = contentType;
this.characterEncoding = characterEncoding;
}
-
// ------------------------------------------------------ Instance Variables
-
private String characterEncoding = null;
private String contentType = "text/html";
private boolean open = false; // Is an element currently open?
private UIComponent component;
private Writer writer = null;
-
// ----------------------------------------------------- Mock Object Methods
-
/**
* <p>Return the <code>Writer</code> that we are wrapping.</p>
*/
- public Writer getWriter() {
+ public Writer getWriter()
+ {
return this.writer;
}
-
// -------------------------------------------------- ResponseWriter Methods
-
/** {@inheritDoc} */
- public ResponseWriter cloneWithWriter(Writer writer) {
+ public ResponseWriter cloneWithWriter(Writer writer)
+ {
return new MockResponseWriter(writer, contentType, characterEncoding);
}
-
/** {@inheritDoc} */
- public void endDocument() throws IOException {
+ public void endDocument() throws IOException
+ {
finish();
writer.flush();
}
-
/** {@inheritDoc} */
- public void endElement(String name) throws IOException {
- if (open) {
+ public void endElement(String name) throws IOException
+ {
+ if (open)
+ {
writer.write("/");
finish();
- } else {
+ }
+ else
+ {
writer.write("</");
writer.write(name);
writer.write(">");
@@ -102,34 +104,36 @@ public class MockResponseWriter extends
component = null;
}
-
/** {@inheritDoc} */
- public String getCharacterEncoding() {
+ public String getCharacterEncoding()
+ {
return this.characterEncoding;
}
-
/** {@inheritDoc} */
- public String getContentType() {
+ public String getContentType()
+ {
return this.contentType;
}
-
/** {@inheritDoc} */
- public void flush() throws IOException {
+ public void flush() throws IOException
+ {
finish();
}
-
/** {@inheritDoc} */
- public void startDocument() throws IOException {
+ public void startDocument() throws IOException
+ {
// Do nothing
}
-
/** {@inheritDoc} */
- public void startElement(String name, UIComponent component) throws IOException {
- if (name == null) {
+ public void startElement(String name, UIComponent component)
+ throws IOException
+ {
+ if (name == null)
+ {
throw new NullPointerException();
}
finish();
@@ -139,110 +143,124 @@ public class MockResponseWriter extends
this.component = component;
}
-
/** {@inheritDoc} */
- public void writeAttribute(String name, Object value, String property) throws IOException {
- if (name == null) {
+ public void writeAttribute(String name, Object value, String property)
+ throws IOException
+ {
+ if (name == null)
+ {
throw new NullPointerException();
}
- if (!open) {
+ if (!open)
+ {
throw new IllegalStateException();
}
String attribute = findValue(value, property);
- if (attribute != null) {
- writer.write(" ");
- writer.write(name);
- writer.write("=\"");
- string(attribute);
+ if (attribute != null)
+ {
+ writer.write(" ");
+ writer.write(name);
+ writer.write("=\"");
+ string(attribute);
- writer.write("\"");
+ writer.write("\"");
}
}
-
/** {@inheritDoc} */
- public void writeComment(Object comment) throws IOException {
- if (comment == null) {
+ public void writeComment(Object comment) throws IOException
+ {
+ if (comment == null)
+ {
throw new NullPointerException();
}
finish();
writer.write("<!-- ");
- if (comment instanceof String) {
+ if (comment instanceof String)
+ {
writer.write((String) comment);
- } else {
+ }
+ else
+ {
writer.write(comment.toString());
}
writer.write(" -->");
}
-
/** {@inheritDoc} */
- public void writeText(Object text, String property) throws IOException {
- if (text == null) {
+ public void writeText(Object text, String property) throws IOException
+ {
+ if (text == null)
+ {
throw new NullPointerException();
}
finish();
String value = findValue(text, property);
- if (value != null) {
- string(value);
+ if (value != null)
+ {
+ string(value);
}
}
-
/** {@inheritDoc} */
- public void writeText(char[] text, int off, int len) throws IOException {
- if (text == null) {
+ public void writeText(char[] text, int off, int len) throws IOException
+ {
+ if (text == null)
+ {
throw new NullPointerException();
}
- if ((off < 0) || (off > text.length) || (len < 0) || (len > text.length)) {
+ if ((off < 0) || (off > text.length) || (len < 0)
+ || (len > text.length))
+ {
throw new IndexOutOfBoundsException();
}
finish();
string(text, off, len);
}
-
/** {@inheritDoc} */
- public void writeURIAttribute(String name, Object value, String property) throws IOException {
- if (name == null) {
+ public void writeURIAttribute(String name, Object value, String property)
+ throws IOException
+ {
+ if (name == null)
+ {
throw new NullPointerException();
}
- if (!open) {
+ if (!open)
+ {
throw new IllegalStateException();
}
String attribute = findValue(value, property);
- if (attribute != null) {
- writer.write(" ");
- writer.write(name);
- writer.write("=\"");
+ if (attribute != null)
+ {
+ writer.write(" ");
+ writer.write(name);
+ writer.write("=\"");
- string(attribute);
- writer.write("\"");
+ string(attribute);
+ writer.write("\"");
}
}
-
// ---------------------------------------------------------- Writer Methods
-
/** {@inheritDoc} */
- public void close() throws IOException {
+ public void close() throws IOException
+ {
finish();
writer.close();
}
-
/** {@inheritDoc} */
- public void write(char[] cbuf, int off, int len) throws IOException {
+ public void write(char[] cbuf, int off, int len) throws IOException
+ {
finish();
writer.write(cbuf, off, len);
}
-
// --------------------------------------------------------- Support Methods
-
/**
* <p>Write the specified character, filtering if necessary.</p>
*
@@ -250,50 +268,68 @@ public class MockResponseWriter extends
*
* @exception IOException if an input/output error occurs
*/
- private void character(char ch) throws IOException {
+ private void character(char ch) throws IOException
+ {
- if (ch <= 0xff) {
+ if (ch <= 0xff)
+ {
// In single byte characters, replace only the five
// characters for which well-known entities exist in XML
- if (ch == 0x22) {
+ if (ch == 0x22)
+ {
writer.write(""");
- } else if (ch == 0x26) {
+ }
+ else if (ch == 0x26)
+ {
writer.write("&");
- } else if (ch == 0x27) {
+ }
+ else if (ch == 0x27)
+ {
writer.write("'");
- } else if (ch == 0x3C) {
+ }
+ else if (ch == 0x3C)
+ {
writer.write("<");
- } else if (ch == 0X3E) {
+ }
+ else if (ch == 0X3E)
+ {
writer.write(">");
- } else {
+ }
+ else
+ {
writer.write(ch);
}
- } else {
- if (substitution()) {
+ }
+ else
+ {
+ if (substitution())
+ {
numeric(writer, ch);
- } else {
+ }
+ else
+ {
writer.write(ch);
}
}
}
-
/**
* <p>Close any element that is currently open.</p>
*
* @exception IOException if an input/output error occurs
*/
- private void finish() throws IOException {
+ private void finish() throws IOException
+ {
- if (open) {
+ if (open)
+ {
writer.write(">");
open = false;
}
}
-
/**
* <p>Write a numeric character reference for specified character
* to the specfied writer.</p>
@@ -303,7 +339,8 @@ public class MockResponseWriter extends
*
* @exception IOException if an input/output error occurs
*/
- private void numeric(Writer writer, char ch) throws IOException {
+ private void numeric(Writer writer, char ch) throws IOException
+ {
writer.write("&#");
writer.write(String.valueOf(ch));
@@ -311,7 +348,6 @@ public class MockResponseWriter extends
}
-
/**
* <p>Write the specified characters (after performing suitable
* replacement of characters by corresponding entities).</p>
@@ -322,16 +358,17 @@ public class MockResponseWriter extends
*
* @exception IOException if an input/output error occurs
*/
- private void string(char[] text, int off, int len) throws IOException {
+ private void string(char[] text, int off, int len) throws IOException
+ {
// Process the specified characters
- for (int i = off; i < (off + len); i++) {
+ for (int i = off; i < (off + len); i++)
+ {
character(text[i]);
}
}
-
/**
* <p>Write the specified string (after performing suitable
* replacement of characters by corresponding entities).</p>
@@ -340,33 +377,45 @@ public class MockResponseWriter extends
*
* @exception IOException if an input/output error occurs
*/
- private void string(String s) throws IOException {
- for (int i = 0; i < s.length(); i++) {
+ private void string(String s) throws IOException
+ {
+ for (int i = 0; i < s.length(); i++)
+ {
character(s.charAt(i));
}
}
-
/**
* <p>Return true if entity substitution should be performed on double
* byte character values.</p>
*/
- private boolean substitution() {
+ private boolean substitution()
+ {
- return !("UTF-8".equals(characterEncoding) || "UTF-16".equals(characterEncoding));
+ return !("UTF-8".equals(characterEncoding) || "UTF-16"
+ .equals(characterEncoding));
}
- private String findValue(final Object value, final String property) {
- if (value != null) {
+ private String findValue(final Object value, final String property)
+ {
+ if (value != null)
+ {
return value instanceof String ? (String) value : value.toString();
- } else if (property != null) {
- if (component != null) {
+ }
+ else if (property != null)
+ {
+ if (component != null)
+ {
final Object object = component.getAttributes().get(property);
- if (object != null) {
- return object instanceof String ? (String) object : object.toString();
- } else {
+ if (object != null)
+ {
+ return object instanceof String ? (String) object : object
+ .toString();
+ }
+ else
+ {
return null;
}
}
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockServlet.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockServlet.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockServlet.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockServlet.java Sat Aug 28 18:59:21 2010
@@ -32,92 +32,87 @@ import javax.servlet.ServletResponse;
* @since 1.0.0
*/
-public class MockServlet implements Servlet {
-
+public class MockServlet implements Servlet
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Create a default Servlet instance.</p>
*/
- public MockServlet() {
+ public MockServlet()
+ {
}
-
/**
* <p>Create a new Servlet with the specified ServletConfig.</p>
*
* @param config The new ServletConfig instance
*/
- public MockServlet(ServletConfig config) throws ServletException {
+ public MockServlet(ServletConfig config) throws ServletException
+ {
init(config);
}
-
// ----------------------------------------------------- Mock Object Methods
-
/**
* <p>Set the <code>ServletConfig</code> instance for this servlet.</p>
*
* @param config The new ServletConfig instance
*/
- public void setServletConfig(ServletConfig config) {
+ public void setServletConfig(ServletConfig config)
+ {
this.config = config;
}
-
// ------------------------------------------------------ Instance Variables
-
/**
* <p>The <code>ServletConfig</code> instance for this servlet.</p>
*/
private ServletConfig config;
-
// --------------------------------------------------------- Servlet Methods
-
/** {@inheritDoc} */
- public void destroy() {
+ public void destroy()
+ {
}
-
/** {@inheritDoc} */
- public ServletConfig getServletConfig() {
+ public ServletConfig getServletConfig()
+ {
return this.config;
}
-
/** {@inheritDoc} */
- public String getServletInfo() {
+ public String getServletInfo()
+ {
return "MockServlet";
}
-
/** {@inheritDoc} */
- public void init(ServletConfig config) throws ServletException {
+ public void init(ServletConfig config) throws ServletException
+ {
this.config = config;
}
-
/** {@inheritDoc} */
public void service(ServletRequest request, ServletResponse response)
- throws IOException, ServletException {
+ throws IOException, ServletException
+ {
// Do nothing by default
}
-
}
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockServletConfig.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockServletConfig.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockServletConfig.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockServletConfig.java Sat Aug 28 18:59:21 2010
@@ -30,98 +30,93 @@ import javax.servlet.ServletContext;
* @since 1.0.0
*/
-public class MockServletConfig implements ServletConfig {
-
+public class MockServletConfig implements ServletConfig
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Construct a default instance.</p>
*/
- public MockServletConfig() {
+ public MockServletConfig()
+ {
}
-
/**
* <p>Construct an instance associated with the specified
* servlet context.</p>
*
* @param context The associated ServletContext
*/
- public MockServletConfig(ServletContext context) {
+ public MockServletConfig(ServletContext context)
+ {
setServletContext(context);
}
-
// ----------------------------------------------------- Mock Object Methods
-
/**
* <p>Add a servlet initialization parameter.</p>
*
* @param name Parameter name
* @param value Parameter value
*/
- public void addInitParameter(String name, String value) {
+ public void addInitParameter(String name, String value)
+ {
parameters.put(name, value);
}
-
/**
* <p>Set the servlet context for this application.</p>
*
* @param context The new servlet context
*/
- public void setServletContext(ServletContext context) {
+ public void setServletContext(ServletContext context)
+ {
this.context = context;
}
-
// ------------------------------------------------------ Instance Variables
-
private ServletContext context;
private Hashtable parameters = new Hashtable();
-
// --------------------------------------------------- ServletConfig Methods
-
/** {@inheritDoc} */
- public String getInitParameter(String name) {
+ public String getInitParameter(String name)
+ {
return (String) parameters.get(name);
}
-
/** {@inheritDoc} */
- public Enumeration getInitParameterNames() {
+ public Enumeration getInitParameterNames()
+ {
return parameters.keys();
}
-
/** {@inheritDoc} */
- public ServletContext getServletContext() {
+ public ServletContext getServletContext()
+ {
return this.context;
}
-
/** {@inheritDoc} */
- public String getServletName() {
+ public String getServletName()
+ {
return "MockServlet";
}
-
}
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockServletOutputStream.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockServletOutputStream.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockServletOutputStream.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockServletOutputStream.java Sat Aug 28 18:59:21 2010
@@ -27,71 +27,65 @@ import javax.servlet.ServletOutputStream
* @since 1.0.0
*/
-public class MockServletOutputStream extends ServletOutputStream {
-
+public class MockServletOutputStream extends ServletOutputStream
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Return a default instance.</p>
*
* @param stream The stream we will use to buffer output
*/
- public MockServletOutputStream(ByteArrayOutputStream stream) {
+ public MockServletOutputStream(ByteArrayOutputStream stream)
+ {
this.baos = stream;
}
-
// ----------------------------------------------------- Mock Object Methods
-
/**
* <p>Return the content that has been written to this output stream.</p>
*/
- public byte[] content() {
+ public byte[] content()
+ {
return baos.toByteArray();
}
-
/**
* <p>Reset this output stream so that it appears no content has been
* written.</p>
*/
- public void reset() {
+ public void reset()
+ {
baos.reset();
}
-
/**
* <p>Return the number of bytes that have been written to this output stream.</p>
*/
- public int size() {
+ public int size()
+ {
return baos.size();
}
-
-
// ------------------------------------------------------ Instance Variables
-
/**
* <p>The internal buffer we use to capture output.</p>
*/
private ByteArrayOutputStream baos = null;
-
// --------------------------------------------- ServletOutputStream Methods
-
/**
* <p>Write the specified content to our internal cache.</p>
*
* @param content Content to be written
*/
- public void write(int content) {
+ public void write(int content)
+ {
baos.write(content);
}
-
}
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockStateManager.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockStateManager.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockStateManager.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockStateManager.java Sat Aug 28 18:59:21 2010
@@ -29,86 +29,82 @@ import javax.faces.context.FacesContext;
* $Id$
* @since 1.0.0
*/
-public class MockStateManager extends StateManager {
-
+public class MockStateManager extends StateManager
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Construct a default instance.</p>
*/
- public MockStateManager() {
+ public MockStateManager()
+ {
}
-
// ----------------------------------------------------- Mock Object Methods
-
// ------------------------------------------------------ Instance Variables
-
// ---------------------------------------------------- StateManager Methods
-
/** {@inheritDoc} */
- public SerializedView saveSerializedView(FacesContext context) {
+ public SerializedView saveSerializedView(FacesContext context)
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public Object getTreeStructureToSave(FacesContext context) {
+ public Object getTreeStructureToSave(FacesContext context)
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
- public Object getComponentStateToSave(FacesContext context) {
+ public Object getComponentStateToSave(FacesContext context)
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
public void writeState(FacesContext context, SerializedView view)
- throws IOException {
+ throws IOException
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
public UIViewRoot restoreView(FacesContext context, String viewId,
- String renderKitId) {
+ String renderKitId)
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
public UIViewRoot restoreTreeStructure(FacesContext context, String viewId,
- String renderKitId) {
+ String renderKitId)
+ {
throw new UnsupportedOperationException();
}
-
/** {@inheritDoc} */
public void restoreComponentState(FacesContext context, UIViewRoot view,
- String renderKitId) {
+ String renderKitId)
+ {
throw new UnsupportedOperationException();
}
-
}
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockValueBinding.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockValueBinding.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockValueBinding.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockValueBinding.java Sat Aug 28 18:59:21 2010
@@ -32,39 +32,40 @@ import javax.faces.el.ReferenceSyntaxExc
import javax.faces.el.ValueBinding;
import javax.faces.el.VariableResolver;
-
/**
* <p>Mock implementation of <code>ValueBinding</code>.</p>
*
* @since 1.0.0
*/
-public class MockValueBinding extends ValueBinding implements StateHolder {
-
+public class MockValueBinding extends ValueBinding implements StateHolder
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Construct a default instance.</p>
*/
- public MockValueBinding() {
+ public MockValueBinding()
+ {
this(null, null);
}
-
/**
* <p>Construct a new value binding for the specified expression.</p>
*
* @param application Application instance to be wrapped
* @param ref Expression to be wrapped
*/
- public MockValueBinding(Application application, String ref) {
+ public MockValueBinding(Application application, String ref)
+ {
this.application = application;
- if (ref != null) {
- if (ref.startsWith("#{") && ref.endsWith("}")) {
+ if (ref != null)
+ {
+ if (ref.startsWith("#{") && ref.endsWith("}"))
+ {
ref = ref.substring(2, ref.length() - 1);
}
}
@@ -72,43 +73,39 @@ public class MockValueBinding extends Va
}
-
// ----------------------------------------------------- Mock Object Methods
-
/**
* <p>Return the expression string for this value binding.</p>
*/
- public String ref() {
+ public String ref()
+ {
return this.ref;
}
-
// ------------------------------------------------------ Instance Variables
-
/**
* <p>The <code>Application</code> instance for this application.</p>
*/
private transient Application application; // Restored as necessary
-
/**
* <p>The expression this value binding will evaluate.</p>
*/
private String ref;
-
// ---------------------------------------------------- ValueBinding Methods
-
/** {@inheritDoc} */
- public Object getValue(FacesContext context)
- throws EvaluationException, PropertyNotFoundException {
+ public Object getValue(FacesContext context) throws EvaluationException,
+ PropertyNotFoundException
+ {
- if (context == null) {
+ if (context == null)
+ {
throw new NullPointerException();
}
List names = parse(ref);
@@ -117,13 +114,15 @@ public class MockValueBinding extends Va
VariableResolver vr = application().getVariableResolver();
String name = (String) names.get(0);
Object base = vr.resolveVariable(context, name);
- if (names.size() < 2) {
+ if (names.size() < 2)
+ {
return (base);
}
// Resolve the property names
PropertyResolver pr = application().getPropertyResolver();
- for (int i = 1; i < names.size(); i++) {
+ for (int i = 1; i < names.size(); i++)
+ {
base = pr.getValue(base, (String) names.get(i));
}
@@ -132,12 +131,13 @@ public class MockValueBinding extends Va
}
-
/** {@inheritDoc} */
public void setValue(FacesContext context, Object value)
- throws EvaluationException, PropertyNotFoundException {
+ throws EvaluationException, PropertyNotFoundException
+ {
- if (context == null) {
+ if (context == null)
+ {
throw new NullPointerException();
}
List names = parse(ref);
@@ -146,25 +146,28 @@ public class MockValueBinding extends Va
VariableResolver vr = application().getVariableResolver();
String name = (String) names.get(0);
Object base = vr.resolveVariable(context, name);
- if (names.size() < 2) {
- if ("applicationScope".equals(name)
- || "requestScope".equals(name)
- || "sessionScope".equals(name)) {
- throw new ReferenceSyntaxException("Cannot set '"
- + name + "'");
+ if (names.size() < 2)
+ {
+ if ("applicationScope".equals(name) || "requestScope".equals(name)
+ || "sessionScope".equals(name))
+ {
+ throw new ReferenceSyntaxException("Cannot set '" + name + "'");
}
Map map = econtext().getRequestMap();
- if (map.containsKey(name)) {
+ if (map.containsKey(name))
+ {
map.put(name, value);
return;
}
map = econtext().getSessionMap();
- if ((map != null) && (map.containsKey(name))) {
+ if ((map != null) && (map.containsKey(name)))
+ {
map.put(name, value);
return;
}
map = econtext().getApplicationMap();
- if (map.containsKey(name)) {
+ if (map.containsKey(name))
+ {
map.put(name, value);
return;
}
@@ -174,7 +177,8 @@ public class MockValueBinding extends Va
// Resolve the property names
PropertyResolver pr = application().getPropertyResolver();
- for (int i = 1; i < (names.size() - 1); i++) {
+ for (int i = 1; i < (names.size() - 1); i++)
+ {
// System.out.println(" property=" + names.get(i));
base = pr.getValue(base, (String) names.get(i));
}
@@ -184,12 +188,13 @@ public class MockValueBinding extends Va
}
-
/** {@inheritDoc} */
public boolean isReadOnly(FacesContext context)
- throws PropertyNotFoundException {
+ throws PropertyNotFoundException
+ {
- if (context == null) {
+ if (context == null)
+ {
throw new NullPointerException();
}
List names = parse(ref);
@@ -198,13 +203,15 @@ public class MockValueBinding extends Va
VariableResolver vr = application().getVariableResolver();
String name = (String) names.get(0);
Object base = vr.resolveVariable(context, name);
- if (names.size() < 2) {
+ if (names.size() < 2)
+ {
return true;
}
// Resolve the property names
PropertyResolver pr = application().getPropertyResolver();
- for (int i = 1; i < names.size() - 1; i++) {
+ for (int i = 1; i < names.size() - 1; i++)
+ {
base = pr.getValue(base, (String) names.get(i));
}
@@ -213,12 +220,12 @@ public class MockValueBinding extends Va
}
-
/** {@inheritDoc} */
- public Class getType(FacesContext context)
- throws PropertyNotFoundException {
+ public Class getType(FacesContext context) throws PropertyNotFoundException
+ {
- if (context == null) {
+ if (context == null)
+ {
throw new NullPointerException();
}
List names = parse(ref);
@@ -227,13 +234,15 @@ public class MockValueBinding extends Va
VariableResolver vr = application().getVariableResolver();
String name = (String) names.get(0);
Object base = vr.resolveVariable(context, name);
- if (names.size() < 2) {
+ if (names.size() < 2)
+ {
return base.getClass();
}
// Resolve the property names
PropertyResolver pr = application().getPropertyResolver();
- for (int i = 1; i < names.size() - 1; i++) {
+ for (int i = 1; i < names.size() - 1; i++)
+ {
base = pr.getValue(base, (String) names.get(i));
}
@@ -243,18 +252,18 @@ public class MockValueBinding extends Va
}
/** {@inheritDoc} */
- public String getExpressionString() {
+ public String getExpressionString()
+ {
return "#{" + ref + "}";
}
-
// ----------------------------------------------------- StateHolder Methods
-
/** {@inheritDoc} */
- public Object saveState(FacesContext context) {
+ public Object saveState(FacesContext context)
+ {
Object[] values = new Object[1];
values[0] = ref;
@@ -262,113 +271,127 @@ public class MockValueBinding extends Va
}
-
/** {@inheritDoc} */
- public void restoreState(FacesContext context, Object state) {
+ public void restoreState(FacesContext context, Object state)
+ {
Object[] values = (Object[]) state;
ref = (String) values[0];
}
-
/**
* <p>Flag indicating that this value is transient.</p>
*/
private boolean transientFlag = false;
-
/** {@inheritDoc} */
- public boolean isTransient() {
+ public boolean isTransient()
+ {
return this.transientFlag;
}
-
/** {@inheritDoc} */
- public void setTransient(boolean transientFlag) {
+ public void setTransient(boolean transientFlag)
+ {
this.transientFlag = transientFlag;
}
-
// --------------------------------------------------------- Private Methods
-
/**
* <p>Return the relevant <code>Application</code> instance.</p>
*/
- private Application application() {
+ private Application application()
+ {
- if (application == null) {
+ if (application == null)
+ {
application = FacesContext.getCurrentInstance().getApplication();
}
return (application);
}
-
/**
* <p>Return the relevant <code>ExternalContext</code> instance.</p>
*/
- private ExternalContext econtext() {
+ private ExternalContext econtext()
+ {
return (FacesContext.getCurrentInstance().getExternalContext());
}
-
/**
* <p>Return a list of the expression elements in this expression.</p>
*
* @param ref Expression to be parsed
*/
- private List parse(String ref) {
+ private List parse(String ref)
+ {
List names = new ArrayList();
StringBuffer expr = new StringBuffer(ref);
boolean isBlockOn = false;
- for (int i = expr.length() - 1; i > -1; i--) {
- if (expr.charAt(i) == ' ') {
+ for (int i = expr.length() - 1; i > -1; i--)
+ {
+ if (expr.charAt(i) == ' ')
+ {
expr.deleteCharAt(i);
- } else if (expr.charAt(i) == ']') {
+ }
+ else if (expr.charAt(i) == ']')
+ {
expr.deleteCharAt(i);
- } else if (expr.charAt(i) == '[') {
+ }
+ else if (expr.charAt(i) == '[')
+ {
expr.deleteCharAt(i);
- } else if (expr.charAt(i) == '\'') {
- if (!isBlockOn) {
+ }
+ else if (expr.charAt(i) == '\'')
+ {
+ if (!isBlockOn)
+ {
expr.deleteCharAt(i);
- } else {
+ }
+ else
+ {
names.add(0, expr.substring(i + 1));
expr.delete(i, expr.length());
}
isBlockOn = !isBlockOn;
- } else if (expr.charAt(i) == '.' && !isBlockOn) {
+ }
+ else if (expr.charAt(i) == '.' && !isBlockOn)
+ {
names.add(0, expr.substring(i + 1));
expr.delete(i, expr.length());
}
}
- if (expr.length() > 0) {
+ if (expr.length() > 0)
+ {
names.add(0, expr.toString());
}
- if (names.size() < 1) {
- throw new ReferenceSyntaxException("No expression in '"
- + ref + "'");
+ if (names.size() < 1)
+ {
+ throw new ReferenceSyntaxException("No expression in '" + ref + "'");
}
- for (int i = 0; i < names.size(); i++) {
+ for (int i = 0; i < names.size(); i++)
+ {
String name = (String) names.get(i);
- if (name.length() < 1) {
- throw new ReferenceSyntaxException("Invalid expression '"
- + ref + "'");
+ if (name.length() < 1)
+ {
+ throw new ReferenceSyntaxException("Invalid expression '" + ref
+ + "'");
}
}
return (names);
}
-
}
Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockVariableResolver.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockVariableResolver.java?rev=990408&r1=990407&r2=990408&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockVariableResolver.java (original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockVariableResolver.java Sat Aug 28 18:59:21 2010
@@ -36,78 +36,106 @@ import javax.faces.el.VariableResolver;
* @since 1.0.0
*/
-public class MockVariableResolver extends VariableResolver {
-
+public class MockVariableResolver extends VariableResolver
+{
// ------------------------------------------------------------ Constructors
-
/**
* <p>Construct a default instance.</p>
*/
- public MockVariableResolver() {
+ public MockVariableResolver()
+ {
}
-
// ----------------------------------------------------- Mock Object Methods
-
// ------------------------------------------------------ Instance Variables
-
// ------------------------------------------------ VariableResolver Methods
-
/** {@inheritDoc} */
- public Object resolveVariable(FacesContext context, String name) {
+ public Object resolveVariable(FacesContext context, String name)
+ {
- if ((context == null) || (name == null)) {
+ if ((context == null) || (name == null))
+ {
throw new NullPointerException();
}
// Check for magic names
- if ("application".equals(name)) {
+ if ("application".equals(name))
+ {
return external().getContext();
- } else if ("applicationScope".equals(name)) {
+ }
+ else if ("applicationScope".equals(name))
+ {
return external().getApplicationMap();
- } else if ("cookie".equals(name)) {
+ }
+ else if ("cookie".equals(name))
+ {
return external().getRequestCookieMap();
- } else if ("facesContext".equals(name)) {
+ }
+ else if ("facesContext".equals(name))
+ {
return FacesContext.getCurrentInstance();
- } else if ("header".equals(name)) {
+ }
+ else if ("header".equals(name))
+ {
return external().getRequestHeaderMap();
- } else if ("headerValues".equals(name)) {
+ }
+ else if ("headerValues".equals(name))
+ {
return external().getRequestHeaderValuesMap();
- } else if ("param".equals(name)) {
+ }
+ else if ("param".equals(name))
+ {
return external().getRequestParameterMap();
- } else if ("paramValues".equals(name)) {
+ }
+ else if ("paramValues".equals(name))
+ {
return external().getRequestParameterValuesMap();
- } else if ("request".equals(name)) {
+ }
+ else if ("request".equals(name))
+ {
return external().getRequest();
- } else if ("requestScope".equals(name)) {
+ }
+ else if ("requestScope".equals(name))
+ {
return external().getRequestMap();
- } else if ("response".equals(name)) {
+ }
+ else if ("response".equals(name))
+ {
return external().getResponse();
- } else if ("session".equals(name)) {
+ }
+ else if ("session".equals(name))
+ {
return external().getSession(true);
- } else if ("sessionScope".equals(name)) {
+ }
+ else if ("sessionScope".equals(name))
+ {
return external().getSessionMap();
- } else if ("view".equals(name)) {
+ }
+ else if ("view".equals(name))
+ {
return FacesContext.getCurrentInstance().getViewRoot();
}
// Search ascending scopes for non-magic names
Map map = null;
map = external().getRequestMap();
- if (map.containsKey(name)) {
+ if (map.containsKey(name))
+ {
return map.get(name);
}
map = external().getSessionMap();
- if ((map != null) && (map.containsKey(name))) {
+ if ((map != null) && (map.containsKey(name)))
+ {
return map.get(name);
}
map = external().getApplicationMap();
- if (map.containsKey(name)) {
+ if (map.containsKey(name))
+ {
return map.get(name);
}
@@ -116,19 +144,16 @@ public class MockVariableResolver extend
}
-
-
// --------------------------------------------------------- Private Methods
-
/**
* <p>Return the <code>ExternalContext</code> for this request.</p>
*/
- private ExternalContext external() {
+ private ExternalContext external()
+ {
return FacesContext.getCurrentInstance().getExternalContext();
}
-
}