### Question:
IntegrationBeanDefinitionParser implements BeanDefinitionParser { public BeanDefinition parse(Element element, ParserContext parserContext) { BeanDefinitionParserHelper helper = new BeanDefinitionParserHelper(element, parserContext); parserContext.pushContainingComponent(helper.getComponentDefinition()); helper.register(SpringFacesIntegration.class); registerIfAttributeIsTrue(helper, "validators", SpringFacesValidatorSupport.class); registerIfAttributeIsTrue(helper, "converters", SpringFacesConverterSupport.class); registerIfAttributeIsTrue(helper, "exception-handlers", SpringFacesExceptionHandlerSupport.class, ObjectMessageExceptionHandler.class); registerIfAttributeIsTrue(helper, "spring-expressions", StandardEvaluationContextPostProcessorSupport.class, FacesStandardEvaluationContextPostProcessor.class); parserContext.popAndRegisterContainingComponent(); return null; }  BeanDefinition parse(Element element, ParserContext parserContext);  }### Answer:
@Test public void shouldOnlyRegisterIntegration() throws Exception { this.parser.parse(this.element, this.parserContext); assertThat(this.beanDefinitions.size(), is(1)); }
@Test public void shouldRegisterValidatorSupport() throws Exception { given(this.element.getAttribute("validators")).willReturn("true"); this.parser.parse(this.element, this.parserContext); assertThat(this.beanDefinitions.size(), is(2)); assertThat(this.beanDefinitions.get(1).getBeanClassName(), is(SpringFacesValidatorSupport.class.getName())); }
@Test public void shouldRegisterConverterSupport() throws Exception { given(this.element.getAttribute("converters")).willReturn("true"); this.parser.parse(this.element, this.parserContext); assertThat(this.beanDefinitions.size(), is(2)); assertThat(this.beanDefinitions.get(1).getBeanClassName(), is(SpringFacesConverterSupport.class.getName())); }
@Test public void shouldRegisterExceptionHandlerSupport() throws Exception { given(this.element.getAttribute("exception-handlers")).willReturn("true"); this.parser.parse(this.element, this.parserContext); assertThat(this.beanDefinitions.size(), is(3)); assertThat(this.beanDefinitions.get(1).getBeanClassName(), is(SpringFacesExceptionHandlerSupport.class.getName())); assertThat(this.beanDefinitions.get(2).getBeanClassName(), is(ObjectMessageExceptionHandler.class.getName())); }
@Test public void shouldRegisterSpringExpressionSupport() throws Exception { given(this.element.getAttribute("spring-expressions")).willReturn("true"); this.parser.parse(this.element, this.parserContext); assertThat(this.beanDefinitions.size(), is(3)); assertThat(this.beanDefinitions.get(1).getBeanClassName(), is(StandardEvaluationContextPostProcessorSupport.class.getName())); assertThat(this.beanDefinitions.get(2).getBeanClassName(), is(FacesStandardEvaluationContextPostProcessor.class.getName())); }