You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by be...@apache.org on 2012/12/18 09:44:34 UTC
svn commit: r1423331 -
/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringInteralInboundStanzaRelayTestCase.java
Author: berndf
Date: Tue Dec 18 08:44:33 2012
New Revision: 1423331
URL: http://svn.apache.org/viewvc?rev=1423331&view=rev
Log:
unit tests verifying VYSPER-337
Modified:
mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringInteralInboundStanzaRelayTestCase.java
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringInteralInboundStanzaRelayTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringInteralInboundStanzaRelayTestCase.java?rev=1423331&r1=1423330&r2=1423331&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringInteralInboundStanzaRelayTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringInteralInboundStanzaRelayTestCase.java Tue Dec 18 08:44:33 2012
@@ -40,8 +40,10 @@ import org.apache.vysper.xmpp.state.reso
import org.apache.vysper.xmpp.state.resourcebinding.DefaultResourceRegistry;
import org.apache.vysper.xmpp.state.resourcebinding.ResourceRegistry;
+import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadPoolExecutor;
/**
*/
@@ -205,5 +207,58 @@ public class DeliveringInteralInboundSta
// test succeeds
}
}
+
+ public void testSequentialDeliveryOneThread() throws DeliveryException, XMLSemanticError, EntityFormatException {
+
+ DefaultServerRuntimeContext serverRuntimeContext = new DefaultServerRuntimeContext(null, null);
+
+ stanzaRelay.setServerRuntimeContext(serverRuntimeContext);
+ stanzaRelay.setMaxThreadCount(1);
+
+ TestSessionContext sessionContext = createSessionForTo(TO_ENTITY, 1);
+
+ final int STANZA_COUNT = 1000;
+
+ for (int i = 0; i < STANZA_COUNT; i++) {
+ Stanza stanza = StanzaBuilder.createMessageStanza(FROM_ENTITY, TO_ENTITY, "en", "" + i).build();
+ stanzaRelay.relay(TO_ENTITY, stanza, null);
+ }
+ for (int i = 0; i < STANZA_COUNT; i++) {
+ final Stanza nextResponse = sessionContext.getNextRecordedResponse(100);
+ assertEquals("" + i, nextResponse.getSingleInnerElementsNamed("body").getSingleInnerText().getText());
+ }
+
+ }
+
+ public void testSequentialDeliveryManyThreads() throws DeliveryException, XMLSemanticError, EntityFormatException {
+
+ DefaultServerRuntimeContext serverRuntimeContext = new DefaultServerRuntimeContext(null, null);
+
+ stanzaRelay.setServerRuntimeContext(serverRuntimeContext);
+ stanzaRelay.setMaxThreadCount(10);
+
+ TestSessionContext sessionContext = createSessionForTo(TO_ENTITY, 1);
+
+ final int STANZA_COUNT = 1000;
+
+ for (int i = 0; i < STANZA_COUNT; i++) {
+ Stanza stanza = StanzaBuilder.createMessageStanza(FROM_ENTITY, TO_ENTITY, "en", "" + i).build();
+ stanzaRelay.relay(TO_ENTITY, stanza, null);
+ }
+
+ /*
+ our handling currently does not enforce strict ordered delivery (for example by session).
+ If stanzas A and B enter the Relay's queue in that order, we only ensure that processing is started in
+ that order. However, it might as well happen that B is processed in parallel to A, and even exits
+ before A.
+ */
+
+ for (int i = 0; i < STANZA_COUNT; i++) {
+ final Stanza nextResponse = sessionContext.getNextRecordedResponse(100);
+ boolean matches = ("" + i).equals(nextResponse.getSingleInnerElementsNamed("body").getSingleInnerText().getText());
+ if (!matches) return; // succeed
+ }
+ Assert.fail("delivered in sequence is unexpected, see VYSPER-337");
+ }
}