Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.wallmart.calculateroute.test.rest; import com.wallmart.calculateroute.Application; import com.wallmart.calculateroute.domain.Route; import java.util.HashMap; import java.util.Map; import org.apache.log4j.Logger; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.IntegrationTest; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.TestRestTemplate; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.web.client.RestTemplate; /** * * @author Thomas Daniel Kaneko Teixeira(TDKT) */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) @WebAppConfiguration @IntegrationTest public class CalculateRouteTest { final String BASE_URL = "http://localhost:8080/calculateRoute?"; final String BASE_URL_POST = "http://localhost:8080/insertRoute/"; final static Logger logger = Logger.getLogger(CalculateRouteTest.class); @Test public void shouldCreateNewMapCitiAndDistance() { RestTemplate restTemplate = new TestRestTemplate(); Map<String, String> vars = new HashMap<>(); String result = ""; vars.put("map", "So Paulo"); vars.put("start", "Morumbi"); vars.put("end", "Jardins"); vars.put("distance", "13"); result = restTemplate.getForObject(BASE_URL + "map={map}&start={start}&end={end}&distance={distance}", String.class, vars); // result = restTemplate.getForObject(BASE_URL + "{map}/{start}/{end}/{distance}", String.class, vars); vars.put("map", "mapCidade"); vars.put("start", "A"); vars.put("end", "B"); vars.put("distance", "10"); result = restTemplate.getForObject(BASE_URL + "map={map}&start={start}&end={end}&distance={distance}", String.class, vars); } }