-
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.
- Loading branch information
Showing
35 changed files
with
805 additions
and
54 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
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
1 change: 1 addition & 0 deletions
1
...sources/META-INF/native-image/io.micronaut/micronaut-buffer-netty/native-image.properties
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 @@ | ||
Args = --features=io.micronaut.buffer.netty.NettyFeature |
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
1 change: 1 addition & 0 deletions
1
...resources/META-INF/native-image/io.micronaut/micronaut-http-netty/native-image.properties
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 @@ | ||
Args = --features=io.micronaut.http.netty.graal.HttpNettyFeature |
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
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
77 changes: 77 additions & 0 deletions
77
http-server-tck/src/main/java/io/micronaut/http/server/tck/tests/HeadersTest.java
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,77 @@ | ||
/* | ||
* Copyright 2017-2023 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.http.server.tck.tests; | ||
|
||
import io.micronaut.context.annotation.Requires; | ||
import io.micronaut.http.HttpRequest; | ||
import io.micronaut.http.HttpStatus; | ||
import io.micronaut.http.MediaType; | ||
import io.micronaut.http.annotation.Controller; | ||
import io.micronaut.http.annotation.Get; | ||
import io.micronaut.http.annotation.Header; | ||
import io.micronaut.http.server.tck.AssertionUtils; | ||
import io.micronaut.http.server.tck.HttpResponseAssertion; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static io.micronaut.http.server.tck.TestScenario.asserts; | ||
|
||
@SuppressWarnings({ | ||
"java:S5960", // We're allowed assertions, as these are used in tests only | ||
"checkstyle:MissingJavadocType", | ||
"checkstyle:DesignForExtension" | ||
}) | ||
public class HeadersTest { | ||
public static final String SPEC_NAME = "HeadersTest"; | ||
|
||
/** | ||
* Message header field names are case-insensitive | ||
* | ||
* @see <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2">HTTP/1.1 Message Headers</a> | ||
*/ | ||
@Test | ||
void headersAreCaseInsensitiveAsPerMessageHeadersSpecification() throws IOException { | ||
// standard header name with mixed case | ||
asserts(SPEC_NAME, | ||
HttpRequest.GET("/foo/ok").header("aCcEpT", MediaType.APPLICATION_JSON), | ||
(server, request) -> AssertionUtils.assertDoesNotThrow(server, request, HttpResponseAssertion.builder() | ||
.status(HttpStatus.OK) | ||
.body("{\"status\":\"ok\"}") | ||
.build())); | ||
// custom header name with mixed case | ||
asserts(SPEC_NAME, | ||
HttpRequest.GET("/foo/bar").header("fOO", "ok"), | ||
(server, request) -> AssertionUtils.assertDoesNotThrow(server, request, HttpResponseAssertion.builder() | ||
.status(HttpStatus.OK) | ||
.body("{\"status\":\"ok\"}") | ||
.build())); | ||
} | ||
|
||
@Controller("/foo") | ||
@Requires(property = "spec.name", value = SPEC_NAME) | ||
static class ProduceController { | ||
@Get(value = "/ok", produces = MediaType.APPLICATION_JSON) | ||
String getOkAsJson() { | ||
return "{\"status\":\"ok\"}"; | ||
} | ||
|
||
@Get(value = "/bar", produces = MediaType.APPLICATION_JSON) | ||
String getFooAsJson(@Header("Foo") String foo) { | ||
return "{\"status\":\"" + foo + "\"}"; | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...ver-tck/src/main/java/io/micronaut/http/server/tck/tests/endpoints/health/HealthTest.java
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,50 @@ | ||
/* | ||
* Copyright 2017-2023 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.http.server.tck.tests.endpoints.health; | ||
|
||
import io.micronaut.http.HttpRequest; | ||
import io.micronaut.http.HttpStatus; | ||
import io.micronaut.http.server.tck.AssertionUtils; | ||
import io.micronaut.http.server.tck.HttpResponseAssertion; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static io.micronaut.http.server.tck.TestScenario.asserts; | ||
|
||
@SuppressWarnings({ | ||
"java:S5960", // We're allowed assertions, as these are used in tests only | ||
"checkstyle:MissingJavadocType", | ||
"checkstyle:DesignForExtension" | ||
}) | ||
public class HealthTest { | ||
private static final String SPEC_NAME = "HealthTest"; | ||
|
||
/** | ||
* This test verifies health endpoint is exposed. The server under test needs to publish the {@link io.micronaut.discovery.event.ServiceReadyEvent} or {@link io.micronaut.runtime.server.event.ServerStartupEvent} for {@link io.micronaut.management.health.indicator.service.ServiceReadyHealthIndicator} to be UP. | ||
* @throws IOException Exception thrown while getting the server under test. | ||
*/ | ||
@Test | ||
public void healthEndpointExposed() throws IOException { | ||
// standard header name with mixed case | ||
asserts(SPEC_NAME, | ||
HttpRequest.GET("/health"), | ||
(server, request) -> AssertionUtils.assertDoesNotThrow(server, request, HttpResponseAssertion.builder() | ||
.status(HttpStatus.OK) | ||
.body("{\"status\":\"UP\"}") | ||
.build())); | ||
} | ||
} |
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
Oops, something went wrong.