INT-1580, more polishing, more tests

This commit is contained in:
Oleg Zhurakousky
2010-11-03 19:19:20 -04:00
parent c1c38db8c4
commit ad37847162
4 changed files with 41 additions and 3 deletions

View File

@@ -57,7 +57,7 @@ public class XmppConnectionParser extends AbstractSingleBeanDefinitionParser {
Assert.hasText(serviceName, "'serviceName' is requuired if 'host' is not provided");
}
if (StringUtils.hasText(serviceName)){
connectionConfigurationBuilder.addConstructorArgValue(port);
connectionConfigurationBuilder.addConstructorArgValue(serviceName);
}
for (String attribute : connectionFactoryAttributes) {
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, attribute);

View File

@@ -42,8 +42,8 @@
<xsd:attribute name="host" type="xsd:string"/>
<xsd:attribute name="service-name" type="xsd:string"/>
<xsd:attribute name="resource" type="xsd:string"/>
<xsd:attribute name="sasl-mechanism-supported" type="xsd:string"/>
<xsd:attribute name="sasl-mechanism-supported-index" type="xsd:string"/>
<!-- <xsd:attribute name="sasl-mechanism-supported" type="xsd:string"/>-->
<!-- <xsd:attribute name="sasl-mechanism-supported-index" type="xsd:string"/>-->
<xsd:attribute name="port" type="xsd:string" default="5222"/>
<xsd:attribute name="subscription-mode" default="accept_all">
<xsd:annotation>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
http://www.springframework.org/schema/integration/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp-2.0.xsd"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-xmpp="http://www.springframework.org/schema/integration/xmpp">
<int-xmpp:xmpp-connection id="connection"
user="happy.user"
password="blah"
host="localhost"
auto-startup="false"
resource="SpringSource"
port="6222"
service-name="foogle.com"
subscription-mode="reject_all"/>
</beans>

View File

@@ -42,8 +42,26 @@ public class XmppConnectionParserTests {
XmppConnectionFactoryBean xmppFb = ac.getBean("&connection", XmppConnectionFactoryBean.class);
assertEquals("happy.user", TestUtils.getPropertyValue(xmppFb, "user"));
assertEquals("blah", TestUtils.getPropertyValue(xmppFb, "password"));
assertEquals("Smack", TestUtils.getPropertyValue(xmppFb, "resource"));
assertEquals("accept_all", TestUtils.getPropertyValue(xmppFb, "subscriptionMode"));
ConnectionConfiguration configuration = (ConnectionConfiguration) TestUtils.getPropertyValue(connection, "configuration");
assertEquals("localhost", configuration.getHost());
assertEquals(5222, configuration.getPort());
}
@Test
public void testCompleteConfiguration(){
ApplicationContext ac = new ClassPathXmlApplicationContext("XmppConnectionParserTest-complete.xml", this.getClass());
XMPPConnection connection = ac.getBean("connection", XMPPConnection.class);
assertNull(connection.getServiceName());
assertFalse(connection.isConnected());
XmppConnectionFactoryBean xmppFb = ac.getBean("&connection", XmppConnectionFactoryBean.class);
assertEquals("happy.user", TestUtils.getPropertyValue(xmppFb, "user"));
assertEquals("blah", TestUtils.getPropertyValue(xmppFb, "password"));
assertEquals("SpringSource", TestUtils.getPropertyValue(xmppFb, "resource"));
assertEquals("reject_all", TestUtils.getPropertyValue(xmppFb, "subscriptionMode"));
ConnectionConfiguration configuration = (ConnectionConfiguration) TestUtils.getPropertyValue(connection, "configuration");
assertEquals("localhost", configuration.getHost());
assertEquals(6222, configuration.getPort());
assertEquals("foogle.com", configuration.getServiceName());
}
}