Author: alexsmirnov
Date: 2010-10-28 16:31:56 -0400 (Thu, 28 Oct 2010)
New Revision: 19748
Added:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/el/
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/el/ValueDescriptor.java
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/el/ValueExpressionAnalayser.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/CapturingELContext.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/ValueExpressionAnalayserImpl.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/ValueReference.java
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/ELTestBase.java
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/TestCaptureEL.java
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/ValueExpressionAnalayserTest.java
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/model/
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/model/Bean.java
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/model/Person.java
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/BeanValidatorServiceConstrainsTest.java
Modified:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/BeanValidatorService.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorBehavior.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetValidatorTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
Log:
CODING IN PROGRESS - issue RF-9510: BeanValidatorService tests and implementation
https://jira.jboss.org/browse/RF-9510
Added:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/el/ValueDescriptor.java
===================================================================
--- branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/el/ValueDescriptor.java
(rev 0)
+++
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/el/ValueDescriptor.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -0,0 +1,111 @@
+/**
+ *
+ */
+package org.richfaces.el;
+
+/**
+ * This class describes bean property.
+ * @author asmirnov
+ *
+ */
+public class ValueDescriptor {
+
+ private final String name;
+
+ private final boolean readOnly;
+
+ private final Class<?> beanType;
+
+ private final Class<?> propertyType;
+
+ /**
+ * @param beanType
+ * @param name
+ * @param propertyType
+ * @param readOnly
+ */
+ ValueDescriptor(Class<?> beanType, String name, Class<?> propertyType,
boolean readOnly) {
+ this.beanType = beanType;
+ this.name = name;
+ this.propertyType = propertyType;
+ this.readOnly = readOnly;
+ }
+
+ ValueDescriptor(Class<?> beanType, String name) {
+ this(beanType,name,Object.class,false);
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the readOnly
+ */
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ /**
+ * @return the beanType
+ */
+ public Class<?> getBeanType() {
+ return beanType;
+ }
+
+ /**
+ * @return the propertyType
+ */
+ public Class<?> getPropertyType() {
+ return propertyType;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((beanType == null) ? 0 : beanType.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ValueDescriptor other = (ValueDescriptor) obj;
+ if (beanType == null) {
+ if (other.beanType != null) {
+ return false;
+ }
+ } else if (!beanType.equals(other.beanType)) {
+ return false;
+ }
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ return true;
+ }
+
+
+}
Property changes on:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/el/ValueDescriptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/el/ValueExpressionAnalayser.java
===================================================================
---
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/el/ValueExpressionAnalayser.java
(rev 0)
+++
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/el/ValueExpressionAnalayser.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -0,0 +1,18 @@
+/**
+ *
+ */
+package org.richfaces.el;
+
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+
+/**
+ * Implementation of this interface extract information about bean property from
EL-expression.
+ * @author asmirnov
+ *
+ */
+public interface ValueExpressionAnalayser {
+
+ ValueDescriptor getPropertyDescriptor(FacesContext context, ValueExpression
expression);
+
+}
Property changes on:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/el/ValueExpressionAnalayser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/BeanValidatorService.java
===================================================================
---
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/BeanValidatorService.java 2010-10-28
19:11:02 UTC (rev 19747)
+++
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/BeanValidatorService.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -19,9 +19,9 @@
* @param expression
* @return
*/
- Collection<FacesObjectDescriptor> getConstrains(FacesContext context,
ValueExpression expression,Class<?> ...groups);
+ Collection<ValidatorDescriptor> getConstrains(FacesContext context,
ValueExpression expression,Class<?> ...groups);
- Collection<String> validateExpression(FacesContext context,ValueExpression
expression, Object newValue,Class<?> ...groups);
+// Collection<String> validateExpression(FacesContext context,ValueExpression
expression, Object newValue,Class<?> ...groups);
- Collection<String> validateObject(FacesContext context,Object object, Object
newValue,Class<?> ...groups);
+// Collection<String> validateObject(FacesContext context,Object object, Object
newValue,Class<?> ...groups);
}
Added:
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/CapturingELContext.java
===================================================================
---
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/CapturingELContext.java
(rev 0)
+++
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/CapturingELContext.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -0,0 +1,141 @@
+/**
+ *
+ */
+package org.richfaces.el;
+
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+import java.util.Locale;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.FunctionMapper;
+import javax.el.VariableMapper;
+
+/**
+ * This class wraps original ELContext and capture whole call stack to the target object
so it could be used to extract
+ * semantic information like annotations or Jena Model properties.
+ *
+ * @author asmirnov
+ *
+ */
+public class CapturingELContext extends ELContext {
+
+ private final ELContext parent;
+
+ private ValueReference reference = null;
+
+ private final InterceptingResolver resolver;
+
+ public CapturingELContext(ELContext parent) {
+ this.parent = parent;
+ resolver = new InterceptingResolver(parent.getELResolver());
+ }
+
+ public ValueReference getReference() {
+ return reference;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ELContext#getELResolver()
+ */
+ @Override
+ public ELResolver getELResolver() {
+ return resolver;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object getContext(Class key) {
+ return parent.getContext(key);
+ }
+
+ @Override
+ public FunctionMapper getFunctionMapper() {
+ return parent.getFunctionMapper();
+ }
+
+ @Override
+ public Locale getLocale() {
+ return parent.getLocale();
+ }
+
+ @Override
+ public VariableMapper getVariableMapper() {
+ return parent.getVariableMapper();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void putContext(Class key, Object contextObject) {
+ parent.putContext(key, contextObject);
+ }
+
+ @Override
+ public void setLocale(Locale locale) {
+ parent.setLocale(locale);
+ }
+
+ /**
+ * This resolver records all intermediate objects from the EL-expression that can be
used to detect Semantic Beans
+ * annotations or Jena Model properties.
+ *
+ * @author asmirnov
+ *
+ */
+ private final class InterceptingResolver extends ELResolver {
+
+ private ELResolver delegate;
+
+ public InterceptingResolver(ELResolver delegate) {
+ this.delegate = delegate;
+ }
+
+ // Capture the base and property rather than write the value
+ @Override
+ public void setValue(ELContext context, Object base, Object property, Object
value) {
+ if (base != null) {
+ context.setPropertyResolved(true);
+ reference = new ValueReference(base, property, reference);
+ }
+ }
+
+ // The rest of the methods simply delegate to the existing context
+
+ @Override
+ public Object getValue(ELContext context, Object base, Object property) {
+ // Null value for the base means new properties chain.
+ // TODO - record each chain to the separate collection for compound
expressions.
+ reference = new ValueReference(base, property, reference);
+ return delegate.getValue(context, base, property);
+ }
+
+ @Override
+ public Class<?> getType(ELContext context, Object base, Object property) {
+ if (base != null) {
+ context.setPropertyResolved(true);
+ reference = new ValueReference(base, property, reference);
+ }
+ return Object.class;
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property) {
+ return delegate.isReadOnly(context, base, property);
+ }
+
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
Object base) {
+ return delegate.getFeatureDescriptors(context, base);
+ }
+
+ @Override
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ return delegate.getCommonPropertyType(context, base);
+ }
+
+ }
+
+}
Property changes on:
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/CapturingELContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added:
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/ValueExpressionAnalayserImpl.java
===================================================================
---
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/ValueExpressionAnalayserImpl.java
(rev 0)
+++
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/ValueExpressionAnalayserImpl.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -0,0 +1,20 @@
+package org.richfaces.el;
+
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+
+public class ValueExpressionAnalayserImpl implements ValueExpressionAnalayser {
+
+ public ValueDescriptor getPropertyDescriptor(FacesContext context, ValueExpression
expression) {
+ CapturingELContext capturingContext = new
CapturingELContext(context.getELContext());
+ expression.getType(capturingContext);
+ ValueReference reference = capturingContext.getReference();
+ if(null != reference && null != reference.getBase() && null !=
reference.getProperty()){
+ // TODO - detect arrays, maps and lists. Check JSF implementation code -
seems that Mojarra dosn't validate such fields.
+ ValueDescriptor descriptor = new
ValueDescriptor(reference.getBase().getClass(),reference.getProperty().toString());
+ return descriptor;
+ }
+ return null;
+ }
+
+}
Property changes on:
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/ValueExpressionAnalayserImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added:
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/ValueReference.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/ValueReference.java
(rev 0)
+++
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/ValueReference.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -0,0 +1,37 @@
+/**
+ *
+ */
+package org.richfaces.el;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ValueReference {
+ private final Object base;
+ private final Object property;
+ private final ValueReference parent;
+
+ public ValueReference(Object base, Object property, ValueReference parent) {
+ this.base = base;
+ this.property = property;
+ this.parent = parent;
+ }
+
+ public Object getBase() {
+ return base;
+ }
+
+ public Object getProperty() {
+ return property;
+ }
+
+ public boolean hasNext() {
+ return null != parent;
+ }
+
+ public ValueReference next() {
+ return parent;
+ }
+
+}
Property changes on:
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/ValueReference.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/ELTestBase.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/ELTestBase.java
(rev 0)
+++
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/ELTestBase.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -0,0 +1,143 @@
+package org.richfaces.el;
+
+import java.beans.FeatureDescriptor;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.el.BeanELResolver;
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.FunctionMapper;
+import javax.el.ListELResolver;
+import javax.el.MapELResolver;
+import javax.el.ValueExpression;
+import javax.el.VariableMapper;
+
+import org.jboss.el.ExpressionFactoryImpl;
+import org.junit.After;
+import org.junit.Before;
+import org.richfaces.el.model.Bean;
+import org.richfaces.el.model.Person;
+
+import com.google.common.collect.Iterators;
+
+public class ELTestBase {
+
+ class DummyELResolver extends ELResolver {
+
+ private final ELResolver beanResolver = new BeanELResolver();
+ private final ELResolver mapResolver = new MapELResolver();
+ private final ELResolver listResolver = new ListELResolver();
+
+ @Override
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ return String.class;
+ }
+
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
Object base) {
+ return Iterators.emptyIterator();
+ }
+
+ @Override
+ public Class<?> getType(ELContext context, Object base, Object property) {
+ if (null == base) {
+ if ("bean".equals(property)) {
+ return Bean.class;
+ } else if ("person".equals(property)) {
+ return Person.class;
+ }
+ } else if (base instanceof List) {
+ return listResolver.getType(context, base, property);
+ } else if (base instanceof Map) {
+ return mapResolver.getType(context, base, property);
+ }
+ return beanResolver.getType(context, base, property);
+ }
+
+ @Override
+ public Object getValue(ELContext context, Object base, Object property) {
+ if (null == base) {
+ if ("bean".equals(property)) {
+ return bean;
+ } else if ("person".equals(property)) {
+ return person;
+ }
+ } else if (base instanceof List) {
+ return listResolver.getValue(context, base, property);
+ } else if (base instanceof Map) {
+ return mapResolver.getValue(context, base, property);
+ }
+ return beanResolver.getValue(context, base, property);
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property) {
+ return true;
+ }
+
+ @Override
+ public void setValue(ELContext context, Object base, Object property, Object
value) {
+ // do nothing
+
+ }
+
+ }
+
+ class DummyELContext extends ELContext {
+
+ @Override
+ public ELResolver getELResolver() {
+ return elResolver;
+ }
+
+ @Override
+ public FunctionMapper getFunctionMapper() {
+ return null;
+ }
+
+ @Override
+ public VariableMapper getVariableMapper() {
+ return null;
+ }
+
+ }
+
+ protected ExpressionFactoryImpl expressionFactory;
+ protected Bean bean;
+ protected ELResolver elResolver;
+ protected ELContext elContext;
+ protected CapturingELContext capturingELContext;
+ protected Person person;
+
+ @Before
+ public void setUp() throws Exception {
+ expressionFactory = new ExpressionFactoryImpl();
+ bean = new Bean();
+ person = new Person();
+ bean.setString("foo");
+ ArrayList<String> list = new ArrayList<String>(1);
+ list.add("bar");
+ bean.setList(list);
+ HashMap<String, String> map = new HashMap<String, String>();
+ map.put("boo", "baz");
+ bean.setMap(map);
+ elResolver = new DummyELResolver();
+ elContext = new DummyELContext();
+ capturingELContext = new CapturingELContext(elContext);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ expressionFactory = null;
+ }
+
+ protected ValueExpression parse(String expressionString) {
+ ValueExpression expression = expressionFactory.createValueExpression(elContext,
expressionString, String.class);
+ return expression;
+ }
+
+}
Property changes on:
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/ELTestBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added:
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/TestCaptureEL.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/TestCaptureEL.java
(rev 0)
+++
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/TestCaptureEL.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -0,0 +1,61 @@
+package org.richfaces.el;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+
+import javax.el.ValueExpression;
+
+import org.jboss.test.faces.mock.MockTestRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(MockTestRunner.class)
+public class TestCaptureEL extends ELTestBase {
+
+ @Test
+ public void testDummyResolverString() throws Exception {
+ ValueExpression expression = parse("#{bean.string}");
+ assertEquals("foo", expression.getValue(elContext));
+ }
+
+ @Test
+ public void testDummyResolverList() throws Exception {
+ ValueExpression expression = parse("#{bean.list[0]}");
+ assertEquals("bar", expression.getValue(elContext));
+ }
+
+ @Test
+ public void testDummyResolverMap() throws Exception {
+ ValueExpression expression = parse("#{bean.map['boo']}");
+ assertEquals("baz", expression.getValue(elContext));
+ }
+
+ @Test
+ public void captureString() throws Exception {
+ ValueExpression expression = parse("#{bean.string}");
+ expression.getType(capturingELContext);
+ ValueReference reference = capturingELContext.getReference();
+ assertEquals("string", reference.getProperty());
+ assertSame(bean, reference.getBase());
+ reference = reference.next();
+ assertNotNull(reference);
+ assertEquals("bean", reference.getProperty());
+ assertNull(reference.getBase());
+ assertNull(reference.next());
+ }
+
+ @Test
+ public void captureMap() throws Exception {
+ ValueExpression expression = parse("#{bean.map['boo']}");
+ expression.getType(capturingELContext);
+ ValueReference reference = capturingELContext.getReference();
+ assertEquals("boo", reference.getProperty());
+ assertSame(bean.getMap(), reference.getBase());
+ reference = reference.next();
+ assertNotNull(reference);
+ assertEquals("map", reference.getProperty());
+ }
+
+}
Property changes on:
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/TestCaptureEL.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added:
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/ValueExpressionAnalayserTest.java
===================================================================
---
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/ValueExpressionAnalayserTest.java
(rev 0)
+++
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/ValueExpressionAnalayserTest.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -0,0 +1,17 @@
+package org.richfaces.el;
+
+
+import org.junit.After;
+import org.junit.Before;
+
+public class ValueExpressionAnalayserTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+}
Property changes on:
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/ValueExpressionAnalayserTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/model/Bean.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/model/Bean.java
(rev 0)
+++
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/model/Bean.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -0,0 +1,39 @@
+package org.richfaces.el.model;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class Bean {
+
+ private List<String> list;
+
+ private Map<String, String> map = new HashMap<String, String>();
+
+ private String string;
+
+ public List<String> getList() {
+ return list;
+ }
+
+ public void setList(List<String> list) {
+ this.list = list;
+ }
+
+ public Map<String, String> getMap() {
+ return map;
+ }
+
+ public void setMap(Map<String, String> map) {
+ this.map = map;
+ }
+
+ public String getString() {
+ return string;
+ }
+
+ public void setString(String string) {
+ this.string = string;
+ }
+
+}
Property changes on:
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/model/Bean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added:
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/model/Person.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/model/Person.java
(rev 0)
+++
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/model/Person.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -0,0 +1,98 @@
+/**
+ *
+ */
+package org.richfaces.el.model;
+
+import java.net.URI;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class Person {
+
+ public static final String FOO_BAR = "http://foo.bar/baz#";
+
+ public static final String FOAF = "http://xmlns.com/foaf/0.1/";
+ private String id;
+
+ private Collection<URI> emailAddress;
+
+ private String name;
+
+ private String dummy;
+
+ private Double account;
+
+ private String string;
+
+ private String property;
+
+ private Map<Integer, Object> options;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Collection<URI> getEmailAddress() {
+ return emailAddress;
+ }
+
+ public void setEmailAddress(Collection<URI> email) {
+ this.emailAddress = email;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Double getAccount() {
+ return account;
+ }
+
+ public void setAccount(Double account) {
+ this.account = account;
+ }
+
+ public String getDummy() {
+ return dummy;
+ }
+
+ public void setDummy(String dummy) {
+ this.dummy = dummy;
+ }
+
+ public void setString(String string) {
+ this.string = string;
+ }
+
+ public String getString() {
+ return string;
+ }
+
+ public void setProperty(String property) {
+ this.property = property;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ public void setOptions(Map<Integer, Object> options) {
+ this.options = options;
+ }
+
+ public Map<Integer, Object> getOptions() {
+ return options;
+ }
+}
Property changes on:
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/el/model/Person.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added:
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/BeanValidatorServiceConstrainsTest.java
===================================================================
---
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/BeanValidatorServiceConstrainsTest.java
(rev 0)
+++
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/BeanValidatorServiceConstrainsTest.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -0,0 +1,17 @@
+package org.richfaces.validator;
+
+
+import org.junit.After;
+import org.junit.Before;
+
+public class BeanValidatorServiceConstrainsTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+}
Property changes on:
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/BeanValidatorServiceConstrainsTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorBehavior.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorBehavior.java 2010-10-28
19:11:02 UTC (rev 19747)
+++
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorBehavior.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -6,7 +6,7 @@
import javax.faces.component.behavior.ClientBehaviorContext;
import org.richfaces.validator.ConverterDescriptor;
-import org.richfaces.validator.FacesObjectDescriptor;
+import org.richfaces.validator.ValidatorDescriptor;
/**
* <p class="changed_added_4_0">Interface for JSF Behavior that creates
scripts for client-side validation</p>
@@ -39,7 +39,7 @@
* @param context
* @return
*/
- Collection<FacesObjectDescriptor> getValidators(ClientBehaviorContext
context);
+ Collection<ValidatorDescriptor> getValidators(ClientBehaviorContext context);
/**
* <p class="changed_added_4_0">Returns array of classes that
represents JSR-303 validation groups.</p>
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java 2010-10-28
19:11:02 UTC (rev 19747)
+++
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -22,7 +22,6 @@
*/
package org.richfaces.component.behavior;
-import java.util.ArrayList;
import java.util.Collection;
import javax.el.ValueExpression;
@@ -48,7 +47,7 @@
import org.richfaces.validator.ConverterDescriptor;
import org.richfaces.validator.FacesConverterService;
import org.richfaces.validator.FacesValidatorService;
-import org.richfaces.validator.FacesObjectDescriptor;
+import org.richfaces.validator.ValidatorDescriptor;
import com.google.common.collect.Lists;
@@ -177,10 +176,10 @@
* @see
org.richfaces.component.behavior.ClientValidatorBehavior#getValidators(javax.faces.component.behavior.
* ClientBehaviorContext)
*/
- public Collection<FacesObjectDescriptor> getValidators(ClientBehaviorContext
context) {
+ public Collection<ValidatorDescriptor> getValidators(ClientBehaviorContext
context) {
UIComponent component = context.getComponent();
if (component instanceof EditableValueHolder) {
- ArrayList<FacesObjectDescriptor> validators = Lists.newArrayList();
+ Collection<ValidatorDescriptor> validators = Lists.newArrayList();
EditableValueHolder input = (EditableValueHolder) component;
Validator[] facesValidators = input.getValidators();
FacesContext facesContext = context.getFacesContext();
Modified:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetValidatorTest.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetValidatorTest.java 2010-10-28
19:11:02 UTC (rev 19747)
+++
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetValidatorTest.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -22,7 +22,6 @@
import org.richfaces.application.ServiceTracker;
import org.richfaces.validator.BeanValidatorService;
import org.richfaces.validator.FacesValidatorService;
-import org.richfaces.validator.FacesObjectDescriptor;
import org.richfaces.validator.ValidatorDescriptor;
import com.google.common.collect.Iterables;
@@ -48,7 +47,7 @@
private Validator validator;
@Mock
- private FacesObjectDescriptor beanValidatorDescriptor;
+ private ValidatorDescriptor beanValidatorDescriptor;
@Mock
private BeanValidatorService validatorService;
@@ -89,14 +88,14 @@
controller.verify();
}
- private Collection<FacesObjectDescriptor> checkValidator() {
+ private Collection<ValidatorDescriptor> checkValidator() {
controller.replay();
- Collection<FacesObjectDescriptor> validators =
behavior.getValidators(behaviorContext);
+ Collection<ValidatorDescriptor> validators =
behavior.getValidators(behaviorContext);
// controller.verify();
return validators;
}
- private void setupBeanValidator(FacesObjectDescriptor... validators) {
+ private void setupBeanValidator(ValidatorDescriptor... validators) {
expect(validatorService.getConstrains(environment.getFacesContext(), expression,
DEFAULT_GROUP)).andStubReturn(
Lists.newArrayList(validators));
@@ -124,9 +123,9 @@
public void testComponentValidator() throws Exception {
setupComponentValidator(validator);
setupBeanValidator();
- Collection<FacesObjectDescriptor> validators = checkValidator();
+ Collection<ValidatorDescriptor> validators = checkValidator();
assertEquals(1, validators.size());
- FacesObjectDescriptor validatorDescriptor =
Iterables.getOnlyElement(validators);
+ ValidatorDescriptor validatorDescriptor = Iterables.getOnlyElement(validators);
assertSame(validator.getClass(), validatorDescriptor.getImplementationClass());
assertEquals(VALIDATION_ERROR, validatorDescriptor.getMessage());
controller.verify();
@@ -136,9 +135,9 @@
public void testBeanValidators() throws Exception {
setupComponentValidator();
setupBeanValidator(beanValidatorDescriptor);
- Collection<FacesObjectDescriptor> validators = checkValidator();
+ Collection<ValidatorDescriptor> validators = checkValidator();
assertEquals(1, validators.size());
- FacesObjectDescriptor validatorDescriptor =
Iterables.getOnlyElement(validators);
+ ValidatorDescriptor validatorDescriptor = Iterables.getOnlyElement(validators);
assertSame(beanValidatorDescriptor, validatorDescriptor);
controller.verify();
}
Modified:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-10-28
19:11:02 UTC (rev 19747)
+++
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-10-28
20:31:56 UTC (rev 19748)
@@ -28,11 +28,12 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.validator.ConverterDescriptor;
+import org.richfaces.validator.FacesObjectDescriptor;
+import org.richfaces.validator.LibraryFunction;
import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryFunction;
import org.richfaces.validator.LibraryScriptString;
import org.richfaces.validator.ScriptNotFoundException;
-import org.richfaces.validator.FacesObjectDescriptor;
+import org.richfaces.validator.ValidatorDescriptor;
import com.google.common.collect.Lists;
@@ -254,9 +255,9 @@
} else {
expect(mockBehavior.getConverter(behaviorContext)).andStubReturn(null);
}
- ArrayList<FacesObjectDescriptor> validatorDescriptors = new
ArrayList<FacesObjectDescriptor>(validators.length);
+ Collection<ValidatorDescriptor> validatorDescriptors = new
ArrayList<ValidatorDescriptor>(validators.length);
for (Class<?> validator : validators) {
- FacesObjectDescriptor validatorDescriptor =
controller.createNiceMock(FacesObjectDescriptor.class);
+ ValidatorDescriptor validatorDescriptor =
controller.createNiceMock(ValidatorDescriptor.class);
setupDescription(validator, validatorDescriptor);
validatorDescriptors.add(validatorDescriptor);
}