summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--PortingProgress.txt1
-rw-r--r--test/com/isode/stroke/elements/IQTest.java56
2 files changed, 56 insertions, 1 deletions
diff --git a/PortingProgress.txt b/PortingProgress.txt
index e486023..9b22cc6 100644
--- a/PortingProgress.txt
+++ b/PortingProgress.txt
@@ -72,7 +72,6 @@ Elements:
All files ported to 6ca201d0b48f4273e24dd7bff17c4a46eeaddf39 except for:
-IQTest -- Not Yet Ported!
WhiteBoard Functionalities -- Not Yet Ported!
Individual Comments:
diff --git a/test/com/isode/stroke/elements/IQTest.java b/test/com/isode/stroke/elements/IQTest.java
new file mode 100644
index 0000000..1c742c3
--- /dev/null
+++ b/test/com/isode/stroke/elements/IQTest.java
@@ -0,0 +1,56 @@
+/* Copyright (c) 2016, Isode Limited, London, England.
+ * All rights reserved.
+ *
+ * Acquisition and use of this software and related materials for any
+ * purpose requires a written license agreement from Isode Limited,
+ * or a written license from an organisation licensed by Isode Limited
+ * to grant such a license.
+ *
+ */
+package com.isode.stroke.elements;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+
+import com.isode.stroke.elements.ErrorPayload.Condition;
+import com.isode.stroke.elements.ErrorPayload.Type;
+import com.isode.stroke.jid.JID;
+
+/**
+ * Unit test for {@link IQ}
+ */
+public class IQTest {
+
+ @Test
+ public void testCreateResult() {
+ Payload payload = new SoftwareVersion("myclient");
+ IQ iq = IQ.createResult(new JID("foo@bar/fum"), "myid", payload);
+
+ assertEquals(new JID("foo@bar/fum"),iq.getTo());
+ assertEquals("myid",iq.getID());
+ assertEquals(payload,iq.getPayload(new SoftwareVersion()));
+ }
+
+ @Test
+ public void testCreateResult_WithoutPayload() {
+ IQ iq = IQ.createError(new JID("foo@bar/fum"), "myid");
+
+ assertEquals(new JID("foo@bar/fum"),iq.getTo());
+ assertEquals("myid",iq.getID());
+ assertNull(iq.getPayload(new SoftwareVersion()));
+ }
+
+ @Test
+ public void testCreateError() {
+ IQ iq = IQ.createError(new JID("foo@bar/fum"), "myid", Condition.BadRequest, Type.Modify);
+
+ assertEquals(new JID("foo@bar/fum"),iq.getTo());
+ assertEquals("myid",iq.getID());
+ ErrorPayload error = iq.getPayload(new ErrorPayload());
+ assertEquals(Condition.BadRequest,error.getCondition());
+ assertEquals(Type.Modify,error.getType());
+ }
+
+}