diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 000000000..9f2b69572 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,11 @@ +name: Integration test +on: workflow_dispatch +jobs: + setup-serial-port-pair: + runs-on: ubuntu-20.04 + steps: + - name: install dependencies + run: | + sudo dpkg --add-architecture i386 && \ + sudo apt update && sudp apt install -y wine socat + diff --git a/integration-test/library-compatibility/pom.xml b/integration-test/library-compatibility/pom.xml new file mode 100644 index 000000000..ebef6e987 --- /dev/null +++ b/integration-test/library-compatibility/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + com.IntegrationTest + jssc-test + 2.9.4-SNAPSHOT + + + 6 + 6 + + + + + io.github.java-native + jssc + 2.9.4-SNAPSHOT + + + org.slf4j + slf4j-simple + 1.7.30 + + + + + + + maven-assembly-plugin + + + + com.example.Main + + + + jar-with-dependencies + + runme + false + + + + + + \ No newline at end of file diff --git a/integration-test/library-compatibility/src/main/java/com/example/Main.java b/integration-test/library-compatibility/src/main/java/com/example/Main.java new file mode 100644 index 000000000..0029a633d --- /dev/null +++ b/integration-test/library-compatibility/src/main/java/com/example/Main.java @@ -0,0 +1,41 @@ +package com.example; + +import jssc.*; + +import java.util.Arrays; + +public class Main { + + static SerialPortEventListener listener = new SerialPortEventListener() { + @Override + public void serialEvent(SerialPortEvent serialPortEvent) { + System.err.println("Event type " + serialPortEvent.getEventType()); + try { + System.out.println(serialPortEvent.getPort().readString()); + } catch (SerialPortException e) { + e.printStackTrace(); + } + } + }; + + public static void main(String... args) throws SerialPortException, InterruptedException { + String[] serialPorts = SerialPortList.getPortNames(); + String portAName = serialPorts[0]; + String portBName = serialPorts[1]; + System.out.println("Serial ports: " + Arrays.asList(SerialPortList.getPortNames())); + final SerialPort portA = new SerialPort(portAName); + final SerialPort portB = new SerialPort(portBName); + portA.openPort(); + portB.openPort(); + + portA.addEventListener(listener); + portB.addEventListener(listener); + + portA.writeBytes("Hello, it's A".getBytes()); + portB.writeBytes("Hello, it's B".getBytes()); + + Thread.sleep(1000); + portA.closePort(); + portB.closePort(); + } +}