use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class BinarySerializerTest method testEdge.
@Test
public void testEdge() {
HugeConfig config = FakeObjects.newConfig();
BinarySerializer ser = new BinarySerializer(config);
FakeObjects objects = new FakeObjects();
HugeEdge edge1 = objects.newEdge(123, 456);
HugeEdge edge2 = objects.newEdge(147, 789);
BackendEntry entry1 = ser.writeEdge(edge1);
HugeVertex vertex1 = ser.readVertex(edge1.graph(), entry1);
Assert.assertEquals(1, vertex1.getEdges().size());
HugeEdge edge = vertex1.getEdges().iterator().next();
Assert.assertEquals(edge1, edge);
assertCollectionEquals(edge1.getProperties(), edge.getProperties());
BackendEntry entry2 = ser.writeEdge(edge2);
HugeVertex vertex2 = ser.readVertex(edge1.graph(), entry2);
Assert.assertEquals(1, vertex2.getEdges().size());
edge = vertex2.getEdges().iterator().next();
Assert.assertEquals(edge2, edge);
assertCollectionEquals(edge2.getProperties(), edge.getProperties());
}
use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class BinarySerializerTest method testVertex.
@Test
public void testVertex() {
HugeConfig config = FakeObjects.newConfig();
BinarySerializer ser = new BinarySerializer(config);
HugeEdge edge = new FakeObjects().newEdge(123, 456);
BackendEntry entry1 = ser.writeVertex(edge.sourceVertex());
HugeVertex vertex1 = ser.readVertex(edge.graph(), entry1);
Assert.assertEquals(edge.sourceVertex(), vertex1);
assertCollectionEquals(edge.sourceVertex().getProperties(), vertex1.getProperties());
BackendEntry entry2 = ser.writeVertex(edge.targetVertex());
HugeVertex vertex2 = ser.readVertex(edge.graph(), entry2);
Assert.assertEquals(edge.targetVertex(), vertex2);
assertCollectionEquals(edge.targetVertex().getProperties(), vertex2.getProperties());
Whitebox.setInternalState(vertex2, "removed", true);
Assert.assertTrue(vertex2.removed());
BackendEntry entry3 = ser.writeVertex(vertex2);
Assert.assertEquals(0, entry3.columnsSize());
Assert.assertNull(ser.readVertex(edge.graph(), null));
}
use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class SerializerFactoryTest method testRegister.
@Test
public void testRegister() {
HugeConfig config = FakeObjects.newConfig();
SerializerFactory.register("fake", FakeSerializer.class.getName());
Assert.assertEquals(FakeSerializer.class, SerializerFactory.serializer(config, "fake").getClass());
Assert.assertThrows(BackendException.class, () -> {
// exist
SerializerFactory.register("fake", FakeSerializer.class.getName());
}, e -> {
Assert.assertContains("Exists serializer:", e.getMessage());
});
Assert.assertThrows(BackendException.class, () -> {
// invalid class
SerializerFactory.register("fake", "com.baidu.hugegraph.Invalid");
}, e -> {
Assert.assertContains("Invalid class:", e.getMessage());
});
Assert.assertThrows(BackendException.class, () -> {
// subclass
SerializerFactory.register("fake", "com.baidu.hugegraph.HugeGraph");
}, e -> {
Assert.assertContains("Class is not a subclass of class", e.getMessage());
});
}
use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class SecurityManagerTest method loadGraph.
private static HugeGraph loadGraph(boolean needClear) {
HugeConfig config = FakeObjects.newConfig();
HugeGraph graph = HugeFactory.open(config);
if (needClear) {
graph.clearBackend();
}
graph.initBackend();
graph.serverStarted(IdGenerator.of("server1"), NodeRole.MASTER);
return graph;
}
use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class BaseRocksDBUnitTest method open.
private static RocksDBSessions open(String table) throws RocksDBException {
HugeConfig config = FakeObjects.newConfig();
RocksDBSessions rocks = new RocksDBStdSessions(config, "db", "store", DB_PATH, DB_PATH);
rocks.createTable(table);
return rocks;
}
Aggregations