Code clean up for XMPP module
* Ugrade to Checkstyle `10.0` * Migrate XMPP test to JUnit `5`
This commit is contained in:
@@ -359,7 +359,7 @@ configure(javaProjects) { subproject ->
|
||||
|
||||
checkstyle {
|
||||
configDirectory.set(rootProject.file('src/checkstyle'))
|
||||
toolVersion = project.hasProperty('checkstyleVersion') ? project.checkstyleVersion : '9.2.1'
|
||||
toolVersion = project.hasProperty('checkstyleVersion') ? project.checkstyleVersion : '10.0'
|
||||
}
|
||||
|
||||
jar {
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* MessageHandler that sends an XMPP Chat Message. Supported payload types are Smack Message
|
||||
* (org.jivesoftware.smack.packet.Message) or String.
|
||||
* {@link org.jivesoftware.smack.packet.Message} or String.
|
||||
*
|
||||
* @author Josh Long
|
||||
* @author Mario Gray
|
||||
|
||||
@@ -105,7 +105,6 @@ public class DefaultXmppHeaderMapper extends AbstractHeaderMapper<MessageBuilder
|
||||
target.setThread(threadId);
|
||||
}
|
||||
populateToHeader(headers, target);
|
||||
|
||||
populateFromHeader(headers, target);
|
||||
|
||||
String subject = getHeaderIfAvailable(headers, XmppHeaders.SUBJECT, String.class);
|
||||
@@ -119,10 +118,8 @@ public class DefaultXmppHeaderMapper extends AbstractHeaderMapper<MessageBuilder
|
||||
typeHeader = Message.Type.valueOf((String) typeHeader);
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("XMPP Type must be either a valid [Message.Type] " +
|
||||
"enum value or a String representation of such.");
|
||||
}
|
||||
logger.warn("XMPP Type must be either a valid [Message.Type] " +
|
||||
"enum value or a String representation of such.");
|
||||
}
|
||||
}
|
||||
if (typeHeader instanceof Message.Type messageType) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -26,8 +26,7 @@ import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.MessageBuilder;
|
||||
import org.jivesoftware.smack.packet.StanzaBuilder;
|
||||
import org.jivesoftware.smackx.jiveproperties.JivePropertiesManager;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@@ -40,8 +39,7 @@ import org.springframework.integration.xmpp.inbound.ChatMessageListeningEndpoint
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
@@ -51,8 +49,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Florian Schmaus
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class ChatMessageInboundChannelAdapterParserTests {
|
||||
|
||||
@@ -70,7 +67,7 @@ public class ChatMessageInboundChannelAdapterParserTests {
|
||||
private ChatMessageListeningEndpoint autoChannelAdapter;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void testInboundAdapter() {
|
||||
ChatMessageListeningEndpoint adapter = context.getBean("xmppInboundAdapter", ChatMessageListeningEndpoint.class);
|
||||
MessageChannel errorChannel = (MessageChannel) TestUtils.getPropertyValue(adapter, "errorChannel");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -24,8 +24,7 @@ import static org.mockito.Mockito.verify;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.jiveproperties.JivePropertiesManager;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -45,8 +44,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
@@ -55,8 +53,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Gunnar Hillert
|
||||
* @author Florian Schmaus
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
public class ChatMessageOutboundChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
@@ -114,7 +111,6 @@ public class ChatMessageOutboundChannelAdapterParserTests {
|
||||
.isSameAs(this.extensionElementProvider);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void withHeaderMapper() throws Exception {
|
||||
Object pollingConsumer = context.getBean("withHeaderMapper");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
package org.springframework.integration.xmpp.config;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
@@ -28,8 +30,11 @@ public class PresenceInboundChannelAdapterParserTests {
|
||||
|
||||
@Test
|
||||
public void testPresenceInboundChannelAdapterParser() {
|
||||
new ClassPathXmlApplicationContext("PresenceInboundChannelAdapterParserTests-context.xml", this.getClass()).close();
|
||||
// no assertion needed. The fact that no exception was thrown satisfies this test
|
||||
assertThatNoException()
|
||||
.isThrownBy(() ->
|
||||
new ClassPathXmlApplicationContext("PresenceInboundChannelAdapterParserTests-context.xml",
|
||||
this.getClass())
|
||||
.close());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -20,8 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -35,17 +34,16 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
public class PresenceOutboundChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -17,13 +17,14 @@
|
||||
package org.springframework.integration.xmpp.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.roster.Roster;
|
||||
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
||||
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
@@ -47,9 +48,12 @@ public class XmppConnectionFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmppConnectionFactoryBeanViaConfig() throws Exception {
|
||||
new ClassPathXmlApplicationContext("XmppConnectionFactoryBeanTests-context.xml", this.getClass()).close();
|
||||
// the fact that no exception was thrown satisfies this test
|
||||
public void testXmppConnectionFactoryBeanViaConfig() {
|
||||
assertThatNoException()
|
||||
.isThrownBy(() ->
|
||||
new ClassPathXmlApplicationContext("XmppConnectionFactoryBeanTests-context.xml",
|
||||
this.getClass())
|
||||
.close());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.integration.xmpp.config;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
@@ -38,7 +38,7 @@ public class XmppConnectionParserTests {
|
||||
public void testSimpleConfiguration() {
|
||||
ConfigurableApplicationContext ac =
|
||||
new ClassPathXmlApplicationContext("XmppConnectionParserTests-simple.xml", this.getClass());
|
||||
XMPPConnection connection = ac.getBean("connection", XMPPConnection.class);
|
||||
XMPPConnection connection = ac.getBean("connection", XMPPConnection.class);
|
||||
assertThat(connection.getXMPPServiceDomain().toString()).isEqualTo("my.domain");
|
||||
assertThat(connection.isConnected()).isFalse();
|
||||
XmppConnectionFactoryBean xmppFb = ac.getBean("&connection", XmppConnectionFactoryBean.class);
|
||||
@@ -57,7 +57,7 @@ public class XmppConnectionParserTests {
|
||||
public void testCompleteConfiguration() {
|
||||
ConfigurableApplicationContext ac =
|
||||
new ClassPathXmlApplicationContext("XmppConnectionParserTests-complete.xml", this.getClass());
|
||||
XMPPConnection connection = ac.getBean("connection", XMPPConnection.class);
|
||||
XMPPConnection connection = ac.getBean("connection", XMPPConnection.class);
|
||||
assertThat(connection.getXMPPServiceDomain().toString()).isEqualTo("foogle.com");
|
||||
assertThat(connection.isConnected()).isFalse();
|
||||
XmppConnectionFactoryBean xmppFb = ac.getBean("&connection", XmppConnectionFactoryBean.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -25,8 +25,7 @@ import static org.mockito.Mockito.verify;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -38,8 +37,7 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -50,8 +48,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class XmppHeaderEnricherParserTests {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -16,13 +16,12 @@
|
||||
|
||||
package org.springframework.integration.xmpp.ignore;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -30,8 +29,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@Disabled
|
||||
public class ConsoleChatTests {
|
||||
|
||||
public static void main(String[] args) {
|
||||
@@ -39,7 +38,6 @@ public class ConsoleChatTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void run() throws Exception {
|
||||
Thread.sleep(10 * 1000 * 1000);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -16,23 +16,20 @@
|
||||
|
||||
package org.springframework.integration.xmpp.ignore;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Josh Long
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@Disabled
|
||||
public class InboundChatTests {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void run() throws Exception {
|
||||
Thread.sleep(10 * 1000 * 1000);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -16,12 +16,11 @@
|
||||
|
||||
package org.springframework.integration.xmpp.ignore;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* this class demonstrates that when I launch this and then manipulate the status of the
|
||||
@@ -30,12 +29,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Josh Long
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@Disabled
|
||||
public class InboundPresenceTests {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void run() throws Exception {
|
||||
Thread.sleep(60 * 1000 * 1000);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -16,12 +16,10 @@
|
||||
|
||||
package org.springframework.integration.xmpp.ignore;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* Testing support for sending messages.
|
||||
@@ -29,12 +27,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Josh Long
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@Disabled
|
||||
public class OutboundChatTests {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void run() throws Exception {
|
||||
Thread.sleep(10 * 1000 * 100);
|
||||
}
|
||||
|
||||
@@ -18,17 +18,15 @@ package org.springframework.integration.xmpp.ignore;
|
||||
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.StanzaBuilder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.xmpp.outbound.PresenceSendingMessageHandler;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* Tests {@link PresenceSendingMessageHandler} to ensure that we are able to publish status.
|
||||
@@ -38,8 +36,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@Disabled
|
||||
public class OutboundPresenceTests {
|
||||
|
||||
@Autowired
|
||||
@@ -47,7 +45,6 @@ public class OutboundPresenceTests {
|
||||
private DirectChannel input;
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testOutbound() throws Throwable {
|
||||
Presence presence = StanzaBuilder.buildPresence().build();
|
||||
input.send(new GenericMessage<>(presence));
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.integration.xmpp.ignore;
|
||||
|
||||
import org.jivesoftware.smack.packet.StanzaBuilder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
@@ -32,10 +32,10 @@ import org.springframework.messaging.support.GenericMessage;
|
||||
* @author Artem Bilan
|
||||
* @author Florian Schmaus
|
||||
*/
|
||||
@Disabled
|
||||
public class SmackMessageSampleTests {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void validateSmackMessageSent() throws XmppStringprepException {
|
||||
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("SmackMessageSampleTest-context.xml",
|
||||
this.getClass());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -37,8 +37,8 @@ public class XmppMessageConsumer {
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@ServiceActivator
|
||||
public void consume(Object input) throws Throwable {
|
||||
String text = null;
|
||||
public void consume(Object input) {
|
||||
String text;
|
||||
if (input instanceof Message) {
|
||||
text = ((Message) input).getBody();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -218,15 +218,15 @@ public class ChatMessageListeningEndpointTests {
|
||||
|
||||
@Test
|
||||
public void testGcmExtension() throws Exception {
|
||||
String data = "{\n" +
|
||||
" \"to\":\"me\",\n" +
|
||||
" \"notification\": {\n" +
|
||||
" \"title\": \"Something interesting\",\n" +
|
||||
" \"text\": \"Here we go\"\n" +
|
||||
" },\n" +
|
||||
" \"time_to_live\":\"600\"\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
String data = """
|
||||
{
|
||||
"to":"me",
|
||||
"notification": {
|
||||
"title": "Something interesting",
|
||||
"text": "Here we go"
|
||||
},
|
||||
"time_to_live":"600"
|
||||
}""";
|
||||
GcmPacketExtension packetExtension = new GcmPacketExtension(data);
|
||||
MessageBuilder smackMessage = StanzaBuilder.buildMessage();
|
||||
smackMessage.addExtension(packetExtension);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.xmpp.inbound;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -26,7 +27,7 @@ import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.StanzaBuilder;
|
||||
import org.jivesoftware.smack.roster.Roster;
|
||||
import org.jivesoftware.smack.roster.RosterListener;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
@@ -67,10 +68,11 @@ public class PresenceListeningEndpointTests {
|
||||
assertThat(rosterSet.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testNonInitializedFailure() {
|
||||
PresenceListeningEndpoint rosterEndpoint = new PresenceListeningEndpoint(mock(XMPPConnection.class));
|
||||
rosterEndpoint.start();
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(rosterEndpoint::start);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,11 +106,12 @@ public class PresenceListeningEndpointTests {
|
||||
assertThat(TestUtils.getPropertyValue(endpoint, "xmppConnection")).isNotNull();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testNoXmppConnection() {
|
||||
PresenceListeningEndpoint handler = new PresenceListeningEndpoint();
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(handler::afterPropertiesSet);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package org.springframework.integration.xmpp.outbound;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
@@ -28,7 +30,7 @@ import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.StanzaBuilder;
|
||||
import org.jivesoftware.smackx.gcm.packet.GcmPacketExtension;
|
||||
import org.jivesoftware.smackx.gcm.provider.GcmExtensionProvider;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@@ -50,7 +52,6 @@ import org.springframework.messaging.support.GenericMessage;
|
||||
*/
|
||||
public class ChatMessageSendingMessageHandlerTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testSendMessages() throws Exception {
|
||||
XMPPConnection connection = mock(XMPPConnection.class);
|
||||
@@ -184,16 +185,18 @@ public class ChatMessageSendingMessageHandlerTests {
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = MessageHandlingException.class)
|
||||
public void validateFailureNoChatToUser() throws Exception {
|
||||
@Test
|
||||
public void validateFailureNoChatToUser() {
|
||||
ChatMessageSendingMessageHandler handler = new ChatMessageSendingMessageHandler(mock(XMPPConnection.class));
|
||||
handler.handleMessage(new GenericMessage<>("hello"));
|
||||
assertThatExceptionOfType(MessageHandlingException.class)
|
||||
.isThrownBy(() -> handler.handleMessage(new GenericMessage<>("hello")));
|
||||
}
|
||||
|
||||
@Test(expected = MessageHandlingException.class)
|
||||
public void validateMessageWithUnsupportedPayload() throws Exception {
|
||||
@Test
|
||||
public void validateMessageWithUnsupportedPayload() {
|
||||
ChatMessageSendingMessageHandler handler = new ChatMessageSendingMessageHandler(mock(XMPPConnection.class));
|
||||
handler.handleMessage(new GenericMessage<>(123));
|
||||
assertThatExceptionOfType(MessageHandlingException.class)
|
||||
.isThrownBy(() -> handler.handleMessage(new GenericMessage<>(123)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -206,11 +209,12 @@ public class ChatMessageSendingMessageHandlerTests {
|
||||
assertThat(TestUtils.getPropertyValue(handler, "xmppConnection")).isNotNull();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testNoXmppConnection() {
|
||||
ChatMessageSendingMessageHandler handler = new ChatMessageSendingMessageHandler();
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(handler::afterPropertiesSet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
package org.springframework.integration.xmpp.outbound;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.StanzaBuilder;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
@@ -46,13 +48,13 @@ public class PresenceSendingMessageHandlerTests {
|
||||
handler.handleMessage(new GenericMessage<>(StanzaBuilder.buildPresence().build()));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Test(expected = MessageHandlingException.class)
|
||||
@Test
|
||||
public void testWrongPayload() {
|
||||
PresenceSendingMessageHandler handler = new PresenceSendingMessageHandler(mock(XMPPConnection.class));
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
handler.handleMessage(new GenericMessage(new Object()));
|
||||
assertThatExceptionOfType(MessageHandlingException.class)
|
||||
.isThrownBy(() -> handler.handleMessage(new GenericMessage<>(new Object())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,11 +67,12 @@ public class PresenceSendingMessageHandlerTests {
|
||||
assertThat(TestUtils.getPropertyValue(handler, "xmppConnection")).isNotNull();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testNoXmppConnection() {
|
||||
PresenceSendingMessageHandler handler = new PresenceSendingMessageHandler();
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(handler::afterPropertiesSet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -25,7 +25,7 @@ import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.MessageBuilder;
|
||||
import org.jivesoftware.smack.packet.StanzaBuilder;
|
||||
import org.jivesoftware.smackx.jiveproperties.JivePropertiesManager;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
import org.springframework.integration.xmpp.XmppHeaders;
|
||||
|
||||
Reference in New Issue
Block a user