Apply project coding conventions to Repository example

This commit is contained in:
Ilkka Seppala
2015-12-05 21:26:30 +02:00
parent 02d6754804
commit 507b89d5e4
7 changed files with 138 additions and 132 deletions
@@ -22,9 +22,10 @@ import com.google.common.collect.Lists;
/**
* Test case to test the functions of {@link PersonRepository}, beside the CRUD functions, the query
* by {@link org.springframework.data.jpa.domain.Specification} are also test.
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { AppConfig.class}, loader = AnnotationConfigContextLoader.class)
@ContextConfiguration(classes = { AppConfig.class }, loader = AnnotationConfigContextLoader.class)
public class AnnotationBasedRepositoryTest {
@Resource
@@ -107,4 +108,3 @@ public class AnnotationBasedRepositoryTest {
}
}
@@ -20,35 +20,36 @@ import org.springframework.transaction.annotation.Transactional;
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { AppConfig.class}, loader = AnnotationConfigContextLoader.class)
@ContextConfiguration(classes = { AppConfig.class }, loader = AnnotationConfigContextLoader.class)
public class AppConfigTest {
@Autowired
DataSource dataSource;
/**
* Test for bean instance
*/
@Test
public void testDataSource() {
assertNotNull(dataSource);
}
/**
* Test for correct query execution
* @throws SQLException
*/
@Test
@Transactional
public void testQuery() throws SQLException{
ResultSet resultSet = dataSource.getConnection().createStatement().executeQuery("SELECT 1");
String result = null;
String expected = "1";
while (resultSet.next()) {
result = resultSet.getString(1);
}
assertTrue(result.equals(expected));
}
@Autowired
DataSource dataSource;
/**
* Test for bean instance
*/
@Test
public void testDataSource() {
assertNotNull(dataSource);
}
/**
* Test for correct query execution
*
* @throws SQLException
*/
@Test
@Transactional
public void testQuery() throws SQLException {
ResultSet resultSet = dataSource.getConnection().createStatement().executeQuery("SELECT 1");
String result = null;
String expected = "1";
while (resultSet.next()) {
result = resultSet.getString(1);
}
assertTrue(result.equals(expected));
}
}
@@ -23,7 +23,7 @@ import com.google.common.collect.Lists;
* by {@link org.springframework.data.jpa.domain.Specification} are also test.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
public class RepositoryTest {
@Resource
@@ -106,4 +106,3 @@ public class RepositoryTest {
}
}