Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.WebResource.addFilter()


    // A managed bean with no use of injection whatsoever.
    @Test
    public void testManagedBeanWithNoUseOfInjectionWhatsoeverResource() throws Exception {
        WebResource webResource = resource().path("/helloworld");
        webResource.addFilter(new LoggingFilter());
        String responseMsg = webResource.get(String.class);
        assertEquals("Hello World", responseMsg);
    }

    //Shows injection of context objects into the fields of a managed bean
View Full Code Here


    //Shows injection of context objects into the fields of a managed bean
    @Test
    public void testManagedBeanWithUseOfInjectionOfContextObjectsIntoFieldsResource() throws Exception {
        WebResource webResource = resource().path("/simple");
        webResource.addFilter(new LoggingFilter());
        String responseMsg = webResource.get(String.class);
        //grab port from environment when running inside hudson and port is changed
        // otherwise, fall back to default port 8080
        String httpPort = System.getProperty("jersey.test.port");
        if (httpPort.equals(null)) {
View Full Code Here

    //Shows injection of context objects and path parameters into the fields of a managed
    @Test
    public void testManagedBeanWithUseOfInjectionOfContextObjectsAndPathParamsIntoFieldsResource() throws Exception {
        WebResource webResource = resource().path("other/c/d");
        webResource.addFilter(new LoggingFilter());
        String responseMsg = webResource.get(String.class);
        assertEquals("OTHER c d", responseMsg);
    }

    //Shows constructor injection of a path parameter in a managed bean.
View Full Code Here

    //Shows constructor injection of a path parameter in a managed bean.
    @Test
    public void testConstructorInjectionOfAPathParamInAManagedBeanResource() throws Exception {
        WebResource webResource = resource().path("echoconstructor/a");
        webResource.addFilter(new LoggingFilter());
        String responseMsg = webResource.get(String.class);
        assertEquals("ECHO a", responseMsg);
    }

    //Shows injection of path and query parameters into the fields of a managed bean
View Full Code Here

    //Shows injection of path and query parameters into the fields of a managed bean
    @Test
    public void testManagedBeanWithUseOfInjectionOfPathAndQueryParamsIntoFieldsResource() throws Exception {
        WebResource webResource = resource().path("echofield/b");
        webResource.addFilter(new LoggingFilter());
        String responseMsg = webResource.get(String.class);
        assertEquals("ECHO null b", responseMsg);
    }

    //A managed bean that uses (but does not inject) a path parameter.
View Full Code Here

    //A managed bean that uses (but does not inject) a path parameter.
    @Test
    public void testManagedBeanThatUsesButDoesNotInjectAPathParamResource() throws Exception {
        WebResource webResource = resource().path("echo/a");
        webResource.addFilter(new LoggingFilter());
        String responseMsg = webResource.get(String.class);
        assertEquals("ECHO a", responseMsg);
    }
}
View Full Code Here

     * @param password The password.
     * @return The authentication token.
     */
    public String login(String username, String password) {
        WebResource resource = client.getClient().resource(client.uriBuilder("/login").build());
        resource.addFilter(new HTTPBasicAuthFilter(username, password));
        ClientResponse response = resource.get(ClientResponse.class);
        response.close();
        return client.getAuthToken();
    }

View Full Code Here

     * @param password The password.
     * @return The authentication token.
     */
    public String login(String username, String password) {
        WebResource resource = client.getClient().resource(client.uriBuilder("/login").build());
        resource.addFilter(new HTTPBasicAuthFilter(username, password));
        ClientResponse response = resource.get(ClientResponse.class);
        response.close();
        return client.getAuthToken();
    }

View Full Code Here

        // Make REST Request

        Client client2 = Client.create();
        RestUtil.initialize(client2);
        WebResource webResource = client2.resource(restURL);
        webResource.addFilter(new HTTPBasicAuthFilter(username, password));
        MultivaluedMap payLoad = new MultivaluedMapImpl();
        payLoad.putSingle("remoteHostName", request.getRemoteHost());

        ClientResponse resp = webResource.accept(RESPONSE_TYPE).post(ClientResponse.class, payLoad);
        RestResponse restResp = RestResponse.getRestResponse(resp);
View Full Code Here

      return this.apieStatesCache.get("", new Callable<Map<String, IAPIStateDTO>>() {
        @Override
        public Map<String, IAPIStateDTO> call() throws Exception {
          try {
            final WebResource resource = ServiceConstants.REST_CLIENT.resource(API_STATES_URL.toExternalForm());
            resource.addFilter(new RetryClientFilter(RETRY_COUNT));
            final WebResource.Builder builder = resource.accept(MediaType.APPLICATION_JSON_TYPE);
            try {
              final String response = builder.get(String.class).replaceAll(Pattern.quote("\\"), "");
              LOGGER.trace("Retrieved response=" + response);
              final Map<String, IAPIStateDTO> result = GW2StatsService.this.gw2statsDTOFactory.newAPIStatesOf(response);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.