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.mycompany.CPUTAuction.restapi.BidRestControllerTest.java
@Test public void testreadBidById() { int bid_Id = 1001; HttpEntity<?> requestEntity = getHttpEntity(); ResponseEntity<Bid> responseEntity = restTemplate.exchange(URL + "api/bid/id/" + bid_Id, HttpMethod.GET, requestEntity, Bid.class); Bid club = responseEntity.getBody(); Assert.assertNotNull(club);/* w ww .ja va2 s . com*/ }
From source file:com.orange.ngsi2.client.Ngsi2ClientTest.java
@Test(expected = HttpMessageNotReadableException.class) public void testGetV2_SyntaxError() throws Exception { mockServer.expect(requestTo(baseURL + "/v2")).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess("{/", MediaType.APPLICATION_JSON)); ngsiClient.getV2().get();/*from w ww . j a v a 2 s . com*/ }
From source file:org.moserp.inventory.rest.InventoryTest.java
@Test public void testInventoryItemsPerFacility() { InventoryTransfer inventoryTransfer = new InventoryTransfer(new ProductInstance(product), facility, mobileFacility, new Quantity(55)); restTemplate.postForLocation(testEnvironment.createRestUri("inventoryTransfers"), inventoryTransfer); Resources<InventoryItem> inventories = restTemplate.exchange( testEnvironment.createRestUri("inventoryItems/search/findByProductIdOrFacilityId?facilityId=2"), HttpMethod.GET, null, new ParameterizedTypeReference<Resources<InventoryItem>>() { }).getBody();/* ww w . j av a 2 s . co m*/ assertEquals("size", 1, inventories.getContent().size()); }
From source file:com.haulmont.restapi.ldap.LdapAuthController.java
@RequestMapping(value = "/v2/ldap/token", method = RequestMethod.GET) public ResponseEntity<OAuth2AccessToken> getAccessToken(Principal principal, @RequestParam Map<String, String> parameters, HttpServletRequest request) throws HttpRequestMethodNotSupportedException { if (!allowedRequestMethods.contains(HttpMethod.GET)) { throw new HttpRequestMethodNotSupportedException("GET"); }/*from w w w. ja v a 2 s. c o m*/ return postAccessToken(principal, parameters, request); }
From source file:de.zib.gndms.gndmc.AbstractClient.java
/** * Executes a GET on a url, where the request header contains a given user name. * //from w ww . j av a2 s . c o m * @param <T> The body type of the response. * @param clazz The type of the return value. * @param url The url of the request. * @param dn The user name. * @return The response as entity. */ protected final <T> ResponseEntity<T> unifiedGet(final Class<T> clazz, final String url, final String dn) { return unifiedX(HttpMethod.GET, clazz, null, url, dn, null); }
From source file:cz.zcu.kiv.eeg.mobile.base.ws.asynctask.TestCredentials.java
@Override protected UserInfo doInBackground(Void... params) { SharedPreferences credentials = getCredentials(); String username = credentials.getString("tmp_username", null); String password = credentials.getString("tmp_password", null); String url = credentials.getString("tmp_url", null) + Values.SERVICE_USER + "login"; setState(RUNNING, R.string.working_ws_credentials); HttpAuthentication authHeader = new HttpBasicAuthentication(username, password); HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setAuthorization(authHeader); requestHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_XML)); HttpEntity<Object> entity = new HttpEntity<Object>(requestHeaders); SSLSimpleClientHttpRequestFactory factory = new SSLSimpleClientHttpRequestFactory(); // Create a new RestTemplate instance RestTemplate restTemplate = new RestTemplate(factory); restTemplate.getMessageConverters().add(new SimpleXmlHttpMessageConverter()); try {// w ww . j av a 2 s.c om // Make the network request Log.d(TAG, url); ResponseEntity<UserInfo> userInfo = restTemplate.exchange(url, HttpMethod.GET, entity, UserInfo.class); return (Values.user = userInfo.getBody()); } catch (Exception e) { Log.e(TAG, e.getLocalizedMessage(), e); setState(ERROR, e); return null; } finally { setState(DONE); } }
From source file:tools.AbstractIntegrationTest.java
protected ResponseEntity<String> exchangeRequest(URI uri) { return this.restTemplate.exchange(new RequestEntity<>(new HttpHeaders(), HttpMethod.GET, uri), String.class); }
From source file:org.messic.android.util.RestJSONClient.java
/** * Rest GET petition to the server at the url param, sending all the post parameters defiend at formData. This post * return an object (json marshalling) of class defined at clazz parameter. You should register a * {@link RestListener} in order to obtain the returned object, this is because the petition is done in an async * process./* w w w.j a v a 2 s. c o m*/ * * @param url {@link string} URL to attack * @param clazz Class<T/> class that you will marshall to a json object * @param rl {@link RestListener} listener to push the object returned */ public static <T> void get(final String url, final Class<T> clazz, final RestListener<T> rl) { final RestTemplate restTemplate = new RestTemplate(); restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); // Populate the MultiValueMap being serialized and headers in an HttpEntity object to use for the request final HttpEntity<MultiValueMap<?, ?>> requestEntity = new HttpEntity<MultiValueMap<?, ?>>( new LinkedMultiValueMap<String, Object>(), requestHeaders); AsyncTask<Void, Void, Void> at = new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { try { ResponseEntity<T> response = restTemplate.exchange(url, HttpMethod.GET, requestEntity, clazz); rl.response(response.getBody()); } catch (Exception e) { rl.fail(e); } return null; } }; at.execute(); }
From source file:fr.putnami.pwt.plugin.ajaxbot.filter.AjaxPageFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; if (HttpMethod.GET.toString().equals(request.getMethod()) && req.getParameter(QUERY_PARAM_ESCAPED_FRAGMENT) != null) { ByteStreams.copy(this.getHtmlStream(request), resp.getOutputStream()); } else {/*from www .j av a 2s. com*/ chain.doFilter(req, resp); } }
From source file:com.nobu.dvdrentalweb.test.restapi.AccountRestControllerTest.java
@Test public void testgetAllAcounts() { HttpEntity<?> requestEntity = getHttpEntity(); ResponseEntity<Account[]> responseEntity = restTemplate.exchange(URL + "api/account/accounts", HttpMethod.GET, requestEntity, Account[].class); Account[] accounts = responseEntity.getBody(); for (Account account : accounts) { System.out.println("The Account Name is " + account.getAccountName()); }/*from w w w . j av a 2 s.c o m*/ Assert.assertTrue(accounts.length > 0); }