public ViewFactory createViewFactory(Expression viewId, ExpressionParser expressionParser, ConversionService conversionService, BinderConfiguration binderConfiguration, Validator validator, ValidationHintResolver validationHintResolver) { if (useSpringBeanBinding) { expressionParser = new BeanWrapperExpressionParser(conversionService); } AbstractMvcViewFactory viewFactory = createMvcViewFactory(viewId, expressionParser, conversionService, binderConfiguration); if (StringUtils.hasText(eventIdParameterName)) { viewFactory.setEventIdParameterName(eventIdParameterName); } if (StringUtils.hasText(fieldMarkerPrefix)) { viewFactory.setFieldMarkerPrefix(fieldMarkerPrefix); } viewFactory.setValidator(validator); viewFactory.setValidationHintResolver(validationHintResolver); return viewFactory; }
public void testParseSimpleDelimitedNotAllowed() { String exp = "${flag}"; try { parser.parseExpression(exp, null); fail("should have failed"); } catch (ParserException e) { } }
public void testParseSimpleAllowDelimited() { parser.setAllowDelimitedEvalExpressions(true); String exp = "${flag}"; Expression e = parser.parseExpression(exp, null); assertNotNull(e); Boolean b = (Boolean) e.getValue(bean); assertFalse(b); }
public void testSetValueWithCoersion() { GenericConversionService cs = (GenericConversionService) parser.getConversionService(); StringToDate converter = new StringToDate(); converter.setPattern("yyyy-MM-dd"); cs.addConverter(converter); Expression e = parser.parseExpression("date", null); e.setValue(bean, "2008-9-15"); }
public void testGetValueType() { String exp = "flag"; Expression e = parser.parseExpression(exp, null); assertEquals(boolean.class, e.getValueType(bean)); }
protected ExpressionParser getExpressionParser() { return new BeanWrapperExpressionParser(); }
public void testGetValueTypeNullCollectionValue() { String exp = "list[0]"; Expression e = parser.parseExpression(exp, null); assertEquals(null, e.getValueType(bean)); }
public ViewFactory createViewFactory(Expression viewId, ExpressionParser expressionParser, ConversionService conversionService, BinderConfiguration binderConfiguration) { if (useSpringBeanBinding) { expressionParser = new BeanWrapperExpressionParser(conversionService); } AbstractMvcViewFactory viewFactory = createMvcViewFactory(viewId, expressionParser, conversionService, binderConfiguration); if (StringUtils.hasText(eventIdParameterName)) { viewFactory.setEventIdParameterName(eventIdParameterName); } if (StringUtils.hasText(fieldMarkerPrefix)) { viewFactory.setFieldMarkerPrefix(fieldMarkerPrefix); } return viewFactory; }
public void testParseSimple() { String exp = "flag"; Expression e = parser.parseExpression(exp, null); assertNotNull(e); Boolean b = (Boolean) e.getValue(bean); assertFalse(b); }
public ViewFactory createViewFactory(Expression viewId, ExpressionParser expressionParser, ConversionService conversionService, BinderConfiguration binderConfiguration, Validator validator, ValidationHintResolver validationHintResolver) { if (useSpringBeanBinding) { expressionParser = new BeanWrapperExpressionParser(conversionService); } AbstractMvcViewFactory viewFactory = createMvcViewFactory(viewId, expressionParser, conversionService, binderConfiguration); if (StringUtils.hasText(eventIdParameterName)) { viewFactory.setEventIdParameterName(eventIdParameterName); } if (StringUtils.hasText(fieldMarkerPrefix)) { viewFactory.setFieldMarkerPrefix(fieldMarkerPrefix); } viewFactory.setValidator(validator); viewFactory.setValidationHintResolver(validationHintResolver); return viewFactory; }
public void testTemplateEnclosedCompositeNotSupported() { String exp = "${hello ${flag} ${flag} ${flag}}"; try { parser.parseExpression(exp, new FluentParserContext().template()); fail("Should've failed - not intended use"); } catch (ParserException e) { } }
public void testSetBogusValueWithCoersion() { Expression e = parser.parseExpression("date", null); try { e.setValue(bean, "bogus"); fail("Should have failed tme"); } catch (ValueCoercionException ex) { assertTrue(ex.getCause() instanceof TypeMismatchException); } }
public void testParseTemplateComposite() { String exp = "hello ${flag} ${flag} ${flag}"; Expression e = parser.parseExpression(exp, new FluentParserContext().template()); assertNotNull(e); String str = (String) e.getValue(bean); assertEquals("hello false false false", str); }
public void testParseTemplateEmpty() { Expression e = parser.parseExpression("", new FluentParserContext().template()); assertNotNull(e); assertEquals("", e.getValue(bean)); }
public void testParseTemplateSimpleLiteral() { String exp = "flag"; Expression e = parser.parseExpression(exp, new FluentParserContext().template()); assertNotNull(e); assertEquals("flag", e.getValue(bean)); }