Package org.fusesource.restygwt.client

Examples of org.fusesource.restygwt.client.Resource


  public void testAddQueryParam() {
    Map<String, String> headersMap = new HashMap<String, String>();
    headersMap.put("Authentication", "Basic 4711");
    headersMap.put("Accept", "application/json");

    Resource resource = new Resource(GWT.getModuleBaseURL()
        + "api/getendpoint", headersMap);

    Resource resourceInTest = resource.addQueryParam("p1", "v1");

    assertMapsAreEqual(headersMap, resourceInTest.getHeaders());
  }
View Full Code Here


 
  public void testAddQueryParams() {
    Map<String, String> headersMap = new HashMap<String, String>();
    headersMap.put("Authentication", "Basic 4711");
    headersMap.put("Accept", "application/json");
    Resource resource = new Resource(GWT.getModuleBaseURL()
        + "api/getendpoint", headersMap);

    List<String> paramValues = Arrays.asList(new String[] {"v1","v2"});
    Resource resourceInTest = resource.addQueryParams("p1", paramValues);

    assertMapsAreEqual(headersMap, resourceInTest.getHeaders());
  }
View Full Code Here

    public void testFlakyConnection() {
        /*
         *  setup the service, usually done in gin
         */
        Resource resource = new Resource(GWT.getModuleBaseURL() + "api/getendpoint");
        service = GWT.create(ExampleService.class);
        ((RestServiceProxy) service).setResource(resource);

        service.getExampleDto(new MethodCallback<ExampleDto>() {
            @Override
View Full Code Here

   
    @Override
    protected void gwtSetUp() throws Exception {
        super.gwtSetUp();       
        service = GWT.create(QueryTestRestService.class)
        Resource resource = new Resource(GWT.getModuleBaseURL() + "echo");
        ((RestServiceProxy) service).setResource(resource);
    }
View Full Code Here

       
        Dispatcher dispatcher = new DefaultFilterawareDispatcher(cachingDispatcherFilter);

        Defaults.setDispatcher(dispatcher);

        Resource resource = new Resource(GWT.getModuleBaseURL() + "api/getendpoint");
        final ExampleService service = GWT.create(ExampleService.class);
        ((RestServiceProxy) service).setResource(resource);

        Timer timer = new Timer() {
            @Override
View Full Code Here

    return "org.fusesource.restygwt.BasicTestGwt";
  }

  // Simple Uri
  public void testUri() {
    Resource r1 = new Resource(BU);

    assertEquals(BU, r1.getPath());
    assertEquals(null, r1.getQuery());
    assertEquals(BU, r1.getUri());

    Resource r2 = r1.addQueryParam("a", "1").addQueryParam("b", "2");

    assertEquals(BU, r2.getPath());
    assertEquals(EQ, r2.getQuery());
    assertEquals(BU + "?" + EQ, r2.getUri());

    assertNull(r2.getHeaders());
  }
View Full Code Here

  public void testUri_Headers() {
    Map<String, String> headersMap = new HashMap<String, String>();
    headersMap.put("Authentication", "Basic 4711");
    headersMap.put("Accept", "application/json");

    Resource r1 = new Resource(BU, headersMap);

    assertEquals(BU, r1.getPath());
    assertEquals(null, r1.getQuery());
    assertEquals(BU, r1.getUri());

    Resource r2 = r1.addQueryParam("a", "1").addQueryParam("b", "2");

    assertEquals(BU, r2.getPath());
    assertEquals(EQ, r2.getQuery());
    assertEquals(BU + "?" + EQ, r2.getUri());

    assertEquals(2, r2.getHeaders().size());
  }
View Full Code Here

    assertEquals(2, r2.getHeaders().size());
  }

  public void testUri_Query() {
    Resource r1 = new Resource(BU, "x=y");

    assertEquals(BU, r1.getPath());
    assertEquals("x=y", r1.getQuery());
    assertEquals(BU + "?" + "x=y", r1.getUri());

    Resource r2 = r1.addQueryParam("a", "1").addQueryParam("b", "2");

    assertEquals(BU, r2.getPath());
    assertEquals("x=y" + "&" + EQ, r2.getQuery());
    assertEquals(BU + "?" + "x=y" + "&" + EQ, r2.getUri());

    assertNull(r2.getHeaders());
  }
View Full Code Here

  public void testUri_Query_Headers() {
    Map<String, String> headersMap = new HashMap<String, String>();
    headersMap.put("Authentication", "Basic 4711");
    headersMap.put("Accept", "application/json");

    Resource r1 = new Resource(BU, "x=y", headersMap);

    assertEquals(BU, r1.getPath());
    assertEquals("x=y", r1.getQuery());
    assertEquals(BU + "?" + "x=y", r1.getUri());

    Resource r2 = r1.addQueryParam("a", "1").addQueryParam("b", "2");

    assertEquals(BU, r2.getPath());
    assertEquals("x=y" + "&" + EQ, r2.getQuery());
    assertEquals(BU + "?" + "x=y" + "&" + EQ, r2.getUri());

    assertEquals(2, r2.getHeaders().size());
  }
View Full Code Here

  }

  public void testPassOnOfHeaders(){
      Map<String, String> headers = new HashMap<String, String>();
      headers.put("X-CustomHeader", "123456789");
      Method method = new Resource("http://localhost", headers).get();
      assertEquals("123456789",method.builder.getHeader("X-CustomHeader"));
  }
View Full Code Here

TOP

Related Classes of org.fusesource.restygwt.client.Resource

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.