Added BoatLocationEncoder.
Updated BoatLocationDecoder test to use new encoder. Updated MockOutput to use new encoder. It logs a warning if encoding fails. #story[1095]
This commit is contained in:
@@ -7,23 +7,52 @@ import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Created by hba56 on 23/04/17.
|
||||
* Test for the BoatLocation encoder and decoder
|
||||
*/
|
||||
public class BoatLocationDecoderTest {
|
||||
|
||||
|
||||
/**
|
||||
* Creates a BoatLocation message, encodes it, decodes it, and checks that the result matches the starting message.
|
||||
*/
|
||||
@Test
|
||||
public void getByteArrayTest(){
|
||||
public void getByteArrayTest() throws Exception {
|
||||
|
||||
//Create message.
|
||||
long time = System.currentTimeMillis();
|
||||
BoatLocation testMessage = new BoatLocation((byte) 1, time, 2,
|
||||
3, (byte) 1, 180, -180, 4, 5,
|
||||
(short) 6, (short) 7, 8, 9, 10, 11,
|
||||
(short) 12, 13, 14 , (short) 15,
|
||||
16, 17, (short) 18);
|
||||
|
||||
byte [] testEncodedMessage = RaceVisionByteEncoder.boatLocation(testMessage);
|
||||
BoatLocation testMessage = new BoatLocation(
|
||||
(byte) 1,
|
||||
time,
|
||||
2,
|
||||
3,
|
||||
(byte) 1,
|
||||
180,
|
||||
-180,
|
||||
4,
|
||||
5,
|
||||
(short) 6,
|
||||
(short) 7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
(short) 12,
|
||||
13,
|
||||
14,
|
||||
(short) 15,
|
||||
16,
|
||||
17,
|
||||
(short) 18 );
|
||||
|
||||
//Encode.
|
||||
byte [] testEncodedMessage = RaceVisionByteEncoder.encode(testMessage);
|
||||
|
||||
//Decode.
|
||||
BoatLocationDecoder testDecoder = new BoatLocationDecoder(testEncodedMessage);
|
||||
BoatLocation decodedTest = testDecoder.getMessage();
|
||||
|
||||
//Check if valid.
|
||||
Assert.assertEquals(testMessage.getMessageVersionNumber(), decodedTest.getMessageVersionNumber());
|
||||
Assert.assertEquals(testMessage.getTime(), decodedTest.getTime());
|
||||
Assert.assertEquals(testMessage.getSequenceNumber(), decodedTest.getSequenceNumber());
|
||||
|
||||
Reference in New Issue
Block a user