You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/02/22 13:49:28 UTC
[GitHub] [flink] RyanSkraba commented on a change in pull request #18830: [FLINK-26225][jmx] Migrate tests to JUnit5
RyanSkraba commented on a change in pull request #18830:
URL: https://github.com/apache/flink/pull/18830#discussion_r811957441
##########
File path: flink-metrics/flink-metrics-jmx/src/test/java/org/apache/flink/metrics/jmx/JMXReporterFactoryTest.java
##########
@@ -19,57 +19,53 @@
import org.apache.flink.management.jmx.JMXService;
import org.apache.flink.metrics.util.MetricReporterTestUtils;
-import org.apache.flink.util.TestLogger;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.allOf;
-import static org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo;
-import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo;
+import static org.assertj.core.api.Assertions.assertThat;
/** Tests for the {@link JMXReporterFactory}. */
-public class JMXReporterFactoryTest extends TestLogger {
+class JMXReporterFactoryTest {
- @After
- public void shutdownService() throws IOException {
+ @AfterEach
+ void shutdownService() throws IOException {
JMXService.stopInstance();
}
@Test
- public void testPortRangeArgument() {
+ void testPortRangeArgument() {
Properties properties = new Properties();
properties.setProperty(JMXReporterFactory.ARG_PORT, "9000-9010");
JMXReporter metricReporter = new JMXReporterFactory().createMetricReporter(properties);
try {
- Assert.assertThat(
- metricReporter.getPort().get(),
- allOf(greaterThanOrEqualTo(9000), lessThanOrEqualTo(9010)));
+ assertThat(metricReporter.getPort().get())
Review comment:
```suggestion
assertThat(opt).get(as(InstanceOfAssertFactories.INTEGER))
```
Just for info... I'm not a huge fan of AssertJ syntax for Optional, but this also guards against _.empty()_. I'm also OK with just throwing the NoSuchElementException on failure, like we currently do (for readability).
##########
File path: flink-metrics/flink-metrics-jmx/src/test/java/org/apache/flink/metrics/jmx/JMXReporterTest.java
##########
@@ -268,9 +265,9 @@ public void testMeterReporting() throws Exception {
MBeanAttributeInfo[] attributeInfos = info.getAttributes();
- assertEquals(2, attributeInfos.length);
+ assertThat(attributeInfos.length).isEqualTo(2);
Review comment:
```suggestion
assertThat(attributeInfos).hasSize(2);
```
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org