use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestNetworkClasses method encodeAndDecodeKeepAlive2.
/**
* The the encoding and decoding of a keep alive package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void encodeAndDecodeKeepAlive2() throws IOException, PackageEncodeException {
final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
final String tablename = "testgroup_abc";
final List<Tuple> tuples = new ArrayList<>();
tuples.add(new Tuple("abc", new BoundingBox(1d, 2d, 1d, 2d), "".getBytes()));
tuples.add(new Tuple("def", new BoundingBox(2d, 2d, 4d, 20d), "".getBytes()));
tuples.add(new Tuple("xyz", new BoundingBox(10d, 20d, 10d, 20d), "".getBytes()));
final KeepAliveRequest keepAlivePackage = new KeepAliveRequest(sequenceNumber, tablename, tuples);
byte[] encodedVersion = networkPackageToByte(keepAlivePackage);
Assert.assertNotNull(encodedVersion);
final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedVersion);
final KeepAliveRequest decodedPackage = KeepAliveRequest.decodeTuple(bb);
Assert.assertEquals(keepAlivePackage.getTablename(), decodedPackage.getTablename());
Assert.assertEquals(keepAlivePackage.getTuples().size(), decodedPackage.getTuples().size());
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestNetworkClasses method encodeAndDecodeInsertTuple2.
/**
* The the encoding and decoding of an insert tuple package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void encodeAndDecodeInsertTuple2() throws IOException, PackageEncodeException {
final Tuple tuple = new Tuple("key", new BoundingBox(1.3244343224, 232.232333343, 34324.343, 343243.0), "abc".getBytes(), 12);
final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
final InsertTupleRequest insertPackage = new InsertTupleRequest(sequenceNumber, ROUTING_HEADER_UNROUTED, new TupleStoreName("test"), tuple);
byte[] encodedVersion = networkPackageToByte(insertPackage);
Assert.assertNotNull(encodedVersion);
final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedVersion);
final InsertTupleRequest decodedPackage = InsertTupleRequest.decodeTuple(bb);
Assert.assertEquals(insertPackage.getTuple(), decodedPackage.getTuple());
Assert.assertEquals(insertPackage.getTable(), decodedPackage.getTable());
Assert.assertEquals(insertPackage.getRoutingHeader(), new RoutingHeader(false));
Assert.assertEquals(insertPackage, decodedPackage);
Assert.assertEquals(insertPackage.hashCode(), decodedPackage.hashCode());
Assert.assertTrue(insertPackage.toString().length() > 10);
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestNetworkClasses method testDecodeJoinQuery.
/**
* Test decode bounding box query
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void testDecodeJoinQuery() throws IOException, PackageEncodeException {
final List<TupleStoreName> tables = Arrays.asList(new TupleStoreName("3dgroup_table1"), new TupleStoreName("3dgroup_table2"), new TupleStoreName("3dgroup_table3"));
final BoundingBox boundingBox = new BoundingBox(10d, 20d);
final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
final QueryJoinRequest queryRequest = new QueryJoinRequest(sequenceNumber, ROUTING_HEADER_ROUTED, tables, boundingBox, false, (short) 10);
byte[] encodedPackage = networkPackageToByte(queryRequest);
Assert.assertNotNull(encodedPackage);
final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedPackage);
boolean result = NetworkPackageDecoder.validateRequestPackageHeader(bb, NetworkConst.REQUEST_TYPE_QUERY);
Assert.assertTrue(result);
final QueryJoinRequest decodedPackage = QueryJoinRequest.decodeTuple(bb);
Assert.assertEquals(queryRequest.getBoundingBox(), decodedPackage.getBoundingBox());
Assert.assertEquals(tables, decodedPackage.getTables());
Assert.assertEquals(queryRequest.isPagingEnabled(), decodedPackage.isPagingEnabled());
Assert.assertEquals(queryRequest.getTuplesPerPage(), decodedPackage.getTuplesPerPage());
Assert.assertEquals(NetworkConst.REQUEST_QUERY_JOIN, NetworkPackageDecoder.getQueryTypeFromRequest(bb));
Assert.assertEquals(queryRequest.toString(), decodedPackage.toString());
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestNetworkClasses method testDecodeCointinousBoundingBoxQuery.
/**
* Test decode bounding box query
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void testDecodeCointinousBoundingBoxQuery() throws IOException, PackageEncodeException {
final String table = "table1";
final BoundingBox boundingBox = new BoundingBox(10d, 20d);
final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
final QueryBoundingBoxContinuousRequest queryRequest = new QueryBoundingBoxContinuousRequest(sequenceNumber, ROUTING_HEADER_ROUTED, table, boundingBox);
byte[] encodedPackage = networkPackageToByte(queryRequest);
Assert.assertNotNull(encodedPackage);
final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedPackage);
boolean result = NetworkPackageDecoder.validateRequestPackageHeader(bb, NetworkConst.REQUEST_TYPE_QUERY);
Assert.assertTrue(result);
final QueryBoundingBoxContinuousRequest decodedPackage = QueryBoundingBoxContinuousRequest.decodeTuple(bb);
Assert.assertEquals(queryRequest.getBoundingBox(), decodedPackage.getBoundingBox());
Assert.assertEquals(queryRequest.getTable(), decodedPackage.getTable());
Assert.assertEquals(NetworkConst.REQUEST_QUERY_CONTINUOUS_BBOX, NetworkPackageDecoder.getQueryTypeFromRequest(bb));
Assert.assertTrue(queryRequest.toString().length() > 10);
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestRegionIdMapper method testMappingAppears1.
/**
* Wait until mapping appears
* @throws InterruptedException
* @throws TimeoutException
*/
@Test(timeout = 10000)
public void testMappingAppears1() throws TimeoutException, InterruptedException {
final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
regionIdMapper.waitUntilMappingAppears(3);
}
Aggregations