Good Morning people! I am doing unit test in my spring boot application but it launches the next exception: java.lang.IllegalArgumentException: No DataSource specified;
This is my method:
@RestController public class controlador { @Autowired(required = true) JdbcTemplate conn; @CrossOrigin @RequestMapping(value = "/getlistadopantallatab", method = RequestMethod.POST, consumes="application/json",produces = "application/json") @ResponseBody public Map<String, Object> getListadoPantallaTab(@RequestBody Map<String,Object> dto) { Map<String, Object> simpleJdbcCallResult = null; try { SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(conn) .withCatalogName("CCR_PACKAGE") .withProcedureName("getListadoPorPantallaTab"); SqlParameterSource in = new MapSqlParameterSource(dto); simpleJdbcCallResult = simpleJdbcCall.execute(in); } catch (Exception e) { System.out.println("Se ha lanzado la siguiente excepcion: " + e); } return simpleJdbcCallResult; } and it is my test:
public class controladorTest { static controlador mockInstanced; @BeforeClass public static void setup() throws Exception { mockInstanced= new controlador(); mockInstanced.conn = mock(JdbcTemplate.class); } /** * Test of getListadoPantallaTab method, of class controlador. */ @Test public void testGetListadoPantallaTab() { System.out.println("Test unitario getListadoPantallaTab: "); @SuppressWarnings("serial") Map<String, Object> dto = new HashMap<String, Object>() {{ put("Inicio", 1); put("fin", 15); }}; mockInstanced.getListadoPantallaTab(dto); } Somebody knows what i am doing wrong?
PD: Sorry for my english, i am spanish!