Skip to content

Commit

Permalink
Merge branch 'master' of github.com:zephyyrr/ESARack
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyyrr committed Jul 22, 2017
2 parents cd98865 + f104ad0 commit 6db6f2f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 16 additions & 14 deletions src/test/java/com/esamarathon/ESARack/hardware/test/TestIN1606.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,44 @@

public class TestIN1606<T> {

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);
}

@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);
}
Expand All @@ -59,7 +61,7 @@ public class TestIN1606<T> {
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);
}
Expand All @@ -68,16 +70,16 @@ public class TestIN1606<T> {
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);
}
Expand Down

0 comments on commit 6db6f2f

Please sign in to comment.