summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarun Gupta <tarun1995gupta@gmail.com>2015-06-21 09:17:11 (GMT)
committerTarun Gupta <tarun1995gupta@gmail.com>2015-06-30 13:24:34 (GMT)
commitb830f64de47271777d8e45ddb0a18dc2ac740dd9 (patch)
tree2501225b8783e2fc878720662c46b9a9e950f2ff /test/com/isode
parentba7342e593920595af36fcd8e8e44ec206f8b561 (diff)
downloadstroke-b830f64de47271777d8e45ddb0a18dc2ac740dd9.zip
stroke-b830f64de47271777d8e45ddb0a18dc2ac740dd9.tar.bz2
Adds Parser and Serializer for Priority Element.
Adds Priority Parser and Serializer. License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details. Test-Information: Tests passes for Priority Parser and Serializer. Change-Id: I0077cd0a3d179590b6ea78fa445e91358ff8b623
Diffstat (limited to 'test/com/isode')
-rw-r--r--test/com/isode/stroke/parser/payloadparsers/PriorityParserTest.java50
-rw-r--r--test/com/isode/stroke/serializer/payloadserializers/PrioritySerializerTest.java36
2 files changed, 86 insertions, 0 deletions
diff --git a/test/com/isode/stroke/parser/payloadparsers/PriorityParserTest.java b/test/com/isode/stroke/parser/payloadparsers/PriorityParserTest.java
new file mode 100644
index 0000000..5422bf0
--- /dev/null
+++ b/test/com/isode/stroke/parser/payloadparsers/PriorityParserTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.parser.payloadparsers;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import org.junit.Test;
+import com.isode.stroke.elements.Priority;
+import com.isode.stroke.parser.payloadparsers.PriorityParser;
+import com.isode.stroke.parser.payloadparsers.PayloadsParserTester;
+import com.isode.stroke.eventloop.DummyEventLoop;
+
+public class PriorityParserTest {
+
+ public PriorityParserTest() {
+
+ }
+
+ @Test
+ public void testParse() {
+ DummyEventLoop eventLoop = new DummyEventLoop();
+ PayloadsParserTester parser = new PayloadsParserTester(eventLoop);
+
+ assertNotNull(parser.parse("<priority>-120</priority>"));
+
+ Priority payload = (Priority)(parser.getPayload());
+ assertEquals(-120, payload.getPriority());
+ }
+
+ @Test
+ public void testParse_Invalid() {
+ DummyEventLoop eventLoop = new DummyEventLoop();
+ PayloadsParserTester parser = new PayloadsParserTester(eventLoop);
+
+ assertNotNull(parser.parse("<priority>invalid</priority>"));
+
+ Priority payload = (Priority)(parser.getPayload());
+ assertEquals(0, payload.getPriority());
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/serializer/payloadserializers/PrioritySerializerTest.java b/test/com/isode/stroke/serializer/payloadserializers/PrioritySerializerTest.java
new file mode 100644
index 0000000..c3c3a37
--- /dev/null
+++ b/test/com/isode/stroke/serializer/payloadserializers/PrioritySerializerTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.PrioritySerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.elements.Priority;
+
+public class PrioritySerializerTest {
+
+ /**
+ * Default Constructor.
+ */
+ public PrioritySerializerTest() {
+
+ }
+
+ @Test
+ public void testSerialize() {
+ PrioritySerializer testling = new PrioritySerializer();
+ Priority priority = new Priority(-113);
+
+ assertEquals("<priority>-113</priority>", testling.serialize(priority));
+ }
+} \ No newline at end of file