From bd414df9443f0bdda7681f32a1141b8041c8518d Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 8 Apr 2019 17:02:19 +0200 Subject: [PATCH] Remove JMXMP from TestGroup Due to the changes in a7425c81c000cd385417f0626759b3efc070c10b, we no longer need to execute tests using the JMXMP protocol in PERFORMANCE builds. This commit removes the JMXMP constant from the TestGroup enum and updates affected tests, thereby effectively including such tests in the standard build from now on. See gh-22757 --- .../jmx/AbstractMBeanServerTests.java | 12 +---------- .../access/MBeanClientInterceptorTests.java | 8 +------- .../RemoteMBeanClientInterceptorTests.java | 10 +--------- .../ConnectorServerFactoryBeanTests.java | 20 +------------------ ...MBeanServerConnectionFactoryBeanTests.java | 15 ++------------ .../springframework/tests/AssumeTests.java | 12 +++++------ .../org/springframework/tests/TestGroup.java | 8 +------- .../springframework/tests/TestGroupTests.java | 6 +++--- 8 files changed, 16 insertions(+), 75 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java b/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java index 9a36d73d9b..524f9b07ae 100644 --- a/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,20 +27,11 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericApplicationContext; import org.springframework.jmx.export.MBeanExporter; -import org.springframework.tests.TestGroup; import org.springframework.util.MBeanTestUtils; import static org.junit.Assert.*; /** - * Note: certain tests throughout this hierarchy require the presence of - * the {@code jmxremote_optional.jar} in your classpath. For this reason, these tests are - * run only if {@link TestGroup#JMXMP} is enabled. - * - *

If you wish to run these tests, follow the instructions in the TestGroup class to - * enable JMXMP tests (i.e., set the following Java system property: - * {@code -DtestGroups=jmxmp}). - * *

If you run into the "Unsupported protocol: jmxmp" error, you will need to * download the JMX * Remote API 1.0.1_04 Reference Implementation from Oracle and extract @@ -49,7 +40,6 @@ import static org.junit.Assert.*; * *

See also: *

diff --git a/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java b/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java index cf83975517..7fe92ec216 100644 --- a/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,17 +36,12 @@ import org.springframework.jmx.JmxException; import org.springframework.jmx.JmxTestBean; import org.springframework.jmx.export.MBeanExporter; import org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler; -import org.springframework.tests.Assume; -import org.springframework.tests.TestGroup; import org.springframework.util.SocketUtils; import static org.junit.Assert.*; import static org.junit.Assume.*; /** - * To run the tests in the class, set the following Java system property: - * {@code -DtestGroups=jmxmp}. - * * @author Rob Harrop * @author Juergen Hoeller * @author Sam Brannen @@ -175,7 +170,6 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests { @Test public void testTestLazyConnectionToRemote() throws Exception { assumeTrue(runTests); - Assume.group(TestGroup.JMXMP); final int port = SocketUtils.findAvailableTcpPort(); diff --git a/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java b/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java index ab6cf60deb..628aac0b09 100644 --- a/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,14 +27,9 @@ import javax.management.remote.JMXServiceURL; import org.junit.After; -import org.springframework.tests.Assume; -import org.springframework.tests.TestGroup; import org.springframework.util.SocketUtils; /** - * To run the tests in the class, set the following Java system property: - * {@code -DtestGroups=jmxmp}. - * * @author Rob Harrop * @author Chris Beams * @author Sam Brannen @@ -58,9 +53,6 @@ public class RemoteMBeanClientInterceptorTests extends MBeanClientInterceptorTes @Override public void onSetUp() throws Exception { - runTests = false; - Assume.group(TestGroup.JMXMP); - runTests = true; super.onSetUp(); this.connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(getServiceUrl(), null, getServer()); try { diff --git a/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java index 9dd45e0f23..8177b792a2 100644 --- a/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,19 +27,13 @@ import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; -import org.junit.After; import org.junit.Test; import org.springframework.jmx.AbstractMBeanServerTests; -import org.springframework.tests.Assume; -import org.springframework.tests.TestGroup; import static org.junit.Assert.*; /** - * To run the tests in the class, set the following Java system property: - * {@code -DtestGroups=jmxmp}. - * * @author Rob Harrop * @author Chris Beams * @author Sam Brannen @@ -49,18 +43,6 @@ public class ConnectorServerFactoryBeanTests extends AbstractMBeanServerTests { private static final String OBJECT_NAME = "spring:type=connector,name=test"; - @Override - protected void onSetUp() throws Exception { - Assume.group(TestGroup.JMXMP); - } - - @After - @Override - public void tearDown() throws Exception { - Assume.group(TestGroup.JMXMP, () -> super.tearDown()); - } - - @Test public void startupWithLocatedServer() throws Exception { ConnectorServerFactoryBean bean = new ConnectorServerFactoryBean(); diff --git a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java index 1656b3b1b0..a6a9e6f56b 100644 --- a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,28 +26,19 @@ import org.junit.Test; import org.springframework.aop.support.AopUtils; import org.springframework.jmx.AbstractMBeanServerTests; -import org.springframework.tests.Assume; -import org.springframework.tests.TestGroup; import org.springframework.util.SocketUtils; import static org.junit.Assert.*; /** - * To run the tests in the class, set the following Java system property: - * {@code -DtestGroups=jmxmp}. - * * @author Rob Harrop * @author Juergen Hoeller * @author Sam Brannen */ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTests { - private final String serviceUrl; + private final String serviceUrl = "service:jmx:jmxmp://localhost:" + SocketUtils.findAvailableTcpPort(9800, 9900); - { - int port = SocketUtils.findAvailableTcpPort(9800, 9900); - this.serviceUrl = "service:jmx:jmxmp://localhost:" + port; - } private JMXServiceURL getJMXServiceUrl() throws MalformedURLException { return new JMXServiceURL(serviceUrl); @@ -59,7 +50,6 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe @Test public void testTestValidConnection() throws Exception { - Assume.group(TestGroup.JMXMP); JMXConnectorServer connectorServer = getConnectorServer(); connectorServer.start(); @@ -92,7 +82,6 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe @Test public void testTestWithLazyConnection() throws Exception { - Assume.group(TestGroup.JMXMP); MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean(); bean.setServiceUrl(serviceUrl); bean.setConnectOnStartup(false); diff --git a/spring-core/src/test/java/org/springframework/tests/AssumeTests.java b/spring-core/src/test/java/org/springframework/tests/AssumeTests.java index 09401c073e..76f6e59ffa 100644 --- a/spring-core/src/test/java/org/springframework/tests/AssumeTests.java +++ b/spring-core/src/test/java/org/springframework/tests/AssumeTests.java @@ -58,22 +58,22 @@ public class AssumeTests { @Test public void assumeGroupWithNoActiveTestGroups() { setTestGroups(""); - Assume.group(JMXMP); + Assume.group(LONG_RUNNING); fail("assumption should have failed"); } @Test public void assumeGroupWithNoMatchingActiveTestGroup() { setTestGroups(PERFORMANCE, CI); - Assume.group(JMXMP); + Assume.group(LONG_RUNNING); fail("assumption should have failed"); } @Test public void assumeGroupWithMatchingActiveTestGroup() { - setTestGroups(JMXMP); + setTestGroups(LONG_RUNNING); try { - Assume.group(JMXMP); + Assume.group(LONG_RUNNING); } catch (AssumptionViolatedException ex) { fail("assumption should NOT have failed"); @@ -99,7 +99,7 @@ public class AssumeTests { setTestGroups(testGroups); try { - Assume.group(JMXMP); + Assume.group(LONG_RUNNING); fail("assumption should have failed"); } catch (IllegalStateException ex) { @@ -109,7 +109,7 @@ public class AssumeTests { assertThat(ex.getCause(), instanceOf(IllegalArgumentException.class)); assertThat(ex.getCause().getMessage(), equalTo("Unable to find test group 'bogus' when parsing testGroups value: '" + testGroups - + "'. Available groups include: [LONG_RUNNING,PERFORMANCE,JMXMP,CI]")); + + "'. Available groups include: [LONG_RUNNING,PERFORMANCE,CI]")); } } diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroup.java b/spring-core/src/test/java/org/springframework/tests/TestGroup.java index 61ce88b064..d1dbdbe76f 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestGroup.java +++ b/spring-core/src/test/java/org/springframework/tests/TestGroup.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,12 +50,6 @@ public enum TestGroup { */ PERFORMANCE, - /** - * Tests requiring the presence of jmxremote_optional.jar in jre/lib/ext in order to - * avoid "Unsupported protocol: jmxmp" errors. - */ - JMXMP, - /** * Tests that should only be run on the continuous integration server. */ diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java b/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java index 286ba284a3..54a2fe1e1e 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java +++ b/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ public class TestGroupTests { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Unable to find test group 'missing' when parsing " + "testGroups value: 'performance, missing'. Available groups include: " + - "[LONG_RUNNING,PERFORMANCE,JMXMP,CI]"); + "[LONG_RUNNING,PERFORMANCE,CI]"); TestGroup.parse("performance, missing"); } @@ -92,7 +92,7 @@ public class TestGroupTests { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Unable to find test group 'missing' when parsing " + "testGroups value: 'all-missing'. Available groups include: " + - "[LONG_RUNNING,PERFORMANCE,JMXMP,CI]"); + "[LONG_RUNNING,PERFORMANCE,CI]"); TestGroup.parse("all-missing"); }