Java Code Examples for org.springframework.web.bind.support.ConfigurableWebBindingInitializer#setValidator()
The following examples show how to use
org.springframework.web.bind.support.ConfigurableWebBindingInitializer#setValidator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestMappingHandlerAdapterIntegrationTests.java From spring-analysis-note with MIT License | 6 votes |
@Before public void setup() throws Exception { ConfigurableWebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer(); bindingInitializer.setValidator(new StubValidator()); List<HandlerMethodArgumentResolver> customResolvers = new ArrayList<>(); customResolvers.add(new ServletWebArgumentResolverAdapter(new ColorArgumentResolver())); GenericWebApplicationContext context = new GenericWebApplicationContext(); context.refresh(); handlerAdapter = new RequestMappingHandlerAdapter(); handlerAdapter.setWebBindingInitializer(bindingInitializer); handlerAdapter.setCustomArgumentResolvers(customResolvers); handlerAdapter.setApplicationContext(context); handlerAdapter.setBeanFactory(context.getBeanFactory()); handlerAdapter.afterPropertiesSet(); request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); request.setMethod("POST"); // Expose request to the current thread (for SpEL expressions) RequestContextHolder.setRequestAttributes(new ServletWebRequest(request)); }
Example 2
Source File: RequestMappingHandlerAdapterIntegrationTests.java From java-technology-stack with MIT License | 6 votes |
@Before public void setup() throws Exception { ConfigurableWebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer(); bindingInitializer.setValidator(new StubValidator()); List<HandlerMethodArgumentResolver> customResolvers = new ArrayList<>(); customResolvers.add(new ServletWebArgumentResolverAdapter(new ColorArgumentResolver())); GenericWebApplicationContext context = new GenericWebApplicationContext(); context.refresh(); handlerAdapter = new RequestMappingHandlerAdapter(); handlerAdapter.setWebBindingInitializer(bindingInitializer); handlerAdapter.setCustomArgumentResolvers(customResolvers); handlerAdapter.setApplicationContext(context); handlerAdapter.setBeanFactory(context.getBeanFactory()); handlerAdapter.afterPropertiesSet(); request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); request.setMethod("POST"); // Expose request to the current thread (for SpEL expressions) RequestContextHolder.setRequestAttributes(new ServletWebRequest(request)); }
Example 3
Source File: RequestMappingHandlerAdapterIntegrationTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Before public void setup() throws Exception { ConfigurableWebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer(); bindingInitializer.setValidator(new StubValidator()); List<HandlerMethodArgumentResolver> customResolvers = new ArrayList<HandlerMethodArgumentResolver>(); customResolvers.add(new ServletWebArgumentResolverAdapter(new ColorArgumentResolver())); GenericWebApplicationContext context = new GenericWebApplicationContext(); context.refresh(); handlerAdapter = new RequestMappingHandlerAdapter(); handlerAdapter.setWebBindingInitializer(bindingInitializer); handlerAdapter.setCustomArgumentResolvers(customResolvers); handlerAdapter.setApplicationContext(context); handlerAdapter.setBeanFactory(context.getBeanFactory()); handlerAdapter.afterPropertiesSet(); request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); request.setMethod("POST"); // Expose request to the current thread (for SpEL expressions) RequestContextHolder.setRequestAttributes(new ServletWebRequest(request)); }
Example 4
Source File: WebFluxConfigurationSupport.java From spring-analysis-note with MIT License | 5 votes |
/** * Return the {@link ConfigurableWebBindingInitializer} to use for * initializing all {@link WebDataBinder} instances. */ protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer( FormattingConversionService webFluxConversionService, Validator webFluxValidator) { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(webFluxConversionService); initializer.setValidator(webFluxValidator); MessageCodesResolver messageCodesResolver = getMessageCodesResolver(); if (messageCodesResolver != null) { initializer.setMessageCodesResolver(messageCodesResolver); } return initializer; }
Example 5
Source File: ModelAttributeMethodArgumentResolverTests.java From spring-analysis-note with MIT License | 5 votes |
@Before public void setup() throws Exception { LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean(); validator.afterPropertiesSet(); ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setValidator(validator); this.bindContext = new BindingContext(initializer); }
Example 6
Source File: WebMvcConfigurationSupport.java From spring-analysis-note with MIT License | 5 votes |
/** * Return the {@link ConfigurableWebBindingInitializer} to use for * initializing all {@link WebDataBinder} instances. */ protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer( FormattingConversionService mvcConversionService, Validator mvcValidator) { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(mvcConversionService); initializer.setValidator(mvcValidator); MessageCodesResolver messageCodesResolver = getMessageCodesResolver(); if (messageCodesResolver != null) { initializer.setMessageCodesResolver(messageCodesResolver); } return initializer; }
Example 7
Source File: WebFluxConfigurationSupport.java From java-technology-stack with MIT License | 5 votes |
/** * Return the {@link ConfigurableWebBindingInitializer} to use for * initializing all {@link WebDataBinder} instances. */ protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer() { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(webFluxConversionService()); initializer.setValidator(webFluxValidator()); MessageCodesResolver messageCodesResolver = getMessageCodesResolver(); if (messageCodesResolver != null) { initializer.setMessageCodesResolver(messageCodesResolver); } return initializer; }
Example 8
Source File: ModelAttributeMethodArgumentResolverTests.java From java-technology-stack with MIT License | 5 votes |
@Before public void setup() throws Exception { LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean(); validator.afterPropertiesSet(); ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setValidator(validator); this.bindContext = new BindingContext(initializer); }
Example 9
Source File: WebMvcConfigurationSupport.java From java-technology-stack with MIT License | 5 votes |
/** * Return the {@link ConfigurableWebBindingInitializer} to use for * initializing all {@link WebDataBinder} instances. */ protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer() { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(mvcConversionService()); initializer.setValidator(mvcValidator()); MessageCodesResolver messageCodesResolver = getMessageCodesResolver(); if (messageCodesResolver != null) { initializer.setMessageCodesResolver(messageCodesResolver); } return initializer; }
Example 10
Source File: WebMvcConfigurationSupport.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Return the {@link ConfigurableWebBindingInitializer} to use for * initializing all {@link WebDataBinder} instances. */ protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer() { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(mvcConversionService()); initializer.setValidator(mvcValidator()); initializer.setMessageCodesResolver(getMessageCodesResolver()); return initializer; }
Example 11
Source File: WebMvcConfigurationSupport.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Return the {@link ConfigurableWebBindingInitializer} to use for * initializing all {@link WebDataBinder} instances. */ protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer() { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(mvcConversionService()); initializer.setValidator(mvcValidator()); initializer.setMessageCodesResolver(getMessageCodesResolver()); return initializer; }
Example 12
Source File: MessageReaderArgumentResolverTests.java From spring-analysis-note with MIT License | 4 votes |
@Before public void setup() throws Exception { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setValidator(new TestBeanValidator()); this.bindingContext = new BindingContext(initializer); }
Example 13
Source File: MessageReaderArgumentResolverTests.java From java-technology-stack with MIT License | 4 votes |
@Before public void setup() throws Exception { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setValidator(new TestBeanValidator()); this.bindingContext = new BindingContext(initializer); }