mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-29 15:32:06 +01:00
Treat <body/> just like all other extension elements in Message
This turned out to be a rather large change.
This commit is contained in:
parent
cb9a11b74e
commit
a9e45475ab
39 changed files with 261 additions and 219 deletions
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.jivesoftware.smack.util.Objects;
|
import org.jivesoftware.smack.util.Objects;
|
||||||
|
@ -128,7 +129,7 @@ public abstract class IQ extends Stanza {
|
||||||
public final XmlStringBuilder toXML(String enclosingNamespace) {
|
public final XmlStringBuilder toXML(String enclosingNamespace) {
|
||||||
XmlStringBuilder buf = new XmlStringBuilder(enclosingNamespace);
|
XmlStringBuilder buf = new XmlStringBuilder(enclosingNamespace);
|
||||||
buf.halfOpenElement(IQ_ELEMENT);
|
buf.halfOpenElement(IQ_ELEMENT);
|
||||||
addCommonAttributes(buf);
|
addCommonAttributes(buf, enclosingNamespace);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
buf.attribute("type", "get");
|
buf.attribute("type", "get");
|
||||||
}
|
}
|
||||||
|
@ -158,9 +159,10 @@ public abstract class IQ extends Stanza {
|
||||||
IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this));
|
IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this));
|
||||||
if (iqChildElement != null) {
|
if (iqChildElement != null) {
|
||||||
xml.append(iqChildElement);
|
xml.append(iqChildElement);
|
||||||
XmlStringBuilder extensionsXml = getExtensionsXML();
|
|
||||||
|
List<ExtensionElement> extensionsXml = getExtensions();
|
||||||
if (iqChildElement.isEmptyElement) {
|
if (iqChildElement.isEmptyElement) {
|
||||||
if (extensionsXml.length() == 0) {
|
if (extensionsXml.isEmpty()) {
|
||||||
xml.closeEmptyElement();
|
xml.closeEmptyElement();
|
||||||
return xml;
|
return xml;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -66,7 +66,6 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
private String thread = null;
|
private String thread = null;
|
||||||
|
|
||||||
private final Set<Subject> subjects = new HashSet<Subject>();
|
private final Set<Subject> subjects = new HashSet<Subject>();
|
||||||
private final Set<Body> bodies = new HashSet<Body>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new, "normal" message.
|
* Creates a new, "normal" message.
|
||||||
|
@ -142,7 +141,6 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
this.type = other.type;
|
this.type = other.type;
|
||||||
this.thread = other.thread;
|
this.thread = other.thread;
|
||||||
this.subjects.addAll(other.subjects);
|
this.subjects.addAll(other.subjects);
|
||||||
this.bodies.addAll(other.bodies);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,7 +195,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
private Subject getMessageSubject(String language) {
|
private Subject getMessageSubject(String language) {
|
||||||
language = determineLanguage(language);
|
language = determineLanguage(language);
|
||||||
for (Subject subject : subjects) {
|
for (Subject subject : subjects) {
|
||||||
if (language.equals(subject.language)) {
|
if (Objects.equals(language, subject.language)) {
|
||||||
return subject;
|
return subject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +294,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
* @return the body of the message.
|
* @return the body of the message.
|
||||||
*/
|
*/
|
||||||
public String getBody() {
|
public String getBody() {
|
||||||
return getBody(null);
|
return getBody(language);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -331,7 +329,13 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
* @since 3.0.2
|
* @since 3.0.2
|
||||||
*/
|
*/
|
||||||
public Set<Body> getBodies() {
|
public Set<Body> getBodies() {
|
||||||
return Collections.unmodifiableSet(bodies);
|
List<ExtensionElement> bodiesList = getExtensions(Body.ELEMENT, Body.NAMESPACE);
|
||||||
|
Set<Body> resultSet = new HashSet<>(bodiesList.size());
|
||||||
|
for (ExtensionElement extensionElement : bodiesList) {
|
||||||
|
Body body = (Body) extensionElement;
|
||||||
|
resultSet.add(body);
|
||||||
|
}
|
||||||
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -375,8 +379,11 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
*/
|
*/
|
||||||
public Body addBody(String language, String body) {
|
public Body addBody(String language, String body) {
|
||||||
language = determineLanguage(language);
|
language = determineLanguage(language);
|
||||||
|
|
||||||
|
removeBody(language);
|
||||||
|
|
||||||
Body messageBody = new Body(language, body);
|
Body messageBody = new Body(language, body);
|
||||||
bodies.add(messageBody);
|
addExtension(messageBody);
|
||||||
return messageBody;
|
return messageBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +413,8 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
* @since 3.0.2
|
* @since 3.0.2
|
||||||
*/
|
*/
|
||||||
public boolean removeBody(Body body) {
|
public boolean removeBody(Body body) {
|
||||||
return bodies.remove(body);
|
ExtensionElement removedElement = removeExtension(body);
|
||||||
|
return removedElement != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -418,7 +426,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
public List<String> getBodyLanguages() {
|
public List<String> getBodyLanguages() {
|
||||||
Body defaultBody = getMessageBody(null);
|
Body defaultBody = getMessageBody(null);
|
||||||
List<String> languages = new ArrayList<String>();
|
List<String> languages = new ArrayList<String>();
|
||||||
for (Body body : bodies) {
|
for (Body body : getBodies()) {
|
||||||
if (!body.equals(defaultBody)) {
|
if (!body.equals(defaultBody)) {
|
||||||
languages.add(body.language);
|
languages.add(body.language);
|
||||||
}
|
}
|
||||||
|
@ -472,9 +480,9 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||||
XmlStringBuilder buf = new XmlStringBuilder();
|
XmlStringBuilder buf = new XmlStringBuilder(enclosingNamespace);
|
||||||
buf.halfOpenElement(ELEMENT);
|
buf.halfOpenElement(ELEMENT);
|
||||||
addCommonAttributes(buf);
|
enclosingNamespace = addCommonAttributes(buf, enclosingNamespace);
|
||||||
buf.optAttribute("type", type);
|
buf.optAttribute("type", type);
|
||||||
buf.rightAngleBracket();
|
buf.rightAngleBracket();
|
||||||
|
|
||||||
|
@ -490,25 +498,15 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
continue;
|
continue;
|
||||||
buf.append(subject.toXML(null));
|
buf.append(subject.toXML(null));
|
||||||
}
|
}
|
||||||
// Add the body in the default language
|
|
||||||
Body defaultBody = getMessageBody(null);
|
|
||||||
if (defaultBody != null) {
|
|
||||||
buf.element("body", defaultBody.message);
|
|
||||||
}
|
|
||||||
// Add the bodies in other languages
|
|
||||||
for (Body body : getBodies()) {
|
|
||||||
// Skip the default language
|
|
||||||
if (body.equals(defaultBody))
|
|
||||||
continue;
|
|
||||||
buf.append(body.toXML(enclosingNamespace));
|
|
||||||
}
|
|
||||||
buf.optElement("thread", thread);
|
buf.optElement("thread", thread);
|
||||||
// Append the error subpacket if the message type is an error.
|
// Append the error subpacket if the message type is an error.
|
||||||
if (type == Type.error) {
|
if (type == Type.error) {
|
||||||
appendErrorIfExists(buf);
|
appendErrorIfExists(buf);
|
||||||
}
|
}
|
||||||
// Add packet extensions, if any are defined.
|
|
||||||
buf.append(getExtensionsXML());
|
// Add extension elements, if any are defined.
|
||||||
|
buf.append(getExtensions(), enclosingNamespace);
|
||||||
|
|
||||||
buf.closeElement(ELEMENT);
|
buf.closeElement(ELEMENT);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,9 +273,9 @@ public final class Presence extends Stanza implements TypedCloneable<Presence> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||||
XmlStringBuilder buf = new XmlStringBuilder();
|
XmlStringBuilder buf = new XmlStringBuilder(enclosingNamespace);
|
||||||
buf.halfOpenElement(ELEMENT);
|
buf.halfOpenElement(ELEMENT);
|
||||||
addCommonAttributes(buf);
|
addCommonAttributes(buf, enclosingNamespace);
|
||||||
if (type != Type.available) {
|
if (type != Type.available) {
|
||||||
buf.attribute("type", type);
|
buf.attribute("type", type);
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,8 @@ public final class Presence extends Stanza implements TypedCloneable<Presence> {
|
||||||
if (mode != null && mode != Mode.available) {
|
if (mode != null && mode != Mode.available) {
|
||||||
buf.element("show", mode);
|
buf.element("show", mode);
|
||||||
}
|
}
|
||||||
buf.append(getExtensionsXML());
|
|
||||||
|
buf.append(getExtensions(), enclosingNamespace);
|
||||||
|
|
||||||
// Add the error sub-packet, if there is one.
|
// Add the error sub-packet, if there is one.
|
||||||
appendErrorIfExists(buf);
|
appendErrorIfExists(buf);
|
||||||
|
|
|
@ -470,7 +470,15 @@ public abstract class Stanza implements TopLevelStreamElement {
|
||||||
* @return the removed stanza extension or null.
|
* @return the removed stanza extension or null.
|
||||||
*/
|
*/
|
||||||
public ExtensionElement removeExtension(ExtensionElement extension) {
|
public ExtensionElement removeExtension(ExtensionElement extension) {
|
||||||
return removeExtension(extension.getElementName(), extension.getNamespace());
|
String key = XmppStringUtils.generateKey(extension.getElementName(), extension.getNamespace());
|
||||||
|
synchronized (packetExtensions) {
|
||||||
|
List<ExtensionElement> list = packetExtensions.getAll(key);
|
||||||
|
boolean removed = list.remove(extension);
|
||||||
|
if (removed) {
|
||||||
|
return extension;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -479,22 +487,6 @@ public abstract class Stanza implements TopLevelStreamElement {
|
||||||
@Override
|
@Override
|
||||||
public abstract String toString();
|
public abstract String toString();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the extension sub-packets (including properties data) as an XML
|
|
||||||
* String, or the Empty String if there are no stanza extensions.
|
|
||||||
*
|
|
||||||
* @return the extension sub-packets as XML or the Empty String if there
|
|
||||||
* are no stanza extensions.
|
|
||||||
*/
|
|
||||||
protected final XmlStringBuilder getExtensionsXML() {
|
|
||||||
XmlStringBuilder xml = new XmlStringBuilder();
|
|
||||||
// Add in all standard extension sub-packets.
|
|
||||||
for (ExtensionElement extension : getExtensions()) {
|
|
||||||
xml.append(extension.toXML(null));
|
|
||||||
}
|
|
||||||
return xml;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the default language used for all messages containing localized content.
|
* Returns the default language used for all messages containing localized content.
|
||||||
*
|
*
|
||||||
|
@ -507,13 +499,26 @@ public abstract class Stanza implements TopLevelStreamElement {
|
||||||
/**
|
/**
|
||||||
* Add to, from, id and 'xml:lang' attributes
|
* Add to, from, id and 'xml:lang' attributes
|
||||||
*
|
*
|
||||||
* @param xml
|
* @param xml the {@link XmlStringBuilder}.
|
||||||
|
* @param enclosingNamespace the enclosing XML namespace.
|
||||||
|
* @return the set namespace for this stanza.
|
||||||
*/
|
*/
|
||||||
protected void addCommonAttributes(XmlStringBuilder xml) {
|
protected String addCommonAttributes(XmlStringBuilder xml, String enclosingNamespace) {
|
||||||
|
String namespace;
|
||||||
|
if (enclosingNamespace == null || !enclosingNamespace.equals(StreamOpen.CLIENT_NAMESPACE)
|
||||||
|
|| !enclosingNamespace.equals(StreamOpen.SERVER_NAMESPACE)) {
|
||||||
|
namespace = StreamOpen.CLIENT_NAMESPACE;
|
||||||
|
} else {
|
||||||
|
namespace = enclosingNamespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
xml.xmlnsAttribute(namespace);
|
||||||
xml.optAttribute("to", getTo());
|
xml.optAttribute("to", getTo());
|
||||||
xml.optAttribute("from", getFrom());
|
xml.optAttribute("from", getFrom());
|
||||||
xml.optAttribute("id", getStanzaId());
|
xml.optAttribute("id", getStanzaId());
|
||||||
xml.xmllangAttribute(getLanguage());
|
xml.xmllangAttribute(getLanguage());
|
||||||
|
|
||||||
|
return namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void logCommonAttributes(StringBuilder sb) {
|
protected void logCommonAttributes(StringBuilder sb) {
|
||||||
|
|
|
@ -246,28 +246,12 @@ public class PacketParserUtils {
|
||||||
switch (elementName) {
|
switch (elementName) {
|
||||||
case "subject":
|
case "subject":
|
||||||
String xmlLangSubject = getLanguageAttribute(parser);
|
String xmlLangSubject = getLanguageAttribute(parser);
|
||||||
if (xmlLangSubject == null) {
|
|
||||||
xmlLangSubject = defaultLanguage;
|
|
||||||
}
|
|
||||||
|
|
||||||
String subject = parseElementText(parser);
|
String subject = parseElementText(parser);
|
||||||
|
|
||||||
if (message.getSubject(xmlLangSubject) == null) {
|
if (message.getSubject(xmlLangSubject) == null) {
|
||||||
message.addSubject(xmlLangSubject, subject);
|
message.addSubject(xmlLangSubject, subject);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Message.BODY:
|
|
||||||
String xmlLang = getLanguageAttribute(parser);
|
|
||||||
if (xmlLang == null) {
|
|
||||||
xmlLang = defaultLanguage;
|
|
||||||
}
|
|
||||||
|
|
||||||
String body = parseElementText(parser);
|
|
||||||
|
|
||||||
if (message.getBody(xmlLang) == null) {
|
|
||||||
message.addBody(xmlLang, body);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "thread":
|
case "thread":
|
||||||
if (thread == null) {
|
if (thread == null) {
|
||||||
thread = parser.nextText();
|
thread = parser.nextText();
|
||||||
|
@ -290,6 +274,11 @@ public class PacketParserUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
message.setThread(thread);
|
message.setThread(thread);
|
||||||
|
|
||||||
|
// TODO check for duplicate body elements. This means we need to check for duplicate xml:lang pairs and for
|
||||||
|
// situations where we have a body element with an explicit xml lang set and once where the value is inherited
|
||||||
|
// and both values are equal.
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -457,8 +457,12 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlStringBuilder append(Collection<? extends Element> elements) {
|
public XmlStringBuilder append(Collection<? extends Element> elements) {
|
||||||
|
return append(elements, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public XmlStringBuilder append(Collection<? extends Element> elements, String enclosingNamespace) {
|
||||||
for (Element element : elements) {
|
for (Element element : elements) {
|
||||||
append(element.toXML(null));
|
append(element.toXML(enclosingNamespace));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class MessageTest {
|
||||||
Message messageTypeInConstructor = new Message(null, Message.Type.chat);
|
Message messageTypeInConstructor = new Message(null, Message.Type.chat);
|
||||||
messageTypeInConstructor.setStanzaId(null);
|
messageTypeInConstructor.setStanzaId(null);
|
||||||
assertEquals(type, messageTypeInConstructor.getType());
|
assertEquals(type, messageTypeInConstructor.getType());
|
||||||
assertXMLEqual(control, messageTypeInConstructor.toXML(null).toString());
|
assertXMLEqual(control, messageTypeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
controlBuilder = new StringBuilder();
|
controlBuilder = new StringBuilder();
|
||||||
controlBuilder.append("<message")
|
controlBuilder.append("<message")
|
||||||
|
@ -62,7 +62,7 @@ public class MessageTest {
|
||||||
Message messageTypeSet = getNewMessage();
|
Message messageTypeSet = getNewMessage();
|
||||||
messageTypeSet.setType(type2);
|
messageTypeSet.setType(type2);
|
||||||
assertEquals(type2, messageTypeSet.getType());
|
assertEquals(type2, messageTypeSet.getType());
|
||||||
assertXMLEqual(control, messageTypeSet.toXML(null).toString());
|
assertXMLEqual(control, messageTypeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test(expected = NullPointerException.class)
|
||||||
|
@ -87,7 +87,7 @@ public class MessageTest {
|
||||||
message.setSubject(messageSubject);
|
message.setSubject(messageSubject);
|
||||||
|
|
||||||
assertEquals(messageSubject, message.getSubject());
|
assertEquals(messageSubject, message.getSubject());
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -106,7 +106,7 @@ public class MessageTest {
|
||||||
message.setBody(messageBody);
|
message.setBody(messageBody);
|
||||||
|
|
||||||
assertEquals(messageBody, message.getBody());
|
assertEquals(messageBody, message.getBody());
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -183,7 +183,7 @@ public class MessageTest {
|
||||||
message.setThread(messageThread);
|
message.setThread(messageThread);
|
||||||
|
|
||||||
assertEquals(messageThread, message.getThread());
|
assertEquals(messageThread, message.getThread());
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -201,7 +201,7 @@ public class MessageTest {
|
||||||
Message message = getNewMessage();
|
Message message = getNewMessage();
|
||||||
message.setLanguage(lang);
|
message.setLanguage(lang);
|
||||||
|
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Message getNewMessage() {
|
private static Message getNewMessage() {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class PresenceTest {
|
||||||
Presence presenceTypeInConstructor = new Presence(type);
|
Presence presenceTypeInConstructor = new Presence(type);
|
||||||
presenceTypeInConstructor.setStanzaId(null);
|
presenceTypeInConstructor.setStanzaId(null);
|
||||||
assertEquals(type, presenceTypeInConstructor.getType());
|
assertEquals(type, presenceTypeInConstructor.getType());
|
||||||
assertXMLEqual(control, presenceTypeInConstructor.toXML(null).toString());
|
assertXMLEqual(control, presenceTypeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
controlBuilder = new StringBuilder();
|
controlBuilder = new StringBuilder();
|
||||||
controlBuilder.append("<presence")
|
controlBuilder.append("<presence")
|
||||||
|
@ -56,7 +56,7 @@ public class PresenceTest {
|
||||||
Presence presenceTypeSet = getNewPresence();
|
Presence presenceTypeSet = getNewPresence();
|
||||||
presenceTypeSet.setType(type2);
|
presenceTypeSet.setType(type2);
|
||||||
assertEquals(type2, presenceTypeSet.getType());
|
assertEquals(type2, presenceTypeSet.getType());
|
||||||
assertXMLEqual(control, presenceTypeSet.toXML(null).toString());
|
assertXMLEqual(control, presenceTypeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test(expected = NullPointerException.class)
|
||||||
|
@ -90,7 +90,7 @@ public class PresenceTest {
|
||||||
presence.setStatus(status);
|
presence.setStatus(status);
|
||||||
|
|
||||||
assertEquals(status, presence.getStatus());
|
assertEquals(status, presence.getStatus());
|
||||||
assertXMLEqual(control, presence.toXML(null).toString());
|
assertXMLEqual(control, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -109,7 +109,7 @@ public class PresenceTest {
|
||||||
presence.setPriority(priority);
|
presence.setPriority(priority);
|
||||||
|
|
||||||
assertEquals(priority, presence.getPriority());
|
assertEquals(priority, presence.getPriority());
|
||||||
assertXMLEqual(control, presence.toXML(null).toString());
|
assertXMLEqual(control, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
@ -142,7 +142,7 @@ public class PresenceTest {
|
||||||
mode1);
|
mode1);
|
||||||
presenceModeInConstructor.setStanzaId(null);
|
presenceModeInConstructor.setStanzaId(null);
|
||||||
assertEquals(mode1, presenceModeInConstructor.getMode());
|
assertEquals(mode1, presenceModeInConstructor.getMode());
|
||||||
assertXMLEqual(control, presenceModeInConstructor.toXML(null).toString());
|
assertXMLEqual(control, presenceModeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
controlBuilder = new StringBuilder();
|
controlBuilder = new StringBuilder();
|
||||||
controlBuilder.append("<presence>")
|
controlBuilder.append("<presence>")
|
||||||
|
@ -155,7 +155,7 @@ public class PresenceTest {
|
||||||
Presence presenceModeSet = getNewPresence();
|
Presence presenceModeSet = getNewPresence();
|
||||||
presenceModeSet.setMode(mode2);
|
presenceModeSet.setMode(mode2);
|
||||||
assertEquals(mode2, presenceModeSet.getMode());
|
assertEquals(mode2, presenceModeSet.getMode());
|
||||||
assertXMLEqual(control, presenceModeSet.toXML(null).toString());
|
assertXMLEqual(control, presenceModeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -183,7 +183,7 @@ public class PresenceTest {
|
||||||
Presence presence = getNewPresence();
|
Presence presence = getNewPresence();
|
||||||
presence.setLanguage(lang);
|
presence.setLanguage(lang);
|
||||||
|
|
||||||
assertXMLEqual(control, presence.toXML(null).toString());
|
assertXMLEqual(control, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Presence getNewPresence() {
|
private static Presence getNewPresence() {
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.jivesoftware.smack.test.util.TestUtils;
|
||||||
import org.jivesoftware.smack.test.util.XmlUnitUtils;
|
import org.jivesoftware.smack.test.util.XmlUnitUtils;
|
||||||
|
|
||||||
import com.jamesmurty.utils.XMLBuilder;
|
import com.jamesmurty.utils.XMLBuilder;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
@ -67,6 +68,7 @@ public class PacketParserUtilsTest {
|
||||||
|
|
||||||
// message has default language, body has no language
|
// message has default language, body has no language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
|
@ -87,6 +89,7 @@ public class PacketParserUtilsTest {
|
||||||
|
|
||||||
// message has non-default language, body has no language
|
// message has non-default language, body has no language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
|
@ -106,6 +109,7 @@ public class PacketParserUtilsTest {
|
||||||
|
|
||||||
// message has no language, body has no language
|
// message has no language, body has no language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
|
@ -118,12 +122,13 @@ public class PacketParserUtilsTest {
|
||||||
|
|
||||||
assertEquals(defaultLanguage, message.getBody());
|
assertEquals(defaultLanguage, message.getBody());
|
||||||
assertTrue(message.getBodyLanguages().isEmpty());
|
assertTrue(message.getBodyLanguages().isEmpty());
|
||||||
assertEquals(defaultLanguage, message.getBody(defaultLanguage));
|
assertEquals(defaultLanguage, message.getBody(null));
|
||||||
assertNull(message.getBody(otherLanguage));
|
assertNull(message.getBody(otherLanguage));
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(null).toString());
|
||||||
|
|
||||||
// message has no language, body has default language
|
// message has no language, body has default language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
|
@ -135,16 +140,16 @@ public class PacketParserUtilsTest {
|
||||||
|
|
||||||
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
|
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
|
||||||
|
|
||||||
assertEquals(defaultLanguage, message.getBody());
|
assertNull(message.getBody());
|
||||||
assertTrue(message.getBodyLanguages().isEmpty());
|
assertFalse(message.getBodyLanguages().isEmpty());
|
||||||
assertEquals(defaultLanguage, message.getBody(defaultLanguage));
|
assertEquals(defaultLanguage, message.getBody(defaultLanguage));
|
||||||
assertNull(message.getBody(otherLanguage));
|
assertNull(message.getBody(otherLanguage));
|
||||||
|
|
||||||
// body attribute xml:lang is unnecessary
|
assertXMLEqual(control, message.toXML(null).toString());
|
||||||
assertXMLNotEqual(control, message.toXML(null).toString());
|
|
||||||
|
|
||||||
// message has no language, body has non-default language
|
// message has no language, body has non-default language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
|
@ -161,10 +166,11 @@ public class PacketParserUtilsTest {
|
||||||
assertTrue(message.getBodyLanguages().contains(otherLanguage));
|
assertTrue(message.getBodyLanguages().contains(otherLanguage));
|
||||||
assertEquals(otherLanguage, message.getBody(otherLanguage));
|
assertEquals(otherLanguage, message.getBody(otherLanguage));
|
||||||
assertNull(message.getBody(defaultLanguage));
|
assertNull(message.getBody(defaultLanguage));
|
||||||
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
assertXMLEqual(control, message.toXML(null).toString());
|
||||||
|
|
||||||
// message has default language, body has non-default language
|
// message has default language, body has non-default language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
|
@ -182,10 +188,11 @@ public class PacketParserUtilsTest {
|
||||||
assertTrue(message.getBodyLanguages().contains(otherLanguage));
|
assertTrue(message.getBodyLanguages().contains(otherLanguage));
|
||||||
assertEquals(otherLanguage, message.getBody(otherLanguage));
|
assertEquals(otherLanguage, message.getBody(otherLanguage));
|
||||||
assertNull(message.getBody(defaultLanguage));
|
assertNull(message.getBody(defaultLanguage));
|
||||||
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
assertXMLEqual(control, message.toXML(null).toString());
|
||||||
|
|
||||||
// message has non-default language, body has default language
|
// message has non-default language, body has default language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
|
@ -203,7 +210,7 @@ public class PacketParserUtilsTest {
|
||||||
assertTrue(message.getBodyLanguages().contains(defaultLanguage));
|
assertTrue(message.getBodyLanguages().contains(defaultLanguage));
|
||||||
assertEquals(defaultLanguage, message.getBody(defaultLanguage));
|
assertEquals(defaultLanguage, message.getBody(defaultLanguage));
|
||||||
assertNull(message.getBody(otherLanguage));
|
assertNull(message.getBody(otherLanguage));
|
||||||
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
assertXMLEqual(control, message.toXML(null).toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +239,7 @@ public class PacketParserUtilsTest {
|
||||||
assertTrue(message.getSubjectLanguages().isEmpty());
|
assertTrue(message.getSubjectLanguages().isEmpty());
|
||||||
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
||||||
assertNull(message.getSubject(otherLanguage));
|
assertNull(message.getSubject(otherLanguage));
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
// message has non-default language, subject has no language
|
// message has non-default language, subject has no language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
@ -251,7 +258,7 @@ public class PacketParserUtilsTest {
|
||||||
assertTrue(message.getSubjectLanguages().isEmpty());
|
assertTrue(message.getSubjectLanguages().isEmpty());
|
||||||
assertEquals(otherLanguage, message.getSubject(otherLanguage));
|
assertEquals(otherLanguage, message.getSubject(otherLanguage));
|
||||||
assertNull(message.getSubject(defaultLanguage));
|
assertNull(message.getSubject(defaultLanguage));
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
// message has no language, subject has no language
|
// message has no language, subject has no language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
@ -267,9 +274,9 @@ public class PacketParserUtilsTest {
|
||||||
|
|
||||||
assertEquals(defaultLanguage, message.getSubject());
|
assertEquals(defaultLanguage, message.getSubject());
|
||||||
assertTrue(message.getSubjectLanguages().isEmpty());
|
assertTrue(message.getSubjectLanguages().isEmpty());
|
||||||
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
assertEquals(defaultLanguage, message.getSubject(null));
|
||||||
assertNull(message.getSubject(otherLanguage));
|
assertNull(message.getSubject(otherLanguage));
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
// message has no language, subject has default language
|
// message has no language, subject has default language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
@ -284,13 +291,11 @@ public class PacketParserUtilsTest {
|
||||||
|
|
||||||
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
|
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
|
||||||
|
|
||||||
assertEquals(defaultLanguage, message.getSubject());
|
assertFalse(message.getSubjectLanguages().isEmpty());
|
||||||
assertTrue(message.getSubjectLanguages().isEmpty());
|
|
||||||
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
||||||
assertNull(message.getSubject(otherLanguage));
|
assertNull(message.getSubject(otherLanguage));
|
||||||
|
|
||||||
// subject attribute xml:lang is unnecessary
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
assertXMLNotEqual(control, message.toXML(null).toString());
|
|
||||||
|
|
||||||
// message has no language, subject has non-default language
|
// message has no language, subject has non-default language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
@ -310,7 +315,7 @@ public class PacketParserUtilsTest {
|
||||||
assertTrue(message.getSubjectLanguages().contains(otherLanguage));
|
assertTrue(message.getSubjectLanguages().contains(otherLanguage));
|
||||||
assertEquals(otherLanguage, message.getSubject(otherLanguage));
|
assertEquals(otherLanguage, message.getSubject(otherLanguage));
|
||||||
assertNull(message.getSubject(defaultLanguage));
|
assertNull(message.getSubject(defaultLanguage));
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
// message has default language, subject has non-default language
|
// message has default language, subject has non-default language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
@ -331,7 +336,7 @@ public class PacketParserUtilsTest {
|
||||||
assertTrue(message.getSubjectLanguages().contains(otherLanguage));
|
assertTrue(message.getSubjectLanguages().contains(otherLanguage));
|
||||||
assertEquals(otherLanguage, message.getSubject(otherLanguage));
|
assertEquals(otherLanguage, message.getSubject(otherLanguage));
|
||||||
assertNull(message.getSubject(defaultLanguage));
|
assertNull(message.getSubject(defaultLanguage));
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
// message has non-default language, subject has default language
|
// message has non-default language, subject has default language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
@ -352,7 +357,7 @@ public class PacketParserUtilsTest {
|
||||||
assertTrue(message.getSubjectLanguages().contains(defaultLanguage));
|
assertTrue(message.getSubjectLanguages().contains(defaultLanguage));
|
||||||
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
||||||
assertNull(message.getSubject(otherLanguage));
|
assertNull(message.getSubject(otherLanguage));
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,6 +371,7 @@ public class PacketParserUtilsTest {
|
||||||
|
|
||||||
// message has default language, first body no language, second body other language
|
// message has default language, first body no language, second body other language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
|
@ -387,34 +393,11 @@ public class PacketParserUtilsTest {
|
||||||
assertEquals(2, message.getBodies().size());
|
assertEquals(2, message.getBodies().size());
|
||||||
assertEquals(1, message.getBodyLanguages().size());
|
assertEquals(1, message.getBodyLanguages().size());
|
||||||
assertTrue(message.getBodyLanguages().contains(otherLanguage));
|
assertTrue(message.getBodyLanguages().contains(otherLanguage));
|
||||||
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
assertXMLEqual(control, message.toXML(null).toString());
|
||||||
|
|
||||||
// message has default language, first body no language, second body default language
|
|
||||||
control = XMLBuilder.create("message")
|
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
|
||||||
.a("id", "zid615d9")
|
|
||||||
.a("type", "chat")
|
|
||||||
.a("xml:lang", defaultLanguage)
|
|
||||||
.e("body")
|
|
||||||
.t(defaultLanguage)
|
|
||||||
.up()
|
|
||||||
.e("body")
|
|
||||||
.a("xml:lang", defaultLanguage)
|
|
||||||
.t(defaultLanguage + "2")
|
|
||||||
.asString(outputProperties);
|
|
||||||
|
|
||||||
message = PacketParserUtils
|
|
||||||
.parseMessage(PacketParserUtils.getParserFor(control));
|
|
||||||
|
|
||||||
assertEquals(defaultLanguage, message.getBody());
|
|
||||||
assertEquals(defaultLanguage, message.getBody(defaultLanguage));
|
|
||||||
assertEquals(1, message.getBodies().size());
|
|
||||||
assertEquals(0, message.getBodyLanguages().size());
|
|
||||||
assertXMLNotEqual(control, message.toXML(null).toString());
|
|
||||||
|
|
||||||
// message has non-default language, first body no language, second body default language
|
// message has non-default language, first body no language, second body default language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
|
@ -436,14 +419,24 @@ public class PacketParserUtilsTest {
|
||||||
assertEquals(2, message.getBodies().size());
|
assertEquals(2, message.getBodies().size());
|
||||||
assertEquals(1, message.getBodyLanguages().size());
|
assertEquals(1, message.getBodyLanguages().size());
|
||||||
assertTrue(message.getBodyLanguages().contains(defaultLanguage));
|
assertTrue(message.getBodyLanguages().contains(defaultLanguage));
|
||||||
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
assertXMLEqual(control, message.toXML(null).toString());
|
||||||
|
}
|
||||||
|
|
||||||
// message has no language, first body no language, second body default language
|
// TODO: Re-enable once we throw an exception on duplicate body elements.
|
||||||
control = XMLBuilder.create("message")
|
@Ignore
|
||||||
|
@Test
|
||||||
|
public void duplicateMessageBodiesTest()
|
||||||
|
throws FactoryConfigurationError, XmlPullParserException, IOException, Exception {
|
||||||
|
String defaultLanguage = Stanza.getDefaultLanguage();
|
||||||
|
|
||||||
|
// message has default language, first body no language, second body default language
|
||||||
|
String control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
.a("type", "chat")
|
.a("type", "chat")
|
||||||
|
.a("xml:lang", defaultLanguage)
|
||||||
.e("body")
|
.e("body")
|
||||||
.t(defaultLanguage)
|
.t(defaultLanguage)
|
||||||
.up()
|
.up()
|
||||||
|
@ -452,7 +445,7 @@ public class PacketParserUtilsTest {
|
||||||
.t(defaultLanguage + "2")
|
.t(defaultLanguage + "2")
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
message = PacketParserUtils
|
Message message = PacketParserUtils
|
||||||
.parseMessage(PacketParserUtils.getParserFor(control));
|
.parseMessage(PacketParserUtils.getParserFor(control));
|
||||||
|
|
||||||
assertEquals(defaultLanguage, message.getBody());
|
assertEquals(defaultLanguage, message.getBody());
|
||||||
|
@ -460,9 +453,19 @@ public class PacketParserUtilsTest {
|
||||||
assertEquals(1, message.getBodies().size());
|
assertEquals(1, message.getBodies().size());
|
||||||
assertEquals(0, message.getBodyLanguages().size());
|
assertEquals(0, message.getBodyLanguages().size());
|
||||||
assertXMLNotEqual(control, message.toXML(null).toString());
|
assertXMLNotEqual(control, message.toXML(null).toString());
|
||||||
|
}
|
||||||
|
|
||||||
// message has no language, first body no language, second body other language
|
@Ignore
|
||||||
control = XMLBuilder.create("message")
|
@Test
|
||||||
|
public void duplicateMessageBodiesTest2()
|
||||||
|
throws FactoryConfigurationError, XmlPullParserException, IOException, Exception {
|
||||||
|
String defaultLanguage = Stanza.getDefaultLanguage();
|
||||||
|
String otherLanguage = determineNonDefaultLanguage();
|
||||||
|
|
||||||
|
// message has no language, first body no language, second body no language
|
||||||
|
String control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
|
.a("xml:lang", defaultLanguage)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
|
@ -470,43 +473,44 @@ public class PacketParserUtilsTest {
|
||||||
.e("body")
|
.e("body")
|
||||||
.t(defaultLanguage)
|
.t(defaultLanguage)
|
||||||
.up()
|
.up()
|
||||||
|
.e("body")
|
||||||
|
.t(otherLanguage)
|
||||||
|
.asString(outputProperties);
|
||||||
|
|
||||||
|
PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void messageNoLanguageFirstBodyNoLanguageSecondBodyOtherTest()
|
||||||
|
throws FactoryConfigurationError, XmlPullParserException, IOException, Exception {
|
||||||
|
String defaultLanguage = Stanza.getDefaultLanguage();
|
||||||
|
String otherLanguage = determineNonDefaultLanguage();
|
||||||
|
|
||||||
|
// message has no language, first body no language, second body other language
|
||||||
|
String control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
|
.a("id", "zid615d9")
|
||||||
|
.a("type", "chat")
|
||||||
|
.e("body")
|
||||||
|
// TODO change default language into something else
|
||||||
|
.t(defaultLanguage)
|
||||||
|
.up()
|
||||||
.e("body")
|
.e("body")
|
||||||
.a("xml:lang", otherLanguage)
|
.a("xml:lang", otherLanguage)
|
||||||
.t(otherLanguage)
|
.t(otherLanguage)
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
message = PacketParserUtils
|
Message message = PacketParserUtils
|
||||||
.parseMessage(PacketParserUtils.getParserFor(control));
|
.parseMessage(PacketParserUtils.getParserFor(control));
|
||||||
|
|
||||||
assertEquals(defaultLanguage, message.getBody());
|
assertEquals(defaultLanguage, message.getBody());
|
||||||
assertEquals(defaultLanguage, message.getBody(defaultLanguage));
|
assertEquals(defaultLanguage, message.getBody(null));
|
||||||
assertEquals(otherLanguage, message.getBody(otherLanguage));
|
assertEquals(otherLanguage, message.getBody(otherLanguage));
|
||||||
assertEquals(2, message.getBodies().size());
|
assertEquals(2, message.getBodies().size());
|
||||||
assertEquals(1, message.getBodyLanguages().size());
|
assertEquals(1, message.getBodyLanguages().size());
|
||||||
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
assertXMLEqual(control, message.toXML(null).toString());
|
||||||
|
|
||||||
// message has no language, first body no language, second body no language
|
|
||||||
control = XMLBuilder.create("message")
|
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
|
||||||
.a("id", "zid615d9")
|
|
||||||
.a("type", "chat")
|
|
||||||
.e("body")
|
|
||||||
.t(defaultLanguage)
|
|
||||||
.up()
|
|
||||||
.e("body")
|
|
||||||
.t(otherLanguage)
|
|
||||||
.asString(outputProperties);
|
|
||||||
|
|
||||||
message = PacketParserUtils
|
|
||||||
.parseMessage(PacketParserUtils.getParserFor(control));
|
|
||||||
|
|
||||||
assertEquals(defaultLanguage, message.getBody());
|
|
||||||
assertEquals(defaultLanguage, message.getBody(defaultLanguage));
|
|
||||||
assertEquals(1, message.getBodies().size());
|
|
||||||
assertEquals(0, message.getBodyLanguages().size());
|
|
||||||
assertXMLNotEqual(control, message.toXML(null).toString());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -540,7 +544,7 @@ public class PacketParserUtilsTest {
|
||||||
assertEquals(2, message.getSubjects().size());
|
assertEquals(2, message.getSubjects().size());
|
||||||
assertEquals(1, message.getSubjectLanguages().size());
|
assertEquals(1, message.getSubjectLanguages().size());
|
||||||
assertTrue(message.getSubjectLanguages().contains(otherLanguage));
|
assertTrue(message.getSubjectLanguages().contains(otherLanguage));
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
// message has default language, first subject no language, second subject default language
|
// message has default language, first subject no language, second subject default language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
@ -564,7 +568,7 @@ public class PacketParserUtilsTest {
|
||||||
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
||||||
assertEquals(1, message.getSubjects().size());
|
assertEquals(1, message.getSubjects().size());
|
||||||
assertEquals(0, message.getSubjectLanguages().size());
|
assertEquals(0, message.getSubjectLanguages().size());
|
||||||
assertXMLNotEqual(control, message.toXML(null).toString());
|
assertXMLNotEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
// message has non-default language, first subject no language, second subject default language
|
// message has non-default language, first subject no language, second subject default language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
@ -589,8 +593,9 @@ public class PacketParserUtilsTest {
|
||||||
assertEquals(2, message.getSubjects().size());
|
assertEquals(2, message.getSubjects().size());
|
||||||
assertEquals(1, message.getSubjectLanguages().size());
|
assertEquals(1, message.getSubjectLanguages().size());
|
||||||
assertTrue(message.getSubjectLanguages().contains(defaultLanguage));
|
assertTrue(message.getSubjectLanguages().contains(defaultLanguage));
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
|
/*
|
||||||
// message has no language, first subject no language, second subject default language
|
// message has no language, first subject no language, second subject default language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
|
@ -612,7 +617,7 @@ public class PacketParserUtilsTest {
|
||||||
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
||||||
assertEquals(1, message.getSubjects().size());
|
assertEquals(1, message.getSubjects().size());
|
||||||
assertEquals(0, message.getSubjectLanguages().size());
|
assertEquals(0, message.getSubjectLanguages().size());
|
||||||
assertXMLNotEqual(control, message.toXML(null).toString());
|
assertXMLNotEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
// message has no language, first subject no language, second subject other language
|
// message has no language, first subject no language, second subject other language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
@ -636,7 +641,7 @@ public class PacketParserUtilsTest {
|
||||||
assertEquals(otherLanguage, message.getSubject(otherLanguage));
|
assertEquals(otherLanguage, message.getSubject(otherLanguage));
|
||||||
assertEquals(2, message.getSubjects().size());
|
assertEquals(2, message.getSubjects().size());
|
||||||
assertEquals(1, message.getSubjectLanguages().size());
|
assertEquals(1, message.getSubjectLanguages().size());
|
||||||
assertXMLEqual(control, message.toXML(null).toString());
|
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
|
||||||
// message has no language, first subject no language, second subject no language
|
// message has no language, first subject no language, second subject no language
|
||||||
control = XMLBuilder.create("message")
|
control = XMLBuilder.create("message")
|
||||||
|
@ -658,7 +663,8 @@ public class PacketParserUtilsTest {
|
||||||
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
||||||
assertEquals(1, message.getSubjects().size());
|
assertEquals(1, message.getSubjects().size());
|
||||||
assertEquals(0, message.getSubjectLanguages().size());
|
assertEquals(0, message.getSubjectLanguages().size());
|
||||||
assertXMLNotEqual(control, message.toXML(null).toString());
|
assertXMLNotEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,6 +677,7 @@ public class PacketParserUtilsTest {
|
||||||
@Test(expected = XmlPullParserException.class)
|
@Test(expected = XmlPullParserException.class)
|
||||||
public void invalidMessageBodyContainingTagTest() throws Exception {
|
public void invalidMessageBodyContainingTagTest() throws Exception {
|
||||||
String control = XMLBuilder.create("message")
|
String control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
|
@ -691,6 +698,7 @@ public class PacketParserUtilsTest {
|
||||||
@Test
|
@Test
|
||||||
public void invalidXMLInMessageBody() throws Exception {
|
public void invalidXMLInMessageBody() throws Exception {
|
||||||
String validControl = XMLBuilder.create("message")
|
String validControl = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
|
@ -732,12 +740,17 @@ public class PacketParserUtilsTest {
|
||||||
@Test
|
@Test
|
||||||
public void multipleMessageBodiesParsingTest() throws Exception {
|
public void multipleMessageBodiesParsingTest() throws Exception {
|
||||||
String control = XMLBuilder.create("message")
|
String control = XMLBuilder.create("message")
|
||||||
|
.namespace(StreamOpen.CLIENT_NAMESPACE)
|
||||||
.a("from", "romeo@montague.lit/orchard")
|
.a("from", "romeo@montague.lit/orchard")
|
||||||
.a("to", "juliet@capulet.lit/balcony")
|
.a("to", "juliet@capulet.lit/balcony")
|
||||||
.a("id", "zid615d9")
|
.a("id", "zid615d9")
|
||||||
.a("type", "chat")
|
.a("type", "chat")
|
||||||
.a("xml:lang", "en")
|
.a("xml:lang", "en")
|
||||||
.e("body")
|
.e("body")
|
||||||
|
// TODO: Remove the following xml:lang once Smack's serialization toXml() API is aware of a potential
|
||||||
|
// scoping xml:lang value. The out message stanza already declares an xml:lang with the exact same
|
||||||
|
// value, hence this statement is redundant.
|
||||||
|
.a("xml:lang", "en")
|
||||||
.t("This is a test of the emergency broadcast system, 1.")
|
.t("This is a test of the emergency broadcast system, 1.")
|
||||||
.up()
|
.up()
|
||||||
.e("body")
|
.e("body")
|
||||||
|
@ -750,7 +763,7 @@ public class PacketParserUtilsTest {
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
Stanza message = PacketParserUtils.parseStanza(control);
|
Stanza message = PacketParserUtils.parseStanza(control);
|
||||||
XmlUnitUtils.assertSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE));
|
XmlUnitUtils.assertSimilar(control, message.toXML(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -760,7 +773,7 @@ public class PacketParserUtilsTest {
|
||||||
|
|
||||||
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
|
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
|
||||||
|
|
||||||
assertXMLEqual(stanza, presence.toXML(null).toString());
|
assertXMLEqual(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
// CHECKSTYLE:ON
|
// CHECKSTYLE:ON
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,7 +784,7 @@ public class PacketParserUtilsTest {
|
||||||
|
|
||||||
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
|
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
|
||||||
|
|
||||||
assertXMLEqual(stanza, presence.toXML(null).toString());
|
assertXMLEqual(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
assertEquals(Presence.Type.unsubscribed, presence.getType());
|
assertEquals(Presence.Type.unsubscribed, presence.getType());
|
||||||
// CHECKSTYLE:ON
|
// CHECKSTYLE:ON
|
||||||
}
|
}
|
||||||
|
@ -786,7 +799,7 @@ public class PacketParserUtilsTest {
|
||||||
+ "</presence>";
|
+ "</presence>";
|
||||||
|
|
||||||
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
|
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
|
||||||
assertXMLEqual(stanza, presence.toXML(null).toString());
|
assertXMLEqual(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
assertEquals(Presence.Type.unsubscribed, presence.getType());
|
assertEquals(Presence.Type.unsubscribed, presence.getType());
|
||||||
assertEquals("dnd", presence.getMode().name());
|
assertEquals("dnd", presence.getMode().name());
|
||||||
assertEquals("en", presence.getLanguage());
|
assertEquals("en", presence.getLanguage());
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.jivesoftware.smackx.chat_markers;
|
package org.jivesoftware.smackx.chat_markers;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements;
|
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements;
|
||||||
|
@ -40,7 +41,7 @@ public class AcknowledgedExtensionTest {
|
||||||
Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
|
Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
|
||||||
message.setStanzaId("message-2");
|
message.setStanzaId("message-2");
|
||||||
message.addExtension(new ChatMarkersElements.AcknowledgedExtension("message-1"));
|
message.addExtension(new ChatMarkersElements.AcknowledgedExtension("message-1"));
|
||||||
Assert.assertEquals(acknowledgedMessageStanza, message.toXML(null).toString());
|
Assert.assertEquals(acknowledgedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.jivesoftware.smackx.chat_markers;
|
package org.jivesoftware.smackx.chat_markers;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements;
|
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements;
|
||||||
|
@ -40,7 +41,7 @@ public class DisplayedExtensionTest {
|
||||||
Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
|
Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
|
||||||
message.setStanzaId("message-2");
|
message.setStanzaId("message-2");
|
||||||
message.addExtension(new ChatMarkersElements.DisplayedExtension("message-1"));
|
message.addExtension(new ChatMarkersElements.DisplayedExtension("message-1"));
|
||||||
Assert.assertEquals(displayedMessageStanza, message.toXML(null).toString());
|
Assert.assertEquals(displayedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
public class MarkableExtensionTest {
|
public class MarkableExtensionTest {
|
||||||
|
|
||||||
String markableMessageStanza = "<message to='ingrichard@royalty.england.lit/throne' id='message-1'>"
|
String markableMessageStanza = "<message xmlns='jabber:client' to='ingrichard@royalty.england.lit/throne' id='message-1'>"
|
||||||
+ "<body>My lord, dispatch; read o'er these articles.</body>"
|
+ "<body>My lord, dispatch; read o'er these articles.</body>"
|
||||||
+ "<markable xmlns='urn:xmpp:chat-markers:0'/>" + "</message>";
|
+ "<markable xmlns='urn:xmpp:chat-markers:0'/>" + "</message>";
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.jivesoftware.smackx.chat_markers;
|
package org.jivesoftware.smackx.chat_markers;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements;
|
import org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements;
|
||||||
|
@ -40,7 +41,7 @@ public class ReceivedExtensionTest {
|
||||||
Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
|
Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
|
||||||
message.setStanzaId("message-2");
|
message.setStanzaId("message-2");
|
||||||
message.addExtension(new ChatMarkersElements.ReceivedExtension("message-1"));
|
message.addExtension(new ChatMarkersElements.ReceivedExtension("message-1"));
|
||||||
Assert.assertEquals(receivedMessageStanza, message.toXML(null).toString());
|
Assert.assertEquals(receivedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2017 Grigory Fedorov, Florian Schmaus
|
* Copyright © 2017-2018 Grigory Fedorov, Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.httpfileupload.element.Slot;
|
import org.jivesoftware.smackx.httpfileupload.element.Slot;
|
||||||
|
@ -68,7 +69,7 @@ public class SlotProviderTest {
|
||||||
|
|
||||||
checkUrls(slot);
|
checkUrls(slot);
|
||||||
|
|
||||||
assertXMLEqual(SLOT_IQ, slot.toXML(null).toString());
|
assertXMLEqual(SLOT_IQ, slot.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String SLOT_V0_2_IQ =
|
private static final String SLOT_V0_2_IQ =
|
||||||
|
@ -88,7 +89,7 @@ public class SlotProviderTest {
|
||||||
|
|
||||||
checkUrls(slot);
|
checkUrls(slot);
|
||||||
|
|
||||||
String slotXml = slot.toXML(null).toString();
|
String slotXml = slot.toXML(StreamOpen.CLIENT_NAMESPACE).toString();
|
||||||
assertXMLEqual(SLOT_V0_2_IQ, slotXml);
|
assertXMLEqual(SLOT_V0_2_IQ, slotXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ public class SlotProviderTest {
|
||||||
|
|
||||||
checkUrls(slot);
|
checkUrls(slot);
|
||||||
|
|
||||||
String slotXml = slot.toXML(null).toString();
|
String slotXml = slot.toXML(StreamOpen.CLIENT_NAMESPACE).toString();
|
||||||
assertXMLEqual(SLOT_WITH_HEADERS_IQ, slotXml);
|
assertXMLEqual(SLOT_WITH_HEADERS_IQ, slotXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.jivesoftware.smackx.mam;
|
package org.jivesoftware.smackx.mam;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
||||||
import org.jivesoftware.smackx.rsm.packet.RSMSet;
|
import org.jivesoftware.smackx.rsm.packet.RSMSet;
|
||||||
|
@ -45,7 +46,7 @@ public class PagingTest extends MamTest {
|
||||||
|
|
||||||
Assert.assertEquals(mamQueryIQ.getDataForm(), dataForm);
|
Assert.assertEquals(mamQueryIQ.getDataForm(), dataForm);
|
||||||
Assert.assertEquals(mamQueryIQ.getDataForm().getFields().get(0).getValues().get(0), "urn:xmpp:mam:1");
|
Assert.assertEquals(mamQueryIQ.getDataForm().getFields().get(0).getValues().get(0), "urn:xmpp:mam:1");
|
||||||
Assert.assertEquals(mamQueryIQ.toXML(null).toString(), pagingStanza);
|
Assert.assertEquals(mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), pagingStanza);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.mam;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.mam.element.MamElements;
|
import org.jivesoftware.smackx.mam.element.MamElements;
|
||||||
import org.jivesoftware.smackx.mam.element.MamPrefsIQ;
|
import org.jivesoftware.smackx.mam.element.MamPrefsIQ;
|
||||||
import org.jivesoftware.smackx.mam.element.MamPrefsIQ.DefaultBehavior;
|
import org.jivesoftware.smackx.mam.element.MamPrefsIQ.DefaultBehavior;
|
||||||
|
@ -41,7 +43,7 @@ public class PreferencesTest {
|
||||||
public void checkRetrievePrefsStanza() throws Exception {
|
public void checkRetrievePrefsStanza() throws Exception {
|
||||||
MamPrefsIQ mamPrefIQ = new MamPrefsIQ();
|
MamPrefsIQ mamPrefIQ = new MamPrefsIQ();
|
||||||
mamPrefIQ.setStanzaId("sarasa");
|
mamPrefIQ.setStanzaId("sarasa");
|
||||||
Assert.assertEquals(mamPrefIQ.toXML(null).toString(), retrievePrefsStanzaExample);
|
Assert.assertEquals(mamPrefIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), retrievePrefsStanzaExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -55,7 +57,7 @@ public class PreferencesTest {
|
||||||
|
|
||||||
MamPrefsIQ mamPrefIQ = new MamPrefsIQ(alwaysJids, neverJids, DefaultBehavior.roster);
|
MamPrefsIQ mamPrefIQ = new MamPrefsIQ(alwaysJids, neverJids, DefaultBehavior.roster);
|
||||||
mamPrefIQ.setStanzaId("sarasa");
|
mamPrefIQ.setStanzaId("sarasa");
|
||||||
Assert.assertEquals(mamPrefIQ.toXML(null).toString(), updatePrefsStanzaExample);
|
Assert.assertEquals(mamPrefIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), updatePrefsStanzaExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.TimeZone;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.Message.Type;
|
import org.jivesoftware.smack.packet.Message.Type;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||||
|
@ -45,7 +46,7 @@ public class QueryArchiveTest extends MamTest {
|
||||||
+ "<result xmlns='urn:xmpp:mam:1' queryid='g27' id='34482-21985-73620'>"
|
+ "<result xmlns='urn:xmpp:mam:1' queryid='g27' id='34482-21985-73620'>"
|
||||||
+ "<forwarded xmlns='urn:xmpp:forward:0'>"
|
+ "<forwarded xmlns='urn:xmpp:forward:0'>"
|
||||||
+ "<delay xmlns='urn:xmpp:delay' stamp='2002-10-13T23:58:37.000+00:00'></delay>" + "<message "
|
+ "<delay xmlns='urn:xmpp:delay' stamp='2002-10-13T23:58:37.000+00:00'></delay>" + "<message "
|
||||||
+ "from='coven@chat.shakespeare.lit/firstwitch' " + "id='162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2' "
|
+ "xmlns='jabber:client' from='coven@chat.shakespeare.lit/firstwitch' " + "id='162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2' "
|
||||||
+ "type='chat'>" + "<body>Thrice the brinded cat hath mew.</body>" + "</message>" + "</forwarded>"
|
+ "type='chat'>" + "<body>Thrice the brinded cat hath mew.</body>" + "</message>" + "</forwarded>"
|
||||||
+ "</result>" + "</message>";
|
+ "</result>" + "</message>";
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ public class QueryArchiveTest extends MamTest {
|
||||||
MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, dataForm);
|
MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, dataForm);
|
||||||
mamQueryIQ.setType(IQ.Type.set);
|
mamQueryIQ.setType(IQ.Type.set);
|
||||||
mamQueryIQ.setStanzaId("sarasa");
|
mamQueryIQ.setStanzaId("sarasa");
|
||||||
Assert.assertEquals(mamQueryIQ.toXML(null).toString(), mamSimpleQueryIQ);
|
Assert.assertEquals(mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), mamSimpleQueryIQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -80,7 +81,8 @@ public class QueryArchiveTest extends MamTest {
|
||||||
|
|
||||||
message.addExtension(new MamResultExtension("g27", "34482-21985-73620", forwarded));
|
message.addExtension(new MamResultExtension("g27", "34482-21985-73620", forwarded));
|
||||||
|
|
||||||
Assert.assertEquals(message.toXML(null).toString(), mamQueryResultExample);
|
// FIXME: The order of assertEquals is reversed, fix it by switching it.
|
||||||
|
Assert.assertEquals(message.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), mamQueryResultExample);
|
||||||
|
|
||||||
MamResultExtension mamResultExtension = MamResultExtension.from(message);
|
MamResultExtension mamResultExtension = MamResultExtension.from(message);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.jivesoftware.smackx.mam;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.mam.element.MamElements;
|
import org.jivesoftware.smackx.mam.element.MamElements;
|
||||||
import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
||||||
|
@ -46,7 +47,7 @@ public class ResultsLimitTest extends MamTest {
|
||||||
mamQueryIQ.setStanzaId("sarasa");
|
mamQueryIQ.setStanzaId("sarasa");
|
||||||
|
|
||||||
methodAddResultsLimit.invoke(mamManager, 10, mamQueryIQ);
|
methodAddResultsLimit.invoke(mamManager, 10, mamQueryIQ);
|
||||||
Assert.assertEquals(mamQueryIQ.toXML(null).toString(), resultsLimitStanza);
|
Assert.assertEquals(mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), resultsLimitStanza);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.mam.element.MamElements;
|
import org.jivesoftware.smackx.mam.element.MamElements;
|
||||||
import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
import org.jivesoftware.smackx.mam.element.MamQueryIQ;
|
||||||
import org.jivesoftware.smackx.xdata.FormField;
|
import org.jivesoftware.smackx.xdata.FormField;
|
||||||
|
@ -44,7 +46,7 @@ public class RetrieveFormFieldsTest extends MamTest {
|
||||||
MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId);
|
MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId);
|
||||||
mamQueryIQ.setStanzaId("sarasa");
|
mamQueryIQ.setStanzaId("sarasa");
|
||||||
|
|
||||||
Assert.assertEquals(mamQueryIQ.toXML(null).toString(), retrieveFormFieldStanza);
|
Assert.assertEquals(mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), retrieveFormFieldStanza);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -30,19 +30,19 @@ import org.jxmpp.jid.impl.JidCreate;
|
||||||
|
|
||||||
public class MUCLightAffiliationsChangeExtensionTest {
|
public class MUCLightAffiliationsChangeExtensionTest {
|
||||||
|
|
||||||
private static final String exampleMessageStanza = "<message " + "to='coven@muclight.shakespeare.lit' id='member1' type='groupchat'>"
|
private static final String exampleMessageStanza = "<message xmlns='jabber:client' to='coven@muclight.shakespeare.lit' id='member1' type='groupchat'>"
|
||||||
+ "<x xmlns='urn:xmpp:muclight:0#affiliations'>"
|
+ "<x xmlns='urn:xmpp:muclight:0#affiliations'>"
|
||||||
+ "<user affiliation='owner'>sarasa2@shakespeare.lit</user>"
|
+ "<user affiliation='owner'>sarasa2@shakespeare.lit</user>"
|
||||||
+ "<user affiliation='member'>sarasa1@shakespeare.lit</user>"
|
+ "<user affiliation='member'>sarasa1@shakespeare.lit</user>"
|
||||||
+ "<user affiliation='none'>sarasa3@shakespeare.lit</user>" + "</x>" + "</message>";
|
+ "<user affiliation='none'>sarasa3@shakespeare.lit</user>" + "</x>" + "</message>";
|
||||||
|
|
||||||
private static final String exampleMessageStanzaWithVersion = "<message "
|
private static final String exampleMessageStanzaWithVersion = "<message xmlns='jabber:client' "
|
||||||
+ "to='coven@muclight.shakespeare.lit' id='member1' type='groupchat'>"
|
+ "to='coven@muclight.shakespeare.lit' id='member1' type='groupchat'>"
|
||||||
+ "<x xmlns='urn:xmpp:muclight:0#affiliations'>" + "<version>qwerty</version>"
|
+ "<x xmlns='urn:xmpp:muclight:0#affiliations'>" + "<version>qwerty</version>"
|
||||||
+ "<user affiliation='member'>sarasa1@shakespeare.lit</user>"
|
+ "<user affiliation='member'>sarasa1@shakespeare.lit</user>"
|
||||||
+ "<user affiliation='none'>sarasa3@shakespeare.lit</user>" + "</x>" + "<body></body>" + "</message>";
|
+ "<user affiliation='none'>sarasa3@shakespeare.lit</user>" + "</x>" + "<body></body>" + "</message>";
|
||||||
|
|
||||||
private static final String exampleMessageStanzaWithPrevVersion = "<message "
|
private static final String exampleMessageStanzaWithPrevVersion = "<message xmlns='jabber:client' "
|
||||||
+ "to='coven@muclight.shakespeare.lit' id='member1' type='groupchat'>"
|
+ "to='coven@muclight.shakespeare.lit' id='member1' type='groupchat'>"
|
||||||
+ "<x xmlns='urn:xmpp:muclight:0#affiliations'>" + "<prev-version>njiokm</prev-version>"
|
+ "<x xmlns='urn:xmpp:muclight:0#affiliations'>" + "<prev-version>njiokm</prev-version>"
|
||||||
+ "<version>qwerty</version>" + "<user affiliation='owner'>sarasa2@shakespeare.lit</user>"
|
+ "<version>qwerty</version>" + "<user affiliation='owner'>sarasa2@shakespeare.lit</user>"
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.util.HashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.IQ.Type;
|
import org.jivesoftware.smack.packet.IQ.Type;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ;
|
import org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ;
|
||||||
|
@ -61,7 +62,7 @@ public class MUCLightBlockingTest {
|
||||||
mucLightBlockingIQ.setStanzaId("getblock1");
|
mucLightBlockingIQ.setStanzaId("getblock1");
|
||||||
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
||||||
|
|
||||||
Assert.assertEquals(getBlockingListIQExample, mucLightBlockingIQ.toXML(null).toString());
|
Assert.assertEquals(getBlockingListIQExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -88,7 +89,7 @@ public class MUCLightBlockingTest {
|
||||||
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
||||||
mucLightBlockingIQ.setStanzaId("block1");
|
mucLightBlockingIQ.setStanzaId("block1");
|
||||||
|
|
||||||
Assert.assertEquals(blockingRoomsIQExample, mucLightBlockingIQ.toXML(null).toString());
|
Assert.assertEquals(blockingRoomsIQExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -102,7 +103,7 @@ public class MUCLightBlockingTest {
|
||||||
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
||||||
mucLightBlockingIQ.setStanzaId("block2");
|
mucLightBlockingIQ.setStanzaId("block2");
|
||||||
|
|
||||||
Assert.assertEquals(blockingUsersIQExample, mucLightBlockingIQ.toXML(null).toString());
|
Assert.assertEquals(blockingUsersIQExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -118,7 +119,7 @@ public class MUCLightBlockingTest {
|
||||||
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
|
||||||
mucLightBlockingIQ.setStanzaId("unblock1");
|
mucLightBlockingIQ.setStanzaId("unblock1");
|
||||||
|
|
||||||
Assert.assertEquals(unblockingUsersAndRoomsExample, mucLightBlockingIQ.toXML(null).toString());
|
Assert.assertEquals(unblockingUsersAndRoomsExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,16 +26,16 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class MUCLightConfigurationsChangeExtensionTest {
|
public class MUCLightConfigurationsChangeExtensionTest {
|
||||||
|
|
||||||
private static final String messageWithSubjectChangeExample = "<message to='crone1@shakespeare.lit' from='coven@muclight.shakespeare.lit' id='newsubject' type='groupchat'>"
|
private static final String messageWithSubjectChangeExample = "<message xmlns='jabber:client' to='crone1@shakespeare.lit' from='coven@muclight.shakespeare.lit' id='newsubject' type='groupchat'>"
|
||||||
+ "<body></body>" + "<x xmlns='urn:xmpp:muclight:0#configuration'>"
|
+ "<body></body>" + "<x xmlns='urn:xmpp:muclight:0#configuration'>"
|
||||||
+ "<prev-version>asdfghj000</prev-version>" + "<version>asdfghj</version>"
|
+ "<prev-version>asdfghj000</prev-version>" + "<version>asdfghj</version>"
|
||||||
+ "<subject>To be or not to be?</subject>" + "</x>" + "</message>";
|
+ "<subject>To be or not to be?</subject>" + "</x>" + "</message>";
|
||||||
|
|
||||||
private static final String messageWithRoomNameChangeExample = "<message to='crone1@shakespeare.lit' from='coven@muclight.shakespeare.lit' id='newsubject' type='groupchat'>"
|
private static final String messageWithRoomNameChangeExample = "<message xmlns='jabber:client' to='crone1@shakespeare.lit' from='coven@muclight.shakespeare.lit' id='newsubject' type='groupchat'>"
|
||||||
+ "<body></body>" + "<x xmlns='urn:xmpp:muclight:0#configuration'>" + "<prev-version>zaqwsx</prev-version>"
|
+ "<body></body>" + "<x xmlns='urn:xmpp:muclight:0#configuration'>" + "<prev-version>zaqwsx</prev-version>"
|
||||||
+ "<version>zxcvbnm</version>" + "<roomname>A Darker Cave</roomname>" + "</x>" + "</message>";
|
+ "<version>zxcvbnm</version>" + "<roomname>A Darker Cave</roomname>" + "</x>" + "</message>";
|
||||||
|
|
||||||
private static final String messageWithConfigsChangeExample = "<message to='crone1@shakespeare.lit' from='coven@muclight.shakespeare.lit' id='newsubject' type='groupchat'>"
|
private static final String messageWithConfigsChangeExample = "<message xmlns='jabber:client' to='crone1@shakespeare.lit' from='coven@muclight.shakespeare.lit' id='newsubject' type='groupchat'>"
|
||||||
+ "<body></body>" + "<x xmlns='urn:xmpp:muclight:0#configuration'>" + "<prev-version>zaqwsx</prev-version>"
|
+ "<body></body>" + "<x xmlns='urn:xmpp:muclight:0#configuration'>" + "<prev-version>zaqwsx</prev-version>"
|
||||||
+ "<version>zxcvbnm</version>" + "<roomname>A Darker Cave</roomname>" + "<color>blue</color>" + "</x>"
|
+ "<version>zxcvbnm</version>" + "<roomname>A Darker Cave</roomname>" + "<color>blue</color>" + "</x>"
|
||||||
+ "</message>";
|
+ "</message>";
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.muclight;
|
package org.jivesoftware.smackx.muclight;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.muclight.element.MUCLightDestroyIQ;
|
import org.jivesoftware.smackx.muclight.element.MUCLightDestroyIQ;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -31,7 +33,7 @@ public class MUCLightDestroyTest {
|
||||||
public void checkDestroyMUCLightStanza() throws Exception {
|
public void checkDestroyMUCLightStanza() throws Exception {
|
||||||
MUCLightDestroyIQ mucLightDestroyIQ = new MUCLightDestroyIQ(JidCreate.from("coven@muclight.shakespeare.lit"));
|
MUCLightDestroyIQ mucLightDestroyIQ = new MUCLightDestroyIQ(JidCreate.from("coven@muclight.shakespeare.lit"));
|
||||||
mucLightDestroyIQ.setStanzaId("destroy1");
|
mucLightDestroyIQ.setStanzaId("destroy1");
|
||||||
Assert.assertEquals(mucLightDestroyIQ.toXML(null).toString(), stanza);
|
Assert.assertEquals(mucLightDestroyIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), stanza);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.jivesoftware.smackx.muclight;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.muclight.element.MUCLightAffiliationsIQ;
|
import org.jivesoftware.smackx.muclight.element.MUCLightAffiliationsIQ;
|
||||||
|
@ -45,7 +46,7 @@ public class MUCLightGetAffiliationsTest {
|
||||||
MUCLightGetAffiliationsIQ mucLightGetAffiliationsIQ = new MUCLightGetAffiliationsIQ(
|
MUCLightGetAffiliationsIQ mucLightGetAffiliationsIQ = new MUCLightGetAffiliationsIQ(
|
||||||
JidCreate.from("coven@muclight.shakespeare.lit"), "abcdefg");
|
JidCreate.from("coven@muclight.shakespeare.lit"), "abcdefg");
|
||||||
mucLightGetAffiliationsIQ.setStanzaId("getmembers");
|
mucLightGetAffiliationsIQ.setStanzaId("getmembers");
|
||||||
Assert.assertEquals(getAffiliationsIQExample, mucLightGetAffiliationsIQ.toXML(null).toString());
|
Assert.assertEquals(getAffiliationsIQExample, mucLightGetAffiliationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.jivesoftware.smackx.muclight;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ;
|
import org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ;
|
||||||
|
@ -48,7 +49,7 @@ public class MUCLightGetConfigsTest {
|
||||||
MUCLightGetConfigsIQ mucLightGetConfigsIQ = new MUCLightGetConfigsIQ(
|
MUCLightGetConfigsIQ mucLightGetConfigsIQ = new MUCLightGetConfigsIQ(
|
||||||
JidCreate.from("coven@muclight.shakespeare.lit"), "abcdefg");
|
JidCreate.from("coven@muclight.shakespeare.lit"), "abcdefg");
|
||||||
mucLightGetConfigsIQ.setStanzaId("config0");
|
mucLightGetConfigsIQ.setStanzaId("config0");
|
||||||
Assert.assertEquals(getConfigsIQExample, mucLightGetConfigsIQ.toXML(null).toString());
|
Assert.assertEquals(getConfigsIQExample, mucLightGetConfigsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.jivesoftware.smackx.muclight;
|
package org.jivesoftware.smackx.muclight;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.muclight.element.MUCLightGetInfoIQ;
|
import org.jivesoftware.smackx.muclight.element.MUCLightGetInfoIQ;
|
||||||
|
@ -45,7 +46,7 @@ public class MUCLightInfoTest {
|
||||||
MUCLightGetInfoIQ mucLightGetInfoIQWithVersion = new MUCLightGetInfoIQ(
|
MUCLightGetInfoIQ mucLightGetInfoIQWithVersion = new MUCLightGetInfoIQ(
|
||||||
JidCreate.from("coven@muclight.shakespeare.lit"), "abcdefg");
|
JidCreate.from("coven@muclight.shakespeare.lit"), "abcdefg");
|
||||||
mucLightGetInfoIQWithVersion.setStanzaId("getinfo1");
|
mucLightGetInfoIQWithVersion.setStanzaId("getinfo1");
|
||||||
Assert.assertEquals(mucLightGetInfoIQWithVersion.toXML(null).toString(), exampleWithVersion);
|
Assert.assertEquals(mucLightGetInfoIQWithVersion.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), exampleWithVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -53,7 +54,7 @@ public class MUCLightInfoTest {
|
||||||
MUCLightGetInfoIQ mucLightGetInfoIQWithoutVersion = new MUCLightGetInfoIQ(
|
MUCLightGetInfoIQ mucLightGetInfoIQWithoutVersion = new MUCLightGetInfoIQ(
|
||||||
JidCreate.from("coven@muclight.shakespeare.lit"), null);
|
JidCreate.from("coven@muclight.shakespeare.lit"), null);
|
||||||
mucLightGetInfoIQWithoutVersion.setStanzaId("getinfo1");
|
mucLightGetInfoIQWithoutVersion.setStanzaId("getinfo1");
|
||||||
Assert.assertEquals(mucLightGetInfoIQWithoutVersion.toXML(null).toString(), exampleWithoutVersion);
|
Assert.assertEquals(mucLightGetInfoIQWithoutVersion.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), exampleWithoutVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.muclight;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.muclight.element.MUCLightSetConfigsIQ;
|
import org.jivesoftware.smackx.muclight.element.MUCLightSetConfigsIQ;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -47,7 +49,7 @@ public class MUCLightSetConfigsIQTest {
|
||||||
JidCreate.from("coven@muclight.shakespeare.lit"), "A Darker Cave", customConfigs);
|
JidCreate.from("coven@muclight.shakespeare.lit"), "A Darker Cave", customConfigs);
|
||||||
mucLightSetConfigsIQ.setStanzaId("conf1");
|
mucLightSetConfigsIQ.setStanzaId("conf1");
|
||||||
|
|
||||||
Assert.assertEquals(setConfigsIQExample, mucLightSetConfigsIQ.toXML(null).toString());
|
Assert.assertEquals(setConfigsIQExample, mucLightSetConfigsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -56,7 +58,7 @@ public class MUCLightSetConfigsIQTest {
|
||||||
JidCreate.from("coven@muclight.shakespeare.lit"), "A Darker Cave", null);
|
JidCreate.from("coven@muclight.shakespeare.lit"), "A Darker Cave", null);
|
||||||
mucLightChangeRoomNameIQ.setStanzaId("roomName1");
|
mucLightChangeRoomNameIQ.setStanzaId("roomName1");
|
||||||
|
|
||||||
Assert.assertEquals(changeRoomNameIQExample, mucLightChangeRoomNameIQ.toXML(null).toString());
|
Assert.assertEquals(changeRoomNameIQExample, mucLightChangeRoomNameIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -65,7 +67,7 @@ public class MUCLightSetConfigsIQTest {
|
||||||
JidCreate.from("coven@muclight.shakespeare.lit"), null, "To be or not to be?", null);
|
JidCreate.from("coven@muclight.shakespeare.lit"), null, "To be or not to be?", null);
|
||||||
mucLightChangeSubjectIQ.setStanzaId("subject1");
|
mucLightChangeSubjectIQ.setStanzaId("subject1");
|
||||||
|
|
||||||
Assert.assertEquals(changeSubjectIQExample, mucLightChangeSubjectIQ.toXML(null).toString());
|
Assert.assertEquals(changeSubjectIQExample, mucLightChangeSubjectIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.push_notifications;
|
package org.jivesoftware.smackx.push_notifications;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.push_notifications.element.DisablePushNotificationsIQ;
|
import org.jivesoftware.smackx.push_notifications.element.DisablePushNotificationsIQ;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -36,7 +38,7 @@ public class DisablePushNotificationsIQTest {
|
||||||
DisablePushNotificationsIQ disablePushNotificationsIQ = new DisablePushNotificationsIQ(
|
DisablePushNotificationsIQ disablePushNotificationsIQ = new DisablePushNotificationsIQ(
|
||||||
JidCreate.from("push-5.client.example"));
|
JidCreate.from("push-5.client.example"));
|
||||||
disablePushNotificationsIQ.setStanzaId("x97");
|
disablePushNotificationsIQ.setStanzaId("x97");
|
||||||
Assert.assertEquals(disableAllNotificationsIQExample, disablePushNotificationsIQ.toXML(null).toString());
|
Assert.assertEquals(disableAllNotificationsIQExample, disablePushNotificationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -44,7 +46,7 @@ public class DisablePushNotificationsIQTest {
|
||||||
DisablePushNotificationsIQ disablePushNotificationsIQ = new DisablePushNotificationsIQ(
|
DisablePushNotificationsIQ disablePushNotificationsIQ = new DisablePushNotificationsIQ(
|
||||||
JidCreate.from("push-5.client.example"), "yxs32uqsflafdk3iuqo");
|
JidCreate.from("push-5.client.example"), "yxs32uqsflafdk3iuqo");
|
||||||
disablePushNotificationsIQ.setStanzaId("x97");
|
disablePushNotificationsIQ.setStanzaId("x97");
|
||||||
Assert.assertEquals(disableNodeNotificationsIQExample, disablePushNotificationsIQ.toXML(null).toString());
|
Assert.assertEquals(disableNodeNotificationsIQExample, disablePushNotificationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.push_notifications;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.push_notifications.element.EnablePushNotificationsIQ;
|
import org.jivesoftware.smackx.push_notifications.element.EnablePushNotificationsIQ;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -41,7 +43,7 @@ public class EnablePushNotificationsIQTest {
|
||||||
EnablePushNotificationsIQ enablePushNotificationsIQ = new EnablePushNotificationsIQ(
|
EnablePushNotificationsIQ enablePushNotificationsIQ = new EnablePushNotificationsIQ(
|
||||||
JidCreate.from("push-5.client.example"), "yxs32uqsflafdk3iuqo");
|
JidCreate.from("push-5.client.example"), "yxs32uqsflafdk3iuqo");
|
||||||
enablePushNotificationsIQ.setStanzaId("x42");
|
enablePushNotificationsIQ.setStanzaId("x42");
|
||||||
Assert.assertEquals(exampleEnableIQ, enablePushNotificationsIQ.toXML(null).toString());
|
Assert.assertEquals(exampleEnableIQ, enablePushNotificationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -53,7 +55,7 @@ public class EnablePushNotificationsIQTest {
|
||||||
JidCreate.from("push-5.client.example"), "yxs32uqsflafdk3iuqo", publishOptions);
|
JidCreate.from("push-5.client.example"), "yxs32uqsflafdk3iuqo", publishOptions);
|
||||||
enablePushNotificationsIQ.setStanzaId("x42");
|
enablePushNotificationsIQ.setStanzaId("x42");
|
||||||
|
|
||||||
Assert.assertEquals(exampleEnableIQWithPublishOptions, enablePushNotificationsIQ.toXML(null).toString());
|
Assert.assertEquals(exampleEnableIQWithPublishOptions, enablePushNotificationsIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,10 @@ import org.jxmpp.jid.impl.JidCreate;
|
||||||
|
|
||||||
public class BlockContactsIQTest {
|
public class BlockContactsIQTest {
|
||||||
|
|
||||||
private static final String blockContactIQExample = "<iq id='block1' type='set'>" + "<block xmlns='urn:xmpp:blocking'>"
|
private static final String blockContactIQExample = "<iq xmlns='jabber:client' id='block1' type='set'>" + "<block xmlns='urn:xmpp:blocking'>"
|
||||||
+ "<item jid='romeo@montague.net'/>" + "<item jid='pepe@montague.net'/>" + "</block>" + "</iq>";
|
+ "<item jid='romeo@montague.net'/>" + "<item jid='pepe@montague.net'/>" + "</block>" + "</iq>";
|
||||||
|
|
||||||
private static final String blockContactPushIQExample = "<iq to='juliet@capulet.com/chamber' type='set' id='push1'>"
|
private static final String blockContactPushIQExample = "<iq xmlns='jabber:client' to='juliet@capulet.com/chamber' type='set' id='push1'>"
|
||||||
+ "<block xmlns='urn:xmpp:blocking'>" + "<item jid='romeo@montague.net'/>"
|
+ "<block xmlns='urn:xmpp:blocking'>" + "<item jid='romeo@montague.net'/>"
|
||||||
+ "<item jid='pepe@montague.net'/>" + "</block>" + "</iq>";
|
+ "<item jid='pepe@montague.net'/>" + "</block>" + "</iq>";
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.jivesoftware.smackx.blocking;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.IQ.Type;
|
import org.jivesoftware.smack.packet.IQ.Type;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.blocking.element.BlockListIQ;
|
import org.jivesoftware.smackx.blocking.element.BlockListIQ;
|
||||||
|
@ -42,7 +43,7 @@ public class GetBlockingListTest {
|
||||||
BlockListIQ getBlockListIQ = new BlockListIQ(null);
|
BlockListIQ getBlockListIQ = new BlockListIQ(null);
|
||||||
getBlockListIQ.setType(Type.get);
|
getBlockListIQ.setType(Type.get);
|
||||||
getBlockListIQ.setStanzaId("blocklist1");
|
getBlockListIQ.setStanzaId("blocklist1");
|
||||||
Assert.assertEquals(getBlockingListIQExample, getBlockListIQ.toXML(null).toString());
|
Assert.assertEquals(getBlockingListIQExample, getBlockListIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.blocking.element.UnblockContactsIQ;
|
import org.jivesoftware.smackx.blocking.element.UnblockContactsIQ;
|
||||||
|
@ -53,7 +54,7 @@ public class UnblockContactsIQTest {
|
||||||
UnblockContactsIQ unblockContactIQ = new UnblockContactsIQ(jids);
|
UnblockContactsIQ unblockContactIQ = new UnblockContactsIQ(jids);
|
||||||
unblockContactIQ.setStanzaId("unblock1");
|
unblockContactIQ.setStanzaId("unblock1");
|
||||||
|
|
||||||
Assert.assertEquals(unblockContactIQExample, unblockContactIQ.toXML(null).toString());
|
Assert.assertEquals(unblockContactIQExample, unblockContactIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -68,7 +69,7 @@ public class UnblockContactsIQTest {
|
||||||
public void checkUnblockAllIQStanza() throws Exception {
|
public void checkUnblockAllIQStanza() throws Exception {
|
||||||
UnblockContactsIQ unblockAllIQ = new UnblockContactsIQ(null);
|
UnblockContactsIQ unblockAllIQ = new UnblockContactsIQ(null);
|
||||||
unblockAllIQ.setStanzaId("unblock2");
|
unblockAllIQ.setStanzaId("unblock2");
|
||||||
Assert.assertEquals(unblockAllIQExample, unblockAllIQ.toXML(null).toString());
|
Assert.assertEquals(unblockAllIQExample, unblockAllIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.jivesoftware.smackx.bob;
|
package org.jivesoftware.smackx.bob;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ.Type;
|
import org.jivesoftware.smack.packet.IQ.Type;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
@ -45,7 +46,7 @@ public class BoBIQTest extends SmackTestSuite {
|
||||||
createdBoBIQ.setTo(JidCreate.from("ladymacbeth@shakespeare.lit/castle"));
|
createdBoBIQ.setTo(JidCreate.from("ladymacbeth@shakespeare.lit/castle"));
|
||||||
createdBoBIQ.setType(Type.get);
|
createdBoBIQ.setType(Type.get);
|
||||||
|
|
||||||
Assert.assertEquals(sampleBoBIQRequest, createdBoBIQ.toXML(null).toString());
|
Assert.assertEquals(sampleBoBIQRequest, createdBoBIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -65,7 +66,7 @@ public class BoBIQTest extends SmackTestSuite {
|
||||||
Assert.assertEquals(bobIQ.getBoBData().getMaxAge(), createdBoBIQ.getBoBData().getMaxAge());
|
Assert.assertEquals(bobIQ.getBoBData().getMaxAge(), createdBoBIQ.getBoBData().getMaxAge());
|
||||||
Assert.assertEquals(bobIQ.getBoBData().getType(), createdBoBIQ.getBoBData().getType());
|
Assert.assertEquals(bobIQ.getBoBData().getType(), createdBoBIQ.getBoBData().getType());
|
||||||
Assert.assertEquals(bobIQ.getBoBData().getContentBase64Encoded(), createdBoBIQ.getBoBData().getContentBase64Encoded());
|
Assert.assertEquals(bobIQ.getBoBData().getContentBase64Encoded(), createdBoBIQ.getBoBData().getContentBase64Encoded());
|
||||||
Assert.assertEquals(bobIQ.toXML(null).toString(), createdBoBIQ.toXML(null).toString());
|
Assert.assertEquals(bobIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), createdBoBIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.InitExtensions;
|
import org.jivesoftware.smackx.InitExtensions;
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ public class CloseTest extends InitExtensions {
|
||||||
close.setTo(JidCreate.from("juliet@capulet.lit/balcony"));
|
close.setTo(JidCreate.from("juliet@capulet.lit/balcony"));
|
||||||
close.setStanzaId("us71g45j");
|
close.setStanzaId("us71g45j");
|
||||||
|
|
||||||
assertXMLEqual(control, close.toXML(null).toString());
|
assertXMLEqual(control, close.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.mockito.Mockito.mock;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.InitExtensions;
|
import org.jivesoftware.smackx.InitExtensions;
|
||||||
|
@ -77,7 +78,7 @@ public class DataTest extends InitExtensions {
|
||||||
data.setTo(JidCreate.from("juliet@capulet.lit/balcony"));
|
data.setTo(JidCreate.from("juliet@capulet.lit/balcony"));
|
||||||
data.setStanzaId("kr91n475");
|
data.setStanzaId("kr91n475");
|
||||||
|
|
||||||
assertXMLEqual(control, data.toXML(null).toString());
|
assertXMLEqual(control, data.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.InitExtensions;
|
import org.jivesoftware.smackx.InitExtensions;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
||||||
|
@ -102,7 +103,7 @@ public class OpenTest extends InitExtensions {
|
||||||
open.setTo(JidCreate.from("juliet@capulet.lit/balcony"));
|
open.setTo(JidCreate.from("juliet@capulet.lit/balcony"));
|
||||||
open.setStanzaId("jn3h8g65");
|
open.setStanzaId("jn3h8g65");
|
||||||
|
|
||||||
assertXMLEqual(control, open.toXML(null).toString());
|
assertXMLEqual(control, open.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014 Florian Schmaus
|
* Copyright 2014-2018 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -44,7 +44,7 @@ public class JivePropertiesExtensionTest extends InitExtensions {
|
||||||
@Test
|
@Test
|
||||||
public void checkProvider() throws Exception {
|
public void checkProvider() throws Exception {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
String properties = "<message from='romeo@example.net/orchard' to='juliet@example.com/balcony'>"
|
String properties = "<message xmlns='jabber:client' from='romeo@example.net/orchard' to='juliet@example.com/balcony'>"
|
||||||
+ "<body>Neither, fair saint, if either thee dislike.</body>"
|
+ "<body>Neither, fair saint, if either thee dislike.</body>"
|
||||||
+ "<properties xmlns='http://www.jivesoftware.com/xmlns/xmpp/properties'>"
|
+ "<properties xmlns='http://www.jivesoftware.com/xmlns/xmpp/properties'>"
|
||||||
+ "<property>"
|
+ "<property>"
|
||||||
|
|
|
@ -28,12 +28,12 @@ public class MessageCorrectExtensionTest {
|
||||||
|
|
||||||
private static final String idInitialMessage = "bad1";
|
private static final String idInitialMessage = "bad1";
|
||||||
|
|
||||||
private static final String initialMessageXml = "<message to='juliet@capulet.net/balcony' id='good1'>"
|
private static final String initialMessageXml = "<message xmlns='jabber:client' to='juliet@capulet.net/balcony' id='good1'>"
|
||||||
+ "<body>But soft, what light through yonder window breaks?</body>" + "</message>";
|
+ "<body>But soft, what light through yonder window breaks?</body>" + "</message>";
|
||||||
|
|
||||||
private static final CharSequence messageCorrectionXml = "<replace xmlns='urn:xmpp:message-correct:0' id='bad1'/>";
|
private static final CharSequence messageCorrectionXml = "<replace xmlns='urn:xmpp:message-correct:0' id='bad1'/>";
|
||||||
|
|
||||||
private static final CharSequence expectedXml = "<message to='juliet@capulet.net/balcony' id='good1'>"
|
private static final CharSequence expectedXml = "<message xmlns='jabber:client' to='juliet@capulet.net/balcony' id='good1'>"
|
||||||
+ "<body>But soft, what light through yonder window breaks?</body>"
|
+ "<body>But soft, what light through yonder window breaks?</body>"
|
||||||
+ "<replace xmlns='urn:xmpp:message-correct:0' id='bad1'/>" + "</message>";
|
+ "<replace xmlns='urn:xmpp:message-correct:0' id='bad1'/>" + "</message>";
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014 Florian Schmaus
|
* Copyright 2014-2018 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -34,7 +34,7 @@ public class HeadersProviderTest {
|
||||||
public void headersInMessageTest() throws Exception {
|
public void headersInMessageTest() throws Exception {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
final String messageStanza =
|
final String messageStanza =
|
||||||
"<message from='romeo@shakespeare.lit/orchard' to='juliet@capulet.com' type='chat'>" +
|
"<message xmlns='jabber:client' from='romeo@shakespeare.lit/orchard' to='juliet@capulet.com' type='chat'>" +
|
||||||
"<body>Wherefore are thou?!?</body>" +
|
"<body>Wherefore are thou?!?</body>" +
|
||||||
"<headers xmlns='http://jabber.org/protocol/shim'>" +
|
"<headers xmlns='http://jabber.org/protocol/shim'>" +
|
||||||
"<header name='Urgency'>high</header>" +
|
"<header name='Urgency'>high</header>" +
|
||||||
|
|
Loading…
Reference in a new issue