diff --git a/pom.xml b/pom.xml
index 15b614823..3b1ab826d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -203,6 +203,12 @@
1.19.3
test
+
+ org.hamcrest
+ hamcrest-library
+ 1.3
+ test
+
scm:git:git@github.com:Datadog/jmxfetch.git
diff --git a/src/test/java/org/datadog/jmxfetch/TestGCMetrics.java b/src/test/java/org/datadog/jmxfetch/TestGCMetrics.java
index 8b27a38a3..a8945fbcd 100644
--- a/src/test/java/org/datadog/jmxfetch/TestGCMetrics.java
+++ b/src/test/java/org/datadog/jmxfetch/TestGCMetrics.java
@@ -1,19 +1,27 @@
package org.datadog.jmxfetch;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+
import javax.management.MBeanServerConnection;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
+
+import org.junit.Test;
+
import lombok.extern.slf4j.Slf4j;
+
import org.datadog.jmxfetch.reporter.ConsoleReporter;
import org.datadog.jmxfetch.util.MisbehavingJMXServer;
-import org.junit.Test;
-import org.testcontainers.containers.output.Slf4jLogConsumer;
@Slf4j
public class TestGCMetrics extends TestCommon {
@@ -21,7 +29,6 @@ public class TestGCMetrics extends TestCommon {
private static final int RMI_PORT = 9090;
private static final int CONTROL_PORT = 9091;
private static final int SUPERVISOR_PORT = 9092;
- private static final Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(log);
private static boolean isDomainPresent(final String domain, final MBeanServerConnection mbs) {
boolean found = false;
@@ -44,28 +51,22 @@ private static boolean isDomainPresent(final String domain, final MBeanServerCon
*/
@Test
public void testJMXDirectBasic() throws Exception {
- try (final MisbehavingJMXServer server = new MisbehavingJMXServer(
- RMI_PORT,
- CONTROL_PORT,
+ try (final MisbehavingJMXServer server = new MisbehavingJMXServer(RMI_PORT, CONTROL_PORT,
SUPERVISOR_PORT)) {
server.start();
final String ipAddress = server.getIp();
final String remoteJmxServiceUrl = String.format(
- "service:jmx:rmi:///jndi/rmi://%s:%s/jmxrmi",
- ipAddress, RMI_PORT
- );
+ "service:jmx:rmi:///jndi/rmi://%s:%s/jmxrmi", ipAddress, RMI_PORT);
final JMXServiceURL jmxUrl = new JMXServiceURL(remoteJmxServiceUrl);
final JMXConnector conn = JMXConnectorFactory.connect(jmxUrl);
final MBeanServerConnection mBeanServerConnection = conn.getMBeanServerConnection();
- assertTrue(isDomainPresent("Bohnanza", mBeanServerConnection));
+ assertThat(isDomainPresent("Bohnanza", mBeanServerConnection), is(true));
}
}
@Test
public void testJMXFetchBasic() throws IOException {
- try (final MisbehavingJMXServer server = new MisbehavingJMXServer(
- RMI_PORT,
- CONTROL_PORT,
+ try (final MisbehavingJMXServer server = new MisbehavingJMXServer(RMI_PORT, CONTROL_PORT,
SUPERVISOR_PORT)) {
server.start();
final String ipAddress = server.getIp();
@@ -84,8 +85,67 @@ public void testJMXFetchBasic() throws IOException {
" domain: Bohnanza"
);
this.app.doIteration();
- List