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

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


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

        // Entity Stream to be read with DataSourceProvider
        DataSourceProvider dsp = new DataSourceProvider();
        DataSourceProvider.ByteArrayDataSource bads =
            new DataSourceProvider.ByteArrayDataSource(bais, "text/plain");

        // Check if readable - assert true
        assertTrue(dsp.isReadable(DataSource.class, null, null, null));
        assertTrue(dsp.isReadable(Object.class, null, null, null));
        // Check if readable - assert false
        assertFalse(dsp.isReadable(DataSourceProvider.ByteArrayDataSource.class, null, null, null));
        assertFalse(" Reading to String.class is not supported", dsp.isReadable(String.class,
                                                                                null,
                                                                                null,
                                                                                null));

        DataSource ds = null;
        try {
            // Read Entity
            ds =
                dsp
                    .readFrom(null, null, null, MediaType.WILDCARD_TYPE, null, bads
                        .getInputStream());
        } catch (IOException e) {
            assertFalse(" Failed to read Entity", true);
        }
View Full Code Here


        ByteArrayInputStream bais = new ByteArrayInputStream(message.getBytes());
        DataSourceProvider.ByteArrayDataSource bads =
            new DataSourceProvider.ByteArrayDataSource(bais, "text/plain");

        // Entity Stream to be read with DataSourceProvider
        DataSourceProvider dsp = new DataSourceProvider();

        // Check if writable - assert true
        assertTrue(dsp.isWriteable(DataSourceProvider.ByteArrayDataSource.class, null, null, null));

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

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        try {
            dsp.writeTo(bads, 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

            postMethod.setRequestEntity(requestEntity);
            HttpClient client = new HttpClient();
            client.executeMethod(postMethod);

            // just use our provider to read the response
            DataSourceProvider provider = new DataSourceProvider();
            DataSource returnedData =
                provider.readFrom(DataSource.class,
                                  null,
                                  null,
                                  new MediaType("application", "datasource"),
                                  null,
                                  postMethod.getResponseBodyAsStream());
View Full Code Here

            postMethod.setRequestEntity(requestEntity);
            HttpClient client = new HttpClient();
            client.executeMethod(postMethod);

            // just use our provider to read the response
            DataSourceProvider provider = new DataSourceProvider();
            DataSource returnedData =
                provider.readFrom(DataSource.class,
                                  null,
                                  null,
                                  new MediaType("application", "datasource"),
                                  null,
                                  postMethod.getResponseBodyAsStream());
View Full Code Here

TOP

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

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.