Skip to content

Commit

Permalink
Fix the issue of failing few UTs due to delay in response
Browse files Browse the repository at this point in the history
  • Loading branch information
IshikaDawda committed Sep 25, 2023
1 parent 911143f commit 44f489a
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.newrelic.agent.security.instrumentation.jetty12.test;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.newrelic.agent.security.introspec.InstrumentationTestConfig;
import com.newrelic.agent.security.introspec.SecurityInstrumentationTestRunner;
import com.newrelic.agent.security.introspec.SecurityIntrospector;
Expand Down Expand Up @@ -65,7 +64,7 @@ public void testHandle() throws Exception {

List<AbstractOperation> operations = introspector.getOperations();
Assert.assertTrue("No operations detected", operations.size() > 0);
System.out.println(new ObjectMapper().writeValueAsString(operations));

RXSSOperation operation = (RXSSOperation) operations.get(0);

Assert.assertEquals("Invalid event category.", VulnerabilityCaseType.REFLECTED_XSS, operation.getCaseType());
Expand Down Expand Up @@ -310,6 +309,7 @@ private void serviceWithoutHeaders() throws Exception {
conn.connect();

System.out.println(conn.getResponseCode());
waitForProcessing();
}

@Trace(dispatcher = true)
Expand All @@ -325,6 +325,7 @@ private String serviceWithHeaders() throws Exception {
conn.connect();

conn.getResponseCode();
waitForProcessing();
return headerValue;
}

Expand All @@ -335,4 +336,12 @@ private static int getRandomPort() {
throw new RuntimeException("Unable to allocate ephemeral port ");
}
}

private static void waitForProcessing() {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}

0 comments on commit 44f489a

Please sign in to comment.