Skip to content

Commit 5ce95b5

Browse files
authored
fix(versions): upgrade spring-boot-dependencies to 2.1.11.RELEASE (#187)
* fix: upgrade Spring Boot dependency version to 2.1.8.RELEASE * fix(versions): update Spring Boot to 2.1.9.RELEASE * fix(versions): update spring-boot-dependencies to 2.1.11.RELEASE * fix: Added `@DirtiesContext` due to test context caching H2 db * fix: Set properties to control UTC timezone with Hibernate * fix: Added missing `@DirtiesContext` annotation on tests * fix: Added `@AutoConfigureTestDatabase(replace = Replace.ANY)` annotation * fix: set `maven-surefire-plugin` system property to `user.timezone=UTC` * refactor(tests): Added AbstractSpringBootTestSupport class
1 parent deafe11 commit 5ce95b5

19 files changed

+115
-146
lines changed

graphql-jpa-query-build/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<dependency>
1616
<groupId>org.springframework.boot</groupId>
1717
<artifactId>spring-boot-dependencies</artifactId>
18-
<version>2.1.7.RELEASE</version>
18+
<version>2.1.11.RELEASE</version>
1919
<type>pom</type>
2020
<scope>import</scope>
2121
</dependency>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.introproventures.graphql.jpa.query;
2+
3+
import org.junit.runner.RunWith;
4+
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
5+
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace;
6+
import org.springframework.test.context.TestPropertySource;
7+
import org.springframework.test.context.junit4.SpringRunner;
8+
9+
@RunWith(SpringRunner.class)
10+
@TestPropertySource({"classpath:hibernate.properties"})
11+
@AutoConfigureTestDatabase(replace = Replace.ANY)
12+
public abstract class AbstractSpringBootTestSupport {
13+
14+
}

graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/converter/GraphQLJpaConverterTests.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@
3232
import javax.persistence.criteria.Subquery;
3333
import javax.transaction.Transactional;
3434

35+
import org.junit.Test;
36+
import org.springframework.beans.factory.annotation.Autowired;
37+
import org.springframework.boot.autoconfigure.SpringBootApplication;
38+
import org.springframework.boot.test.context.SpringBootTest;
39+
import org.springframework.context.annotation.Bean;
40+
3541
import com.fasterxml.jackson.databind.JsonNode;
3642
import com.fasterxml.jackson.databind.ObjectMapper;
43+
import com.introproventures.graphql.jpa.query.AbstractSpringBootTestSupport;
3744
import com.introproventures.graphql.jpa.query.converter.model.JsonEntity;
3845
import com.introproventures.graphql.jpa.query.converter.model.TaskEntity;
3946
import com.introproventures.graphql.jpa.query.converter.model.TaskVariableEntity;
@@ -42,22 +49,10 @@
4249
import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
4350
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
4451
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
45-
import org.junit.Test;
46-
import org.junit.runner.RunWith;
47-
import org.springframework.beans.factory.annotation.Autowired;
48-
import org.springframework.boot.autoconfigure.SpringBootApplication;
49-
import org.springframework.boot.test.context.SpringBootTest;
50-
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
51-
import org.springframework.context.annotation.Bean;
52-
import org.springframework.test.context.TestPropertySource;
53-
import org.springframework.test.context.junit4.SpringRunner;
5452

5553

56-
@RunWith(SpringRunner.class)
57-
@SpringBootTest(webEnvironment=WebEnvironment.NONE,
58-
properties = "spring.datasource.data=GraphQLJpaConverterTests.sql")
59-
@TestPropertySource({"classpath:hibernate.properties"})
60-
public class GraphQLJpaConverterTests {
54+
@SpringBootTest(properties = "spring.datasource.data=GraphQLJpaConverterTests.sql")
55+
public class GraphQLJpaConverterTests extends AbstractSpringBootTestSupport {
6156

6257
@SpringBootApplication
6358
static class Application {

graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/embeddedid/EntityWithEmbeddedIdTest.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,19 @@
55
import javax.persistence.EntityManager;
66

77
import org.junit.Test;
8-
import org.junit.runner.RunWith;
98
import org.springframework.beans.factory.annotation.Autowired;
109
import org.springframework.boot.autoconfigure.SpringBootApplication;
1110
import org.springframework.boot.test.context.SpringBootTest;
1211
import org.springframework.context.annotation.Bean;
13-
import org.springframework.test.context.TestPropertySource;
14-
import org.springframework.test.context.junit4.SpringRunner;
1512

13+
import com.introproventures.graphql.jpa.query.AbstractSpringBootTestSupport;
1614
import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
1715
import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
1816
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
1917
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
2018

21-
@RunWith(SpringRunner.class)
22-
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
23-
properties = "spring.datasource.data=EntityWithEmbeddedIdTest.sql")
24-
@TestPropertySource({"classpath:hibernate.properties"})
25-
public class EntityWithEmbeddedIdTest {
19+
@SpringBootTest(properties = "spring.datasource.data=EntityWithEmbeddedIdTest.sql")
20+
public class EntityWithEmbeddedIdTest extends AbstractSpringBootTestSupport {
2621

2722
@SpringBootApplication
2823
static class Application {

graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/idclass/EntityWithIdClassTest.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,19 @@
55
import javax.persistence.EntityManager;
66

77
import org.junit.Test;
8-
import org.junit.runner.RunWith;
98
import org.springframework.beans.factory.annotation.Autowired;
109
import org.springframework.boot.autoconfigure.SpringBootApplication;
1110
import org.springframework.boot.test.context.SpringBootTest;
1211
import org.springframework.context.annotation.Bean;
13-
import org.springframework.test.context.TestPropertySource;
14-
import org.springframework.test.context.junit4.SpringRunner;
1512

13+
import com.introproventures.graphql.jpa.query.AbstractSpringBootTestSupport;
1614
import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
1715
import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
1816
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
1917
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
2018

21-
@RunWith(SpringRunner.class)
22-
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
23-
properties = "spring.datasource.data=EntityWithIdClassTest.sql")
24-
@TestPropertySource({"classpath:hibernate.properties"})
25-
public class EntityWithIdClassTest {
19+
@SpringBootTest(properties = "spring.datasource.data=EntityWithIdClassTest.sql")
20+
public class EntityWithIdClassTest extends AbstractSpringBootTestSupport {
2621

2722
@SpringBootApplication
2823
static class Application {

graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/localdatetime/GraphQLLocalDateTimeTest.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
package com.introproventures.graphql.jpa.query.localdatetime;
22

3-
import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
4-
import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
5-
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
6-
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import javax.persistence.EntityManager;
6+
7+
import org.junit.BeforeClass;
78
import org.junit.Test;
8-
import org.junit.runner.RunWith;
99
import org.springframework.beans.factory.annotation.Autowired;
1010
import org.springframework.boot.autoconfigure.SpringBootApplication;
1111
import org.springframework.boot.test.context.SpringBootTest;
1212
import org.springframework.context.annotation.Bean;
13-
import org.springframework.test.context.TestPropertySource;
14-
import org.springframework.test.context.junit4.SpringRunner;
1513

16-
import javax.persistence.EntityManager;
17-
18-
import static org.assertj.core.api.Assertions.assertThat;
14+
import com.introproventures.graphql.jpa.query.AbstractSpringBootTestSupport;
15+
import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
16+
import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
17+
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
18+
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
1919

20-
@RunWith(SpringRunner.class)
21-
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
22-
properties = "spring.datasource.data=LocalDatetTmeData.sql")
23-
@TestPropertySource({"classpath:hibernate.properties"})
24-
public class GraphQLLocalDateTimeTest {
20+
@SpringBootTest(properties = "spring.datasource.data=LocalDatetTmeData.sql")
21+
public class GraphQLLocalDateTimeTest extends AbstractSpringBootTestSupport {
2522

2623
@SpringBootApplication
2724
static class Application {
@@ -44,6 +41,11 @@ public GraphQLSchemaBuilder graphQLSchemaBuilder(final EntityManager entityManag
4441
@Autowired
4542
private EntityManager entityManager;
4643

44+
@BeforeClass
45+
public static void init() {
46+
//TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
47+
}
48+
4749
@Test
4850
public void queryLocalDateWithEqualTest() {
4951
//given

graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/BooksSchemaBuildTest.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,22 @@
2424

2525
import javax.persistence.EntityManager;
2626

27-
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
28-
import graphql.schema.GraphQLFieldDefinition;
29-
import graphql.schema.GraphQLList;
30-
import graphql.schema.GraphQLSchema;
3127
import org.junit.Before;
3228
import org.junit.Test;
33-
import org.junit.runner.RunWith;
3429
import org.springframework.beans.factory.annotation.Autowired;
3530
import org.springframework.boot.autoconfigure.SpringBootApplication;
3631
import org.springframework.boot.test.context.SpringBootTest;
37-
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
3832
import org.springframework.context.annotation.Bean;
39-
import org.springframework.test.context.junit4.SpringRunner;
4033

41-
@RunWith(SpringRunner.class)
42-
@SpringBootTest(
43-
webEnvironment=WebEnvironment.NONE
44-
)
45-
public class BooksSchemaBuildTest {
34+
import com.introproventures.graphql.jpa.query.AbstractSpringBootTestSupport;
35+
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
36+
37+
import graphql.schema.GraphQLFieldDefinition;
38+
import graphql.schema.GraphQLList;
39+
import graphql.schema.GraphQLSchema;
40+
41+
@SpringBootTest
42+
public class BooksSchemaBuildTest extends AbstractSpringBootTestSupport {
4643

4744
@SpringBootApplication
4845
static class TestConfiguration {

graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/CalculatedEntityTests.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010
import javax.persistence.EntityManager;
1111

1212
import org.junit.Test;
13-
import org.junit.runner.RunWith;
1413
import org.springframework.beans.factory.annotation.Autowired;
1514
import org.springframework.boot.autoconfigure.SpringBootApplication;
1615
import org.springframework.boot.test.context.SpringBootTest;
1716
import org.springframework.context.annotation.Bean;
18-
import org.springframework.test.context.TestPropertySource;
19-
import org.springframework.test.context.junit4.SpringRunner;
2017
import org.springframework.util.Assert;
2118

19+
import com.introproventures.graphql.jpa.query.AbstractSpringBootTestSupport;
2220
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
2321
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
2422

@@ -27,10 +25,8 @@
2725
import graphql.schema.GraphQLSchema;
2826
import graphql.validation.ValidationErrorType;
2927

30-
@RunWith(SpringRunner.class)
31-
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.NONE)
32-
@TestPropertySource({"classpath:hibernate.properties"})
33-
public class CalculatedEntityTests {
28+
@SpringBootTest
29+
public class CalculatedEntityTests extends AbstractSpringBootTestSupport {
3430
@SpringBootApplication
3531
static class Application {
3632
@Bean

graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/EntityIntrospectorTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,21 @@
1414

1515
import org.junit.Before;
1616
import org.junit.Test;
17-
import org.junit.runner.RunWith;
1817
import org.mockito.Mockito;
1918
import org.springframework.beans.factory.annotation.Autowired;
2019
import org.springframework.boot.autoconfigure.SpringBootApplication;
2120
import org.springframework.boot.test.context.SpringBootTest;
22-
import org.springframework.test.context.TestPropertySource;
23-
import org.springframework.test.context.junit4.SpringRunner;
2421

22+
import com.introproventures.graphql.jpa.query.AbstractSpringBootTestSupport;
2523
import com.introproventures.graphql.jpa.query.schema.impl.EntityIntrospector;
2624
import com.introproventures.graphql.jpa.query.schema.impl.EntityIntrospector.EntityIntrospectionResult;
2725
import com.introproventures.graphql.jpa.query.schema.impl.EntityIntrospector.EntityIntrospectionResult.AttributePropertyDescriptor;
2826
import com.introproventures.graphql.jpa.query.schema.model.calculated.CalculatedEntity;
2927
import com.introproventures.graphql.jpa.query.schema.model.calculated.ParentCalculatedEntity;
3028
import com.introproventures.graphql.jpa.query.schema.model.metamodel.ClassWithCustomMetamodel;
3129

32-
@RunWith(SpringRunner.class)
33-
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.NONE)
34-
@TestPropertySource({"classpath:hibernate.properties"})
35-
public class EntityIntrospectorTest {
30+
@SpringBootTest
31+
public class EntityIntrospectorTest extends AbstractSpringBootTestSupport {
3632

3733
@SpringBootApplication
3834
static class Application {

graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/GraphQLEnumVariableBindingsTests.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,19 @@
2424

2525
import javax.persistence.EntityManager;
2626

27-
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
28-
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
2927
import org.junit.Test;
30-
import org.junit.runner.RunWith;
3128
import org.springframework.beans.factory.annotation.Autowired;
3229
import org.springframework.boot.autoconfigure.SpringBootApplication;
3330
import org.springframework.boot.test.context.SpringBootTest;
34-
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
3531
import org.springframework.context.annotation.Bean;
36-
import org.springframework.test.context.TestPropertySource;
37-
import org.springframework.test.context.junit4.SpringRunner;
32+
33+
import com.introproventures.graphql.jpa.query.AbstractSpringBootTestSupport;
34+
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
35+
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
3836

3937

40-
@RunWith(SpringRunner.class)
41-
@SpringBootTest(webEnvironment=WebEnvironment.NONE)
42-
@TestPropertySource({"classpath:hibernate.properties"})
43-
public class GraphQLEnumVariableBindingsTests {
38+
@SpringBootTest
39+
public class GraphQLEnumVariableBindingsTests extends AbstractSpringBootTestSupport {
4440

4541
@SpringBootApplication
4642
static class Application {

0 commit comments

Comments
 (0)