This commit is contained in:
Mark Fisher
2008-12-15 15:02:10 +00:00
parent e665c83fb6
commit 17849dbdea
6 changed files with 136 additions and 2 deletions

View File

@@ -0,0 +1,65 @@
/*
* Copyright 2002-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.config.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.context.IntegrationContextUtils;
/**
* @author Mark Fisher
*/
public class PollerParserTests {
@Test
public void defaultPollerWithId() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"defaultPollerWithId.xml", PollerParserTests.class);
Object poller = context.getBean("defaultPollerWithId");
assertNotNull(poller);
Object defaultPoller = context.getBean(IntegrationContextUtils.DEFAULT_POLLER_METADATA_BEAN_NAME);
assertNotNull(defaultPoller);
assertEquals(defaultPoller, context.getBean("defaultPollerWithId"));
}
@Test
public void defaultPollerWithoutId() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"defaultPollerWithoutId.xml", PollerParserTests.class);
Object defaultPoller = context.getBean(IntegrationContextUtils.DEFAULT_POLLER_METADATA_BEAN_NAME);
assertNotNull(defaultPoller);
}
@Test(expected = BeanDefinitionParsingException.class)
public void multipleDefaultPollers() {
new ClassPathXmlApplicationContext(
"multipleDefaultPollers.xml", PollerParserTests.class);
}
@Test(expected = BeanDefinitionParsingException.class)
public void topLevelPollerWithoutId() {
new ClassPathXmlApplicationContext(
"topLevelPollerWithoutId.xml", PollerParserTests.class);
}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
<poller id="defaultPollerWithId" default="true">
<interval-trigger interval="5000"/>
</poller>
</beans:beans>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
<poller default="true">
<interval-trigger interval="5000"/>
</poller>
</beans:beans>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
<poller id="defaultPoller1" default="true">
<interval-trigger interval="3000"/>
</poller>
<poller id="defaultPoller2" default="true">
<interval-trigger interval="10000"/>
</poller>
</beans:beans>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
<poller>
<interval-trigger interval="3000"/>
</poller>
</beans:beans>