Author: alexsmirnov
Date: 2011-02-25 15:48:14 -0500 (Fri, 25 Feb 2011)
New Revision: 21943
Modified:
branches/4.0.0.CR1/ui/validator/api/src/main/java/org/richfaces/validator/FacesConverterService.java
branches/4.0.0.CR1/ui/validator/api/src/main/java/org/richfaces/validator/FacesValidatorService.java
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/validator/ConverterServiceImpl.java
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/validator/FacesServiceBase.java
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java
branches/4.0.0.CR1/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetConverterTest.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetValidatorTest.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ConverterTestBase.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LengthValidatorTest.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/ValidatorTestBase.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/validator/FacesConverterServiceTest.java
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/validator/FacesValidatorServiceTest.java
Log:
RESOLVED - issue RF-10268: CSV: ValidateLength works wrong without maximum specified
https://issues.jboss.org/browse/RF-10268
https://issues.jboss.org/browse/RF-10611
https://issues.jboss.org/browse/RF-10434
Modified:
branches/4.0.0.CR1/ui/validator/api/src/main/java/org/richfaces/validator/FacesConverterService.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/api/src/main/java/org/richfaces/validator/FacesConverterService.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/api/src/main/java/org/richfaces/validator/FacesConverterService.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -1,5 +1,6 @@
package org.richfaces.validator;
+import javax.faces.component.EditableValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
@@ -11,6 +12,6 @@
*/
public interface FacesConverterService {
- ConverterDescriptor getConverterDescription(FacesContext context,Converter
converter);
+ ConverterDescriptor getConverterDescription(FacesContext context,EditableValueHolder
input, Converter converter);
}
Modified:
branches/4.0.0.CR1/ui/validator/api/src/main/java/org/richfaces/validator/FacesValidatorService.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/api/src/main/java/org/richfaces/validator/FacesValidatorService.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/api/src/main/java/org/richfaces/validator/FacesValidatorService.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -1,10 +1,11 @@
package org.richfaces.validator;
+import javax.faces.component.EditableValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
public interface FacesValidatorService {
- ValidatorDescriptor getValidatorDescription(FacesContext context,Validator
validator);
+ ValidatorDescriptor getValidatorDescription(FacesContext context,EditableValueHolder
component, Validator validator);
}
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -245,7 +245,7 @@
}
if(null != converter){
FacesConverterService converterService =
ServiceTracker.getService(facesContext, FacesConverterService.class);
- return converterService.getConverterDescription(facesContext,
converter);
+ return converterService.getConverterDescription(facesContext, input,
converter);
} else {
return null;
}
@@ -293,7 +293,7 @@
validators.addAll(beanValidatorService.getConstrains(facesContext, valueExpression,
getGroups()));
}
} else {
-
validators.add(facesValidatorService.getValidatorDescription(facesContext, validator));
+
validators.add(facesValidatorService.getValidatorDescription(facesContext, input,
validator));
}
}
}
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/validator/ConverterServiceImpl.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/validator/ConverterServiceImpl.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/validator/ConverterServiceImpl.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -5,6 +5,7 @@
import javax.faces.application.FacesMessage;
+import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.convert.BigDecimalConverter;
@@ -37,9 +38,9 @@
* @see
org.richfaces.validator.FacesConverterService#getConverterDescription(javax.faces.context.FacesContext,
* javax.faces.convert.Converter)
*/
- public ConverterDescriptor getConverterDescription(FacesContext context, Converter
converter) {
+ public ConverterDescriptor getConverterDescription(FacesContext context,
EditableValueHolder input, Converter converter) {
// determine converter message.
- FacesMessage message = getMessage(context, converter);
+ FacesMessage message = getMessage(context, converter, input);
ConverterDescriptorImpl descriptor = new
ConverterDescriptorImpl(converter.getClass(), message);
fillParameters(descriptor, converter);
descriptor.makeImmutable();
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/validator/FacesServiceBase.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/validator/FacesServiceBase.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/validator/FacesServiceBase.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -7,6 +7,8 @@
import java.lang.reflect.InvocationTargetException;
import javax.faces.application.FacesMessage;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import com.google.common.collect.ImmutableSet;
@@ -50,11 +52,23 @@
*
* @param context
* @param component
+ * @param input TODO
* @return
*/
- public FacesMessage getMessage(FacesContext context, T component) {
+ public FacesMessage getMessage(FacesContext context, T component, EditableValueHolder
input) {
String messageId = getMessageId(component);
return MessageFactory.createMessage(context, messageId);
}
+
+ protected void setLabelParameter(EditableValueHolder input, FacesValidatorDescriptor
descriptor) {
+ if (input instanceof UIComponent) {
+ UIComponent component = (UIComponent) input;
+ Object label = component.getAttributes().get("label");
+ if(null!=label){
+ descriptor.addParameter("label", label);
+ }
+ }
+ }
+
}
\ No newline at end of file
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -4,6 +4,7 @@
package org.richfaces.validator;
import javax.faces.application.FacesMessage;
+import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.validator.DoubleRangeValidator;
@@ -19,15 +20,20 @@
*/
public class FacesValidatorServiceImpl extends FacesServiceBase<Validator>
implements FacesValidatorService {
+ private static final String PATTERN = "pattern";
+ private static final String MINIMUM = "min";
+ private static final String MAXIMUM = "max";
+
/*
* (non-Javadoc)
*
* @see
org.richfaces.validator.FacesValidatorService#getValidatorDescription(javax.faces.context.FacesContext,
* javax.faces.validator.Validator)
*/
- public ValidatorDescriptor getValidatorDescription(FacesContext context, Validator
validator) {
- FacesMessage message = getMessage(context, validator);
+ public ValidatorDescriptor getValidatorDescription(FacesContext context,
EditableValueHolder input, Validator validator) {
+ FacesMessage message = getMessage(context, validator, input);
FacesValidatorDescriptor descriptor = new
FacesValidatorDescriptor(validator.getClass(), message);
+ setLabelParameter(input, descriptor);
fillParameters(descriptor, validator);
descriptor.makeImmutable();
return descriptor;
@@ -39,7 +45,7 @@
String messageId;
if (component instanceof DoubleRangeValidator) {
DoubleRangeValidator validator = (DoubleRangeValidator) component;
- if(validator.getMaximum() > Double.MIN_VALUE){
+ if(validator.getMaximum() < Double.MAX_VALUE){
if(validator.getMinimum()> Double.MIN_VALUE){
messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
} else {
@@ -65,13 +71,13 @@
}
} else if (component instanceof LongRangeValidator) {
LongRangeValidator validator = (LongRangeValidator) component;
- if(validator.getMaximum() >0){
- if(validator.getMinimum()>0){
+ if(validator.getMaximum() !=0){
+ if(validator.getMinimum()!=0){
messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
} else {
messageId = LongRangeValidator.MAXIMUM_MESSAGE_ID;
}
- } else if( validator.getMinimum()>0){
+ } else if( validator.getMinimum()!=0){
messageId = LongRangeValidator.MINIMUM_MESSAGE_ID;
} else {
messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;// What to use
for that case ( no min/max set, validator always pass ).
@@ -86,4 +92,40 @@
return messageId;
}
+ @Override
+ protected void fillParameters(BaseFacesObjectDescriptor<Validator> descriptor,
Validator component) {
+ if (component instanceof DoubleRangeValidator) {
+ DoubleRangeValidator validator = (DoubleRangeValidator) component;
+ if(validator.getMaximum() < Double.MAX_VALUE){
+ descriptor.addParameter(MAXIMUM, validator.getMaximum());
+ }
+ if( validator.getMinimum()>Double.MIN_VALUE){
+ descriptor.addParameter(MINIMUM, validator.getMinimum());
+ }
+ } else if (component instanceof LengthValidator) {
+ LengthValidator validator = (LengthValidator) component;
+ if(validator.getMaximum() >0){
+ descriptor.addParameter(MAXIMUM, validator.getMaximum());
+ }
+ if( validator.getMinimum()>0){
+ descriptor.addParameter(MINIMUM, validator.getMinimum());
+ }
+ } else if (component instanceof LongRangeValidator) {
+ LongRangeValidator validator = (LongRangeValidator) component;
+ if(validator.getMaximum() !=0){
+ descriptor.addParameter(MAXIMUM, validator.getMaximum());
+ }
+ if( validator.getMinimum()!=0){
+ descriptor.addParameter(MINIMUM, validator.getMinimum());
+ }
+ } else if (component instanceof RegexValidator) {
+ RegexValidator validator = (RegexValidator) component;
+ descriptor.addParameter(PATTERN, validator.getPattern());
+ } else if (component instanceof RequiredValidator) {
+ // do nothing.
+ } else {
+ super.fillParameters(descriptor, component);
+ }
+
+ }
}
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js 2011-02-25
20:48:14 UTC (rev 21943)
@@ -36,6 +36,12 @@
return value;
}
+ var getLabel = function(component,id){
+ if(component.p){
+ return component.p.label || id;
+ }
+ return id;
+ }
$.extend(rf.csv, {
RE_DIGITS: /^-?\d+$/,
@@ -63,9 +69,10 @@
var converter = params.c;
rf.csv.clearMessage(id);
if (converter) {
+ var label=getLabel(converter,id);
try {
if (converter.f)
- convertedValue = converter.f(value,id,converter.p,converter.m);
+ convertedValue = converter.f(value,id,getLabel(converter,id),converter.m);
} catch (e){
e.severity=2;
rf.csv.sendMessage(id, e);
@@ -76,12 +83,13 @@
}
var validators = params.v;
if (validators) {
- var validatorFunction;
+ var validatorFunction,validator;
try {
for (i=0;i<validators.length;i++) {
- validatorFunction = validators[i].f;
+ validator=validators[i];
+ validatorFunction = validator.f;
if (validatorFunction) {
- validatorFunction(convertedValue,id, validators[i].p,validators[i].m);
+ validatorFunction(convertedValue,getLabel(validator,id),
validator.p,validator.m);
}
}
} catch (e) {
@@ -164,14 +172,14 @@
});
var validateRange = function(value,label,params,msg) {
- var isMinSet = typeof params.minimum === "number" ;//&&
params.minimum >0;
- var isMaxSet = typeof params.maximum === "number" ;//&&
params.maximum >0;
+ var isMinSet = typeof params.min === "number" ;//&& params.min
>0;
+ var isMaxSet = typeof params.max === "number" ;//&& params.max
>0;
- if (isMaxSet && value > params.maximum) {
- throw
rf.csv.interpolateMessage(msg,isMinSet?[params.minimum,params.maximum,label]:[params.maximum,label]);
+ if (isMaxSet && value > params.max) {
+ throw
rf.csv.interpolateMessage(msg,isMinSet?[params.min,params.max,label]:[params.max,label]);
}
- if (isMinSet && value < params.minimum) {
- throw
rf.csv.interpolateMessage(msg,isMaxSet?[params.minimum,params.maximum,label]:[params.minimum,label]);
+ if (isMinSet && value < params.min) {
+ throw
rf.csv.interpolateMessage(msg,isMaxSet?[params.min,params.max,label]:[params.min,label]);
}
};
@@ -231,7 +239,7 @@
},
"validateSize": function (value,label,params,msg) {
var length = value?value.length:0;
- validateRange(length,label,{maximum:params.max,minimum:params.min},msg);
+ validateRange(length,label,params,msg);
},
"validateRegex": function (value,label,params,msg) {
validateRegex(value,label,params.pattern,msg);
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetConverterTest.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetConverterTest.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetConverterTest.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -45,7 +45,7 @@
public void setupService() {
expect(factory.getInstance(FacesConverterService.class)).andStubReturn(converterService);
converterCapture = new Capture<Converter>();
-
expect(converterService.getConverterDescription(eq(environment.getFacesContext()),
capture(converterCapture)))
+
expect(converterService.getConverterDescription(same(environment.getFacesContext()),
same(input), capture(converterCapture)))
.andStubReturn(descriptor);
ServiceTracker.setFactory(factory);
}
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetValidatorTest.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetValidatorTest.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetValidatorTest.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -107,7 +107,7 @@
ValidatorDescriptor validatorDescriptor =
environment.createMock(ValidatorDescriptor.class);
expect((Class)
validatorDescriptor.getImplementationClass()).andStubReturn(validator.getClass());
expect(validatorDescriptor.getMessage()).andStubReturn(VALIDATION_ERROR);
-
expect(facesValidatorService.getValidatorDescription(environment.getFacesContext(),
validator))
+
expect(facesValidatorService.getValidatorDescription(environment.getFacesContext(), input,
validator))
.andStubReturn(validatorDescriptor);
}
}
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -7,7 +7,7 @@
import java.util.Locale;
import java.util.Map;
-import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
import javax.faces.component.UIViewRoot;
import org.jboss.test.faces.mock.MockFacesEnvironment;
@@ -32,7 +32,7 @@
protected final RunParameters criteria;
protected MockFacesEnvironment facesEnvironment;
- protected UIComponent component;
+ protected UIInput input;
public MockTestBase(RunParameters criteria) {
this.criteria = criteria;
@@ -42,7 +42,7 @@
@Before
public void setUp() {
this.facesEnvironment =
MockFacesEnvironment.createEnvironment().withApplication().resetToNice();
- component = facesEnvironment.createMock(UIComponent.class);
+ input = facesEnvironment.createMock(UIInput.class);
recordMocks();
facesEnvironment.replay();
}
@@ -51,8 +51,8 @@
UIViewRoot viewRoot = facesEnvironment.createMock(UIViewRoot.class);
expect(viewRoot.getLocale()).andStubReturn(Locale.ENGLISH);
expect(facesEnvironment.getFacesContext().getViewRoot()).andStubReturn(viewRoot);
- expect(component.getAttributes()).andStubReturn(Collections.EMPTY_MAP);
-
expect(component.getClientId(facesEnvironment.getFacesContext())).andStubReturn(TEST_COMPONENT_ID);
+ expect(input.getAttributes()).andStubReturn(Collections.EMPTY_MAP);
+
expect(input.getClientId(facesEnvironment.getFacesContext())).andStubReturn(TEST_COMPONENT_ID);
}
@After
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -5,7 +5,6 @@
import java.util.List;
-import javax.faces.convert.BooleanConverter;
import javax.faces.convert.ByteConverter;
import javax.faces.convert.Converter;
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ConverterTestBase.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ConverterTestBase.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ConverterTestBase.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -1,13 +1,10 @@
package org.richfaces.javascript.client.converter;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.*;
import javax.faces.application.FacesMessage;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
-import javax.faces.validator.Validator;
import net.sourceforge.htmlunit.corejs.javascript.JavaScriptException;
import net.sourceforge.htmlunit.corejs.javascript.NativeObject;
@@ -33,7 +30,7 @@
Converter converter = createConverter();
try {
Object convertedValue =
- converter.getAsObject(facesEnvironment.getFacesContext(), component,
criteria.getValue().toString());
+ converter.getAsObject(facesEnvironment.getFacesContext(), input,
criteria.getValue().toString());
Object jsConvertedValue =
convertOnClient(converter);
if(null != convertedValue || null != jsConvertedValue){
@@ -66,7 +63,7 @@
private Object getErrorMessage(Converter converter) {
ConverterServiceImpl converterService = new ConverterServiceImpl();
- FacesMessage message =
converterService.getMessage(facesEnvironment.getFacesContext(), converter);
+ FacesMessage message =
converterService.getMessage(facesEnvironment.getFacesContext(), converter, input);
return new Message(message);
}
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -4,7 +4,6 @@
import java.util.List;
import java.util.Map;
-import javax.faces.convert.BooleanConverter;
import javax.faces.convert.NumberConverter;
import javax.faces.convert.Converter;
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -1,11 +1,8 @@
package org.richfaces.javascript.client.converter;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
import java.util.List;
-import javax.faces.convert.BooleanConverter;
import javax.faces.convert.ShortConverter;
import javax.faces.convert.Converter;
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -18,8 +18,8 @@
*/
public class DoubleRangeValidatorTest extends ValidatorTestBase {
- private static final String MINIMUM = "minimum";
- private static final String MAXIMUM = "maximum";
+ private static final String MINIMUM = "min";
+ private static final String MAXIMUM = "max";
/**
* @param criteria
*/
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LengthValidatorTest.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LengthValidatorTest.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LengthValidatorTest.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -18,8 +18,8 @@
*/
public class LengthValidatorTest extends ValidatorTestBase {
- private static final String MINIMUM = "minimum";
- private static final String MAXIMUM = "maximum";
+ private static final String MINIMUM = "min";
+ private static final String MAXIMUM = "max";
/**
* @param criteria
*/
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -18,8 +18,8 @@
*/
public class LongRangeValidatorTest extends ValidatorTestBase {
- private static final String MINIMUM = "minimum";
- private static final String MAXIMUM = "maximum";
+ private static final String MINIMUM = "min";
+ private static final String MAXIMUM = "max";
/**
* @param criteria
*/
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -4,10 +4,7 @@
package org.richfaces.javascript.client.validator;
import java.util.List;
-import java.util.Map;
-import javax.faces.validator.LengthValidator;
-import javax.faces.validator.Validator;
import javax.validation.constraints.Max;
import org.junit.runners.Parameterized.Parameters;
@@ -38,9 +35,8 @@
@Parameters
public static List<RunParameters[]> parameters() {
- return options(
-
pass(0,PROP,"number",MAXIMUM,2),pass(2,PROP,"number",MAXIMUM,2),pass(123,PROP,"number",MAXIMUM,2)
- );
+ return options(pass(0, PROP, "number", MAXIMUM, 2), pass(2, PROP,
"number", MAXIMUM, 2),
+ pass(123, PROP, "number", MAXIMUM, 2));
}
public static final class Bean {
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/ValidatorTestBase.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/ValidatorTestBase.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/ValidatorTestBase.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -49,7 +49,7 @@
public void testValidator() throws Exception {
Validator validator = createValidator();
try {
- validator.validate(facesEnvironment.getFacesContext(), component,
criteria.getValue());
+ validator.validate(facesEnvironment.getFacesContext(), input,
criteria.getValue());
validateOnClient(validator);
} catch (ValidatorException e) {
// client-side script has to throw exception too.
@@ -80,7 +80,7 @@
private Object getErrorMessage(Validator validator) {
FacesValidatorServiceImpl validatorService = new FacesValidatorServiceImpl();
- FacesMessage message =
validatorService.getMessage(facesEnvironment.getFacesContext(), validator);
+ FacesMessage message =
validatorService.getMessage(facesEnvironment.getFacesContext(), validator, input);
return new Message(message);
}
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/validator/FacesConverterServiceTest.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/validator/FacesConverterServiceTest.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/validator/FacesConverterServiceTest.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -70,7 +70,7 @@
public void getConverterClass() throws Exception {
converter = new BooleanConverter();
controller.replay();
- ConverterDescriptor converterDescription =
serviceImpl.getConverterDescription(environment.getFacesContext(), converter);
+ ConverterDescriptor converterDescription =
serviceImpl.getConverterDescription(environment.getFacesContext(), input, converter);
assertEquals(converter.getClass(),
converterDescription.getImplementationClass());
}
@@ -85,7 +85,7 @@
facesMessage = e.getFacesMessage();
}
assertNotNull(facesMessage);
- ConverterDescriptor converterDescription =
serviceImpl.getConverterDescription(environment.getFacesContext(), converter);
+ ConverterDescriptor converterDescription =
serviceImpl.getConverterDescription(environment.getFacesContext(), input, converter);
String summary = converterDescription.getMessage().getSummary();
summary = summary.replace("{2}", "foo");
summary = summary.replace("'{0}'", "abc");
@@ -102,7 +102,7 @@
converter.setType("both");
converter.setTimeZone(TimeZone.getTimeZone("EST"));
controller.replay();
- ConverterDescriptor converterDescription =
serviceImpl.getConverterDescription(environment.getFacesContext(), converter);
+ ConverterDescriptor converterDescription =
serviceImpl.getConverterDescription(environment.getFacesContext(), input, converter);
Map<String, ? extends Object> additionalParameters =
converterDescription.getAdditionalParameters();
assertEquals("short",
additionalParameters.get("dateStyle"));
assertEquals("MM/DD/YYYY",
additionalParameters.get("pattern"));
Modified:
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/validator/FacesValidatorServiceTest.java
===================================================================
---
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/validator/FacesValidatorServiceTest.java 2011-02-25
20:30:06 UTC (rev 21942)
+++
branches/4.0.0.CR1/ui/validator/ui/src/test/java/org/richfaces/validator/FacesValidatorServiceTest.java 2011-02-25
20:48:14 UTC (rev 21943)
@@ -65,7 +65,7 @@
public void getConverterClass() throws Exception {
validator = new LengthValidator();
controller.replay();
- ValidatorDescriptor validatorDescription =
serviceImpl.getValidatorDescription(environment.getFacesContext(), validator);
+ ValidatorDescriptor validatorDescription =
serviceImpl.getValidatorDescription(environment.getFacesContext(), input, validator);
assertEquals(validator.getClass(),
validatorDescription.getImplementationClass());
}
@@ -80,7 +80,7 @@
facesMessage = e.getFacesMessage();
}
assertNotNull(facesMessage);
- ValidatorDescriptor validatorDescription =
serviceImpl.getValidatorDescription(environment.getFacesContext(), validator);
+ ValidatorDescriptor validatorDescription =
serviceImpl.getValidatorDescription(environment.getFacesContext(), input, validator);
String summary = validatorDescription.getMessage().getSummary();
summary = summary.replace("{0}", "foo");
assertEquals(facesMessage.getSummary(), summary);