Package org.jboss.aerogear.android.http

Examples of org.jboss.aerogear.android.http.HeaderAndBody


    @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()));
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

                try {
                    request.write(data);
                } catch (IOException ex) {
                    throw new RuntimeException(ex);
                }
                return new HeaderAndBody(data, new HashMap<String, Object>());
            }

            @Override
            public HeaderAndBody post(byte[] data) {
                try {
                    request.write(data);
                } catch (IOException ex) {
                    throw new RuntimeException(ex);
                }
                return new HeaderAndBody(data, new HashMap<String, Object>());
            }
        };

        PipeConfig config = new PipeConfig(url, ListClassId.class);
        config.setResponseParser(new GsonResponseParser(builder.create()));
View Full Code Here

        final CountDownLatch latch = new CountDownLatch(1);

        HttpProviderFactory factory = mock(HttpProviderFactory.class);
        HttpProvider provider = mock(HttpProvider.class);
        HeaderAndBody headerAndBody = mock(HeaderAndBody.class);
        when(headerAndBody.getBody()).thenReturn("".getBytes());
        when(provider.get()).thenReturn(headerAndBody);
        when(factory.get(anyObject(), anyObject())).thenReturn(provider);

        AuthorizationFields authFields = new AuthorizationFields();
        authFields.addQueryParameter("token", "token");
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

        PipeConfig config = new PipeConfig(url, ListClassId.class);
        config.setPageConfig(pageConfig);

        RestAdapter adapter = new RestAdapter(Data.class, url, config);
        List<Data> list = new ArrayList<Data>();
        HeaderAndBody response = new HeaderAndBody(new byte[] {}, new HashMap<String, Object>() {
            {
                put("next", "chapter3");
                put("previous", "chapter2");
            }
        });
View Full Code Here

        RestAdapter adapter = new RestAdapter(Data.class, url, config);
        Object restRunner = UnitTestUtils.getPrivateField(adapter, "restRunner");

        List<Data> list = new ArrayList<Data>();
        HeaderAndBody response = new HeaderAndBody("{\"pages\":{\"next\":\"chapter3\",\"previous\":\"chapter2\"}}".getBytes(), new HashMap<String, Object>());
        JSONObject where = new JSONObject();
        Method method = restRunner.getClass().getDeclaredMethod("computePagedList", List.class, HeaderAndBody.class, JSONObject.class, Pipe.class);
        method.setAccessible(true);

        WrappingPagedList<Data> pagedList = (WrappingPagedList<Data>) method.invoke(restRunner, list, response, where, adapter);
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.android.http.HeaderAndBody

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.