This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new 0a42991a25 Tidy openapi-java tests after removal of support for 
OpenAPI V2
0a42991a25 is described below

commit 0a42991a25b7f0dc374638489a4d90c26d183b7b
Author: James Netherton <[email protected]>
AuthorDate: Fri Apr 12 08:05:49 2024 +0100

    Tidy openapi-java tests after removal of support for OpenAPI V2
---
 integration-tests/openapi-java/pom.xml             |   6 -
 .../component/openapijava/it/OpenApiRoutes.java    | 260 ++++++++++-----------
 .../openapijava/it/common/OpenApiTest.java         | 215 -----------------
 .../component/openapijava/it/v3/OpenApiV3IT.java   |   2 -
 .../component/openapijava/it/v3/OpenApiV3Test.java | 189 ++++++++++++++-
 .../openapijava/it/v3/OpenApiV3TestProfile.java    |  30 ---
 6 files changed, 309 insertions(+), 393 deletions(-)

diff --git a/integration-tests/openapi-java/pom.xml 
b/integration-tests/openapi-java/pom.xml
index 3da74cb849..cac13bb1d7 100644
--- a/integration-tests/openapi-java/pom.xml
+++ b/integration-tests/openapi-java/pom.xml
@@ -96,16 +96,10 @@
                         <artifactId>maven-failsafe-plugin</artifactId>
                         <executions>
                             <execution>
-                                <id>profile-openapi-v3</id>
                                 <goals>
                                     <goal>integration-test</goal>
                                     <goal>verify</goal>
                                 </goals>
-                                <configuration>
-                                    <systemPropertyVariables>
-                                        <test.profile>openapi.v3</test.profile>
-                                    </systemPropertyVariables>
-                                </configuration>
                             </execution>
                         </executions>
                     </plugin>
diff --git 
a/integration-tests/openapi-java/src/main/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiRoutes.java
 
b/integration-tests/openapi-java/src/main/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiRoutes.java
index e89d8554df..f6b587cf18 100644
--- 
a/integration-tests/openapi-java/src/main/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiRoutes.java
+++ 
b/integration-tests/openapi-java/src/main/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiRoutes.java
@@ -30,14 +30,10 @@ import 
org.apache.camel.quarkus.component.openapijava.it.model.AllOfFormWrapper;
 import 
org.apache.camel.quarkus.component.openapijava.it.model.AnyOfFormWrapper;
 import org.apache.camel.quarkus.component.openapijava.it.model.Fruit;
 import 
org.apache.camel.quarkus.component.openapijava.it.model.OneOfFormWrapper;
-import org.eclipse.microprofile.config.inject.ConfigProperty;
 
 @ApplicationScoped
 public class OpenApiRoutes extends RouteBuilder {
 
-    @ConfigProperty(name = "openapi.version")
-    String openApiVersion;
-
     @Override
     public void configure() throws Exception {
 
@@ -49,7 +45,7 @@ public class OpenApiRoutes extends RouteBuilder {
                 .apiProperty("api.title", "Camel Quarkus API")
                 .apiProperty("api.description", "The Awesome Camel Quarkus 
REST API")
                 .apiProperty("api.version", "1.2.3")
-                .apiProperty("openapi.version", openApiVersion)
+                .apiProperty("openapi.version", "3.0.0")
                 .apiProperty("cors", "true")
                 .apiProperty("schemes", "http,https")
                 .apiProperty("api.path", "/api-docs")
@@ -134,146 +130,144 @@ public class OpenApiRoutes extends RouteBuilder {
                 .end()
                 .end();
 
-        if (openApiVersion.startsWith("3")) {
-            rest()
-                    .get("/security/bearer/token")
-                    .to("seda:echoMethodPath")
-                    .securityDefinitions()
-                    .bearerToken("bearerAuth", "Bearer Token Authentication")
-                    .end()
+        rest()
+                .get("/security/bearer/token")
+                .to("seda:echoMethodPath")
+                .securityDefinitions()
+                .bearerToken("bearerAuth", "Bearer Token Authentication")
+                .end()
 
-                    .get("/security/mutual/tls")
-                    .to("seda:echoMethodPath")
-                    .securityDefinitions()
-                    .mutualTLS("mutualTLS")
-                    .end()
+                .get("/security/mutual/tls")
+                .to("seda:echoMethodPath")
+                .securityDefinitions()
+                .mutualTLS("mutualTLS")
+                .end()
 
-                    .get("/security/openid")
-                    .to("seda:echoMethodPath")
-                    .securityDefinitions()
-                    .openIdConnect("openId", 
"https://secure.apache.org/fake/openid-configuration";)
-                    .end()
+                .get("/security/openid")
+                .to("seda:echoMethodPath")
+                .securityDefinitions()
+                .openIdConnect("openId", 
"https://secure.apache.org/fake/openid-configuration";)
+                .end()
 
-                    .get("/api/operation/spec/array/params")
-                    .param()
-                    .name("string_array")
-                    .dataType("array")
-                    .arrayType("string")
-                    .allowableValues("A", "B", "C")
-                    .endParam()
-                    .param()
-                    .name("int_array")
-                    .dataType("array")
-                    .arrayType("int")
-                    .allowableValues("1", "2", "3")
-                    .endParam()
-                    .param()
-                    .name("integer_array")
-                    .dataType("array")
-                    .arrayType("integer")
-                    .allowableValues("1", "2", "3")
-                    .endParam()
-                    .param()
-                    .name("long_array")
-                    .dataType("array")
-                    .arrayType("long")
-                    .allowableValues("1", "2", "3")
-                    .endParam()
-                    .param()
-                    .name("float_array")
-                    .dataType("array")
-                    .arrayType("float")
-                    .allowableValues("1.0", "2.0", "3.0")
-                    .endParam()
-                    .param()
-                    .name("double_array")
-                    .dataType("array")
-                    .arrayType("double")
-                    .allowableValues("1.0", "2.0", "3.0")
-                    .endParam()
-                    .param()
-                    .name("boolean_array")
-                    .dataType("array")
-                    .arrayType("boolean")
-                    .allowableValues("true", "false")
-                    .endParam()
-                    .param()
-                    .name("byte_array")
-                    .dataType("array")
-                    .arrayType("byte")
-                    .allowableValues("1", "2", "3")
-                    .endParam()
-                    .param()
-                    .name("binary_array")
-                    .dataType("array")
-                    .arrayType("binary")
-                    .allowableValues("1", "2", "3")
-                    .endParam()
-                    .param()
-                    .name("date_array")
-                    .dataType("array")
-                    .arrayType("date")
-                    .allowableValues("2023-01-01", "2023-02-02", "2023-03-03")
-                    .endParam()
-                    .param()
-                    .name("datetime_array")
-                    .dataType("array")
-                    .arrayType("date-time")
-                    .allowableValues("2023-01-01T11:11:11+01:00", 
"2023-02-02T12:12:12+01:00", "2023-03-03T13:13:13+01:00")
-                    .endParam()
-                    .param()
-                    .name("password_array")
-                    .dataType("array")
-                    .arrayType("password")
-                    .allowableValues("foo", "bar", "cheese")
-                    .endParam()
-                    .to("seda:echoMethodPath");
+                .get("/api/operation/spec/array/params")
+                .param()
+                .name("string_array")
+                .dataType("array")
+                .arrayType("string")
+                .allowableValues("A", "B", "C")
+                .endParam()
+                .param()
+                .name("int_array")
+                .dataType("array")
+                .arrayType("int")
+                .allowableValues("1", "2", "3")
+                .endParam()
+                .param()
+                .name("integer_array")
+                .dataType("array")
+                .arrayType("integer")
+                .allowableValues("1", "2", "3")
+                .endParam()
+                .param()
+                .name("long_array")
+                .dataType("array")
+                .arrayType("long")
+                .allowableValues("1", "2", "3")
+                .endParam()
+                .param()
+                .name("float_array")
+                .dataType("array")
+                .arrayType("float")
+                .allowableValues("1.0", "2.0", "3.0")
+                .endParam()
+                .param()
+                .name("double_array")
+                .dataType("array")
+                .arrayType("double")
+                .allowableValues("1.0", "2.0", "3.0")
+                .endParam()
+                .param()
+                .name("boolean_array")
+                .dataType("array")
+                .arrayType("boolean")
+                .allowableValues("true", "false")
+                .endParam()
+                .param()
+                .name("byte_array")
+                .dataType("array")
+                .arrayType("byte")
+                .allowableValues("1", "2", "3")
+                .endParam()
+                .param()
+                .name("binary_array")
+                .dataType("array")
+                .arrayType("binary")
+                .allowableValues("1", "2", "3")
+                .endParam()
+                .param()
+                .name("date_array")
+                .dataType("array")
+                .arrayType("date")
+                .allowableValues("2023-01-01", "2023-02-02", "2023-03-03")
+                .endParam()
+                .param()
+                .name("datetime_array")
+                .dataType("array")
+                .arrayType("date-time")
+                .allowableValues("2023-01-01T11:11:11+01:00", 
"2023-02-02T12:12:12+01:00", "2023-03-03T13:13:13+01:00")
+                .endParam()
+                .param()
+                .name("password_array")
+                .dataType("array")
+                .arrayType("password")
+                .allowableValues("foo", "bar", "cheese")
+                .endParam()
+                .to("seda:echoMethodPath");
 
-            rest("/form")
-                    .post("/oneOf")
-                    .tag("OneOf")
-                    .bindingMode(RestBindingMode.json)
-                    .description("OneOf rest service")
+        rest("/form")
+                .post("/oneOf")
+                .tag("OneOf")
+                .bindingMode(RestBindingMode.json)
+                .description("OneOf rest service")
 
-                    .consumes("application/json")
-                    .produces("application/json")
-                    .type(OneOfFormWrapper.class)
-                    .responseMessage()
-                    .code(200).message("Ok")
-                    .endResponseMessage()
+                .consumes("application/json")
+                .produces("application/json")
+                .type(OneOfFormWrapper.class)
+                .responseMessage()
+                .code(200).message("Ok")
+                .endResponseMessage()
 
-                    .to("seda:res");
+                .to("seda:res");
 
-            rest("/form")
-                    .post("/allOf")
-                    .tag("AllOf")
-                    .bindingMode(RestBindingMode.json)
-                    .description("AllOf rest service")
+        rest("/form")
+                .post("/allOf")
+                .tag("AllOf")
+                .bindingMode(RestBindingMode.json)
+                .description("AllOf rest service")
 
-                    .consumes("application/json")
-                    .produces("application/json")
-                    .type(AllOfFormWrapper.class)
-                    .responseMessage()
-                    .code(200).message("Ok")
-                    .endResponseMessage()
+                .consumes("application/json")
+                .produces("application/json")
+                .type(AllOfFormWrapper.class)
+                .responseMessage()
+                .code(200).message("Ok")
+                .endResponseMessage()
 
-                    .to("seda:res");
+                .to("seda:res");
 
-            rest("/form")
-                    .post("/anyOf")
-                    .tag("AnyOf")
-                    .bindingMode(RestBindingMode.json)
-                    .description("AnyOf rest service")
+        rest("/form")
+                .post("/anyOf")
+                .tag("AnyOf")
+                .bindingMode(RestBindingMode.json)
+                .description("AnyOf rest service")
 
-                    .consumes("application/json")
-                    .produces("application/json")
-                    .type(AnyOfFormWrapper.class)
-                    .responseMessage()
-                    .code(200).message("Ok")
-                    .endResponseMessage()
+                .consumes("application/json")
+                .produces("application/json")
+                .type(AnyOfFormWrapper.class)
+                .responseMessage()
+                .code(200).message("Ok")
+                .endResponseMessage()
 
-                    .to("seda:res");
-        }
+                .to("seda:res");
 
         from("direct:fruits")
                 .setBody().constant(getFruits())
diff --git 
a/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/common/OpenApiTest.java
 
b/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/common/OpenApiTest.java
deleted file mode 100644
index 42d3c268e8..0000000000
--- 
a/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/common/OpenApiTest.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- *
- *      http://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 org.apache.camel.quarkus.component.openapijava.it.common;
-
-import io.restassured.RestAssured;
-import io.restassured.http.ContentType;
-import org.apache.camel.quarkus.component.openapijava.it.OpenApiContentType;
-import org.apache.camel.quarkus.component.openapijava.it.YamlToJsonFilter;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.EnumSource;
-
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.hasKey;
-import static org.hamcrest.Matchers.is;
-
-/**
- * Tests common to both OpenAPI 2.x & 3.x
- */
-public abstract class OpenApiTest {
-
-    @BeforeAll
-    public static void beforeAll() {
-        RestAssured.filters(new YamlToJsonFilter());
-    }
-
-    @Test
-    public void invokeApiEndpoint() {
-        RestAssured.given()
-                .queryParam("port", RestAssured.port)
-                .get("/api/fruits/list")
-                .then()
-                .contentType(ContentType.JSON)
-                .statusCode(200)
-                .body(
-                        "description", containsInAnyOrder("Winter fruit", 
"Tropical fruit"),
-                        "name", containsInAnyOrder("Apple", "Pineapple"));
-    }
-
-    @ParameterizedTest
-    @EnumSource(OpenApiContentType.class)
-    public void invokeApiDocumentEndpoint(OpenApiContentType contentType) {
-        RestAssured
-                .given()
-                .header("Accept", contentType.getMimeType())
-                .get("/openapi")
-                .then()
-                .contentType(ContentType.JSON)
-                .statusCode(200)
-                .body(
-                        "paths.'/api/fruits/list'", hasKey("get"),
-                        "paths.'/api/fruits/list'.get.summary", is("Gets a 
list of fruits"),
-                        "paths.'/api/fruits/list'.get.operationId", 
is("list"));
-    }
-
-    @ParameterizedTest
-    @EnumSource(OpenApiContentType.class)
-    public void openApiEndpointSecurity(OpenApiContentType contentType) {
-        RestAssured.given()
-                .header("Accept", contentType.getMimeType())
-                .get("/openapi")
-                .then()
-                .contentType(ContentType.JSON)
-                .statusCode(200)
-                .body(
-                        "paths.'/api/security/scopes'", hasKey("get"),
-                        "paths.'/api/security/scopes'.get.security[0].OAuth2", 
contains("scope1", "scope2", "scope3"));
-
-    }
-
-    @ParameterizedTest
-    @EnumSource(OpenApiContentType.class)
-    public void openApiKeySecurityDefinition(OpenApiContentType contentType) {
-        RestAssured.given()
-                .header("Accept", contentType.getMimeType())
-                .get("/openapi")
-                .then()
-                .contentType(ContentType.JSON)
-                .statusCode(200)
-                .body(
-                        "components.securitySchemes", hasKey("X-API-Key"),
-                        "components.securitySchemes.X-API-Key.type", 
is("apiKey"),
-                        "components.securitySchemes.X-API-Key.description", 
is("The API key"),
-                        "components.securitySchemes.X-API-Key.name", 
is("X-API-KEY"),
-                        "components.securitySchemes.X-API-Key.in", 
is("header"));
-
-    }
-
-    @ParameterizedTest
-    @EnumSource(OpenApiContentType.class)
-    public void openApiBasicAuthSecurityDefinition(OpenApiContentType 
contentType) {
-        RestAssured.given()
-                .header("Accept", contentType.getMimeType())
-                .get("/openapi")
-                .then()
-                .contentType(ContentType.JSON)
-                .statusCode(200)
-                .body(
-                        "components.securitySchemes", hasKey("basicAuth"),
-                        "components.securitySchemes.basicAuth.scheme", 
is("basic"),
-                        "components.securitySchemes.basicAuth.type", 
is("http"),
-                        "components.securitySchemes.basicAuth.description", 
is("Basic Authentication"));
-
-    }
-
-    @ParameterizedTest
-    @EnumSource(OpenApiContentType.class)
-    public void openApiOauth2SecurityDefinition(OpenApiContentType 
contentType) {
-        RestAssured.given()
-                .header("Accept", contentType.getMimeType())
-                .get("/openapi")
-                .then()
-                .contentType(ContentType.JSON)
-                .statusCode(200)
-                .body(
-                        "components.securitySchemes", hasKey("oauth2"),
-                        
"components.securitySchemes.oauth2.flows.implicit.authorizationUrl",
-                        is("https://secure.apache.org/fake/oauth2/authorize";),
-                        
"components.securitySchemes.oauth2.flows.implicit.scopes.scope1", is("Scope 1"),
-                        
"components.securitySchemes.oauth2.flows.implicit.scopes.scope2", is("Scope 2"),
-                        
"components.securitySchemes.oauth2.flows.implicit.scopes.scope3", is("Scope 
3"));
-    }
-
-    @ParameterizedTest
-    @EnumSource(OpenApiContentType.class)
-    public void openApiOperationSpecification(OpenApiContentType contentType) {
-        RestAssured.given()
-                .header("Accept", contentType.getMimeType())
-                .get("/openapi")
-                .then()
-                .contentType(ContentType.JSON)
-                .statusCode(200)
-                .body(
-                        "paths.'/api/operation/spec'", hasKey("get"),
-                        "paths.'/api/operation/spec'.get.parameters[0].name", 
is("header_number"),
-                        
"paths.'/api/operation/spec'.get.parameters[0].description", is("Header Param 
Number"),
-                        
"paths.'/api/operation/spec'.get.parameters[0].schema.default", is("1"),
-                        
"paths.'/api/operation/spec'.get.parameters[0].schema.enum", contains("1", "2", 
"3"),
-                        "paths.'/api/operation/spec'.get.parameters[0].in", 
is("header"),
-                        
"paths.'/api/operation/spec'.get.parameters[0].required", is(true),
-                        "paths.'/api/operation/spec'.get.parameters[1].name", 
is("query_letter"),
-                        
"paths.'/api/operation/spec'.get.parameters[1].description", is("Query Param 
Letter"),
-                        
"paths.'/api/operation/spec'.get.parameters[1].schema.default", is("B"),
-                        
"paths.'/api/operation/spec'.get.parameters[1].schema.enum", contains("A", "B", 
"C"),
-                        "paths.'/api/operation/spec'.get.parameters[1].in", 
is("query"),
-                        
"paths.'/api/operation/spec'.get.parameters[1].required", is(false),
-                        
"paths.'/api/operation/spec'.get.responses.418.headers.rate.description", 
is("API Rate Limit"),
-                        
"paths.'/api/operation/spec'.get.responses.418.description", is("I am a 
teapot"),
-                        
"paths.'/api/operation/spec'.get.responses.error.description", is("Response 
Error"));
-    }
-
-    @ParameterizedTest
-    @EnumSource(OpenApiContentType.class)
-    public void openApiInfoSpecification(OpenApiContentType contentType) {
-        RestAssured.given()
-                .header("Accept", contentType.getMimeType())
-                .get("/openapi")
-                .then()
-                .contentType(ContentType.JSON)
-                .statusCode(200)
-                .body(
-                        "info.title", is("Camel Quarkus API"),
-                        "info.version", is("1.2.3"),
-                        "info.description", is("The Awesome Camel Quarkus REST 
API"),
-                        "info.termsOfService", is("https://camel.apache.org";),
-                        "info.contact.name", is("Mr Camel Quarkus"),
-                        "info.contact.url", is("https://camel.apache.org";),
-                        "info.contact.email", is("[email protected]"),
-                        "info.license.name", is("Apache V2"),
-                        "info.license.url", 
is("https://www.apache.org/licenses/LICENSE-2.0";));
-    }
-
-    @ParameterizedTest
-    @EnumSource(OpenApiContentType.class)
-    public void openApiVendorExtensions(OpenApiContentType contentType) {
-        RestAssured.given()
-                .header("Accept", contentType.getMimeType())
-                .get("/openapi")
-                .then()
-                .contentType(ContentType.JSON)
-                .statusCode(200)
-                .body(containsString("x-camelContextId"));
-    }
-
-    @Test
-    public void testCORSHeaders() {
-        RestAssured.given()
-                .get("/openapi")
-                .then()
-                .contentType(ContentType.JSON)
-                .statusCode(200)
-                .header("Access-Control-Allow-Headers", is(
-                        "Origin, Accept, X-Requested-With, Content-Type, 
Access-Control-Request-Method, Access-Control-Request-Headers"))
-                .header("Access-Control-Allow-Methods", is("GET, HEAD, POST, 
PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH"))
-                .header("Access-Control-Allow-Origin", is("*"))
-                .header("Access-Control-Max-Age", is("3600"));
-    }
-}
diff --git 
a/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/v3/OpenApiV3IT.java
 
b/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/v3/OpenApiV3IT.java
index 8533b01272..c4c5c52b8f 100644
--- 
a/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/v3/OpenApiV3IT.java
+++ 
b/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/v3/OpenApiV3IT.java
@@ -17,9 +17,7 @@
 package org.apache.camel.quarkus.component.openapijava.it.v3;
 
 import io.quarkus.test.junit.QuarkusIntegrationTest;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
 
 @QuarkusIntegrationTest
-@EnabledIfSystemProperty(named = "test.profile", matches = "openapi.v3")
 class OpenApiV3IT extends OpenApiV3Test {
 }
diff --git 
a/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/v3/OpenApiV3Test.java
 
b/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/v3/OpenApiV3Test.java
index b7b4e6323e..e0c0d19be4 100644
--- 
a/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/v3/OpenApiV3Test.java
+++ 
b/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/v3/OpenApiV3Test.java
@@ -17,25 +17,200 @@
 package org.apache.camel.quarkus.component.openapijava.it.v3;
 
 import io.quarkus.test.junit.QuarkusTest;
-import io.quarkus.test.junit.TestProfile;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
 import org.apache.camel.quarkus.component.openapijava.it.OpenApiContentType;
-import org.apache.camel.quarkus.component.openapijava.it.common.OpenApiTest;
+import org.apache.camel.quarkus.component.openapijava.it.YamlToJsonFilter;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.EnumSource;
 
 import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.hasKey;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.not;
 
-/**
- * Tests specific to OpenAPI 3.x
- */
 @QuarkusTest
-@TestProfile(OpenApiV3TestProfile.class)
-public class OpenApiV3Test extends OpenApiTest {
+public class OpenApiV3Test {
+    @BeforeAll
+    public static void beforeAll() {
+        RestAssured.filters(new YamlToJsonFilter());
+    }
+
+    @Test
+    public void invokeApiEndpoint() {
+        RestAssured.given()
+                .queryParam("port", RestAssured.port)
+                .get("/api/fruits/list")
+                .then()
+                .contentType(ContentType.JSON)
+                .statusCode(200)
+                .body(
+                        "description", containsInAnyOrder("Winter fruit", 
"Tropical fruit"),
+                        "name", containsInAnyOrder("Apple", "Pineapple"));
+    }
+
+    @ParameterizedTest
+    @EnumSource(OpenApiContentType.class)
+    public void invokeApiDocumentEndpoint(OpenApiContentType contentType) {
+        RestAssured
+                .given()
+                .header("Accept", contentType.getMimeType())
+                .get("/openapi")
+                .then()
+                .contentType(ContentType.JSON)
+                .statusCode(200)
+                .body(
+                        "paths.'/api/fruits/list'", hasKey("get"),
+                        "paths.'/api/fruits/list'.get.summary", is("Gets a 
list of fruits"),
+                        "paths.'/api/fruits/list'.get.operationId", 
is("list"));
+    }
+
+    @ParameterizedTest
+    @EnumSource(OpenApiContentType.class)
+    public void openApiEndpointSecurity(OpenApiContentType contentType) {
+        RestAssured.given()
+                .header("Accept", contentType.getMimeType())
+                .get("/openapi")
+                .then()
+                .contentType(ContentType.JSON)
+                .statusCode(200)
+                .body(
+                        "paths.'/api/security/scopes'", hasKey("get"),
+                        "paths.'/api/security/scopes'.get.security[0].OAuth2", 
contains("scope1", "scope2", "scope3"));
+
+    }
+
+    @ParameterizedTest
+    @EnumSource(OpenApiContentType.class)
+    public void openApiKeySecurityDefinition(OpenApiContentType contentType) {
+        RestAssured.given()
+                .header("Accept", contentType.getMimeType())
+                .get("/openapi")
+                .then()
+                .contentType(ContentType.JSON)
+                .statusCode(200)
+                .body(
+                        "components.securitySchemes", hasKey("X-API-Key"),
+                        "components.securitySchemes.X-API-Key.type", 
is("apiKey"),
+                        "components.securitySchemes.X-API-Key.description", 
is("The API key"),
+                        "components.securitySchemes.X-API-Key.name", 
is("X-API-KEY"),
+                        "components.securitySchemes.X-API-Key.in", 
is("header"));
+
+    }
+
+    @ParameterizedTest
+    @EnumSource(OpenApiContentType.class)
+    public void openApiBasicAuthSecurityDefinition(OpenApiContentType 
contentType) {
+        RestAssured.given()
+                .header("Accept", contentType.getMimeType())
+                .get("/openapi")
+                .then()
+                .contentType(ContentType.JSON)
+                .statusCode(200)
+                .body(
+                        "components.securitySchemes", hasKey("basicAuth"),
+                        "components.securitySchemes.basicAuth.scheme", 
is("basic"),
+                        "components.securitySchemes.basicAuth.type", 
is("http"),
+                        "components.securitySchemes.basicAuth.description", 
is("Basic Authentication"));
+
+    }
+
+    @ParameterizedTest
+    @EnumSource(OpenApiContentType.class)
+    public void openApiOauth2SecurityDefinition(OpenApiContentType 
contentType) {
+        RestAssured.given()
+                .header("Accept", contentType.getMimeType())
+                .get("/openapi")
+                .then()
+                .contentType(ContentType.JSON)
+                .statusCode(200)
+                .body(
+                        "components.securitySchemes", hasKey("oauth2"),
+                        
"components.securitySchemes.oauth2.flows.implicit.authorizationUrl",
+                        is("https://secure.apache.org/fake/oauth2/authorize";),
+                        
"components.securitySchemes.oauth2.flows.implicit.scopes.scope1", is("Scope 1"),
+                        
"components.securitySchemes.oauth2.flows.implicit.scopes.scope2", is("Scope 2"),
+                        
"components.securitySchemes.oauth2.flows.implicit.scopes.scope3", is("Scope 
3"));
+    }
+
+    @ParameterizedTest
+    @EnumSource(OpenApiContentType.class)
+    public void openApiOperationSpecification(OpenApiContentType contentType) {
+        RestAssured.given()
+                .header("Accept", contentType.getMimeType())
+                .get("/openapi")
+                .then()
+                .contentType(ContentType.JSON)
+                .statusCode(200)
+                .body(
+                        "paths.'/api/operation/spec'", hasKey("get"),
+                        "paths.'/api/operation/spec'.get.parameters[0].name", 
is("header_number"),
+                        
"paths.'/api/operation/spec'.get.parameters[0].description", is("Header Param 
Number"),
+                        
"paths.'/api/operation/spec'.get.parameters[0].schema.default", is("1"),
+                        
"paths.'/api/operation/spec'.get.parameters[0].schema.enum", contains("1", "2", 
"3"),
+                        "paths.'/api/operation/spec'.get.parameters[0].in", 
is("header"),
+                        
"paths.'/api/operation/spec'.get.parameters[0].required", is(true),
+                        "paths.'/api/operation/spec'.get.parameters[1].name", 
is("query_letter"),
+                        
"paths.'/api/operation/spec'.get.parameters[1].description", is("Query Param 
Letter"),
+                        
"paths.'/api/operation/spec'.get.parameters[1].schema.default", is("B"),
+                        
"paths.'/api/operation/spec'.get.parameters[1].schema.enum", contains("A", "B", 
"C"),
+                        "paths.'/api/operation/spec'.get.parameters[1].in", 
is("query"),
+                        
"paths.'/api/operation/spec'.get.parameters[1].required", is(false),
+                        
"paths.'/api/operation/spec'.get.responses.418.headers.rate.description", 
is("API Rate Limit"),
+                        
"paths.'/api/operation/spec'.get.responses.418.description", is("I am a 
teapot"),
+                        
"paths.'/api/operation/spec'.get.responses.error.description", is("Response 
Error"));
+    }
+
+    @ParameterizedTest
+    @EnumSource(OpenApiContentType.class)
+    public void openApiInfoSpecification(OpenApiContentType contentType) {
+        RestAssured.given()
+                .header("Accept", contentType.getMimeType())
+                .get("/openapi")
+                .then()
+                .contentType(ContentType.JSON)
+                .statusCode(200)
+                .body(
+                        "info.title", is("Camel Quarkus API"),
+                        "info.version", is("1.2.3"),
+                        "info.description", is("The Awesome Camel Quarkus REST 
API"),
+                        "info.termsOfService", is("https://camel.apache.org";),
+                        "info.contact.name", is("Mr Camel Quarkus"),
+                        "info.contact.url", is("https://camel.apache.org";),
+                        "info.contact.email", is("[email protected]"),
+                        "info.license.name", is("Apache V2"),
+                        "info.license.url", 
is("https://www.apache.org/licenses/LICENSE-2.0";));
+    }
+
+    @ParameterizedTest
+    @EnumSource(OpenApiContentType.class)
+    public void openApiVendorExtensions(OpenApiContentType contentType) {
+        RestAssured.given()
+                .header("Accept", contentType.getMimeType())
+                .get("/openapi")
+                .then()
+                .contentType(ContentType.JSON)
+                .statusCode(200)
+                .body(containsString("x-camelContextId"));
+    }
+
+    @Test
+    public void testCORSHeaders() {
+        RestAssured.given()
+                .get("/openapi")
+                .then()
+                .contentType(ContentType.JSON)
+                .statusCode(200)
+                .header("Access-Control-Allow-Headers", is(
+                        "Origin, Accept, X-Requested-With, Content-Type, 
Access-Control-Request-Method, Access-Control-Request-Headers"))
+                .header("Access-Control-Allow-Methods", is("GET, HEAD, POST, 
PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH"))
+                .header("Access-Control-Allow-Origin", is("*"))
+                .header("Access-Control-Max-Age", is("3600"));
+    }
 
     @ParameterizedTest
     @EnumSource(OpenApiContentType.class)
diff --git 
a/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/v3/OpenApiV3TestProfile.java
 
b/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/v3/OpenApiV3TestProfile.java
deleted file mode 100644
index e0c0f12d40..0000000000
--- 
a/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/v3/OpenApiV3TestProfile.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
- *
- *      http://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 org.apache.camel.quarkus.component.openapijava.it.v3;
-
-import java.util.Map;
-
-import io.quarkus.test.junit.QuarkusTestProfile;
-import org.apache.camel.util.CollectionHelper;
-
-public class OpenApiV3TestProfile implements QuarkusTestProfile {
-
-    @Override
-    public Map<String, String> getConfigOverrides() {
-        return CollectionHelper.mapOf("openapi.version", "3.0.0");
-    }
-}


Reply via email to