diff options
17 files changed, 683 insertions, 21 deletions
diff --git a/src/com/isode/stroke/base/NotNull.java b/src/com/isode/stroke/base/NotNull.java new file mode 100644 index 0000000..f9bc87a --- /dev/null +++ b/src/com/isode/stroke/base/NotNull.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2012, Isode Limited, London, England. + * All rights reserved. + */ + +package com.isode.stroke.base; + +/** + * Helper to check for nulls. + */ +public class NotNull { + + /** + * Throws a NullPointerException if null. + * @param o Object to check for non-nullness + */ + public static void exceptIfNull(Object o) { + if (o == null) { + throw new NullPointerException(); + } + } + + /** + * Throws a NullPointerException if null. + * @param o Object to check for non-nullness + * @param name Variable name to include in error. + */ + public static void exceptIfNull(Object o, String name) { + if (name == null) { + throw new NullPointerException("Variable name passed to exceptIfNull must not be null"); + } + if (o == null) { + throw new NullPointerException(name + " must not be null"); + } + } +} diff --git a/src/com/isode/stroke/elements/DiscoInfo.java b/src/com/isode/stroke/elements/DiscoInfo.java new file mode 100644 index 0000000..f30a682 --- /dev/null +++ b/src/com/isode/stroke/elements/DiscoInfo.java @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2010, Remko Tron�on. + * All rights reserved. + */ +/* + * Copyright (c) 2012, Isode Limited, London, England. + * All rights reserved. + */ +package com.isode.stroke.elements; + +import com.isode.stroke.base.NotNull; +import java.util.ArrayList; +import java.util.List; + +/** + * disco#info from XEP-0030. + */ +public class DiscoInfo extends Payload { + + public static final String ChatStatesFeature = "http://jabber.org/protocol/chatstates"; + public static final String SecurityLabelsFeature = "urn:xmpp:sec-label:0"; + public static final String SecurityLabelsCatalogFeature = "urn:xmpp:sec-label:catalog:2"; + public static final String JabberSearchFeature = "jabber:iq:search"; + public static final String CommandsFeature = "http://jabber.org/protocol/commands"; + public static final String MessageCorrectionFeature = "urn:xmpp:message-correct:0"; + public static final String JingleFeature = "urn:xmpp:jingle:1"; + public static final String JingleFTFeature = "urn:xmpp:jingle:apps:file-transfer:3"; + public static final String JingleTransportsIBBFeature = "urn:xmpp:jingle:transports:ibb:1"; + public static final String JingleTransportsS5BFeature = "urn:xmpp:jingle:transports:s5b:1"; + public static final String Bytestream = "http://jabber.org/protocol/bytestreams"; + public static final String MessageDeliveryReceiptsFeature = "urn:xmpp:receipts"; + + public static class Identity implements Comparable<Identity> { + + /** + * Identity(name, "client", "pc", ""); + */ + public Identity(String name) { + this(name, "client"); + } + + /** + * Identity(name, category, "pc, ""); + */ + public Identity(String name, String category) { + this(name, category, "pc"); + } + + /** + * Identity(name, category, type, ""); + */ + public Identity(String name, String category, String type) { + this(name, category, type, ""); + } + + /** + * + * @param name Identity name, notnull. + * @param category Identity category, notnull. + * @param type Identity type, notnull. + * @param lang Identity language, notnull. + */ + public Identity(String name, String category, String type, String lang) { + NotNull.exceptIfNull(name, "name"); + NotNull.exceptIfNull(category, "category"); + NotNull.exceptIfNull(type, "type"); + NotNull.exceptIfNull(lang, "lang"); + name_ = name; + category_ = category; + type_ = type; + lang_ = lang; + } + + /** + * + * @return Not null. + */ + public String getCategory() { + return category_; + } + + /** + * + * @return Not null. + */ + public String getType() { + return type_; + } + + /** + * + * @return Not null. + */ + public String getLanguage() { + return lang_; + } + + /** + * + * @return Not null. + */ + public String getName() { + return name_; + } + + // Sorted according to XEP-115 rules + public int compareTo(Identity other) { + if (other == null) { + return -1; + } + if (category_.equals(other.category_)) { + if (type_.equals(other.type_)) { + if (lang_.equals(other.lang_)) { + return name_.compareTo(other.name_); + } else { + return lang_.compareTo(other.lang_); + } + } else { + return type_.compareTo(other.type_); + } + } else { + return category_.compareTo(other.category_); + } + } + + private final String name_; + private final String category_; + private final String type_; + private final String lang_; + + + } + + public DiscoInfo() { + } + + /** + * + * @return Node, notnull. + */ + public String getNode() { + return node_; + } + + /** + * + * @param node Notnull. + */ + public void setNode(String node) { + NotNull.exceptIfNull(node, "node"); + node_ = node; + } + + /** + * + * @return Copy of the list of identities. Non-null. + */ + public List<Identity> getIdentities() { + return new ArrayList(identities_); + } + + /** + * + * @param identity Non-null. + */ + public void addIdentity(Identity identity) { + NotNull.exceptIfNull(identity, "identity"); + identities_.add(identity); + } + + /** + * + * @return Copy of the list of features. Nonnull. + */ + public List<String> getFeatures() { + return new ArrayList(features_); + } + + /** + * + * @param feature Non-null. + */ + public void addFeature(String feature) { + NotNull.exceptIfNull(feature, "feature"); + features_.add(feature); + } + + public boolean hasFeature(String feature) { + return features_.contains(feature); + } + + /** + * + * @param form Non-null. + */ + public void addExtension(Form form) { + NotNull.exceptIfNull(form, "form"); + extensions_.add(form); + } + + /** + * + * @return A copy of the list, where the contents are references to the same objects. + */ + public List<Form> getExtensions() { + return new ArrayList(extensions_); + } + private String node_ = ""; + private final List<Identity> identities_ = new ArrayList<Identity>(); + private final List<String> features_ = new ArrayList<String>(); + private final List<Form> extensions_ = new ArrayList<Form>(); +} diff --git a/src/com/isode/stroke/elements/DiscoItems.java b/src/com/isode/stroke/elements/DiscoItems.java new file mode 100644 index 0000000..ac92cb3 --- /dev/null +++ b/src/com/isode/stroke/elements/DiscoItems.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2010, Kevin Smith. + * All rights reserved. + */ +/* + * Copyright (c) 2012, Isode Limited, London, England. + * All rights reserved. + */ +package com.isode.stroke.elements; + +import com.isode.stroke.base.NotNull; +import com.isode.stroke.jid.JID; +import java.util.ArrayList; +import java.util.List; + +/** + * Service discovery disco#items from XEP-0030. + */ +public class DiscoItems extends Payload { + + /** + * A single result item. + */ + public static class Item { + + /** + * @param name Item name, not null. + * @param jid Item JID, not null. + */ + public Item(String name, JID jid) { + this(name, jid, ""); + } + + /** + * @param name Item name, not null. + * @param jid Item JID, not null. + * @param node Item node, not null. + */ + public Item(String name, JID jid, String node) { + NotNull.exceptIfNull(name, "name"); + NotNull.exceptIfNull(jid, "jid"); + NotNull.exceptIfNull(node, "node"); + name_ = name; + jid_ = jid; + node_ = node; + } + + /** + * + * @return Item name, not null. + */ + public String getName() { + return name_; + } + + /** + * + * @return Item node, not null. + */ + public String getNode() { + return node_; + } + + /** + * + * @return Item JID, not null. + */ + public JID getJID() { + return jid_; + } + private final String name_; + private final JID jid_; + private final String node_; + }; + + public DiscoItems() { + } + + public String getNode() { + return node_; + } + + public void setNode(String node) { + node_ = node; + } + + public List<Item> getItems() { + return new ArrayList(items_); + } + + public void addItem(Item item) { + items_.add(item); + } + private String node_; + private final List<Item> items_ = new ArrayList<Item>(); +} + diff --git a/src/com/isode/stroke/eventloop/SimpleEventLoop.java b/src/com/isode/stroke/eventloop/SimpleEventLoop.java index 003fc98..423321e 100644 --- a/src/com/isode/stroke/eventloop/SimpleEventLoop.java +++ b/src/com/isode/stroke/eventloop/SimpleEventLoop.java @@ -12,6 +12,6 @@ package com.isode.stroke.eventloop; public class SimpleEventLoop extends EventLoop { @Override protected void post(Event event) { - event.callback.run(); + handleEvent(event); } } diff --git a/src/com/isode/stroke/examples/gui/StrokeGUI.java b/src/com/isode/stroke/examples/gui/StrokeGUI.java index 09f7936..0422abb 100644 --- a/src/com/isode/stroke/examples/gui/StrokeGUI.java +++ b/src/com/isode/stroke/examples/gui/StrokeGUI.java @@ -151,7 +151,7 @@ public class StrokeGUI extends javax.swing.JFrame { protected void post(final Event event) { EventQueue.invokeLater(new Runnable() { public void run() { - event.callback.run(); + handleEvent(event); } }); } diff --git a/src/com/isode/stroke/parser/Attribute.java b/src/com/isode/stroke/parser/Attribute.java new file mode 100644 index 0000000..d624550 --- /dev/null +++ b/src/com/isode/stroke/parser/Attribute.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2012, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2010, Remko Tronçon. + * All rights reserved. + */ +package com.isode.stroke.parser; + +/* + * Internal parsing class. + */ +public class Attribute { + + public Attribute(String name, String ns) { + this.name = name; + this.ns = ns; + } + + public String getName() { + return name; + } + + public String getNamespace() { + return ns; + } + + @Override + public boolean equals(Object other) { + return other != null + && other instanceof Attribute + && name.equals(((Attribute) other).getName()) + && ns.equals(((Attribute) other).getNamespace()); + } + + @Override + public int hashCode() { + int hash = 3; + hash = 19 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 19 * hash + (this.ns != null ? this.ns.hashCode() : 0); + return hash; + } + private final String name; + private final String ns; +} diff --git a/src/com/isode/stroke/parser/AttributeMap.java b/src/com/isode/stroke/parser/AttributeMap.java index fb4aa68..0e43785 100644 --- a/src/com/isode/stroke/parser/AttributeMap.java +++ b/src/com/isode/stroke/parser/AttributeMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Isode Limited, London, England. + * Copyright (c) 2010-2012, Isode Limited, London, England. * All rights reserved. */ /* @@ -8,26 +8,103 @@ */ package com.isode.stroke.parser; -import java.util.HashMap; +import com.isode.stroke.base.NotNull; +import java.util.ArrayList; +import java.util.List; /** * XML element attributes. */ -public class AttributeMap extends HashMap<String, String> { +public class AttributeMap { + + /** + * Internal class. + */ + public class Entry { + + public Entry(Attribute attribute, String value) { + NotNull.exceptIfNull(attribute, "attribute"); + NotNull.exceptIfNull(value, "value"); + this.attribute = attribute; + this.value = value; + } + + public Attribute getAttribute() { + return attribute; + } + + public String getValue() { + return value; + } + private final Attribute attribute; + private final String value; + }; + + public AttributeMap() { + } + + /** Not null */ public String getAttribute(String attribute) { - return this.containsKey(attribute) ? this.get(attribute) : ""; + NotNull.exceptIfNull(attribute, "attribute"); + return getAttribute(attribute, ""); } - public String getAttributeValue(String attribute) { - return this.containsKey(attribute) ? this.get(attribute) : null; + /** Not null*/ + public String getAttribute(String attribute, String ns) { + String value = getInternal(attribute, ns); + return value != null ? value : ""; } + /** + * + * @param attribute attribute name. + * @return boolean value, defaulting to false if missing. + */ public boolean getBoolAttribute(String attribute) { return getBoolAttribute(attribute, false); } public boolean getBoolAttribute(String attribute, boolean defaultValue) { - String value = getAttribute(attribute); + String value = getInternal(attribute, ""); + if (value == null) { + return defaultValue; + } return "true".equals(value) || "1".equals(value); } + + /** @return Attribute or null if missing.*/ + public String getAttributeValue(String attribute) { + return getInternal(attribute, ""); + } + + /** + * + * @param name Attribute name (non-null). + * @param ns Attribute namespace (non-null). + * @param value Attribute value (non-null). + */ + public void addAttribute(String name, String ns, String value) { + NotNull.exceptIfNull(name, "name"); + NotNull.exceptIfNull(ns, "ns"); + NotNull.exceptIfNull(value, "value"); + attributes.add(new Entry(new Attribute(name, ns), value)); + } + + /** + * Internal method (used for unit tests). + */ + public List<Entry> getEntries() { + return new ArrayList(attributes); + } + + private String getInternal(String name, String ns) { + Attribute attribute = new Attribute(name, ns); + for (Entry entry : attributes) { + if (entry.getAttribute().equals(attribute)) { + return entry.value; + } + } + return null; + } + private final List<Entry> attributes = new ArrayList<Entry>(); } diff --git a/src/com/isode/stroke/parser/GenericPayloadParser.java b/src/com/isode/stroke/parser/GenericPayloadParser.java index 7642d91..4901537 100644 --- a/src/com/isode/stroke/parser/GenericPayloadParser.java +++ b/src/com/isode/stroke/parser/GenericPayloadParser.java @@ -22,7 +22,7 @@ public abstract class GenericPayloadParser <T extends Payload> implements Payloa return payload_; } - protected T getPayloadInternal() { + public T getPayloadInternal() { return payload_; } } diff --git a/src/com/isode/stroke/parser/PullXMLParser.java b/src/com/isode/stroke/parser/PullXMLParser.java index 8b42afe..845dfbc 100644 --- a/src/com/isode/stroke/parser/PullXMLParser.java +++ b/src/com/isode/stroke/parser/PullXMLParser.java @@ -78,7 +78,7 @@ class PullXMLParser extends XMLParser { if (eventType == XmlPullParser.START_TAG) { AttributeMap map = new AttributeMap(); for (int i = 0; i < parser_.getAttributeCount(); i++) { - map.put(parser_.getAttributeName(i), parser_.getAttributeValue(i)); + map.addAttribute(parser_.getAttributeName(i), parser_.getAttributeNamespace(i), parser_.getAttributeValue(i)); } addEvent(new Event(parser_.getName(), parser_.getNamespace(), map)); bump(); diff --git a/src/com/isode/stroke/parser/SerializingParser.java b/src/com/isode/stroke/parser/SerializingParser.java index d18b912..1b89c68 100644 --- a/src/com/isode/stroke/parser/SerializingParser.java +++ b/src/com/isode/stroke/parser/SerializingParser.java @@ -19,8 +19,9 @@ public class SerializingParser { public void handleStartElement(String tag, String ns, AttributeMap attributes) { XMLElement element = new XMLElement(tag, ns); - for (String name : attributes.keySet()) { - element.setAttribute(name, attributes.get(name)); + //FIXME: Ignoring attribute namespace + for (AttributeMap.Entry e : attributes.getEntries()) { + element.setAttribute(e.getAttribute().getName(), e.getValue()); } if (elementStack_.isEmpty()) { diff --git a/src/com/isode/stroke/parser/payloadparsers/DiscoInfoParser.java b/src/com/isode/stroke/parser/payloadparsers/DiscoInfoParser.java new file mode 100644 index 0000000..445a6de --- /dev/null +++ b/src/com/isode/stroke/parser/payloadparsers/DiscoInfoParser.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2012, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2010, Remko Tronçon. + * All rights reserved. + */ +package com.isode.stroke.parser.payloadparsers; + +import com.isode.stroke.elements.DiscoInfo; +import com.isode.stroke.parser.AttributeMap; +import com.isode.stroke.parser.GenericPayloadParser; + + +class DiscoInfoParser extends GenericPayloadParser<DiscoInfo> { + public DiscoInfoParser() { + super(new DiscoInfo()); + } + + public void handleStartElement(String element, String ns, AttributeMap attributes) { + if (level_ == PayloadLevel) { + if (element .equals("identity")) { + getPayloadInternal().addIdentity(new DiscoInfo.Identity(attributes.getAttribute("name"), attributes.getAttribute("category"), attributes.getAttribute("type"), attributes.getAttribute("lang", "http://www.w3.org/XML/1998/namespace"))); + } + else if (element.equals("feature")) { + getPayloadInternal().addFeature(attributes.getAttribute("var")); + } + else if (element.equals("x") && ns.equals("jabber:x:data")) { + assert(formParser_ == null); + formParser_ = new FormParser(); + } + } + if (formParser_ != null) { + formParser_.handleStartElement(element, ns, attributes); + } + ++level_; + } + + public void handleEndElement(String element, String ns) { + --level_; + if (formParser_ != null) { + formParser_.handleEndElement(element, ns); + } + if (level_ == PayloadLevel && formParser_ != null) { + getPayloadInternal().addExtension(formParser_.getPayloadInternal()); + formParser_ = null; + } + } + + public void handleCharacterData(String data) { + if (formParser_ != null) { + formParser_.handleCharacterData(data); + } + } + + private static final int TopLevel = 0; + private static final int PayloadLevel = 1; + private int level_ = 0; + private FormParser formParser_ = null; +} diff --git a/src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java b/src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java new file mode 100644 index 0000000..caf75cf --- /dev/null +++ b/src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2012, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2010, Kevin Smith. + * All rights reserved. + */ +package com.isode.stroke.parser.payloadparsers; + +import com.isode.stroke.elements.DiscoItems; +import com.isode.stroke.elements.DiscoItems.Item; +import com.isode.stroke.jid.JID; +import com.isode.stroke.parser.AttributeMap; +import com.isode.stroke.parser.GenericPayloadParser; + +class DiscoItemsParser extends GenericPayloadParser<DiscoItems> { + public DiscoItemsParser() { + super(new DiscoItems()); + } + + public void handleStartElement(String element, String ns, AttributeMap attributes) { + if (level_ == PayloadLevel) { + if (element.equals("item")) { + Item item = new Item(attributes.getAttribute("name"), new JID(attributes.getAttribute("jid")), attributes.getAttribute("node")); + getPayloadInternal().addItem(item); + } + } + ++level_; + } + + public void handleEndElement(String element, String ns) { + --level_; + } + + public void handleCharacterData(String data) { + } + private static final int TopLevel = 0; + private static final int PayloadLevel = 1; + private int level_ = TopLevel; +} diff --git a/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java b/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java index 6114626..7273cf2 100644 --- a/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java +++ b/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java @@ -27,8 +27,8 @@ public class FullPayloadParserFactoryCollection extends PayloadParserFactoryColl addFactory(new SoftwareVersionParserFactory()); //addFactory(new StorageParserFactory()); addFactory(new RosterParserFactory()); - //addFactory(new DiscoInfoParserFactory()); - //addFactory(new DiscoItemsParserFactory()); + addFactory(new GenericPayloadParserFactory<DiscoInfoParser>("query", "http://jabber.org/protocol/disco#info", DiscoInfoParser.class)); + addFactory(new GenericPayloadParserFactory<DiscoItemsParser>("query", "http://jabber.org/protocol/disco#items", DiscoItemsParser.class)); //addFactory(new CapsInfoParserFactory()); addFactory(new ResourceBindParserFactory()); addFactory(new StartSessionParserFactory()); diff --git a/src/com/isode/stroke/serializer/payloadserializers/DiscoInfoSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/DiscoInfoSerializer.java new file mode 100644 index 0000000..563eb53 --- /dev/null +++ b/src/com/isode/stroke/serializer/payloadserializers/DiscoInfoSerializer.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2012, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2010, Remko Tronçon. + * All rights reserved. + */ + +package com.isode.stroke.serializer.payloadserializers; + +import com.isode.stroke.elements.DiscoInfo; +import com.isode.stroke.elements.Form; +import com.isode.stroke.serializer.GenericPayloadSerializer; +import com.isode.stroke.serializer.xml.XMLElement; +import com.isode.stroke.serializer.xml.XMLRawTextNode; + +class DiscoInfoSerializer extends GenericPayloadSerializer<DiscoInfo>{ + + public DiscoInfoSerializer() { + super(DiscoInfo.class); + } + + @Override + protected String serializePayload(DiscoInfo discoInfo) { + XMLElement queryElement = new XMLElement("query", "http://jabber.org/protocol/disco#info"); + if (!discoInfo.getNode().isEmpty()) { + queryElement.setAttribute("node", discoInfo.getNode()); + } + for (DiscoInfo.Identity identity : discoInfo.getIdentities()) { + XMLElement identityElement = new XMLElement("identity"); + if (!identity.getLanguage().isEmpty()) { + identityElement.setAttribute("xml:lang", identity.getLanguage()); + } + identityElement.setAttribute("category", identity.getCategory()); + identityElement.setAttribute("name", identity.getName()); + identityElement.setAttribute("type", identity.getType()); + queryElement.addNode(identityElement); + } + for (String feature : discoInfo.getFeatures()) { + XMLElement featureElement = new XMLElement("feature"); + featureElement.setAttribute("var", feature); + queryElement.addNode(featureElement); + } + for (Form extension : discoInfo.getExtensions()) { + queryElement.addNode(new XMLRawTextNode(new FormSerializer().serialize(extension))); + } + return queryElement.serialize(); + } + +} diff --git a/src/com/isode/stroke/serializer/payloadserializers/DiscoItemsSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/DiscoItemsSerializer.java new file mode 100644 index 0000000..8d89d98 --- /dev/null +++ b/src/com/isode/stroke/serializer/payloadserializers/DiscoItemsSerializer.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2012, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2010, Kevin Smith. + * All rights reserved. + */ + +package com.isode.stroke.serializer.payloadserializers; + +import com.isode.stroke.elements.DiscoItems; +import com.isode.stroke.serializer.GenericPayloadSerializer; +import com.isode.stroke.serializer.xml.XMLElement; + +class DiscoItemsSerializer extends GenericPayloadSerializer<DiscoItems> { + + public DiscoItemsSerializer() { + super(DiscoItems.class); + } + + @Override + protected String serializePayload(DiscoItems discoItems) { + XMLElement queryElement = new XMLElement("query", "http://jabber.org/protocol/disco#items"); + if (!discoItems.getNode().isEmpty()) { + queryElement.setAttribute("node", discoItems.getNode()); + } + for (DiscoItems.Item item : discoItems.getItems()) { + XMLElement itemElement = new XMLElement("item"); + itemElement.setAttribute("name", item.getName()); + itemElement.setAttribute("jid", item.getJID().toString()); + if (!item.getNode().isEmpty()) { + itemElement.setAttribute("node", item.getNode()); + } + queryElement.addNode(itemElement); + } + return queryElement.serialize(); + } + +} diff --git a/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java b/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java index f43a47e..4051d9b 100644 --- a/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java +++ b/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java @@ -27,8 +27,8 @@ public class FullPayloadSerializerCollection extends PayloadSerializerCollection addSerializer(new SoftwareVersionSerializer()); //addSerializer(new StatusSerializer()); //addSerializer(new StatusShowSerializer()); - //addSerializer(new DiscoInfoSerializer()); - //addSerializer(new DiscoItemsSerializer()); + addSerializer(new DiscoInfoSerializer()); + addSerializer(new DiscoItemsSerializer()); //addSerializer(new CapsInfoSerializer()); addSerializer(new ResourceBindSerializer()); addSerializer(new StartSessionSerializer()); diff --git a/test/com/isode/stroke/parser/XMLParserTest.java b/test/com/isode/stroke/parser/XMLParserTest.java index 69ed0e1..e3f054b 100644 --- a/test/com/isode/stroke/parser/XMLParserTest.java +++ b/test/com/isode/stroke/parser/XMLParserTest.java @@ -73,13 +73,13 @@ public class XMLParserTest { assertEquals(Client.Type.StartElement, client_.events.get(0).type); assertEquals("iq", client_.events.get(0).data); - assertEquals(1, client_.events.get(0).attributes.size()); - assertEquals("get", client_.events.get(0).attributes.get("type")); + assertEquals(1, client_.events.get(0).attributes.getEntries().size()); + assertEquals("get", client_.events.get(0).attributes.getAttribute("type")); assertEquals("", client_.events.get(0).ns); assertEquals(Client.Type.StartElement, client_.events.get(1).type); assertEquals("query", client_.events.get(1).data); - assertEquals(0, client_.events.get(1).attributes.size()); + assertEquals(0, client_.events.get(1).attributes.getEntries().size()); assertEquals("jabber:iq:version", client_.events.get(1).ns); assertEquals(Client.Type.EndElement, client_.events.get(2).type); @@ -104,7 +104,7 @@ public class XMLParserTest { assertEquals(Client.Type.StartElement, client_.events.get(0).type); assertEquals("query", client_.events.get(0).data); - assertEquals(0, client_.events.get(0).attributes.size()); + assertEquals(0, client_.events.get(0).attributes.getEntries().size()); assertEquals("jabber:iq:version", client_.events.get(0).ns); assertEquals(Client.Type.StartElement, client_.events.get(1).type); |