Package org.jboss.aerogear.android.impl.http

Examples of org.jboss.aerogear.android.impl.http.HttpStubProvider


    @Test(timeout = 500L)
    public void testEncoding() throws Exception {
        GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Point.class, new RestAdapterTest.PointTypeAdapter());
        final Charset utf_16 = Charset.forName("UTF-16");

        final HttpStubProvider provider = new HttpStubProvider(url, new HeaderAndBody(SERIALIZED_POINTS.getBytes(utf_16), new HashMap<String, Object>()));

        PipeConfig config = new PipeConfig(url, ListClassId.class);
        config.setRequestBuilder(new GsonRequestBuilder(builder.create()));
        config.setEncoding(utf_16);
        RestAdapter<ListClassId> restPipe = new RestAdapter<ListClassId>(ListClassId.class, url, config);
View Full Code Here


    @Test
    public void testSingleObjectRead() throws Exception {
        GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Point.class, new RestAdapterTest.PointTypeAdapter());
        HeaderAndBody response = new HeaderAndBody(SERIALIZED_POINTS.getBytes(), new HashMap<String, Object>());
        final HttpStubProvider provider = new HttpStubProvider(url, response);

        PipeConfig config = new PipeConfig(url, ListClassId.class);
        config.setRequestBuilder(new GsonRequestBuilder(builder.create()));

        RestAdapter<ListClassId> restPipe = new RestAdapter<ListClassId>(ListClassId.class, url, config);
View Full Code Here

    @Test
    public void testSingleObjectReadWithNestedResult() throws Exception {
        GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Point.class, new RestAdapterTest.PointTypeAdapter());
        HeaderAndBody response = new HeaderAndBody(("{\"result\":{\"points\":" + SERIALIZED_POINTS + "}}").getBytes(), new HashMap<String, Object>());
        final HttpStubProvider provider = new HttpStubProvider(url, response);

        PipeConfig config = new PipeConfig(url, ListClassId.class);
        config.setRequestBuilder(new GsonRequestBuilder(builder.create()));
        config.setDataRoot("result.points");
View Full Code Here

    @Test
    public void testReadArray() throws Exception {
        GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Point.class, new RestAdapterTest.PointTypeAdapter());
        HeaderAndBody response = new HeaderAndBody((POINTS_ARRAY).getBytes(), new HashMap<String, Object>());
        final HttpStubProvider provider = new HttpStubProvider(url, response);

        PipeConfig config = new PipeConfig(url, ListClassId.class);
        config.setRequestBuilder(new GsonRequestBuilder(builder.create()));
        config.setDataRoot("");
View Full Code Here

    public void testGsonBuilderProperty() throws Exception {
        GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Point.class, new RestAdapterTest.PointTypeAdapter());

        final ByteArrayOutputStream request = new ByteArrayOutputStream();

        final HttpStubProvider provider = new HttpStubProvider(url) {
            @Override
            public HeaderAndBody put(String id, byte[] data) {
                try {
                    request.write(data);
                } catch (IOException ex) {
View Full Code Here

    @Test()
    public void testLinkPagingReturnsData() throws InterruptedException, NoSuchFieldException, NoSuchFieldException, IllegalArgumentException,
            IllegalAccessException, Exception {
        Pipeline pipeline = new Pipeline(url);

        final HttpStubProvider provider = new HttpStubProvider(url, new HeaderAndBody(SERIALIZED_POINTS.getBytes(), new HashMap<String, Object>()));

        PageConfig pageConfig = new PageConfig();
        GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Point.class, new RestAdapterTest.PointTypeAdapter());

        PipeConfig pipeConfig = new PipeConfig(url, ListClassId.class);
View Full Code Here

                HashMap<String, Object> headers = new HashMap<String, Object>(1);
                headers
                        .put(
                                "Link",
                                "<http://example.com/TheBook/chapter2>; rel=\"previous\";title=\"previous chapter\",<http://example.com/TheBook/chapter3>; rel=\"next\";title=\"next chapter\"");
                HttpStubProvider provider = new HttpStubProvider(url, new HeaderAndBody(SERIALIZED_POINTS.getBytes(), headers));

                return provider;
            }
        });
View Full Code Here

    @Test
    public void testMultipartBuilderCall() throws MalformedURLException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, InterruptedException {
        URL url = new URL("http://example.com");
        final ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
        final HttpStubProvider provider = new HttpStubProvider(url, null) {
           
            @Override
            public HeaderAndBody put(String id, byte[] data) throws HttpException {
                byteBuffer.put(data);
                return new HeaderAndBody("{}".getBytes(), new HashMap<String, Object>());
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.android.impl.http.HttpStubProvider

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.