File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
jmx-metrics/src/test/java/io/opentelemetry/contrib/jmxmetrics Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 88import static io .opentelemetry .sdk .testing .assertj .MetricAssertions .assertThat ;
99import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .attributeEntry ;
1010import static java .lang .management .ManagementFactory .getPlatformMBeanServer ;
11+ import static java .util .concurrent .TimeUnit .SECONDS ;
1112
1213import groovy .lang .Closure ;
1314import groovy .util .Eval ;
3839import org .junit .jupiter .api .DisplayName ;
3940import org .junit .jupiter .api .Nested ;
4041import org .junit .jupiter .api .Test ;
42+ import org .junit .jupiter .api .Timeout ;
4143import org .junit .jupiter .params .ParameterizedTest ;
4244import org .junit .jupiter .params .provider .CsvSource ;
4345import org .junit .jupiter .params .provider .ValueSource ;
4446
47+ @ Timeout (value = 10 , unit = SECONDS )
4548class InstrumenterHelperTest {
4649
4750 private static final MBeanServer mbeanServer = getPlatformMBeanServer ();
@@ -78,6 +81,11 @@ static void tearDown() throws Exception {
7881 jmxServer .stop ();
7982 }
8083
84+ @ BeforeEach
85+ void confirmServerIsActive () {
86+ assertThat (jmxServer .isActive ()).isTrue ();
87+ }
88+
8189 @ BeforeEach
8290 void setupOtel () {
8391 metricReader = InMemoryMetricReader .create ();
Original file line number Diff line number Diff line change 66package io .opentelemetry .contrib .jmxmetrics ;
77
88import static java .lang .management .ManagementFactory .getPlatformMBeanServer ;
9+ import static java .util .concurrent .TimeUnit .SECONDS ;
910import static org .assertj .core .api .Assertions .assertThat ;
1011
1112import java .util .Arrays ;
2425import org .junit .jupiter .api .AfterAll ;
2526import org .junit .jupiter .api .AfterEach ;
2627import org .junit .jupiter .api .BeforeAll ;
28+ import org .junit .jupiter .api .BeforeEach ;
2729import org .junit .jupiter .api .Test ;
30+ import org .junit .jupiter .api .Timeout ;
2831
32+ @ Timeout (value = 10 , unit = SECONDS )
2933class MBeanHelperTest {
3034
3135 private static final MBeanServer mbeanServer = getPlatformMBeanServer ();
@@ -56,6 +60,11 @@ static void tearDown() throws Exception {
5660 jmxServer .stop ();
5761 }
5862
63+ @ BeforeEach
64+ void confirmServerIsActive () {
65+ assertThat (jmxServer .isActive ()).isTrue ();
66+ }
67+
5968 @ AfterEach
6069 void unregisterBeans () throws Exception {
6170 for (ObjectInstance bean : registeredBeans ) {
Original file line number Diff line number Diff line change 66package io .opentelemetry .contrib .jmxmetrics ;
77
88import static java .lang .management .ManagementFactory .getPlatformMBeanServer ;
9+ import static java .util .concurrent .TimeUnit .SECONDS ;
910import static org .assertj .core .api .Assertions .assertThat ;
1011import static org .assertj .core .api .Assertions .assertThatCode ;
1112import static org .assertj .core .api .Assertions .assertThatThrownBy ;
2829import org .junit .jupiter .api .AfterEach ;
2930import org .junit .jupiter .api .BeforeAll ;
3031import org .junit .jupiter .api .Test ;
32+ import org .junit .jupiter .api .Timeout ;
3133
34+ @ Timeout (value = 10 , unit = SECONDS )
3235class OtelHelperJmxTest {
3336
3437 private static final String thingName =
@@ -48,10 +51,15 @@ static void setUp() throws Exception {
4851
4952 @ AfterAll
5053 static void tearDown () throws Exception {
51- jmxServer .stop ();
5254 mbeanServer .unregisterMBean (new ObjectName (thingName ));
5355 }
5456
57+ @ AfterEach
58+ void stopServer () throws Exception {
59+ // each test stands up its own server
60+ jmxServer .stop ();
61+ }
62+
5563 @ AfterEach
5664 void unregisterBeans () throws Exception {
5765 for (ObjectInstance bean : registeredBeans ) {
You can’t perform that action at this time.
0 commit comments