From a181fda0785ee29c411cacce4495650a90abecfc Mon Sep 17 00:00:00 2001 From: Mikayla Ray Date: Wed, 6 May 2015 14:54:53 -0400 Subject: Added unit tests for BaseTransportConfig, BTTransportConfig, and TCPTransportConfig classes. --- .../test/transport/BTTransportConfigTests.java | 25 ++++++++++++++++++++++ .../test/transport/BaseTransportConfigTests.java | 25 ++++++++++++++++++++++ .../test/transport/TCPTransportConfigTests.java | 21 ++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 sdl_android_tests/src/com/smartdevicelink/test/transport/BTTransportConfigTests.java create mode 100644 sdl_android_tests/src/com/smartdevicelink/test/transport/BaseTransportConfigTests.java create mode 100644 sdl_android_tests/src/com/smartdevicelink/test/transport/TCPTransportConfigTests.java diff --git a/sdl_android_tests/src/com/smartdevicelink/test/transport/BTTransportConfigTests.java b/sdl_android_tests/src/com/smartdevicelink/test/transport/BTTransportConfigTests.java new file mode 100644 index 000000000..55ff11998 --- /dev/null +++ b/sdl_android_tests/src/com/smartdevicelink/test/transport/BTTransportConfigTests.java @@ -0,0 +1,25 @@ +package com.smartdevicelink.test.transport; + +import junit.framework.TestCase; + +import com.smartdevicelink.transport.BTTransportConfig; +import com.smartdevicelink.transport.TransportType; + +public class BTTransportConfigTests extends TestCase { + + public void testValues () { + + BTTransportConfig test1 = new BTTransportConfig(); + BTTransportConfig test2 = new BTTransportConfig(false); + assertEquals("Values should match.", TransportType.BLUETOOTH, test1.getTransportType()); + assertEquals("Values should match.", TransportType.BLUETOOTH, test2.getTransportType()); + + assertTrue("Values should match.", test1.shareConnection()); + assertFalse("Values should match.", test2.shareConnection()); + + test1.setKeepSocketActive(true); + assertTrue("Value should be true.", test1.getKeepSocketActive()); + test1.setKeepSocketActive(false); + assertFalse("Value should be false.", test1.getKeepSocketActive()); + } +} \ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/transport/BaseTransportConfigTests.java b/sdl_android_tests/src/com/smartdevicelink/test/transport/BaseTransportConfigTests.java new file mode 100644 index 000000000..266b66f6b --- /dev/null +++ b/sdl_android_tests/src/com/smartdevicelink/test/transport/BaseTransportConfigTests.java @@ -0,0 +1,25 @@ +package com.smartdevicelink.test.transport; + +import junit.framework.TestCase; + +import com.smartdevicelink.transport.BaseTransportConfig; +import com.smartdevicelink.transport.TransportType; + +public class BaseTransportConfigTests extends TestCase { + + public void testValues () { + + MockBTC mock = new MockBTC(); + assertNotNull("Mock value should not be null", mock); + assertTrue("Value should be true", mock.shareConnection()); + assertEquals("Values do not match", Integer.MAX_VALUE, mock.getHeartBeatTimeout()); + + mock.setHeartBeatTimeout(10); + assertEquals("Values do not match", 10, mock.getHeartBeatTimeout()); + } +} + +class MockBTC extends BaseTransportConfig { + public MockBTC () { } + @Override public TransportType getTransportType() { return null; } +} \ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/transport/TCPTransportConfigTests.java b/sdl_android_tests/src/com/smartdevicelink/test/transport/TCPTransportConfigTests.java new file mode 100644 index 000000000..e8a565b98 --- /dev/null +++ b/sdl_android_tests/src/com/smartdevicelink/test/transport/TCPTransportConfigTests.java @@ -0,0 +1,21 @@ +package com.smartdevicelink.test.transport; + +import com.smartdevicelink.transport.TCPTransportConfig; +import com.smartdevicelink.transport.TransportType; + +import junit.framework.TestCase; + +public class TCPTransportConfigTests extends TestCase { + + public void testValues () { + + TCPTransportConfig test = new TCPTransportConfig(123, "test", true); + assertEquals("Values should match.", 123, test.getPort()); + assertEquals("Values should match.", "test", test.getIPAddress()); + assertTrue("Value should be true.", test.getAutoReconnect()); + assertEquals("Values should match.", TransportType.TCP, test.getTransportType()); + + String expected = "TCPTransportConfig{Port=123, IpAddress='test', AutoReconnect=true}"; + assertEquals("Values should match.", expected, test.toString()); + } +} \ No newline at end of file -- cgit v1.2.1