Skip to content

Instantly share code, notes, and snippets.

@Romeh
Created September 3, 2018 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Romeh/b4e61258176e69666df35b496cd9c4cc to your computer and use it in GitHub Desktop.
Save Romeh/b4e61258176e69666df35b496cd9c4cc to your computer and use it in GitHub Desktop.
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {DbConfig.class})
@ActiveProfiles("DaoTest")
@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:dao/TestData.sql")
public class PostgresEmbeddedDaoTestingApplicationTests {
@Autowired
private CustomerRepository customerRepository;
@Test
public void contextLoads() {
customerRepository.save(Customer.builder()
.id(new Random().nextLong())
.address("brussels")
.name("TestName")
.build());
Assert.assertTrue(customerRepository.findCustomerByName("TestName") != null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment