List of usage examples for org.springframework.integration.xmpp.inbound ChatMessageListeningEndpoint ChatMessageListeningEndpoint
public ChatMessageListeningEndpoint()
From source file:org.springframework.integration.xmpp.inbound.ChatMessageListeningEndpointTests.java
@Test public void testWithImplicitXmppConnection() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerSingleton(XmppContextUtils.XMPP_CONNECTION_BEAN_NAME, mock(XMPPConnection.class)); ChatMessageListeningEndpoint endpoint = new ChatMessageListeningEndpoint(); endpoint.setBeanFactory(bf);/* w w w . j ava2s . c o m*/ endpoint.setOutputChannel(new QueueChannel()); endpoint.afterPropertiesSet(); assertNotNull(TestUtils.getPropertyValue(endpoint, "xmppConnection")); }
From source file:org.springframework.integration.xmpp.inbound.ChatMessageListeningEndpointTests.java
@Test(expected = IllegalArgumentException.class) public void testNoXmppConnection() { ChatMessageListeningEndpoint endpoint = new ChatMessageListeningEndpoint(); endpoint.setBeanFactory(mock(BeanFactory.class)); endpoint.afterPropertiesSet();//from ww w .j av a2 s .com }
From source file:org.springframework.integration.xmpp.inbound.ChatMessageListeningEndpointTests.java
@Test public void testWithErrorChannel() throws NotConnectedException { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); XMPPConnection connection = mock(XMPPConnection.class); bf.registerSingleton(XmppContextUtils.XMPP_CONNECTION_BEAN_NAME, connection); ChatMessageListeningEndpoint endpoint = new ChatMessageListeningEndpoint(); DirectChannel outChannel = new DirectChannel(); outChannel.subscribe(message -> { throw new RuntimeException("ooops"); });//from ww w. j a v a 2 s . c om PollableChannel errorChannel = new QueueChannel(); endpoint.setBeanFactory(bf); endpoint.setOutputChannel(outChannel); endpoint.setErrorChannel(errorChannel); endpoint.afterPropertiesSet(); StanzaListener listener = (StanzaListener) TestUtils.getPropertyValue(endpoint, "stanzaListener"); Message smackMessage = new Message("kermit@frog.com"); smackMessage.setBody("hello"); smackMessage.setThread("1234"); listener.processPacket(smackMessage); ErrorMessage msg = (ErrorMessage) errorChannel.receive(); assertEquals("hello", ((MessagingException) msg.getPayload()).getFailedMessage().getPayload()); }