Search in sources :

Example 1 with TestSerialPortInputStream

use of com.infiniteautomation.serial.TestSerialPortInputStream in project ma-modules-public by infiniteautomation.

the class SerialDataSourceTest method setup.

@Before
public void setup() {
    this.proxy = new TestSerialPortProxy(new TestSerialPortInputStream(), new TestSerialPortOutputStream());
    Common.serialPortManager = new SerialDataSourceSerialPortManager(proxy);
    vo = SerialDataSourceTestData.getStandardDataSourceVO();
    rt = (SerialDataSourceRT) vo.createDataSourceRT();
    testCases.put("Hello World!;", new SerialDataSourceTestCase(SerialDataSourceTestData.getMatchAllPoint(vo), "terminator", ";", 1, new String[] { "Hello World!;" }));
    testCases.put("8812;abcf;", new SerialDataSourceTestCase(SerialDataSourceTestData.getMatchAllPoint(vo), "terminator", ";", 2, new String[] { "8812;", "abcf;" }));
    testCases.put("", new SerialDataSourceTestCase(SerialDataSourceTestData.getMatchAllPoint(vo), "terminator", ";", 0, new String[] {}));
    testCases.put("testStr\n\nabs", new SerialDataSourceTestCase(SerialDataSourceTestData.getNewlineTerminated(vo), "terminator", "\n", 2, new String[] { "testStr", "" }));
    testCases.put("ok;", new SerialDataSourceTestCase(SerialDataSourceTestData.getMatchAllPoint(vo), "terminator", ";", 1, new String[] { "ok;" }));
    // Clean out the timer's tasks
    time = System.currentTimeMillis() - 1000000;
    timer.setStartTime(time);
// TODO requiring more mocks for timers		testCases.put("Hello World!;", new SerialTestCase("timeout", ";", 1, new String[]{"Hello World!;"}));
}
Also used : TestSerialPortProxy(com.infiniteautomation.serial.TestSerialPortProxy) TestSerialPortInputStream(com.infiniteautomation.serial.TestSerialPortInputStream) TestSerialPortOutputStream(com.infiniteautomation.serial.TestSerialPortOutputStream) SerialDataSourceTestCase(com.infiniteautomation.serial.SerialDataSourceTestCase) Before(org.junit.Before)

Aggregations

SerialDataSourceTestCase (com.infiniteautomation.serial.SerialDataSourceTestCase)1 TestSerialPortInputStream (com.infiniteautomation.serial.TestSerialPortInputStream)1 TestSerialPortOutputStream (com.infiniteautomation.serial.TestSerialPortOutputStream)1 TestSerialPortProxy (com.infiniteautomation.serial.TestSerialPortProxy)1 Before (org.junit.Before)1