From aba7cfe71c1ed3290d3b331169c5d56010763b15 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 31 Dec 2014 12:04:28 +1300 Subject: Add filter unit tests --- test/org/traccar/FilterHandlerTest.java | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/org/traccar/FilterHandlerTest.java (limited to 'test/org/traccar') diff --git a/test/org/traccar/FilterHandlerTest.java b/test/org/traccar/FilterHandlerTest.java new file mode 100644 index 000000000..1dacab692 --- /dev/null +++ b/test/org/traccar/FilterHandlerTest.java @@ -0,0 +1,49 @@ +package org.traccar; + +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.traccar.helper.ChannelBufferTools; +import org.traccar.helper.TestDataManager; +import org.traccar.model.Position; +import org.traccar.protocol.AtrackProtocolDecoder; + +import java.util.Date; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.traccar.helper.DecoderVerifier.verify; + +public class FilterHandlerTest { + + private FilterHandler filtingHandler; + private FilterHandler passingHandler; + + @Before + public void setUp() { + filtingHandler = new FilterHandler(true, true, true, 10, 10); + passingHandler = new FilterHandler(false, false, false, 0, 0); + } + + @After + public void tearDown() { + filtingHandler = null; + passingHandler = null; + } + + @Test + public void testFilterInvalid() throws Exception { + + Position position = new Position(0, new Date(), true, 10, 10, 10, 10, 10); + + assertNotNull(filtingHandler.decode(null, null, position)); + assertNotNull(passingHandler.decode(null, null, position)); + + position = new Position(0, new Date(), false, 10, 10, 10, 10, 10); + + assertNull(filtingHandler.decode(null, null, position)); + assertNotNull(passingHandler.decode(null, null, position)); + } + +} -- cgit v1.2.3