Package org.apache.wink.common.internal.providers.entity

Examples of org.apache.wink.common.internal.providers.entity.ReaderProvider


        // Entity Input Stream
        ByteArrayInputStream bais = new ByteArrayInputStream(message.getBytes());

        // Entity Stream to be read with ReaderProvider
        ReaderProvider rp = new ReaderProvider();

        // Check if readable - assert true
        assertTrue(rp.isReadable(Reader.class, null, null, null));
        assertTrue(rp.isReadable(Object.class, null, null, null));
        // Check if readable - assert false
        assertFalse(rp.isReadable(StringReader.class, null, null, null));
        assertFalse(" Reading from String.class is not supported", rp.isReadable(String.class,
                                                                                 null,
                                                                                 null,
                                                                                 null));

        Reader reader = null;
        try {
            // Read Entity
            reader = rp.readFrom(null, null, null, MediaType.WILDCARD_TYPE, null, bais);
        } catch (IOException e) {
            assertFalse(" Failed to read Entity", true);
        }

        BufferedReader sr = new BufferedReader(reader);
View Full Code Here


    public void testMessageWriter() throws UnsupportedEncodingException {

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        // Entity Stream to be read with ReaderProvider
        ReaderProvider rp = new ReaderProvider();

        // Check if writable
        assertTrue(rp.isWriteable(StringReader.class, null, null, null));
        // Check if readable - assert false
        assertFalse(" Writting from String.class is not supported", rp.isWriteable(String.class,
                                                                                   null,
                                                                                   null,
                                                                                   null));

        StringReader reader = new StringReader(message);

        try {
            rp.writeTo(reader, null, null, null, MediaType.WILDCARD_TYPE, null, baos);
        } catch (IOException e) {
            assertFalse(" Failed to write Entity", true);
        }

        assertEquals(message, new String(baos.toByteArray()));
View Full Code Here

    @Test
    public void testMessageWriterClose() throws UnsupportedEncodingException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        // Entity Stream to be read with ReaderProvider
        ReaderProvider rp = new ReaderProvider();

        // Check if writable
        assertTrue(rp.isWriteable(MyReader.class, null, null, null));
        // Check if readable - assert false
        assertFalse(" Writting from String.class is not supported", rp.isWriteable(String.class,
                                                                                   null,
                                                                                   null,
                                                                                   null));

        MyReader reader = new MyReader(new StringReader(message));

        try {
            rp.writeTo(reader, null, null, null, MediaType.WILDCARD_TYPE, null, baos);
        } catch (IOException e) {
            assertFalse(" Failed to write Entity", true);
        }

        assertEquals(message, new String(baos.toByteArray()));
View Full Code Here

        // Entity Input Stream
        ByteArrayInputStream bais = new ByteArrayInputStream(message.getBytes());

        // Entity Stream to be read with ReaderProvider
        ReaderProvider rp = new ReaderProvider();

        // Check if readable - assert true
        assertTrue(rp.isReadable(Reader.class, null, null, null));
        assertTrue(rp.isReadable(Object.class, null, null, null));
        // Check if readable - assert false
        assertFalse(rp.isReadable(StringReader.class, null, null, null));
        assertFalse(" Reading from String.class is not supported", rp.isReadable(String.class,
                                                                                 null,
                                                                                 null,
                                                                                 null));

        Reader reader = null;
        try {
            // Read Entity
            reader = rp.readFrom(null, null, null, MediaType.WILDCARD_TYPE, null, bais);
        } catch (IOException e) {
            assertFalse(" Failed to read Entity", true);
        }

        BufferedReader sr = new BufferedReader(reader);
View Full Code Here

    public void testMessageWriter() throws UnsupportedEncodingException {

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        // Entity Stream to be read with ReaderProvider
        ReaderProvider rp = new ReaderProvider();

        // Check if writable
        assertTrue(rp.isWriteable(StringReader.class, null, null, null));
        // Check if readable - assert false
        assertFalse(" Writting from String.class is not supported", rp.isWriteable(String.class,
                                                                                   null,
                                                                                   null,
                                                                                   null));

        StringReader reader = new StringReader(message);

        try {
            rp.writeTo(reader, null, null, null, MediaType.WILDCARD_TYPE, null, baos);
        } catch (IOException e) {
            assertFalse(" Failed to write Entity", true);
        }

        assertEquals(message, new String(baos.toByteArray()));
View Full Code Here

TOP

Related Classes of org.apache.wink.common.internal.providers.entity.ReaderProvider

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.