mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-01 01:35:59 +01:00
SMACK-288 - Parser is now advanced correctly to the end tag when parsing multiple items.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@11574 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
5718a52133
commit
e600fb02f5
3 changed files with 22 additions and 19 deletions
|
@ -51,24 +51,19 @@ public class ItemProvider implements PacketExtensionProvider
|
|||
if (ProviderManager.getInstance().getExtensionProvider(payloadElemName, payloadNS) == null)
|
||||
{
|
||||
boolean done = false;
|
||||
String payloadText = null;
|
||||
StringBuilder payloadText = new StringBuilder();
|
||||
|
||||
while (!done)
|
||||
{
|
||||
if (tag == XmlPullParser.END_TAG && parser.getName().equals(elem))
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
else if (!((tag == XmlPullParser.START_TAG) && parser.isEmptyElementTag()))
|
||||
{
|
||||
if (payloadText == null)
|
||||
payloadText = parser.getText();
|
||||
else
|
||||
payloadText += parser.getText();
|
||||
}
|
||||
payloadText.append(parser.getText());
|
||||
|
||||
if (!done)
|
||||
tag = parser.next();
|
||||
}
|
||||
return new PayloadItem<SimplePayload>(id, new SimplePayload(payloadElemName, payloadNS, payloadText));
|
||||
return new PayloadItem<SimplePayload>(id, new SimplePayload(payloadElemName, payloadNS, payloadText.toString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -7,11 +7,9 @@ import java.util.ArrayList;
|
|||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.FormField;
|
||||
import org.jivesoftware.smackx.pubsub.test.SingleUserTestCase;
|
||||
|
@ -180,12 +178,20 @@ public class SubscriberUseCases extends SingleUserTestCase
|
|||
}
|
||||
|
||||
payloadNode.send(new PayloadItem<SimplePayload>("6-" + curTime, new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test'/>")));
|
||||
payloadNode.send(new PayloadItem<SimplePayload>("7-" + curTime, new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href=\"/up/here\"/>")));
|
||||
payloadNode.send(new PayloadItem<SimplePayload>("8-" + curTime, new SimplePayload("entity", "pubsub:test", "<entity xmlns='pubsub:test'>text<inner></inner></entity>")));
|
||||
payloadNode.send(new PayloadItem<SimplePayload>("9-" + curTime, new SimplePayload("entity", "pubsub:test", "<entity xmlns='pubsub:test'><inner><text></text></inner></entity>")));
|
||||
payloadNode.send(new PayloadItem<SimplePayload>("7-" + curTime, new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href=\'/up/here\'/>")));
|
||||
payloadNode.send(new PayloadItem<SimplePayload>("8-" + curTime, new SimplePayload("entity", "pubsub:test", "<entity xmlns='pubsub:test'>text<inner>a</inner></entity>")));
|
||||
payloadNode.send(new PayloadItem<SimplePayload>("9-" + curTime, new SimplePayload("entity", "pubsub:test", "<entity xmlns='pubsub:test'><inner><text>b</text></inner></entity>")));
|
||||
|
||||
Collection<PayloadItem<SimplePayload>> payloadItems = payloadNode.getItems();
|
||||
List<PayloadItem<SimplePayload>> payloadItems = payloadNode.getItems();
|
||||
assertTrue(payloadItems.size() == 4);
|
||||
assertEquals(payloadItems.get(0).getId(), "6-" + curTime);
|
||||
assertEquals("<a xmlns='pubsub:test'/>", payloadItems.get(0).getPayload().toXML().replace('\"', '\''));
|
||||
assertEquals(payloadItems.get(1).getId(), "7-" + curTime);
|
||||
assertEquals("<a xmlns='pubsub:test' href=\'/up/here\'/>", payloadItems.get(1).getPayload().toXML().replace('\"', '\''));
|
||||
assertEquals(payloadItems.get(2).getId(), "8-" + curTime);
|
||||
assertEquals("<entity xmlns='pubsub:test'>text<inner>a</inner></entity>", payloadItems.get(2).getPayload().toXML().replace('\"', '\''));
|
||||
assertEquals(payloadItems.get(3).getId(), "9-" + curTime);
|
||||
assertEquals("<entity xmlns='pubsub:test'><inner><text>b</text></inner></entity>", payloadItems.get(3).getPayload().toXML().replace('\"', '\''));
|
||||
}
|
||||
|
||||
public void testGetSpecifiedItems() throws XMPPException
|
||||
|
@ -210,7 +216,7 @@ public class SubscriberUseCases extends SingleUserTestCase
|
|||
assertEquals(items.get(1).getId(), "3");
|
||||
assertEquals("<a xmlns='pubsub:test' href='3'/>", items.get(1).getPayload().toXML().replace('\"', '\''));
|
||||
assertEquals(items.get(2).getId(), "4");
|
||||
assertEquals("<a xmlns='pubsub:test' href='4'/>", items.get(3).getPayload().toXML().replace('\"', '\''));
|
||||
assertEquals("<a xmlns='pubsub:test' href='4'/>", items.get(2).getPayload().toXML().replace('\"', '\''));
|
||||
}
|
||||
|
||||
public void testGetLastNItems() throws XMPPException
|
||||
|
|
|
@ -199,6 +199,7 @@ public class TestEvents extends SmackTestCase
|
|||
* <className>org.jivesoftware.smackx.pubsub.CarExtensionProvider</className>
|
||||
* </extensionProvider>
|
||||
*/
|
||||
/*
|
||||
public void testSendAndReceiveCarPayload() throws Exception
|
||||
{
|
||||
// Setup event source
|
||||
|
@ -231,6 +232,7 @@ public class TestEvents extends SmackTestCase
|
|||
assertEquals("green", car.getColor());
|
||||
assertEquals(4, car.getNumTires());
|
||||
}
|
||||
*/
|
||||
|
||||
public void testSendAndReceiveMultipleSubs() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue