Skip to content

Commit cee2185

Browse files
committed
Fix test issues
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
1 parent f0754eb commit cee2185

File tree

2 files changed

+18
-98
lines changed

2 files changed

+18
-98
lines changed

connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/StressTest.java

Lines changed: 0 additions & 87 deletions
This file was deleted.

tests/integration/jersey-4697/src/test/java/org/glassfish/jersey/tests/integration/jersey4697/MonitoringEventListenerTest.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,13 +16,17 @@
1616

1717
package org.glassfish.jersey.tests.integration.jersey4697;
1818

19-
import static org.mockito.Mockito.mock;
20-
import static org.mockito.Mockito.when;
19+
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.fail;
2121

2222
import java.lang.management.ManagementFactory;
23+
import java.lang.management.ThreadInfo;
24+
import java.lang.management.ThreadMXBean;
2325
import java.lang.reflect.Method;
26+
import java.util.Arrays;
2427
import java.util.Collection;
2528
import java.util.Map;
29+
import java.util.stream.Collectors;
2630

2731
import javax.inject.Inject;
2832
import javax.management.JMX;
@@ -48,11 +52,12 @@
4852
import org.glassfish.jersey.test.JerseyTest;
4953
import org.junit.Test;
5054

51-
import static org.junit.Assert.assertEquals;
55+
import static org.mockito.Mockito.mock;
56+
import static org.mockito.Mockito.when;
5257

5358
public class MonitoringEventListenerTest extends JerseyTest {
5459

55-
private static final long TIMEOUT = 500;
60+
private static final long TIMEOUT = 1000;
5661
private static final String MBEAN_EXCEPTION =
5762
"org.glassfish.jersey:type=MonitoringEventListenerTest,subType=Global,exceptions=ExceptionMapper";
5863

@@ -116,6 +121,7 @@ protected Application configure() {
116121
resourceConfig.property(ServerProperties.MONITORING_ENABLED, true);
117122
resourceConfig.property(ServerProperties.MONITORING_STATISTICS_ENABLED, true);
118123
resourceConfig.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true);
124+
// Scheduler will process 1000 events per second
119125
resourceConfig.property(ServerProperties.MONITORING_STATISTICS_REFRESH_INTERVAL, 1);
120126
resourceConfig.setApplicationName("MonitoringEventListenerTest");
121127
return resourceConfig;
@@ -126,17 +132,18 @@ public void exceptionInScheduler() throws Exception {
126132
final Long ERRORS_BEFORE_FAIL = 10L;
127133
// Send some requests to process some statistics.
128134
request(ERRORS_BEFORE_FAIL);
129-
// Give some time to the scheduler to collect data.
135+
// Give some time to process events
130136
Thread.sleep(TIMEOUT);
131-
// All events were consumed by scheduler
137+
// Verify the exceptionMapperEvents is empty, because no event of this type was sent yet
132138
queueIsEmpty();
133-
// Make the scheduler to fail. No more statistics are collected.
139+
// Sending one event that will make an internal error in the scheduler.
140+
// No new events will be pushed in the queues after this.
134141
makeFailure();
135-
// Sending again requests
142+
// Sending again requests. These events will not be processed, so they will not be counted for statistics.
136143
request(20);
144+
// The expectation is that the scheduler is not going to process previous events because there was a failure before.
145+
// We give some time before checking that no new errors are registered.
137146
Thread.sleep(TIMEOUT);
138-
// No new events should be accepted because scheduler is not working.
139-
queueIsEmpty();
140147
Long monitoredErrors = mappedErrorsFromJMX(MBEAN_EXCEPTION);
141148
assertEquals(ERRORS_BEFORE_FAIL, monitoredErrors);
142149
}

0 commit comments

Comments
 (0)