Moved XML message creation to RaceServer instead of ConnectionAcceptor.

RaceServer does not currently generate new XMLMessages - NYI.
Added a sequence number to RaceDataSource - this is used to indicate that the data source has been modified.
#story[1188]
This commit is contained in:
fjc40
2017-09-01 01:19:17 +12:00
parent d0eebcdb2f
commit 9156bde8af
12 changed files with 154 additions and 120 deletions
@@ -15,30 +15,16 @@ import static org.junit.Assert.*;
*/
public class SourceIdAllocatorTest {
/**
* This is the list of source IDs that we start with.
*/
private List<Integer> originalSourceIDs;
/**
* Used to allocate source IDs.
*/
private MockRace mockRace;
private SourceIdAllocator sourceIdAllocator;
@Before
public void setUp() throws Exception {
originalSourceIDs = new ArrayList<>();
originalSourceIDs.add(120);
originalSourceIDs.add(121);
originalSourceIDs.add(122);
originalSourceIDs.add(123);
originalSourceIDs.add(124);
originalSourceIDs.add(125);
mockRace = MockRaceTest.createMockRace();
sourceIdAllocator = new SourceIdAllocator(originalSourceIDs);
sourceIdAllocator = new SourceIdAllocator(mockRace);
}
@@ -49,11 +35,12 @@ public class SourceIdAllocatorTest {
@Test
public void emptyAllocationTest() {
SourceIdAllocator allocator = new SourceIdAllocator(new ArrayList<>());
mockRace.getRaceDataSource().getParticipants().removeAll(mockRace.getBoatDataSource().getBoats().keySet());
mockRace.getRaceDataSource().getParticipants().addAll(mockRace.getBoatDataSource().getBoats().keySet());
try {
int sourceID = allocator.allocateSourceID();
int sourceID = sourceIdAllocator.allocateSourceID();
fail("Exception should have been thrown, but wasn't.");
@@ -108,10 +95,6 @@ public class SourceIdAllocatorTest {
@Test
public void reallocationTest() throws Exception {
List<Integer> sourceIDList = new ArrayList<>();
sourceIDList.add(123);
SourceIdAllocator sourceIdAllocator = new SourceIdAllocator(sourceIDList);
//Allocate.
int sourceID = sourceIdAllocator.allocateSourceID();
@@ -5,12 +5,6 @@
<CreationTimeDate>2017-04-19T15:30:00+1200</CreationTimeDate>
<RaceStartTime Postpone="false" Time="2017-04-19T15:33:00+1200"/>
<Participants>
<Yacht SourceID="121"/>
<Yacht SourceID="122"/>
<Yacht SourceID="123"/>
<Yacht SourceID="124"/>
<Yacht SourceID="125"/>
<Yacht SourceID="126"/>
</Participants>
<CompoundMarkSequence>
<Corner CompoundMarkID="1" SeqID="1"/>
@@ -54,4 +48,4 @@
<Limit Lat="32.297164" Lon="-64.856394" SeqID="10"/>
<Limit Lat="32.296148" Lon="-64.849184" SeqID="11"/>
</CourseLimit>
</Race>
</Race>