MCPcopy Create free account
hub / github.com/akeranen/the-one / testMapCache

Method testMapCache

test/MapBasedMovementTest.java:169–193  ·  view source on GitHub ↗

Tests the SimMap caching feature

()

Source from the content-addressed store, hash-verified

167 * Tests the SimMap caching feature
168 */
169 public void testMapCache() throws IOException {
170 String mmbClass = "movement.MapBasedMovement";
171 writeToNewFile();
172 assertEquals("1", new TestSettings(MapBasedMovement.MAP_BASE_MOVEMENT_NS).getSetting(MapBasedMovement.NROF_FILES_S));
173 mbm = (MapBasedMovement)s.createIntializedObject(mmbClass);
174 SimMap firstMap = mbm.getMap();
175 mbm = (MapBasedMovement)s.createIntializedObject(mmbClass);
176 SimMap secondMap = mbm.getMap();
177
178 // second call should return the same map object
179 assertTrue(firstMap == secondMap);
180
181 writeToNewFile(); // change the map file
182 mbm = (MapBasedMovement)s.createIntializedObject(mmbClass);
183 SimMap thirdMap = mbm.getMap();
184
185 // after reading from different file, should return a different instance
186 assertTrue(firstMap != thirdMap);
187
188 mbm = (MapBasedMovement)s.createIntializedObject(mmbClass);
189 SimMap fourthMap = mbm.getMap();
190
191 // now should return the same map object as with previous read
192 assertTrue(thirdMap == fourthMap);
193 }
194
195 public void testHostMoving() {
196 final int NROF = 15;

Callers

nothing calls this directly

Calls 4

writeToNewFileMethod · 0.95
getSettingMethod · 0.80
getMapMethod · 0.45

Tested by

no test coverage detected