Search in sources :

Example 1 with KriptonYamlContext

use of com.abubusoft.kripton.KriptonYamlContext in project kripton by xcesco.

the class AbstractBindTypeProcessorTest method setup.

@Before
public void setup() {
    KriptonBinder.registryBinder(new KriptonYamlContext());
    KriptonBinder.registryBinder(new KriptonPropertiesContext());
    KriptonBinder.registryBinder(new KriptonXmlContext());
    KriptonBinder.registryBinder(new KriptonCborContext());
    if (BaseProcessor.DEBUG_MODE) {
        testType = TestType.PREPARE_TEST_JAVA_LIBRARY;
        destinationPath = PathSourceType.DEST_TEST_JAVA_LIBRARY;
    } else {
        testType = TestType.NONE;
    }
}
Also used : KriptonYamlContext(com.abubusoft.kripton.KriptonYamlContext) KriptonXmlContext(com.abubusoft.kripton.KriptonXmlContext) KriptonPropertiesContext(com.abubusoft.kripton.KriptonPropertiesContext) KriptonCborContext(com.abubusoft.kripton.KriptonCborContext) Before(org.junit.Before)

Example 2 with KriptonYamlContext

use of com.abubusoft.kripton.KriptonYamlContext in project kripton by xcesco.

the class AbstractBaseTest method setup.

@Before
public void setup() {
    final String value = System.getProperty(KRIPTON_DEBUG_MODE);
    if ("false".equals(value)) {
        // we are in test, but we don't see log on System.out
        System.setOut(new PrintStream(new NullOutputStream()));
        System.setErr(new PrintStream(new NullOutputStream()));
    }
    // when we run junit test, AnnotationProcessor is always in TEST_MODE
    System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tH:%1$tM:%1$tS.%1$tL %4$-7s [%3$s] (%2$s) %5$s %6$s%n");
    KriptonBinder.registryBinder(new KriptonYamlContext());
    KriptonBinder.registryBinder(new KriptonPropertiesContext());
    KriptonBinder.registryBinder(new KriptonCborContext());
    KriptonBinder.registryBinder(new KriptonSmileContext());
}
Also used : PrintStream(java.io.PrintStream) KriptonYamlContext(com.abubusoft.kripton.KriptonYamlContext) KriptonSmileContext(com.abubusoft.kripton.KriptonSmileContext) KriptonPropertiesContext(com.abubusoft.kripton.KriptonPropertiesContext) KriptonCborContext(com.abubusoft.kripton.KriptonCborContext) NullOutputStream(org.apache.commons.io.output.NullOutputStream) Before(org.junit.Before)

Example 3 with KriptonYamlContext

use of com.abubusoft.kripton.KriptonYamlContext in project kripton by xcesco.

the class Main method main.

public static void main(String[] args) throws Exception {
    Person user = new Person();
    user.email = "dummy@test.org";
    user.name = "Tonj";
    user.surname = "Manero";
    user.username = "1234";
    // registry xml
    KriptonBinder.registryBinder(new KriptonXmlContext());
    KriptonBinder.registryBinder(new KriptonCborContext());
    KriptonBinder.registryBinder(new KriptonPropertiesContext());
    KriptonBinder.registryBinder(new KriptonYamlContext());
    {
        BinderContext binderContext = KriptonBinder.jsonBind();
        String buffer = binderContext.serialize(user);
        Person user2 = binderContext.parse(buffer, Person.class);
        System.out.println(buffer);
    }
    {
        BinderContext binderContext = KriptonBinder.bind(BinderType.XML);
        String buffer = binderContext.serialize(user);
        Person user2 = binderContext.parse(buffer, Person.class);
        System.out.println(buffer);
    }
    {
        Person person = new Person();
        person.email = "tonj.manero@mail.com";
        person.name = "Tonj";
        person.surname = "Manero";
        person.username = "tonj.manero";
        String result = KriptonBinder.jsonBind().serialize(person);
        System.out.println(result);
    }
    {
        BinderContext binderContext = KriptonBinder.bind(BinderType.CBOR);
        // We use this buffer as output for serialization
        KriptonByteArrayOutputStream buffer = new KriptonByteArrayOutputStream();
        binderContext.serialize(user, buffer);
        Person user2 = binderContext.parse(buffer.getByteBuffer(), Person.class);
        System.out.println(toString(buffer.getByteBufferCopy()));
    }
    {
        BinderContext binderContext = KriptonBinder.bind(BinderType.PROPERTIES);
        String buffer = binderContext.serialize(user);
        Person user2 = binderContext.parse(buffer, Person.class);
        System.out.println(buffer);
    }
    {
        BinderContext binderContext = KriptonBinder.bind(BinderType.YAML);
        String buffer = binderContext.serialize(user);
        Person user2 = binderContext.parse(buffer, Person.class);
        System.out.println(buffer);
    }
}
Also used : KriptonYamlContext(com.abubusoft.kripton.KriptonYamlContext) KriptonXmlContext(com.abubusoft.kripton.KriptonXmlContext) KriptonPropertiesContext(com.abubusoft.kripton.KriptonPropertiesContext) KriptonCborContext(com.abubusoft.kripton.KriptonCborContext) BinderContext(com.abubusoft.kripton.BinderContext) KriptonByteArrayOutputStream(com.abubusoft.kripton.common.KriptonByteArrayOutputStream)

Aggregations

KriptonCborContext (com.abubusoft.kripton.KriptonCborContext)3 KriptonPropertiesContext (com.abubusoft.kripton.KriptonPropertiesContext)3 KriptonYamlContext (com.abubusoft.kripton.KriptonYamlContext)3 KriptonXmlContext (com.abubusoft.kripton.KriptonXmlContext)2 Before (org.junit.Before)2 BinderContext (com.abubusoft.kripton.BinderContext)1 KriptonSmileContext (com.abubusoft.kripton.KriptonSmileContext)1 KriptonByteArrayOutputStream (com.abubusoft.kripton.common.KriptonByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 NullOutputStream (org.apache.commons.io.output.NullOutputStream)1