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.appglu.impl.PushTemplateTest.java
@Test public void readDevice() { mockServer.expect(requestTo("http://localhost/appglu/v1/push/device/f3f71c5a-0a98-48f7-9acd-d38d714d76ad")) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess().body(compactedJson("data/push_device")).headers(responseHeaders)); Device device = pushOperations.readDevice("f3f71c5a-0a98-48f7-9acd-d38d714d76ad"); this.assertDevice(device); mockServer.verify();/*from ww w. j a v a2 s .co m*/ }
From source file:org.zalando.github.spring.IssuesTemplateTest.java
@Test public void listUserIssues() throws Exception { mockServer.expect(requestTo("https://api.github.com/user/issues?per_page=25")) .andExpect(method(HttpMethod.GET)) // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN")) .andRespond(withSuccess(new ClassPathResource("listIssues.json", getClass()), MediaType.APPLICATION_JSON)); List<Issue> issueList = issuesTemplate.listUserIssues(); Assertions.assertThat(issueList).isNotNull(); Assertions.assertThat(issueList.size()).isEqualTo(1); Assertions.assertThat(issueList.get(0).getId()).isEqualTo(1); }
From source file:io.syndesis.runtime.SecurityConfiguration.java
@Override @SuppressWarnings("PMD.SignatureDeclareThrowsException") protected void configure(HttpSecurity http) throws Exception { http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() .addFilter(requestHeaderAuthenticationFilter()) .addFilter(new AnonymousAuthenticationFilter("anonymous")).authorizeRequests() .antMatchers(HttpMethod.OPTIONS).permitAll().antMatchers("/api/v1/swagger.*").permitAll() .antMatchers("/api/v1/index.html").permitAll().antMatchers("/api/v1/version").permitAll() .antMatchers(HttpMethod.GET, "/api/v1/credentials/callback").permitAll().antMatchers("/api/v1/**") .hasRole("AUTHENTICATED").anyRequest().permitAll(); http.csrf().disable();//from w w w.j a v a2s . c o m }
From source file:access.test.PiazzaEnvironmentTests.java
@Test public void testResourcesExist() { Mockito.when(this.restTemplate.exchange(Mockito.endsWith("/workspaces/piazza.json"), Mockito.eq(HttpMethod.GET), Mockito.any(), Mockito.eq(String.class))) .thenReturn(new ResponseEntity<>("{\"result\": \"totally exists\"}", HttpStatus.OK)); Mockito.when(this.restTemplate.exchange(Mockito.endsWith("/datastores/piazza.json"), Mockito.eq(HttpMethod.GET), Mockito.any(), Mockito.eq(String.class))) .thenReturn(new ResponseEntity<>("{\"result\": \"totally exists\"}", HttpStatus.OK)); piazzaEnvironment.initializeEnvironment(); assertTrue(true); // no error occurred }
From source file:com.orange.ngsi2.client.Ngsi2ClientTest.java
@Test public void testGetV2_ServerError() throws Exception { thrown.expect(Ngsi2Exception.class); thrown.expectMessage(//from ww w . j a v a 2s . c o m "error: 500 | description: Internal Server Error | affectedItems: [item1, item2, item3]"); mockServer.expect(requestTo(baseURL + "/v2")).andExpect(method(HttpMethod.GET)) .andRespond(withServerError().body(Utils.loadResource("json/error500Response.json"))); ngsiClient.getV2().get(); }
From source file:com.bailen.radioOnline.recursos.REJA.java
public Cancion[] random(String apiKey) throws IOException { HttpHeaders header = new HttpHeaders(); header.set("Authorization", apiKey); HttpEntity entity = new HttpEntity(header); String lista = new String(); HttpEntity<String> response; response = new RestTemplate().exchange("http://ceatic.ujaen.es:8075/radioapi/v2/random", HttpMethod.GET, entity, String.class, lista); String canc = response.getBody(); StringTokenizer st = new StringTokenizer(canc, "[", true); st.nextToken();/*from www.j a v a2s . co m*/ st.nextToken(); canc = "[" + st.nextToken(); try { ObjectMapper a = new ObjectMapper(); Item[] listilla = a.readValue(canc, Item[].class); Vector<Integer> ids = new Vector<>(); for (int i = 0; i < listilla.length; ++i) { ids.add(listilla[i].getId()); } return jamendo.canciones(ids); } catch (Exception e) { //return null; throw new IOException("no se han recibido canciones"); } }
From source file:org.zalando.github.spring.OrganizationTemplateTest.java
@Test public void listUserOrganizations() throws Exception { mockServer.expect(requestTo("https://api.github.com/user/klaus/orgs?per_page=25")) .andExpect(method(HttpMethod.GET)) // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN")) .andRespond(withSuccess(new ClassPathResource("listOrgas.json", getClass()), MediaType.APPLICATION_JSON)); List<Organization> orgaList = usersTemplate.listUserOrganizations("klaus"); Assertions.assertThat(orgaList).isNotNull(); Assertions.assertThat(orgaList.size()).isEqualTo(1); }
From source file:com.alcatel.hello.actuator.ui.SampleActuatorUIApplicationTests.java
@Test public void testError() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity<String> entity = new TestRestTemplate().exchange("http://localhost:" + this.port + "/error", HttpMethod.GET, new HttpEntity<Void>(headers), String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("<html>")); assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("<body>")); assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("Please contact the operator with the above information")); }
From source file:fi.helsinki.opintoni.server.OodiServer.java
public void expectTeacherCoursesRequest(String teacherNumber, String sinceDateString) { server.expect(requestTo(teachingUrl(teacherNumber, sinceDateString))).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(SampleDataFiles.toText("oodi/teachercourses.json"), MediaType.APPLICATION_JSON)); }
From source file:com.gopivotal.cla.github.GitHubConditionalTest.java
@Test public void withNextLink() { HttpHeaders headers = new HttpHeaders(); headers.add("Link", "<" + URL + ">; rel=\"first\""); headers.add("Link", "<" + LINK_URL + ">; rel=\"next\""); ResponseEntity<Set> response1 = new ResponseEntity<Set>(Sets.asSet(), headers, HttpStatus.OK); when(this.restOperations.exchange(URL, HttpMethod.GET, REQUEST_ENTITY, Set.class)).thenReturn(response1); ResponseEntity<Set> response2 = new ResponseEntity<Set>(Sets.asSet(), HttpStatus.OK); when(this.restOperations.exchange(LINK_URL, HttpMethod.GET, REQUEST_ENTITY, Set.class)) .thenReturn(response2);/*from ww w . j a v a 2s. co m*/ this.gitHubType.getTrigger(); assertTrue(this.gitHubType.initializedCalled); }