Package org.fusesource.restygwt.client

Examples of org.fusesource.restygwt.client.Method


  }

  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


        GWTMockUtilities.restore();
    }
   
    public void testNoCallbacksSuccess() throws Exception{
        Response response = EasyMock.createMock(Response.class);
        Method method = EasyMock.createMock(Method.class);
        EasyMock.expect(response.getStatusCode()).andReturn(201);
        EasyMock.expect(method.getData()).andReturn(new HashMap<String,String>());
        EasyMock.replay(response, method);
       
        filter.filter(method, response, null);
       
        EasyMock.verify(response, method);
View Full Code Here

        assertEquals(response.hashCode(), this.storage.getResultOrReturnNull(key).hashCode());
    }

    public void testNoCallbacksError() throws Exception{
        Response response = EasyMock.createMock(Response.class);
        Method method = EasyMock.createMock(Method.class);
        EasyMock.expect(response.getStatusCode()).andReturn(401);
        EasyMock.replay(response, method);
       
        filter.filter(method, response, null);
       
View Full Code Here

        assertNull(this.storage.getResultOrReturnNull(key));
    }

    public void testManyCallbacksSuccess() throws Exception{
        Response response = EasyMock.createMock(Response.class);
        Method method = EasyMock.createMock(Method.class);
        EasyMock.expect(method.getData()).andReturn(new HashMap<String,String>());
        RequestCallback[] myCallbacks = new RequestCallback[4];
        for( int i = 0; i < myCallbacks.length; i++){
            myCallbacks[i] = EasyMock.createMock(RequestCallback.class);
            myCallbacks[i].onResponseReceived(null, null);
            EasyMock.replay(myCallbacks[i]);
View Full Code Here

        GWTMockUtilities.restore();
    }
   
    public void test() throws Exception{
        // setup a method, a builder and a filter-aware callback
        Method method = EasyMock.createMock(Method.class);
        RequestBuilder builder = EasyMock.createMock(RequestBuilder.class);
        RequestCallback rc = new RequestCallback() {
           
            @Override
            public void onResponseReceived(Request request, Response response) {
            }
           
            @Override
            public void onError(Request request, Throwable exception) {
                throw new RuntimeException(exception);
            }
        };
        EasyMock.expect(builder.getCallback()).andReturn(rc);
        EasyMock.replay(builder);
        method.builder = builder;
        EasyMock.expect(method.isExpected(200)).andReturn(true);
        EasyMock.replay(method);
       
        FilterawareRequestCallback callback = new DefaultFilterawareRequestCallback(method);

        // set the response code
View Full Code Here


    @Override
    protected Method methodFor(TickActivityAction action, Resource resource)
    {
        return new Method(resource, PUT.name()).header(HEADER_CONTENT_TYPE, CONTENT_TYPE_JSON);
    }
View Full Code Here

    }

    @Override
    protected Method methodFor(CopyActivityAction action, Resource resource)
    {
        return new Method(resource, PUT.name()).header(HEADER_CONTENT_TYPE, CONTENT_TYPE_JSON);
    }
View Full Code Here

    @Override
    public DispatchRequest execute(final A action, final AsyncCallback<R> resultCallback,
            final ExecuteCommand<A, R> executeCommand)
    {
        final Resource resource = resourceFor(action);
        Method method = methodFor(action, resource);
        applySecurity(action, resource, method);
        executeMethod(method, resultCallback);
        return new DispatchRequestRestletImpl(method);
    }
View Full Code Here

     * @param resource
     * @return
     */
    protected Method methodFor(A action, Resource resource)
    {
        return new Method(resource, GET.name()).header(HEADER_CONTENT_TYPE, CONTENT_TYPE_JSON);
    }
View Full Code Here

     * @param method
     * @return
     */
    protected Method applySecurity(A action, Resource resource, Method method)
    {
        Method result = method;
        if (action.isSecured())
        {
            // Add the security token as header
            String cookieContent = securityCookieAccessor.getCookieContent();
            if (cookieContent != null)
            {
                result = result.header(securityCookieName, cookieContent);
            }
        }
        return result;
    }
View Full Code Here

TOP

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

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.