Seam SVN: r10695 - in modules/trunk/international/src/main/resources: META-INF and 1 other directory.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-29 01:55:00 -0400 (Wed, 29 Apr 2009)
New Revision: 10695
Added:
modules/trunk/international/src/main/resources/META-INF/
modules/trunk/international/src/main/resources/META-INF/beans.xml
Log:
add beans.xml
Added: modules/trunk/international/src/main/resources/META-INF/beans.xml
===================================================================
15 years, 10 months
Seam SVN: r10694 - modules/trunk/el/src/main/java/org/jboss/seam/el.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-29 01:54:37 -0400 (Wed, 29 Apr 2009)
New Revision: 10694
Modified:
modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java
Log:
formatting
Modified: modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java 2009-04-29 05:54:22 UTC (rev 10693)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/…
[View More]Expressions.java 2009-04-29 05:54:37 UTC (rev 10694)
@@ -36,8 +36,9 @@
*
* @author Gavin King
*/
+public
@ApplicationScoped
-public class Expressions implements Serializable
+class Expressions implements Serializable
{
private static final long serialVersionUID = 7420955152664486125L;
[View Less]
15 years, 10 months
Seam SVN: r10693 - modules/trunk/el/src/test/resources.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-29 01:54:22 -0400 (Wed, 29 Apr 2009)
New Revision: 10693
Modified:
modules/trunk/el/src/test/resources/test-suite.xml
Log:
rename test suite for consistency
Modified: modules/trunk/el/src/test/resources/test-suite.xml
===================================================================
--- modules/trunk/el/src/test/resources/test-suite.xml 2009-04-29 05:54:07 UTC (rev 10692)
+++ modules/trunk/el/src/test/resources/test-suite.xml 2009-04-29 05:54:22 UTC (…
[View More]rev 10693)
@@ -1,6 +1,6 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="Seam EL Module Unit Tests" verbose="1">
- <test name="Seam EL Module Unit Tests">
+<suite name="Seam EL Module Test Suite" verbose="1">
+ <test name="Seam EL Module - Unit Tests">
<!--
<method-selectors>
<method-selector>
[View Less]
15 years, 10 months
Seam SVN: r10692 - in modules/trunk/el/src/main: resources and 1 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-29 01:54:07 -0400 (Wed, 29 Apr 2009)
New Revision: 10692
Added:
modules/trunk/el/src/main/resources/
modules/trunk/el/src/main/resources/META-INF/
modules/trunk/el/src/main/resources/META-INF/beans.xml
Log:
add beans.xml
Added: modules/trunk/el/src/main/resources/META-INF/beans.xml
===================================================================
15 years, 10 months
Seam SVN: r10691 - in modules/trunk: mock and 10 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-29 01:52:55 -0400 (Wed, 29 Apr 2009)
New Revision: 10691
Added:
modules/trunk/mock/
modules/trunk/mock/pom.xml
modules/trunk/mock/src/
modules/trunk/mock/src/main/
modules/trunk/mock/src/main/java/
modules/trunk/mock/src/main/java/org/
modules/trunk/mock/src/main/java/org/jboss/
modules/trunk/mock/src/main/java/org/jboss/seam/
modules/trunk/mock/src/main/java/org/jboss/seam/mock/
modules/trunk/mock/src/main/java/org/jboss/seam/…
[View More]mock/faces/
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockApplication.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockApplicationFactory.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockExternalContext.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockFacesContext.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockFacesContextFactory.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockLifecycle.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockLifecycleFactory.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockNavigationHandler.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockRenderKit.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockResponseStateManager.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockResponseWriter.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockStateManager.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockViewHandler.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/
modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockHttpServletRequest.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockHttpServletResponse.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockHttpSession.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockServletContext.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/util/
modules/trunk/mock/src/main/java/org/jboss/seam/mock/util/EnumerationIterator.java
modules/trunk/mock/src/main/java/org/jboss/seam/mock/util/IteratorEnumeration.java
modules/trunk/mock/src/main/resources/
Log:
mock module
Property changes on: modules/trunk/mock
___________________________________________________________________
Name: svn:ignore
+ target
Added: modules/trunk/mock/pom.xml
===================================================================
--- modules/trunk/mock/pom.xml (rev 0)
+++ modules/trunk/mock/pom.xml 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,39 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>seam-parent</artifactId>
+ <groupId>org.jboss.seam</groupId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>seam-mock</artifactId>
+ <packaging>jar</packaging>
+ <version>3.0.0-SNAPSHOT</version>
+ <name>Seam Mock Objects Module</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockApplication.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockApplication.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockApplication.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,421 @@
+package org.jboss.seam.mock.faces;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.el.CompositeELResolver;
+import javax.el.ExpressionFactory;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
+import javax.faces.application.NavigationHandler;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.BigDecimalConverter;
+import javax.faces.convert.BigIntegerConverter;
+import javax.faces.convert.BooleanConverter;
+import javax.faces.convert.ByteConverter;
+import javax.faces.convert.CharacterConverter;
+import javax.faces.convert.Converter;
+import javax.faces.convert.DoubleConverter;
+import javax.faces.convert.FloatConverter;
+import javax.faces.convert.IntegerConverter;
+import javax.faces.convert.LongConverter;
+import javax.faces.convert.ShortConverter;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.PropertyResolver;
+import javax.faces.el.ReferenceSyntaxException;
+import javax.faces.el.ValueBinding;
+import javax.faces.el.VariableResolver;
+import javax.faces.event.ActionListener;
+import javax.faces.validator.Validator;
+
+@SuppressWarnings("deprecation")
+public class MockApplication extends Application
+{
+
+ private javax.el.CompositeELResolver elResolver;
+ private javax.el.CompositeELResolver additionalResolvers;
+ private Collection locales;
+
+ public MockApplication()
+ {
+ elResolver = new CompositeELResolver();
+ additionalResolvers = new CompositeELResolver();
+ elResolver.add(additionalResolvers);
+ //elResolver.add(EL.EL_RESOLVER);
+ }
+
+ @Override
+ public Object evaluateExpressionGet(FacesContext context, String expression, Class type) throws javax.el.ELException
+ {
+ return getExpressionFactory().createValueExpression(context.getELContext(), expression, type).getValue(context.getELContext());
+ }
+
+ @Override
+ public void addELContextListener(javax.el.ELContextListener elcl)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void addELResolver(javax.el.ELResolver r)
+ {
+ additionalResolvers.add(r);
+ }
+
+ @Override
+ public UIComponent createComponent(javax.el.ValueExpression ve, FacesContext context, String id) throws FacesException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public javax.el.ELContextListener[] getELContextListeners()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public javax.el.ELResolver getELResolver()
+ {
+ return elResolver;
+ }
+
+ @Override
+ public java.util.ResourceBundle getResourceBundle(FacesContext context, String string)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeELContextListener(javax.el.ELContextListener elcl)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ActionListener getActionListener()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setActionListener(ActionListener listener)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private Locale defaultLocale = Locale.ENGLISH;
+
+ @Override
+ public Locale getDefaultLocale()
+ {
+ return defaultLocale;
+ }
+
+ @Override
+ public void setDefaultLocale(Locale locale)
+ {
+ defaultLocale = locale;
+ }
+
+ @Override
+ public String getDefaultRenderKitId()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setDefaultRenderKitId(String rk)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private String msgBundleName;
+
+ @Override
+ public String getMessageBundle()
+ {
+ return msgBundleName;
+ }
+
+ @Override
+ public void setMessageBundle(String bundleName)
+ {
+ this.msgBundleName = bundleName;
+ }
+
+ private NavigationHandler navigationHandler = null; //new SeamNavigationHandler( new MockNavigationHandler() );
+
+ @Override
+ public NavigationHandler getNavigationHandler()
+ {
+ return navigationHandler;
+ }
+
+ @Override
+ public void setNavigationHandler(NavigationHandler navigationHandler)
+ {
+ this.navigationHandler = navigationHandler;
+ }
+
+ @Override
+ public PropertyResolver getPropertyResolver()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setPropertyResolver(PropertyResolver pr)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private VariableResolver variableResolver = /*new SeamVariableResolver(*/ new VariableResolver() {
+ @Override
+ public Object resolveVariable(FacesContext ctx, String name) throws EvaluationException
+ {
+ return null;
+ }
+ } /*)*/;
+
+ @Override
+ public VariableResolver getVariableResolver()
+ {
+ return variableResolver;
+ }
+
+ @Override
+ public void setVariableResolver(VariableResolver variableResolver)
+ {
+ this.variableResolver = variableResolver;
+ }
+
+ private ViewHandler viewHandler = null; //new SeamViewHandler( new MockViewHandler() );
+
+ @Override
+ public ViewHandler getViewHandler()
+ {
+ return viewHandler;
+ }
+
+ @Override
+ public void setViewHandler(ViewHandler viewHandler)
+ {
+ this.viewHandler = viewHandler;
+ }
+
+ private StateManager stateManager = null; //new SeamStateManager( new MockStateManager() );
+
+ @Override
+ public StateManager getStateManager()
+ {
+ return stateManager;
+ }
+
+ @Override
+ public void setStateManager(StateManager stateManager)
+ {
+ this.stateManager = stateManager;
+ }
+
+ @Override
+ public void addComponent(String name, String x)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public UIComponent createComponent(String name) throws FacesException
+ {
+ // Best guess component creation with a dummy component if it can't be found
+ if (name.startsWith("org.jboss.seam.mail.ui") || name.startsWith("org.jboss.seam.excel.ui"))
+ {
+ try
+ {
+ return (UIComponent) Class.forName(name).newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new UnsupportedOperationException("Unable to create component " + name);
+ }
+ }
+ else
+ {
+ // Oh well, can't simply create the component so put a dummy one in its place
+ return new UIOutput();
+ }
+ }
+
+ @Override
+ public UIComponent createComponent(ValueBinding vb, FacesContext fc, String x)
+ throws FacesException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Iterator getComponentTypes()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private final Map<Class, Converter> converters = new HashMap<Class, Converter>();
+ {
+ converters.put(Integer.class, new IntegerConverter());
+ converters.put(Long.class, new LongConverter());
+ converters.put(Float.class, new FloatConverter());
+ converters.put(Double.class, new DoubleConverter());
+ converters.put(Boolean.class, new BooleanConverter());
+ converters.put(Short.class, new ShortConverter());
+ converters.put(Byte.class, new ByteConverter());
+ converters.put(Character.class, new CharacterConverter());
+ converters.put(BigDecimal.class, new BigDecimalConverter());
+ converters.put(BigInteger.class, new BigIntegerConverter());
+ }
+
+ private final Map<String, Converter> convertersById = new HashMap<String, Converter>();
+ {
+ convertersById.put(IntegerConverter.CONVERTER_ID, new IntegerConverter());
+ convertersById.put(LongConverter.CONVERTER_ID, new LongConverter());
+ convertersById.put(FloatConverter.CONVERTER_ID, new FloatConverter());
+ convertersById.put(DoubleConverter.CONVERTER_ID, new DoubleConverter());
+ convertersById.put(BooleanConverter.CONVERTER_ID, new BooleanConverter());
+ convertersById.put(ShortConverter.CONVERTER_ID, new ShortConverter());
+ convertersById.put(ByteConverter.CONVERTER_ID, new ByteConverter());
+ convertersById.put(CharacterConverter.CONVERTER_ID, new CharacterConverter());
+ convertersById.put(BigDecimalConverter.CONVERTER_ID, new BigDecimalConverter());
+ convertersById.put(BigIntegerConverter.CONVERTER_ID, new BigIntegerConverter());
+ }
+
+ @Override
+ public void addConverter(String id, String converterClass)
+ {
+ convertersById.put(id, instantiateConverter(converterClass));
+ }
+
+ @Override
+ public void addConverter(Class type, String converterClass)
+ {
+ converters.put(type, instantiateConverter(converterClass));
+ }
+
+ private Converter instantiateConverter(String converterClass)
+ {
+ try
+ {
+ return (Converter) Class.forName(converterClass).newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public Converter createConverter(String id)
+ {
+ return convertersById.get(id);
+ }
+
+ @Override
+ public Converter createConverter(Class clazz)
+ {
+ return converters.get(clazz);
+ }
+
+ @Override
+ public Iterator getConverterIds()
+ {
+ return convertersById.keySet().iterator();
+ }
+
+ @Override
+ public Iterator getConverterTypes()
+ {
+ return converters.keySet().iterator();
+ }
+
+ @Override
+ public MethodBinding createMethodBinding(String expression, Class[] params)
+ throws ReferenceSyntaxException
+ {
+ return null; //new UnifiedELMethodBinding(expression, params);
+
+ }
+
+ @Override
+ public ValueBinding createValueBinding(String expression)
+ throws ReferenceSyntaxException
+ {
+ return null; //new UnifiedELValueBinding(expression);
+ }
+
+ @Override
+ public Iterator getSupportedLocales()
+ {
+ if (locales == null)
+ {
+ return Collections.singleton(defaultLocale).iterator();
+ }
+ else
+ {
+ return locales.iterator();
+ }
+ }
+
+ @Override
+ public void setSupportedLocales(Collection locales)
+ {
+ this.locales = locales;
+ }
+
+ private final Map<String, Validator> validatorsById = new HashMap<String, Validator>();
+
+ @Override
+ public void addValidator(String id, String validatorClass)
+ {
+ validatorsById.put(id, instantiateValidator(validatorClass));
+ }
+
+ private Validator instantiateValidator(String validatorClass)
+ {
+ try
+ {
+ return (Validator) Class.forName(validatorClass).newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public Validator createValidator(String id) throws FacesException
+ {
+ return validatorsById.get(id);
+ }
+
+ @Override
+ public Iterator getValidatorIds()
+ {
+ return validatorsById.keySet().iterator();
+ }
+
+ @Override
+ public ExpressionFactory getExpressionFactory()
+ {
+ return null; //SeamExpressionFactory.INSTANCE;
+ }
+
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockApplicationFactory.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockApplicationFactory.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockApplicationFactory.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,40 @@
+package org.jboss.seam.mock.faces;
+
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+
+/**
+ * An mock implementation of the JSF ApplicationFactory which returns a mock
+ * Application wrapped in a SeamApplication. This class can be registered with
+ * JSF to allow JSF to be used formally in a test environment as follows:
+ *
+ * <code>
+ * FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
+ * "org.jboss.seam.mock.faces.MockApplicationFactory");
+ * Application application = ((ApplicationFactory) FactoryFinder
+ * .getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
+ * </code>
+ *
+ * @author Dan Allen
+ */
+public class MockApplicationFactory extends ApplicationFactory
+{
+ private Application application;
+
+ @Override
+ public Application getApplication()
+ {
+// if (application == null)
+// {
+// application = new SeamApplication();
+// }
+ return application;
+ }
+
+ @Override
+ public void setApplication(Application application)
+ {
+ this.application = application;
+ }
+
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockExternalContext.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockExternalContext.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockExternalContext.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,560 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.seam.mock.faces;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.Principal;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.ServletContext;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.jboss.seam.mock.servlet.MockHttpServletRequest;
+import org.jboss.seam.mock.servlet.MockHttpServletResponse;
+import org.jboss.seam.mock.servlet.MockHttpSession;
+import org.jboss.seam.mock.servlet.MockServletContext;
+import org.jboss.seam.mock.util.EnumerationIterator;
+
+/**
+ * @author Gavin King
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 9684 $
+ */
+public class MockExternalContext extends ExternalContext
+{
+ private ServletContext context;
+
+ private HttpServletRequest request;
+
+ private HttpServletResponse response;
+
+ public MockExternalContext()
+ {
+ this.context = new MockServletContext();
+ this.request = new MockHttpServletRequest(new MockHttpSession(context));
+ this.response = new MockHttpServletResponse();
+ }
+
+ public MockExternalContext(ServletContext context)
+ {
+ this.context = context;
+ this.request = new MockHttpServletRequest(new MockHttpSession(context));
+ this.response = new MockHttpServletResponse();
+ }
+
+ public MockExternalContext(ServletContext context, HttpSession session)
+ {
+ this.context = context;
+ this.request = new MockHttpServletRequest(session);
+ this.response = new MockHttpServletResponse();
+ }
+
+ public MockExternalContext(ServletContext context, HttpServletRequest request)
+ {
+ this.context = context;
+ this.request = request;
+ this.response = new MockHttpServletResponse();
+ }
+
+ public MockExternalContext(ServletContext context, HttpServletRequest request,
+ HttpServletResponse response)
+ {
+ this.context = context;
+ this.request = request;
+ this.response = response;
+ }
+
+ public MockExternalContext(HttpServletRequest request)
+ {
+ this.request = request;
+ }
+
+ @Override
+ public void dispatch(String url) throws IOException
+ {
+
+ }
+
+ @Override
+ public String encodeActionURL(String url)
+ {
+ return encodeURL(url);
+ }
+
+ @Override
+ public String encodeNamespace(String ns)
+ {
+ return ns;
+ }
+
+ @Override
+ public String encodeResourceURL(String url)
+ {
+ return encodeURL(url);
+ }
+
+ @Override
+ public Map getApplicationMap()
+ {
+ return new AttributeMap()
+ {
+ @Override
+ public Enumeration keys()
+ {
+ return context.getAttributeNames();
+ }
+
+ @Override
+ public Object getAttribute(String key)
+ {
+ return context.getAttribute(key);
+ }
+
+ @Override
+ public void setAttribute(String key, Object value)
+ {
+ context.setAttribute(key, value);
+ }
+
+ @Override
+ public void removeAttribute(String key)
+ {
+ context.removeAttribute(key);
+ }
+ };
+ }
+
+ @Override
+ public String getAuthType()
+ {
+ return request.getAuthType();
+ }
+
+ @Override
+ public Object getContext()
+ {
+ return context;
+ }
+
+ @Override
+ public String getInitParameter(String name)
+ {
+ return context.getInitParameter(name);
+ }
+
+ @Override
+ public Map getInitParameterMap()
+ {
+ Map result = new HashMap();
+ Enumeration e = context.getInitParameterNames();
+ while (e.hasMoreElements())
+ {
+ String name = (String) e.nextElement();
+ result.put(name, context.getInitParameter(name));
+ }
+ return result;
+ }
+
+ @Override
+ public String getRemoteUser()
+ {
+ return request.getRemoteUser();
+ }
+
+ @Override
+ public Object getRequest()
+ {
+ return request;
+ }
+
+ @Override
+ public String getRequestContextPath()
+ {
+ String path = (String) request.getAttribute("org.jboss.seam.web.requestContextPath");
+ return path!=null ? path : request.getContextPath();
+ }
+
+ @Override
+ public Map getRequestCookieMap()
+ {
+ Map<String, Cookie> cookieMap = new HashMap<String, Cookie>();
+
+ if (request != null && request.getCookies() != null)
+ {
+ for (Cookie cookie : request.getCookies())
+ {
+ cookieMap.put(cookie.getName(), cookie);
+ }
+ }
+
+ return cookieMap;
+ }
+
+ @Override
+ public Map getRequestHeaderMap()
+ {
+ Map result = new HashMap();
+ Enumeration<String> names = request.getHeaderNames();
+ while (names.hasMoreElements())
+ {
+ String name = names.nextElement();
+ result.put(name, request.getHeader(name));
+ }
+ return result;
+ }
+
+ @Override
+ public Map getRequestHeaderValuesMap()
+ {
+ Map<String, String[]> result = new HashMap<String, String[]>();
+ Enumeration<String> en = request.getHeaderNames();
+ while (en.hasMoreElements())
+ {
+ String header = en.nextElement();
+ List<String> headerList = Collections.list(request.getHeaders(header));
+ String[] headers = new String[headerList.size()];
+ for (int i = 0; i < headerList.size(); i++)
+ {
+ headers[i] = headerList.get(i);
+ }
+ result.put(header, headers);
+ }
+ return result;
+ }
+
+ @Override
+ public Locale getRequestLocale()
+ {
+ return Locale.ENGLISH;
+ }
+
+ @Override
+ public Iterator getRequestLocales()
+ {
+ return Collections.singleton(Locale.ENGLISH).iterator();
+ }
+
+ @Override
+ public Map getRequestMap()
+ {
+ return new AttributeMap()
+ {
+ @Override
+ public Enumeration keys()
+ {
+ return request.getAttributeNames();
+ }
+
+ @Override
+ public Object getAttribute(String key)
+ {
+ return request.getAttribute(key);
+ }
+
+ @Override
+ public void setAttribute(String key, Object value)
+ {
+ request.setAttribute(key, value);
+ }
+
+ @Override
+ public void removeAttribute(String key)
+ {
+ request.removeAttribute(key);
+ }
+ };
+ }
+
+ @Override
+ public Map getRequestParameterMap()
+ {
+ Map map = new HashMap();
+ Enumeration<String> names = request.getParameterNames();
+ while (names.hasMoreElements())
+ {
+ String name = names.nextElement();
+ map.put(name, request.getParameter(name));
+ }
+ return map;
+ }
+
+ @Override
+ public Iterator getRequestParameterNames()
+ {
+ return request.getParameterMap().keySet().iterator();
+ }
+
+ @Override
+ public Map getRequestParameterValuesMap()
+ {
+ return request.getParameterMap();
+ }
+
+ @Override
+ public String getRequestPathInfo()
+ {
+ String path = (String) request.getAttribute("org.jboss.seam.web.requestPathInfo");
+ return path!=null ? path : request.getPathInfo();
+ }
+
+ @Override
+ public String getRequestServletPath()
+ {
+ String path = (String) request.getAttribute("org.jboss.seam.web.requestServletPath");
+ return path!=null ? path : request.getServletPath();
+ }
+
+ @Override
+ public URL getResource(String name) throws MalformedURLException
+ {
+ return context.getResource(name);
+ }
+
+ @Override
+ public InputStream getResourceAsStream(String name)
+ {
+ return context.getResourceAsStream(name);
+ }
+
+ @Override
+ public Set getResourcePaths(String name)
+ {
+ return context.getResourcePaths(name);
+ }
+
+ @Override
+ public Object getResponse()
+ {
+ return response;
+ }
+
+ @Override
+ public Object getSession(boolean create)
+ {
+ return request.getSession();
+ }
+
+ @Override
+ public Map getSessionMap()
+ {
+ final HttpSession session = request.getSession(true); //TODO: create the session lazily, RI should do that to
+ return new AttributeMap()
+ {
+ @Override
+ public Enumeration keys()
+ {
+ return session.getAttributeNames();
+ }
+
+ @Override
+ public Object getAttribute(String key)
+ {
+ return session.getAttribute(key);
+ }
+
+ @Override
+ public void setAttribute(String key, Object value)
+ {
+ session.setAttribute(key, value);
+ }
+
+ @Override
+ public void removeAttribute(String key)
+ {
+ session.removeAttribute(key);
+ }
+ };
+ }
+
+ static abstract class AttributeMap implements Map
+ {
+
+ public abstract Enumeration keys();
+
+ public Object get(Object key)
+ {
+ return getAttribute((String) key);
+ }
+
+ public Object put(Object key, Object value)
+ {
+ Object result = get(key);
+ setAttribute((String) key, value);
+ return result;
+ }
+
+ public void clear()
+ {
+ Enumeration e = keys();
+ while (e.hasMoreElements())
+ {
+ remove(e.nextElement());
+ }
+ }
+
+ public boolean containsKey(Object key)
+ {
+ Enumeration e = keys();
+ while (e.hasMoreElements())
+ {
+ if (key.equals(e.nextElement())) return true;
+ }
+ return false;
+ }
+
+ public boolean containsValue(Object value)
+ {
+ Enumeration e = keys();
+ while (e.hasMoreElements())
+ {
+ if (value.equals(get(e.nextElement()))) return true;
+ }
+ return false;
+ }
+
+ public Set entrySet()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public abstract Object getAttribute(String key);
+
+ public boolean isEmpty()
+ {
+ return size() == 0;
+ }
+
+ public Set keySet()
+ {
+ return new AbstractSet()
+ {
+
+ @Override
+ public Iterator iterator()
+ {
+ return new EnumerationIterator(keys());
+ }
+
+ @Override
+ public int size()
+ {
+ return AttributeMap.this.size();
+ }
+
+ };
+ }
+
+ public abstract void setAttribute(String key, Object value);
+
+ public abstract void removeAttribute(String key);
+
+ public void putAll(Map t)
+ {
+ for (Map.Entry me : (Set<Map.Entry>) t.entrySet())
+ {
+ put(me.getKey(), me.getValue());
+ }
+ }
+
+ public Object remove(Object key)
+ {
+ Object result = getAttribute((String) key);
+ removeAttribute((String) key);
+ return result;
+ }
+
+ public int size()
+ {
+ int i = 0;
+ Enumeration e = keys();
+ while (e.hasMoreElements())
+ {
+ e.nextElement();
+ i++;
+ }
+ return i;
+ }
+
+ public Collection values()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+
+ @Override
+ public Principal getUserPrincipal()
+ {
+ return request.getUserPrincipal();
+ }
+
+ @Override
+ public boolean isUserInRole(String role)
+ {
+ return request.isUserInRole(role);
+ }
+
+ @Override
+ public void log(String message, Throwable t)
+ {
+
+ }
+
+ @Override
+ public void log(String t)
+ {
+ }
+
+ @Override
+ public void redirect(String url) throws IOException
+ {
+ response.sendRedirect(url);
+ FacesContext.getCurrentInstance().responseComplete();
+ }
+
+ /**
+ * @since 1.2
+ */
+ @Override
+ public String getResponseContentType()
+ {
+ return response.getContentType();
+ }
+
+ /**
+ * Attempt to encode the URL, falling back to
+ * an identity function if the response has
+ * not been set on this mock context. This
+ * functionality is needed in order for
+ * the ExceptionFilter to maintain the session id
+ * when url rewriting is used.
+ */
+ protected String encodeURL(String url)
+ {
+ if (response != null) {
+ String encodedUrl = response.encodeURL(url);
+ url = (encodedUrl != null ? encodedUrl : url);
+ }
+ return url;
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockFacesContext.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockFacesContext.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockFacesContext.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,388 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * $Id$
+ */
+package org.jboss.seam.mock.faces;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import java.util.NoSuchElementException;
+import javax.el.ELContext;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseStream;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.PhaseId;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+
+/**
+ * @author Gavin King
+ * @author Thomas Heute
+ * @author Dan Allen
+ */
+public class MockFacesContext extends FacesContext
+{
+ private Application application;
+
+ private UIViewRoot viewRoot;
+
+ /**
+ * Store mapping of clientId to ArrayList of FacesMessage instances. The
+ * null key is used to represent FacesMessage instances that are not
+ * associated with a clientId instance.
+ */
+ private final Map<String, List<FacesMessage>> messages = new LinkedHashMap<String, List<FacesMessage>>();
+
+ private ExternalContext externalContext;
+
+ private ResponseWriter responseWriter;
+
+ private RenderKitFactory renderKitFactory;
+
+ private ELContext elContext;
+
+ private boolean renderResponse;
+
+ private boolean responseComplete;
+
+ private PhaseId currentPhaseId;
+
+ public MockFacesContext()
+ {
+ }
+
+ public MockFacesContext(Application application)
+ {
+ this.application = application;
+ }
+
+ public MockFacesContext(ExternalContext externalContext, Application application)
+ {
+ this.externalContext = externalContext;
+ this.application = application;
+ }
+
+ // Create a MockFacesContext using a ApplicationFactory to get the
+ // Application
+ public MockFacesContext(ExternalContext externalContext)
+ {
+ application = ((ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
+ renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ this.externalContext = externalContext;
+ }
+
+ @Override
+ public Application getApplication()
+ {
+ return application;
+ }
+
+ @Override
+ public Iterator getClientIdsWithMessages()
+ {
+ return messages.keySet().iterator();
+ }
+
+ @Override
+ public ExternalContext getExternalContext()
+ {
+ return externalContext;
+ }
+
+ @Override
+ public Severity getMaximumSeverity()
+ {
+ Severity max = null;
+ for (List<FacesMessage> messagesForKey : messages.values())
+ {
+ for (FacesMessage msg : messagesForKey)
+ {
+ if (msg.getSeverity() == FacesMessage.SEVERITY_FATAL)
+ {
+ return FacesMessage.SEVERITY_FATAL;
+ }
+ else if (max == null || msg.getSeverity().compareTo(max) > 0)
+ {
+ max = msg.getSeverity();
+ }
+ }
+ }
+ return max;
+ }
+
+ @Override
+ public Iterator getMessages()
+ {
+ return messages.size() > 0 ? new FacesMessagesIterator(messages) : Collections.<FacesMessage>emptyList().iterator();
+ }
+
+ @Override
+ public Iterator getMessages(String clientId)
+ {
+ List<FacesMessage> messagesForKey = messages.get(clientId);
+ return messagesForKey != null ? messagesForKey.iterator() : Collections.<FacesMessage>emptyList().iterator();
+ }
+
+ @Override
+ public List<FacesMessage> getMessageList()
+ {
+ List<FacesMessage> aggregatedMessages = new ArrayList<FacesMessage>();
+ for (List<FacesMessage> messagesForKey : messages.values())
+ {
+ aggregatedMessages.addAll(messagesForKey);
+ }
+ return Collections.unmodifiableList(aggregatedMessages);
+ }
+
+ @Override
+ public List<FacesMessage> getMessageList(String clientId)
+ {
+ return messages.containsKey(clientId) ? Collections.unmodifiableList(messages.get(clientId)) : Collections.<FacesMessage>emptyList();
+ }
+
+ @Override
+ public RenderKit getRenderKit()
+ {
+ if (getViewRoot() == null || getViewRoot().getRenderKitId() == null)
+ {
+ return MockRenderKit.INSTANCE;
+ }
+ else
+ {
+ return renderKitFactory.getRenderKit(this, getViewRoot().getRenderKitId());
+ }
+ }
+
+ @Override
+ public boolean getRenderResponse()
+ {
+ return renderResponse;
+ }
+
+ @Override
+ public boolean getResponseComplete()
+ {
+ return responseComplete;
+ }
+
+ @Override
+ public ResponseStream getResponseStream()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setResponseStream(ResponseStream stream)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ResponseWriter getResponseWriter()
+ {
+ return responseWriter;
+ }
+
+ @Override
+ public void setResponseWriter(ResponseWriter writer)
+ {
+ responseWriter = writer;
+ }
+
+ @Override
+ public UIViewRoot getViewRoot()
+ {
+ return viewRoot;
+ }
+
+ @Override
+ public void setViewRoot(UIViewRoot vr)
+ {
+ viewRoot = vr;
+ }
+
+ @Override
+ public void addMessage(String clientId, FacesMessage msg)
+ {
+ if (!messages.containsKey(clientId))
+ {
+ List<FacesMessage> messagesForKey = new ArrayList<FacesMessage>(1);
+ messagesForKey.add(msg);
+ messages.put(clientId, messagesForKey);
+ }
+ else
+ {
+ messages.get(clientId).add(msg);
+ }
+ }
+
+ @Override
+ public void release()
+ {
+ setCurrentInstance(null);
+ MockFacesContextFactory.setFacesContext(null);
+ }
+
+ @Override
+ public void renderResponse()
+ {
+ renderResponse = true;
+ }
+
+ @Override
+ public void responseComplete()
+ {
+ responseComplete = true;
+ }
+
+ @Override
+ public PhaseId getCurrentPhaseId()
+ {
+ return currentPhaseId;
+ }
+
+ @Override
+ public void setCurrentPhaseId(PhaseId phaseId)
+ {
+ this.currentPhaseId = phaseId;
+ }
+
+ public MockFacesContext setCurrent()
+ {
+ setCurrentInstance(this);
+
+ MockFacesContextFactory.setFacesContext(this);
+ return this;
+ }
+
+ public MockFacesContext createViewRoot()
+ {
+ viewRoot = new UIViewRoot();
+ viewRoot.setRenderKitId(getApplication().getViewHandler().calculateRenderKitId(this));
+ return this;
+ }
+
+ @Override
+ public ELContext getELContext()
+ {
+ /*
+ if (elContext == null)
+ {
+ elContext = EL.createELContext(EL.createELContext(), getApplication().getELResolver());
+ elContext.putContext(FacesContext.class, this);
+ }
+ return elContext;
+ */
+ return elContext;
+ }
+
+ public void setELContext(ELContext elContext)
+ {
+ this.elContext = elContext;
+ }
+
+ private static final class FacesMessagesIterator implements Iterator<FacesMessage>
+ {
+ private Map<String, List<FacesMessage>> messages;
+
+ private int keyIndex = -1;
+
+ private int numKeys;
+
+ private Iterator<FacesMessage> messagesForKey;
+
+ private Iterator<String> keys;
+
+ FacesMessagesIterator(Map<String, List<FacesMessage>> messages)
+ {
+ this.messages = messages;
+ numKeys = messages.size();
+ keys = messages.keySet().iterator();
+ }
+
+ public boolean hasNext()
+ {
+ if (keyIndex == -1)
+ {
+ keyIndex++;
+ messagesForKey = messages.get(keys.next()).iterator();
+ }
+ while (!messagesForKey.hasNext())
+ {
+ keyIndex++;
+ if ((keyIndex) < numKeys)
+ {
+ messagesForKey = messages.get(keys.next()).iterator();
+ }
+ else
+ {
+ return false;
+ }
+ }
+ return messagesForKey.hasNext();
+ }
+
+ public FacesMessage next()
+ {
+ if (keyIndex >= numKeys)
+ {
+ throw new NoSuchElementException();
+ }
+ if (messagesForKey != null && messagesForKey.hasNext())
+ {
+ return messagesForKey.next();
+ }
+ else
+ {
+ if (!this.hasNext())
+ {
+ throw new NoSuchElementException();
+ }
+ else
+ {
+ return messagesForKey.next();
+ }
+ }
+ }
+
+ public void remove()
+ {
+ if (keyIndex == -1)
+ {
+ throw new IllegalStateException();
+ }
+ messagesForKey.remove();
+ }
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockFacesContextFactory.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockFacesContextFactory.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockFacesContextFactory.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,27 @@
+package org.jboss.seam.mock.faces;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.lifecycle.Lifecycle;
+
+public class MockFacesContextFactory extends FacesContextFactory
+{
+ private static FacesContext facesContext;
+
+ @Override
+ public FacesContext getFacesContext(Object context, Object request, Object response, Lifecycle lifecycle) throws FacesException
+ {
+ return facesContext;
+ }
+
+ public static void setFacesContext(FacesContext facesContext)
+ {
+ MockFacesContextFactory.facesContext = facesContext;
+ }
+
+ public static FacesContext getFacesContext()
+ {
+ return MockFacesContextFactory.facesContext;
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockLifecycle.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockLifecycle.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockLifecycle.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,49 @@
+//$Id: MockLifecycle.java 8195 2008-05-15 13:25:37Z pete.muir(a)jboss.org $
+package org.jboss.seam.mock.faces;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+
+public class MockLifecycle extends Lifecycle
+{
+ public static final Lifecycle INSTANCE = new MockLifecycle();
+
+ public MockLifecycle()
+ {
+ MockLifecycleFactory.setLifecycle(this);
+ FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY, MockLifecycleFactory.class.getName());
+ }
+
+ @Override
+ public void addPhaseListener(PhaseListener pl)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void execute(FacesContext ctx) throws FacesException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public PhaseListener[] getPhaseListeners()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removePhaseListener(PhaseListener pl)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void render(FacesContext ctx) throws FacesException
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockLifecycleFactory.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockLifecycleFactory.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockLifecycleFactory.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,40 @@
+package org.jboss.seam.mock.faces;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+
+public class MockLifecycleFactory extends LifecycleFactory
+{
+ private static Lifecycle lifecycle;
+
+ public static void setLifecycle(Lifecycle lifecycle)
+ {
+ MockLifecycleFactory.lifecycle = lifecycle;
+ }
+
+ public static Lifecycle getLifecycle()
+ {
+ return MockLifecycleFactory.lifecycle;
+ }
+
+ @Override
+ public void addLifecycle(String lifecycleId, Lifecycle lifecycle)
+ {
+ throw new IllegalArgumentException("Not supported by mock");
+ }
+
+ @Override
+ public Lifecycle getLifecycle(String lifecycleId)
+ {
+ return lifecycle;
+ }
+
+ @Override
+ public Iterator<String> getLifecycleIds()
+ {
+ return Arrays.asList(DEFAULT_LIFECYCLE).iterator();
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockNavigationHandler.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockNavigationHandler.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockNavigationHandler.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,12 @@
+package org.jboss.seam.mock.faces;
+
+import javax.faces.application.NavigationHandler;
+import javax.faces.context.FacesContext;
+
+public class MockNavigationHandler extends NavigationHandler
+{
+ @Override
+ public void handleNavigation(FacesContext context, String action, String outcome)
+ {
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockRenderKit.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockRenderKit.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockRenderKit.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,45 @@
+package org.jboss.seam.mock.faces;
+
+import java.io.OutputStream;
+import java.io.Writer;
+
+import javax.faces.context.ResponseStream;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.RenderKit;
+import javax.faces.render.Renderer;
+import javax.faces.render.ResponseStateManager;
+
+public class MockRenderKit extends RenderKit
+{
+ public static final MockRenderKit INSTANCE = new MockRenderKit();
+
+ @Override
+ public void addRenderer(String x, String y, Renderer renderer)
+ {
+ // Do nothing
+ }
+
+ @Override
+ public Renderer getRenderer(String x, String y)
+ {
+ return null;
+ }
+
+ @Override
+ public ResponseStateManager getResponseStateManager()
+ {
+ return new MockResponseStateManager();
+ }
+
+ @Override
+ public ResponseWriter createResponseWriter(Writer writer, String x, String y)
+ {
+ return new MockResponseWriter();
+ }
+
+ @Override
+ public ResponseStream createResponseStream(OutputStream stream)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockResponseStateManager.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockResponseStateManager.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockResponseStateManager.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,28 @@
+package org.jboss.seam.mock.faces;
+
+import java.io.IOException;
+
+import javax.faces.application.StateManager.SerializedView;
+import javax.faces.context.FacesContext;
+import javax.faces.render.ResponseStateManager;
+
+@SuppressWarnings("deprecation")
+public class MockResponseStateManager extends ResponseStateManager
+{
+ @Override
+ public Object getComponentStateToRestore(FacesContext ctx)
+ {
+ return new Object();
+ }
+
+ @Override
+ public Object getTreeStructureToRestore(FacesContext ctx, String x)
+ {
+ return new Object();
+ }
+
+ @Override
+ public void writeState(FacesContext ctx, SerializedView viewState) throws IOException
+ {
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockResponseWriter.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockResponseWriter.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockResponseWriter.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,158 @@
+package org.jboss.seam.mock.faces;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.ResponseWriter;
+
+public class MockResponseWriter extends ResponseWriter
+{
+ private Writer writer;
+
+ public MockResponseWriter(Writer writer)
+ {
+ this.writer = writer;
+ }
+
+ public MockResponseWriter()
+ {
+ this.writer = new StringWriter();
+ }
+
+ @Override
+ public ResponseWriter cloneWithWriter(Writer writer)
+ {
+ return new MockResponseWriter(writer);
+ }
+
+ @Override
+ public void endDocument() throws IOException
+ {
+ // Do nothing
+ }
+
+ @Override
+ public void endElement(String element) throws IOException
+ {
+ // Do nothing
+ }
+
+ @Override
+ public void flush() throws IOException
+ {
+ writer.flush();
+
+ }
+
+ @Override
+ public String getCharacterEncoding()
+ {
+ return null;
+ }
+
+ @Override
+ public String getContentType()
+ {
+ return null;
+ }
+
+ @Override
+ public void startDocument() throws IOException
+ {
+ // Do nothing
+ }
+
+ @Override
+ public void startElement(String element, UIComponent component) throws IOException
+ {
+ // Do nothing
+ }
+
+ @Override
+ public void writeAttribute(String attribute, Object object, String string) throws IOException
+ {
+ // Do nothing
+ }
+
+ @Override
+ public void writeComment(Object object) throws IOException
+ {
+ // TODO Do nothing
+ }
+
+ @Override
+ public void writeText(Object value, String string) throws IOException
+ {
+ if (value == null)
+ {
+ throw new NullPointerException("Text must not be null.");
+ }
+ String strValue = value.toString();
+ write(strValue);
+ }
+
+ @Override
+ public void writeText(char[] chars, int start, int end) throws IOException
+ {
+ if (chars == null)
+ {
+ throw new NullPointerException("cbuf name must not be null");
+ }
+ if (chars.length < start + end)
+ {
+ throw new IndexOutOfBoundsException((start + end) + " > " + chars.length);
+ }
+ String strValue = new String(chars, start, end);
+ write(strValue);
+ }
+
+ @Override
+ public void writeURIAttribute(String attribute, Object object, String string) throws IOException
+ {
+ // Do nothing
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ writer.close();
+
+ }
+
+ @Override
+ public void write(char[] chars, int start, int end) throws IOException
+ {
+ writer.write(chars, start, end);
+ }
+
+ @Override
+ public void write(String str) throws IOException
+ {
+ writer.write(str);
+ }
+
+ @Override
+ public void write(int c) throws IOException
+ {
+ writer.write(c);
+ }
+
+ @Override
+ public void write(char cbuf[]) throws IOException
+ {
+ writer.write(cbuf);
+ }
+
+ @Override
+ public void write(String str, int off, int len) throws IOException
+ {
+ writer.write(str, off, len);
+ }
+
+ public Writer getWriter()
+ {
+ return this.writer;
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockStateManager.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockStateManager.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockStateManager.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,63 @@
+package org.jboss.seam.mock.faces;
+
+import java.io.IOException;
+
+import javax.faces.application.StateManager;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+@SuppressWarnings("deprecation")
+public class MockStateManager extends StateManager
+{
+ @Override
+ public Object saveView(FacesContext ctx)
+ {
+ return null;
+ }
+
+ @Override
+ public void writeState(FacesContext ctx, Object state) throws IOException
+ {
+ }
+
+ @Override
+ public SerializedView saveSerializedView(FacesContext ctx)
+ {
+ return null;
+ }
+
+ @Override
+ protected Object getTreeStructureToSave(FacesContext ctx)
+ {
+ return null;
+ }
+
+ @Override
+ protected Object getComponentStateToSave(FacesContext ctx)
+ {
+ return null;
+ }
+
+ @Override
+ public void writeState(FacesContext ctx, SerializedView sv)
+ throws IOException
+ {
+ }
+
+ @Override
+ public UIViewRoot restoreView(FacesContext ctx, String x, String y)
+ {
+ return null;
+ }
+
+ @Override
+ protected UIViewRoot restoreTreeStructure(FacesContext ctx, String x, String y)
+ {
+ return null;
+ }
+
+ @Override
+ protected void restoreComponentState(FacesContext ctx, UIViewRoot viewRoot, String x)
+ {
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockViewHandler.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockViewHandler.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/faces/MockViewHandler.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,89 @@
+package org.jboss.seam.mock.faces;
+
+import java.io.IOException;
+import java.util.Locale;
+
+import javax.faces.FacesException;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+public class MockViewHandler extends ViewHandler
+{
+ @Override
+ public Locale calculateLocale(FacesContext ctx)
+ {
+ return Locale.getDefault();
+ }
+
+ @Override
+ public String calculateRenderKitId(FacesContext ctx)
+ {
+ return null;
+ }
+
+ @Override
+ public UIViewRoot createView(FacesContext ctx, String viewId)
+ {
+ UIViewRoot viewRoot = new UIViewRoot();
+ viewRoot.setViewId(viewId);
+ //TODO: set locale?
+ return viewRoot;
+ }
+
+ @Override
+ public String getActionURL(FacesContext ctx, String viewId)
+ {
+ String contextPath = ctx.getExternalContext().getRequestContextPath();
+ String pathInfo = ctx.getExternalContext().getRequestPathInfo();
+ String servletPath = ctx.getExternalContext().getRequestServletPath();
+
+ if (pathInfo == null || pathInfo.length() == 0)
+ {
+ int sploc = servletPath.lastIndexOf('.');
+ if (sploc < 0)
+ {
+ throw new IllegalArgumentException("no file extension in servlet path: " + servletPath);
+ }
+ return contextPath + getViewIdSansSuffix(viewId) + servletPath.substring(sploc);
+
+ }
+ else
+ {
+ return contextPath + (servletPath != null ? servletPath : "") + viewId;
+ }
+ }
+
+ private static String getViewIdSansSuffix(String viewId)
+ {
+ int loc = viewId.lastIndexOf('.');
+ if (loc < 0)
+ {
+ throw new IllegalArgumentException("no file extension in view id: " + viewId);
+ }
+ return viewId.substring(0, loc);
+ }
+
+ @Override
+ public String getResourceURL(FacesContext ctx, String url)
+ {
+ return url;
+ }
+
+ @Override
+ public void renderView(FacesContext ctx, UIViewRoot viewRoot)
+ throws IOException, FacesException
+ {
+ }
+
+ @Override
+ public UIViewRoot restoreView(FacesContext ctx, String id)
+ {
+ return null;
+ }
+
+ @Override
+ public void writeState(FacesContext ctx) throws IOException
+ {
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockHttpServletRequest.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockHttpServletRequest.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockHttpServletRequest.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,394 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.seam.mock.servlet;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import org.jboss.seam.mock.util.IteratorEnumeration;
+
+/**
+ * @author Gavin King
+ * @author Thomas Heute
+ */
+public class MockHttpServletRequest implements HttpServletRequest
+{
+
+ private Map<String, String[]> parameters = new HashMap<String, String[]>();
+ private Map<String, Object> attributes = new HashMap<String, Object>();
+ private HttpSession session;
+ private Map<String, String[]> headers = new HashMap<String, String[]>();
+ private String principalName;
+ private Set<String> principalRoles;
+ private Cookie[] cookies;
+ private String method;
+ private Enumeration locales;
+
+ public MockHttpServletRequest(HttpSession session)
+ {
+ this(session, null, new HashSet<String>());
+ }
+
+ public MockHttpServletRequest(HttpSession session, String principalName, Set<String> principalRoles)
+ {
+ this(session, principalName, principalRoles, new Cookie[] {}, null);
+ }
+
+ public MockHttpServletRequest(HttpSession session, String principalName, Set<String> principalRoles, Cookie[] cookies, String method)
+ {
+ this.session = session;
+ this.principalName = principalName;
+ this.principalRoles = principalRoles;
+ this.cookies = cookies;
+ this.method = method;
+ // The 1.2 RI NPEs if this header isn't present
+ headers.put("Accept", new String[0]);
+ locales = new IteratorEnumeration(new ArrayList().iterator());
+ }
+
+ public Map<String, String[]> getParameters()
+ {
+ return parameters;
+ }
+
+ public Map<String, Object> getAttributes()
+ {
+ return attributes;
+ }
+
+ public String getAuthType()
+ {
+ //TODO
+ return null;
+ }
+
+ public Cookie[] getCookies()
+ {
+ return cookies;
+ }
+
+ public long getDateHeader(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getHeader(String header)
+ {
+ String[] values = headers.get(header);
+ return values==null || values.length==0 ? null : values[0];
+ }
+
+ public Enumeration getHeaders(String header)
+ {
+ return new IteratorEnumeration( Arrays.asList( headers.get(header) ).iterator() );
+ }
+
+ public Enumeration getHeaderNames()
+ {
+ return new IteratorEnumeration( headers.keySet().iterator() );
+ }
+
+ public int getIntHeader(String header)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getMethod()
+ {
+ return method;
+ }
+
+ public String getPathInfo()
+ {
+ //TODO
+ return null;
+ }
+
+ public String getPathTranslated()
+ {
+ //TODO
+ return null;
+ }
+
+ public String getContextPath()
+ {
+ return "/project";
+ }
+
+ public String getQueryString()
+ {
+ //TODO
+ return null;
+ }
+
+ public String getRemoteUser()
+ {
+ return principalName;
+ }
+
+ public boolean isUserInRole(String role)
+ {
+ return principalRoles.contains(role);
+ }
+
+ public Principal getUserPrincipal()
+ {
+ return principalName==null ? null :
+ new Principal()
+ {
+ public String getName()
+ {
+ return principalName;
+ }
+ };
+ }
+
+ public String getRequestedSessionId()
+ {
+ //TODO
+ return null;
+ }
+
+ public String getRequestURI()
+ {
+ return "http://localhost:8080/myproject/page.seam";
+ }
+
+ public StringBuffer getRequestURL()
+ {
+ return new StringBuffer( getRequestURI() );
+ }
+
+ public String getServletPath()
+ {
+ return "/page.seam";
+ }
+
+ public HttpSession getSession(boolean create)
+ {
+ return session;
+ }
+
+ public HttpSession getSession()
+ {
+ return getSession(true);
+ }
+
+ public boolean isRequestedSessionIdValid()
+ {
+ return true;
+ }
+
+ public boolean isRequestedSessionIdFromCookie()
+ {
+ return true;
+ }
+
+ public boolean isRequestedSessionIdFromURL()
+ {
+ return false;
+ }
+
+ public boolean isRequestedSessionIdFromUrl()
+ {
+ return false;
+ }
+
+ public Object getAttribute(String att)
+ {
+ return attributes.get(att);
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ return new IteratorEnumeration( attributes.keySet().iterator() );
+ }
+
+ public String getCharacterEncoding()
+ {
+ //TODO
+ return null;
+ }
+
+ public void setCharacterEncoding(String enc)
+ throws UnsupportedEncodingException
+ {
+ //TODO
+
+ }
+
+ public int getContentLength()
+ {
+ //TODO
+ return 0;
+ }
+
+ public String getContentType()
+ {
+ //TODO
+ return null;
+ }
+
+ public ServletInputStream getInputStream() throws IOException
+ {
+ //TODO
+ return null;
+ }
+
+ public String getParameter(String param)
+ {
+ String[] values = parameters.get(param);
+ return values==null || values.length==0 ? null : values[0];
+ }
+
+ public Enumeration getParameterNames()
+ {
+ return new IteratorEnumeration( parameters.keySet().iterator() );
+ }
+
+ public String[] getParameterValues(String param)
+ {
+ return parameters.get(param);
+ }
+
+ public Map getParameterMap()
+ {
+ return parameters;
+ }
+
+ public String getProtocol()
+ {
+ //TODO
+ return null;
+ }
+
+ public String getScheme()
+ {
+ //TODO
+ return null;
+ }
+
+ public String getServerName()
+ {
+ //TODO
+ return null;
+ }
+
+ public int getServerPort()
+ {
+ //TODO
+ return 0;
+ }
+
+ public BufferedReader getReader() throws IOException
+ {
+ //TODO
+ return null;
+ }
+
+ public String getRemoteAddr()
+ {
+ //TODO
+ return null;
+ }
+
+ public String getRemoteHost()
+ {
+ //TODO
+ return null;
+ }
+
+ public void setAttribute(String att, Object value)
+ {
+ if (value==null)
+ {
+ attributes.remove(value);
+ }
+ else
+ {
+ attributes.put(att, value);
+ }
+ }
+
+ public void removeAttribute(String att)
+ {
+ attributes.remove(att);
+ }
+
+ public Locale getLocale()
+ {
+ //TODO
+ return null;
+ }
+
+ public Enumeration getLocales()
+ {
+ return locales;
+ }
+
+ public boolean isSecure()
+ {
+ //TODO
+ return false;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String path)
+ {
+ //TODO
+ return null;
+ }
+
+ public String getRealPath(String path)
+ {
+ //TODO
+ return null;
+ }
+
+ public int getRemotePort()
+ {
+ //TODO
+ return 0;
+ }
+
+ public String getLocalName()
+ {
+ //TODO
+ return null;
+ }
+
+ public String getLocalAddr()
+ {
+ //TODO
+ return null;
+ }
+
+ public int getLocalPort()
+ {
+ //TODO
+ return 0;
+ }
+
+ public Map<String, String[]> getHeaders()
+ {
+ return headers;
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockHttpServletResponse.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockHttpServletResponse.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockHttpServletResponse.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,153 @@
+package org.jboss.seam.mock.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+public class MockHttpServletResponse implements HttpServletResponse
+{
+ public void addCookie(Cookie cookie)
+ {
+ }
+
+ public void addDateHeader(String arg0, long arg1)
+ {
+ }
+
+ public void addHeader(String arg0, String arg1)
+ {
+ }
+
+ public void addIntHeader(String arg0, int arg1)
+ {
+ }
+
+ public boolean containsHeader(String arg0)
+ {
+ return false;
+ }
+
+ public String encodeRedirectURL(String arg0)
+ {
+ return null;
+ }
+
+ public String encodeRedirectUrl(String arg0)
+ {
+ return null;
+ }
+
+ public String encodeURL(String url)
+ {
+ return url;
+ }
+
+ @Deprecated
+ public String encodeUrl(String url)
+ {
+ return encodeURL(url);
+ }
+
+ public void sendError(int arg0) throws IOException
+ {
+ }
+
+ public void sendError(int arg0, String arg1) throws IOException
+ {
+ }
+
+ public void sendRedirect(String arg0) throws IOException
+ {
+ }
+
+ public void setDateHeader(String arg0, long arg1)
+ {
+ }
+
+ public void setHeader(String arg0, String arg1)
+ {
+ }
+
+ public void setIntHeader(String arg0, int arg1)
+ {
+ }
+
+ public void setStatus(int arg0)
+ {
+ }
+
+ public void setStatus(int arg0, String arg1)
+ {
+ }
+
+ public void flushBuffer() throws IOException
+ {
+ }
+
+ public int getBufferSize()
+ {
+ return 0;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return null;
+ }
+
+ public String getContentType()
+ {
+ return null;
+ }
+
+ public Locale getLocale()
+ {
+ return null;
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException
+ {
+ return null;
+ }
+
+ public PrintWriter getWriter() throws IOException
+ {
+ return null;
+ }
+
+ public boolean isCommitted()
+ {
+ return false;
+ }
+
+ public void reset()
+ {
+ }
+
+ public void resetBuffer()
+ {
+ }
+
+ public void setBufferSize(int arg0)
+ {
+ }
+
+ public void setCharacterEncoding(String arg0)
+ {
+ }
+
+ public void setContentLength(int arg0)
+ {
+ }
+
+ public void setContentType(String arg0)
+ {
+ }
+
+ public void setLocale(Locale arg0)
+ {
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockHttpSession.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockHttpSession.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockHttpSession.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.seam.mock.servlet;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionContext;
+import org.jboss.seam.mock.util.IteratorEnumeration;
+
+/**
+ * @author Gavin King
+ * @author Thomas Heute
+ * @version $Revision: 9668 $
+ */
+@SuppressWarnings("deprecation")
+public class MockHttpSession implements HttpSession
+{
+
+ private Map<String, Object> attributes = new HashMap<String, Object>();
+ private boolean isInvalid;
+ private ServletContext servletContext;
+
+ public MockHttpSession() {}
+
+ public MockHttpSession(ServletContext servletContext)
+ {
+ this.servletContext = servletContext;
+ }
+
+ public boolean isInvalid()
+ {
+ return isInvalid;
+ }
+
+ public long getCreationTime()
+ {
+ return 0;
+ }
+
+ public String getId()
+ {
+ return null;
+ }
+
+ public long getLastAccessedTime()
+ {
+ return 0;
+ }
+
+ private int maxInactiveInterval;
+
+ public void setMaxInactiveInterval(int max)
+ {
+ maxInactiveInterval = max;
+ }
+
+ public int getMaxInactiveInterval()
+ {
+ return maxInactiveInterval;
+ }
+
+ public HttpSessionContext getSessionContext()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getAttribute(String att)
+ {
+ return attributes.get(att);
+ }
+
+ public Object getValue(String att)
+ {
+ return getAttribute(att);
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ return new IteratorEnumeration( attributes.keySet().iterator() );
+ }
+
+ public String[] getValueNames()
+ {
+ return attributes.keySet().toArray( new String[0] );
+ }
+
+ public void setAttribute(String att, Object value)
+ {
+ if (value==null)
+ {
+ attributes.remove(att);
+ }
+ else
+ {
+ attributes.put(att, value);
+ }
+ }
+
+ public void putValue(String att, Object value)
+ {
+ setAttribute(att, value);
+ }
+
+ public void removeAttribute(String att)
+ {
+ attributes.remove(att);
+ }
+
+ public void removeValue(String att)
+ {
+ removeAttribute(att);
+ }
+
+ public void invalidate()
+ {
+ attributes.clear();
+ isInvalid = true;
+ }
+
+ public boolean isNew()
+ {
+ return false;
+ }
+
+ public Map<String, Object> getAttributes()
+ {
+ return attributes;
+ }
+
+ public ServletContext getServletContext()
+ {
+ return servletContext;
+ }
+
+ /*public void clear() {
+ attributes.clear();
+ isInvalid = false;
+ }*/
+
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockServletContext.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockServletContext.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/servlet/MockServletContext.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,312 @@
+//$Id: MockServletContext.java 9513 2008-11-06 03:09:55Z shane.bryzak(a)jboss.com $
+package org.jboss.seam.mock.servlet;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.jboss.seam.mock.util.IteratorEnumeration;
+
+public class MockServletContext implements ServletContext
+{
+ private Map<String, String> initParameters = new HashMap<String, String>();
+ private Map<String, Object> attributes = new HashMap<String, Object>();
+ private File webappRoot;
+ private File webInfRoot;
+ private File webInfClassesRoot;
+
+ public MockServletContext()
+ {
+ try
+ {
+ URL webxml = getClass().getResource("/WEB-INF/web.xml");
+ if (webxml != null)
+ {
+ webInfRoot = new File(webxml.toURI()).getParentFile();
+ if (webInfRoot != null)
+ {
+ webInfClassesRoot = new File(webInfRoot.getParentFile().getPath() + "/classes");
+ webappRoot = webInfRoot.getParentFile();
+ }
+ // call processing of context parameters
+ processContextParameters(webxml);
+ }
+ else
+ {
+ webappRoot = new File(getClass().getResource("/.").toURI());
+ }
+ }
+ catch (URISyntaxException e)
+ {
+ System.out.println("Unable to find web.xml:" + e.getMessage());
+ }
+ }
+
+ private void processContextParameters(URL webXML)
+ {
+ /*
+ try
+ {
+ Element root = XML.getRootElementSafely(webXML.openStream());
+ for (Element element : (List<Element>) root.elements("context-param"))
+ {
+ getInitParameters().put(element.elementText("param-name"), element.elementText("param-value"));
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Error parsing web.xml", e);
+ }
+ catch (DocumentException e)
+ {
+ throw new RuntimeException("Error parsing web.xml", e);
+ }
+ */
+ }
+
+ public Map<String, String> getInitParameters()
+ {
+ return initParameters;
+ }
+
+ public Map<String, Object> getAttributes()
+ {
+ return attributes;
+ }
+
+ public ServletContext getContext(String name)
+ {
+ return this;
+ }
+
+ public int getMajorVersion()
+ {
+ return 2;
+ }
+
+ public int getMinorVersion()
+ {
+ return 4;
+ }
+
+ public String getMimeType(String arg0)
+ {
+ return null;
+ }
+
+ public Set getResourcePaths(String name)
+ {
+ Enumeration<URL> enumeration = null;
+ try
+ {
+ enumeration = getClass().getClassLoader().getResources("WEB-INF");
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Error finding webroot.", e);
+ }
+ Set<String> result = new HashSet<String>();
+ while (enumeration.hasMoreElements())
+ {
+ URL url = enumeration.nextElement();
+ File rootFile = new File(url.getPath()).getParentFile();
+ File newFile = new File(rootFile.getPath() + name);
+ File[] files = newFile.listFiles();
+ if (files != null)
+ {
+ addPaths(result, files, rootFile.getPath());
+ }
+ }
+ return result;
+ }
+
+ private static void addPaths(Set<String> result, File[] files, String rootPath)
+ {
+ for (File file : files)
+ {
+ String filePath = file.getPath().substring(rootPath.length()).replace('\\', '/');
+ if (file.isDirectory())
+ {
+ result.add(filePath + "/");
+ }
+ else
+ {
+ result.add(filePath);
+ }
+ }
+ }
+
+ /**
+ * Get the URL for a particular resource that is relative to the web app root
+ * directory.
+ *
+ * @param name The name of the resource to get
+ * @return The resource, or null if resource not found
+ * @throws MalformedURLException If the URL is invalid
+ */
+ public URL getResource(String name) throws MalformedURLException
+ {
+ File file = getFile(name, webappRoot);
+
+ if (file == null)
+ {
+ file = getFile(name, webInfRoot);
+ }
+
+ if (file == null)
+ {
+ file = getFile(name, webInfClassesRoot);
+ }
+
+ if (file != null)
+ {
+ return file.toURI().toURL();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ private static File getFile(String name, File root)
+ {
+ if (root == null)
+ {
+ return null;
+ }
+
+ if (name.startsWith("/"))
+ {
+ name = name.substring(1);
+ }
+
+ File f = new File(root, name);
+ if (!f.exists())
+ {
+ return null;
+ }
+ else
+ {
+ return f;
+ }
+ }
+
+ public InputStream getResourceAsStream(String name)
+ {
+ return getClass().getResourceAsStream(name);
+ }
+
+ public RequestDispatcher getRequestDispatcher(String url)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public RequestDispatcher getNamedDispatcher(String name)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Servlet getServlet(String name) throws ServletException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Enumeration getServlets()
+ {
+ return null;
+ }
+
+ public Enumeration getServletNames()
+ {
+ return null;
+ }
+
+ public void log(String msg)
+ {
+ }
+
+ public void log(Exception ex, String msg)
+ {
+ }
+
+ public void log(String msg, Throwable ex)
+ {
+ }
+
+ public String getRealPath(String relativePath)
+ {
+ if (webappRoot != null)
+ {
+ return webappRoot.getAbsolutePath() + relativePath;
+ }
+ else
+ {
+ return relativePath;
+ }
+ }
+
+ public String getServerInfo()
+ {
+ return null;
+ }
+
+ public String getInitParameter(String param)
+ {
+ return initParameters.get(param);
+ }
+
+ public Enumeration getInitParameterNames()
+ {
+ return new IteratorEnumeration(initParameters.keySet().iterator());
+ }
+
+ public Object getAttribute(String att)
+ {
+ return attributes.get(att);
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ return new IteratorEnumeration(attributes.keySet().iterator());
+ }
+
+ public void setAttribute(String att, Object value)
+ {
+ if (value == null)
+ {
+ attributes.remove(value);
+ }
+ else
+ {
+ attributes.put(att, value);
+ }
+ }
+
+ public void removeAttribute(String att)
+ {
+ attributes.remove(att);
+ }
+
+ public String getServletContextName()
+ {
+ return "Mock";
+ }
+
+ public String getContextPath()
+ {
+ return null;
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/util/EnumerationIterator.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/util/EnumerationIterator.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/util/EnumerationIterator.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,29 @@
+package org.jboss.seam.mock.util;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+
+public class EnumerationIterator<T> implements Iterator<T>
+{
+ private Enumeration e;
+
+ public EnumerationIterator(Enumeration e)
+ {
+ this.e = e;
+ }
+
+ public boolean hasNext()
+ {
+ return e.hasMoreElements();
+ }
+
+ public T next()
+ {
+ return (T) e.nextElement();
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: modules/trunk/mock/src/main/java/org/jboss/seam/mock/util/IteratorEnumeration.java
===================================================================
--- modules/trunk/mock/src/main/java/org/jboss/seam/mock/util/IteratorEnumeration.java (rev 0)
+++ modules/trunk/mock/src/main/java/org/jboss/seam/mock/util/IteratorEnumeration.java 2009-04-29 05:52:55 UTC (rev 10691)
@@ -0,0 +1,25 @@
+//$Id: IteratorEnumeration.java 5629 2007-06-29 00:41:37Z gavin $
+package org.jboss.seam.mock.util;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+
+public class IteratorEnumeration implements Enumeration
+{
+ private Iterator iterator;
+
+ public IteratorEnumeration(Iterator iterator)
+ {
+ this.iterator = iterator;
+ }
+
+ public boolean hasMoreElements()
+ {
+ return iterator.hasNext();
+ }
+
+ public Object nextElement()
+ {
+ return iterator.next();
+ }
+}
[View Less]
15 years, 10 months
Seam SVN: r10690 - in modules/trunk/faces/src/main/java/org/jboss/seam/faces: annotations and 1 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-04-28 23:35:21 -0400 (Tue, 28 Apr 2009)
New Revision: 10690
Added:
modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataBinderClass.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModel.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModelSelection.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModelSelectionIndex.java
modules/trunk/…
[View More]faces/src/main/java/org/jboss/seam/faces/annotations/DataSelectorClass.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/
modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataBinder.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelBinder.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelIndexSelector.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelSelector.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataSelector.java
Log:
add datamodel stuff
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataBinderClass.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataBinderClass.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataBinderClass.java 2009-04-29 03:35:21 UTC (rev 10690)
@@ -0,0 +1,27 @@
+package org.jboss.seam.faces.annotations;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.jboss.seam.faces.databinding.DataBinder;
+
+/**
+ * Meta-annotation that specifies that an annotation
+ * is a databinding annotation, ie. that it results
+ * in outjection of a wrapped representation of the
+ * annotated component attribute value.
+ *
+ * @see org.jboss.seam.databinding.DataBinder
+ * @author Gavin King
+ */
+@Target(ANNOTATION_TYPE)
+@Retention(RUNTIME)
+@Documented
+public @interface DataBinderClass
+{
+ Class<? extends DataBinder> value();
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModel.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModel.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModel.java 2009-04-29 03:35:21 UTC (rev 10690)
@@ -0,0 +1,57 @@
+//$Id: DataModel.java 2169 2006-10-10 03:48:19Z gavin $
+package org.jboss.seam.faces.annotations;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import javax.context.ScopeType;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.jboss.seam.faces.annotations.DataBinderClass;
+import org.jboss.seam.faces.databinding.DataModelBinder;
+
+/**
+ * Outjects a collection to the same scope as the owning component
+ * (or to the EVENT scope in the case of a stateless component),
+ * after wrapping as a JSF DataModel (a List as a ListDataModel, a
+ * Map as a MapDataModel, a Set as a SetDataModel, an array as an
+ * ArrayDataModel). Note that the List, Map, Set or array
+ * will be re-wrapped and re-outjected each time the current
+ * component value is different to the value held by the
+ * context variable as determined by calling equals() on the
+ * underlying collection.
+ *
+ * @author Gavin King
+ *
+ * @see org.jboss.seam.jsf.ListDataModel
+ * @see org.jboss.seam.jsf.MapDataModel
+ * @see org.jboss.seam.jsf.SetDataModel
+ * @see org.jboss.seam.jsf.ArrayDataModel
+ */
+@Target({FIELD, METHOD})
+@Retention(RUNTIME)
+@Documented
+(a)DataBinderClass(DataModelBinder.class)
+public @interface DataModel
+{
+ /**
+ * The context variable name. Defaults to the name of
+ * the annotated field or getter method.
+ */
+ String value() default "";
+
+ /**
+ * Specifies the scope to outject the DataModel to.
+ * If no scope is explicitly specified, the scope of
+ * the component with the @DataModel attribute is used.
+ * But if the component scope is STATELESS, the EVENT
+ * scope is used.
+ *
+ */
+ Class<? extends Annotation> scope();
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModelSelection.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModelSelection.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModelSelection.java 2009-04-29 03:35:21 UTC (rev 10690)
@@ -0,0 +1,33 @@
+//$Id: DataModelSelection.java 2025 2006-09-18 16:43:02Z gavin $
+package org.jboss.seam.faces.annotations;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.jboss.seam.faces.databinding.DataModelSelector;
+
+/**
+ * Injects the selected row data of a DataModel.
+ * Intended for use with @DataModel.
+ *
+ * @author Gavin King
+ * @see DataModel
+ */
+@Target({FIELD, METHOD})
+@Retention(RUNTIME)
+@Documented
+(a)DataSelectorClass(DataModelSelector.class)
+public @interface DataModelSelection
+{
+ /**
+ * The context variable name of the DataModel. Defaults
+ * to the name for the outjected @DataModel if there
+ * is exactly one @DataModel for the component.
+ */
+ String value() default "";
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModelSelectionIndex.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModelSelectionIndex.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModelSelectionIndex.java 2009-04-29 03:35:21 UTC (rev 10690)
@@ -0,0 +1,34 @@
+//$Id: DataModelSelectionIndex.java 2025 2006-09-18 16:43:02Z gavin $
+package org.jboss.seam.faces.annotations;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.jboss.seam.faces.databinding.DataModelIndexSelector;
+
+/**
+ * Injects the selected row index of a ListDataModel,
+ * MapDataModel or ArrayDataModel. Intended for use
+ * with @DataModel.
+ *
+ * @author Gavin King
+ * @see DataModel
+ */
+@Target({FIELD, METHOD})
+@Retention(RUNTIME)
+@Documented
+(a)DataSelectorClass(DataModelIndexSelector.class)
+public @interface DataModelSelectionIndex
+{
+ /**
+ * The context variable name of the DataModel. Defaults
+ * to the name for the outjected @DataModel if there
+ * is exactly one @DataModel for the component.
+ */
+ String value() default "";
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataSelectorClass.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataSelectorClass.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataSelectorClass.java 2009-04-29 03:35:21 UTC (rev 10690)
@@ -0,0 +1,27 @@
+package org.jboss.seam.faces.annotations;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.jboss.seam.faces.databinding.DataSelector;
+
+/**
+ * Meta-annotation that specifies that an annotation
+ * is a dataselection annotation, ie. that it results
+ * in injection of the selected item of some databound
+ * data.
+ *
+ * @see org.jboss.seam.databinding.DataSelector
+ * @author Gavin King
+ */
+@Target(ANNOTATION_TYPE)
+@Retention(RUNTIME)
+@Documented
+public @interface DataSelectorClass
+{
+ Class<? extends DataSelector> value();
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataBinder.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataBinder.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataBinder.java 2009-04-29 03:35:21 UTC (rev 10690)
@@ -0,0 +1,23 @@
+package org.jboss.seam.faces.databinding;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * Allows some "bound type" to be exposed to
+ * the user interface via a "wrapper type".
+ *
+ * @author Gavin King
+ *
+ * @param <Out> the annotation type
+ * @param <Type> the bound type
+ * @param <WrapperType> the wrapper type
+ */
+public interface DataBinder<Out extends Annotation, Type, WrapperType>
+{
+ String getVariableName(Out out);
+ Class<? extends Annotation> getVariableScope(Out out);
+ WrapperType wrap(Out out, Type value);
+ Type getWrappedData(Out out, WrapperType wrapper);
+ Object getSelection(Out out, WrapperType wrapper);
+ boolean isDirty(Out out, WrapperType wrapper, Type value);
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelBinder.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelBinder.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelBinder.java 2009-04-29 03:35:21 UTC (rev 10690)
@@ -0,0 +1,66 @@
+package org.jboss.seam.faces.databinding;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+
+import javax.inject.Current;
+
+import org.jboss.seam.faces.annotations.DataModel;
+import org.jboss.seam.faces.DataModels;
+
+/**
+ * Exposes a List, array, Map or Set to the UI as a JSF DataModel
+ *
+ * @author Gavin King
+ */
+public class DataModelBinder implements DataBinder<DataModel, Object, javax.faces.model.DataModel>
+{
+ @Current DataModels dataModels;
+
+ public String getVariableName(DataModel out)
+ {
+ return out.value();
+ }
+
+ public Class<? extends Annotation> getVariableScope(DataModel out)
+ {
+ return out.scope();
+ }
+
+ public javax.faces.model.DataModel wrap(DataModel out, Object value)
+ {
+ return dataModels.getDataModel(value);
+ }
+
+ public Object getWrappedData(DataModel out, javax.faces.model.DataModel wrapper)
+ {
+ return wrapper.getWrappedData();
+ }
+
+ public Object getSelection(DataModel out, javax.faces.model.DataModel wrapper)
+ {
+ if ( wrapper.getRowCount()==0 || wrapper.getRowIndex()<0 ||
+ wrapper.getRowIndex()>=wrapper.getRowCount())
+ {
+ return null;
+ }
+ else
+ {
+ Object rowData = wrapper.getRowData();
+ if (rowData instanceof Map.Entry)
+ {
+ return ( (Map.Entry) rowData ).getValue();
+ }
+ else
+ {
+ return rowData;
+ }
+ }
+ }
+
+ public boolean isDirty(DataModel out, javax.faces.model.DataModel wrapper, Object value)
+ {
+ return !getWrappedData(out, wrapper).equals(value);
+ }
+
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelIndexSelector.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelIndexSelector.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelIndexSelector.java 2009-04-29 03:35:21 UTC (rev 10690)
@@ -0,0 +1,42 @@
+package org.jboss.seam.faces.databinding;
+
+import java.util.Map;
+
+import javax.faces.model.DataModel;
+
+import org.jboss.seam.faces.annotations.DataModelSelectionIndex;
+
+/**
+ * Extracts the selected "index" (the row index, or the key of a map) from a JSF DataModel.
+ *
+ * @author Gavin King
+ */
+public class DataModelIndexSelector implements DataSelector<DataModelSelectionIndex, DataModel>
+{
+
+ public String getVariableName(DataModelSelectionIndex in)
+ {
+ return in.value();
+ }
+
+ public Object getSelection(DataModelSelectionIndex in, DataModel wrapper)
+ {
+ if ( wrapper.getRowCount()==0 || wrapper.getRowIndex()<0 )
+ {
+ return null;
+ }
+ else
+ {
+ Object rowData = wrapper.getRowData();
+ if (rowData instanceof Map.Entry)
+ {
+ return ( (Map.Entry) rowData ).getKey();
+ }
+ else
+ {
+ return wrapper.getRowIndex();
+ }
+ }
+ }
+
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelSelector.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelSelector.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelSelector.java 2009-04-29 03:35:21 UTC (rev 10690)
@@ -0,0 +1,42 @@
+package org.jboss.seam.faces.databinding;
+
+import java.util.Map;
+
+import javax.faces.model.DataModel;
+
+import org.jboss.seam.faces.annotations.DataModelSelection;
+
+/**
+ * Extracts the selected object (the element, or the value of a map) from a JSF DataModel.
+ *
+ * @author Gavin King
+ */
+public class DataModelSelector implements DataSelector<DataModelSelection, DataModel>
+{
+
+ public String getVariableName(DataModelSelection in)
+ {
+ return in.value();
+ }
+
+ public Object getSelection(DataModelSelection in, DataModel wrapper)
+ {
+ if ( wrapper.getRowCount()==0 || wrapper.getRowIndex()<0 )
+ {
+ return null;
+ }
+ else
+ {
+ Object rowData = wrapper.getRowData();
+ if (rowData instanceof Map.Entry)
+ {
+ return ( (Map.Entry) rowData ).getValue();
+ }
+ else
+ {
+ return rowData;
+ }
+ }
+ }
+
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataSelector.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataSelector.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataSelector.java 2009-04-29 03:35:21 UTC (rev 10690)
@@ -0,0 +1,18 @@
+package org.jboss.seam.faces.databinding;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * Allows extraction of the selected item
+ * from some "wrapper type".
+ *
+ * @author Gavin King
+ *
+ * @param <In> the annotation type
+ * @param <WrapperType> the wrapper type
+ */
+public interface DataSelector<In extends Annotation, WrapperType>
+{
+ String getVariableName(In in);
+ Object getSelection(In in, WrapperType wrapper);
+}
[View Less]
15 years, 10 months
Seam SVN: r10689 - in modules/trunk/security: src/main/java/org/jboss/seam/security and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-04-28 20:25:59 -0400 (Tue, 28 Apr 2009)
New Revision: 10689
Added:
modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java
Removed:
modules/trunk/security/src/main/java/org/jboss/seam/security/FacesSecurityEvents.java
Modified:
modules/trunk/security/pom.xml
Log:
renamed FacesSecurityEvents to SecurityEventMessages
Modified: modules/trunk/security/pom.xml
=======================================================…
[View More]============
--- modules/trunk/security/pom.xml 2009-04-28 22:45:14 UTC (rev 10688)
+++ modules/trunk/security/pom.xml 2009-04-29 00:25:59 UTC (rev 10689)
@@ -16,11 +16,11 @@
<dependencies>
<dependency>
- <groupId>org.jboss.webbeans</groupId>
+ <groupId>${webbeans.groupId}</groupId>
<artifactId>jsr299-api</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.webbeans</groupId>
+ <groupId>${webbeans.groupId}</groupId>
<artifactId>webbeans-logging</artifactId>
</dependency>
<dependency>
@@ -40,15 +40,19 @@
<artifactId>drools-core</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.seam</groupId>
+ <groupId>${seam.groupId}</groupId>
<artifactId>seam-drools</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.seam</groupId>
+ <groupId>${seam.groupId}</groupId>
<artifactId>seam-el</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.seam</groupId>
+ <groupId>${seam.groupId}</groupId>
+ <artifactId>seam-international</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${seam.groupId}</groupId>
<artifactId>seam-persistence</artifactId>
</dependency>
<dependency>
Deleted: modules/trunk/security/src/main/java/org/jboss/seam/security/FacesSecurityEvents.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/FacesSecurityEvents.java 2009-04-28 22:45:14 UTC (rev 10688)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/FacesSecurityEvents.java 2009-04-29 00:25:59 UTC (rev 10689)
@@ -1,95 +0,0 @@
-package org.jboss.seam.security;
-
-import javax.context.ApplicationScoped;
-import javax.event.Observes;
-import javax.security.auth.login.LoginException;
-
-import org.jboss.seam.international.StatusMessages;
-import org.jboss.seam.international.StatusMessage.Severity;
-import org.jboss.seam.security.events.AlreadyLoggedInEvent;
-import org.jboss.seam.security.events.LoggedInEvent;
-import org.jboss.seam.security.events.LoginFailedEvent;
-import org.jboss.seam.security.events.NotLoggedInEvent;
-import org.jboss.seam.security.events.PostAuthenticateEvent;
-
-/**
- * Produces FacesMessages in response of certain security events, and helps to decouple the
- * Identity component from JSF.
- *
- * @author Shane Bryzak
- */
-@ApplicationScoped
-public class FacesSecurityEvents
-{
- public void postAuthenticate(@Observes PostAuthenticateEvent event)
- {
- //org.jboss.security.saml.SSOManager.processManualLoginNotification(
- //ServletContexts.instance().getRequest(), identity.getPrincipal().getName());
- }
-
- public void addLoginFailedMessage(@Observes LoginFailedEvent event)
- {
- StatusMessages.instance().addFromResourceBundleOrDefault(
- getLoginFailedMessageSeverity(),
- getLoginFailedMessageKey(),
- getLoginFailedMessage(),
- event.getLoginException());
- }
-
- public String getLoginFailedMessage()
- {
- return "Login failed";
- }
-
- public Severity getLoginFailedMessageSeverity()
- {
- return Severity.INFO;
- }
-
- public String getLoginFailedMessageKey()
- {
- return "org.jboss.seam.loginFailed";
- }
-
- public void addLoginSuccessfulMessage(@Observes LoggedInEvent event)
- {
- StatusMessages.instance().addFromResourceBundleOrDefault(
- getLoginSuccessfulMessageSeverity(),
- getLoginSuccessfulMessageKey(),
- getLoginSuccessfulMessage(),
- Identity.instance().getCredentials().getUsername());
- }
-
- public void addNotLoggedInMessage(@Observes NotLoggedInEvent event)
- {
- StatusMessages.instance().addFromResourceBundleOrDefault(
- Severity.WARN,
- "org.jboss.seam.NotLoggedIn",
- "Please log in first"
- );
- }
-
- public Severity getLoginSuccessfulMessageSeverity()
- {
- return Severity.INFO;
- }
-
- public String getLoginSuccessfulMessage()
- {
- return "Welcome, #0";
- }
-
- public String getLoginSuccessfulMessageKey()
- {
- return "org.jboss.seam.loginSuccessful";
- }
-
- public void addAlreadyLoggedInMessage(@Observes AlreadyLoggedInEvent event)
- {
- StatusMessages.instance().addFromResourceBundleOrDefault (
- Severity.WARN,
- "org.jboss.seam.AlreadyLoggedIn",
- "You are already logged in, please log out first if you wish to log in again"
- );
- }
-}
Added: modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java 2009-04-29 00:25:59 UTC (rev 10689)
@@ -0,0 +1,95 @@
+package org.jboss.seam.security;
+
+import javax.context.ApplicationScoped;
+import javax.event.Observes;
+import javax.security.auth.login.LoginException;
+
+import org.jboss.seam.international.StatusMessages;
+import org.jboss.seam.international.StatusMessage.Severity;
+import org.jboss.seam.security.events.AlreadyLoggedInEvent;
+import org.jboss.seam.security.events.LoggedInEvent;
+import org.jboss.seam.security.events.LoginFailedEvent;
+import org.jboss.seam.security.events.NotLoggedInEvent;
+import org.jboss.seam.security.events.PostAuthenticateEvent;
+
+/**
+ * Produces FacesMessages in response of certain security events, and helps to decouple the
+ * Identity component from JSF.
+ *
+ * @author Shane Bryzak
+ */
+@ApplicationScoped
+public class SecurityEventMessages
+{
+ public void postAuthenticate(@Observes PostAuthenticateEvent event)
+ {
+ //org.jboss.security.saml.SSOManager.processManualLoginNotification(
+ //ServletContexts.instance().getRequest(), identity.getPrincipal().getName());
+ }
+
+ public void addLoginFailedMessage(@Observes LoginFailedEvent event)
+ {
+ StatusMessages.instance().addFromResourceBundleOrDefault(
+ getLoginFailedMessageSeverity(),
+ getLoginFailedMessageKey(),
+ getLoginFailedMessage(),
+ event.getLoginException());
+ }
+
+ public String getLoginFailedMessage()
+ {
+ return "Login failed";
+ }
+
+ public Severity getLoginFailedMessageSeverity()
+ {
+ return Severity.INFO;
+ }
+
+ public String getLoginFailedMessageKey()
+ {
+ return "org.jboss.seam.loginFailed";
+ }
+
+ public void addLoginSuccessfulMessage(@Observes LoggedInEvent event)
+ {
+ StatusMessages.instance().addFromResourceBundleOrDefault(
+ getLoginSuccessfulMessageSeverity(),
+ getLoginSuccessfulMessageKey(),
+ getLoginSuccessfulMessage(),
+ Identity.instance().getCredentials().getUsername());
+ }
+
+ public void addNotLoggedInMessage(@Observes NotLoggedInEvent event)
+ {
+ StatusMessages.instance().addFromResourceBundleOrDefault(
+ Severity.WARN,
+ "org.jboss.seam.NotLoggedIn",
+ "Please log in first"
+ );
+ }
+
+ public Severity getLoginSuccessfulMessageSeverity()
+ {
+ return Severity.INFO;
+ }
+
+ public String getLoginSuccessfulMessage()
+ {
+ return "Welcome, #0";
+ }
+
+ public String getLoginSuccessfulMessageKey()
+ {
+ return "org.jboss.seam.loginSuccessful";
+ }
+
+ public void addAlreadyLoggedInMessage(@Observes AlreadyLoggedInEvent event)
+ {
+ StatusMessages.instance().addFromResourceBundleOrDefault (
+ Severity.WARN,
+ "org.jboss.seam.AlreadyLoggedIn",
+ "You are already logged in, please log out first if you wish to log in again"
+ );
+ }
+}
[View Less]
15 years, 10 months
Seam SVN: r10688 - in branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks: entity and 2 other directories.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2009-04-28 18:45:14 -0400 (Tue, 28 Apr 2009)
New Revision: 10688
Removed:
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/UserHome.java
Modified:
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/Authenticator.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ContextHome.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/…
[View More]ResourceNotFoundException.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/TaskHome.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Context.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Task.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/User.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/UserResourceHome.java
branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/UserFactory.java
Log:
seam tasks example server part
Modified: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/Authenticator.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/Authenticator.java 2009-04-28 22:41:24 UTC (rev 10687)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/Authenticator.java 2009-04-28 22:45:14 UTC (rev 10688)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.example.tasks;
import javax.persistence.EntityManager;
@@ -4,10 +25,12 @@
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.example.tasks.entity.User;
+import org.jboss.seam.log.Log;
import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.Identity;
@@ -31,6 +54,8 @@
private EntityManager entityManager;
@Out(scope = ScopeType.SESSION)
private User user;
+ @Logger
+ private Log log;
public boolean authenticate()
{
@@ -39,6 +64,7 @@
{
if (user.isAdmin())
{
+ log.info("Admin rights granted for {0}", user.getUsername());
identity.addRole("admin");
}
return true;
Modified: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ContextHome.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ContextHome.java 2009-04-28 22:41:24 UTC (rev 10687)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ContextHome.java 2009-04-28 22:45:14 UTC (rev 10688)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.example.tasks;
import org.jboss.seam.annotations.AutoCreate;
@@ -5,6 +26,11 @@
import org.jboss.seam.example.tasks.entity.Context;
import org.jboss.seam.framework.EntityHome;
+/**
+ *
+ * @author Jozef Hartinger
+ *
+ */
@Name("contextHome")
@AutoCreate
public class ContextHome extends EntityHome<Context>
Modified: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ResourceNotFoundException.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ResourceNotFoundException.java 2009-04-28 22:41:24 UTC (rev 10687)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/ResourceNotFoundException.java 2009-04-28 22:45:14 UTC (rev 10688)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.example.tasks;
/**
Modified: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/TaskHome.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/TaskHome.java 2009-04-28 22:41:24 UTC (rev 10687)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/TaskHome.java 2009-04-28 22:45:14 UTC (rev 10688)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.example.tasks;
import org.jboss.seam.annotations.AutoCreate;
@@ -5,6 +26,11 @@
import org.jboss.seam.example.tasks.entity.Task;
import org.jboss.seam.framework.EntityHome;
+/**
+ *
+ * @author Jozef Hartinger
+ *
+ */
@Name("taskHome")
@AutoCreate
public class TaskHome extends EntityHome<Task>
Deleted: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/UserHome.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/UserHome.java 2009-04-28 22:41:24 UTC (rev 10687)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/UserHome.java 2009-04-28 22:45:14 UTC (rev 10688)
@@ -1,13 +0,0 @@
-package org.jboss.seam.example.tasks;
-
-import org.jboss.seam.annotations.AutoCreate;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.example.tasks.entity.User;
-import org.jboss.seam.framework.EntityHome;
-
-@Name("userHome")
-@AutoCreate
-public class UserHome extends EntityHome<User>
-{
-
-}
Modified: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Context.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Context.java 2009-04-28 22:41:24 UTC (rev 10687)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Context.java 2009-04-28 22:45:14 UTC (rev 10688)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.example.tasks.entity;
import java.util.List;
@@ -16,6 +37,11 @@
import org.hibernate.validator.NotNull;
+/**
+ *
+ * @author Jozef Hartinger
+ *
+ */
@Entity
@XmlRootElement
@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "NAME", "OWNER_USERNAME" }))
Modified: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Task.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Task.java 2009-04-28 22:41:24 UTC (rev 10687)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/Task.java 2009-04-28 22:45:14 UTC (rev 10688)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.example.tasks.entity;
import java.util.Date;
@@ -16,6 +37,11 @@
import org.hibernate.validator.NotNull;
+/**
+ *
+ * @author Jozef Hartinger
+ *
+ */
@Entity
@XmlRootElement
@NamedQuery(name="taskByNameAndContext", query="select task from Task task where task.name like :task and task.context.id = :context")
Modified: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/User.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/User.java 2009-04-28 22:41:24 UTC (rev 10687)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/entity/User.java 2009-04-28 22:45:14 UTC (rev 10688)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.example.tasks.entity;
import java.util.List;
@@ -10,6 +31,11 @@
import org.hibernate.validator.NotNull;
+/**
+ *
+ * @author Jozef Hartinger
+ *
+ */
@Entity
@XmlRootElement
public class User
Modified: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/UserResourceHome.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/UserResourceHome.java 2009-04-28 22:41:24 UTC (rev 10687)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/resource/UserResourceHome.java 2009-04-28 22:45:14 UTC (rev 10688)
@@ -25,8 +25,7 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.security.Admin;
-import org.jboss.seam.example.tasks.UserHome;
+import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.example.tasks.entity.User;
import org.jboss.seam.framework.EntityHome;
import org.jboss.seam.resteasy.ResourceHome;
@@ -41,7 +40,7 @@
*/
@Path("/auth/user")
@Name("userResourceHome")
-@Admin
+@Restrict("#{s:hasRole('admin')}")
public class UserResourceHome extends ResourceHome<User, String>
{
@@ -50,8 +49,8 @@
setMediaTypes(new String[] { "application/xml", "application/json", "application/fastinfoset" });
}
- @In
- private UserHome userHome;
+ @In()
+ private EntityHome<User> userHome;
@Override
public EntityHome getEntityHome()
Modified: branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/UserFactory.java
===================================================================
--- branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/UserFactory.java 2009-04-28 22:41:24 UTC (rev 10687)
+++ branches/community/Seam_2_1/examples/tasks/src/main/org/jboss/seam/example/tasks/test/UserFactory.java 2009-04-28 22:45:14 UTC (rev 10688)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.seam.example.tasks.test;
import org.jboss.seam.annotations.Factory;
@@ -3,6 +24,6 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
-import org.jboss.seam.example.tasks.UserHome;
import org.jboss.seam.example.tasks.entity.User;
+import org.jboss.seam.framework.EntityHome;
/**
@@ -16,7 +37,7 @@
public class UserFactory
{
- @In private UserHome userHome;
+ @In private EntityHome<User> userHome;
@Factory(autoCreate=true, value="user")
public User getDemo() {
[View Less]
15 years, 10 months
Seam SVN: r10687 - branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2009-04-28 18:41:24 -0400 (Tue, 28 Apr 2009)
New Revision: 10687
Modified:
branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test/ResourceQueryTest.java
Log:
fixed ResourceQueryTest
Modified: branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test/ResourceQueryTest.java
===================================================================
--- branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/…
[View More]example/restbay/test/ResourceQueryTest.java 2009-04-28 22:10:04 UTC (rev 10686)
+++ branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test/ResourceQueryTest.java 2009-04-28 22:41:24 UTC (rev 10687)
@@ -42,7 +42,7 @@
@Override
protected void onResponse(MockHttpServletResponse response)
{
- String expectedResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><resteasy:collection xmlns:resteasy=\"http://jboss.org/resteasy\"><category><categoryId>3</categoryId><name>Books</name></category><category><categoryId>4</categoryId><name>Cameras and Photography</name></category></resteasy:collection>";
+ String expectedResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><collection><category><categoryId>3</categoryId><name>Books</name></category><category><categoryId>4</categoryId><name>Cameras and Photography</name></category></collection>";
assertEquals(response.getContentAsString(), expectedResponse, "Unexpected response.");
}
[View Less]
15 years, 10 months
Seam SVN: r10686 - branches/community/Seam_2_1/src/main/org/jboss/seam/navigation.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2009-04-28 18:10:04 -0400 (Tue, 28 Apr 2009)
New Revision: 10686
Modified:
branches/community/Seam_2_1/src/main/org/jboss/seam/navigation/Pages.java
Log:
JBSEAM-4130
Modified: branches/community/Seam_2_1/src/main/org/jboss/seam/navigation/Pages.java
===================================================================
--- branches/community/Seam_2_1/src/main/org/jboss/seam/navigation/Pages.java 2009-04-28 21:45:28 UTC (rev 10685)
+++ branches/…
[View More]community/Seam_2_1/src/main/org/jboss/seam/navigation/Pages.java 2009-04-28 22:10:04 UTC (rev 10686)
@@ -736,10 +736,12 @@
{
if ( !overridden.contains( pageParameter.getName() ) )
{
- String value;
+ String value = null;
if ( pageParameter.getValueExpression()==null )
- {
- value = (String) Contexts.getPageContext().get( pageParameter.getName() );
+ {
+ if (Contexts.isPageContextActive()) {
+ value = (String) Contexts.getPageContext().get(pageParameter.getName());
+ }
}
else
{
[View Less]
15 years, 10 months