use of org.apache.geode.management.internal.web.domain.Link in project geode by apache.
the class ClientHttpRequestJUnitTest method testCreateRequestEntityForPut.
@Test
@SuppressWarnings("unchecked")
public void testCreateRequestEntityForPut() throws Exception {
final Link expectedLink = new Link("put", toUri("http://host.domain.com:8080/app/libraries/{name}/books/{isbn}"), HttpMethod.PUT);
final ClientHttpRequest request = new ClientHttpRequest(expectedLink);
assertEquals(expectedLink, request.getLink());
final MultiValueMap<String, Object> expectedRequestParameters = new LinkedMultiValueMap<String, Object>(4);
expectedRequestParameters.add("year", "1979");
request.addHeaderValues(HttpHeader.ACCEPT.getName(), MediaType.TEXT_XML_VALUE);
request.addHeaderValues(HttpHeader.CONTENT_TYPE.getName(), MediaType.APPLICATION_FORM_URLENCODED_VALUE);
request.addParameterValues("year", expectedRequestParameters.getFirst("year"));
final HttpEntity<MultiValueMap<String, Object>> requestEntity = (HttpEntity<MultiValueMap<String, Object>>) request.createRequestEntity();
assertNotNull(requestEntity);
assertNotNull(requestEntity.getHeaders());
assertEquals(Collections.singletonList(MediaType.TEXT_XML), requestEntity.getHeaders().getAccept());
assertEquals(MediaType.APPLICATION_FORM_URLENCODED, requestEntity.getHeaders().getContentType());
assertEquals(expectedRequestParameters, requestEntity.getBody());
}
use of org.apache.geode.management.internal.web.domain.Link in project geode by apache.
the class ClientHttpRequestJUnitTest method testGetURLForGetWithQueryParametersNoBody.
@Test
public void testGetURLForGetWithQueryParametersNoBody() throws Exception {
final Link expectedLink = new Link("find", toUri("http://host.domain.com:8080/app/libraries/{name}/books/{author}"), HttpMethod.GET);
final ClientHttpRequest request = new ClientHttpRequest(expectedLink);
request.addParameterValues("author", "Rowling");
request.addParameterValues("category", "science-fiction");
request.addParameterValues("name", "Boston");
request.addParameterValues("year", "2007");
final Map<String, Object> uriVariables = new HashMap<String, Object>(4);
uriVariables.put("author", "Rowling");
uriVariables.put("category", "mystery");
uriVariables.put("isbn", "0-123456789");
uriVariables.put("name", "Amazon");
assertEquals(expectedLink, request.getLink());
assertEquals("http://host.domain.com:8080/app/libraries/Amazon/books/Rowling?category=science-fiction&year=2007", toString(request.getURL(uriVariables)));
}
use of org.apache.geode.management.internal.web.domain.Link in project geode by apache.
the class ClientHttpRequestJUnitTest method testGetPathVariablesWithUriHavingNoPathVariables.
@Test
public void testGetPathVariablesWithUriHavingNoPathVariables() throws Exception {
final Link expectedLink = new Link("test", toUri("http://host.domain.com:8080/app/service"));
final ClientHttpRequest request = new ClientHttpRequest(expectedLink);
assertEquals(expectedLink, request.getLink());
final List<String> actualPathVariables = request.getPathVariables();
assertNotNull(actualPathVariables);
assertTrue(actualPathVariables.isEmpty());
}
use of org.apache.geode.management.internal.web.domain.Link in project geode by apache.
the class ClientHttpRequestJUnitTest method testCreateClientHttpRequest.
@Test
public void testCreateClientHttpRequest() throws Exception {
final Link expectedLink = new Link("test", toUri("http://host.domain.com:8080/app/service"));
final ClientHttpRequest request = new ClientHttpRequest(expectedLink);
assertNotNull(request);
assertEquals(expectedLink, request.getLink());
}
use of org.apache.geode.management.internal.web.domain.Link in project geode by apache.
the class ClientHttpRequestJUnitTest method testGetMethod.
@Test
public void testGetMethod() throws Exception {
Link link = new Link("get-resource", toUri("http://host.domain.com:8080/app/resources/{id}"));
ClientHttpRequest request = new ClientHttpRequest(link);
assertEquals(link, request.getLink());
assertEquals(org.springframework.http.HttpMethod.GET, request.getMethod());
link = new Link("delete-resource", toUri("http://host.domain.com:8080/app/resources/{id}"), HttpMethod.DELETE);
request = new ClientHttpRequest(link);
assertEquals(link, request.getLink());
assertEquals(org.springframework.http.HttpMethod.DELETE, request.getMethod());
link = new Link("delete-resource", toUri("http://host.domain.com:8080/app/service"), HttpMethod.HEAD);
request = new ClientHttpRequest(link);
assertEquals(link, request.getLink());
assertEquals(org.springframework.http.HttpMethod.HEAD, request.getMethod());
link = new Link("delete-resource", toUri("http://host.domain.com:8080/app/service"), HttpMethod.OPTIONS);
request = new ClientHttpRequest(link);
assertEquals(link, request.getLink());
assertEquals(org.springframework.http.HttpMethod.OPTIONS, request.getMethod());
link = new Link("delete-resource", toUri("http://host.domain.com:8080/app/resources"), HttpMethod.POST);
request = new ClientHttpRequest(link);
assertEquals(link, request.getLink());
assertEquals(org.springframework.http.HttpMethod.POST, request.getMethod());
link = new Link("delete-resource", toUri("http://host.domain.com:8080/app/resources"), HttpMethod.PUT);
request = new ClientHttpRequest(link);
assertEquals(link, request.getLink());
assertEquals(org.springframework.http.HttpMethod.PUT, request.getMethod());
link = new Link("delete-resource", toUri("http://host.domain.com:8080/app"), HttpMethod.TRACE);
request = new ClientHttpRequest(link);
assertEquals(link, request.getLink());
assertEquals(org.springframework.http.HttpMethod.TRACE, request.getMethod());
}
Aggregations