Search in sources :

Example 1 with ObjectSerializer

use of org.bboxdb.commons.ObjectSerializer in project bboxdb by jnidzwetzki.

the class TestMemtable method testInsertAndReadPerson.

/**
 * Test insert2
 * @throws Exception
 */
@Test(timeout = 60000)
public void testInsertAndReadPerson() throws Exception {
    final PersonEntity person1 = new PersonEntity("Jan", "Jansen", 30);
    final ObjectSerializer<PersonEntity> serializer = new ObjectSerializer<PersonEntity>();
    final Tuple createdTuple = new Tuple("1", null, serializer.serialize(person1));
    memtable.put(createdTuple);
    final List<Tuple> readTupleList = memtable.get("1");
    Assert.assertTrue(readTupleList.size() == 1);
    final Tuple readTuple = readTupleList.get(0);
    final PersonEntity readPerson1 = serializer.deserialize(readTuple.getDataBytes());
    Assert.assertEquals(person1, readPerson1);
}
Also used : PersonEntity(org.bboxdb.commons.entity.PersonEntity) ObjectSerializer(org.bboxdb.commons.ObjectSerializer) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 2 with ObjectSerializer

use of org.bboxdb.commons.ObjectSerializer in project bboxdb by jnidzwetzki.

the class TestObjectSerializer method testSerializer2.

@Test(timeout = 60000)
public void testSerializer2() throws ClassNotFoundException, IOException {
    final PersonEntity test = new PersonEntity("Jan", "Jensen", 30);
    ObjectSerializer<PersonEntity> serializer = new ObjectSerializer<PersonEntity>();
    final PersonEntity deserialize = serializer.deserialize(serializer.serialize(test));
    Assert.assertEquals(test, deserialize);
    Assert.assertTrue(test.toString().length() > 10);
    Assert.assertEquals(test.hashCode(), deserialize.hashCode());
}
Also used : PersonEntity(org.bboxdb.commons.entity.PersonEntity) ObjectSerializer(org.bboxdb.commons.ObjectSerializer) Test(org.junit.Test)

Example 3 with ObjectSerializer

use of org.bboxdb.commons.ObjectSerializer in project bboxdb by jnidzwetzki.

the class TestStorageManager method testInsertAndReadPerson.

@Test(timeout = 60000)
public void testInsertAndReadPerson() throws Exception {
    final PersonEntity person1 = new PersonEntity("Jan", "Jansen", 30);
    final ObjectSerializer<PersonEntity> serializer = new ObjectSerializer<PersonEntity>();
    final Tuple createdTuple = new Tuple("1", BoundingBox.FULL_SPACE, serializer.serialize(person1));
    storageManager.put(createdTuple);
    final List<Tuple> readTuples = storageManager.get("1");
    Assert.assertTrue(readTuples.size() == 1);
    final Tuple readTuple = readTuples.get(0);
    final PersonEntity readPerson1 = serializer.deserialize(readTuple.getDataBytes());
    Assert.assertEquals(person1, readPerson1);
}
Also used : PersonEntity(org.bboxdb.commons.entity.PersonEntity) ObjectSerializer(org.bboxdb.commons.ObjectSerializer) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Aggregations

ObjectSerializer (org.bboxdb.commons.ObjectSerializer)3 PersonEntity (org.bboxdb.commons.entity.PersonEntity)3 Test (org.junit.Test)3 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)2 Tuple (org.bboxdb.storage.entity.Tuple)2