Tano
Tano

Reputation: 1377

Java Spring JUnit Test Datasource not specified

I have the following code:

@Override
public long getUniqueId() {
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String dateAndTime= dateFormat.format(new Date());
    jdbcTemplate.update(someSqlQuery, dateAndTime);

    SimpleJdbcCall jdbcCall = new SimpleJdbcCall(jdbcTemplate).withProcedureName("IDENTITY").withReturnValue();
    }
    return 0;
}

And I want to write simple unit test but whenever the code reaches the line with SimpleJdbcCall throws exception that "DataSource is not specified". This is my test so far:

@Test
public void testGetBatchId() {
    transactionImpl.getUniqueId();
}

What is wrong with my setup?

Upvotes: 0

Views: 882

Answers (1)

JWqvist
JWqvist

Reputation: 717

If you want to make integration test you need the data source defined in the test scope

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = GatewayApplication.class)
@WebAppConfiguration
@Transactional
public class ControllerIT {

Upvotes: 1

Related Questions