Remove JMXMP from TestGroup

Due to the changes in a7425c81c0, 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
This commit is contained in:
Sam Brannen 2019-04-08 17:02:19 +02:00
parent fd8fa301a6
commit bd414df944
8 changed files with 16 additions and 75 deletions

View File

@ -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.*;
/**
* <strong>Note:</strong> 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.
*
* <p>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}).
*
* <p>If you run into the <em>"Unsupported protocol: jmxmp"</em> error, you will need to
* download the <a href="https://www.oracle.com/technetwork/java/javase/tech/download-jsp-141676.html">JMX
* Remote API 1.0.1_04 Reference Implementation</a> from Oracle and extract
@ -49,7 +40,6 @@ import static org.junit.Assert.*;
*
* <p>See also:
* <ul>
* <li>
* <li><a href="https://jira.spring.io/browse/SPR-8093">SPR-8093</a></li>
* <li><a href="https://issuetracker.springsource.com/browse/EBR-349">EBR-349</a></li>
* </ul>

View File

@ -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();

View File

@ -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 {

View File

@ -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();

View File

@ -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);

View File

@ -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]"));
}
}

View File

@ -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.
*/

View File

@ -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");
}