aswinad commented on code in PR #79:
URL: 
https://github.com/apache/sling-org-apache-sling-engine/pull/79#discussion_r3456884888


##########
src/test/java/org/apache/sling/engine/impl/RequestProcessorMBeanImplTest.java:
##########
@@ -132,58 +132,64 @@ public void test_statistics() throws 
NotCompliantMBeanException {
         // is reinitialized
         bean.resetStatistics();
 
-        // Simulate a single request
-        final long durationValue = min + random.nextInt(max - min);
-        final int callCountValue = min + random.nextInt(max - min);
-        final int peakRecursionDepthValue = min + random.nextInt(max - min);
+        final RequestData firstRequestDataAfterReset = 
Mockito.mock(RequestData.class, "firstRequestDataAfterReset");
+        
Mockito.when(firstRequestDataAfterReset.getElapsedTimeMsec()).thenReturn(100L);
+        
Mockito.when(firstRequestDataAfterReset.getServletCallCount()).thenReturn(10);
+        
Mockito.when(firstRequestDataAfterReset.getPeakRecusionDepth()).thenReturn(5);
 
-        final RequestData requestData = Mockito.mock(RequestData.class, 
"requestDataAfterReset");
-        
Mockito.when(requestData.getElapsedTimeMsec()).thenReturn(durationValue);
-        
Mockito.when(requestData.getServletCallCount()).thenReturn(callCountValue);
-        
Mockito.when(requestData.getPeakRecusionDepth()).thenReturn(peakRecursionDepthValue);
+        final RequestData secondRequestDataAfterReset = 
Mockito.mock(RequestData.class, "secondRequestDataAfterReset");
+        
Mockito.when(secondRequestDataAfterReset.getElapsedTimeMsec()).thenReturn(200L);
+        
Mockito.when(secondRequestDataAfterReset.getServletCallCount()).thenReturn(20);
+        
Mockito.when(secondRequestDataAfterReset.getPeakRecusionDepth()).thenReturn(15);
 
-        bean.addRequestData(requestData);
+        bean.addRequestData(firstRequestDataAfterReset);
 
-        // As only one request has been simulated since resetStatiscts: min, 
max and mean statistics should be equals to
-        // the request data
         assertEquals("After resetStatistics Number of requests must be one", 
1, bean.getRequestsCount());
-        assertEquals("After resetStatistics Min Duration must be equal", 
bean.getMinRequestDurationMsec(), (long)
-                durationValue);
-        assertEquals("After resetStatistics Max Duration must be equal", 
bean.getMaxRequestDurationMsec(), (long)
-                durationValue);
+        assertEquals("After resetStatistics Min Duration must be equal", 100L, 
bean.getMinRequestDurationMsec());
+        assertEquals("After resetStatistics Max Duration must be equal", 100L, 
bean.getMaxRequestDurationMsec());
+        assertEquals("After resetStatistics Mean Duration must be equal", 
100.0, bean.getMeanRequestDurationMsec(), 0d);
         assertEquals(
-                "After resetStatistics Mean Duration must be equal",

Review Comment:
   Good point, thanks. I meant this as an additional check, not as a 
replacement for the existing mean-duration assertion. I’ve updated the test to 
keep the single-request mean assertion and add the standard-deviation check 
alongside it.



-- 
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