swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API

Home Page:http://swagger.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mvn test: Failed to resolve 'FakeType' into class, java.lang.AssertionError: expected ... found ..

patsw-jpm opened this issue · comments

Branch v.2.2.20 mvn test throws errors here

19:08:28.211 [main] ERROR i.s.v3.core.util.ReflectionUtils - Failed to resolve 'FakeType' into class java.lang.ClassNotFoundException: FakeType at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at io.swagger.v3.core.util.ReflectionUtils.loadClassByName(ReflectionUtils.java:53) at io.swagger.v3.core.util.ReflectionUtils.typeFromString(ReflectionUtils.java:35) at io.swagger.v3.core.util.reflection.ReflectionUtilsTest.typeFromStringTest(ReflectionUtilsTest.java:38)

19:08:28.216 [main] ERROR i.s.v3.core.util.ReflectionUtils - Failed to resolve 'null' into class java.lang.NullPointerException: null at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:383) at java.base/java.lang.Class.forName(Class.java:376) at io.swagger.v3.core.util.ReflectionUtils.loadClassByName(ReflectionUtils.java:51) at io.swagger.v3.core.util.ReflectionUtils.typeFromString(ReflectionUtils.java:35) at io.swagger.v3.core.util.reflection.ReflectionUtilsTest.typeFromStringTest(ReflectionUtilsTest.java:39) Tests run: 429, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 6.922 sec <<< FAILURE!

testBooleanAdditionalPropertiesSerialization(io.swagger.v3.core.serialization.OpenAPI3_1SerializationTest) Time elapsed: 0.014 sec <<< FAILURE!
java.lang.AssertionError: expected [openapi: 3.1.0
components:
schemas:
test:
type: object
additionalProperties: true
] but found [openapi: 3.1.0
components:
schemas:
test:
type: object
additionalProperties: true
]
at org.testng.Assert.fail(Assert.java:111)
at org.testng.Assert.failNotEquals(Assert.java:1578)
at org.testng.Assert.assertEqualsImpl(Assert.java:150)
at org.testng.Assert.assertEquals(Assert.java:132)
at org.testng.Assert.assertEquals(Assert.java:656)
at org.testng.Assert.assertEquals(Assert.java:666) io.swagger.v3.core.serialization.OpenAPI3_1SerializationTest.testBooleanAdditionalPropertiesSerialization(OpenAPI3_1SerializationTest.java:1471)'

Results :
Failed tests: testBooleanAdditionalPropertiesSerialization(io.swagger.v3.core.serialization.OpenAPI3_1SerializationTes(..)expected [openapi: 3.1.0
Tests run: 429, Failures: 1, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for swagger-project 2.2.20:
[INFO]
[INFO] swagger-project .................................... SUCCESS [ 0.205 s]
[INFO] swagger-annotations ................................ SUCCESS [ 1.834 s]
[INFO] swagger-models ..................................... SUCCESS [ 4.175 s]
[INFO] swagger-core ....................................... FAILURE [ 10.747 s]

Since this is the stable release, what I am doing wrong in the initial build?

The Failed to resolve 'FakeType' into class is not a test failure/error but an error log during test (updated to warn in #4596).

We can not reproduce your failed test testBooleanAdditionalPropertiesSerialization, can you detail which command, java and maven version you are using when building, along with any significant details?

building with java 11+ with command ./mvnw clean install works fine

The command was ./mvnw clean install and these versions:
java -version
java version "21.0.1" 2023-10-17 LTS
mvn -v
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: C:\apache-maven-3.8.4 Java version: 18, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-18 Default locale: en_US, platform encoding: UTF-8 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
When I reverted to Java version 11 the above error no longer appeared.
java -version
java version "11.0.21" 2023-10-17 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.21+9-LTS-193) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.21+9-LTS-193, mixed mode)

Thanks for details, reopening as issue is reproducible when building/testing with Java 21+. Issue is related to not ignored List newly introduces properties first and last in one test.