diff options
Diffstat (limited to 'test/com/isode')
-rw-r--r-- | test/com/isode/stroke/parser/payloadparsers/PriorityParserTest.java | 50 | ||||
-rw-r--r-- | test/com/isode/stroke/serializer/payloadserializers/PrioritySerializerTest.java | 36 |
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 |