File tree Expand file tree Collapse file tree 7 files changed +84
-0
lines changed
okhttp4-spring-boot-starter
src/test/java/io/freefair/okhttp/starter4
okhttp5-spring-boot-starter
src/test/java/io/freefair/okhttp/starter5 Expand file tree Collapse file tree 7 files changed +84
-0
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,6 @@ subprojects { Project starterProject ->
6
6
attributes ' Spring-Boot-Jar-Type' : ' dependencies-starter'
7
7
}
8
8
}
9
+
10
+ test. useJUnitPlatform()
9
11
}
Original file line number Diff line number Diff line change @@ -10,4 +10,6 @@ dependencies {
10
10
api project(' :okhttp-spring-boot-autoconfigure' )
11
11
api project(' :okhttp-spring-client' )
12
12
api ' com.squareup.okhttp3:okhttp'
13
+
14
+ testImplementation ' org.springframework.boot:spring-boot-starter-test'
13
15
}
Original file line number Diff line number Diff line change
1
+ package io .freefair .okhttp .starter4 ;
2
+
3
+ import okhttp3 .OkHttpClient ;
4
+ import org .junit .jupiter .api .Test ;
5
+ import org .springframework .beans .factory .annotation .Autowired ;
6
+ import org .springframework .boot .test .context .SpringBootTest ;
7
+ import org .springframework .boot .test .context .assertj .AssertableApplicationContext ;
8
+ import org .springframework .context .ConfigurableApplicationContext ;
9
+
10
+ import static org .assertj .core .api .Assertions .assertThat ;
11
+
12
+ @ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .NONE )
13
+ public class OkHttp4Test {
14
+
15
+ @ Autowired
16
+ private ConfigurableApplicationContext applicationContext ;
17
+
18
+ @ Test
19
+ void contextLoads () {
20
+ assertThat (applicationContext ).isNotNull ();
21
+ }
22
+
23
+ @ Test
24
+ void hasClientBean () {
25
+ AssertableApplicationContext context = AssertableApplicationContext .get (() -> applicationContext );
26
+
27
+ assertThat (context ).hasSingleBean (OkHttpClient .class );
28
+ OkHttpClient okHttpClient = context .getBean (OkHttpClient .class );
29
+
30
+ assertThat (okHttpClient ).isNotNull ();
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ package io .freefair .okhttp .starter4 ;
2
+
3
+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
4
+
5
+ @ SpringBootApplication
6
+ public class OkHttp4TestApplication {
7
+ }
Original file line number Diff line number Diff line change @@ -11,4 +11,6 @@ dependencies {
11
11
api project(' :okhttp-spring-boot-autoconfigure' )
12
12
api project(' :okhttp-spring-client' )
13
13
api ' com.squareup.okhttp3:okhttp'
14
+
15
+ testImplementation ' org.springframework.boot:spring-boot-starter-test'
14
16
}
Original file line number Diff line number Diff line change
1
+ package io .freefair .okhttp .starter5 ;
2
+
3
+ import okhttp3 .OkHttpClient ;
4
+ import org .junit .jupiter .api .Test ;
5
+ import org .springframework .beans .factory .annotation .Autowired ;
6
+ import org .springframework .boot .test .context .SpringBootTest ;
7
+ import org .springframework .boot .test .context .assertj .AssertableApplicationContext ;
8
+ import org .springframework .context .ConfigurableApplicationContext ;
9
+
10
+ import static org .assertj .core .api .Assertions .assertThat ;
11
+
12
+ @ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .NONE )
13
+ public class OkHttp5Test {
14
+
15
+ @ Autowired
16
+ private ConfigurableApplicationContext applicationContext ;
17
+
18
+ @ Test
19
+ void contextLoads () {
20
+ assertThat (applicationContext ).isNotNull ();
21
+ }
22
+
23
+ @ Test
24
+ void hasClientBean () {
25
+ AssertableApplicationContext context = AssertableApplicationContext .get (() -> applicationContext );
26
+
27
+ assertThat (context ).hasSingleBean (OkHttpClient .class );
28
+ OkHttpClient okHttpClient = context .getBean (OkHttpClient .class );
29
+
30
+ assertThat (okHttpClient ).isNotNull ();
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ package io .freefair .okhttp .starter5 ;
2
+
3
+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
4
+
5
+ @ SpringBootApplication
6
+ public class OkHttp5TestApplication {
7
+ }
You can’t perform that action at this time.
0 commit comments