summaryrefslogtreecommitdiffstats
path: root/test/com
diff options
context:
space:
mode:
authorAlex Clayton <alex.clayton@isode.com>2016-02-04 16:58:12 (GMT)
committerNick Hudson <nick.hudson@isode.com>2016-02-08 15:06:46 (GMT)
commit14ce99a513cf4ac8ff4a2305bd5917285dc14106 (patch)
tree401eb360e8ddd4bc25688205febf33125cac87c9 /test/com
parent16f76289d203069036a2fb2da1b559f0e888728b (diff)
downloadstroke-14ce99a513cf4ac8ff4a2305bd5917285dc14106.zip
stroke-14ce99a513cf4ac8ff4a2305bd5917285dc14106.tar.bz2
Add IQTest
Add the IQTest class. Test-information: All tests pass. Change-Id: I1fa14c275f9fbe19f4b21002b300024334d5a9da
Diffstat (limited to 'test/com')
-rw-r--r--test/com/isode/stroke/elements/IQTest.java56
1 files changed, 56 insertions, 0 deletions
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());
+ }
+
+}