formatter-registry config

This commit is contained in:
Keith Donald
2008-04-11 14:18:53 +00:00
parent 875b4c304a
commit 0d9e9b7f84
6 changed files with 131 additions and 18 deletions

View File

@@ -2,12 +2,21 @@ package org.springframework.faces.config;
import junit.framework.TestCase;
import org.springframework.binding.convert.ConversionException;
import org.springframework.binding.convert.ConversionExecutor;
import org.springframework.binding.convert.ConversionService;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionParser;
import org.springframework.binding.format.Formatter;
import org.springframework.binding.format.FormatterRegistry;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.faces.model.converter.FacesConversionService;
import org.springframework.faces.webflow.JSFMockHelper;
import org.springframework.faces.webflow.JsfManagedBeanAwareELExpressionParser;
import org.springframework.faces.webflow.JsfViewFactoryCreator;
import org.springframework.webflow.engine.builder.ViewFactoryCreator;
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;
import org.springframework.webflow.execution.ViewFactory;
import org.springframework.webflow.expression.el.WebFlowELExpressionParser;
public class FacesFlowBuilderServicesBeanDefinitionParserTests extends TestCase {
@@ -40,4 +49,60 @@ public class FacesFlowBuilderServicesBeanDefinitionParserTests extends TestCase
assertTrue(builderServices.getViewFactoryCreator() instanceof JsfViewFactoryCreator);
assertTrue(builderServices.getConversionService() instanceof FacesConversionService);
}
public void testFlowBuilderServicesCustomized() {
builderServices = (FlowBuilderServices) context.getBean("flowBuilderServicesCustom");
assertNotNull(builderServices);
assertNotNull(builderServices.getExpressionParser());
assertTrue(builderServices.getViewFactoryCreator() instanceof TestViewFactoryCreator);
assertTrue(builderServices.getConversionService() instanceof TestConversionService);
assertTrue(builderServices.getFormatterRegistry() instanceof TestFormatterRegistry);
}
public static class TestViewFactoryCreator implements ViewFactoryCreator {
public ViewFactory createViewFactory(Expression viewIdExpression, ExpressionParser expressionParser,
FormatterRegistry formatterRegistry) {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public String getViewIdByConvention(String viewStateId) {
return viewStateId;
}
}
public static class TestConversionService implements ConversionService {
public Class getClassByAlias(String alias) throws ConversionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass)
throws ConversionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public ConversionExecutor getConversionExecutorByTargetAlias(Class sourceClass, String targetAlias)
throws ConversionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public ConversionExecutor[] getConversionExecutorsForSource(Class sourceClass) throws ConversionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
}
public static class TestFormatterRegistry implements FormatterRegistry {
public Formatter getFormatter(Class clazz) {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public Formatter getFormatter(String id) {
throw new UnsupportedOperationException("Auto-generated method stub");
}
}
}

View File

@@ -11,5 +11,19 @@
<faces:flow-builder-services id="flowBuilderServicesDefault"/>
<faces:flow-builder-services id="flowBuilderServicesLegacy" enable-managed-beans="true"/>
<faces:flow-builder-services id="flowBuilderServicesCustom"
expression-parser="customExpressionParser"
view-factory-creator="customViewFactoryCreator"
conversion-service="customConversionService"
formatter-registry="customFormatterRegistry"/>
<bean id="customExpressionParser" class="org.springframework.webflow.expression.DefaultExpressionParserFactory" factory-method="getExpressionParser"/>
<bean id="customViewFactoryCreator" class="org.springframework.faces.config.FacesFlowBuilderServicesBeanDefinitionParserTests$TestViewFactoryCreator"/>
<bean id="customConversionService" class="org.springframework.faces.config.FacesFlowBuilderServicesBeanDefinitionParserTests$TestConversionService"/>
<bean id="customFormatterRegistry" class="org.springframework.faces.config.FacesFlowBuilderServicesBeanDefinitionParserTests$TestFormatterRegistry"/>
</beans>