prathyushreddylpr opened a new pull request, #1542:
URL: https://github.com/apache/cxf/pull/1542

   ### Description
   Fixed the flaky test `extendedXmlJavaTypeAdapter` and 
`simpleXmlJavaTypeAdapter`  inside `JAXBUtilsTest.java` class. 
   
   
https://github.com/apache/cxf/blob/b608027f5f352affd3d2228ae4733b47049f2590/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXBUtilsTest.java#L38
   
   
https://github.com/apache/cxf/blob/b608027f5f352affd3d2228ae4733b47049f2590/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXBUtilsTest.java#L43
   
   #### Root Cause
   The tests `extendedXmlJavaTypeAdapter` and `simpleXmlJavaTypeAdapter` have 
been reported flaky when run with the 
[NonDex](https://github.com/TestingResearchIllinois/NonDex) tool. The tests 
failed due to the non-deterministic ordering of fields returned by 
getDeclaredFields(). The getDeclaredFields() method returns an array of Field 
objects representing all the fields declared by a class or interface. In the 
above tests, it returned two values: one a private field named birthDate of 
type `java.time.LocalDate` and the other 
`org.apache.cxf.jaxrs.utils.JAXBUtilsTest$CustomerDetailsWithExtendedAdapter.this$0`.
 The second value represents a synthetic field generated by the Java compiler 
for the inner class CustomerDetailsWithExtendedAdapter. When an inner class 
accesses members of its enclosing class, Java creates a synthetic field (in 
this case, this$0) as a reference to the outer class (JAXBUtilsTest) which is 
not useful for the test.
   
   #### Fix
   To ensure the tests are not flaky due to the non-deterministic ordering of 
fields returned by getDeclaredFields(), we introduced a condition to filter out 
the fields(synthetic and final fields) that are not useful for the testing.
   
   
   ### How this has been tested?
   
   **Java:** openjdk version "17.0.8"
   **Maven:** Apache Maven 3.6.3
   
   1) **Module build** - Successful
   Command used - 
   ```
   mvn install -pl core -am -DskipTests
   ```
   
   2) **Regular test**  - Successful
   Commands used - 
   
   ```
   mvn -pl rt/frontend/jaxrs/ 
-Dtest=org.apache.cxf.jaxrs.utils.JAXBUtilsTest#extendedXmlJavaTypeAdapter
   ```
   
   ```
   mvn -pl rt/frontend/jaxrs/ 
-Dtest=org.apache.cxf.jaxrs.utils.JAXBUtilsTest#simpleXmlJavaTypeAdapter
   ```
   
   3) **NonDex test**  - Failed
   Command used - 
   ```
   mvn -pl rt/frontend/jaxrs/ 
edu.illinois:nondex-maven-plugin:2.1.7-SNAPSHOT:nondex 
-Dtest=org.apache.cxf.jaxrs.utils.JAXBUtilsTest#extendedXmlJavaTypeAdapter
   ```
   
   ```
   mvn -pl rt/frontend/jaxrs/ 
edu.illinois:nondex-maven-plugin:2.1.7-SNAPSHOT:nondex 
-Dtest=org.apache.cxf.jaxrs.utils.JAXBUtilsTest#simpleXmlJavaTypeAdapter
   ```
   
   NonDex test passed after the fix.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to