You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In com.networknt.correlation.CorrelationHandlerTest, if testGetWithoutTid() is run after testGetWithoutTidNoAutogen(), we face the following issue
java.lang.AssertionError:
Expected :200
Actual :500
at org.junit.Assert.fail(Assert.java:89)
at org.junit.Assert.failNotEquals(Assert.java:835)
at org.junit.Assert.assertEquals(Assert.java:647)
at org.junit.Assert.assertEquals(Assert.java:633)
at com.networknt.correlation.CorrelationHandlerTest.test02_testGetWithoutTid(CorrelationHandlerTest.java:158)
Since JUnit 4 doesn't guarantee the order of test executions by default, JUnit could execute testGetWithoutTid() after testGetWithoutTidNoAutogen() resulting in the above error.
Root Cause
The test testGetWithoutTidNoAutogen() sets the autogenCorrelationID to false at
logger.info("Associate traceability Id " + tId + " with correlation Id " + cId);
}
Since the UUID is not generated and not set in the request handler, the request given from the test testGetWithoutTid() results in a 5xx server error
Proposed Solution
Resetting the CorrelationHandler.config to default value before each test run will ensure that the unit tests are run with the correct config value
This can be done by setting the configuration to its default value through CorrelationHandler.config.setAutogenCorrelationID(true); after the test testGetWithoutTidNoAutogen() is executed
The text was updated successfully, but these errors were encountered:
Issue
com.networknt.correlation.CorrelationHandlerTest
, iftestGetWithoutTid()
is run aftertestGetWithoutTidNoAutogen()
, we face the following issuetestGetWithoutTid()
aftertestGetWithoutTidNoAutogen()
resulting in the above error.Root Cause
testGetWithoutTidNoAutogen()
sets theautogenCorrelationID
tofalse
atlight-4j/correlation/src/test/java/com/networknt/correlation/CorrelationHandlerTest.java
Line 159 in 7152f18
testGetWithoutTid()
is run after the above step, the following code is not executed because of the pollutedautogenCorrelationID
light-4j/correlation/src/main/java/com/networknt/correlation/CorrelationHandler.java
Lines 68 to 75 in 7152f18
testGetWithoutTid()
results in a 5xx server errorProposed Solution
CorrelationHandler.config
to default value before each test run will ensure that the unit tests are run with the correct config valueCorrelationHandler.config.setAutogenCorrelationID(true);
after the testtestGetWithoutTidNoAutogen()
is executedThe text was updated successfully, but these errors were encountered: