List of usage examples for org.springframework.http HttpMethod GET
HttpMethod GET
To view the source code for org.springframework.http HttpMethod GET.
Click Source Link
From source file:com.gopivotal.cla.github.GitHubConditionalTest.java
@Test public void noNextLink() { HttpHeaders headers = new HttpHeaders(); headers.add("Link", "<" + URL + ">; rel=\"first\""); ResponseEntity<Set> response = new ResponseEntity<Set>(Sets.asSet(), headers, HttpStatus.OK); when(this.restOperations.exchange(URL, HttpMethod.GET, REQUEST_ENTITY, Set.class)).thenReturn(response); this.gitHubType.getTrigger(); assertTrue(this.gitHubType.initializedCalled); }
From source file:com.appglu.impl.SyncTemplateTest.java
@Test public void changesForTable() { mockServer.expect(requestTo("http://localhost/appglu/v1/sync/changes/logged_table?from_version=2")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.OK) .body(compactedJson("data/sync_changes_for_table_response")).headers(responseHeaders)); TableChanges loggedTableChanges = this.syncOperations.changesForTable("logged_table", 2); this.assertTable(loggedTableChanges, "logged_table", 9, 2); RowChanges firstRow = loggedTableChanges.getChanges().get(0); this.assertRow(firstRow, 2, 1, "row1", 1, SyncOperation.INSERT); RowChanges secondRow = loggedTableChanges.getChanges().get(1); this.assertRow(secondRow, 2, 2, "row2", 2, SyncOperation.UPDATE); mockServer.verify();/*from www .ja v a 2s . c o m*/ }
From source file:com.expedia.client.WunderGroundClient.java
@Override public ResponseEntity<Response> getXMLResponse(Object request) { ResponseEntity<Response> responseEntity = null; Weather weather = null;//from www .java 2 s.c o m if (request instanceof Weather) { weather = (Weather) request; List<MediaType> mediaTypes = new ArrayList<MediaType>(); mediaTypes.add(MediaType.APPLICATION_XML); HttpHeaders headers = new HttpHeaders(); headers.setAccept(mediaTypes); HttpEntity<Weather> httpEntity = new HttpEntity<Weather>(null, headers); try { System.out.println("Hitting weather service!"); responseEntity = restTemplate.exchange(weatherServiceXmlUrl, HttpMethod.GET, httpEntity, Response.class, weatherApiKey, weather.getZipCode()); } catch (RuntimeException e) { e.printStackTrace(); weather.setErrorDesc("Get failed" + e.getMessage()); } } return responseEntity; }
From source file:com.capitalone.dashboard.collector.DefaultNexusIQClientTest.java
@Test public void getApplications() throws Exception { settings.setSelectStricterLicense(true); String appJson = getJson("applications.json"); String instanceUrl = "http://nexusiq.com"; String appListUrl = "http://nexusiq.com/api/v2/applications"; doReturn(new ResponseEntity<>(appJson, HttpStatus.OK)).when(rest).exchange(eq(appListUrl), eq(HttpMethod.GET), Matchers.any(HttpEntity.class), eq(String.class)); List<NexusIQApplication> apps = defaultNexusIQClient.getApplications(instanceUrl); assertThat(apps.size(), is(2));/*from www . j a v a2 s. c o m*/ assertThat(apps.get(0).getApplicationName(), is("Innovation-Challenge-picket")); assertThat(apps.get(1).getApplicationName(), is("ABCD4567")); assertThat(apps.get(0).getApplicationId(), is("65df87ab0cd04810b18562146b6083bf")); assertThat(apps.get(1).getApplicationId(), is("d50b407aeb21480f8bbce3d46f1a5574")); }
From source file:comsat.sample.freemarker.SampleWebFreeMarkerApplicationTests.java
@Test public void testFreeMarkerErrorTemplate() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); HttpEntity<String> requestEntity = new HttpEntity<String>(headers); ResponseEntity<String> responseEntity = new TestRestTemplate().exchange( "http://localhost:" + port + "/does-not-exist", HttpMethod.GET, requestEntity, String.class); assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); assertTrue("Wrong body:\n" + responseEntity.getBody(), responseEntity.getBody().contains("Something went wrong: 404 Not Found")); }
From source file:fi.helsinki.opintoni.server.LeikiServer.java
private void expextResults(String requestUrl, String responseFile) { server.expect(requestTo(requestUrl)).andExpect(method(HttpMethod.GET)).andRespond( withSuccess(SampleDataFiles.toText("leiki/" + responseFile), MediaType.APPLICATION_JSON)); }
From source file:at.ac.univie.isc.asio.security.HttpMethodRestrictionFilter.java
@Override public void doFilter(final ServletRequest servletRequest, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { final HttpServletRequest request = (HttpServletRequest) servletRequest; final Authentication authentication = org.springframework.security.core.context.SecurityContextHolder .getContext().getAuthentication(); if (authentication != null && HttpMethod.GET.name().equalsIgnoreCase(request.getMethod())) { logger.debug("applying " + RESTRICTION + " to " + authentication); Set<GrantedAuthority> restricted = RESTRICTION.mapAuthorities(authentication.getAuthorities()); if (restricted.isEmpty()) { // anonymous and remember me tokens require at least one authority restricted = Collections.<GrantedAuthority>singleton(Role.NONE); }/* w w w.j a va2 s . co m*/ if (!restricted.containsAll(authentication.getAuthorities())) { final AbstractAuthenticationToken replacement = copy(authentication, restricted); replacement.setDetails(authentication.getDetails()); logger.debug("injecting " + replacement); org.springframework.security.core.context.SecurityContextHolder.getContext() .setAuthentication(replacement); } else { logger.debug("skip restricting " + authentication + " as it contains no restricted authorities"); } } else { logger.debug("skip restricting " + authentication + " on HTTP method " + request.getMethod()); } chain.doFilter(request, response); }
From source file:fi.helsinki.opintoni.server.WebPageServer.java
public void expectMetaDataNotFound() { server.expect(requestTo(OpenGraphSampleData.INVALID_URL)).andExpect(method(HttpMethod.GET)) .andRespond(withStatus(HttpStatus.NOT_FOUND)); }
From source file:net.eusashead.hateoas.springhalbuilder.controller.CustomerListController.java
@RequestMapping(method = RequestMethod.OPTIONS) public ResponseEntity<Void> options(OptionsResponseBuilder<Void> builder) { return builder.allow(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.POST).build(); }
From source file:com.example.SampleWebFreeMarkerApplicationTests.java
@Test public void testFreeMarkerErrorTemplate() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); HttpEntity<String> requestEntity = new HttpEntity<String>(headers); ResponseEntity<String> responseEntity = new TestRestTemplate().exchange( "http://localhost:" + this.port + "/" + contextPath + "/does-not-exist", HttpMethod.GET, requestEntity, String.class); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(responseEntity.getBody()).contains("Something went wrong: 404 Not Found"); }