TimerParser implements BeanDefinitionParser { @Override public BeanDefinition parse(Element element, ParserContext parserContext) { final BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(TimerFactoryBean.class); DescriptionElementParser.doParse(element, builder); builder.addPropertyValue("name", element.getLocalName()); BeanDefinitionParserUtils.setPropertyValue(builder, element.getAttribute("id"), "timerId"); BeanDefinitionParserUtils.setPropertyValue(builder, element.getAttribute("interval"), "interval"); BeanDefinitionParserUtils.setPropertyValue(builder, element.getAttribute("delay"), "delay"); BeanDefinitionParserUtils.setPropertyValue(builder, element.getAttribute("repeatCount"), "repeatCount"); BeanDefinitionParserUtils.setPropertyValue(builder, element.getAttribute("fork"), "fork"); ActionContainerParser.doParse(element, parserContext, builder); return builder.getBeanDefinition(); }  @Override BeanDefinition parse(Element element, ParserContext parserContext);  }
@Test public void testParse() throws Exception { assertActionCount(3); assertActionClassAndName(Timer.class, "timer"); Timer action = getNextTestActionFromTest(); Assert.assertEquals(action.getTimerId(), "timer1"); Assert.assertEquals(action.getDelay(), 5000L); Assert.assertEquals(action.getRepeatCount(), 1); Assert.assertEquals(action.getInterval(), 2000L); Assert.assertEquals(action.getActionCount(), 1); action = getNextTestActionFromTest(); Assert.assertEquals(action.getTimerId(), "timer2"); Assert.assertEquals(action.getDelay(), 500L); Assert.assertEquals(action.getRepeatCount(), 2); Assert.assertEquals(action.getInterval(), 200L); Assert.assertEquals(action.getActionCount(), 2); long defaultDelay = 0L; int defaultRepeat = Integer.MAX_VALUE; long defaultInterval = 1000L; action = getNextTestActionFromTest(); Assert.assertNotNull(action.getTimerId()); Assert.assertEquals(action.getDelay(), defaultDelay); Assert.assertEquals(action.getRepeatCount(), defaultRepeat); Assert.assertEquals(action.getInterval(), defaultInterval); Assert.assertEquals(action.getActionCount(), 1); }