Package com.sun.jersey.api.client

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


    formParams
        .add(FormParameters.RAW_DATA,
            "{\"metadata\":{\"GPSTimeStamp\":\"NOT_AVAILABLE\",\"ISOSpeedRatings\":\"100\",\"Orientation\":\"6\",\"Model\":\"GT-N7100\",\"WhiteBalance\":\"0\",\"GPSLongitude\":\"NOT_AVAILABLE\",\"ImageLength\":\"2448\",\"FocalLength\":\"3.7\",\"HasFaces\":\"1\",\"ImageName\":\"20140707_134558.jpg\",\"GPSDateStamp\":\"NOT_AVAILABLE\",\"Flash\":\"0\",\"DateTime\":\"2014:07:07 13:45:58\",\"NumberOfFaces\":\"1\",\"ExposureTime\":\"0.020\",\"GPSProcessingMethod\":\"NOT_AVAILABLE\",\"FNumber\":\"2.6\",\"ImageWidth\":\"3264\",\"GPSLatitude\":\"NOT_AVAILABLE\",\"GPSAltitudeRef\":\"-1\",\"Make\":\"SAMSUNG\",\"GPSAltitude\":\"-1.0\"}}");
   
    formParams.add(FormParameters.CONTENT_TYPE, FormParameters.CONTENT_TYPE_JSON);
    String response = webRes.type(MediaType.APPLICATION_FORM_URLENCODED)
        .post(String.class, formParams);
    System.out.print(response);
    String sampleTriple = "<20140707_134558.jpg> <http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#make> \"SAMSUNG\" .";
    int idx = response.indexOf(sampleTriple);
    assert(idx != -1);
View Full Code Here


            "{\"metadata\":{\"GPSTimeStamp\":\"NOT_AVAILABLE\",\"ISOSpeedRatings\":\"100\",\"Orientation\":\"6\",\"Model\":\"GT-N7100\",\"WhiteBalance\":\"0\",\"GPSLongitude\":\"NOT_AVAILABLE\",\"ImageLength\":\"2448\",\"FocalLength\":\"3.7\",\"HasFaces\":\"1\",\"ImageName\":\"20140707_134558.jpg\",\"GPSDateStamp\":\"NOT_AVAILABLE\",\"Flash\":\"0\",\"DateTime\":\"2014:07:07 13:45:58\",\"NumberOfFaces\":\"1\",\"ExposureTime\":\"0.020\",\"GPSProcessingMethod\":\"NOT_AVAILABLE\",\"FNumber\":\"2.6\",\"ImageWidth\":\"3264\",\"GPSLatitude\":\"NOT_AVAILABLE\",\"GPSAltitudeRef\":\"-1\",\"Make\":\"SAMSUNG\",\"GPSAltitude\":\"-1.0\"}}");
    formParams.add(FormParameters.CONTENT_TYPE, FormParameters.CONTENT_TYPE_JSON);
    formParams.add(FormParameters.USERNAME, "finimg");
    formParams.add(FormParameters.PASSWORD, "isi");

    String response = webRes.type(MediaType.APPLICATION_FORM_URLENCODED)
        .post(String.class, formParams);
    System.out.print(response);
    String sampleTriple = "<20140707_134558.jpg> <http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#make> \"SAMSUNG\" .";
    int idx = response.indexOf(sampleTriple);
    assert(idx != -1);
View Full Code Here

        }else if(eventRequest.getEvent().get("title") == null){
            throw new EventApiException("'title' must be set in the event data");
        }
        WebResource wr = restClient.client.resource(UriBuilder.fromPath(eventApiUrl).build());
        wr.addFilter(new BearerTokenFilter(accessToken));
        ClientResponse cr = wr.type(MediaType.APPLICATION_JSON_TYPE).post(ClientResponse.class, eventRequest);
        if(cr.getStatus() >= 300){
            String error = String.format("EvenApi.publish() returned HTTP status: %s, message: %s",cr.getStatus(), cr.toString());
            logger.error(error);
            throw new EventApiException(error);
        }
View Full Code Here

    RegistrationResponse response;
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    client = Client.create(clientConfig);
    WebResource webResource = client.resource("http://localhost:9998/register/dummyhost");
    response = webResource.type(MediaType.APPLICATION_JSON)
        .post(RegistrationResponse.class, createDummyJSONRegister());
    LOG.info("Returned from Server responce=" + response);
    Assert.assertEquals(response.getResponseStatus(), RegistrationStatus.OK);
  }
View Full Code Here

    HeartBeatResponse response;
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    client = Client.create(clientConfig);
    WebResource webResource = client.resource("http://localhost:9998/heartbeat/dummyhost");
    response = webResource.type(MediaType.APPLICATION_JSON)
        .post(HeartBeatResponse.class, createDummyHeartBeat());
    LOG.info("Returned from Server: "
        + " response=" + response);
    Assert.assertEquals(response.getResponseId(), 0L);
  }
View Full Code Here

    HeartBeatResponse response;
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    client = Client.create(clientConfig);
    WebResource webResource = client.resource("http://localhost:9998/heartbeat/dummyhost");
    response = webResource.type(MediaType.APPLICATION_JSON)
        .post(HeartBeatResponse.class, createDummyHeartBeatWithAgentEnv());
    LOG.info("Returned from Server: "
        + " response=" + response);
    Assert.assertEquals(response.getResponseId(), 0L);
  }
View Full Code Here

        wr = c.resource(shoppingLinks.get("products").getHref());

        Product product = new Product();
        product.setName("iPhone");
        product.setCost(199.99);
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, product);
        Assert.assertEquals(201, response.getStatus());

        product = new Product();
        product.setName("MacBook Pro");
        product.setCost(3299.99);
View Full Code Here

        Assert.assertEquals(201, response.getStatus());

        product = new Product();
        product.setName("MacBook Pro");
        product.setCost(3299.99);
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, product);
        Assert.assertEquals(201, response.getStatus());

        product = new Product();
        product.setName("iPod");
        product.setCost(49.99);
View Full Code Here

        Assert.assertEquals(201, response.getStatus());

        product = new Product();
        product.setName("iPod");
        product.setCost(49.99);
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, product);
        Assert.assertEquals(201, response.getStatus());

    }

    @Test
View Full Code Here

            customer.setCity("Boston");
            customer.setState("MA");
            customer.setZip("02115");
            customer.setCountry("USA");
            wr = c.resource(shoppingLinks.get("customers").getHref());
            response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, customer);
            Assert.assertEquals(201, response.getStatus());
            String uri = (String) response.getHeaders().getFirst("Location");

            wr = c.resource(uri);
            customer = wr.get(Customer.class);
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.