Skip to content

Commit

Permalink
Merge pull request quarkusio#4474 from aureamunoz/compiler-options-sp…
Browse files Browse the repository at this point in the history
…ring-it

test: add spring-web integration test with @PathVariable without configuration
  • Loading branch information
geoand authored Oct 29, 2019
2 parents 11602b0 + bad1edc commit d171c19
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bom/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2421,7 +2421,7 @@
</exclusion>
</exclusions>
</dependency>

<!-- Keycloak -->
<dependency>
<groupId>org.keycloak</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,6 @@ private void validate(Collection<AnnotationInstance> restControllerInstances) {
if (pathVariableInstance.target().kind() != AnnotationTarget.Kind.METHOD_PARAMETER) {
continue;
}
if ((pathVariableInstance.value() == null) && (pathVariableInstance.value("name") == null)) {
MethodInfo method = pathVariableInstance.target().asMethodParameter().method();
throw new IllegalArgumentException(
"Currently method parameters annotated with @PathVariable must supply a value for 'name' or 'value'."
+
"Offending method is " + method.declaringClass().name() + "#" + method.name());
}

}
}
}
Expand Down
6 changes: 6 additions & 0 deletions integration-tests/spring-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<parameters>true</parameters>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
Expand All @@ -20,8 +21,8 @@ public GreetingController(GreetingService greetingService) {
}

@GetMapping(path = "/json/{message}")
public Greeting greet(@PathVariable(name = "message") String message) {
return greetingService.greet(message);
public Greeting greet(@PathVariable String message, @RequestParam String suffix) {
return greetingService.greet(message + suffix);
}

@PostMapping(path = "/person")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ public void testJsonResult() {
.body(containsString("hello"));
}

@Test
public void testJsonResult2() {
RestAssured.when().get("/greeting/json/hello?suffix=000").then()
.contentType("application/json")
.body(containsString("hello000"));
}

@Test
public void testInvalidJsonInputAndResult() {
RestAssured.given().contentType("application/json").body("{\"name\":\"\"}").post("/greeting/person").then()
Expand Down

0 comments on commit d171c19

Please sign in to comment.