Search in sources :

Example 1 with AbstractSerializer

use of com.baidu.hugegraph.backend.serializer.AbstractSerializer in project incubator-hugegraph by apache.

the class SerializerFactoryTest method testSerializer.

@Test
public void testSerializer() {
    HugeConfig config = FakeObjects.newConfig();
    AbstractSerializer serializer = SerializerFactory.serializer(config, "text");
    Assert.assertEquals(TextSerializer.class, serializer.getClass());
    serializer = SerializerFactory.serializer(config, "binary");
    Assert.assertEquals(BinarySerializer.class, serializer.getClass());
    serializer = SerializerFactory.serializer(config, "binaryscatter");
    Assert.assertEquals(BinaryScatterSerializer.class, serializer.getClass());
    Assert.assertThrows(BackendException.class, () -> {
        SerializerFactory.serializer(config, "invalid");
    }, e -> {
        Assert.assertContains("Not exists serializer:", e.getMessage());
    });
}
Also used : AbstractSerializer(com.baidu.hugegraph.backend.serializer.AbstractSerializer) HugeConfig(com.baidu.hugegraph.config.HugeConfig) BaseUnitTest(com.baidu.hugegraph.unit.BaseUnitTest) Test(org.junit.Test)

Example 2 with AbstractSerializer

use of com.baidu.hugegraph.backend.serializer.AbstractSerializer in project incubator-hugegraph by apache.

the class StandardHugeGraph method serializer.

private AbstractSerializer serializer() {
    String name = this.configuration.get(CoreOptions.SERIALIZER);
    LOG.debug("Loading serializer '{}' for graph '{}'", name, this.name);
    AbstractSerializer serializer = SerializerFactory.serializer(this.configuration, name);
    if (serializer == null) {
        throw new HugeException("Can't load serializer with name " + name);
    }
    return serializer;
}
Also used : AbstractSerializer(com.baidu.hugegraph.backend.serializer.AbstractSerializer)

Aggregations

AbstractSerializer (com.baidu.hugegraph.backend.serializer.AbstractSerializer)2 HugeConfig (com.baidu.hugegraph.config.HugeConfig)1 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)1 Test (org.junit.Test)1