GH-2071: Upgrade to S-WS-3.0 and Smack-4.2.1
Fixes: spring-projects/spring-integration#2071 * Clean up `build.gradle` for redundant excludes * Add `javax.mail` dependency to WS module to avoid WARN about missed providers * Refactoring for the XMPP module according changes in the latest Smack * Polishing for the `BackToBackAdapterTests` to avoid extra wait for `null` on the channel and some race conditions when client is closed during by the `stop()` during publishing Polishing `UriVariableTests` according the latest S-WS B-S Revert excludes removal
This commit is contained in:
committed by
Gary Russell
parent
1f88e2de7b
commit
bc4337ffa8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -23,13 +23,13 @@ import static org.junit.Assert.assertSame;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smackx.jiveproperties.JivePropertiesManager;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -71,7 +71,7 @@ public class ChatMessageInboundChannelAdapterParserTests {
|
||||
private ChatMessageListeningEndpoint autoChannelAdapter;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public void testInboundAdapter() {
|
||||
ChatMessageListeningEndpoint adapter = context.getBean("xmppInboundAdapter", ChatMessageListeningEndpoint.class);
|
||||
MessageChannel errorChannel = (MessageChannel) TestUtils.getPropertyValue(adapter, "errorChannel");
|
||||
@@ -86,14 +86,14 @@ public class ChatMessageInboundChannelAdapterParserTests {
|
||||
assertEquals("#root", TestUtils.getPropertyValue(adapter, "payloadExpression.expression"));
|
||||
adapter.start();
|
||||
Map asyncRecvListeners = TestUtils.getPropertyValue(connection, "asyncRecvListeners", Map.class);
|
||||
assertEquals(1, asyncRecvListeners.size());
|
||||
assertSame(stanzaFilter,
|
||||
TestUtils.getPropertyValue(asyncRecvListeners.values().iterator().next(), "packetFilter"));
|
||||
assertEquals(6, asyncRecvListeners.size());
|
||||
Object lastListener = asyncRecvListeners.values().stream().reduce((first, second) -> second).get();
|
||||
assertSame(stanzaFilter, TestUtils.getPropertyValue(lastListener, "packetFilter"));
|
||||
adapter.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInboundAdapterUsageWithHeaderMapper() throws NotConnectedException {
|
||||
public void testInboundAdapterUsageWithHeaderMapper() throws Exception {
|
||||
XMPPConnection xmppConnection = Mockito.mock(XMPPConnection.class);
|
||||
|
||||
ChatMessageListeningEndpoint adapter = context.getBean("xmppInboundAdapter", ChatMessageListeningEndpoint.class);
|
||||
@@ -106,10 +106,10 @@ public class ChatMessageInboundChannelAdapterParserTests {
|
||||
|
||||
Message message = new Message();
|
||||
message.setBody("hello");
|
||||
message.setTo("oleg");
|
||||
message.setTo(JidCreate.from("oleg"));
|
||||
JivePropertiesManager.addProperty(message, "foo", "foo");
|
||||
JivePropertiesManager.addProperty(message, "bar", "bar");
|
||||
stanzaListener.processPacket(message);
|
||||
stanzaListener.processStanza(message);
|
||||
org.springframework.messaging.Message<?> siMessage = xmppInbound.receive(0);
|
||||
assertEquals("foo", siMessage.getHeaders().get("foo"));
|
||||
assertEquals("oleg", siMessage.getHeaders().get("xmpp_to"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -131,7 +131,7 @@ public class ChatMessageOutboundChannelAdapterParserTests {
|
||||
doAnswer(invocation -> {
|
||||
Object[] args = invocation.getArguments();
|
||||
org.jivesoftware.smack.packet.Message xmppMessage = (org.jivesoftware.smack.packet.Message) args[0];
|
||||
assertEquals("oleg", xmppMessage.getTo());
|
||||
assertEquals("oleg", xmppMessage.getTo().toString());
|
||||
assertEquals("foobar", JivePropertiesManager.getProperty(xmppMessage, "foobar"));
|
||||
return null;
|
||||
}).when(connection).sendStanza(Mockito.any(org.jivesoftware.smack.packet.Message.class));
|
||||
@@ -150,7 +150,7 @@ public class ChatMessageOutboundChannelAdapterParserTests {
|
||||
doAnswer(invocation -> {
|
||||
Object[] args = invocation.getArguments();
|
||||
org.jivesoftware.smack.packet.Message xmppMessage = (org.jivesoftware.smack.packet.Message) args[0];
|
||||
assertEquals("artem", xmppMessage.getTo());
|
||||
assertEquals("artem", xmppMessage.getTo().toString());
|
||||
assertEquals("hello", xmppMessage.getBody());
|
||||
return null;
|
||||
}).when(connection).sendStanza(Mockito.any(org.jivesoftware.smack.packet.Message.class));
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<bean id="xmppConnectionConfigurationBuilder" class="org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration"
|
||||
factory-method="builder">
|
||||
<property name="serviceName" value="myServiceName"/>
|
||||
<property name="xmppDomain" value="#{T(org.jxmpp.jid.impl.JidCreate).domainBareFrom('myServiceName')}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="xmppConnection" class="org.springframework.integration.xmpp.config.XmppConnectionFactoryBean">
|
||||
|
||||
@@ -40,7 +40,10 @@ public class XmppConnectionFactoryBeanTests {
|
||||
@Test
|
||||
public void testXmppConnectionFactoryBean() throws Exception {
|
||||
XmppConnectionFactoryBean xmppConnectionFactoryBean = new XmppConnectionFactoryBean();
|
||||
xmppConnectionFactoryBean.setConnectionConfiguration(mock(XMPPTCPConnectionConfiguration.class));
|
||||
xmppConnectionFactoryBean.setConnectionConfiguration(
|
||||
XMPPTCPConnectionConfiguration.builder()
|
||||
.setXmppDomain("foo")
|
||||
.build());
|
||||
XMPPConnection connection = xmppConnectionFactoryBean.createInstance();
|
||||
assertNotNull(connection);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 @@ package org.springframework.integration.xmpp.config;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.junit.Test;
|
||||
@@ -42,7 +41,7 @@ public class XmppConnectionParserTests {
|
||||
ConfigurableApplicationContext ac =
|
||||
new ClassPathXmlApplicationContext("XmppConnectionParserTests-simple.xml", this.getClass());
|
||||
XMPPConnection connection = ac.getBean("connection", XMPPConnection.class);
|
||||
assertEquals("my.domain", connection.getServiceName());
|
||||
assertEquals("my.domain", connection.getXMPPServiceDomain().toString());
|
||||
assertFalse(connection.isConnected());
|
||||
XmppConnectionFactoryBean xmppFb = ac.getBean("&connection", XmppConnectionFactoryBean.class);
|
||||
assertEquals("happy.user@my.domain", TestUtils.getPropertyValue(xmppFb, "user"));
|
||||
@@ -56,20 +55,12 @@ public class XmppConnectionParserTests {
|
||||
ac.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultConnectionName() {
|
||||
ConfigurableApplicationContext ac =
|
||||
new ClassPathXmlApplicationContext("XmppConnectionParserTests-simple.xml", this.getClass());
|
||||
assertTrue(ac.containsBean("xmppConnection"));
|
||||
ac.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompleteConfiguration() {
|
||||
ConfigurableApplicationContext ac =
|
||||
new ClassPathXmlApplicationContext("XmppConnectionParserTests-complete.xml", this.getClass());
|
||||
XMPPConnection connection = ac.getBean("connection", XMPPConnection.class);
|
||||
assertEquals("foogle.com", connection.getServiceName());
|
||||
assertEquals("foogle.com", connection.getXMPPServiceDomain().toString());
|
||||
assertFalse(connection.isConnected());
|
||||
XmppConnectionFactoryBean xmppFb = ac.getBean("&connection", XmppConnectionFactoryBean.class);
|
||||
assertEquals("happy.user", TestUtils.getPropertyValue(xmppFb, "user"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -18,6 +18,8 @@ package org.springframework.integration.xmpp.ignore;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -27,25 +29,26 @@ import org.springframework.messaging.support.GenericMessage;
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class SmackMessageSampleTests {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void validateSmackMessageSent() {
|
||||
public void validateSmackMessageSent() throws XmppStringprepException {
|
||||
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("SmackMessageSampleTest-context.xml",
|
||||
this.getClass());
|
||||
|
||||
MessageChannel xmppInput = ac.getBean("xmppInput", MessageChannel.class);
|
||||
|
||||
|
||||
org.jivesoftware.smack.packet.Message smackMessage = new org.jivesoftware.smack.packet.Message(
|
||||
"springintegration@gmail.com");
|
||||
org.jivesoftware.smack.packet.Message smackMessage =
|
||||
new org.jivesoftware.smack.packet.Message(JidCreate.from("springintegration@gmail.com"));
|
||||
smackMessage.setBody("Message sent as Smack Message");
|
||||
|
||||
Message<org.jivesoftware.smack.packet.Message> message =
|
||||
new GenericMessage<org.jivesoftware.smack.packet.Message>(smackMessage);
|
||||
Message<org.jivesoftware.smack.packet.Message> message = new GenericMessage<>(smackMessage);
|
||||
|
||||
xmppInput.send(message);
|
||||
ac.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.gcm.packet.GcmPacketExtension;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mockito;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
@@ -126,7 +128,7 @@ public class ChatMessageListeningEndpointTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithErrorChannel() throws NotConnectedException {
|
||||
public void testWithErrorChannel() throws NotConnectedException, XmppStringprepException, InterruptedException {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
XMPPConnection connection = mock(XMPPConnection.class);
|
||||
bf.registerSingleton(XmppContextUtils.XMPP_CONNECTION_BEAN_NAME, connection);
|
||||
@@ -143,10 +145,10 @@ public class ChatMessageListeningEndpointTests {
|
||||
endpoint.setErrorChannel(errorChannel);
|
||||
endpoint.afterPropertiesSet();
|
||||
StanzaListener listener = (StanzaListener) TestUtils.getPropertyValue(endpoint, "stanzaListener");
|
||||
Message smackMessage = new Message("kermit@frog.com");
|
||||
Message smackMessage = new Message(JidCreate.from("kermit@frog.com"));
|
||||
smackMessage.setBody("hello");
|
||||
smackMessage.setThread("1234");
|
||||
listener.processPacket(smackMessage);
|
||||
listener.processStanza(smackMessage);
|
||||
|
||||
ErrorMessage msg =
|
||||
(ErrorMessage) errorChannel.receive();
|
||||
@@ -170,7 +172,7 @@ public class ChatMessageListeningEndpointTests {
|
||||
Message smackMessage = new Message();
|
||||
smackMessage.setBody("foo");
|
||||
|
||||
XmlPullParser xmlPullParser = PacketParserUtils.newXmppParser(new StringReader(smackMessage.toString()));
|
||||
XmlPullParser xmlPullParser = PacketParserUtils.newXmppParser(new StringReader(smackMessage.toXML().toString()));
|
||||
xmlPullParser.next();
|
||||
testXMPPConnection.parseAndProcessStanza(xmlPullParser);
|
||||
|
||||
@@ -196,7 +198,7 @@ public class ChatMessageListeningEndpointTests {
|
||||
endpoint.setPayloadExpression(null);
|
||||
|
||||
smackMessage = new Message();
|
||||
xmlPullParser = PacketParserUtils.newXmppParser(new StringReader(smackMessage.toString()));
|
||||
xmlPullParser = PacketParserUtils.newXmppParser(new StringReader(smackMessage.toXML().toString()));
|
||||
xmlPullParser.next();
|
||||
testXMPPConnection.parseAndProcessStanza(xmlPullParser);
|
||||
|
||||
@@ -239,7 +241,7 @@ public class ChatMessageListeningEndpointTests {
|
||||
endpoint.afterPropertiesSet();
|
||||
endpoint.start();
|
||||
|
||||
XmlPullParser xmlPullParser = PacketParserUtils.newXmppParser(new StringReader(smackMessage.toString()));
|
||||
XmlPullParser xmlPullParser = PacketParserUtils.newXmppParser(new StringReader(smackMessage.toXML().toString()));
|
||||
xmlPullParser.next();
|
||||
testXMPPConnection.parseAndProcessStanza(xmlPullParser);
|
||||
|
||||
|
||||
@@ -19,12 +19,8 @@ package org.springframework.integration.xmpp.inbound;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
@@ -57,21 +53,11 @@ public class PresenceListeningEndpointTests {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testEndpointLifecycle() {
|
||||
final Set<RosterListener> rosterSet = new HashSet<RosterListener>();
|
||||
XMPPConnection connection = mock(XMPPConnection.class);
|
||||
Roster roster = mock(Roster.class);
|
||||
Map<XMPPConnection, Roster> instances = TestUtils.getPropertyValue(roster, "INSTANCES", Map.class);
|
||||
instances.put(connection, roster);
|
||||
Roster roster = Roster.getInstanceFor(connection);
|
||||
|
||||
doAnswer(invocation -> {
|
||||
rosterSet.add(invocation.getArgument(0));
|
||||
return null;
|
||||
}).when(roster).addRosterListener(any(RosterListener.class));
|
||||
Set<RosterListener> rosterSet = TestUtils.getPropertyValue(roster, "rosterListeners", Set.class);
|
||||
|
||||
doAnswer(invocation -> {
|
||||
rosterSet.remove((RosterListener) invocation.getArgument(0));
|
||||
return null;
|
||||
}).when(roster).removeRosterListener(any(RosterListener.class));
|
||||
PresenceListeningEndpoint rosterEndpoint = new PresenceListeningEndpoint(connection);
|
||||
rosterEndpoint.setOutputChannel(new QueueChannel());
|
||||
rosterEndpoint.setBeanFactory(mock(BeanFactory.class));
|
||||
@@ -93,9 +79,6 @@ public class PresenceListeningEndpointTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testRosterPresenceChangeEvent() {
|
||||
XMPPConnection connection = mock(XMPPConnection.class);
|
||||
Roster roster = mock(Roster.class);
|
||||
Map<XMPPConnection, Roster> instances = TestUtils.getPropertyValue(roster, "INSTANCES", Map.class);
|
||||
instances.put(connection, roster);
|
||||
PresenceListeningEndpoint rosterEndpoint = new PresenceListeningEndpoint(connection);
|
||||
QueueChannel channel = new QueueChannel();
|
||||
rosterEndpoint.setOutputChannel(channel);
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smackx.gcm.packet.GcmPacketExtension;
|
||||
import org.jivesoftware.smackx.gcm.provider.GcmExtensionProvider;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@@ -112,7 +113,8 @@ public class ChatMessageSendingMessageHandlerTests {
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
org.jivesoftware.smack.packet.Message smackMessage = new org.jivesoftware.smack.packet.Message("kermit@frog.com");
|
||||
org.jivesoftware.smack.packet.Message smackMessage =
|
||||
new org.jivesoftware.smack.packet.Message(JidCreate.from("kermit@frog.com"));
|
||||
smackMessage.setBody("Test Message");
|
||||
|
||||
|
||||
@@ -123,7 +125,7 @@ public class ChatMessageSendingMessageHandlerTests {
|
||||
verify(connection, times(1)).sendStanza(smackMessage);
|
||||
|
||||
// assuming we know thread ID although currently we do not provide this capability
|
||||
smackMessage = new org.jivesoftware.smack.packet.Message("kermit@frog.com");
|
||||
smackMessage = new org.jivesoftware.smack.packet.Message(JidCreate.from("kermit@frog.com"));
|
||||
smackMessage.setBody("Hello Kitty");
|
||||
smackMessage.setThread("123");
|
||||
message = MessageBuilder.withPayload(smackMessage).build();
|
||||
@@ -159,7 +161,7 @@ public class ChatMessageSendingMessageHandlerTests {
|
||||
org.jivesoftware.smack.packet.Message smackMessage = argumentCaptor.getValue();
|
||||
|
||||
assertNull(smackMessage.getBody());
|
||||
assertEquals("kermit@frog.com", smackMessage.getTo());
|
||||
assertEquals("kermit@frog.com", smackMessage.getTo().toString());
|
||||
GcmPacketExtension gcmPacketExtension = GcmPacketExtension.from(smackMessage);
|
||||
assertNotNull(gcmPacketExtension);
|
||||
assertEquals(json, gcmPacketExtension.getJson());
|
||||
@@ -171,13 +173,13 @@ public class ChatMessageSendingMessageHandlerTests {
|
||||
@Test(expected = MessageHandlingException.class)
|
||||
public void validateFailureNoChatToUser() throws Exception {
|
||||
ChatMessageSendingMessageHandler handler = new ChatMessageSendingMessageHandler(mock(XMPPConnection.class));
|
||||
handler.handleMessage(new GenericMessage<String>("hello"));
|
||||
handler.handleMessage(new GenericMessage<>("hello"));
|
||||
}
|
||||
|
||||
@Test(expected = MessageHandlingException.class)
|
||||
public void validateMessageWithUnsupportedPayload() throws Exception {
|
||||
ChatMessageSendingMessageHandler handler = new ChatMessageSendingMessageHandler(mock(XMPPConnection.class));
|
||||
handler.handleMessage(new GenericMessage<Integer>(123));
|
||||
handler.handleMessage(new GenericMessage<>(123));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -25,6 +25,8 @@ import java.util.Map;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smackx.jiveproperties.JivePropertiesManager;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
import org.springframework.integration.xmpp.XmppHeaders;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
@@ -32,6 +34,8 @@ import org.springframework.messaging.MessageHeaders;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Florian Schmaus
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class DefaultXmppHeaderMapperTests {
|
||||
@@ -39,7 +43,7 @@ public class DefaultXmppHeaderMapperTests {
|
||||
@Test
|
||||
public void fromHeadersStandardOutbound() {
|
||||
DefaultXmppHeaderMapper mapper = new DefaultXmppHeaderMapper();
|
||||
Map<String, Object> headerMap = new HashMap<String, Object>();
|
||||
Map<String, Object> headerMap = new HashMap<>();
|
||||
headerMap.put("userDefined1", "foo");
|
||||
headerMap.put("userDefined2", "bar");
|
||||
headerMap.put(XmppHeaders.THREAD, "test.thread");
|
||||
@@ -53,8 +57,8 @@ public class DefaultXmppHeaderMapperTests {
|
||||
|
||||
// "standard" XMPP headers
|
||||
assertEquals("test.thread", target.getThread());
|
||||
assertEquals("test.to", target.getTo());
|
||||
assertEquals("test.from", target.getFrom());
|
||||
assertEquals("test.to", target.getTo().toString());
|
||||
assertEquals("test.from", target.getFrom().toString());
|
||||
assertEquals("test.subject", target.getSubject());
|
||||
assertEquals(Message.Type.headline, target.getType());
|
||||
|
||||
@@ -70,7 +74,7 @@ public class DefaultXmppHeaderMapperTests {
|
||||
@Test
|
||||
public void fromHeadersUserDefinedOnly() {
|
||||
DefaultXmppHeaderMapper mapper = new DefaultXmppHeaderMapper();
|
||||
mapper.setRequestHeaderNames(new String[] { "userDefined1", "userDefined2" });
|
||||
mapper.setRequestHeaderNames("userDefined1", "userDefined2");
|
||||
Map<String, Object> headerMap = new HashMap<String, Object>();
|
||||
headerMap.put("userDefined1", "foo");
|
||||
headerMap.put("userDefined2", "bar");
|
||||
@@ -104,17 +108,17 @@ public class DefaultXmppHeaderMapperTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toHeadersStandardOnly() {
|
||||
public void toHeadersStandardOnly() throws XmppStringprepException {
|
||||
DefaultXmppHeaderMapper mapper = new DefaultXmppHeaderMapper();
|
||||
Message source = new Message("test.to", Message.Type.headline);
|
||||
source.setFrom("test.from");
|
||||
Message source = new Message(JidCreate.from("test.to"), Message.Type.headline);
|
||||
source.setFrom(JidCreate.from("test.from"));
|
||||
source.setSubject("test.subject");
|
||||
source.setThread("test.thread");
|
||||
JivePropertiesManager.addProperty(source, "userDefined1", "foo");
|
||||
JivePropertiesManager.addProperty(source, "userDefined2", "bar");
|
||||
Map<String, Object> headers = mapper.toHeadersFromRequest(source);
|
||||
assertEquals("test.to", headers.get(XmppHeaders.TO));
|
||||
assertEquals("test.from", headers.get(XmppHeaders.FROM));
|
||||
assertEquals("test.to", headers.get(XmppHeaders.TO).toString());
|
||||
assertEquals("test.from", headers.get(XmppHeaders.FROM).toString());
|
||||
assertEquals("test.subject", headers.get(XmppHeaders.SUBJECT));
|
||||
assertEquals("test.thread", headers.get(XmppHeaders.THREAD));
|
||||
assertEquals(Message.Type.headline, headers.get(XmppHeaders.TYPE));
|
||||
@@ -123,11 +127,11 @@ public class DefaultXmppHeaderMapperTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toHeadersUserDefinedOnly() {
|
||||
public void toHeadersUserDefinedOnly() throws XmppStringprepException {
|
||||
DefaultXmppHeaderMapper mapper = new DefaultXmppHeaderMapper();
|
||||
mapper.setReplyHeaderNames(new String[] { "userDefined*" });
|
||||
Message source = new Message("test.to", Message.Type.headline);
|
||||
source.setFrom("test.from");
|
||||
mapper.setReplyHeaderNames("userDefined*");
|
||||
Message source = new Message(JidCreate.from("test.to"), Message.Type.headline);
|
||||
source.setFrom(JidCreate.from("test.from"));
|
||||
source.setSubject("test.subject");
|
||||
source.setThread("test.thread");
|
||||
JivePropertiesManager.addProperty(source, "userDefined1", "foo");
|
||||
|
||||
Reference in New Issue
Block a user