Search in sources :

Example 1 with ListTablesResponse

use of org.bboxdb.network.packages.response.ListTablesResponse in project bboxdb by jnidzwetzki.

the class TestNetworkClasses method testListTablesResponse.

/**
 * Try to encode and decode the list tables response
 * @throws PackageEncodeException
 * @throws IOException
 */
@Test(timeout = 60000)
public void testListTablesResponse() throws PackageEncodeException, IOException {
    final List<TupleStoreName> tables = new ArrayList<TupleStoreName>();
    tables.add(new TupleStoreName("3_group1_table1"));
    tables.add(new TupleStoreName("3_group1_testtable"));
    tables.add(new TupleStoreName("3_group1_test4711"));
    tables.add(new TupleStoreName("3_group1_mytest57"));
    final ListTablesResponse response = new ListTablesResponse((short) 3, tables);
    final byte[] encodedPackage = networkPackageToByte(response);
    Assert.assertNotNull(encodedPackage);
    final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedPackage);
    final ListTablesResponse responseDecoded = ListTablesResponse.decodePackage(bb);
    final List<TupleStoreName> myTables = responseDecoded.getTables();
    Assert.assertEquals(tables, myTables);
    Assert.assertEquals(tables.size(), myTables.size());
}
Also used : ArrayList(java.util.ArrayList) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) ListTablesResponse(org.bboxdb.network.packages.response.ListTablesResponse) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 ListTablesResponse (org.bboxdb.network.packages.response.ListTablesResponse)1 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)1 Test (org.junit.Test)1