You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2010/06/26 22:40:05 UTC
svn commit: r958281 [14/22] - in /mina/vysper/trunk:
demo/pubsub/client/src/main/java/org/apache/vysper/demo/pubsub/client/
nbxml/src/main/java/org/apache/vysper/charset/
nbxml/src/main/java/org/apache/vysper/xml/decoder/
nbxml/src/main/java/org/apache...
Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/writer/DenseStanzaLogRenderer.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/writer/DenseStanzaLogRenderer.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/writer/DenseStanzaLogRenderer.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/writer/DenseStanzaLogRenderer.java Sat Jun 26 20:39:54 2010
@@ -19,16 +19,18 @@
*/
package org.apache.vysper.xmpp.writer;
-import org.apache.vysper.xml.fragment.*;
-import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.vysper.xml.fragment.XMLElement;
+import org.apache.vysper.xml.fragment.XMLSemanticError;
+import org.apache.vysper.xml.fragment.XMLText;
import org.apache.vysper.xmpp.stanza.IQStanza;
import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.List;
-import java.util.Iterator;
-
/**
* renders only reduced digest stanza information for logging output
*
@@ -39,13 +41,16 @@ public class DenseStanzaLogRenderer {
final static Logger logger = LoggerFactory.getLogger(DenseStanzaLogRenderer.class);
private static final String ELEMENT_SEPARATOR = ".";
+
private static final String ATTR_QUOTE = "'";
+
private static final String EQUALS = "=";
public static String render(XMLElement stanza) {
try {
StringBuilder stringBuilder = new StringBuilder();
- if (stanza == null) return stringBuilder.append("NULL_STANZA").toString();
+ if (stanza == null)
+ return stringBuilder.append("NULL_STANZA").toString();
String outerName = stanza.getName();
stringBuilder.append(outerName);
XMLElement firstInnerElement = stanza.getFirstInnerElement();
@@ -82,7 +87,7 @@ public class DenseStanzaLogRenderer {
if ("query".equals(firstInnerElement.getName())) {
renderIQQuery(stringBuilder, firstInnerElement);
} else {
- renderNamespace(stringBuilder, firstInnerElement);
+ renderNamespace(stringBuilder, firstInnerElement);
}
}
}
@@ -103,11 +108,13 @@ public class DenseStanzaLogRenderer {
} else if (nsUri.equals("http://jabber.org/protocol/disco#info")) {
stringBuilder.append(ELEMENT_SEPARATOR).append("info");
List<XMLElement> features = queryElement.getInnerElementsNamed("feature");
- if (features != null) for (XMLElement feature : features) {
- String varAttrValue = feature.getAttributeValue("var");
- if (varAttrValue == null) varAttrValue = "NOT_GIVEN";
- renderAttributeForm(stringBuilder, "feature", varAttrValue);
- }
+ if (features != null)
+ for (XMLElement feature : features) {
+ String varAttrValue = feature.getAttributeValue("var");
+ if (varAttrValue == null)
+ varAttrValue = "NOT_GIVEN";
+ renderAttributeForm(stringBuilder, "feature", varAttrValue);
+ }
} else {
stringBuilder.append(ELEMENT_SEPARATOR).append("????");
}
@@ -127,7 +134,8 @@ public class DenseStanzaLogRenderer {
stringBuilder.append(ELEMENT_SEPARATOR);
stringBuilder.append("starttls");
XMLElement required = starttls.getSingleInnerElementsNamed("required");
- if (required != null) stringBuilder.append("[required]");
+ if (required != null)
+ stringBuilder.append("[required]");
}
XMLElement mechanisms = features.getSingleInnerElementsNamed("mechanisms");
if (mechanisms != null) {
@@ -138,7 +146,8 @@ public class DenseStanzaLogRenderer {
for (Iterator<XMLElement> it = list.iterator(); it.hasNext();) {
XMLElement element = it.next();
stringBuilder.append(element.getSingleInnerText().getText());
- if (it.hasNext()) stringBuilder.append(",");
+ if (it.hasNext())
+ stringBuilder.append(",");
}
}
stringBuilder.append("]");
@@ -204,7 +213,6 @@ public class DenseStanzaLogRenderer {
}
}
-
private static void renderAttribute(StringBuilder stringBuilder, XMLElement element, String attributeName) {
String attributeValue = element.getAttributeValue(attributeName);
if (attributeValue != null) {
@@ -229,7 +237,8 @@ public class DenseStanzaLogRenderer {
XMLText xmlText = null;
try {
xmlText = firstInnerElement.getSingleInnerText();
- if (xmlText != null) stringBuilder.append(xmlText.getText());
+ if (xmlText != null)
+ stringBuilder.append(xmlText.getText());
} catch (XMLSemanticError xmlSemanticError) {
stringBuilder.append("???");
}
Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/writer/SystemOutStanzaWriter.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/writer/SystemOutStanzaWriter.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/writer/SystemOutStanzaWriter.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/writer/SystemOutStanzaWriter.java Sat Jun 26 20:39:54 2010
@@ -30,6 +30,7 @@ import org.apache.vysper.xmpp.stanza.Sta
public class SystemOutStanzaWriter implements StanzaWriter {
boolean isFirst = true;
+
private String closingElement;
public void writeXMLProlog() {
@@ -40,8 +41,10 @@ public class SystemOutStanzaWriter imple
Renderer renderer = new Renderer(stanza);
System.out.print(renderer.getOpeningElement() + renderer.getElementContent());
- if (isFirst) closingElement = renderer.getClosingElement();
- else System.out.print(closingElement);
+ if (isFirst)
+ closingElement = renderer.getClosingElement();
+ else
+ System.out.print(closingElement);
isFirst = false;
}
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/mina/codec/MockIoSession.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/mina/codec/MockIoSession.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/mina/codec/MockIoSession.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/mina/codec/MockIoSession.java Sat Jun 26 20:39:54 2010
@@ -25,14 +25,11 @@ import org.apache.mina.core.service.Defa
import org.apache.mina.core.session.DummySession;
import org.apache.mina.core.session.IoSessionConfig;
-public class MockIoSession extends DummySession
- {
+public class MockIoSession extends DummySession {
- public MockIoSession() {
- setTransportMetadata(
- new DefaultTransportMetadata(
- "mina", "dummy", false, true,
- SocketAddress.class, IoSessionConfig.class, Object.class));
+ public MockIoSession() {
+ setTransportMetadata(new DefaultTransportMetadata("mina", "dummy", false, true, SocketAddress.class,
+ IoSessionConfig.class, Object.class));
}
}
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/stanzasession/StanzaSessionTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/stanzasession/StanzaSessionTestCase.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/stanzasession/StanzaSessionTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/stanzasession/StanzaSessionTestCase.java Sat Jun 26 20:39:54 2010
@@ -19,19 +19,20 @@
*/
package org.apache.vysper.stanzasession;
+import java.util.ArrayList;
+import java.util.List;
+
import junit.framework.TestCase;
+
import org.apache.vysper.xmpp.addressing.EntityImpl;
import org.apache.vysper.xmpp.delivery.StanzaRelayBroker;
+import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary;
import org.apache.vysper.xmpp.server.DefaultServerRuntimeContext;
import org.apache.vysper.xmpp.server.ServerFeatures;
-import org.apache.vysper.xmpp.stanza.StanzaBuilder;
import org.apache.vysper.xmpp.stanza.Stanza;
-import org.apache.vysper.xmpp.writer.DenseStanzaLogRenderer;
-import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary;
+import org.apache.vysper.xmpp.stanza.StanzaBuilder;
import org.apache.vysper.xmpp.state.resourcebinding.ResourceRegistry;
-
-import java.util.List;
-import java.util.ArrayList;
+import org.apache.vysper.xmpp.writer.DenseStanzaLogRenderer;
/**
*/
@@ -42,7 +43,7 @@ public class StanzaSessionTestCase exten
@Override
protected void setUp() throws Exception {
StanzaRelayBroker relay = new StanzaRelayBroker();
-
+
List<NamespaceHandlerDictionary> dictionaries = new ArrayList<NamespaceHandlerDictionary>();
dictionaries.add(new org.apache.vysper.xmpp.modules.core.base.BaseStreamStanzaDictionary());
dictionaries.add(new org.apache.vysper.xmpp.modules.core.starttls.StartTLSStanzaDictionary());
@@ -51,48 +52,31 @@ public class StanzaSessionTestCase exten
dictionaries.add(new org.apache.vysper.xmpp.modules.core.session.SessionStanzaDictionary());
dictionaries.add(new org.apache.vysper.xmpp.modules.core.compatibility.jabber_iq_auth.JabberIQAuthDictionary());
dictionaries.add(new org.apache.vysper.xmpp.modules.roster.RosterDictionary());
-
- DefaultServerRuntimeContext serverContext = new DefaultServerRuntimeContext(
- new EntityImpl(null, "test", null),
- relay,
- new ServerFeatures(),
- dictionaries,
- new ResourceRegistry());
+
+ DefaultServerRuntimeContext serverContext = new DefaultServerRuntimeContext(new EntityImpl(null, "test", null),
+ relay, new ServerFeatures(), dictionaries, new ResourceRegistry());
relay.setServerRuntimeContext(serverContext);
sessionFactory = new StanzaSessionFactory();
sessionFactory.setServerRuntimeContext(serverContext);
}
-
+
public void testHandshake() {
StanzaSession session = sessionFactory.createNewSession();
- session.send(
- new StanzaBuilder("stream", "http://etherx.jabber.org/streams", "stream")
- .addAttribute("from", "me@vysper.org")
- .addAttribute("to", "vysper.org")
- .declareNamespace("", "jabber:client")
- .build()
- );
+ session.send(new StanzaBuilder("stream", "http://etherx.jabber.org/streams", "stream").addAttribute("from",
+ "me@vysper.org").addAttribute("to", "vysper.org").declareNamespace("", "jabber:client").build());
Stanza stanza = waitForStanza(session);
assertNotNull(stanza);
System.out.println(DenseStanzaLogRenderer.render(stanza));
- session.send(
- new StanzaBuilder("starttls", "urn:ietf:params:xml:ns:xmpp-tls")
- .addAttribute("from", "me@vysper.org")
- .build()
- );
+ session.send(new StanzaBuilder("starttls", "urn:ietf:params:xml:ns:xmpp-tls").addAttribute("from",
+ "me@vysper.org").build());
stanza = waitForStanza(session);
assertNotNull(stanza);
System.out.println(DenseStanzaLogRenderer.render(stanza));
session.setIsSecure();
- session.send(
- new StanzaBuilder("stream", "http://etherx.jabber.org/streams", "stream")
- .addAttribute("from", "me@vysper.org")
- .addAttribute("to", "vysper.org")
- .declareNamespace("", "jabber:client")
- .build()
- );
+ session.send(new StanzaBuilder("stream", "http://etherx.jabber.org/streams", "stream").addAttribute("from",
+ "me@vysper.org").addAttribute("to", "vysper.org").declareNamespace("", "jabber:client").build());
stanza = waitForStanza(session);
assertNotNull(stanza);
System.out.println(DenseStanzaLogRenderer.render(stanza));
@@ -102,8 +86,13 @@ public class StanzaSessionTestCase exten
long inTime = System.currentTimeMillis();
while (System.currentTimeMillis() < inTime + 10000) {
Stanza stanza = session.poll();
- if (stanza != null) return stanza;
- try { Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); }
+ if (stanza != null)
+ return stanza;
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
}
return null;
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java Sat Jun 26 20:39:54 2010
@@ -19,15 +19,15 @@
*/
package org.apache.vysper.xmpp.addressing;
-import junit.framework.TestCase;
-
import java.util.Arrays;
+import junit.framework.TestCase;
+
public class EntityConformanceTestCase extends TestCase {
- public void testCheckRFC3920Conformance() {
- String error = buildLargeString(1024);
- String okButOnTheEdge = buildLargeString(1023);
+ public void testCheckRFC3920Conformance() {
+ String error = buildLargeString(1024);
+ String okButOnTheEdge = buildLargeString(1023);
runAllChecks(error, "x");
runAllChecks(error, okButOnTheEdge);
}
@@ -50,15 +50,14 @@ public class EntityConformanceTestCase e
}
private boolean doCheck(String node, String domain, String resource) {
- return EntityConformance.checkRFC3920Conformance(new EntityImpl(
- node, domain, resource));
- }
-
- private String buildLargeString(int length) {
- char[] chars = new char[length];
- Arrays.fill(chars, 'x');
- return new String(chars);
- }
+ return EntityConformance.checkRFC3920Conformance(new EntityImpl(node, domain, resource));
+ }
+
+ private String buildLargeString(int length) {
+ char[] chars = new char[length];
+ Arrays.fill(chars, 'x');
+ return new String(chars);
+ }
public void testEquals() {
assertEquals(new EntityImpl(null, "vysper.org", null), new EntityImpl(null, "vysper.org", ""));
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/authorization/PlainTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/authorization/PlainTestCase.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/authorization/PlainTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/authorization/PlainTestCase.java Sat Jun 26 20:39:54 2010
@@ -21,14 +21,14 @@ package org.apache.vysper.xmpp.authoriza
import junit.framework.TestCase;
+import org.apache.commons.codec.binary.Base64;
import org.apache.vysper.xml.fragment.XMLSemanticError;
-import org.apache.vysper.xmpp.server.TestSessionContext;
-import org.apache.vysper.xmpp.server.SessionState;
-import org.apache.vysper.xmpp.protocol.SessionStateHolder;
import org.apache.vysper.xmpp.protocol.NamespaceURIs;
-import org.apache.vysper.xmpp.stanza.StanzaBuilder;
+import org.apache.vysper.xmpp.protocol.SessionStateHolder;
+import org.apache.vysper.xmpp.server.SessionState;
+import org.apache.vysper.xmpp.server.TestSessionContext;
import org.apache.vysper.xmpp.stanza.Stanza;
-import org.apache.commons.codec.binary.Base64;
+import org.apache.vysper.xmpp.stanza.StanzaBuilder;
/**
*/
@@ -45,9 +45,8 @@ public class PlainTestCase extends TestC
public void testPlainNonBASE64() throws XMLSemanticError {
- Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
- .addText("aEflkejidkj==")
- .build();
+ Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL).addText(
+ "aEflkejidkj==").build();
Stanza response = startMechanism(stanza);
assertResponse(response, "malformed-request");
@@ -55,9 +54,8 @@ public class PlainTestCase extends TestC
public void testPlainNonExistingUser() throws XMLSemanticError {
- Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
- .addText(encode("dieter", "schluppkoweit"))
- .build();
+ Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL).addText(
+ encode("dieter", "schluppkoweit")).build();
Stanza response = startMechanism(stanza);
assertResponse(response, "not-authorized");
@@ -65,9 +63,8 @@ public class PlainTestCase extends TestC
public void testPlainNotExistingUser() throws XMLSemanticError {
- Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
- .addText(encode("dieter", "schluppkoweit"))
- .build();
+ Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL).addText(
+ encode("dieter", "schluppkoweit")).build();
Stanza response = startMechanism(stanza);
assertResponse(response, "not-authorized");
@@ -77,8 +74,8 @@ public class PlainTestCase extends TestC
String innerText = new String(Base64.encodeBase64("continuous".getBytes()));
- Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
- .addText(innerText).build();
+ Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL).addText(innerText)
+ .build();
Stanza response = startMechanism(stanza);
assertResponse(response, "malformed-request");
@@ -94,7 +91,7 @@ public class PlainTestCase extends TestC
private void assertResponse(Stanza response, String failureType) throws XMLSemanticError {
assertTrue(response.getVerifier().nameEquals("failure"));
assertNotNull(response.getSingleInnerElementsNamed(failureType));
- assert stateHolder.getState() != SessionState.AUTHENTICATED;
+ assert stateHolder.getState() != SessionState.AUTHENTICATED;
}
private String encode(String username, String password) {
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/datetime/DateTimeProfileTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/datetime/DateTimeProfileTestCase.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/datetime/DateTimeProfileTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/datetime/DateTimeProfileTestCase.java Sat Jun 26 20:39:54 2010
@@ -26,7 +26,7 @@ import junit.framework.TestCase;
@SuppressWarnings("deprecation")
public class DateTimeProfileTestCase extends TestCase {
-
+
private DateTimeProfile dt = DateTimeProfile.getInstance();
public void testFormatDateTime() throws Exception {
@@ -50,12 +50,11 @@ public class DateTimeProfileTestCase ext
cal.set(Calendar.HOUR_OF_DAY, 11);
cal.set(Calendar.MINUTE, 12);
cal.set(Calendar.SECOND, 13);
-
+
String actual = dt.getTimeInUTC(cal.getTime());
assertEquals("11:12:13Z", actual);
}
-
public void testParseDateTimeWithTz() throws Exception {
Calendar actual = dt.fromDateTime("2009-09-11T11:12:13-01:30");
Calendar expected = Calendar.getInstance(TimeZone.getTimeZone("GMT-01:30"));
@@ -76,7 +75,7 @@ public class DateTimeProfileTestCase ext
try {
dt.fromDateTime("2009-09-11T11:12:13");
fail("Must throw IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// OK
}
}
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringStanzaRelayTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringStanzaRelayTestCase.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringStanzaRelayTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringStanzaRelayTestCase.java Sat Jun 26 20:39:54 2010
@@ -40,9 +40,11 @@ import org.apache.vysper.xmpp.state.reso
/**
*/
public class DeliveringStanzaRelayTestCase extends TestCase {
-
+
protected ResourceRegistry resourceRegistry = new ResourceRegistry();
+
protected AccountManagement accountVerification;
+
protected DeliveringInboundStanzaRelay stanzaRelay;
static class AccountVerificationMock implements AccountManagement {
@@ -60,13 +62,14 @@ public class DeliveringStanzaRelayTestCa
super.setUp();
accountVerification = new AccountVerificationMock();
- stanzaRelay = new DeliveringInboundStanzaRelay(EntityImpl.parse("vysper.org"), resourceRegistry, accountVerification);
+ stanzaRelay = new DeliveringInboundStanzaRelay(EntityImpl.parse("vysper.org"), resourceRegistry,
+ accountVerification);
}
public void testSimpleRelay() throws EntityFormatException, XMLSemanticError, DeliveryException {
DefaultServerRuntimeContext serverRuntimeContext = new DefaultServerRuntimeContext(null, null);
stanzaRelay.setServerRuntimeContext(serverRuntimeContext);
-
+
EntityImpl fromEntity = EntityImpl.parse("userFrom@vysper.org");
EntityImpl toEntity = EntityImpl.parse("userTo@vysper.org");
TestSessionContext sessionContext = TestSessionContext.createSessionContext(toEntity);
@@ -84,7 +87,7 @@ public class DeliveringStanzaRelayTestCa
throw e;
}
}
-
+
public void testSimpleRelayToUnboundSession() throws EntityFormatException, XMLSemanticError, DeliveryException {
EntityImpl fromEntity = EntityImpl.parse("userFrom@vysper.org");
EntityImpl toEntity = EntityImpl.parse("userTo@vysper.org");
@@ -104,9 +107,10 @@ public class DeliveringStanzaRelayTestCa
}
}
- public void testRelayToTwoRecepients_DeliverToALL() throws EntityFormatException, XMLSemanticError, DeliveryException, BindException {
+ public void testRelayToTwoRecepients_DeliverToALL() throws EntityFormatException, XMLSemanticError,
+ DeliveryException, BindException {
DefaultServerRuntimeContext serverRuntimeContext = new DefaultServerRuntimeContext(null, null);
-
+
// !! DeliverMessageToHighestPriorityResourcesOnly = FALSE
serverRuntimeContext.getServerFeatures().setDeliverMessageToHighestPriorityResourcesOnly(false);
@@ -116,7 +120,6 @@ public class DeliveringStanzaRelayTestCa
EntityImpl toEntity = EntityImpl.parse("userTo@vysper.org");
-
TestSessionContext sessionContextToEntity_1_prio3 = createSessionForTo(toEntity, 3); // NON-NEGATIVE
TestSessionContext sessionContextToEntity_2_prio0 = createSessionForTo(toEntity, 0); // NON-NEGATIVE
TestSessionContext sessionContextToEntity_3_prio3 = createSessionForTo(toEntity, 3); // NON-NEGATIVE
@@ -140,7 +143,8 @@ public class DeliveringStanzaRelayTestCa
}
- public void testRelayToTwoRecepients_DeliverToHIGHEST() throws EntityFormatException, XMLSemanticError, DeliveryException, BindException {
+ public void testRelayToTwoRecepients_DeliverToHIGHEST() throws EntityFormatException, XMLSemanticError,
+ DeliveryException, BindException {
DefaultServerRuntimeContext serverRuntimeContext = new DefaultServerRuntimeContext(null, null);
// !! DeliverMessageToHighestPriorityResourcesOnly = TRUE
@@ -152,7 +156,6 @@ public class DeliveringStanzaRelayTestCa
EntityImpl toEntity = EntityImpl.parse("userTo@vysper.org");
-
TestSessionContext sessionContextToEntity_1_prio3 = createSessionForTo(toEntity, 3); // HIGHEST PRIO
TestSessionContext sessionContextToEntity_2_prio0 = createSessionForTo(toEntity, 1); // not receiving
TestSessionContext sessionContextToEntity_3_prio3 = createSessionForTo(toEntity, 3); // HIGHEST PRIO
@@ -184,5 +187,4 @@ public class DeliveringStanzaRelayTestCa
return sessionContextToEntity;
}
-
}
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/TestUser.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/TestUser.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/TestUser.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/TestUser.java Sat Jun 26 20:39:54 2010
@@ -23,31 +23,36 @@ import org.apache.vysper.xmpp.addressing
import org.apache.vysper.xmpp.addressing.EntityFormatException;
import org.apache.vysper.xmpp.addressing.EntityImpl;
import org.apache.vysper.xmpp.delivery.StanzaReceiverQueue;
-import org.apache.vysper.xmpp.server.TestSessionContext;
-import org.apache.vysper.xmpp.state.resourcebinding.BindException;
-import org.apache.vysper.xmpp.modules.roster.persistence.MemoryRosterManager;
-import org.apache.vysper.xmpp.modules.roster.SubscriptionType;
import org.apache.vysper.xmpp.modules.roster.RosterException;
import org.apache.vysper.xmpp.modules.roster.RosterItem;
+import org.apache.vysper.xmpp.modules.roster.SubscriptionType;
+import org.apache.vysper.xmpp.modules.roster.persistence.MemoryRosterManager;
+import org.apache.vysper.xmpp.server.TestSessionContext;
import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.state.resourcebinding.BindException;
public class TestUser {
protected String boundResourceId;
+
protected Entity entity;
+
protected StanzaReceiverQueue queue;
+
protected Entity fqEntity;
public static TestUser createForSession(TestSessionContext sessionContext, Entity entity) throws BindException {
return createForSession(sessionContext, entity, true);
}
- public static TestUser createForSession(TestSessionContext sessionContext, Entity entity, boolean receiveForFullJID) throws BindException {
+ public static TestUser createForSession(TestSessionContext sessionContext, Entity entity, boolean receiveForFullJID)
+ throws BindException {
String boundResourceId = sessionContext.bindResource();
StanzaReceiverQueue queue = sessionContext.addReceiver(entity, receiveForFullJID ? boundResourceId : null);
return new TestUser(boundResourceId, entity, queue);
}
- public static TestUser createQueueReceiver(TestSessionContext parentSession, String entity) throws BindException, EntityFormatException {
+ public static TestUser createQueueReceiver(TestSessionContext parentSession, String entity) throws BindException,
+ EntityFormatException {
return createQueueReceiver(parentSession, EntityImpl.parse(entity));
}
@@ -56,9 +61,12 @@ public class TestUser {
return new TestUser(null, entity, queue);
}
- public static TestUser createContact(TestSessionContext parentSession, MemoryRosterManager rosterManager, String entity, SubscriptionType subscriptionType) throws BindException, EntityFormatException, RosterException {
+ public static TestUser createContact(TestSessionContext parentSession, MemoryRosterManager rosterManager,
+ String entity, SubscriptionType subscriptionType) throws BindException, EntityFormatException,
+ RosterException {
TestUser testUser = createQueueReceiver(parentSession, EntityImpl.parse(entity));
- rosterManager.addContact(parentSession.getInitiatingEntity(), new RosterItem(testUser.getEntity(), subscriptionType));
+ rosterManager.addContact(parentSession.getInitiatingEntity(), new RosterItem(testUser.getEntity(),
+ subscriptionType));
return testUser;
}
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/IQHandlerTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/IQHandlerTestCase.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/IQHandlerTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/IQHandlerTestCase.java Sat Jun 26 20:39:54 2010
@@ -20,6 +20,8 @@
package org.apache.vysper.xmpp.modules.core.base.handler;
+import junit.framework.TestCase;
+
import org.apache.vysper.xml.fragment.XMLElementVerifier;
import org.apache.vysper.xmpp.protocol.NamespaceURIs;
import org.apache.vysper.xmpp.protocol.ResponseStanzaContainer;
@@ -30,7 +32,6 @@ import org.apache.vysper.xmpp.stanza.IQS
import org.apache.vysper.xmpp.stanza.Stanza;
import org.apache.vysper.xmpp.stanza.StanzaBuilder;
import org.apache.vysper.xmpp.stanza.XMPPCoreStanzaVerifier;
-import junit.framework.TestCase;
/**
*/
@@ -56,7 +57,8 @@ public class IQHandlerTestCase extends T
sessionContext.setServerToServer();
TestIQHandler iqHandler = new TestIQHandler();
- ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanzaBuilder.build(), sessionContext.getServerRuntimeContext(), true, sessionContext, null);
+ ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanzaBuilder.build(), sessionContext
+ .getServerRuntimeContext(), true, sessionContext, null);
Stanza responseStanza = responseStanzaContainer.getResponseStanza();
XMLElementVerifier verifier = responseStanza.getVerifier();
assertTrue("error", verifier.nameEquals("error"));
@@ -74,7 +76,8 @@ public class IQHandlerTestCase extends T
Stanza stanza = stanzaBuilder.build(); // this stanza has no ID
IQHandler iqHandler = new IQHandler();
- ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanza, sessionContext.getServerRuntimeContext(), true, sessionContext, null);
+ ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanza, sessionContext
+ .getServerRuntimeContext(), true, sessionContext, null);
Stanza responseStanza = responseStanzaContainer.getResponseStanza();
XMLElementVerifier verifier = responseStanza.getVerifier();
assertTrue("error", verifier.nameEquals("error")); // response is _not_ IQ stanza
@@ -82,7 +85,8 @@ public class IQHandlerTestCase extends T
private void assertIQError(Stanza stanza) {
TestIQHandler iqHandler = new TestIQHandler();
- ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanza, sessionContext.getServerRuntimeContext(), true, sessionContext, null);
+ ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanza, sessionContext
+ .getServerRuntimeContext(), true, sessionContext, null);
Stanza responseStanza = responseStanzaContainer.getResponseStanza();
XMLElementVerifier verifier = responseStanza.getVerifier();
assertTrue("iq", verifier.nameEquals("iq"));
@@ -108,7 +112,7 @@ public class IQHandlerTestCase extends T
// get and set must have exactly one subelement
String type = "get";
- assertAnySub(type); // test with zero
+ assertAnySub(type); // test with zero
assertNotTwoSubs(type); // test with 2
type = "set";
@@ -145,7 +149,8 @@ public class IQHandlerTestCase extends T
stanzaBuilder.startInnerElement("getRequest", NamespaceURIs.JABBER_CLIENT).endInnerElement();
TestIQHandler iqHandler = new TestIQHandler();
- ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanzaBuilder.build(), sessionContext.getServerRuntimeContext(), true, sessionContext, null);
+ ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanzaBuilder.build(), sessionContext
+ .getServerRuntimeContext(), true, sessionContext, null);
IQStanza incomingStanza = iqHandler.getIncomingStanza();
XMPPCoreStanzaVerifier verifier = incomingStanza.getCoreVerifier();
@@ -162,4 +167,3 @@ public class IQHandlerTestCase extends T
}
}
-
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/MessageHandlerRelayTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/MessageHandlerRelayTestCase.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/MessageHandlerRelayTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/MessageHandlerRelayTestCase.java Sat Jun 26 20:39:54 2010
@@ -23,11 +23,13 @@ package org.apache.vysper.xmpp.modules.c
import junit.framework.TestCase;
import org.apache.vysper.xml.fragment.XMLElementVerifier;
-import org.apache.vysper.xmpp.addressing.EntityImpl;
import org.apache.vysper.xmpp.addressing.Entity;
import org.apache.vysper.xmpp.addressing.EntityFormatException;
-import org.apache.vysper.xmpp.delivery.*;
+import org.apache.vysper.xmpp.addressing.EntityImpl;
+import org.apache.vysper.xmpp.delivery.StanzaReceiverQueue;
+import org.apache.vysper.xmpp.delivery.StanzaReceiverRelay;
import org.apache.vysper.xmpp.delivery.failure.DeliveryException;
+import org.apache.vysper.xmpp.modules.core.TestUser;
import org.apache.vysper.xmpp.protocol.NamespaceURIs;
import org.apache.vysper.xmpp.protocol.ResponseStanzaContainer;
import org.apache.vysper.xmpp.protocol.SessionStateHolder;
@@ -35,7 +37,6 @@ import org.apache.vysper.xmpp.server.Tes
import org.apache.vysper.xmpp.stanza.Stanza;
import org.apache.vysper.xmpp.stanza.StanzaBuilder;
import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
-import org.apache.vysper.xmpp.modules.core.TestUser;
/**
*/
@@ -43,27 +44,32 @@ public class MessageHandlerRelayTestCase
private MessageHandler messageHandler = new MessageHandler();
private TestSessionContext senderSessionContext;
-// private SessionStateHolder sessionStateHolder = new SessionStateHolder();
+
+ // private SessionStateHolder sessionStateHolder = new SessionStateHolder();
protected Entity sender;
+
protected TestUser senderUser;
private TestSessionContext receiverSessionContext;
-// private SessionStateHolder sessionStateHolder = new SessionStateHolder();
+
+ // private SessionStateHolder sessionStateHolder = new SessionStateHolder();
protected Entity receiver;
+
protected TestUser receiverUser;
@Override
protected void setUp() throws Exception {
super.setUp();
-
+
// sender
senderSessionContext = TestSessionContext.createWithStanzaReceiverRelay(new SessionStateHolder());
sender = EntityImpl.parse("sender@vysper.org");
senderSessionContext.setInitiatingEntity(sender);
senderUser = TestUser.createForSession(senderSessionContext, sender);
-
+
// receiver
- receiverSessionContext = TestSessionContext.createWithStanzaReceiverRelay(new SessionStateHolder(), senderSessionContext.getServerRuntimeContext());
+ receiverSessionContext = TestSessionContext.createWithStanzaReceiverRelay(new SessionStateHolder(),
+ senderSessionContext.getServerRuntimeContext());
receiver = EntityImpl.parse("receiver@vysper.org");
receiverSessionContext.setInitiatingEntity(receiver);
receiverUser = TestUser.createForSession(receiverSessionContext, receiver, false);
@@ -75,20 +81,23 @@ public class MessageHandlerRelayTestCase
StanzaBuilder stanzaBuilder = new StanzaBuilder("message", NamespaceURIs.JABBER_SERVER);
// receiver@vysper.org, NOT receiver@vysper.org/resourceID
stanzaBuilder.addAttribute("to", receiverUser.getEntity().getBareJID().getFullQualifiedName());
- stanzaBuilder.startInnerElement("timestamp", NamespaceURIs.JABBER_SERVER).addAttribute("value", timestamp).endInnerElement();
+ stanzaBuilder.startInnerElement("timestamp", NamespaceURIs.JABBER_SERVER).addAttribute("value", timestamp)
+ .endInnerElement();
senderSessionContext.setClientToServer();
-
+
assertNull(receiverUser.getNextStanza()); // nothing there yet
assertNull(senderUser.getNextStanza()); // nothing there yet
Stanza stanza = stanzaBuilder.build();
- ResponseStanzaContainer responseStanzaContainer = messageHandler.execute(stanza, senderSessionContext.getServerRuntimeContext(), true, senderSessionContext, null);
+ ResponseStanzaContainer responseStanzaContainer = messageHandler.execute(stanza, senderSessionContext
+ .getServerRuntimeContext(), true, senderSessionContext, null);
Stanza receivedStanza = receiverUser.getNextStanza();
XMLElementVerifier timestampVerifier = receivedStanza.getFirstInnerElement().getVerifier();
-
- assertTrue("stanza relayed to", receivedStanza.getVerifier().toAttributeEquals(receiverUser.getEntity().getFullQualifiedName()));
+
+ assertTrue("stanza relayed to", receivedStanza.getVerifier().toAttributeEquals(
+ receiverUser.getEntity().getFullQualifiedName()));
assertTrue("stanza relayed inner", timestampVerifier.attributeEquals("value", timestamp));
assertNotNull("from added", receivedStanza.getFrom());
assertNotNull("from is full JID", receivedStanza.getFrom().equals(senderUser.getEntityFQ()));
@@ -101,18 +110,21 @@ public class MessageHandlerRelayTestCase
Entity receiver = EntityImpl.parse("to_exist@example.com");
Entity noReceiver = EntityImpl.parse("to_unavail@example.com");
- StanzaReceiverRelay stanzaRelay = (StanzaReceiverRelay) senderSessionContext.getServerRuntimeContext().getStanzaRelay();
+ StanzaReceiverRelay stanzaRelay = (StanzaReceiverRelay) senderSessionContext.getServerRuntimeContext()
+ .getStanzaRelay();
StanzaReceiverQueue senderQueue = new StanzaReceiverQueue();
StanzaReceiverQueue receiverQueue = new StanzaReceiverQueue();
stanzaRelay.add(sender, senderQueue);
stanzaRelay.add(receiver, receiverQueue);
Stanza successfulMessageStanza = StanzaBuilder.createMessageStanza(sender, receiver, "en", "info").build();
- ResponseStanzaContainer responseStanzaContainer = messageHandler.execute(successfulMessageStanza, senderSessionContext.getServerRuntimeContext(), true, senderSessionContext, null);
+ ResponseStanzaContainer responseStanzaContainer = messageHandler.execute(successfulMessageStanza,
+ senderSessionContext.getServerRuntimeContext(), true, senderSessionContext, null);
assertEquals(successfulMessageStanza, receiverQueue.getNext());
Stanza failureMessageStanza = StanzaBuilder.createMessageStanza(sender, noReceiver, "en", "info").build();
- responseStanzaContainer = messageHandler.execute(failureMessageStanza, senderSessionContext.getServerRuntimeContext(), true, senderSessionContext, null);
+ responseStanzaContainer = messageHandler.execute(failureMessageStanza, senderSessionContext
+ .getServerRuntimeContext(), true, senderSessionContext, null);
assertNull(receiverQueue.getNext());
Stanza rejectionStanza = senderQueue.getNext();
assertNotNull(rejectionStanza);
@@ -120,5 +132,5 @@ public class MessageHandlerRelayTestCase
assertEquals("error", rejectionCoreStanza.getType());
}
-
+
}
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/RelayingIQHandlerTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/RelayingIQHandlerTestCase.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/RelayingIQHandlerTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/RelayingIQHandlerTestCase.java Sat Jun 26 20:39:54 2010
@@ -22,7 +22,10 @@ package org.apache.vysper.xmpp.modules.c
import org.apache.vysper.xmpp.modules.core.im.handler.PresenceHandlerBaseTestCase;
import org.apache.vysper.xmpp.protocol.NamespaceURIs;
import org.apache.vysper.xmpp.protocol.ResponseStanzaContainer;
-import org.apache.vysper.xmpp.stanza.*;
+import org.apache.vysper.xmpp.stanza.IQStanzaType;
+import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.stanza.StanzaBuilder;
+import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
/**
*/
@@ -31,18 +34,22 @@ public class RelayingIQHandlerTestCase e
protected RelayingIQHandler relayingIQHandler = new RelayingIQHandler();
public void testIQClientToClient_Outbound_NotSubscribed() {
- Stanza iqStanza = StanzaBuilder.createIQStanza(initiatingUser.getEntityFQ(), unrelatedUser.getEntityFQ(), IQStanzaType.GET, "test").startInnerElement("mandatory", NamespaceURIs.JABBER_CLIENT).build();
+ Stanza iqStanza = StanzaBuilder.createIQStanza(initiatingUser.getEntityFQ(), unrelatedUser.getEntityFQ(),
+ IQStanzaType.GET, "test").startInnerElement("mandatory", NamespaceURIs.JABBER_CLIENT).build();
- ResponseStanzaContainer stanzaContainer = relayingIQHandler.execute(iqStanza, sessionContext.getServerRuntimeContext(), true, sessionContext, null /*don't we have as sessionStateHolder?*/);
+ ResponseStanzaContainer stanzaContainer = relayingIQHandler.execute(iqStanza, sessionContext
+ .getServerRuntimeContext(), true, sessionContext, null /*don't we have as sessionStateHolder?*/);
XMPPCoreStanza response = XMPPCoreStanza.getWrapper(stanzaContainer.getResponseStanza());
assertNotNull(response);
assertTrue(response.isError());
}
public void testIQClientToClient_Outbound() {
- Stanza iqStanza = StanzaBuilder.createIQStanza(initiatingUser.getEntityFQ(), subscribed_FROM.getEntityFQ(), IQStanzaType.GET, "test").startInnerElement("mandatory", NamespaceURIs.JABBER_CLIENT).build();
+ Stanza iqStanza = StanzaBuilder.createIQStanza(initiatingUser.getEntityFQ(), subscribed_FROM.getEntityFQ(),
+ IQStanzaType.GET, "test").startInnerElement("mandatory", NamespaceURIs.JABBER_CLIENT).build();
- ResponseStanzaContainer stanzaContainer = relayingIQHandler.execute(iqStanza, sessionContext.getServerRuntimeContext(), true, sessionContext, null /*don't we have as sessionStateHolder?*/);
+ ResponseStanzaContainer stanzaContainer = relayingIQHandler.execute(iqStanza, sessionContext
+ .getServerRuntimeContext(), true, sessionContext, null /*don't we have as sessionStateHolder?*/);
assertNull(stanzaContainer);
Stanza deliveredStanza = subscribed_FROM.getNextStanza();
assertTrue(deliveredStanza.getVerifier().onlySubelementEquals("mandatory", NamespaceURIs.JABBER_CLIENT));
@@ -50,18 +57,22 @@ public class RelayingIQHandlerTestCase e
}
public void testIQClientToClient_Inbound_NoTO() {
- Stanza iqStanza = StanzaBuilder.createIQStanza(subscribed_FROM.getEntityFQ(), initiatingUser.getEntityFQ(), IQStanzaType.GET, "test").startInnerElement("mandatory", NamespaceURIs.JABBER_CLIENT).build();
+ Stanza iqStanza = StanzaBuilder.createIQStanza(subscribed_FROM.getEntityFQ(), initiatingUser.getEntityFQ(),
+ IQStanzaType.GET, "test").startInnerElement("mandatory", NamespaceURIs.JABBER_CLIENT).build();
- ResponseStanzaContainer stanzaContainer = relayingIQHandler.execute(iqStanza, sessionContext.getServerRuntimeContext(), false, sessionContext, null /*don't we have as sessionStateHolder?*/);
+ ResponseStanzaContainer stanzaContainer = relayingIQHandler.execute(iqStanza, sessionContext
+ .getServerRuntimeContext(), false, sessionContext, null /*don't we have as sessionStateHolder?*/);
XMPPCoreStanza response = XMPPCoreStanza.getWrapper(stanzaContainer.getResponseStanza());
assertNotNull(response);
assertTrue(response.isError());
}
public void testIQClientToClient_Inbound() {
- Stanza iqStanza = StanzaBuilder.createIQStanza(subscribed_TO.getEntityFQ(), initiatingUser.getEntityFQ(), IQStanzaType.GET, "test").startInnerElement("mandatory", NamespaceURIs.JABBER_CLIENT).build();
+ Stanza iqStanza = StanzaBuilder.createIQStanza(subscribed_TO.getEntityFQ(), initiatingUser.getEntityFQ(),
+ IQStanzaType.GET, "test").startInnerElement("mandatory", NamespaceURIs.JABBER_CLIENT).build();
- ResponseStanzaContainer stanzaContainer = relayingIQHandler.execute(iqStanza, sessionContext.getServerRuntimeContext(), false, sessionContext, null /*don't we have as sessionStateHolder?*/);
+ ResponseStanzaContainer stanzaContainer = relayingIQHandler.execute(iqStanza, sessionContext
+ .getServerRuntimeContext(), false, sessionContext, null /*don't we have as sessionStateHolder?*/);
assertNull(stanzaContainer);
Stanza deliveredStanza = sessionContext.getNextRecordedResponse();
assertTrue(deliveredStanza.getVerifier().onlySubelementEquals("mandatory", NamespaceURIs.JABBER_CLIENT));
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/TestIQHandler.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/TestIQHandler.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/TestIQHandler.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/TestIQHandler.java Sat Jun 26 20:39:54 2010
@@ -21,18 +21,19 @@
package org.apache.vysper.xmpp.modules.core.base.handler;
import org.apache.vysper.xmpp.protocol.NamespaceURIs;
-import org.apache.vysper.xmpp.server.SessionContext;
import org.apache.vysper.xmpp.server.ServerRuntimeContext;
+import org.apache.vysper.xmpp.server.SessionContext;
import org.apache.vysper.xmpp.stanza.IQStanza;
+import org.apache.vysper.xmpp.stanza.IQStanzaType;
import org.apache.vysper.xmpp.stanza.Stanza;
import org.apache.vysper.xmpp.stanza.StanzaBuilder;
-import org.apache.vysper.xmpp.stanza.IQStanzaType;
public class TestIQHandler extends IQHandler {
String name = null;
private IQStanza incomingStanza;
+
private String namespaceURI;
public TestIQHandler() {
@@ -46,21 +47,26 @@ public class TestIQHandler extends IQHan
@Override
public boolean verify(Stanza stanza) {
- if (!super.verify(stanza)) return false;
- if (name == null) return true;
+ if (!super.verify(stanza))
+ return false;
+ if (name == null)
+ return true;
return stanza.getVerifier().onlySubelementEquals(name, namespaceURI);
}
@Override
- protected Stanza executeIQLogic(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, boolean outboundStanza, SessionContext sessionContext) {
+ protected Stanza executeIQLogic(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, boolean outboundStanza,
+ SessionContext sessionContext) {
incomingStanza = stanza;
- StanzaBuilder responseBuilder = new StanzaBuilder("iq", NamespaceURIs.JABBER_CLIENT, stanza.getNamespacePrefix());
- if (stanza.getID() != null) responseBuilder.addAttribute("id", stanza.getID());
+ StanzaBuilder responseBuilder = new StanzaBuilder("iq", NamespaceURIs.JABBER_CLIENT, stanza
+ .getNamespacePrefix());
+ if (stanza.getID() != null)
+ responseBuilder.addAttribute("id", stanza.getID());
responseBuilder.addAttribute("type", IQStanzaType.RESULT.value());
- return responseBuilder.build();
+ return responseBuilder.build();
}
public IQStanza getIncomingStanza() {
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/async/AsyncIQGetHandlerTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/async/AsyncIQGetHandlerTestCase.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/async/AsyncIQGetHandlerTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/base/handler/async/AsyncIQGetHandlerTestCase.java Sat Jun 26 20:39:54 2010
@@ -19,7 +19,13 @@
*/
package org.apache.vysper.xmpp.modules.core.base.handler.async;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
import junit.framework.TestCase;
+
import org.apache.vysper.xmpp.addressing.EntityImpl;
import org.apache.vysper.xmpp.protocol.NamespaceURIs;
import org.apache.vysper.xmpp.protocol.ResponseStanzaContainer;
@@ -33,17 +39,12 @@ import org.apache.vysper.xmpp.stanza.Sta
import org.apache.vysper.xmpp.stanza.StanzaBuilder;
import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
/**
*
* @author The Apache MINA Project (dev@mina.apache.org)
*/
public class AsyncIQGetHandlerTestCase extends TestCase {
-
+
private TestSessionContext sessionContext;
private SessionStateHolder sessionStateHolder = new SessionStateHolder();
@@ -55,7 +56,7 @@ public class AsyncIQGetHandlerTestCase e
}
protected static final int SLEEP_INTERVAL = 50;
-
+
private static class AsyncIQGetHandler extends AbstractAsyncIQGetHandler implements Executor {
protected TriggeredRunnableFuture triggeredRunnableFuture;
@@ -65,11 +66,12 @@ public class AsyncIQGetHandlerTestCase e
}
@Override
- protected RunnableFuture<XMPPCoreStanza> createGetTask(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext) {
+ protected RunnableFuture<XMPPCoreStanza> createGetTask(IQStanza stanza,
+ ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext) {
triggeredRunnableFuture = new TriggeredRunnableFuture(stanza, serverRuntimeContext, sessionContext);
return triggeredRunnableFuture;
}
-
+
public TriggeredRunnableFuture getWaitingRunnableFuture() {
return triggeredRunnableFuture;
}
@@ -78,15 +80,17 @@ public class AsyncIQGetHandlerTestCase e
new Thread(runnable).start();
}
}
-
+
private static class TriggeredRunnableFuture extends ResponseFuture<XMPPCoreStanza> {
-
+
protected boolean done = false;
-
+
private boolean triggerDelivery = false; // to signal from test when to proceed
+
protected XMPPCoreStanza response = null;
- protected TriggeredRunnableFuture(XMPPCoreStanza requestStanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext) {
+ protected TriggeredRunnableFuture(XMPPCoreStanza requestStanza, ServerRuntimeContext serverRuntimeContext,
+ SessionContext sessionContext) {
super(requestStanza, serverRuntimeContext, sessionContext);
}
@@ -106,7 +110,8 @@ public class AsyncIQGetHandlerTestCase e
return response;
}
- public XMPPCoreStanza get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
+ public XMPPCoreStanza get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException,
+ TimeoutException {
return response;
}
@@ -120,8 +125,9 @@ public class AsyncIQGetHandlerTestCase e
}
}
try {
- Stanza finalStanza = StanzaBuilder.createIQStanza(requestStanza.getTo(), requestStanza.getFrom(), IQStanzaType.RESULT, requestStanza.getID()).
- startInnerElement("success", NamespaceURIs.JABBER_CLIENT).endInnerElement().build();
+ Stanza finalStanza = StanzaBuilder.createIQStanza(requestStanza.getTo(), requestStanza.getFrom(),
+ IQStanzaType.RESULT, requestStanza.getID()).startInnerElement("success",
+ NamespaceURIs.JABBER_CLIENT).endInnerElement().build();
response = XMPPCoreStanza.getWrapper(finalStanza);
} catch (Throwable e) {
e.printStackTrace();
@@ -130,37 +136,42 @@ public class AsyncIQGetHandlerTestCase e
done = true;
}
}
-
+
public void triggerDelivery() {
triggerDelivery = true;
}
}
-
+
public void testAsyncGet() throws ExecutionException, InterruptedException {
AsyncIQGetHandler asyncIQGetHandler = new AsyncIQGetHandler();
-
+
assertNull("future is create on execute", asyncIQGetHandler.getWaitingRunnableFuture());
- StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(new EntityImpl("test", "vysper.org", null), null, IQStanzaType.GET, "id1");
+ StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(new EntityImpl("test", "vysper.org", null), null,
+ IQStanzaType.GET, "id1");
stanzaBuilder.startInnerElement("query", NamespaceURIs.JABBER_CLIENT).endInnerElement();
Stanza iqStanza = stanzaBuilder.build();
- ResponseStanzaContainer container = asyncIQGetHandler.execute(iqStanza, sessionContext.getServerRuntimeContext(), true, sessionContext, sessionStateHolder);
+ ResponseStanzaContainer container = asyncIQGetHandler.execute(iqStanza, sessionContext
+ .getServerRuntimeContext(), true, sessionContext, sessionStateHolder);
assertTrue(container == null || container.hasNoResponse());
TriggeredRunnableFuture runnableFuture = asyncIQGetHandler.getWaitingRunnableFuture();
assertNotNull("future has been created", runnableFuture);
assertFalse("not done", runnableFuture.isDone());
-
+
runnableFuture.triggerDelivery();
while (!runnableFuture.isDone()) {
- try { Thread.sleep(SLEEP_INTERVAL); } catch (InterruptedException e) { ; }
+ try {
+ Thread.sleep(SLEEP_INTERVAL);
+ } catch (InterruptedException e) {
+ ;
+ }
}
XMPPCoreStanza coreStanza = runnableFuture.get();
assertNotNull(coreStanza);
-
- }
+ }
}
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/DirectedPresenceHandlerTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/DirectedPresenceHandlerTestCase.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/DirectedPresenceHandlerTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/DirectedPresenceHandlerTestCase.java Sat Jun 26 20:39:54 2010
@@ -20,19 +20,18 @@
package org.apache.vysper.xmpp.modules.core.im.handler;
-import org.apache.vysper.xmpp.addressing.EntityFormatException;
+import java.util.Set;
+
import org.apache.vysper.xmpp.addressing.Entity;
+import org.apache.vysper.xmpp.addressing.EntityFormatException;
import org.apache.vysper.xmpp.delivery.StanzaReceiverRelay;
+import org.apache.vysper.xmpp.stanza.PresenceStanza;
+import org.apache.vysper.xmpp.stanza.PresenceStanzaType;
import org.apache.vysper.xmpp.stanza.Stanza;
import org.apache.vysper.xmpp.stanza.StanzaBuilder;
import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
-import org.apache.vysper.xmpp.stanza.PresenceStanza;
-import org.apache.vysper.xmpp.stanza.PresenceStanzaType;
import org.apache.vysper.xmpp.state.resourcebinding.BindException;
import org.apache.vysper.xmpp.state.resourcebinding.ResourceState;
-import org.apache.vysper.xmpp.server.SessionState;
-
-import java.util.Set;
/**
*/
@@ -41,21 +40,24 @@ public class DirectedPresenceHandlerTest
protected PresenceHandler handler = new PresenceHandler();
public void testUpdatedPresence() throws BindException, EntityFormatException {
- StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext().getStanzaRelay();
+ StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext()
+ .getStanzaRelay();
setResourceState(initiatingUser.getBoundResourceId(), ResourceState.AVAILABLE_INTERESTED);
// at first, initial presence
- XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), unrelatedUser.getEntityFQ(), null, null, null, null).build());
+ XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
+ initiatingUser.getEntityFQ(), unrelatedUser.getEntityFQ(), null, null, null, null).build());
handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
assertTrue(0 < receiverRelay.getCountDelivered());
// directed presence has been recorded internally
- Set<Entity> map = (Set<Entity>)sessionContext.getAttribute("DIRECTED_PRESENCE_MAP_" + initiatingUser.getBoundResourceId());
+ Set<Entity> map = (Set<Entity>) sessionContext.getAttribute("DIRECTED_PRESENCE_MAP_"
+ + initiatingUser.getBoundResourceId());
assertNotNull(map);
assertEquals(map.iterator().next(), unrelatedUser.getEntityFQ());
Stanza directedPresence = unrelatedUser.getNextStanza();
- assertNotNull(directedPresence);
+ assertNotNull(directedPresence);
assertTrue(PresenceStanza.isOfType(directedPresence)); // is presence
PresenceStanza presenceStanza = new PresenceStanza(directedPresence);
assertEquals(initiatingUser.getEntityFQ(), presenceStanza.getFrom());
@@ -63,56 +65,65 @@ public class DirectedPresenceHandlerTest
resetRecordedStanzas(); // purge recorded
// directed unavailable presence
- XMPPCoreStanza directedUnvailPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), unrelatedUser.getEntityFQ(), null, PresenceStanzaType.UNAVAILABLE, null, null).build());
+ XMPPCoreStanza directedUnvailPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
+ initiatingUser.getEntityFQ(), unrelatedUser.getEntityFQ(), null, PresenceStanzaType.UNAVAILABLE, null,
+ null).build());
handler.executeCore(directedUnvailPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
assertTrue(0 < receiverRelay.getCountDelivered());
// directed presence has been recorded internally
- map = (Set<Entity>)sessionContext.getAttribute("DIRECTED_PRESENCE_MAP_" + initiatingUser.getBoundResourceId());
+ map = (Set<Entity>) sessionContext.getAttribute("DIRECTED_PRESENCE_MAP_" + initiatingUser.getBoundResourceId());
assertTrue(map.size() == 0);
- ResourceState resourceState = sessionContext.getServerRuntimeContext().getResourceRegistry().getResourceState(initiatingUser.getBoundResourceId());
+ ResourceState resourceState = sessionContext.getServerRuntimeContext().getResourceRegistry().getResourceState(
+ initiatingUser.getBoundResourceId());
assertTrue(ResourceState.isAvailable(resourceState));
Stanza directedUnavailPresence = unrelatedUser.getNextStanza();
- assertNotNull(directedUnavailPresence);
+ assertNotNull(directedUnavailPresence);
assertTrue(PresenceStanza.isOfType(directedUnavailPresence)); // is presence
presenceStanza = new PresenceStanza(directedUnavailPresence);
assertEquals(initiatingUser.getEntityFQ(), presenceStanza.getFrom());
assertEquals(PresenceStanzaType.UNAVAILABLE, presenceStanza.getPresenceType());
-
+
}
+
public void testUnavailableForDirectedPresences() throws BindException, EntityFormatException {
- StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext().getStanzaRelay();
+ StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext()
+ .getStanzaRelay();
setResourceState(initiatingUser.getBoundResourceId(), ResourceState.AVAILABLE_INTERESTED);
// at first, initial presence
- XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), unrelatedUser.getEntityFQ(), null, null, null, null).build());
+ XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
+ initiatingUser.getEntityFQ(), unrelatedUser.getEntityFQ(), null, null, null, null).build());
handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
// directed presence has been recorded internally
- Set<Entity> map = (Set<Entity>)sessionContext.getAttribute("DIRECTED_PRESENCE_MAP_" + initiatingUser.getBoundResourceId());
+ Set<Entity> map = (Set<Entity>) sessionContext.getAttribute("DIRECTED_PRESENCE_MAP_"
+ + initiatingUser.getBoundResourceId());
assertEquals(map.iterator().next(), unrelatedUser.getEntityFQ());
resetRecordedStanzas(); // purge recorded
// GENERAL unavailable presence
- XMPPCoreStanza generalUnavailable = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), null, null, PresenceStanzaType.UNAVAILABLE, null, null).build());
+ XMPPCoreStanza generalUnavailable = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
+ initiatingUser.getEntityFQ(), null, null, PresenceStanzaType.UNAVAILABLE, null, null).build());
handler.executeCore(generalUnavailable, sessionContext.getServerRuntimeContext(), true, sessionContext);
assertTrue(0 < receiverRelay.getCountDelivered());
- ResourceState resourceState = sessionContext.getServerRuntimeContext().getResourceRegistry().getResourceState(initiatingUser.getBoundResourceId());
+ ResourceState resourceState = sessionContext.getServerRuntimeContext().getResourceRegistry().getResourceState(
+ initiatingUser.getBoundResourceId());
assertFalse(ResourceState.isAvailable(resourceState));
// directed presence has been recorded internally
- map = (Set<Entity>)sessionContext.getAttribute("DIRECTED_PRESENCE_MAP_" + initiatingUser.getBoundResourceId());
+ map = (Set<Entity>) sessionContext.getAttribute("DIRECTED_PRESENCE_MAP_" + initiatingUser.getBoundResourceId());
assertEquals(0, map.size());
Stanza directedUnavailPresence = unrelatedUser.getNextStanza();
- assertNotNull(directedUnavailPresence);
+ assertNotNull(directedUnavailPresence);
assertTrue(PresenceStanza.isOfType(directedUnavailPresence)); // is presence
PresenceStanza presenceStanza = new PresenceStanza(directedUnavailPresence);
assertEquals(initiatingUser.getEntityFQ(), presenceStanza.getFrom());
assertEquals(PresenceStanzaType.UNAVAILABLE, presenceStanza.getPresenceType());
-
+
}
-
+
}
\ No newline at end of file
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailInitialOutHandlerTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailInitialOutHandlerTestCase.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailInitialOutHandlerTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailInitialOutHandlerTestCase.java Sat Jun 26 20:39:54 2010
@@ -20,14 +20,15 @@
package org.apache.vysper.xmpp.modules.core.im.handler;
+import static org.apache.vysper.xmpp.stanza.PresenceStanzaType.PROBE;
+
import org.apache.vysper.xml.fragment.XMLSemanticError;
import org.apache.vysper.xmpp.addressing.EntityFormatException;
import org.apache.vysper.xmpp.delivery.StanzaReceiverRelay;
-import static org.apache.vysper.xmpp.stanza.PresenceStanzaType.PROBE;
import org.apache.vysper.xmpp.stanza.Stanza;
import org.apache.vysper.xmpp.stanza.StanzaBuilder;
-import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
import org.apache.vysper.xmpp.stanza.StanzaErrorCondition;
+import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
import org.apache.vysper.xmpp.state.resourcebinding.BindException;
import org.apache.vysper.xmpp.state.resourcebinding.ResourceState;
@@ -38,7 +39,8 @@ public class PresenceAvailInitialOutHand
protected PresenceHandler handler = new PresenceHandler();
public void testInitialPresence() throws BindException, EntityFormatException {
- XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), null, null, null, null, null).build());
+ XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
+ initiatingUser.getEntityFQ(), null, null, null, null, null).build());
assertEquals(ResourceState.CONNECTED, getResourceState());
handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
@@ -46,27 +48,31 @@ public class PresenceAvailInitialOutHand
assertEquals(ResourceState.AVAILABLE, getResourceState());
// 3 intial presence broadcasts to same session (but not to non-available) + 2 presence to subscribers + 2 probes to subscriptions
- assertEquals(3+2+2, ((StanzaReceiverRelay) sessionContext.getServerRuntimeContext().getStanzaRelay()).getCountDelivered());
-
+ assertEquals(3 + 2 + 2, ((StanzaReceiverRelay) sessionContext.getServerRuntimeContext().getStanzaRelay())
+ .getCountDelivered());
+
//
// check presence broadcasts to resources of same session (self, interested & available)
//
-
+
Stanza initiatorNotification = initiatingUser.getNextStanza();
assertNotNull(initiatorNotification);
assertTrue(checkPresence(initiatorNotification, initiatingUser.getEntityFQ(), null));
- assertTrue(initiatorNotification.getVerifier().toAttributeEquals(initiatingUser.getEntityFQ().getFullQualifiedName()));
-
+ assertTrue(initiatorNotification.getVerifier().toAttributeEquals(
+ initiatingUser.getEntityFQ().getFullQualifiedName()));
+
Stanza availableResourceNotification = anotherAvailableUser.getNextStanza();
assertNotNull(availableResourceNotification);
assertTrue(checkPresence(availableResourceNotification, initiatingUser.getEntityFQ(), null));
- assertTrue(availableResourceNotification.getVerifier().toAttributeEquals(anotherAvailableUser.getEntityFQ().getFullQualifiedName()));
+ assertTrue(availableResourceNotification.getVerifier().toAttributeEquals(
+ anotherAvailableUser.getEntityFQ().getFullQualifiedName()));
assertNull(anotherAvailableUser.getNextStanza()); // no more stanzas
-
+
Stanza interestedResourceNotification = anotherInterestedUser.getNextStanza();
assertNotNull(interestedResourceNotification);
assertTrue(checkPresence(interestedResourceNotification, initiatingUser.getEntityFQ(), null));
- assertTrue(interestedResourceNotification.getVerifier().toAttributeEquals(initiatingUser.getEntity().getFullQualifiedName() + "/" + anotherInterestedUser.getBoundResourceId()));
+ assertTrue(interestedResourceNotification.getVerifier().toAttributeEquals(
+ initiatingUser.getEntity().getFullQualifiedName() + "/" + anotherInterestedUser.getBoundResourceId()));
assertNull(anotherInterestedUser.getNextStanza()); // no more stanzas
assertNull(anotherInterestedNotAvailUser.getNextStanza()); // no stanza at all
@@ -74,7 +80,7 @@ public class PresenceAvailInitialOutHand
//
// check other presences
//
-
+
assertNull(unrelatedUser.getNextStanza()); // does not sent pres to everybody arbitrarily
assertTrue(checkPresence(subscribed_FROM.getNextStanza(), initiatingUser.getEntityFQ(), null)); // pres sent to FROM contacts
assertNull(subscribed_FROM.getNextStanza()); // no second stanza sent to FROMs
@@ -91,16 +97,22 @@ public class PresenceAvailInitialOutHand
public void testInitialPresenceWithoutFrom() throws BindException, EntityFormatException, XMLSemanticError {
// after setUp(), there is more than one bound resource
// so, if leaving from == null, the handler will not know from which resource the presence really comes...
- XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(null, null, null, null, null, null).build());
+ XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(null, null, null,
+ null, null, null).build());
- Stanza stanza = handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
+ Stanza stanza = handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true,
+ sessionContext);
// ... and will give an error:
assertEquals("error", stanza.getAttribute("type").getValue());
- assertEquals(StanzaErrorCondition.UNKNOWN_SENDER.value(), stanza.getSingleInnerElementsNamed("error").getFirstInnerElement().getName());
+ assertEquals(StanzaErrorCondition.UNKNOWN_SENDER.value(), stanza.getSingleInnerElementsNamed("error")
+ .getFirstInnerElement().getName());
- sessionContext.getServerRuntimeContext().getResourceRegistry().unbindResource(anotherInterestedNotAvailUser.getBoundResourceId());
- sessionContext.getServerRuntimeContext().getResourceRegistry().unbindResource(anotherInterestedUser.getBoundResourceId());
- sessionContext.getServerRuntimeContext().getResourceRegistry().unbindResource(anotherAvailableUser.getBoundResourceId());
+ sessionContext.getServerRuntimeContext().getResourceRegistry().unbindResource(
+ anotherInterestedNotAvailUser.getBoundResourceId());
+ sessionContext.getServerRuntimeContext().getResourceRegistry().unbindResource(
+ anotherInterestedUser.getBoundResourceId());
+ sessionContext.getServerRuntimeContext().getResourceRegistry().unbindResource(
+ anotherAvailableUser.getBoundResourceId());
// 3 other resources got unbound, remaining one should now be unique
stanza = handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
assertNull(stanza); // no return, esp no error stanza - all the handling is done through relays
@@ -110,12 +122,13 @@ public class PresenceAvailInitialOutHand
assertNull(initiatingUser.getNextStanza()); // no second stanza
// now we run berserk :-) - when there is no resource remaining, from-resolution fails again, and we get the same error again
- boolean noRemainingBinds = sessionContext.getServerRuntimeContext().getResourceRegistry().unbindResource(initiatingUser.getBoundResourceId());
+ boolean noRemainingBinds = sessionContext.getServerRuntimeContext().getResourceRegistry().unbindResource(
+ initiatingUser.getBoundResourceId());
assertTrue(noRemainingBinds);
stanza = handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
assertEquals("error", stanza.getAttribute("type").getValue());
- assertEquals(StanzaErrorCondition.UNKNOWN_SENDER.value(), stanza.getSingleInnerElementsNamed("error").getFirstInnerElement().getName());
+ assertEquals(StanzaErrorCondition.UNKNOWN_SENDER.value(), stanza.getSingleInnerElementsNamed("error")
+ .getFirstInnerElement().getName());
}
-
}
Modified: mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailUpdateOutHandlerTestCase.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailUpdateOutHandlerTestCase.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailUpdateOutHandlerTestCase.java (original)
+++ mina/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailUpdateOutHandlerTestCase.java Sat Jun 26 20:39:54 2010
@@ -35,53 +35,60 @@ public class PresenceAvailUpdateOutHandl
protected PresenceHandler handler = new PresenceHandler();
public void testUpdatedPresence() throws BindException, EntityFormatException {
- StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext().getStanzaRelay();
+ StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext()
+ .getStanzaRelay();
// at first, initial presence
- XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), null, null, null, null, null).build());
+ XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
+ initiatingUser.getEntityFQ(), null, null, null, null, null).build());
handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
assertTrue(0 < receiverRelay.getCountDelivered());
resetRecordedStanzas(); // purge recorded
assertTrue(0 == receiverRelay.getCountDelivered());
-
+
// send update now
final String showValue = "chatty";
-
- XMPPCoreStanza updatePresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), null, null, null, showValue, null).build());
+
+ XMPPCoreStanza updatePresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
+ initiatingUser.getEntityFQ(), null, null, null, showValue, null).build());
handler.executeCore(updatePresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
// check resource state
assertEquals(ResourceState.AVAILABLE, getResourceState());
// 3 presence update broadcasts to same session + 2 presence to subscribers
- assertEquals(3+2, ((StanzaReceiverRelay) sessionContext.getServerRuntimeContext().getStanzaRelay()).getCountDelivered());
-
+ assertEquals(3 + 2, ((StanzaReceiverRelay) sessionContext.getServerRuntimeContext().getStanzaRelay())
+ .getCountDelivered());
+
//
// check presence broadcasts to resources of same session (self, interested & available)
//
-
+
Stanza initiatorNotification = initiatingUser.getNextStanza();
assertNotNull(initiatorNotification);
assertTrue(checkPresence(initiatorNotification, null, initiatingUser.getEntityFQ(), showValue));
- assertTrue(initiatorNotification.getVerifier().toAttributeEquals(initiatingUser.getEntityFQ().getFullQualifiedName()));
-
+ assertTrue(initiatorNotification.getVerifier().toAttributeEquals(
+ initiatingUser.getEntityFQ().getFullQualifiedName()));
+
Stanza availableResourceNotification = anotherAvailableUser.getNextStanza();
assertNotNull(availableResourceNotification);
assertTrue(checkPresence(availableResourceNotification, null, initiatingUser.getEntityFQ(), showValue));
- assertTrue(availableResourceNotification.getVerifier().toAttributeEquals(anotherAvailableUser.getEntityFQ().getFullQualifiedName()));
+ assertTrue(availableResourceNotification.getVerifier().toAttributeEquals(
+ anotherAvailableUser.getEntityFQ().getFullQualifiedName()));
assertNull(anotherAvailableUser.getNextStanza()); // no more stanzas
-
+
Stanza interestedResourceNotification = anotherInterestedUser.getNextStanza();
assertNotNull(interestedResourceNotification);
assertTrue(checkPresence(interestedResourceNotification, null, initiatingUser.getEntityFQ(), showValue));
- assertTrue(interestedResourceNotification.getVerifier().toAttributeEquals(initiatingUser.getEntity().getFullQualifiedName() + "/" + anotherInterestedUser.getBoundResourceId()));
+ assertTrue(interestedResourceNotification.getVerifier().toAttributeEquals(
+ initiatingUser.getEntity().getFullQualifiedName() + "/" + anotherInterestedUser.getBoundResourceId()));
assertNull(anotherInterestedUser.getNextStanza()); // no more stanzas
-
+
assertNull(anotherInterestedNotAvailUser.getNextStanza()); // no stanza at all
//
// check other presences
//
-
+
assertNull(unrelatedUser.getNextStanza()); // does not sent pres to everybody arbitrarily
assertTrue(checkPresence(subscribed_FROM.getNextStanza(), null, initiatingUser.getEntityFQ(), showValue)); // pres sent to FROM contacts
assertNull(subscribed_FROM.getNextStanza()); // no second stanza sent to FROMs