com.sun.jersey.core.util.MultivaluedMapImpl Java Examples

The following examples show how to use com.sun.jersey.core.util.MultivaluedMapImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpRequestParserTest.java    From pxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testConvertToCaseInsensitiveMapUtf8() throws Exception {
    byte[] bytes = {
            (byte) 0x61, (byte) 0x32, (byte) 0x63, (byte) 0x5c, (byte) 0x22,
            (byte) 0x55, (byte) 0x54, (byte) 0x46, (byte) 0x38, (byte) 0x5f,
            (byte) 0xe8, (byte) 0xa8, (byte) 0x88, (byte) 0xe7, (byte) 0xae,
            (byte) 0x97, (byte) 0xe6, (byte) 0xa9, (byte) 0x9f, (byte) 0xe7,
            (byte) 0x94, (byte) 0xa8, (byte) 0xe8, (byte) 0xaa, (byte) 0x9e,
            (byte) 0x5f, (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x30,
            (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x5c,
            (byte) 0x22, (byte) 0x6f, (byte) 0x35
    };
    String value = new String(bytes, CharEncoding.ISO_8859_1);

    MultivaluedMap<String, String> multivaluedMap = new MultivaluedMapImpl();
    multivaluedMap.put("one", Collections.singletonList(value));

    Map<String, String> caseInsensitiveMap = new HttpRequestParser.RequestMap(multivaluedMap);

    assertEquals("Only one key should have exist", caseInsensitiveMap.keySet().size(), 1);

    assertEquals("Value should be converted to UTF-8",
            caseInsensitiveMap.get("one"), "a2c\"UTF8_計算機用語_00000000\"o5");
}
 
Example #2
Source File: DockerClient.java    From docker-java with Apache License 2.0 6 votes vote down vote up
public List<Container> listContainers(boolean allContainers, boolean latest, int limit, boolean showSize, String since, String before) {

		MultivaluedMap<String, String> params = new MultivaluedMapImpl();
		params.add("limit", latest ? "1" : String.valueOf(limit));
		params.add("all", allContainers ? "1" : "0");
		params.add("since", since);
		params.add("before", before);
		params.add("size", showSize ? "1" : "0");

		WebResource webResource = client.resource(restEndpointUrl + "/containers/json").queryParams(params);
		LOGGER.trace("GET: {}", webResource);
		List<Container> containers = webResource.accept(MediaType.APPLICATION_JSON).get(new GenericType<List<Container>>() {
		});
		LOGGER.trace("Response: {}", containers);

		return containers;
	}
 
Example #3
Source File: OptionalViewTest.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testAppendOptionalFieldsNoOptionsGiven() {
    MultivaluedMap map = new MultivaluedMapImpl();

    EntityBody body = new EntityBody();
    body.put("student", "{\"somekey\":\"somevalue\"}");

    List<EntityBody> entities = new ArrayList<EntityBody>();
    entities.add(body);

    entities = optionalView.add(entities, ResourceNames.SECTIONS, map);

    assertEquals("Should only have one", 1, entities.size());
    assertEquals("Should match", body, entities.get(0));
}
 
Example #4
Source File: TypesJerseyResourceIT.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetTraitNames() throws Exception {
    String[] traitsAdded = addTraits();

    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("type", DataTypes.TypeCategory.TRAIT.name());

    JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.LIST_TYPES, queryParams);
    Assert.assertNotNull(response);

    Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));

    final JSONArray list = response.getJSONArray(AtlasClient.RESULTS);
    Assert.assertNotNull(list);
    Assert.assertTrue(list.length() >= traitsAdded.length);
}
 
Example #5
Source File: OnboardingResourceTest.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    injector.setDeveloperContext();
    resource.isSandboxEnabled = true;
    List<String> acceptRequestHeaders = new ArrayList<String>();
    acceptRequestHeaders.add(HypermediaType.VENDOR_SLC_JSON);
    headers = mock(HttpHeaders.class);
    when(headers.getRequestHeader("accept")).thenReturn(acceptRequestHeaders);
    when(headers.getRequestHeaders()).thenReturn(new MultivaluedMapImpl());

    // mockTenantResource = mock(TenantResource.class);

    // clear all related collections
    repo.deleteAll("educationOrganization", null);

}
 
Example #6
Source File: TemplateCallTest.java    From Processor with Apache License 2.0 6 votes vote down vote up
public void testArg()
{
    String param1Value = "1", param2Value = "with space";
    Resource param3Value = ResourceFactory.createResource("http://whateverest/");
    MultivaluedMap queryParams = new MultivaluedMapImpl();
    queryParams.add(PREDICATE1_LOCAL_NAME, param1Value);
    queryParams.add(PREDICATE2_LOCAL_NAME, param2Value);
    queryParams.add(UNUSED_PREDICATE_LOCAL_NAME, param3Value);

    TemplateCall otherCall = TemplateCall.fromResource(resource, template).
        arg(param1, ResourceFactory.createPlainLiteral(param1Value)).
        arg(param2, ResourceFactory.createPlainLiteral(param2Value)).
        arg(param3, param3Value);
    
    assertEquals(call.applyArguments(queryParams).build(), otherCall.build());
}
 
Example #7
Source File: TypesJerseyResourceIT.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetTraitNames() throws Exception {
    String[] traitsAdded = addTraits();

    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("type", DataTypes.TypeCategory.TRAIT.name());

    ObjectNode response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API_V1.LIST_TYPES, queryParams);
    Assert.assertNotNull(response);

    Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));

    final ArrayNode list = (ArrayNode) response.get(AtlasClient.RESULTS);
    Assert.assertNotNull(list);
    Assert.assertTrue(list.size() >= traitsAdded.length);
}
 
Example #8
Source File: DockerClient.java    From docker-java with Apache License 2.0 6 votes vote down vote up
/**
 * Create an image by importing the given stream of a tar file.
 *
 * @param repository  the repository to import to
 * @param tag         any tag for this image
 * @param imageStream the InputStream of the tar file
 * @return an {@link ImageCreateResponse} containing the id of the imported image
 * @throws DockerException if the import fails for some reason.
 */
public ImageCreateResponse importImage(String repository, String tag, InputStream imageStream) throws DockerException {
	Preconditions.checkNotNull(repository, "Repository was not specified");
	Preconditions.checkNotNull(imageStream, "imageStream was not provided");

	MultivaluedMap<String, String> params = new MultivaluedMapImpl();
	params.add("repo", repository);
	params.add("tag", tag);
	params.add("fromSrc", "-");

	WebResource webResource = client.resource(restEndpointUrl + "/images/create").queryParams(params);

	try {
		LOGGER.trace("POST: {}", webResource);
		return webResource.accept(MediaType.APPLICATION_OCTET_STREAM_TYPE).post(ImageCreateResponse.class, imageStream);

	} catch (UniformInterfaceException exception) {
		if (exception.getResponse().getStatus() == 500) {
			throw new DockerException("Server error.", exception);
		} else {
			throw new DockerException(exception);
		}
	}
}
 
Example #9
Source File: DockerClient.java    From docker-java with Apache License 2.0 6 votes vote down vote up
public List<Image> getImages(String name, boolean allImages) throws DockerException {

		MultivaluedMap<String, String> params = new MultivaluedMapImpl();
		params.add("filter", name);
		params.add("all", allImages ? "1" : "0");

		WebResource webResource = client.resource(restEndpointUrl + "/images/json").queryParams(params);

		try {
			LOGGER.trace("GET: {}", webResource);
			List<Image> images = webResource.accept(MediaType.APPLICATION_JSON).get(new GenericType<List<Image>>() {
			});
			LOGGER.trace("Response: {}", images);
			return images;
		} catch (UniformInterfaceException exception) {
			if (exception.getResponse().getStatus() == 400) {
				throw new DockerException("bad parameter");
			} else if (exception.getResponse().getStatus() == 500) {
				throw new DockerException("Server error", exception);
			} else {
				throw new DockerException();
			}
		}

	}
 
Example #10
Source File: HttpRequestParserTest.java    From pxf with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    parameters = new MultivaluedMapImpl();
    parameters.putSingle("X-GP-ALIGNMENT", "all");
    parameters.putSingle("X-GP-SEGMENT-ID", "-44");
    parameters.putSingle("X-GP-SEGMENT-COUNT", "2");
    parameters.putSingle("X-GP-HAS-FILTER", "0");
    parameters.putSingle("X-GP-FORMAT", "TEXT");
    parameters.putSingle("X-GP-URL-HOST", "my://bags");
    parameters.putSingle("X-GP-URL-PORT", "-8020");
    parameters.putSingle("X-GP-ATTRS", "-1");
    parameters.putSingle("X-GP-OPTIONS-ACCESSOR", "are");
    parameters.putSingle("X-GP-OPTIONS-RESOLVER", "packed");
    parameters.putSingle("X-GP-DATA-DIR", "i'm/ready/to/go");
    parameters.putSingle("X-GP-FRAGMENT-METADATA", "U29tZXRoaW5nIGluIHRoZSB3YXk=");
    parameters.putSingle("X-GP-OPTIONS-I'M-STANDING-HERE", "outside-your-door");
    parameters.putSingle("X-GP-USER", "alex");
    parameters.putSingle("X-GP-OPTIONS-SERVER", "custom_server");
    parameters.putSingle("X-GP-XID", "transaction:id");

    when(mockRequestHeaders.getRequestHeaders()).thenReturn(parameters);
    when(mockRequestHeaders.getPath()).thenReturn("foo");

    parser = new HttpRequestParser(mockPluginConf);
}
 
Example #11
Source File: DateSearchFilterTest.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
private ContainerRequest createRequest(String requestPath, String schoolYearsQuery) {
    ContainerRequest request = Mockito.mock(ContainerRequest.class);
    String[] pathParts = requestPath.split("/");
    List<PathSegment> segments = new ArrayList<PathSegment>();
    for (String pathPart : pathParts) {
        segments.add(segmentFor(pathPart));
    }
    
    MultivaluedMap queryParameters = new MultivaluedMapImpl();
    
    String[] schoolYearParts = schoolYearsQuery.split("=");
    if (schoolYearParts.length == 2) {
        queryParameters.add(schoolYearParts[0], schoolYearParts[1]);
    }
    
    Mockito.when(request.getQueryParameters()).thenReturn(queryParameters);
    Mockito.when(request.getPathSegments()).thenReturn(segments);
    Mockito.when(request.getPath()).thenReturn(requestPath);
    return request;
}
 
Example #12
Source File: ApplicationResource.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
protected MultivaluedMap<String, String> getRequestParameters() {
    final MultivaluedMap<String, String> entity = new MultivaluedMapImpl();

    // get the form that jersey processed and use it if it exists (only exist for requests with a body and application form urlencoded
    final Form form = (Form) httpContext.getProperties().get(FormDispatchProvider.FORM_PROPERTY);
    if (form == null) {
        for (final Map.Entry<String, String[]> entry : httpServletRequest.getParameterMap().entrySet()) {
            if (entry.getValue() == null) {
                entity.add(entry.getKey(), null);
            } else {
                for (final String aValue : entry.getValue()) {
                    entity.add(entry.getKey(), aValue);
                }
            }
        }
    } else {
        entity.putAll(form);
    }

    return entity;
}
 
Example #13
Source File: RestJobTest.java    From ingestion with Apache License 2.0 6 votes vote down vote up
@Test
public void simpleGetWithMultipleEventsUsingJsonHandler() throws JobExecutionException {
    String goodUrl = "GOOD URL";
    Map<String, Object> properties = new HashMap<String, Object>();
    MultivaluedMap<String, String> responseHeaders = new MultivaluedMapImpl();
    properties.put(RestSource.CONF_URL, goodUrl);
    properties.put(RestSource.CONF_HEADERS, "{}");
    properties.put(RestSource.CONF_METHOD, "GET");
    String jsonResponse = "[{\"field1\":\"value1\"},{\"field2\":\"value2\"}]";

    restSourceHandler = initJsonHandler("");
    urlHandler = new DefaultUrlHandler();
    when(schedulerContext.get("urlHandler")).thenReturn(urlHandler);
    when(client.resource(goodUrl)).thenReturn(webResource);
    when(response.getEntity(String.class)).thenReturn(jsonResponse);
    when(response.getHeaders()).thenReturn(responseHeaders);
    when(schedulerContext.get("properties")).thenReturn(properties);
    when(schedulerContext.get("restSourceHandler")).thenReturn(restSourceHandler);

    job.execute(context);

    assertThat(queue.size()).isEqualTo(2);
    assertThat(new String(queue.poll().getBody())).isEqualTo("{\"field1\":\"value1\"}");
    assertThat(new String(queue.poll().getBody())).isEqualTo("{\"field2\":\"value2\"}");
}
 
Example #14
Source File: ClientUtils.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Performs a POST using the specified url and form data.
 *
 * @param uri the uri to post to
 * @param formData the data to post
 * @return the client response of the post
 */
public ClientResponse post(URI uri, Map<String, String> formData) throws ClientHandlerException, UniformInterfaceException {
    // convert the form data
    MultivaluedMapImpl entity = new MultivaluedMapImpl();
    for (String key : formData.keySet()) {
        entity.add(key, formData.get(key));
    }

    // get the resource
    WebResource.Builder resourceBuilder = client.resource(uri).accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_FORM_URLENCODED);

    // add the form data if necessary
    if (!entity.isEmpty()) {
        resourceBuilder = resourceBuilder.entity(entity);
    }

    // perform the request
    return resourceBuilder.post(ClientResponse.class);
}
 
Example #15
Source File: AtlasClientV2.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
public AtlasSearchResult fullTextSearchWithParams(final String query, final int limit, final int offset) throws AtlasServiceException {
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add(QUERY, query);
    queryParams.add(LIMIT, String.valueOf(limit));
    queryParams.add(OFFSET, String.valueOf(offset));

    return callAPI(FULL_TEXT_SEARCH, AtlasSearchResult.class, queryParams);
}
 
Example #16
Source File: HttpMultiValuedMapGetOperatorTest.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
@Override
protected MultivaluedMap<String, String> getQueryParams(TestPojo input)
{
  MultivaluedMapImpl map = new MultivaluedMapImpl();

  map.add(input.getName1(), input.getValue11());
  map.add(input.getName1(), input.getValue12());
  map.add(input.getName2(), input.getValue21());
  map.add(input.getName2(), input.getValue22());
  map.add(input.getName2(), input.getValue23());

  return map;
}
 
Example #17
Source File: TemplateCallTest.java    From Processor with Apache License 2.0 5 votes vote down vote up
@Test(expected = ParameterException.class)
public void testValidateNonOptionals()
{
    String param2Value = "with space";
    MultivaluedMap queryParams = new MultivaluedMapImpl();
    // parameter1 is mandatory (spl:defaultValue false), but its value is missing
    queryParams.add(PREDICATE2_LOCAL_NAME, param2Value);
    
    call.applyArguments(queryParams).validateOptionals();
}
 
Example #18
Source File: ThreePartResourceTest.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
private void setupMocks(String uri) throws URISyntaxException {
    requestURI = new java.net.URI(uri);

    MultivaluedMap map = new MultivaluedMapImpl();
    uriInfo = mock(UriInfo.class);
    when(uriInfo.getRequestUri()).thenReturn(requestURI);
    when(uriInfo.getQueryParameters()).thenReturn(map);
    when(uriInfo.getBaseUriBuilder()).thenAnswer(new Answer<UriBuilder>() {
        @Override
        public UriBuilder answer(InvocationOnMock invocation) throws Throwable {
            return new UriBuilderImpl().path("base");
        }
    });
}
 
Example #19
Source File: MetadataDiscoveryJerseyResourceIT.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void testSearchUsingDSL() throws Exception {
    //String query = "from dsl_test_type";
    String query = "from "+ DATABASE_TYPE + " name=\"" + dbName +"\"";
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("query", query);
    JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.SEARCH, queryParams);

    Assert.assertNotNull(response);
    Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));

    assertEquals(response.getString("query"), query);
    assertEquals(response.getString("queryType"), "dsl");
}
 
Example #20
Source File: AtlasClientV2.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
public AtlasLineageInfo getLineageInfo(final String guid, final LineageDirection direction, final int depth) throws AtlasServiceException {
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("direction", direction.toString());
    queryParams.add("depth", String.valueOf(depth));

    return callAPI(LINEAGE_INFO, AtlasLineageInfo.class, queryParams, guid);
}
 
Example #21
Source File: EntityLineageJerseyResourceIT.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void testOutputLineageInfo() throws Exception {
    String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE,
            AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesFactTable).getId()._getId();

    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add(DIRECTION_PARAM, OUTPUT_DIRECTION);
    queryParams.add(DEPTH_PARAM, "5");
    JSONObject response = atlasClientV1.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);

    Assert.assertNotNull(response);
    System.out.println("output lineage info = " + response);

    AtlasLineageInfo outputLineageInfo = gson.fromJson(response.toString(), AtlasLineageInfo.class);

    Map<String, AtlasEntityHeader> entities = outputLineageInfo.getGuidEntityMap();
    Assert.assertNotNull(entities);

    Set<AtlasLineageInfo.LineageRelation> relations = outputLineageInfo.getRelations();
    Assert.assertNotNull(relations);

    Assert.assertEquals(entities.size(), 5);
    Assert.assertEquals(relations.size(), 4);
    Assert.assertEquals(outputLineageInfo.getLineageDirection(), AtlasLineageInfo.LineageDirection.OUTPUT);
    Assert.assertEquals(outputLineageInfo.getLineageDepth(), 5);
    Assert.assertEquals(outputLineageInfo.getBaseEntityGuid(), tableId);
}
 
Example #22
Source File: CustomEntityDecoratorTest.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
@Test
public void testDecoratorNonParam() {
    MultivaluedMap<String, String> map = new MultivaluedMapImpl();
    map.add(ParameterConstants.INCLUDE_CUSTOM, String.valueOf(false));

    EntityBody body = createTestEntity();
    customEntityDecorator.decorate(body, null, map);
    assertEquals("Should match", 3, body.keySet().size());
    assertEquals("Should match", "Male", body.get("sex"));
    assertEquals("Should match", 1234, body.get("studentUniqueStateId"));
}
 
Example #23
Source File: TenantResourceTest.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {

    uriInfo = ResourceTestUtil.buildMockUriInfo(null);

    // inject administrator security context for unit testing
    injector.setRealmAdminContext();

    secUtil = mock(SecurityUtilProxy.class);
    tenantResource.setSecUtil(secUtil);
    when(uriInfo.getQueryParameters()).thenReturn(new MultivaluedMapImpl());

    tenantResource.setIngestionServerList(Arrays.asList("FIRST", "Second", "third"));
}
 
Example #24
Source File: ApplicationRestApiTest.java    From open-Autoscaler with Apache License 2.0 5 votes vote down vote up
@Test
public void test003DetachPolicy() throws JsonProcessingException{
	WebResource webResource = resource();
	MultivaluedMap<String, String> map = new MultivaluedMapImpl();
	map.add("policyId", policyId);
	map.add("state", AutoScalerPolicy.STATE_ENABLED);
	ClientResponse response = webResource.path("/apps/" + TESTAPPID).queryParams(map).type(MediaType.APPLICATION_JSON).delete(ClientResponse.class);
       assertEquals(response.getStatus(), STATUS200);
}
 
Example #25
Source File: RestJobTest.java    From ingestion with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultivaluedHeader() throws JobExecutionException {
    String goodUrl = "GOOD URL";
    when(client.resource(goodUrl)).thenReturn(webResource);

    //Create Properties
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(RestSource.CONF_URL, goodUrl);
    properties.put(RestSource.CONF_HEADERS, "{}");
    properties.put(RestSource.CONF_METHOD, "GET");
    when(response.getEntity(String.class)).thenReturn("XXXXX");

    //Return headers
    MultivaluedMap<String, String> responseHeaders = new MultivaluedMapImpl();
    responseHeaders.put("GOODHEADER", Arrays.asList("aa", "bb"));
    restSourceHandler = initDefaultHandler();
    urlHandler = new DefaultUrlHandler();
    when(schedulerContext.get("urlHandler")).thenReturn(urlHandler);
    when(response.getHeaders()).thenReturn(responseHeaders);
    when(schedulerContext.get("properties")).thenReturn(properties);
    when(schedulerContext.get("restSourceHandler")).thenReturn(restSourceHandler);

    job.execute(context);

    assertEquals(queue.size(), 1);
    assertEquals(queue.poll().getHeaders().get("GOODHEADER"), "aa, bb");
}
 
Example #26
Source File: PolicyRestApiTest.java    From open-Autoscaler with Apache License 2.0 5 votes vote down vote up
@Test
public void test004GetPolicies(){
	WebResource webResource = resource();
	MultivaluedMap<String, String> paramMap = new MultivaluedMapImpl();
	paramMap.add("service_id", TESTSERVICEID);
	ClientResponse response = webResource.path("/policies").queryParams(paramMap).type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
       assertEquals(response.getStatus(), STATUS200);
}
 
Example #27
Source File: StudentAccessValidatorTest.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    request = Mockito.mock(ContainerRequest.class);
    when(request.getPathSegments()).thenAnswer(new Answer<List<PathSegment>>() {
        @Override
        public List<PathSegment> answer(InvocationOnMock invocation) throws Throwable {
            return buildSegment();
        }
    });
    when(request.getQueryParameters()).thenReturn(new MultivaluedMapImpl());
    when(request.getMethod()).thenReturn("GET");
}
 
Example #28
Source File: OperationRESTTest.java    From open-Autoscaler with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetLogLevel(){
	WebResource webResource = resource();
	MultivaluedMap<String, String> map = new MultivaluedMapImpl();
	map.add("package", "org.cloudfoundry.autoscaler.metric.rest");
	ClientResponse response = webResource.path("/operation/log/INFO").queryParams(map).put(ClientResponse.class);
	assertEquals(response.getStatus(), STATUS200);
}
 
Example #29
Source File: DashboardRESTTest.java    From open-Autoscaler with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetAppHistoryMetrics(){
	WebResource webResource = resource();
	MultivaluedMap<String, String> map = new MultivaluedMapImpl();
	map.add("appId", TESTAPPID);
	ClientResponse response = webResource.path("/metrics/"+TESTSERVICEID+"/"+TESTAPPID).get(ClientResponse.class);
	assertEquals(response.getStatus(), STATUS200);
}
 
Example #30
Source File: DashboardRESTTest.java    From open-Autoscaler with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetAppMetricsLastestData(){
	WebResource webResource = resource();
	MultivaluedMap<String, String> map = new MultivaluedMapImpl();
	map.add("appId", TESTAPPID);
	ClientResponse response = webResource.path("/metrics/"+TESTSERVICEID).queryParams(map).get(ClientResponse.class);
	assertEquals(response.getStatus(), STATUS200);
}