Package org.apache.pivot.serialization

Examples of org.apache.pivot.serialization.BinarySerializer


import static org.junit.Assert.fail;

public class BinarySerializerTest {
    @Test
    public void testBinarySerializer() {
        Serializer<Object> serializer = new BinarySerializer();

        Object[] outputData = {
            "Hello World",
            123.456,
            true
        };
        Object[] inputData;

        try {
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            try {
                serializer.writeObject(outputData, outputStream);
            } finally {
                outputStream.close();
            }

            ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
            try {
                inputData = (Object[])serializer.readObject(inputStream);
            } finally {
                inputStream.close();
            }

            assertArrayEquals(outputData, inputData);
View Full Code Here


        TaskGroup queryGroup = new TaskGroup();

        // GET
        final GetQuery getQuery = new GetQuery(HOSTNAME, PORT, PATH, SECURE);
        getQuery.getParameters().put("a", "b");
        getQuery.setSerializer(new BinarySerializer());
        getQuery.getRequestHeaders().add("bar", "hello");
        getQuery.getRequestHeaders().add("bar", "world");
        authentication.authenticate(getQuery);
        queryGroup.add(getQuery);
View Full Code Here

        response.setStatus(200);
        response.setHeader("foo", "hello");
        response.addHeader("foo", "world");

        BinarySerializer serializer = new BinarySerializer();
        response.setContentType(serializer.getMIMEType(map));

        try {
            serializer.writeObject(map, response.getOutputStream());
        } catch(SerializationException exception) {
            throw new ServletException(exception);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.pivot.serialization.BinarySerializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.