Skip to content

Commit

Permalink
Make testsuite/data a Quarkus app, include indexed classes from small…
Browse files Browse the repository at this point in the history
…rye#1096

Fixes smallrye#1098

Signed-off-by: Michael Edgar <michael@xlate.io>
  • Loading branch information
MikeEdgar committed Mar 15, 2023
1 parent 78a66af commit e5b88c9
Show file tree
Hide file tree
Showing 16 changed files with 336 additions and 22 deletions.
1 change: 1 addition & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-open-api-testsuite-data</artifactId>
<classifier>indexed</classifier>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ private static boolean isAssignableFrom(DotName subject, DotName object, ClassLo
Class<?> subjectKlazz = TypeUtil.getClass(subject, cl);
Class<?> objectKlazz = TypeUtil.getClass(object, cl);
return objectKlazz.isAssignableFrom(subjectKlazz);
} catch (@SuppressWarnings("unused") ClassNotFoundException nfe) {
} catch (@SuppressWarnings("unused") ClassNotFoundException | NoClassDefFoundError nfe) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ public static void assertJsonEquals(String entityName, String expectedResource,

public static void assertJsonEquals(String expectedResource, OpenAPI actual) throws JSONException, IOException {
URL resourceUrl = IndexScannerTestBase.class.getResource(expectedResource);
JSONAssert.assertEquals(loadResource(resourceUrl), OpenApiSerializer.serialize(actual, Format.JSON),
assertJsonEquals(resourceUrl, actual);
}

public static void assertJsonEquals(URL expectedResourceUrl, OpenAPI actual) throws JSONException, IOException {
JSONAssert.assertEquals(loadResource(expectedResourceUrl), OpenApiSerializer.serialize(actual, Format.JSON),
true);
}

Expand Down
8 changes: 7 additions & 1 deletion extension-jaxrs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,20 @@
<scope>test</scope>
</dependency>

<!-- Depend on core tests -->
<!-- Depend on core tests and testsuite data classes -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>smallrye-open-api-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-open-api-testsuite-data</artifactId>
<classifier>indexed</classifier>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.UUID;
import java.util.zip.GZIPInputStream;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
Expand Down Expand Up @@ -467,11 +466,12 @@ void testCsvProducesConsumesJakarta() throws IOException, JSONException {
/* *************************************************************************/
@Test
void testSyntheticClassesAndInterfacesIgnoredByDefault() throws IOException, JSONException {
String indexPath = "/io/smallrye/openapi/runtime/jandex-panache+reactive-client.idx.gz";
try (InputStream source = new GZIPInputStream(getClass().getResourceAsStream(indexPath))) {
try (InputStream source = getClass().getResourceAsStream("/smallrye-open-api-testsuite-data.idx")) {
IndexReader reader = new IndexReader(source);
Index i = reader.read();
OpenAPI result = OpenApiProcessor.bootstrap(emptyConfig(), i);
Index index = reader.read();
OpenAPI result = OpenApiProcessor.bootstrap(
dynamicConfig(OASConfig.SCAN_EXCLUDE_PACKAGES, "io.smallrye.openapi.testdata.kotlin"),
index);
printToConsole(result);
assertJsonEquals("ignore.synthetic-classes-interfaces.json", result);
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,40 @@
"title": "Generated API",
"version": "1.0"
},
"tags": [
{
"name": "PeopleResource"
}
],
"paths": {
"/people": {
"get": {
"tags": [
"PeopleResource"
],
"parameters": [
{
"name": "id",
"in": "query",
"schema": {
"format": "int64",
"type": "integer"
}
},
{
"name": "name",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "namedQuery",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "page",
"in": "query",
Expand All @@ -32,18 +62,31 @@
"schema": {
"type": "array",
"items": {

}
}
}
],
"responses": {
"200": {
"description": "OK"
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Person"
}
}
}
}
}
}
},
"post": {
"tags": [
"PeopleResource"
],
"requestBody": {
"content": {
"application/json": {
Expand All @@ -53,15 +96,44 @@
}
}
},
"responses": {
"201": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Person"
}
}
}
}
}
}
},
"/people/count": {
"get": {
"tags": [
"PeopleResource"
],
"responses": {
"200": {
"description": "OK"
"description": "OK",
"content": {
"application/json": {
"schema": {
"format": "int64",
"type": "integer"
}
}
}
}
}
}
},
"/people/{id}": {
"get": {
"tags": [
"PeopleResource"
],
"parameters": [
{
"name": "id",
Expand All @@ -75,11 +147,21 @@
],
"responses": {
"200": {
"description": "OK"
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Person"
}
}
}
}
}
},
"put": {
"tags": [
"PeopleResource"
],
"parameters": [
{
"name": "id",
Expand All @@ -101,12 +183,21 @@
}
},
"responses": {
"200": {
"description": "OK"
"201": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Person"
}
}
}
}
}
},
"delete": {
"tags": [
"PeopleResource"
],
"parameters": [
{
"name": "id",
Expand All @@ -119,8 +210,8 @@
}
],
"responses": {
"200": {
"description": "OK"
"204": {

}
}
}
Expand Down
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<!-- Use Jakarta EE 10 versions -->
<version.resteasy>6.2.3.Final</version.resteasy>
<version.weld.core>5.1.0.Final</version.weld.core>

<!-- Ignore the test data classes in test coverage calculation -->
<sonar.coverage.exclusions>testsuite/data/**/*.java</sonar.coverage.exclusions>
</properties>

<licenses>
Expand Down Expand Up @@ -240,7 +243,14 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>smallrye-open-api-testsuite-data</artifactId>
<classifier>indexed</classifier>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
Loading

0 comments on commit e5b88c9

Please sign in to comment.