* Fix: Github reports security vulnerabilities #933 Upgrade camel and spring-data * -Fix github security vulnerabilities in spring-data and camel * -Code changes for review comments
This commit is contained in:
parent
f5455f9887
commit
84c4b034a9
@ -28,7 +28,7 @@ import org.apache.camel.component.mock.MockEndpoint;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
@ -44,7 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
@SpringApplicationConfiguration(classes = AggregatorRouteTest.class)
|
@SpringBootTest(classes = AggregatorRouteTest.class)
|
||||||
@ActiveProfiles("test")
|
@ActiveProfiles("test")
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
|
@ -28,7 +28,7 @@ import org.apache.camel.component.mock.MockEndpoint;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
@ -42,7 +42,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
@SpringApplicationConfiguration(classes = SplitterRouteTest.class)
|
@SpringBootTest(classes = SplitterRouteTest.class)
|
||||||
@ActiveProfiles("test")
|
@ActiveProfiles("test")
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
|
@ -29,7 +29,7 @@ import org.apache.camel.component.mock.MockEndpoint;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
@ -45,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
@SpringApplicationConfiguration(classes = WireTapRouteTest.class)
|
@SpringBootTest(classes = WireTapRouteTest.class)
|
||||||
@ActiveProfiles("test")
|
@ActiveProfiles("test")
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
|
@ -41,7 +41,11 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-entitymanager</artifactId>
|
<artifactId>hibernate-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-dbcp</groupId>
|
<groupId>commons-dbcp</groupId>
|
||||||
|
@ -72,18 +72,23 @@ public class CakeBakingServiceImpl implements CakeBakingService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
CakeToppingDao toppingBean = context.getBean(CakeToppingDao.class);
|
CakeToppingDao toppingBean = context.getBean(CakeToppingDao.class);
|
||||||
CakeTopping topping = toppingBean.findOne(matchingToppings.iterator().next().getId());
|
Optional<CakeTopping> topping = toppingBean.findById(matchingToppings.iterator().next().getId());
|
||||||
CakeDao cakeBean = context.getBean(CakeDao.class);
|
CakeDao cakeBean = context.getBean(CakeDao.class);
|
||||||
Cake cake = new Cake();
|
if (topping.isPresent()) {
|
||||||
cake.setTopping(topping);
|
Cake cake = new Cake();
|
||||||
cake.setLayers(foundLayers);
|
cake.setTopping(topping.get());
|
||||||
cakeBean.save(cake);
|
cake.setLayers(foundLayers);
|
||||||
topping.setCake(cake);
|
cakeBean.save(cake);
|
||||||
toppingBean.save(topping);
|
topping.get().setCake(cake);
|
||||||
CakeLayerDao layerBean = context.getBean(CakeLayerDao.class);
|
toppingBean.save(topping.get());
|
||||||
for (CakeLayer layer : foundLayers) {
|
CakeLayerDao layerBean = context.getBean(CakeLayerDao.class);
|
||||||
layer.setCake(cake);
|
for (CakeLayer layer : foundLayers) {
|
||||||
layerBean.save(layer);
|
layer.setCake(cake);
|
||||||
|
layerBean.save(layer);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new CakeBakingException(String.format("Topping %s is not available",
|
||||||
|
cakeInfo.cakeToppingInfo.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
<property name="dataSource" ref="dataSource" />
|
<property name="dataSource" ref="dataSource" />
|
||||||
<property name="packagesToScan" value="com.iluwatar" />
|
<property name="packagesToScan" value="com.iluwatar" />
|
||||||
<property name="persistenceProvider">
|
<property name="persistenceProvider">
|
||||||
<bean class="org.hibernate.ejb.HibernatePersistence" />
|
<bean class="org.hibernate.jpa.HibernatePersistenceProvider" />
|
||||||
</property>
|
</property>
|
||||||
<property name="jpaProperties">
|
<property name="jpaProperties">
|
||||||
<map>
|
<map>
|
||||||
|
21
pom.xml
21
pom.xml
@ -28,10 +28,10 @@
|
|||||||
<inceptionYear>2014</inceptionYear>
|
<inceptionYear>2014</inceptionYear>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<hibernate.version>5.0.1.Final</hibernate.version>
|
<hibernate.version>5.2.18.Final</hibernate.version>
|
||||||
<spring.version>4.2.4.RELEASE</spring.version>
|
<spring.version>5.0.13.RELEASE</spring.version>
|
||||||
<spring-boot.version>1.3.3.RELEASE</spring-boot.version>
|
<spring-boot.version>2.0.9.RELEASE</spring-boot.version>
|
||||||
<spring-data.version>1.9.2.RELEASE</spring-data.version>
|
<spring-data.version>2.0.14.RELEASE</spring-data.version>
|
||||||
<h2.version>1.4.190</h2.version>
|
<h2.version>1.4.190</h2.version>
|
||||||
<junit.version>4.12</junit.version>
|
<junit.version>4.12</junit.version>
|
||||||
<junit-jupiter.version>5.0.2</junit-jupiter.version>
|
<junit-jupiter.version>5.0.2</junit-jupiter.version>
|
||||||
@ -40,7 +40,7 @@
|
|||||||
<compiler.version>3.8.1</compiler.version>
|
<compiler.version>3.8.1</compiler.version>
|
||||||
<jacoco.version>0.8.4</jacoco.version>
|
<jacoco.version>0.8.4</jacoco.version>
|
||||||
<commons-dbcp.version>1.4</commons-dbcp.version>
|
<commons-dbcp.version>1.4</commons-dbcp.version>
|
||||||
<camel.version>2.16.1</camel.version>
|
<camel.version>2.24.0</camel.version>
|
||||||
<guava.version>19.0</guava.version>
|
<guava.version>19.0</guava.version>
|
||||||
<mockito.version>1.10.19</mockito.version>
|
<mockito.version>1.10.19</mockito.version>
|
||||||
<apache-httpcomponents.version>4.5.10</apache-httpcomponents.version>
|
<apache-httpcomponents.version>4.5.10</apache-httpcomponents.version>
|
||||||
@ -55,6 +55,7 @@
|
|||||||
<aws-lambda-java-events.version>2.0.1</aws-lambda-java-events.version>
|
<aws-lambda-java-events.version>2.0.1</aws-lambda-java-events.version>
|
||||||
<jackson.version>2.8.5</jackson.version>
|
<jackson.version>2.8.5</jackson.version>
|
||||||
<pmd.version>3.12.0</pmd.version>
|
<pmd.version>3.12.0</pmd.version>
|
||||||
|
<log4j.version>1.2.17</log4j.version>
|
||||||
<jaxb-api.version>2.3.0</jaxb-api.version>
|
<jaxb-api.version>2.3.0</jaxb-api.version>
|
||||||
<annotation-api.version>1.3.1</annotation-api.version>
|
<annotation-api.version>1.3.1</annotation-api.version>
|
||||||
</properties>
|
</properties>
|
||||||
@ -191,11 +192,6 @@
|
|||||||
<artifactId>hibernate-core</artifactId>
|
<artifactId>hibernate-core</artifactId>
|
||||||
<version>${hibernate.version}</version>
|
<version>${hibernate.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-entitymanager</artifactId>
|
|
||||||
<version>${hibernate.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
@ -300,6 +296,11 @@
|
|||||||
<artifactId>mongo-java-driver</artifactId>
|
<artifactId>mongo-java-driver</artifactId>
|
||||||
<version>${mongo-java-driver.version}</version>
|
<version>${mongo-java-driver.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
<version>${log4j.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
<artifactId>jaxb-api</artifactId>
|
<artifactId>jaxb-api</artifactId>
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-entitymanager</artifactId>
|
<artifactId>hibernate-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-dbcp</groupId>
|
<groupId>commons-dbcp</groupId>
|
||||||
@ -71,5 +71,9 @@
|
|||||||
<groupId>javax.annotation</groupId>
|
<groupId>javax.annotation</groupId>
|
||||||
<artifactId>javax.annotation-api</artifactId>
|
<artifactId>javax.annotation-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
package com.iluwatar.repository;
|
package com.iluwatar.repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -84,17 +85,17 @@ public class App {
|
|||||||
nasta.setSurname("Spotakova");
|
nasta.setSurname("Spotakova");
|
||||||
repository.save(nasta);
|
repository.save(nasta);
|
||||||
|
|
||||||
LOGGER.info("Find by id 2: {}", repository.findOne(2L));
|
LOGGER.info("Find by id 2: {}", repository.findById(2L).get());
|
||||||
|
|
||||||
// Remove record from Person
|
// Remove record from Person
|
||||||
repository.delete(2L);
|
repository.deleteById(2L);
|
||||||
|
|
||||||
// count records
|
// count records
|
||||||
LOGGER.info("Count Person records: {}", repository.count());
|
LOGGER.info("Count Person records: {}", repository.count());
|
||||||
|
|
||||||
// find by name
|
// find by name
|
||||||
Person p = repository.findOne(new PersonSpecifications.NameEqualSpec("John"));
|
Optional<Person> p = repository.findOne(new PersonSpecifications.NameEqualSpec("John"));
|
||||||
LOGGER.info("Find by John is {}", p);
|
LOGGER.info("Find by John is {}", p.get());
|
||||||
|
|
||||||
// find by age
|
// find by age
|
||||||
persons = repository.findAll(new PersonSpecifications.AgeBetweenSpec(20, 40));
|
persons = repository.findAll(new PersonSpecifications.AgeBetweenSpec(20, 40));
|
||||||
|
@ -24,6 +24,7 @@ package com.iluwatar.repository;
|
|||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
@ -32,6 +33,7 @@ import org.apache.commons.dbcp.BasicDataSource;
|
|||||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.boot.SpringBootConfiguration;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||||
@ -44,6 +46,7 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@EnableJpaRepositories
|
@EnableJpaRepositories
|
||||||
|
@SpringBootConfiguration
|
||||||
public class AppConfig {
|
public class AppConfig {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(AppConfig.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(AppConfig.class);
|
||||||
@ -60,7 +63,7 @@ public class AppConfig {
|
|||||||
basicDataSource.setUrl("jdbc:h2:~/databases/person");
|
basicDataSource.setUrl("jdbc:h2:~/databases/person");
|
||||||
basicDataSource.setUsername("sa");
|
basicDataSource.setUsername("sa");
|
||||||
basicDataSource.setPassword("sa");
|
basicDataSource.setPassword("sa");
|
||||||
return (DataSource) basicDataSource;
|
return basicDataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -134,17 +137,17 @@ public class AppConfig {
|
|||||||
nasta.setSurname("Spotakova");
|
nasta.setSurname("Spotakova");
|
||||||
repository.save(nasta);
|
repository.save(nasta);
|
||||||
|
|
||||||
LOGGER.info("Find by id 2: {}", repository.findOne(2L));
|
LOGGER.info("Find by id 2: {}", repository.findById(2L).get());
|
||||||
|
|
||||||
// Remove record from Person
|
// Remove record from Person
|
||||||
repository.delete(2L);
|
repository.deleteById(2L);
|
||||||
|
|
||||||
// count records
|
// count records
|
||||||
LOGGER.info("Count Person records: {}", repository.count());
|
LOGGER.info("Count Person records: {}", repository.count());
|
||||||
|
|
||||||
// find by name
|
// find by name
|
||||||
Person p = repository.findOne(new PersonSpecifications.NameEqualSpec("John"));
|
Optional<Person> p = repository.findOne(new PersonSpecifications.NameEqualSpec("John"));
|
||||||
LOGGER.info("Find by John is {}", p);
|
LOGGER.info("Find by John is {}", p.get());
|
||||||
|
|
||||||
// find by age
|
// find by age
|
||||||
persons = repository.findAll(new PersonSpecifications.AgeBetweenSpec(20, 40));
|
persons = repository.findAll(new PersonSpecifications.AgeBetweenSpec(20, 40));
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
<property name="dataSource" ref="dataSource" />
|
<property name="dataSource" ref="dataSource" />
|
||||||
<property name="packagesToScan" value="com.iluwatar" />
|
<property name="packagesToScan" value="com.iluwatar" />
|
||||||
<property name="persistenceProvider">
|
<property name="persistenceProvider">
|
||||||
<bean class="org.hibernate.ejb.HibernatePersistence" />
|
<bean class="org.hibernate.jpa.HibernatePersistenceProvider" />
|
||||||
</property>
|
</property>
|
||||||
<property name="jpaProperties">
|
<property name="jpaProperties">
|
||||||
<map>
|
<map>
|
||||||
|
@ -28,6 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@ -35,9 +36,8 @@ import org.junit.jupiter.api.AfterEach;
|
|||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ import com.google.common.collect.Lists;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
@ContextConfiguration(classes = { AppConfig.class }, loader = AnnotationConfigContextLoader.class)
|
@SpringBootTest(classes = { AppConfig.class })
|
||||||
public class AnnotationBasedRepositoryTest {
|
public class AnnotationBasedRepositoryTest {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -66,7 +66,7 @@ public class AnnotationBasedRepositoryTest {
|
|||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
|
||||||
repository.save(persons);
|
repository.saveAll(persons);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -119,8 +119,8 @@ public class AnnotationBasedRepositoryTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testFindOneByNameEqualSpec() {
|
public void testFindOneByNameEqualSpec() {
|
||||||
|
|
||||||
Person actual = repository.findOne(new PersonSpecifications.NameEqualSpec("Terry"));
|
Optional<Person> actual = repository.findOne(new PersonSpecifications.NameEqualSpec("Terry"));
|
||||||
assertEquals(terry, actual);
|
assertEquals(terry, actual.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
|
@ -25,9 +25,8 @@ package com.iluwatar.repository;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
@ -42,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
@ContextConfiguration(classes = { AppConfig.class }, loader = AnnotationConfigContextLoader.class)
|
@SpringBootTest(classes = { AppConfig.class })
|
||||||
public class AppConfigTest {
|
public class AppConfigTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -28,6 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ import org.junit.jupiter.api.AfterEach;
|
|||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@ -45,7 +46,7 @@ import com.google.common.collect.Lists;
|
|||||||
* by {@link org.springframework.data.jpa.domain.Specification} are also test.
|
* by {@link org.springframework.data.jpa.domain.Specification} are also test.
|
||||||
*/
|
*/
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
|
@SpringBootTest(properties = { "locations=classpath:applicationContext.xml" })
|
||||||
public class RepositoryTest {
|
public class RepositoryTest {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -64,7 +65,7 @@ public class RepositoryTest {
|
|||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
|
||||||
repository.save(persons);
|
repository.saveAll(persons);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -115,8 +116,8 @@ public class RepositoryTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testFindOneByNameEqualSpec() {
|
public void testFindOneByNameEqualSpec() {
|
||||||
|
|
||||||
Person actual = repository.findOne(new PersonSpecifications.NameEqualSpec("Terry"));
|
Optional<Person> actual = repository.findOne(new PersonSpecifications.NameEqualSpec("Terry"));
|
||||||
assertEquals(terry, actual);
|
assertEquals(terry, actual.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
|
Loading…
x
Reference in New Issue
Block a user