diff --git a/source/org/jivesoftware/smack/PacketCollector.java b/source/org/jivesoftware/smack/PacketCollector.java
index 3ef49aa12..317e940b2 100644
--- a/source/org/jivesoftware/smack/PacketCollector.java
+++ b/source/org/jivesoftware/smack/PacketCollector.java
@@ -32,8 +32,9 @@ import java.util.LinkedList;
* use than a {@link PacketListener} when you need to wait for a specific
* result.
*
- * Each packet collector will queue up to 2^16 packets for processing before
- * older packets are automatically dropped.
+ * Each packet collector will queue up a configured number of packets for processing before
+ * older packets are automatically dropped. The default number is retrieved by
+ * {@link SmackConfiguration#getPacketCollectorSize()}.
*
* @see Connection#createPacketCollector(PacketFilter)
* @author Matt Tucker
@@ -45,7 +46,7 @@ public class PacketCollector {
* reached, older packets will be automatically dropped from the queue as
* new packets are added.
*/
- private static final int MAX_PACKETS = 65536;
+ private int maxPackets = SmackConfiguration.getPacketCollectorSize();
private PacketFilter packetFilter;
private LinkedList resultQueue;
@@ -65,6 +66,19 @@ public class PacketCollector {
this.resultQueue = new LinkedList();
}
+ /**
+ * Creates a new packet collector. If the packet filter is null, then
+ * all packets will match this collector.
+ *
+ * @param conection the connection the collector is tied to.
+ * @param packetFilter determines which packets will be returned by this collector.
+ * @param maxSize the maximum number of packets that will be stored in the collector.
+ */
+ protected PacketCollector(Connection conection, PacketFilter packetFilter, int maxSize) {
+ this(conection, packetFilter);
+ maxPackets = maxSize;
+ }
+
/**
* Explicitly cancels the packet collector so that no more results are
* queued up. Once a packet collector has been cancelled, it cannot be
@@ -180,7 +194,7 @@ public class PacketCollector {
}
if (packetFilter == null || packetFilter.accept(packet)) {
// If the max number of packets has been reached, remove the oldest one.
- if (resultQueue.size() == MAX_PACKETS) {
+ if (resultQueue.size() == maxPackets) {
resultQueue.removeLast();
}
// Add the new packet.
diff --git a/source/org/jivesoftware/smack/SmackConfiguration.java b/source/org/jivesoftware/smack/SmackConfiguration.java
index 0e09d23f8..5c4c931a3 100644
--- a/source/org/jivesoftware/smack/SmackConfiguration.java
+++ b/source/org/jivesoftware/smack/SmackConfiguration.java
@@ -44,14 +44,15 @@ import java.util.*;
*/
public final class SmackConfiguration {
- private static final String SMACK_VERSION = "3.2.0";
+ private static final String SMACK_VERSION = "3.2.1";
private static int packetReplyTimeout = 5000;
private static int keepAliveInterval = 30000;
private static Vector defaultMechs = new Vector();
private static boolean localSocks5ProxyEnabled = true;
- private static int localSocks5ProxyPort = 7777;
+ private static int localSocks5ProxyPort = 7778;
+ private static int packetCollectorSize = 5000;
private SmackConfiguration() {
}
@@ -85,20 +86,22 @@ public final class SmackConfiguration {
parseClassToLoad(parser);
}
else if (parser.getName().equals("packetReplyTimeout")) {
- packetReplyTimeout =
- parseIntProperty(parser, packetReplyTimeout);
+ packetReplyTimeout = parseIntProperty(parser, packetReplyTimeout);
}
else if (parser.getName().equals("keepAliveInterval")) {
keepAliveInterval = parseIntProperty(parser, keepAliveInterval);
}
else if (parser.getName().equals("mechName")) {
defaultMechs.add(parser.nextText());
- } else if (parser.getName().equals("localSocks5ProxyEnabled")) {
- localSocks5ProxyEnabled = Boolean.parseBoolean(parser
- .nextText());
- } else if (parser.getName().equals("localSocks5ProxyPort")) {
- localSocks5ProxyPort = parseIntProperty(parser,
- localSocks5ProxyPort);
+ }
+ else if (parser.getName().equals("localSocks5ProxyEnabled")) {
+ localSocks5ProxyEnabled = Boolean.parseBoolean(parser.nextText());
+ }
+ else if (parser.getName().equals("localSocks5ProxyPort")) {
+ localSocks5ProxyPort = parseIntProperty(parser, localSocks5ProxyPort);
+ }
+ else if (parser.getName().equals("packetCollectorSize")) {
+ packetCollectorSize = parseIntProperty(parser, packetCollectorSize);
}
}
eventType = parser.next();
@@ -184,6 +187,26 @@ public final class SmackConfiguration {
keepAliveInterval = interval;
}
+ /**
+ * Gets the default max size of a packet collector before it will delete
+ * the older packets.
+ *
+ * @return The number of packets to queue before deleting older packets.
+ */
+ public static int getPacketCollectorSize() {
+ return packetCollectorSize;
+ }
+
+ /**
+ * Sets the default max size of a packet collector before it will delete
+ * the older packets.
+ *
+ * @param The number of packets to queue before deleting older packets.
+ */
+ public static void setPacketCollectorSize(int collectorSize) {
+ packetCollectorSize = collectorSize;
+ }
+
/**
* Add a SASL mechanism to the list to be used.
*
diff --git a/source/org/jivesoftware/smack/XMPPConnection.java b/source/org/jivesoftware/smack/XMPPConnection.java
index d04585081..9a65a8313 100644
--- a/source/org/jivesoftware/smack/XMPPConnection.java
+++ b/source/org/jivesoftware/smack/XMPPConnection.java
@@ -419,7 +419,7 @@ public class XMPPConnection extends Connection {
saslAuthentication.init();
}
- public void disconnect(Presence unavailablePresence) {
+ public synchronized void disconnect(Presence unavailablePresence) {
// If not connected, ignore this request.
if (packetReader == null || packetWriter == null) {
return;
diff --git a/source/org/jivesoftware/smackx/ServiceDiscoveryManager.java b/source/org/jivesoftware/smackx/ServiceDiscoveryManager.java
index 4dbea30cd..18da4bdcb 100644
--- a/source/org/jivesoftware/smackx/ServiceDiscoveryManager.java
+++ b/source/org/jivesoftware/smackx/ServiceDiscoveryManager.java
@@ -115,7 +115,7 @@ public class ServiceDiscoveryManager {
/**
* Returns the type of client that will be returned when asked for the client identity in a
* disco request. The valid types are defined by the category client. Follow this link to learn
- * the possible types: Jabber::Registrar.
+ * the possible types: Jabber::Registrar.
*
* @return the type of client that will be returned when asked for the client identity in a
* disco request.
@@ -127,7 +127,7 @@ public class ServiceDiscoveryManager {
/**
* Sets the type of client that will be returned when asked for the client identity in a
* disco request. The valid types are defined by the category client. Follow this link to learn
- * the possible types: Jabber::Registrar.
+ * the possible types: Jabber::Registrar.
*
* @param type the type of client that will be returned when asked for the client identity in a
* disco request.
diff --git a/source/org/jivesoftware/smackx/XHTMLText.java b/source/org/jivesoftware/smackx/XHTMLText.java
index 63b8218d5..201e5308a 100644
--- a/source/org/jivesoftware/smackx/XHTMLText.java
+++ b/source/org/jivesoftware/smackx/XHTMLText.java
@@ -131,7 +131,7 @@ public class XHTMLText {
*
*/
public void appendBrTag() {
- text.append("
");
+ text.append("
");
}
/**
diff --git a/source/org/jivesoftware/smackx/debugger/EnhancedDebugger.java b/source/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
index 1c7d8a55f..591726374 100644
--- a/source/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
+++ b/source/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
@@ -326,10 +326,7 @@ public class EnhancedDebugger implements SmackDebugger {
@Override
public void actionPerformed(ActionEvent e) {
- for(int i=0; i< messagesTable.getRowCount();i++)
- {
- messagesTable.removeRow(i);
- }
+ messagesTable.setRowCount(0);
}
});
diff --git a/source/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java b/source/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java
index 06ec67316..2d65cc7e4 100644
--- a/source/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java
+++ b/source/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java
@@ -324,7 +324,8 @@ public class FileTransferNegotiator {
throw new XMPPException(error.getMessage(), error);
}
- if (isByteStream && isIBB && field.getType().equals(FormField.TYPE_LIST_MULTI)) {
+ //if (isByteStream && isIBB && field.getType().equals(FormField.TYPE_LIST_MULTI)) {
+ if (isByteStream && isIBB) {
return new FaultTolerantNegotiator(connection,
byteStreamTransferManager,
inbandTransferManager);
diff --git a/source/org/jivesoftware/smackx/muc/ConnectionDetachedPacketCollector.java b/source/org/jivesoftware/smackx/muc/ConnectionDetachedPacketCollector.java
index 95c4f6610..2a719f629 100644
--- a/source/org/jivesoftware/smackx/muc/ConnectionDetachedPacketCollector.java
+++ b/source/org/jivesoftware/smackx/muc/ConnectionDetachedPacketCollector.java
@@ -20,6 +20,7 @@
package org.jivesoftware.smackx.muc;
+import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.packet.Packet;
import java.util.LinkedList;
@@ -38,7 +39,7 @@ class ConnectionDetachedPacketCollector {
* reached, older packets will be automatically dropped from the queue as
* new packets are added.
*/
- private static final int MAX_PACKETS = 65536;
+ private int maxPackets = SmackConfiguration.getPacketCollectorSize();
private LinkedList resultQueue;
@@ -50,6 +51,15 @@ class ConnectionDetachedPacketCollector {
this.resultQueue = new LinkedList();
}
+ /**
+ * Creates a new packet collector. If the packet filter is null, then
+ * all packets will match this collector.
+ */
+ public ConnectionDetachedPacketCollector(int maxSize) {
+ this.resultQueue = new LinkedList();
+ maxPackets = maxSize;
+ }
+
/**
* Polls to see if a packet is currently available and returns it, or
* immediately returns null if no packets are currently in the
@@ -124,7 +134,7 @@ class ConnectionDetachedPacketCollector {
return;
}
// If the max number of packets has been reached, remove the oldest one.
- if (resultQueue.size() == MAX_PACKETS) {
+ if (resultQueue.size() == maxPackets) {
resultQueue.removeLast();
}
// Add the new packet.
diff --git a/source/org/jivesoftware/smackx/muc/RoomListenerMultiplexor.java b/source/org/jivesoftware/smackx/muc/RoomListenerMultiplexor.java
index 3c9668f79..6f8bf05a7 100644
--- a/source/org/jivesoftware/smackx/muc/RoomListenerMultiplexor.java
+++ b/source/org/jivesoftware/smackx/muc/RoomListenerMultiplexor.java
@@ -60,7 +60,7 @@ class RoomListenerMultiplexor implements ConnectionListener {
*/
public static RoomListenerMultiplexor getRoomMultiplexor(Connection conn) {
synchronized (monitors) {
- if (!monitors.containsKey(conn)) {
+ if (!monitors.containsKey(conn) || monitors.get(conn).get() == null) {
RoomListenerMultiplexor rm = new RoomListenerMultiplexor(conn, new RoomMultiplexFilter(),
new RoomMultiplexListener());
diff --git a/source/org/jivesoftware/smackx/pubsub/PayloadItem.java b/source/org/jivesoftware/smackx/pubsub/PayloadItem.java
index 6ebd430c1..e9497c55e 100644
--- a/source/org/jivesoftware/smackx/pubsub/PayloadItem.java
+++ b/source/org/jivesoftware/smackx/pubsub/PayloadItem.java
@@ -13,11 +13,10 @@
*/
package org.jivesoftware.smackx.pubsub;
+import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
-import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
-
/**
* This class represents an item that has been, or will be published to a
* pubsub node. An Item has several properties that are dependent
diff --git a/test-unit/org/jivesoftware/smack/ChatConnectionTest.java b/test-unit/org/jivesoftware/smack/ChatConnectionTest.java
index 93a808e8c..3ded1ca44 100644
--- a/test-unit/org/jivesoftware/smack/ChatConnectionTest.java
+++ b/test-unit/org/jivesoftware/smack/ChatConnectionTest.java
@@ -40,252 +40,249 @@ import org.junit.Test;
* @see Roster Management
* @author Guenther Niess
*/
-public class ChatConnectionTest
-{
+public class ChatConnectionTest {
- private DummyConnection connection;
+ private DummyConnection connection;
- @Before
- public void setUp() throws Exception
- {
- // Uncomment this to enable debug output
- // Connection.DEBUG_ENABLED = true;
+ @Before
+ public void setUp() throws Exception {
+ // Uncomment this to enable debug output
+ //Connection.DEBUG_ENABLED = true;
- connection = new DummyConnection();
- connection.connect();
- connection.login("me", "secret");
- }
+ connection = new DummyConnection();
+ connection.connect();
+ connection.login("me", "secret");
+ }
- @After
- public void tearDown() throws Exception
- {
- if (connection != null)
- connection.disconnect();
- }
+ @After
+ public void tearDown() throws Exception {
+ if (connection != null)
+ connection.disconnect();
+ }
- /**
- * Confirm that a new chat is created when a chat message is received but
- * there is no thread id for a user with only a base jid.
- */
- @Test
- public void chatCreatedWithIncomingChatNoThreadBaseJid()
- {
- TestChatManagerListener listener = new TestChatManagerListener();
- connection.getChatManager().addChatListener(listener);
+ /**
+ * Confirm that a new chat is created when a chat message is received but
+ * there is no thread id for a user with only a base jid.
+ */
+ @Test
+ public void chatCreatedWithIncomingChatNoThreadBaseJid()
+ {
+ TestChatManagerListener listener = new TestChatManagerListener();
+ connection.getChatManager().addChatListener(listener);
- Packet incomingChat = createChatPacket(null, false);
- processServerMessage(incomingChat);
+ Packet incomingChat = createChatPacket(null, false);
+ processServerMessage(incomingChat);
- Chat newChat = listener.getNewChat();
- assertNotNull(newChat);
- }
+ Chat newChat = listener.getNewChat();
+ assertNotNull(newChat);
+ }
- /**
- * Confirm that a new chat is created when a chat message is received but
- * there is no thread id for a user with a full jid.
- */
- @Test
- public void chatCreatedWhenIncomingChatNoThreadFullJid()
- {
- TestChatManagerListener listener = new TestChatManagerListener();
- connection.getChatManager().addChatListener(listener);
+ /**
+ * Confirm that a new chat is created when a chat message is received but
+ * there is no thread id for a user with a full jid.
+ */
+ @Test
+ public void chatCreatedWhenIncomingChatNoThreadFullJid()
+ {
+ TestChatManagerListener listener = new TestChatManagerListener();
+ connection.getChatManager().addChatListener(listener);
- Packet incomingChat = createChatPacket(null, true);
- processServerMessage(incomingChat);
+ Packet incomingChat = createChatPacket(null, true);
+ processServerMessage(incomingChat);
- Chat newChat = listener.getNewChat();
- assertNotNull(newChat);
- }
+ Chat newChat = listener.getNewChat();
+ assertNotNull(newChat);
+ }
- /**
- * Confirm that an existing chat created with a base jid is matched to an
- * incoming chat message that has no thread id and the user is a full jid.
- */
- @Test
- public void chatFoundWhenNoThreadFullJid()
- {
- TestChatManagerListener listener = new TestChatManagerListener();
- connection.getChatManager().addChatListener(listener);
- Chat outgoing = connection.getChatManager().createChat("you@testserver", null);
+ /**
+ * Confirm that an existing chat created with a base jid is matched to an
+ * incoming chat message that has no thread id and the user is a full jid.
+ */
+ @Test
+ public void chatFoundWhenNoThreadFullJid()
+ {
+ TestChatManagerListener listener = new TestChatManagerListener();
+ connection.getChatManager().addChatListener(listener);
+ Chat outgoing = connection.getChatManager().createChat("you@testserver", null);
- Packet incomingChat = createChatPacket(null, true);
- processServerMessage(incomingChat);
+ Packet incomingChat = createChatPacket(null, true);
+ processServerMessage(incomingChat);
- Chat newChat = listener.getNewChat();
- assertNotNull(newChat);
- assertTrue(newChat == outgoing);
- }
+ Chat newChat = listener.getNewChat();
+ assertNotNull(newChat);
+ assertTrue(newChat == outgoing);
+ }
- /**
- * Confirm that an existing chat created with a base jid is matched to an
- * incoming chat message that has no thread id and the user is a base jid.
- */
- @Test
- public void chatFoundWhenNoThreadBaseJid()
- {
- TestChatManagerListener listener = new TestChatManagerListener();
- connection.getChatManager().addChatListener(listener);
- Chat outgoing = connection.getChatManager().createChat("you@testserver", null);
+ /**
+ * Confirm that an existing chat created with a base jid is matched to an
+ * incoming chat message that has no thread id and the user is a base jid.
+ */
+ @Test
+ public void chatFoundWhenNoThreadBaseJid()
+ {
+ TestChatManagerListener listener = new TestChatManagerListener();
+ connection.getChatManager().addChatListener(listener);
+ Chat outgoing = connection.getChatManager().createChat("you@testserver", null);
- Packet incomingChat = createChatPacket(null, false);
- processServerMessage(incomingChat);
+ Packet incomingChat = createChatPacket(null, false);
+ processServerMessage(incomingChat);
- Chat newChat = listener.getNewChat();
- assertNotNull(newChat);
- assertTrue(newChat == outgoing);
- }
+ Chat newChat = listener.getNewChat();
+ assertNotNull(newChat);
+ assertTrue(newChat == outgoing);
+ }
- /**
- * Confirm that an existing chat created with a base jid is matched to an
- * incoming chat message that has the same id and the user is a full jid.
- */
- @Test
- public void chatFoundWithSameThreadFullJid()
- {
- TestChatManagerListener listener = new TestChatManagerListener();
- connection.getChatManager().addChatListener(listener);
- Chat outgoing = connection.getChatManager().createChat("you@testserver", null);
+ /**
+ * Confirm that an existing chat created with a base jid is matched to an
+ * incoming chat message that has the same id and the user is a full jid.
+ */
+ @Test
+ public void chatFoundWithSameThreadFullJid()
+ {
+ TestChatManagerListener listener = new TestChatManagerListener();
+ connection.getChatManager().addChatListener(listener);
+ Chat outgoing = connection.getChatManager().createChat("you@testserver", null);
- Packet incomingChat = createChatPacket(outgoing.getThreadID(), true);
- processServerMessage(incomingChat);
+ Packet incomingChat = createChatPacket(outgoing.getThreadID(), true);
+ processServerMessage(incomingChat);
- Chat newChat = listener.getNewChat();
- assertNotNull(newChat);
- assertTrue(newChat == outgoing);
- }
+ Chat newChat = listener.getNewChat();
+ assertNotNull(newChat);
+ assertTrue(newChat == outgoing);
+ }
- /**
- * Confirm that an existing chat created with a base jid is matched to an
- * incoming chat message that has the same id and the user is a base jid.
- */
- @Test
- public void chatFoundWithSameThreadBaseJid()
- {
- TestChatManagerListener listener = new TestChatManagerListener();
- connection.getChatManager().addChatListener(listener);
- Chat outgoing = connection.getChatManager().createChat("you@testserver", null);
+ /**
+ * Confirm that an existing chat created with a base jid is matched to an
+ * incoming chat message that has the same id and the user is a base jid.
+ */
+ @Test
+ public void chatFoundWithSameThreadBaseJid()
+ {
+ TestChatManagerListener listener = new TestChatManagerListener();
+ connection.getChatManager().addChatListener(listener);
+ Chat outgoing = connection.getChatManager().createChat("you@testserver", null);
- Packet incomingChat = createChatPacket(outgoing.getThreadID(), false);
- processServerMessage(incomingChat);
+ Packet incomingChat = createChatPacket(outgoing.getThreadID(), false);
+ processServerMessage(incomingChat);
- Chat newChat = listener.getNewChat();
- assertNotNull(newChat);
- assertTrue(newChat == outgoing);
- }
+ Chat newChat = listener.getNewChat();
+ assertNotNull(newChat);
+ assertTrue(newChat == outgoing);
+ }
- /**
- * Confirm that an existing chat created with a base jid is not matched to
- * an incoming chat message that has a different id and the same user as a
- * base jid.
- */
- @Ignore
- @Test
- public void chatNotFoundWithDiffThreadBaseJid()
- {
- TestChatManagerListener listener = new TestChatManagerListener();
- connection.getChatManager().addChatListener(listener);
- Chat outgoing = connection.getChatManager().createChat("you@testserver", null);
+ /**
+ * Confirm that an existing chat created with a base jid is not matched to
+ * an incoming chat message that has a different id and the same user as a
+ * base jid.
+ */
+ @Ignore
+ @Test
+ public void chatNotFoundWithDiffThreadBaseJid()
+ {
+ TestChatManagerListener listener = new TestChatManagerListener();
+ connection.getChatManager().addChatListener(listener);
+ Chat outgoing = connection.getChatManager().createChat("you@testserver", null);
- Packet incomingChat = createChatPacket(outgoing.getThreadID() + "ff", false);
- processServerMessage(incomingChat);
+ Packet incomingChat = createChatPacket(outgoing.getThreadID() + "ff", false);
+ processServerMessage(incomingChat);
- Chat newChat = listener.getNewChat();
- assertNotNull(newChat);
- assertFalse(newChat == outgoing);
- }
+ Chat newChat = listener.getNewChat();
+ assertNotNull(newChat);
+ assertFalse(newChat == outgoing);
+ }
- /**
- * Confirm that an existing chat created with a base jid is not matched to
- * an incoming chat message that has a different id and the same base jid.
- */
- @Ignore
- @Test
- public void chatNotFoundWithDiffThreadFullJid()
- {
- TestChatManagerListener listener = new TestChatManagerListener();
- connection.getChatManager().addChatListener(listener);
- Chat outgoing = connection.getChatManager().createChat("you@testserver", null);
+ /**
+ * Confirm that an existing chat created with a base jid is not matched to
+ * an incoming chat message that has a different id and the same base jid.
+ */
+ @Ignore
+ @Test
+ public void chatNotFoundWithDiffThreadFullJid()
+ {
+ TestChatManagerListener listener = new TestChatManagerListener();
+ connection.getChatManager().addChatListener(listener);
+ Chat outgoing = connection.getChatManager().createChat("you@testserver", null);
- Packet incomingChat = createChatPacket(outgoing.getThreadID() + "ff", true);
- processServerMessage(incomingChat);
+ Packet incomingChat = createChatPacket(outgoing.getThreadID() + "ff", true);
+ processServerMessage(incomingChat);
- Chat newChat = listener.getNewChat();
- assertNotNull(newChat);
- assertFalse(newChat == outgoing);
- }
+ Chat newChat = listener.getNewChat();
+ assertNotNull(newChat);
+ assertFalse(newChat == outgoing);
+ }
- private Packet createChatPacket(final String threadId, final boolean isFullJid)
- {
- Message chatMsg = new Message("me@testserver", Message.Type.chat);
- chatMsg.setBody("the body message");
- chatMsg.setFrom("you@testserver" + (isFullJid ? "/resource" : ""));
-
- if (threadId != null)
- chatMsg.addExtension(new PacketExtension()
- {
- @Override
- public String toXML()
- {
- return "" + threadId + "";
- }
-
- @Override
- public String getNamespace()
- {
- return null;
- }
-
- @Override
- public String getElementName()
- {
- return "thread";
- }
- });
- return chatMsg;
- }
-
- private void processServerMessage(Packet incomingChat)
- {
- TestChatServer chatServer = new TestChatServer(incomingChat);
- chatServer.start();
- try
- {
- chatServer.join();
- } catch (InterruptedException e)
- {
- fail();
- }
- }
-
- class TestChatManagerListener implements ChatManagerListener
- {
- private Chat newChat;
+ private Packet createChatPacket(final String threadId, final boolean isFullJid)
+ {
+ Message chatMsg = new Message("me@testserver", Message.Type.chat);
+ chatMsg.setBody("the body message");
+ chatMsg.setFrom("you@testserver" + (isFullJid ? "/resource" : ""));
+ if (threadId != null)
+ chatMsg.addExtension(new PacketExtension()
+ {
@Override
- public void chatCreated(Chat chat, boolean createdLocally)
+ public String toXML()
{
- newChat = chat;
- }
-
- public Chat getNewChat()
- {
- return newChat;
- }
- }
-
- private class TestChatServer extends Thread
- {
- private Packet chatPacket;
-
- TestChatServer(Packet chatMsg)
- {
- chatPacket = chatMsg;
+ return "" + threadId + "";
}
@Override
- public void run()
+ public String getNamespace()
{
- connection.processPacket(chatPacket);
+ return null;
}
+
+ @Override
+ public String getElementName()
+ {
+ return "thread";
+ }
+ });
+ return chatMsg;
+ }
+
+ private void processServerMessage(Packet incomingChat)
+ {
+ TestChatServer chatServer = new TestChatServer(incomingChat);
+ chatServer.start();
+ try
+ {
+ chatServer.join();
+ } catch (InterruptedException e)
+ {
+ fail();
}
+ }
+
+ class TestChatManagerListener implements ChatManagerListener
+ {
+ private Chat newChat;
+
+ @Override
+ public void chatCreated(Chat chat, boolean createdLocally)
+ {
+ newChat = chat;
+ }
+
+ public Chat getNewChat()
+ {
+ return newChat;
+ }
+ }
+
+ private class TestChatServer extends Thread
+ {
+ private Packet chatPacket;
+
+ TestChatServer(Packet chatMsg)
+ {
+ chatPacket = chatMsg;
+ }
+
+ @Override
+ public void run()
+ {
+ connection.processPacket(chatPacket);
+ }
+ }
}
diff --git a/test-unit/org/jivesoftware/smack/SmackConfigTest.java b/test-unit/org/jivesoftware/smack/SmackConfigTest.java
new file mode 100644
index 000000000..9d7d15d2c
--- /dev/null
+++ b/test-unit/org/jivesoftware/smack/SmackConfigTest.java
@@ -0,0 +1,32 @@
+package org.jivesoftware.smack;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class SmackConfigTest
+{
+ @Test
+ public void validatePacketCollectorSize()
+ {
+ assertEquals(10000, SmackConfiguration.getPacketCollectorSize());
+ }
+
+ @Test
+ public void validateKeepAliveInterval()
+ {
+ assertEquals(30000, SmackConfiguration.getKeepAliveInterval());
+ }
+
+ @Test
+ public void validateLocalSocks5ProxyPort()
+ {
+ assertEquals(7777, SmackConfiguration.getLocalSocks5ProxyPort());
+ }
+
+ @Test
+ public void validateIsLocalSocks5Proxy()
+ {
+ assertTrue(SmackConfiguration.isLocalSocks5ProxyEnabled());
+ }
+}
diff --git a/test-unit/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java b/test-unit/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java
index 291d16019..78364a3da 100644
--- a/test-unit/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java
+++ b/test-unit/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java
@@ -2,6 +2,17 @@ package org.jivesoftware.smackx.pubsub;
import static org.junit.Assert.assertEquals;
+import org.jivesoftware.smack.SmackConfiguration;
+import org.jivesoftware.smack.ThreadedDummyConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.packet.IQ;
+import org.jivesoftware.smack.packet.PacketExtension;
+import org.jivesoftware.smack.packet.XMPPError;
+import org.jivesoftware.smack.packet.XMPPError.Condition;
+import org.jivesoftware.smackx.packet.DiscoverInfo;
+import org.jivesoftware.smackx.packet.DiscoverInfo.Identity;
+import org.jivesoftware.smackx.pubsub.packet.PubSub;
+import org.junit.Assert;
import org.junit.Test;
public class ConfigureFormTest
@@ -13,4 +24,49 @@ public class ConfigureFormTest
form.setChildrenAssociationPolicy(ChildrenAssociationPolicy.owners);
assertEquals(ChildrenAssociationPolicy.owners, form.getChildrenAssociationPolicy());
}
+
+ @Test
+ public void getConfigFormWithInsufficientPriviliges() throws XMPPException
+ {
+ ThreadedDummyConnection con = new ThreadedDummyConnection();
+ PubSubManager mgr = new PubSubManager(con);
+ DiscoverInfo info = new DiscoverInfo();
+ Identity ident = new Identity("pubsub", null);
+ ident.setType("leaf");
+ info.addIdentity(ident);
+ con.addIQReply(info);
+
+ Node node = mgr.getNode("princely_musings");
+
+ PubSub errorIq = new PubSub();
+ XMPPError error = new XMPPError(Condition.forbidden);
+ errorIq.setError(error);
+ con.addIQReply(errorIq);
+
+ try
+ {
+ node.getNodeConfiguration();
+ }
+ catch (XMPPException e)
+ {
+ Assert.assertEquals(XMPPError.Type.AUTH, e.getXMPPError().getType());
+ }
+ }
+
+ @Test (expected=XMPPException.class)
+ public void getConfigFormWithTimeout() throws XMPPException
+ {
+ ThreadedDummyConnection con = new ThreadedDummyConnection();
+ PubSubManager mgr = new PubSubManager(con);
+ DiscoverInfo info = new DiscoverInfo();
+ Identity ident = new Identity("pubsub", null);
+ ident.setType("leaf");
+ info.addIdentity(ident);
+ con.addIQReply(info);
+
+ Node node = mgr.getNode("princely_musings");
+
+ SmackConfiguration.setPacketReplyTimeout(100);
+ node.getNodeConfiguration();
+ }
}