blob: bd5cbc714e2391e9c9e70e0d980c964a0f40edac (
plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
package org.reprap.devices;
import org.reprap.comms.Communicator;
import org.reprap.comms.port.TestPort;
import org.reprap.comms.port.testhandlers.TestDevice;
import org.reprap.comms.port.testhandlers.TestStepper;
import org.reprap.comms.snap.SNAPAddress;
import org.reprap.comms.snap.SNAPCommunicator;
import org.testng.Assert;
/**
*
* @testng.configuration groups = "comms,all,all-offline"
*
*/
public class StepperTest {
TestPort port;
GenericStepperMotor motor;
Communicator communicator;
/**
* @testng.configuration beforeSuite = "true"
*/
public void setUp() throws Exception {
port = new TestPort();
port.addDevice(new TestStepper(), new SNAPAddress(2));
Communicator communicator = new SNAPCommunicator(port, new SNAPAddress(0));
motor = new GenericStepperMotor(communicator, new SNAPAddress(2), 200);
}
/**
* @testng.configuration afterSuite = "true"
*/
public void tearDown() {
motor.dispose();
//communicator.dispose();
port.close();
}
/**
* @testng.test groups = "comms,all,all-offline"
* timeOut="1000"
*/
public void testStepperBasic() throws Exception {
int version = motor.getVersion();
Assert.assertEquals(version, TestDevice.version);
}
/**
* A test that drops the first received packet to check
* that the request will time out and be re-sent
* @testng.test groups = "comms,all,all-offline"
* timeOut="5000"
*/
public void testTimeouts() throws Exception {
port.dropNextIncomingPacket();
int version = motor.getVersion();
Assert.assertEquals(version, TestDevice.version);
}
}
|