mina-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ber...@apache.org
Subject svn commit: r784414 - in /mina/sandbox/vysper/trunk/src: main/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/handler/ test/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/handler/
Date Sat, 13 Jun 2009 16:06:49 GMT
Author: berndf
Date: Sat Jun 13 16:06:49 2009
New Revision: 784414

URL: http://svn.apache.org/viewvc?rev=784414&view=rev
Log:
[vysper] patch and commit comment contributed by Michael Jakl. thanks.
implements the general JID malformed error for subscribe to node  (VYSPER-65)

Modified:
    mina/sandbox/vysper/trunk/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/handler/PubSubSubscribeHandler.java
    mina/sandbox/vysper/trunk/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/handler/PubSubSubscribeTestCase.java

Modified: mina/sandbox/vysper/trunk/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/handler/PubSubSubscribeHandler.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/handler/PubSubSubscribeHandler.java?rev=784414&r1=784413&r2=784414&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/handler/PubSubSubscribeHandler.java
(original)
+++ mina/sandbox/vysper/trunk/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/handler/PubSubSubscribeHandler.java
Sat Jun 13 16:06:49 2009
@@ -71,8 +71,13 @@
 		try {
 			subJID = EntityImpl.parse(strSubJID);
 		} catch (EntityFormatException e) {
-			// TODO return error stanza... (general error)
-			return null;
+			StanzaBuilder error = StanzaBuilder.createIQStanza(receiver, sender, IQStanzaType.ERROR,
iqStanzaID);
+			error.startInnerElement("error");
+			error.addAttribute("type", "modify");
+			error.startInnerElement("jid-malformed", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STANZAS);
+			error.endInnerElement(); // jid-malformed
+			error.endInnerElement(); // error
+			return error.getFinalStanza();
 		}
 		
 		if(!sender.getBareJID().equals(subJID.getBareJID())) {

Modified: mina/sandbox/vysper/trunk/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/handler/PubSubSubscribeTestCase.java
URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/handler/PubSubSubscribeTestCase.java?rev=784414&r1=784413&r2=784414&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/handler/PubSubSubscribeTestCase.java
(original)
+++ mina/sandbox/vysper/trunk/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/handler/PubSubSubscribeTestCase.java
Sat Jun 13 16:06:49 2009
@@ -82,7 +82,7 @@
 		XMLElement error = response.getFirstInnerElement();
 		assertEquals("error", error.getName());
 		assertEquals("modify", error.getAttributeValue("type"));
-		
+
 		List<XMLElement> errorContent = error.getInnerElements(); 
 		assertEquals(2, errorContent.size());
 		assertEquals("bad-request", errorContent.get(0).getName());
@@ -92,6 +92,28 @@
 		assertEquals(NamespaceURIs.XEP0060_PUBSUB_ERRORS, errorContent.get(1).getNamespace());
 	}
 	
+	public void testSubscribeJIDMalformed() {
+		DefaultSubscribeStanzaGenerator sg = new DefaultSubscribeStanzaGenerator();
+		sg.overrideSubscriberJID("@@");
+		
+		ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsub, "id123"), true);
+		assertTrue(result.hasResponse());
+		IQStanza response = new IQStanza(result.getResponseStanza());
+		assertEquals(IQStanzaType.ERROR.value(),response.getType());
+		assertFalse(node.isSubscribed(client));
+		
+		assertEquals("id123", response.getAttributeValue("id")); // IDs must match
+		
+		XMLElement error = response.getFirstInnerElement();
+		assertEquals("error", error.getName());
+		assertEquals("modify", error.getAttributeValue("type"));
+		
+		List<XMLElement> errorContent = error.getInnerElements(); 
+		assertEquals(1, errorContent.size());
+		assertEquals("jid-malformed", errorContent.get(0).getName());
+		assertEquals(NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STANZAS, errorContent.get(0).getNamespace());
+	}
+	
 	public void testSubscribeNoSuchNode() throws Exception {
 		DefaultSubscribeStanzaGenerator sg = new DefaultSubscribeStanzaGenerator();
 		Entity pubsubWrongNode = EntityImpl.parse("pubsub.vysper.org/doesnotexist");



Mime
View raw message