use of org.bboxdb.network.routing.RoutingHeader in project bboxdb by jnidzwetzki.
the class TestNetworkClasses method encodeAndDecodeDeletedTuple1.
/**
* The the encoding and decoding of an insert tuple package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void encodeAndDecodeDeletedTuple1() throws IOException, PackageEncodeException {
final Tuple tuple = new DeletedTuple("key", 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.assertEquals(insertPackage.toString(), decodedPackage.toString());
Assert.assertTrue(TupleHelper.isDeletedTuple(decodedPackage.getTuple()));
}
use of org.bboxdb.network.routing.RoutingHeader in project bboxdb by jnidzwetzki.
the class TestNetworkClasses method encodeAndDecodeInsertTupleWithCustomHeader.
/**
* The the encoding and decoding of an insert tuple package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void encodeAndDecodeInsertTupleWithCustomHeader() throws IOException, PackageEncodeException {
final RoutingHeader routingHeader = ROUTING_HEADER_ROUTED;
final Tuple tuple = new Tuple("key", BoundingBox.FULL_SPACE, "abc".getBytes(), 12);
final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
final InsertTupleRequest insertPackage = new InsertTupleRequest(sequenceNumber, ROUTING_HEADER_ROUTED, new TupleStoreName("test"), tuple);
Assert.assertEquals(routingHeader, insertPackage.getRoutingHeader());
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(routingHeader, decodedPackage.getRoutingHeader());
Assert.assertFalse(insertPackage.getRoutingHeader().equals(new RoutingHeader(false)));
Assert.assertEquals(insertPackage, decodedPackage);
Assert.assertEquals(insertPackage.hashCode(), decodedPackage.hashCode());
Assert.assertTrue(insertPackage.toString().length() > 10);
}
use of org.bboxdb.network.routing.RoutingHeader in project bboxdb by jnidzwetzki.
the class TestRoutingHeader method testSetHopValid.
/**
* Test set valid next hops
*/
@Test(timeout = 60000)
public void testSetHopValid() {
final RoutingHeader routingHeader = new RoutingHeader((short) 10, "node1:12,2;node2:23,1");
routingHeader.setHop((short) 0);
routingHeader.setHop((short) 1);
}
use of org.bboxdb.network.routing.RoutingHeader in project bboxdb by jnidzwetzki.
the class TestRoutingHeader method testRoutedPackageHeader1.
/**
* Test the encoding and the decoding of an routed package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void testRoutedPackageHeader1() throws IOException, PackageEncodeException {
final RoutingHeader routingHeader = new RoutingHeader((short) 10, "node1:12,1;node2:23,2");
final byte[] encodedBytes = RoutingHeaderParser.encodeHeader(routingHeader);
final ByteArrayInputStream bis = new ByteArrayInputStream(encodedBytes);
final RoutingHeader resultRoutingHeader = RoutingHeaderParser.decodeRoutingHeader(bis);
Assert.assertEquals(routingHeader, resultRoutingHeader);
}
use of org.bboxdb.network.routing.RoutingHeader in project bboxdb by jnidzwetzki.
the class TestRoutingHeader method testRoutedPackageHeader3.
/**
* Test the encoding and the decoding of an routed package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void testRoutedPackageHeader3() throws IOException, PackageEncodeException {
final RoutingHeader routingHeader = new RoutingHeader((short) 10, "node1:12,1;node2:23,2");
final byte[] encodedBytes = RoutingHeaderParser.encodeHeader(routingHeader);
final ByteBuffer bb = ByteBuffer.wrap(encodedBytes);
bb.order(Const.APPLICATION_BYTE_ORDER);
Assert.assertEquals(0, bb.position());
final RoutingHeader resultRoutingHeader = RoutingHeaderParser.decodeRoutingHeader(bb);
Assert.assertEquals(0, bb.remaining());
Assert.assertEquals(routingHeader, resultRoutingHeader);
Assert.assertEquals(routingHeader.hashCode(), resultRoutingHeader.hashCode());
Assert.assertTrue(routingHeader.toString().length() > 10);
}
Aggregations