Merge pull request #158 from garyrussell/INT-2202

Add auto-startup To Inbound Endpoints
This commit is contained in:
Mark Fisher
2011-10-31 15:39:01 -04:00
7 changed files with 40 additions and 0 deletions

View File

@@ -101,6 +101,8 @@ abstract class AbstractAmqpInboundAdapterParser extends AbstractSingleBeanDefini
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "message-converter");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "header-mapper");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "error-channel");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-startup");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "phase");
this.configureChannels(element, parserContext, builder);
}

View File

@@ -379,6 +379,13 @@
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="auto-startup" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
Boolean value indicating whether this endpoint should start automatically.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:attributeGroup name="containerAttributes">

View File

@@ -11,6 +11,9 @@
<amqp:inbound-channel-adapter id="rabbitInbound" queue-names="inboundchanneladapter.test.1"/>
<amqp:inbound-channel-adapter id="autoStartFalse" queue-names="inboundchanneladapter.test.2"
auto-startup="false" phase="123"/>
<bean id="rabbitConnectionFactory" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.springframework.amqp.rabbit.connection.ConnectionFactory"/>
</bean>

View File

@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.amqp.inbound.AmqpInboundChannelAdapter;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -45,6 +46,14 @@ public class AmqpInboundChannelAdapterParserTests {
Object adapter = context.getBean("rabbitInbound.adapter");
assertEquals(DirectChannel.class, channel.getClass());
assertEquals(AmqpInboundChannelAdapter.class, adapter.getClass());
assertEquals(Boolean.TRUE, TestUtils.getPropertyValue(adapter, "autoStartup"));
assertEquals(0, TestUtils.getPropertyValue(adapter, "phase"));
}
@Test
public void verifyLifeCycle() {
Object adapter = context.getBean("autoStartFalse.adapter");
assertEquals(Boolean.FALSE, TestUtils.getPropertyValue(adapter, "autoStartup"));
assertEquals(123, TestUtils.getPropertyValue(adapter, "phase"));
}
}

View File

@@ -20,4 +20,8 @@
<bean id="testConverter" class="org.springframework.integration.amqp.config.AmqpInboundGatewayParserTests$TestConverter"/>
<si-amqp:inbound-gateway id="autoStartFalseGateway" request-channel="requests" queue-names="test"
connection-factory="rabbitConnectionFactory" message-converter="testConverter"
auto-startup="false" phase="123"/>
</beans>

View File

@@ -16,6 +16,7 @@
package org.springframework.integration.amqp.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import org.junit.Test;
@@ -48,8 +49,16 @@ public class AmqpInboundGatewayParserTests {
TestConverter testConverter = context.getBean("testConverter", TestConverter.class);
assertSame(testConverter, gatewayConverter);
assertSame(testConverter, templateConverter);
assertEquals(Boolean.TRUE, TestUtils.getPropertyValue(gateway, "autoStartup"));
assertEquals(0, TestUtils.getPropertyValue(gateway, "phase"));
}
@Test
public void verifyLifeCycle() {
Object gateway = context.getBean("autoStartFalseGateway");
assertEquals(Boolean.FALSE, TestUtils.getPropertyValue(gateway, "autoStartup"));
assertEquals(123, TestUtils.getPropertyValue(gateway, "phase"));
}
private static class TestConverter extends SimpleMessageConverter {}

View File

@@ -16,6 +16,7 @@
package org.springframework.integration.amqp.config;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -28,4 +29,9 @@ public class GatewayEchoTests {
new ClassPathXmlApplicationContext("GatewayEchoTests-context.xml", GatewayEchoTests.class);
}
@Test
/**
* Dummy test to satisfy maven in some environments.
*/
public void test() {}
}