INT-1617 updated test classes to reflect name changes, modified Presence related class names, fixed test

This commit is contained in:
Oleg Zhurakousky
2010-11-15 13:53:46 -05:00
parent 2151f3ec9c
commit 557fd6625e
12 changed files with 61 additions and 37 deletions

View File

@@ -33,7 +33,7 @@ public class PresenceInboundChannelAdapterParser extends AbstractSingleBeanDefin
@Override
protected String getBeanClassName(Element element) {
return "org.springframework.integration.xmpp.inbound.RosterListeningEndpoint";
return "org.springframework.integration.xmpp.inbound.PresenceListeningEndpoint";
}
@Override

View File

@@ -89,7 +89,8 @@ public class XmppConnectionFactoryBean extends AbstractFactoryBean<XMPPConnectio
@Override
protected XMPPConnection createInstance() throws Exception {
return new XMPPConnection(this.connectionConfiguration);
connection = new XMPPConnection(this.connectionConfiguration);
return connection;
}
public void start() {

View File

@@ -42,20 +42,20 @@ import org.springframework.util.Assert;
* @author Oleg Zhurakousky
* @since 2.0
*/
public class RosterListeningEndpoint extends AbstractXmppConnectionAwareEndpoint {
public class PresenceListeningEndpoint extends AbstractXmppConnectionAwareEndpoint {
private static final Log logger = LogFactory.getLog(RosterListeningEndpoint.class);
private static final Log logger = LogFactory.getLog(PresenceListeningEndpoint.class);
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
private final EventForwardingRosterListener rosterListener = new EventForwardingRosterListener();
public RosterListeningEndpoint() {
public PresenceListeningEndpoint() {
super();
}
public RosterListeningEndpoint(XMPPConnection xmppConnection) {
public PresenceListeningEndpoint(XMPPConnection xmppConnection) {
super(xmppConnection);
}
@@ -70,7 +70,8 @@ public class RosterListeningEndpoint extends AbstractXmppConnectionAwareEndpoint
@Override
protected void doStart() {
Assert.isTrue(this.initialized, this.getComponentName() + "#" + this.getComponentType() + " must be initialized");
this.xmppConnection.getRoster().addRosterListener(rosterListener);
Roster roster = this.xmppConnection.getRoster();
roster.addRosterListener(rosterListener);
}
@Override
@@ -105,7 +106,7 @@ public class RosterListeningEndpoint extends AbstractXmppConnectionAwareEndpoint
}
public void presenceChanged(Presence presence) {
logger.debug("presence changed: " + ToStringBuilder.reflectionToString(presence));
logger.debug("presence changed: " + presence.getFrom() + " - " + presence);
messagingTemplate.convertAndSend(presence);
}
}

View File

@@ -1,11 +0,0 @@
log4j.rootCategory=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
log4j.category.org.springframework=WARN
# log4j.category.org.springframework.integration=DEBUG
# log4j.category.org.springframework.integration.jdbc=DEBUG
log4j.category.org.springframework=DEBUG

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p: %c - %m%n" />
</layout>
</appender>
<logger name="org.springframework.integration">
<level value="warn" />
</logger>
<logger name="org.springframework.integration.xmpp">
<level value="debug" />
</logger>
<!-- Root Logger -->
<root>
<priority value="warn" />
<appender-ref ref="console" />
</root>
</log4j:configuration>

View File

@@ -4,7 +4,7 @@
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:console="http://www.springframework.org/schema/integration/stream"
xmlns:stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
@@ -19,7 +19,7 @@
<beans:property name="location" value="classpath:test.properties"/>
</beans:bean>
<beans:bean id="xmppRosterEventConsumer" class="org.springframework.integration.xmpp.ignore.XmppRosterEventConsumer"/>
<xmpp:xmpp-connection
id="testConnection"
@@ -29,10 +29,17 @@
service-name="${user.1.service}"
/>
<xmpp:presence-inbound-channel-adapter channel="inboundRosterEventChannel" xmpp-connection="testConnection"/>
<channel id="inboundRosterEventChannel"/>
<xmpp:roster-event-inbound-channel-adapter channel="inboundRosterEventChannel" xmpp-connection="testConnection"/>
<service-activator input-channel="inboundRosterEventChannel" ref="xmppRosterEventConsumer"/>
<service-activator input-channel="inboundRosterEventChannel" output-channel="stdOutChannel"
expression="'Presence event from: ' + payload.getFrom() + ' - ' + payload.getMode()"/>
<channel id="stdOutChannel"/>
<stream:stdout-channel-adapter channel="stdOutChannel" append-newline="true"/>
</beans:beans>

View File

@@ -36,7 +36,7 @@ public class InboundXmppRosterEventsEndpointTests {
@Test
@Ignore
public void run() throws Exception {
Thread.sleep(60 * 1000);
Thread.sleep(60 * 1000 * 1000);
}
}

View File

@@ -39,7 +39,7 @@ import org.springframework.integration.xmpp.inbound.ChatMessageListeningEndpoint
* @author Oleg Zhurakousky
*
*/
public class XmppMessageDrivenEndpointTests {
public class ChatMessageListeningEndpointTests {
@Test

View File

@@ -45,7 +45,7 @@ import org.springframework.integration.xmpp.core.XmppContextUtils;
/**
* @author Oleg Zhurakousky
*/
public class XmppRosterListeningEndpointTests {
public class PresenceListeningEndpointTests {
@Test
public void testEndpointLifecycle() {
@@ -67,7 +67,7 @@ public class XmppRosterListeningEndpointTests {
return null;
}
}).when(roster).removeRosterListener(Mockito.any(RosterListener.class));
RosterListeningEndpoint rosterEndpoint = new RosterListeningEndpoint(connection);
PresenceListeningEndpoint rosterEndpoint = new PresenceListeningEndpoint(connection);
rosterEndpoint.afterPropertiesSet();
assertEquals(0, rosterSet.size());
rosterEndpoint.start();
@@ -78,7 +78,7 @@ public class XmppRosterListeningEndpointTests {
@Test(expected=IllegalArgumentException.class)
public void testNonInitializedFailure() {
RosterListeningEndpoint rosterEndpoint = new RosterListeningEndpoint(mock(XMPPConnection.class));
PresenceListeningEndpoint rosterEndpoint = new PresenceListeningEndpoint(mock(XMPPConnection.class));
rosterEndpoint.start();
}
@@ -87,7 +87,7 @@ public class XmppRosterListeningEndpointTests {
XMPPConnection connection = mock(XMPPConnection.class);
Roster roster = mock(Roster.class);
when(connection.getRoster()).thenReturn(roster);
RosterListeningEndpoint rosterEndpoint = new RosterListeningEndpoint(connection);
PresenceListeningEndpoint rosterEndpoint = new PresenceListeningEndpoint(connection);
QueueChannel channel = new QueueChannel();
rosterEndpoint.setRequestChannel(channel);
rosterEndpoint.afterPropertiesSet();
@@ -103,7 +103,7 @@ public class XmppRosterListeningEndpointTests {
public void testWithImplicitXmppConnection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerSingleton(XmppContextUtils.XMPP_CONNECTION_BEAN_NAME, mock(XMPPConnection.class));
RosterListeningEndpoint endpoint = new RosterListeningEndpoint();
PresenceListeningEndpoint endpoint = new PresenceListeningEndpoint();
endpoint.setBeanFactory(bf);
endpoint.afterPropertiesSet();
assertNotNull(TestUtils.getPropertyValue(endpoint,"xmppConnection"));
@@ -111,7 +111,7 @@ public class XmppRosterListeningEndpointTests {
@Test(expected=IllegalArgumentException.class)
public void testNoXmppConnection() {
RosterListeningEndpoint handler = new RosterListeningEndpoint();
PresenceListeningEndpoint handler = new PresenceListeningEndpoint();
handler.afterPropertiesSet();
}

View File

@@ -43,7 +43,7 @@ import org.springframework.integration.xmpp.outbound.ChatMessageSendingMessageHa
* @author Oleg Zhurakousky
*
*/
public class XmppMessageSendingMessageHandlerTests {
public class ChatMessageSendingMessageHandlerTests {
@Test

View File

@@ -33,7 +33,7 @@ import org.springframework.integration.xmpp.outbound.PresenceSendingMessageHandl
* @author Oleg Zhurakousky
*
*/
public class XmppRosterEventMessageSendingHandlerTests {
public class PresenceSendingMessageHandlerTests {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test

View File

@@ -1,6 +1,6 @@
user.2.login=springintegration@gmail.com
user.2.login=user2@gmail.com
user.1.login=springintegration.eip@gmail.com
user.1.password=spr1ng1p
user.1.login=user1@gmail.com
user.1.password=password
user.1.host=talk.google.com
user.1.service=gmail.com