aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/org/traccar/protocol/ST210ProtocolDecoderTest.java96
-rw-r--r--test/org/traccar/server/SocketCliente.java44
2 files changed, 92 insertions, 48 deletions
diff --git a/test/org/traccar/protocol/ST210ProtocolDecoderTest.java b/test/org/traccar/protocol/ST210ProtocolDecoderTest.java
index cf5b0b8e6..bd1e60ee1 100644
--- a/test/org/traccar/protocol/ST210ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/ST210ProtocolDecoderTest.java
@@ -10,64 +10,64 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.traccar.Server;
import org.traccar.helper.Log;
-//import org.traccar.server.SocketCliente;
+import org.traccar.server.SocketCliente;
public class ST210ProtocolDecoderTest {
- /*@BeforeClass
- public static void UpServer() {
- final Server service = new Server();
- String[] args = new String[1];
- args[0] = "setup\\windows\\windows.cfg";
- try {
- service.init(args);
+ @BeforeClass
+ public static void UpServer() {
+ final Server service = new Server();
+ String[] args = new String[1];
+ args[0] = "setup\\windows\\windows.cfg";
+ try {
+ service.init(args);
- Log.info("starting server...");
- service.start();
+ Log.info("starting server...");
+ service.start();
- // Shutdown server properly
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- Log.info("shutting down server...");
- service.stop();
- }
- });
+ // Shutdown server properly
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ Log.info("shutting down server...");
+ service.stop();
+ }
+ });
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
- @Test
- public void testClienteMsg() throws Exception {
+ @Test
+ public void testClienteMsg() throws Exception {
- SocketCliente cliente = new SocketCliente();
- cliente.SendMSG(
- "localhost",
- 5010,
- "SA200STT;317652;042;20120718;15:37:12;16d41;-15.618755;-056.083241;000.024;000.00;8;1;41548;12.17;100000;2;1979");
+ SocketCliente cliente = new SocketCliente();
+ cliente.SendMSG(
+ "localhost",
+ 5010,
+ "SA200STT;317652;042;20120718;15:37:12;16d41;-15.618755;-056.083241;000.024;000.00;8;1;41548;12.17;100000;2;1979");
+ }
- }*/
+/* @Test
+ public void testDecode() throws Exception {
-/* @Test
- public void testDecode() throws Exception {
+ ST210ProtocolDecoder decoder = new ST210ProtocolDecoder(
+ new TestDataManager(), 0);
- ST210ProtocolDecoder decoder = new ST210ProtocolDecoder(
- new TestDataManager(), 0);
+ assertNotNull(decoder
+ .decode(null,
+ null,
+ "SA200STT;317652;042;20120718;15:37:12;16d41;-15.618755;-056.083241;000.024;000.00;8;1;41548;12.17;100000;2;1979"));
+ assertNotNull(decoder
+ .decode(null,
+ null,
+ "SA200STT;317652;042;20120721;19:04:30;16d41;-15.618743;-056.083221;000.001;000.00;12;1;41557;12.21;000000;1;3125"));
+ assertNotNull(decoder
+ .decode(null,
+ null,
+ "SA200STT;317652;042;20120722;00:24:23;16d41;-15.618767;-056.083214;000.011;000.00;11;1;41557;12.21;000000;1;3205"));
+ }*/
- assertNotNull(decoder
- .decode(null,
- null,
- "SA200STT;317652;042;20120718;15:37:12;16d41;-15.618755;-056.083241;000.024;000.00;8;1;41548;12.17;100000;2;1979"));
- assertNotNull(decoder
- .decode(null,
- null,
- "SA200STT;317652;042;20120721;19:04:30;16d41;-15.618743;-056.083221;000.001;000.00;12;1;41557;12.21;000000;1;3125"));
- assertNotNull(decoder
- .decode(null,
- null,
- "SA200STT;317652;042;20120722;00:24:23;16d41;-15.618767;-056.083214;000.011;000.00;11;1;41557;12.21;000000;1;3205"));
- }*/
}
diff --git a/test/org/traccar/server/SocketCliente.java b/test/org/traccar/server/SocketCliente.java
new file mode 100644
index 000000000..c26c02e49
--- /dev/null
+++ b/test/org/traccar/server/SocketCliente.java
@@ -0,0 +1,44 @@
+package org.traccar.server;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.net.Socket;
+
+public class SocketCliente {
+
+ /**
+ * @param args
+ */
+ public void SendMSG(String url, int port, String msg) {
+
+ Socket s = null;
+
+ PrintStream ps = null;
+
+ try {
+
+ s = new Socket(url, port);
+
+ ps = new PrintStream(s.getOutputStream());
+
+ ps.println(msg);
+
+ System.out.println("send");
+
+ } catch (IOException e) {
+
+ System.out
+ .println("Some problem happened on send data to socket.");
+
+ } finally {
+
+ try {
+ s.close();
+ } catch (IOException e) {
+ }
+
+ }
+
+ }
+
+}