Skip to content

Commit 5bc0abe

Browse files
authored
Merge pull request #129 from WebFuzzing/spring-batch-rest-drivers
Spring batch rest drivers
2 parents c7921d4 + 14684d5 commit 5bc0abe

File tree

18 files changed

+815
-3
lines changed

18 files changed

+815
-3
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,11 @@ scripts/dockerize/dockerfiles
330330
jdk_17_maven/cs/rest/ohsome-api/target/
331331
jdk_17_maven/em/embedded/rest/ohsome-api/target/
332332
jdk_17_maven/em/external/rest/ohsome-api/target/
333+
334+
jdk_8_maven/cs/rest/original/spring-batch-rest/api/target
335+
jdk_8_maven/cs/rest/original/spring-batch-rest/quartz-api/target
336+
jdk_8_maven/cs/rest/original/spring-batch-rest/util/target
337+
jdk_8_maven/cs/rest/original/spring-batch-rest/example/api/target
338+
jdk_8_maven/cs/rest/original/spring-batch-rest/example/quartz-api/target
339+
jdk_8_maven/em/embedded/rest/spring-batch-rest/target
340+
jdk_8_maven/em/external/rest/spring-batch-rest/target

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ For simplicity, all schemas are also available as JSON/YML files under the folde
7070
> **IMPORTANT**: More details (e.g., #LOCs and used databases) on these APIs can be found [in this table](statistics/table_emb.md).
7171
7272

73-
### REST: Java/Kotlin (26)
73+
### REST: Java/Kotlin (27)
7474

7575
* **Bibliothek** (MIT), [jdk_17_gradle/cs/rest/bibliothek](jdk_17_gradle/cs/rest/bibliothek), from [https://github.com/PaperMC/bibliothek](https://github.com/PaperMC/bibliothek)
7676

@@ -98,7 +98,7 @@ For simplicity, all schemas are also available as JSON/YML files under the folde
9898

9999
* **OCVN** (MIT), [jdk_8_maven/cs/rest-gui/ocvn](jdk_8_maven/cs/rest-gui/ocvn), from [https://github.com/devgateway/ocvn](https://github.com/devgateway/ocvn)
100100

101-
* **Ohsome API** (MIT), [jdk_17_maven/cs/rest/ohsome-api](jdk_17_maven/cs/rest/ohsome-api), from [https://github.com/GIScience/ohsome-api](https://github.com/GIScience/ohsome-api)
101+
* **Ohsome API** (AGPL-3.0), [jdk_17_maven/cs/rest/ohsome-api](jdk_17_maven/cs/rest/ohsome-api), from [https://github.com/GIScience/ohsome-api](https://github.com/GIScience/ohsome-api)
102102

103103
* **Payments Public API** (MIT), [jdk_11_maven/cs/rest/pay-publicapi](jdk_11_maven/cs/rest/pay-publicapi), from [https://github.com/alphagov/pay-publicapi](https://github.com/alphagov/pay-publicapi)
104104

@@ -118,6 +118,8 @@ For simplicity, all schemas are also available as JSON/YML files under the folde
118118

119119
* **Session Service** (not-known license), [jdk_8_maven/cs/rest/original/session-service](jdk_8_maven/cs/rest/original/session-service), from [https://github.com/cBioPortal/session-service](https://github.com/cBioPortal/session-service)
120120

121+
* **Spring-batch-rest** (Apache), [jdk_8_maven/cs/rest/original/spring-batch-rest](jdk_8_maven/cs/rest/original/spring-batch-rest), from [https://github.com/chrisgleissner/spring-batch-rest](https://github.com/chrisgleissner/spring-batch-rest)
122+
121123
* **Tiltaksgjennomføring API** (MIT), [jdk_17_maven/cs/rest/tiltaksgjennomforing-api](jdk_17_maven/cs/rest/tiltaksgjennomforing-api), from [https://github.com/navikt/tiltaksgjennomforing-api](https://github.com/navikt/tiltaksgjennomforing-api)
122124

123125
* **User Management** (MIT), [jdk_8_maven/cs/rest/original/user-management](jdk_8_maven/cs/rest/original/user-management), from [https://github.com/andreagiassi/microservice-rbac-user-management](https://github.com/andreagiassi/microservice-rbac-user-management)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM amazoncorretto:8-alpine-jdk
2+
3+
COPY ./dist/spring-batch-rest-sut.jar .
4+
COPY ./dist/jacocoagent.jar .
5+
6+
7+
8+
#ENV TOOL="undefined"
9+
#ENV RUN="0"
10+
11+
ENTRYPOINT \
12+
java \
13+
# unfortunately dumponexit is completely unreliable in Docker :(
14+
# -javaagent:jacocoagent.jar=destfile=./jacoco/spring-batch-rest__${TOOL}__${RUN}__jacoco.exec,append=false,dumponexit=true \
15+
-javaagent:jacocoagent.jar=output=tcpserver,address=*,port=6300,append=false,dumponexit=false \
16+
-jar spring-batch-rest-sut.jar \
17+
--server.port=8080 --spring.batch.job.enabled=false --lastNamePrefix= --upperCase=false

dockerfiles/spring-batch-rest.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
sut-spring-batch-rest:
3+
build:
4+
dockerfile: ./dockerfiles/spring-batch-rest.dockerfile
5+
context: ..
6+
# environment:
7+
# TOOL: ${TOOL:-undefined}
8+
# RUN: ${RUN:-0}
9+
ports:
10+
- "${HOST_PORT:-8080}:8080"
11+
- "${JACOCO_PORT:-6300}:6300"
12+
# volumes:
13+
# default env does not work on volumes
14+
# - ${JACOCODIR}:/jacoco
15+

jdk_8_maven/cs/rest/original/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<module>youtube-mock</module>
2424
<module>user-management</module>
2525
<module>blogapi</module>
26+
<module>spring-batch-rest</module>
2627
</modules>
2728

2829

jdk_8_maven/cs/rest/original/spring-batch-rest/example/api/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
</goals>
6666
<configuration>
6767
<attach>false</attach>
68+
<!-- Modified -->
69+
<finalName>spring-batch-rest</finalName>
70+
<classifier>sut</classifier>
71+
<!-- Modified -->
6872
</configuration>
6973
</execution>
7074
</executions>

jdk_8_maven/cs/rest/original/spring-batch-rest/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<groupId>org.springframework.boot</groupId>
88
<artifactId>spring-boot-starter-parent</artifactId>
99
<version>2.2.7.RELEASE</version>
10+
<relativePath/>
1011
</parent>
1112

1213
<groupId>com.github.chrisgleissner</groupId>

jdk_8_maven/em/embedded/rest/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<module>youtube-mock</module>
3030
<module>user-management</module>
3131
<module>blogapi</module>
32+
<module>spring-batch-rest</module>
3233
</modules>
3334

3435
</project>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<artifactId>evomaster-benchmark-em-embedded-rest-spring-batch-rest</artifactId>
8+
<packaging>jar</packaging>
9+
10+
<parent>
11+
<groupId>org.evomaster</groupId>
12+
<artifactId>evomaster-benchmark-em-embedded-rest</artifactId>
13+
<version>3.4.1-SNAPSHOT</version>
14+
</parent>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>com.github.chrisgleissner</groupId>
19+
<artifactId>spring-batch-rest-example-core</artifactId>
20+
<version>1.5.2-SNAPSHOT</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.eclipse.jetty</groupId>
24+
<artifactId>jetty-server</artifactId>
25+
<version>9.4.52.v20230823</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.evomaster</groupId>
29+
<artifactId>evomaster-client-java-controller</artifactId>
30+
<version>3.4.1-SNAPSHOT</version>
31+
<exclusions>
32+
<exclusion>
33+
<groupId>javax.validation</groupId>
34+
<artifactId>validation-api</artifactId>
35+
</exclusion>
36+
</exclusions>
37+
</dependency>
38+
<dependency>
39+
<groupId>javax.validation</groupId>
40+
<artifactId>validation-api</artifactId>
41+
<version>2.0.1.Final</version>
42+
</dependency>
43+
</dependencies>
44+
45+
46+
</project>
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package em.embedded.spring.batch.rest;
2+
3+
import org.evomaster.client.java.controller.EmbeddedSutController;
4+
import org.evomaster.client.java.controller.InstrumentedSutStarter;
5+
import org.evomaster.client.java.sql.DbSpecification;
6+
7+
8+
import org.evomaster.client.java.controller.problem.ProblemInfo;
9+
import org.evomaster.client.java.controller.problem.RestProblem;
10+
import org.evomaster.client.java.controller.api.dto.auth.AuthenticationDto;
11+
import org.evomaster.client.java.controller.api.dto.SutInfoDto;
12+
import com.github.chrisgleissner.springbatchrest.example.core.SpringBatchRestCoreSampleApplication;
13+
14+
import org.springframework.boot.SpringApplication;
15+
import org.springframework.context.ConfigurableApplicationContext;
16+
17+
import java.util.List;
18+
import java.util.Map;
19+
20+
/**
21+
* Class used to start/stop the SUT. This will be controller by the EvoMaster process
22+
*/
23+
public class EmbeddedEvoMasterController extends EmbeddedSutController {
24+
25+
public static void main(String[] args) {
26+
27+
int port = 40100;
28+
if (args.length > 0) {
29+
port = Integer.parseInt(args[0]);
30+
}
31+
32+
EmbeddedEvoMasterController controller = new EmbeddedEvoMasterController(port);
33+
InstrumentedSutStarter starter = new InstrumentedSutStarter(controller);
34+
35+
starter.start();
36+
}
37+
38+
39+
private ConfigurableApplicationContext ctx;
40+
41+
42+
public EmbeddedEvoMasterController() {
43+
this(40100);
44+
}
45+
46+
public EmbeddedEvoMasterController(int port) {
47+
setControllerPort(port);
48+
}
49+
50+
@Override
51+
public String startSut() {
52+
ctx = SpringApplication.run(SpringBatchRestCoreSampleApplication.class, new String[]{
53+
"--server.port=0",
54+
"--spring.batch.job.enabled=false",
55+
"--lastNamePrefix=",
56+
"--upperCase=false"
57+
});
58+
59+
60+
return "http://localhost:" + getSutPort();
61+
}
62+
63+
protected int getSutPort() {
64+
return (Integer) ((Map) ctx.getEnvironment()
65+
.getPropertySources().get("server.ports").getSource())
66+
.get("local.server.port");
67+
}
68+
69+
70+
@Override
71+
public boolean isSutRunning() {
72+
return ctx != null && ctx.isRunning();
73+
}
74+
75+
@Override
76+
public void stopSut() {
77+
ctx.stop();
78+
}
79+
80+
@Override
81+
public String getPackagePrefixesToCover() {
82+
return "com.github.chrisgleissner.";
83+
}
84+
85+
@Override
86+
public void resetStateOfSUT() {
87+
}
88+
89+
@Override
90+
public List<AuthenticationDto> getInfoForAuthentication() {
91+
return null;
92+
}
93+
94+
95+
@Override
96+
public ProblemInfo getProblemInfo() {
97+
return new RestProblem(
98+
"http://localhost:" + getSutPort() + "/v3/api-docs",
99+
null
100+
);
101+
}
102+
103+
@Override
104+
public SutInfoDto.OutputFormat getPreferredOutputFormat() {
105+
return SutInfoDto.OutputFormat.JAVA_JUNIT_4;
106+
}
107+
108+
@Override
109+
public List<DbSpecification> getDbSpecifications() {
110+
return null;
111+
}
112+
113+
}

0 commit comments

Comments
 (0)