Skip to content

Commit 048f89a

Browse files
authored
Merge pull request #1497 from WebFuzzing/named-examples
named examples handling
2 parents c51be54 + ffdfa2a commit 048f89a

42 files changed

Lines changed: 793 additions & 145 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core-tests/e2e-tests/spring/emb-json/src/test/java/org/evomaster/e2etests/emb/json/genome/GenomeNexusExampleEMTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void runEMTest() throws Throwable {
2424
runTestHandlingFlakyAndCompilation(
2525
"GenomeNexusExampleGeneratedEMTest",
2626
"org.bar.GenomeNexusExampleGeneratedEMTest",
27-
500,
27+
2000,
2828
true,
2929
(args) -> {
3030
Solution<RestIndividual> solution = initAndRun(args);

core-tests/e2e-tests/spring/emb-json/src/test/java/org/evomaster/e2etests/emb/json/proxyprint/ProxyPrintExampleEMTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void runEMTest() throws Throwable {
2424
runTestHandlingFlakyAndCompilation(
2525
"ProxyPrintExampleGeneratedEMTest",
2626
"org.foo.ProxyPrintExampleGeneratedEMTest",
27-
5_000,
27+
7_000,
2828
true,
2929
(args) -> {
3030
setOption(args, "taintForceSelectionOfGenesWithSpecialization", "true");
@@ -34,7 +34,7 @@ public void runEMTest() throws Throwable {
3434

3535
assertHasAtLeastOne(solution, HttpVerb.POST, 200, "/api/json", "Printing");
3636
},
37-
3
37+
6
3838
);
3939
}
4040
}

core-tests/e2e-tests/spring/spring-rest-mongo/src/test/java/org/evomaster/e2etests/spring/rest/mongo/findoneby/MongoFindOneByEMTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public void testFindOneOnGivenEndpoint(String endpoint) throws Throwable {
5454
assertFalse(solution.getIndividuals().isEmpty());
5555
assertHasAtLeastOne(solution, HttpVerb.GET, 400, endpoint, null);
5656
assertHasAtLeastOne(solution, HttpVerb.GET, 200, endpoint, null);
57-
});
57+
},
58+
6);
5859
}
5960
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.foo.rest.examples.spring.openapi.v3.namedexample
2+
3+
import org.springframework.boot.SpringApplication
4+
import org.springframework.boot.autoconfigure.SpringBootApplication
5+
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
6+
import org.springframework.http.ResponseEntity
7+
import org.springframework.web.bind.annotation.GetMapping
8+
import org.springframework.web.bind.annotation.PostMapping
9+
import org.springframework.web.bind.annotation.RequestBody
10+
import org.springframework.web.bind.annotation.RequestMapping
11+
import org.springframework.web.bind.annotation.RequestParam
12+
import org.springframework.web.bind.annotation.RestController
13+
import javax.ws.rs.QueryParam
14+
15+
@SpringBootApplication(exclude = [SecurityAutoConfiguration::class])
16+
@RequestMapping(path = ["/api/namedexample"])
17+
@RestController
18+
open class NamedExampleApplication {
19+
20+
21+
companion object {
22+
@JvmStatic
23+
fun main(args: Array<String>) {
24+
SpringApplication.run(NamedExampleApplication::class.java, *args)
25+
}
26+
}
27+
28+
29+
@PostMapping
30+
open fun post(
31+
@QueryParam("q0") q0: String?,
32+
@QueryParam("q1") q1: String?,
33+
@QueryParam("q2") q2: String?,
34+
@QueryParam("q3") q3: String?,
35+
@QueryParam("q4") q4: String?,
36+
@RequestBody dto: NamedExampleDto
37+
) : ResponseEntity<String> {
38+
39+
//on purpose do nothing with input... should still be selected in test suites due to BB coverage
40+
41+
return ResponseEntity.ok("OK")
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.foo.rest.examples.spring.openapi.v3.namedexample
2+
3+
class NamedExampleDto {
4+
5+
var data : String? = null
6+
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
openapi: 3.1.0
2+
info:
3+
title: OpenAPI definition
4+
version: v0
5+
servers:
6+
- url: http://localhost:8080
7+
description: Generated server url
8+
paths:
9+
/api/namedexample:
10+
post:
11+
tags:
12+
- named-example-application
13+
operationId: post
14+
parameters:
15+
- name: q0
16+
in: query
17+
required: false
18+
schema:
19+
type: string
20+
examples:
21+
foo:
22+
value: "fooq0"
23+
- name: q1
24+
in: query
25+
required: false
26+
schema:
27+
type: string
28+
examples:
29+
foo:
30+
value: "fooq1"
31+
a0:
32+
value: "X"
33+
a1:
34+
value: "X"
35+
a2:
36+
value: "X"
37+
a3:
38+
value: "X"
39+
a4:
40+
value: "X"
41+
a5:
42+
value: "X"
43+
a6:
44+
value: "X"
45+
a7:
46+
value: "X"
47+
a8:
48+
value: "X"
49+
a9:
50+
value: "X"
51+
- name: q2
52+
in: query
53+
required: false
54+
schema:
55+
type: string
56+
examples:
57+
foo:
58+
value: "fooq2"
59+
b0:
60+
value: "X"
61+
b1:
62+
value: "X"
63+
b2:
64+
value: "X"
65+
b3:
66+
value: "X"
67+
b4:
68+
value: "X"
69+
b5:
70+
value: "X"
71+
b6:
72+
value: "X"
73+
b7:
74+
value: "X"
75+
b8:
76+
value: "X"
77+
b9:
78+
value: "X"
79+
- name: q3
80+
in: query
81+
required: false
82+
schema:
83+
type: string
84+
examples:
85+
foo:
86+
value: "fooq3"
87+
c0:
88+
value: "X"
89+
c1:
90+
value: "X"
91+
c2:
92+
value: "X"
93+
c3:
94+
value: "X"
95+
c4:
96+
value: "X"
97+
c5:
98+
value: "X"
99+
c6:
100+
value: "X"
101+
c7:
102+
value: "X"
103+
c8:
104+
value: "X"
105+
c9:
106+
value: "X"
107+
- name: q4
108+
in: query
109+
required: false
110+
schema:
111+
type: string
112+
examples:
113+
foo:
114+
value: "fooq4"
115+
a0:
116+
value: "X"
117+
a1:
118+
value: "X"
119+
requestBody:
120+
required: true
121+
content:
122+
application/json:
123+
schema:
124+
$ref: '#/components/schemas/NamedExampleDto'
125+
examples:
126+
foo:
127+
value:
128+
data: "fooBody"
129+
responses:
130+
'200':
131+
description: OK
132+
content:
133+
'*/*':
134+
schema:
135+
type: string
136+
components:
137+
schemas:
138+
NamedExampleDto:
139+
type: object
140+
properties:
141+
data:
142+
type: string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.foo.rest.examples.spring.openapi.v3.namedexample
2+
3+
import com.foo.rest.examples.spring.openapi.v3.SpringController
4+
import org.evomaster.client.java.controller.problem.ProblemInfo
5+
import org.evomaster.client.java.controller.problem.RestProblem
6+
7+
class NamedExampleController : SpringController(NamedExampleApplication::class.java){
8+
9+
10+
override fun getProblemInfo(): ProblemInfo {
11+
return RestProblem(
12+
"http://localhost:$sutPort/openapi-named-example.yaml",
13+
null
14+
)
15+
}
16+
}

core-tests/e2e-tests/spring/spring-rest-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/gson/mapdouble/MapDoubleGsonEMTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class MapDoubleGsonEMTest : SpringTestBase() {
2121
fun basicEMTest() {
2222
runTestHandlingFlakyAndCompilation(
2323
"MapDoubleGsonEMTestGenerated",
24-
1_000
24+
2_000
2525
) { args: List<String> ->
2626

2727
setOption(args, "taintForceSelectionOfGenesWithSpecialization", "true")

core-tests/e2e-tests/spring/spring-rest-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/jackson/mapdouble/MapDoubleJacksonEMTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class MapDoubleJacksonEMTest : SpringTestBase() {
2121
fun basicEMTest() {
2222
runTestHandlingFlakyAndCompilation(
2323
"MapDoubleJacksonEM",
24-
1000
24+
2000
2525
) { args: List<String> ->
2626

2727
setOption(args, "taintForceSelectionOfGenesWithSpecialization", "true")

core-tests/e2e-tests/spring/spring-rest-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/jackson/maplistint/MapListIntJacksonEMTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class MapListIntJacksonEMTest : SpringTestBase() {
2121
fun basicEMTest() {
2222
runTestHandlingFlakyAndCompilation(
2323
"MapListIntJacksonEM",
24-
2000
24+
3000
2525
) { args: List<String> ->
2626

2727
setOption(args, "taintForceSelectionOfGenesWithSpecialization", "true")

0 commit comments

Comments
 (0)