forked from ev3dev-lang-java/ev3dev-lang-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShellTest.java
More file actions
39 lines (29 loc) · 1.05 KB
/
ShellTest.java
File metadata and controls
39 lines (29 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package ev3dev.utils;
import ev3dev.hardware.EV3DevPlatform;
import ev3dev.sensors.Battery;
import fake_ev3dev.ev3dev.sensors.FakeBattery;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@Slf4j
public class ShellTest {
@Before
public void resetTest() throws IOException {
FakeBattery.deleteEV3DevFakeSystemPath();
FakeBattery.createEV3DevFakeSystemPath();
}
@Test
public void executeSimpleCommandTest() throws Exception {
FakeBattery fakeBattery = new FakeBattery(EV3DevPlatform.EV3BRICK);
final String result = Shell.execute("ls " + FakeBattery.EV3DEV_FAKE_SYSTEM_PATH + "/" + Battery.BATTERY);
assertThat(result, is("legoev3-battery\n"));
}
@Test
public void executeSimpleCommandKOTest() throws Exception {
final String result = Shell.execute("lsrare ");
assertThat(result, is(Shell.COMMAND_ERROR_MESSAGE));
}
}