Repository: camel Updated Branches: refs/heads/master 4938eee27 -> 341e66ecd
CAMEL-10544: Should resolve a given room's domain properly if not explicitly provided Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/341e66ec Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/341e66ec Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/341e66ec Branch: refs/heads/master Commit: 341e66ecd853b848e29e298066ee21e96ac0e2f7 Parents: 4938eee Author: Babak Vahdat <[email protected]> Authored: Thu May 18 21:13:28 2017 +0200 Committer: Babak Vahdat <[email protected]> Committed: Thu May 18 21:13:28 2017 +0200 ---------------------------------------------------------------------- .../camel/component/xmpp/XmppEndpoint.java | 22 ++++++++------------ .../component/xmpp/XmppMultiUserChatTest.java | 9 +++++--- 2 files changed, 15 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/341e66ec/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java index 2fd6699..fb82b4b 100644 --- a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java +++ b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java @@ -48,7 +48,6 @@ import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; import org.jivesoftware.smackx.iqregister.AccountManager; import org.jivesoftware.smackx.muc.MultiUserChatManager; import org.jxmpp.jid.DomainBareJid; -import org.jxmpp.jid.EntityBareJid; import org.jxmpp.jid.parts.Localpart; import org.jxmpp.jid.parts.Resourcepart; import org.jxmpp.stringprep.XmppStringprepException; @@ -182,8 +181,8 @@ public class XmppEndpoint extends DefaultEndpoint implements HeaderFilterStrateg newConnection.connect(); - newConnection.addSyncStanzaListener(new XmppLogger("INBOUND"), (stanza -> true)); - newConnection.addSyncStanzaListener(new XmppLogger("OUTBOUND"), (stanza -> true)); + newConnection.addSyncStanzaListener(new XmppLogger("INBOUND"), stanza -> true); + newConnection.addSyncStanzaListener(new XmppLogger("OUTBOUND"), stanza -> true); if (!newConnection.isAuthenticated()) { if (user != null) { @@ -230,7 +229,11 @@ public class XmppEndpoint extends DefaultEndpoint implements HeaderFilterStrateg port = 5222; } String sName = getServiceName() == null ? host : getServiceName(); - XMPPTCPConnectionConfiguration conf = XMPPTCPConnectionConfiguration.builder().setHostAddress(InetAddress.getByName(host)).setPort(port).setXmppDomain(sName).build(); + XMPPTCPConnectionConfiguration conf = XMPPTCPConnectionConfiguration.builder() + .setHostAddress(InetAddress.getByName(host)) + .setPort(port) + .setXmppDomain(sName) + .build(); return new XMPPTCPConnection(conf); } @@ -249,17 +252,10 @@ public class XmppEndpoint extends DefaultEndpoint implements HeaderFilterStrateg List<DomainBareJid> xmppServiceDomains = multiUserChatManager.getXMPPServiceDomains(); if (xmppServiceDomains.isEmpty()) { throw new XMPPErrorException(null, - XMPPError.from(Condition.item_not_found, "Cannot find Multi User Chat service on connection: " + getConnectionMessage(connection)).build()); + XMPPError.from(Condition.item_not_found, "Cannot find any XMPPServiceDomain by MultiUserChatManager on connection: " + getConnectionMessage(connection)).build()); } - for (EntityBareJid joinedRoom : multiUserChatManager.getJoinedRooms()) { - if (joinedRoom.toString().equals(room)) { - LOG.debug("Resolved chat room: {}", room); - return room; - } - } - - throw new IllegalStateException("Could not find the joined room: " + room); + return room + "@" + xmppServiceDomains.iterator().next(); } public String getConnectionDescription() { http://git-wip-us.apache.org/repos/asf/camel/blob/341e66ec/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppMultiUserChatTest.java ---------------------------------------------------------------------- diff --git a/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppMultiUserChatTest.java b/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppMultiUserChatTest.java index 406ee4d..e0f6a71 100644 --- a/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppMultiUserChatTest.java +++ b/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppMultiUserChatTest.java @@ -68,15 +68,18 @@ public class XmppMultiUserChatTest extends CamelTestSupport { } protected String getProducerUri() { - - // the nickname paramenter is necessary in these URLs because the '@' in the user name can not be parsed by + // the nickname parameter is necessary in these URLs because the '@' in the user name can not be parsed by // vysper during chat room message routing. + // here on purpose we provide the room query parameter without the domain name as 'camel-test', and camel + // will resolve it properly to '[email protected]' return "xmpp://localhost:" + EmbeddedXmppTestServer.instance().getXmppPort() - + "/?connectionConfig=#customConnectionConfig&[email protected]&[email protected]&password=secret&nickname=camel_producer"; + + "/?connectionConfig=#customConnectionConfig&room=camel-test&[email protected]&password=secret&nickname=camel_producer"; } protected String getConsumerUri() { + // however here we provide the room query parameter as fully qualified including the domain name as + // '[email protected]' return "xmpp://localhost:" + EmbeddedXmppTestServer.instance().getXmppPort() + "/?connectionConfig=#customConnectionConfig&[email protected]&[email protected]&password=secret&nickname=camel_consumer"; }
