File tree 6 files changed +44
-10
lines changed
.github/actions/integration-test
java/de/turing85/spring/fileupload
6 files changed +44
-10
lines changed Original file line number Diff line number Diff line change 72
72
--batch-mode \
73
73
--color always \
74
74
--define ci \
75
- failsafe:integration-test failsafe:verify \
75
+ failsafe:integration-test@e2e-test failsafe:verify@e2e-test \
76
76
|| return_code="${?}"
77
77
78
78
echo "Stopping Application"
Original file line number Diff line number Diff line change 33
33
<maven .compiler.release>17</maven .compiler.release>
34
34
<project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
35
35
<project .reporting.outputEncoding>UTF-8</project .reporting.outputEncoding>
36
+ <run-e2e-test >false</run-e2e-test >
36
37
37
38
<!-- Dependency versions -->
38
39
<lombok .version>1.18.28</lombok .version>
52
53
<version >${surefire-plugin.version} </version >
53
54
<executions >
54
55
<execution >
56
+ <id >e2e-test</id >
55
57
<goals >
56
58
<goal >integration-test</goal >
57
59
<goal >verify</goal >
58
60
</goals >
59
- <phase >verify</phase >
61
+ <phase >none</phase >
62
+ <configuration >
63
+ <argLine >-Dspring.profiles.active=e2e</argLine >
64
+ <includes >
65
+ <include >**/*CucumberTest.java</include >
66
+ </includes >
67
+ </configuration >
60
68
</execution >
61
69
</executions >
62
70
</plugin >
63
71
<plugin >
64
72
<artifactId >maven-surefire-plugin</artifactId >
65
73
<version >${surefire-plugin.version} </version >
74
+ <executions >
75
+ <execution >
76
+ <id >default-test</id >
77
+ <configuration >
78
+ <argLine >-Dspring.profiles.active=test</argLine >
79
+ </configuration >
80
+ </execution >
81
+ </executions >
66
82
</plugin >
67
83
<plugin >
68
84
<groupId >net.revelc.code.formatter</groupId >
Original file line number Diff line number Diff line change 10
10
@ SelectClasspathResource ("de/turing85/spring/fileupload" )
11
11
@ CucumberContextConfiguration
12
12
@ ContextConfiguration (classes = FileUploadApplication .class )
13
- @ SpringBootTest
14
- class FileUploadIT {
13
+ @ SpringBootTest ( webEnvironment = SpringBootTest . WebEnvironment . RANDOM_PORT )
14
+ class FileUploadCucumberTest {
15
15
}
Original file line number Diff line number Diff line change 1
1
package de .turing85 .spring .fileupload ;
2
2
3
+ import java .net .URI ;
4
+
5
+ import de .turing85 .spring .fileupload .actor .FileUploadActor ;
6
+ import io .cucumber .spring .ScenarioScope ;
7
+ import org .springframework .beans .factory .annotation .Value ;
3
8
import org .springframework .boot .autoconfigure .SpringBootApplication ;
9
+ import org .springframework .boot .test .web .server .LocalServerPort ;
10
+ import org .springframework .context .annotation .Bean ;
11
+ import org .springframework .context .annotation .Profile ;
4
12
5
13
@ SpringBootApplication
6
14
class TestApplication {
15
+ @ Bean
16
+ @ ScenarioScope
17
+ @ Profile ("test" )
18
+ static FileUploadActor testActor (
19
+ @ SuppressWarnings ("SpringJavaInjectionPointsAutowiringInspection" )
20
+ @ LocalServerPort int port ) {
21
+ return new FileUploadActor (URI .create ("http://localhost:%d" .formatted (port )));
22
+ }
23
+
24
+ @ Bean
25
+ @ ScenarioScope
26
+ @ Profile ("e2e" )
27
+ static FileUploadActor e2eActor (@ Value ("${sut.url}" ) URI sutUrl ) {
28
+ return new FileUploadActor (sutUrl );
29
+ }
7
30
}
Original file line number Diff line number Diff line change 8
8
9
9
import com .google .common .truth .Truth ;
10
10
import de .turing85 .spring .fileupload .UploadResource ;
11
- import io .cucumber .spring .ScenarioScope ;
12
11
import org .apache .http .client .methods .CloseableHttpResponse ;
13
12
import org .apache .http .client .methods .HttpPost ;
14
13
import org .apache .http .entity .ContentType ;
15
14
import org .apache .http .entity .mime .MultipartEntityBuilder ;
16
15
import org .apache .http .impl .client .CloseableHttpClient ;
17
16
import org .apache .http .impl .client .HttpClients ;
18
- import org .springframework .beans .factory .annotation .Value ;
19
17
import org .springframework .http .HttpStatus ;
20
- import org .springframework .stereotype .Component ;
21
18
22
- @ Component
23
- @ ScenarioScope
24
19
public class FileUploadActor {
25
20
private static final Random RANDOM = new Random ();
26
21
private static final int EXPECTED_SIZE_NOT_SET = -1 ;
@@ -32,7 +27,7 @@ public class FileUploadActor {
32
27
private CloseableHttpClient client ;
33
28
private CloseableHttpResponse response ;
34
29
35
- public FileUploadActor (@ Value ( "${sut.url}" ) URI sutUrl ) {
30
+ public FileUploadActor (URI sutUrl ) {
36
31
this .sutUrl = sutUrl ;
37
32
}
38
33
File renamed without changes.
You can’t perform that action at this time.
0 commit comments