use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestRegionIdMapper method testGetAll.
/**
* Get all known mappings
*/
@Test(timeout = 60000)
public void testGetAll() {
final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
regionIdMapper.addMapping(1, new BoundingBox(1d, 2d, 1d, 2d));
regionIdMapper.addMapping(2, new BoundingBox(10d, 20d, 10d, 20d));
regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
final List<TupleStoreName> mappingResult = regionIdMapper.getAllLocalTables(DEFAULT_SSTABLE_NAME);
Assert.assertEquals(3, mappingResult.size());
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestRegionIdMapper method testMappingDisappears2.
/**
* Wait until mapping disappears
* @throws InterruptedException
* @throws TimeoutException
*/
@Test(timeout = 15000, expected = TimeoutException.class)
public void testMappingDisappears2() throws TimeoutException, InterruptedException {
final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
regionIdMapper.waitUntilMappingDisappears(3, 5, TimeUnit.SECONDS);
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestRegionIdMapper method testZeroMapping.
/**
* Test the mapping with no entries
*/
@Test(timeout = 60000)
public void testZeroMapping() {
final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
Assert.assertEquals(0, regionIdMapper.getLocalTablesForRegion(new BoundingBox(2.5d, 2.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME).size());
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestRegionIdMapper method testMappingAppears3.
/**
* Wait until mapping appears
* @throws InterruptedException
* @throws TimeoutException
*/
@Test(timeout = 15000)
public void testMappingAppears3() throws TimeoutException, InterruptedException {
final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
final Runnable runable = new Runnable() {
@Override
public void run() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
}
};
final Thread thread = new Thread(runable);
thread.start();
regionIdMapper.waitUntilMappingAppears(3, 5, TimeUnit.SECONDS);
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestRegionIdMapper method testOneMapping.
/**
* Test the mapping with one entry
*/
@Test(timeout = 60000)
public void testOneMapping() {
final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
regionIdMapper.addMapping(1, new BoundingBox(1d, 2d, 1d, 2d));
Assert.assertEquals(0, regionIdMapper.getLocalTablesForRegion(new BoundingBox(2.5d, 2.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME).size());
Assert.assertEquals(1, regionIdMapper.getLocalTablesForRegion(new BoundingBox(1.5d, 1.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME).size());
regionIdMapper.clear();
Assert.assertEquals(0, regionIdMapper.getLocalTablesForRegion(new BoundingBox(1.5d, 1.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME).size());
}
Aggregations