diff --git a/README.md b/README.md index 85d99f9..9ad79b1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ +[![CircleCI](https://circleci.com/gh/zephyyrr/ESARack.svg?style=svg)](https://circleci.com/gh/zephyyrr/ESARack) + # ESARack Control software for controlling the ESA racks diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..f6cb6fe --- /dev/null +++ b/circle.yml @@ -0,0 +1,18 @@ +dependencies: + override: + - chmod +x gradlew + +compile: + override: + - ./gradlew shadowJar + +test: + override: + - ./gradlew test + post: + - mkdir -p $CIRCLE_TEST_REPORTS/junit/ + - find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \; + +general: + artifacts: + - "build/libs" diff --git a/src/test/java/com/esamarathon/ESARack/hardware/test/TestIN1606.java b/src/test/java/com/esamarathon/ESARack/hardware/test/TestIN1606.java index 139a7e4..db5b3cb 100644 --- a/src/test/java/com/esamarathon/ESARack/hardware/test/TestIN1606.java +++ b/src/test/java/com/esamarathon/ESARack/hardware/test/TestIN1606.java @@ -14,25 +14,27 @@ public class TestIN1606 { + private static final String linesep = System.getProperty("line.separator"); + @Test public void TestGetInput() throws IOException, InterruptedException { - byte[] expectedDataSent = "!\r\n".getBytes(); - byte[] response = "1\r\n".getBytes(); + byte[] expectedDataSent = ("!"+linesep).getBytes(); + byte[] response = ("1"+linesep).getBytes(); String expectedResult = "1"; testCaseForGet((IN1606 in1606) -> in1606.getInput(), expectedDataSent, response, expectedResult); } @Test public void TestSetInput() throws IOException, InterruptedException { ByteArrayOutputStream out = new ByteArrayOutputStream(); - String input = String.valueOf(1+Math.round(Math.random() * 6)); + String input = String.valueOf(1+Math.round(Math.random() * 5)); IN1606 in1606 = getMockedIN1606(out, ("IN"+input+" All\r\n").getBytes()); in1606.setInput(input); - Assert.assertArrayEquals((input+"!\r\n").getBytes(), out.toByteArray()); + Assert.assertArrayEquals((input+"!" + linesep).getBytes(), out.toByteArray()); } @Test public void TestGetWidth() throws IOException, InterruptedException { - byte[] expectedDataSent = (IN1606.ESC + "HSIZ\r\r\n").getBytes(); - byte[] response = "50\r\n".getBytes(); + byte[] expectedDataSent = (IN1606.ESC + "HSIZ\r" + linesep).getBytes(); + byte[] response = ("50\r\n").getBytes(); Integer expectedResult = 50; testCaseForGet((IN1606 in1606) -> in1606.getWidth(), expectedDataSent, response, expectedResult); } @@ -40,16 +42,16 @@ public class TestIN1606 { @Test public void TestSetWidth() throws IOException, InterruptedException { ByteArrayOutputStream out = new ByteArrayOutputStream(); int input = 345; - IN1606 in1606 = getMockedIN1606(out, ("HSIZ"+input+"\r\n").getBytes()); + IN1606 in1606 = getMockedIN1606(out, ("HSIZ"+input+linesep).getBytes()); in1606.setWidth(input); - String expected = IN1606.ESC + String.valueOf(input) + "HSIZ\r\r\n"; + String expected = IN1606.ESC + String.valueOf(input) + "HSIZ\r"+linesep; String actual = out.toString(); Assert.assertEquals("Should be equal.", expected, actual); } @Test public void TestGetHeight() throws IOException, InterruptedException { - byte[] expectedDataSent = (IN1606.ESC + "VSIZ\r\r\n").getBytes(); - byte[] response = "75\r\n".getBytes(); + byte[] expectedDataSent = (IN1606.ESC + "VSIZ\r"+linesep).getBytes(); + byte[] response = ("75"+linesep).getBytes(); Integer expectedResult = 75; testCaseForGet((IN1606 in1606) -> in1606.getHeight(), expectedDataSent, response, expectedResult); } @@ -59,7 +61,7 @@ public class TestIN1606 { int input = 4096; IN1606 in1606 = getMockedIN1606(out, ("VSIZ"+input+"\r\n").getBytes()); in1606.setHeight(input); - String expected = IN1606.ESC + String.valueOf(input) + "VSIZ\r\r\n"; + String expected = IN1606.ESC + String.valueOf(input) + "VSIZ\r"+linesep; String actual = out.toString(); Assert.assertEquals("Should be equal.", expected, actual); } @@ -68,16 +70,16 @@ public class TestIN1606 { ByteArrayOutputStream out = new ByteArrayOutputStream(); IN1606 in1606 = getMockedIN1606(out, ("Img1\r\n").getBytes()); in1606.executeAutoMode(AutoImageType.Fill); - String expected = "1*A\r\n"; + String expected = "1*A"+linesep; String actual = out.toString(); Assert.assertEquals("Should be equal.", expected, actual); } @Test public void TestExecuteAutoImage_Follow() throws IOException, InterruptedException { ByteArrayOutputStream out = new ByteArrayOutputStream(); - IN1606 in1606 = getMockedIN1606(out, ("Img1\r\n").getBytes()); + IN1606 in1606 = getMockedIN1606(out, ("Img2\r\n").getBytes()); in1606.executeAutoMode(AutoImageType.Follow); - String expected = "2*A\r\n"; + String expected = "2*A"+linesep; String actual = out.toString(); Assert.assertEquals("Should be equal.", expected, actual); }