-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ControllerConstraintHandlerTest for JDK client (#9299)
This fixes the StreamTest and FilterErrorTest TCK tests that were failing in #9299 Closes #9223 Closes #9300
- Loading branch information
Showing
4 changed files
with
126 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
http-client-jdk/src/test/groovy/io/micronaut/http/client/jdk/RawStringHandlingSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package io.micronaut.http.client.jdk | ||
|
||
import io.micronaut.context.annotation.Property | ||
import io.micronaut.context.annotation.Requires | ||
import io.micronaut.http.annotation.Controller | ||
import io.micronaut.http.annotation.Get | ||
import io.micronaut.http.annotation.QueryValue | ||
import io.micronaut.http.client.annotation.Client | ||
import io.micronaut.test.extensions.spock.annotation.MicronautTest | ||
import jakarta.inject.Inject | ||
import spock.lang.Issue | ||
import spock.lang.Specification | ||
|
||
@MicronautTest | ||
@Property(name = "spec.name", value = "RawStringHandlingSpec") | ||
class RawStringHandlingSpec extends Specification { | ||
|
||
@Inject | ||
RawClient client | ||
|
||
@Issue("https://github.com/micronaut-projects/micronaut-core/issues/9223") | ||
void "test raw return type handling"() { | ||
when: | ||
def result = client.string() | ||
|
||
then: | ||
result.get() == "Hello World" | ||
|
||
when: | ||
result = client.noString() | ||
|
||
then: | ||
result.empty | ||
|
||
when: | ||
result = client.optional('present') | ||
|
||
then: | ||
result.get() == "Hello World" | ||
|
||
when: | ||
result = client.optional('absent') | ||
|
||
then: | ||
result.empty | ||
} | ||
|
||
@Controller("/raw") | ||
@Requires(property = "spec.name", value = "RawStringHandlingSpec") | ||
static class RawController { | ||
|
||
@Get(value = "/string") | ||
String string() { | ||
"Hello World" | ||
} | ||
|
||
@Get(value = "/no-string") | ||
String noString() { | ||
null | ||
} | ||
|
||
@Get(value = "/optional") | ||
Optional<String> optional(@QueryValue String name) { | ||
if (name == 'present') { | ||
return Optional.of("Hello World") | ||
} else { | ||
return Optional.empty() | ||
} | ||
} | ||
} | ||
|
||
@Client("/") | ||
@Requires(property = "spec.name", value = "RawStringHandlingSpec") | ||
static interface RawClient { | ||
|
||
@Get("/raw/string") | ||
Optional<String> string() | ||
|
||
@Get("/raw/no-string") | ||
Optional<String> noString() | ||
|
||
@Get("/raw/optional") | ||
Optional<String> optional(@QueryValue String name) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters