summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'test/com/isode/stroke/serializer')
-rw-r--r--test/com/isode/stroke/serializer/payloadserializers/DeliveryReceiptSerializerTest.java44
-rw-r--r--test/com/isode/stroke/serializer/payloadserializers/DiscoInfoSerializerTest.java71
-rw-r--r--test/com/isode/stroke/serializer/payloadserializers/ReplaceSerializerTest.java41
-rw-r--r--test/com/isode/stroke/serializer/payloadserializers/ResourceBindSerializerTest.java60
-rw-r--r--test/com/isode/stroke/serializer/payloadserializers/SecurityLabelSerializerTest.java67
-rw-r--r--test/com/isode/stroke/serializer/payloadserializers/SecurityLabelsCatalogSerializerTest.java81
-rw-r--r--test/com/isode/stroke/serializer/payloadserializers/SoftwareVersionSerializerTest.java35
-rw-r--r--test/com/isode/stroke/serializer/payloadserializers/StatusSerializerTest.java37
-rw-r--r--test/com/isode/stroke/serializer/payloadserializers/StatusShowSerializerTest.java71
-rw-r--r--test/com/isode/stroke/serializer/payloadserializers/VCardSerializerTest.java151
10 files changed, 658 insertions, 0 deletions
diff --git a/test/com/isode/stroke/serializer/payloadserializers/DeliveryReceiptSerializerTest.java b/test/com/isode/stroke/serializer/payloadserializers/DeliveryReceiptSerializerTest.java
new file mode 100644
index 0000000..9115bd6
--- /dev/null
+++ b/test/com/isode/stroke/serializer/payloadserializers/DeliveryReceiptSerializerTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import com.isode.stroke.serializer.payloadserializers.DeliveryReceiptRequestSerializer;
+import com.isode.stroke.serializer.payloadserializers.DeliveryReceiptSerializer;
+import com.isode.stroke.elements.DeliveryReceiptRequest;
+import com.isode.stroke.elements.DeliveryReceipt;
+
+public class DeliveryReceiptSerializerTest {
+
+ /**
+ * Default Constructor.
+ */
+ public DeliveryReceiptSerializerTest() {
+
+ }
+
+ @Test
+ public void testSerialize_XEP0184Example3() {
+ String expected = "<request xmlns=\"urn:xmpp:receipts\"/>";
+
+ DeliveryReceiptRequest receipt = new DeliveryReceiptRequest();
+
+ DeliveryReceiptRequestSerializer serializer = new DeliveryReceiptRequestSerializer();
+ assertEquals(expected, serializer.serializePayload(receipt));
+ }
+
+ @Test
+ public void testSerialize_XEP0184Example4() {
+ String expected = "<received id=\"richard2-4.1.247\" xmlns=\"urn:xmpp:receipts\"/>";
+
+ DeliveryReceipt receipt = new DeliveryReceipt("richard2-4.1.247");
+
+ DeliveryReceiptSerializer serializer = new DeliveryReceiptSerializer();
+ assertEquals(expected, serializer.serializePayload(receipt));
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/serializer/payloadserializers/DiscoInfoSerializerTest.java b/test/com/isode/stroke/serializer/payloadserializers/DiscoInfoSerializerTest.java
new file mode 100644
index 0000000..7ae9778
--- /dev/null
+++ b/test/com/isode/stroke/serializer/payloadserializers/DiscoInfoSerializerTest.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import com.isode.stroke.serializer.payloadserializers.DiscoInfoSerializer;
+import com.isode.stroke.elements.DiscoInfo;
+import com.isode.stroke.elements.Form;
+
+public class DiscoInfoSerializerTest {
+
+ /**
+ * Default Constructor.
+ */
+ public DiscoInfoSerializerTest() {
+
+ }
+
+ @Test
+ public void testSerialize() {
+ DiscoInfoSerializer testling = new DiscoInfoSerializer();
+ DiscoInfo discoInfo = new DiscoInfo();
+ discoInfo.addIdentity(new DiscoInfo.Identity("Swift", "client", "pc"));
+ discoInfo.addIdentity(new DiscoInfo.Identity("Vlug", "client", "pc", "nl"));
+ discoInfo.addFeature("http://jabber.org/protocol/caps");
+ discoInfo.addFeature("http://jabber.org/protocol/disco#info");
+ discoInfo.setNode("http://swift.im#bla");
+
+ String expectedResult =
+ "<query node=\"http://swift.im#bla\" xmlns=\"http://jabber.org/protocol/disco#info\">" +
+ "<identity category=\"client\" name=\"Swift\" type=\"pc\"/>" +
+ "<identity category=\"client\" name=\"Vlug\" type=\"pc\" xml:lang=\"nl\"/>" +
+ "<feature var=\"http://jabber.org/protocol/caps\"/>" +
+ "<feature var=\"http://jabber.org/protocol/disco#info\"/>" +
+ "</query>";
+
+ assertEquals(expectedResult, testling.serialize(discoInfo));
+ }
+
+ @Test
+ public void testSerialize_Form() {
+ DiscoInfoSerializer testling = new DiscoInfoSerializer();
+ DiscoInfo discoInfo = new DiscoInfo();
+ discoInfo.addFeature("http://jabber.org/protocol/caps");
+ discoInfo.addFeature("http://jabber.org/protocol/disco#info");
+ Form form = new Form(Form.Type.FORM_TYPE);
+ form.setTitle("Bot Configuration");
+ discoInfo.addExtension(form);
+
+ String expectedResult =
+ "<query xmlns=\"http://jabber.org/protocol/disco#info\">" +
+ "<feature var=\"http://jabber.org/protocol/caps\"/>" +
+ "<feature var=\"http://jabber.org/protocol/disco#info\"/>" +
+ "<x type=\"form\" xmlns=\"jabber:x:data\">" +
+ "<title>Bot Configuration</title>" +
+ "</x>" +
+ "</query>";
+
+ assertEquals(expectedResult, testling.serialize(discoInfo));
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/serializer/payloadserializers/ReplaceSerializerTest.java b/test/com/isode/stroke/serializer/payloadserializers/ReplaceSerializerTest.java
new file mode 100644
index 0000000..8ee7469
--- /dev/null
+++ b/test/com/isode/stroke/serializer/payloadserializers/ReplaceSerializerTest.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011 Vlad Voicu
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+/*
+ * Copyright (c) 2012 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import com.isode.stroke.serializer.payloadserializers.ReplaceSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.elements.Replace;
+
+public class ReplaceSerializerTest {
+
+ /**
+ * Default Constructor.
+ */
+ public ReplaceSerializerTest() {
+
+ }
+
+ @Test
+ public void testSerialize() {
+ ReplaceSerializer testling = new ReplaceSerializer();
+ Replace replace = new Replace();
+ replace.setID("bad1");
+ assertEquals("<replace id = 'bad1' xmlns='urn:xmpp:message-correct:0'/>", testling.serialize(replace));
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/serializer/payloadserializers/ResourceBindSerializerTest.java b/test/com/isode/stroke/serializer/payloadserializers/ResourceBindSerializerTest.java
new file mode 100644
index 0000000..16a9ed2
--- /dev/null
+++ b/test/com/isode/stroke/serializer/payloadserializers/ResourceBindSerializerTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import com.isode.stroke.serializer.payloadserializers.ResourceBindSerializer;
+import com.isode.stroke.elements.ResourceBind;
+import com.isode.stroke.jid.JID;
+
+public class ResourceBindSerializerTest {
+
+ /**
+ * Default Constructor.
+ */
+ public ResourceBindSerializerTest() {
+
+ }
+
+ @Test
+ public void testSerialize_JID() {
+ ResourceBindSerializer testling = new ResourceBindSerializer();
+ ResourceBind resourceBind = new ResourceBind();
+ resourceBind.setJID(new JID("somenode@example.com/someresource"));
+
+ assertEquals(
+ "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">" +
+ "<jid>somenode@example.com/someresource</jid>" +
+ "</bind>", testling.serialize(resourceBind));
+ }
+
+ @Test
+ public void testSerialize_Resource() {
+ ResourceBindSerializer testling = new ResourceBindSerializer();
+ ResourceBind resourceBind = new ResourceBind();
+ resourceBind.setResource("someresource");
+
+ assertEquals(
+ "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">" +
+ "<resource>someresource</resource>" +
+ "</bind>", testling.serialize(resourceBind));
+ }
+
+ @Test
+ public void testSerialize_Empty() {
+ ResourceBindSerializer testling = new ResourceBindSerializer();
+ ResourceBind resourceBind = new ResourceBind();
+
+ assertEquals("<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>", testling.serialize(resourceBind));
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/serializer/payloadserializers/SecurityLabelSerializerTest.java b/test/com/isode/stroke/serializer/payloadserializers/SecurityLabelSerializerTest.java
new file mode 100644
index 0000000..d9ddccb
--- /dev/null
+++ b/test/com/isode/stroke/serializer/payloadserializers/SecurityLabelSerializerTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import com.isode.stroke.serializer.payloadserializers.SecurityLabelSerializer;
+import com.isode.stroke.elements.SecurityLabel;
+
+public class SecurityLabelSerializerTest {
+
+ /**
+ * Default Constructor.
+ */
+ public SecurityLabelSerializerTest() {
+
+ }
+
+ @Test
+ public void testSerialize() {
+ SecurityLabelSerializer testling = new SecurityLabelSerializer();
+ SecurityLabel securityLabel = new SecurityLabel();
+ securityLabel.setDisplayMarking("SECRET");
+ securityLabel.setForegroundColor("black");
+ securityLabel.setBackgroundColor("red");
+ securityLabel.setLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>");
+ securityLabel.addEquivalentLabel("<icismlabel xmlns=\"http://example.gov/IC-ISM/0\" classification=\"S\" ownerProducer=\"USA\" disseminationControls=\"FOUO\"/>");
+ securityLabel.addEquivalentLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>");
+
+ assertEquals(
+ "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
+ + "<displaymarking bgcolor=\"red\" fgcolor=\"black\">SECRET</displaymarking>"
+ + "<label>"
+ + "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"
+ + "</label>"
+ + "<equivalentlabel>"
+ + "<icismlabel xmlns=\"http://example.gov/IC-ISM/0\" classification=\"S\" ownerProducer=\"USA\" disseminationControls=\"FOUO\"/>"
+ + "</equivalentlabel>"
+ + "<equivalentlabel>"
+ + "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>"
+ + "</equivalentlabel>"
+ + "</securitylabel>", testling.serialize(securityLabel));
+ }
+
+ @Test
+ public void testSerialize_EmptyLabel() {
+ SecurityLabelSerializer testling = new SecurityLabelSerializer();
+ SecurityLabel securityLabel = new SecurityLabel();
+ securityLabel.setDisplayMarking("SECRET");
+ securityLabel.setLabel("");
+
+ assertEquals(
+ "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
+ + "<displaymarking>SECRET</displaymarking>"
+ + "<label></label>"
+ + "</securitylabel>", testling.serialize(securityLabel));
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/serializer/payloadserializers/SecurityLabelsCatalogSerializerTest.java b/test/com/isode/stroke/serializer/payloadserializers/SecurityLabelsCatalogSerializerTest.java
new file mode 100644
index 0000000..d61cfab
--- /dev/null
+++ b/test/com/isode/stroke/serializer/payloadserializers/SecurityLabelsCatalogSerializerTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import com.isode.stroke.serializer.payloadserializers.SecurityLabelsCatalogSerializer;
+import com.isode.stroke.elements.SecurityLabelsCatalog;
+import com.isode.stroke.elements.SecurityLabel;
+import com.isode.stroke.jid.JID;
+
+public class SecurityLabelsCatalogSerializerTest {
+
+ /**
+ * Default Constructor.
+ */
+ public SecurityLabelsCatalogSerializerTest() {
+
+ }
+
+ @Test
+ public void testSerialize() {
+ SecurityLabelsCatalogSerializer testling = new SecurityLabelsCatalogSerializer();
+ SecurityLabelsCatalog catalog = new SecurityLabelsCatalog();
+ catalog.setTo(new JID("example.com"));
+ catalog.setName("Default");
+ catalog.setDescription("an example set of labels");
+
+ SecurityLabelsCatalog.Item item1 = new SecurityLabelsCatalog.Item();
+ SecurityLabel securityLabel1 = new SecurityLabel();
+ item1.setLabel(securityLabel1);
+ securityLabel1.setDisplayMarking("SECRET");
+ securityLabel1.setForegroundColor("black");
+ securityLabel1.setBackgroundColor("red");
+ item1.setIsDefault(false);
+ item1.setSelector("Classified|SECRET");
+ securityLabel1.setLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>");
+ catalog.addItem(item1);
+
+ SecurityLabelsCatalog.Item item2 = new SecurityLabelsCatalog.Item();
+ SecurityLabel securityLabel2 = new SecurityLabel();
+ item2.setLabel(securityLabel2);
+ securityLabel2.setDisplayMarking("CONFIDENTIAL");
+ securityLabel2.setForegroundColor("black");
+ securityLabel2.setBackgroundColor("navy");
+ item2.setIsDefault(true);
+ item2.setSelector("Classified|CONFIDENTIAL");
+ securityLabel2.setLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel>");
+ catalog.addItem(item2);
+
+ SecurityLabelsCatalog.Item item3 = new SecurityLabelsCatalog.Item();
+ item3.setSelector("Unclassified|UNCLASSIFIED");
+ catalog.addItem(item3);
+
+ assertEquals(
+ "<catalog desc=\"an example set of labels\" name=\"Default\" to=\"example.com\" xmlns=\"urn:xmpp:sec-label:catalog:2\">"
+ + "<item selector=\"Classified|SECRET\">"
+ + "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
+ + "<displaymarking bgcolor=\"red\" fgcolor=\"black\">SECRET</displaymarking>"
+ + "<label><esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel></label>"
+ + "</securitylabel>"
+ + "</item>"
+ + "<item default=\"true\" selector=\"Classified|CONFIDENTIAL\">"
+ + "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
+ + "<displaymarking bgcolor=\"navy\" fgcolor=\"black\">CONFIDENTIAL</displaymarking>"
+ + "<label><esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel></label>"
+ + "</securitylabel>"
+ + "</item>"
+ + "<item selector=\"Unclassified|UNCLASSIFIED\"/>"
+ + "</catalog>", testling.serialize(catalog));
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/serializer/payloadserializers/SoftwareVersionSerializerTest.java b/test/com/isode/stroke/serializer/payloadserializers/SoftwareVersionSerializerTest.java
new file mode 100644
index 0000000..1361033
--- /dev/null
+++ b/test/com/isode/stroke/serializer/payloadserializers/SoftwareVersionSerializerTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import com.isode.stroke.serializer.payloadserializers.SoftwareVersionSerializer;
+import com.isode.stroke.elements.SoftwareVersion;
+
+public class SoftwareVersionSerializerTest {
+
+ /**
+ * Default Constructor.
+ */
+ public SoftwareVersionSerializerTest() {
+
+ }
+
+ @Test
+ public void testSerialize() {
+ SoftwareVersionSerializer testling = new SoftwareVersionSerializer();
+ SoftwareVersion softwareVersion = new SoftwareVersion("Swift", "0.1", "Mac OS X");
+ String expectedResult = "<query xmlns=\"jabber:iq:version\"><name>Swift</name><version>0.1</version><os>Mac OS X</os></query>";
+ assertEquals(expectedResult, testling.serialize(softwareVersion));
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/serializer/payloadserializers/StatusSerializerTest.java b/test/com/isode/stroke/serializer/payloadserializers/StatusSerializerTest.java
new file mode 100644
index 0000000..32b4390
--- /dev/null
+++ b/test/com/isode/stroke/serializer/payloadserializers/StatusSerializerTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import com.isode.stroke.serializer.payloadserializers.StatusSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.elements.Status;
+
+public class StatusSerializerTest {
+
+ /**
+ * Default Constructor.
+ */
+ public StatusSerializerTest() {
+
+ }
+
+ @Test
+ public void testSerialize() {
+ StatusSerializer testling = new StatusSerializer();
+ Status status = new Status("I am away");
+ String expectedResult = "<status>I am away</status>";
+ assertEquals(expectedResult, testling.serialize(status));
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/serializer/payloadserializers/StatusShowSerializerTest.java b/test/com/isode/stroke/serializer/payloadserializers/StatusShowSerializerTest.java
new file mode 100644
index 0000000..7eae46e
--- /dev/null
+++ b/test/com/isode/stroke/serializer/payloadserializers/StatusShowSerializerTest.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import com.isode.stroke.serializer.payloadserializers.StatusShowSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.elements.StatusShow;
+
+public class StatusShowSerializerTest {
+
+ /**
+ * Default Constructor.
+ */
+ public StatusShowSerializerTest() {
+
+ }
+
+ @Test
+ public void testSerialize_Online() {
+ StatusShowSerializer testling = new StatusShowSerializer();
+ StatusShow statusShow = new StatusShow(StatusShow.Type.Online);
+ assertEquals("", testling.serialize(statusShow));
+ }
+
+ @Test
+ public void testSerialize_Away() {
+ StatusShowSerializer testling = new StatusShowSerializer();
+ StatusShow statusShow = new StatusShow(StatusShow.Type.Away);
+ assertEquals("<show>away</show>", testling.serialize(statusShow));
+ }
+
+ @Test
+ public void testSerialize_FFC() {
+ StatusShowSerializer testling = new StatusShowSerializer();
+ StatusShow statusShow = new StatusShow(StatusShow.Type.FFC);
+ assertEquals("<show>chat</show>", testling.serialize(statusShow));
+ }
+
+ @Test
+ public void testSerialize_XA() {
+ StatusShowSerializer testling = new StatusShowSerializer();
+ StatusShow statusShow = new StatusShow(StatusShow.Type.XA);
+ assertEquals("<show>xa</show>", testling.serialize(statusShow));
+ }
+
+ @Test
+ public void testSerialize_DND() {
+ StatusShowSerializer testling = new StatusShowSerializer();
+ StatusShow statusShow = new StatusShow(StatusShow.Type.DND);
+ assertEquals("<show>dnd</show>", testling.serialize(statusShow));
+ }
+
+ @Test
+ public void testSerialize_None() {
+ StatusShowSerializer testling = new StatusShowSerializer();
+ StatusShow statusShow = new StatusShow(StatusShow.Type.None);
+ assertEquals("", testling.serialize(statusShow));
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/serializer/payloadserializers/VCardSerializerTest.java b/test/com/isode/stroke/serializer/payloadserializers/VCardSerializerTest.java
new file mode 100644
index 0000000..57c4d1e
--- /dev/null
+++ b/test/com/isode/stroke/serializer/payloadserializers/VCardSerializerTest.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import com.isode.stroke.elements.VCard;
+import com.isode.stroke.serializer.payloadserializers.VCardSerializer;
+import com.isode.stroke.base.DateTime;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.base.ByteArray;
+
+public class VCardSerializerTest {
+
+ @Test
+ public void testSerialize() {
+ VCardSerializer testling = new VCardSerializer();
+ VCard vcard = new VCard();
+ vcard.setVersion("2.0");
+ vcard.setFullName("Alice In Wonderland");
+ vcard.setPrefix("Mrs");
+ vcard.setGivenName("Alice");
+ vcard.setMiddleName("In");
+ vcard.setFamilyName("Wonderland");
+ vcard.setSuffix("PhD");
+ vcard.setNickname("DreamGirl");
+ vcard.setPhoto(new ByteArray("abcdef"));
+ vcard.setPhotoType("image/png");
+ vcard.setBirthday(DateTime.stringToDate("1865-05-04T00:00:00Z"));
+ vcard.addUnknownContent("<MAILER>mutt</MAILER>");
+
+ VCard.EMailAddress emailAddress1 = new VCard.EMailAddress();
+ emailAddress1.address = "alice@wonderland.lit";
+ emailAddress1.isHome = true;
+ emailAddress1.isPreferred = true;
+ emailAddress1.isInternet = true;
+ vcard.addEMailAddress(emailAddress1);
+
+ VCard.EMailAddress address2 = new VCard.EMailAddress();
+ address2.address = "alice@teaparty.lit";
+ address2.isWork = true;
+ address2.isX400 = true;
+ vcard.addEMailAddress(address2);
+
+ VCard.Telephone telephone1 = new VCard.Telephone();
+ telephone1.number = "555-6273";
+ telephone1.isHome = true;
+ telephone1.isVoice = true;
+ vcard.addTelephone(telephone1);
+
+ VCard.Address address1 = new VCard.Address();
+ address1.locality = "Any Town";
+ address1.street = "Fake Street 123";
+ address1.postalCode = "12345";
+ address1.country = "USA";
+ address1.isHome = true;
+ vcard.addAddress(address1);
+
+ VCard.AddressLabel label1 = new VCard.AddressLabel();
+ label1.lines.add("Fake Street 123");
+ label1.lines.add("12345 Any Town");
+ label1.lines.add("USA");
+ label1.isHome = true;
+ vcard.addAddressLabel(label1);
+
+ vcard.addJID(new JID("alice@teaparty.lit"));
+ vcard.addJID(new JID("alice@wonderland.lit"));
+
+ vcard.setDescription("I once fell down a rabbit hole.");
+
+ VCard.Organization org1 = new VCard.Organization();
+ org1.name = "Alice In Wonderland Inc.";
+ vcard.addOrganization(org1);
+
+ vcard.addTitle("Some Title");
+ vcard.addRole("Main Character");
+ vcard.addURL("http://wonderland.lit/~alice");
+ vcard.addURL("http://teaparty.lit/~alice2");
+
+ String expectedResult =
+ "<vCard xmlns=\"vcard-temp\">"
+ + "<VERSION>2.0</VERSION>"
+ + "<FN>Alice In Wonderland</FN>"
+ + "<N>"
+ + "<FAMILY>Wonderland</FAMILY>"
+ + "<GIVEN>Alice</GIVEN>"
+ + "<MIDDLE>In</MIDDLE>"
+ + "<PREFIX>Mrs</PREFIX>"
+ + "<SUFFIX>PhD</SUFFIX>"
+ + "</N>"
+ + "<EMAIL>"
+ + "<USERID>alice@wonderland.lit</USERID>"
+ + "<HOME/>"
+ + "<INTERNET/>"
+ + "<PREF/>"
+ + "</EMAIL>"
+ + "<EMAIL>"
+ + "<USERID>alice@teaparty.lit</USERID>"
+ + "<WORK/>"
+ + "<X400/>"
+ + "</EMAIL>"
+ + "<NICKNAME>DreamGirl</NICKNAME>"
+ + "<PHOTO>"
+ + "<TYPE>image/png</TYPE>"
+ + "<BINVAL>YWJjZGVm</BINVAL>"
+ + "</PHOTO>"
+ + "<BDAY>1865-05-04T00:00:00Z</BDAY>"
+ + "<TEL>"
+ + "<NUMBER>555-6273</NUMBER>"
+ + "<HOME/>"
+ + "<VOICE/>"
+ + "</TEL>"
+ + "<ADR>"
+ + "<STREET>Fake Street 123</STREET>"
+ + "<LOCALITY>Any Town</LOCALITY>"
+ + "<PCODE>12345</PCODE>"
+ + "<CTRY>USA</CTRY>"
+ + "<HOME/>"
+ + "</ADR>"
+ + "<LABEL>"
+ + "<LINE>Fake Street 123</LINE>"
+ + "<LINE>12345 Any Town</LINE>"
+ + "<LINE>USA</LINE>"
+ + "<HOME/>"
+ + "</LABEL>"
+ + "<JID>alice@teaparty.lit</JID>"
+ + "<JID>alice@wonderland.lit</JID>"
+ + "<DESC>I once fell down a rabbit hole.</DESC>"
+ + "<ORG>"
+ + "<ORGNAME>Alice In Wonderland Inc.</ORGNAME>"
+ + "</ORG>"
+ + "<TITLE>Some Title</TITLE>"
+ + "<ROLE>Main Character</ROLE>"
+ + "<URL>http://wonderland.lit/~alice</URL>"
+ + "<URL>http://teaparty.lit/~alice2</URL>"
+ + "<MAILER>mutt</MAILER>"
+ + "</vCard>";
+
+ assertEquals(expectedResult, testling.serialize(vcard));
+ }
+} \ No newline at end of file