Polish MBeanClientInterceptorTests and recover two lost tests

Two test methods were missing the @Test annotation after the migration
from JUnit 3 to JUnit 4.
This commit is contained in:
Sam Brannen 2020-03-31 19:02:15 +02:00
parent 9bd74c270f
commit 01cf0a3d4e
1 changed files with 21 additions and 27 deletions

View File

@ -90,14 +90,14 @@ class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
}
@Test
void testProxyClassIsDifferent() throws Exception {
void proxyClassIsDifferent() throws Exception {
assumeTrue(runTests);
IJmxTestBean proxy = getProxy();
assertThat(proxy.getClass()).as("The proxy class should be different than the base class").isNotSameAs(IJmxTestBean.class);
}
@Test
void testDifferentProxiesSameClass() throws Exception {
void differentProxiesSameClass() throws Exception {
assumeTrue(runTests);
IJmxTestBean proxy1 = getProxy();
IJmxTestBean proxy2 = getProxy();
@ -107,7 +107,7 @@ class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
}
@Test
void testGetAttributeValue() throws Exception {
void getAttributeValue() throws Exception {
assumeTrue(runTests);
IJmxTestBean proxy1 = getProxy();
int age = proxy1.getAge();
@ -115,7 +115,7 @@ class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
}
@Test
void testSetAttributeValue() throws Exception {
void setAttributeValue() throws Exception {
assumeTrue(runTests);
IJmxTestBean proxy = getProxy();
proxy.setName("Rob Harrop");
@ -123,39 +123,35 @@ class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
}
@Test
void testSetAttributeValueWithRuntimeException() throws Exception {
void setAttributeValueWithRuntimeException() throws Exception {
assumeTrue(runTests);
IJmxTestBean proxy = getProxy();
assertThatIllegalArgumentException().isThrownBy(() ->
proxy.setName("Juergen"));
assertThatIllegalArgumentException().isThrownBy(() -> proxy.setName("Juergen"));
}
@Test
void testSetAttributeValueWithCheckedException() throws Exception {
void setAttributeValueWithCheckedException() throws Exception {
assumeTrue(runTests);
IJmxTestBean proxy = getProxy();
assertThatExceptionOfType(ClassNotFoundException.class).isThrownBy(() ->
proxy.setName("Juergen Class"));
assertThatExceptionOfType(ClassNotFoundException.class).isThrownBy(() -> proxy.setName("Juergen Class"));
}
@Test
void testSetAttributeValueWithIOException() throws Exception {
void setAttributeValueWithIOException() throws Exception {
assumeTrue(runTests);
IJmxTestBean proxy = getProxy();
assertThatIOException().isThrownBy(() ->
proxy.setName("Juergen IO"));
assertThatIOException().isThrownBy(() -> proxy.setName("Juergen IO"));
}
@Test
void testSetReadOnlyAttribute() throws Exception {
void setReadOnlyAttribute() throws Exception {
assumeTrue(runTests);
IJmxTestBean proxy = getProxy();
assertThatExceptionOfType(InvalidInvocationException.class).isThrownBy(() ->
proxy.setAge(900));
assertThatExceptionOfType(InvalidInvocationException.class).isThrownBy(() -> proxy.setAge(900));
}
@Test
void testInvokeNoArgs() throws Exception {
void invokeNoArgs() throws Exception {
assumeTrue(runTests);
IJmxTestBean proxy = getProxy();
long result = proxy.myOperation();
@ -163,7 +159,7 @@ class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
}
@Test
void testInvokeArgs() throws Exception {
void invokeArgs() throws Exception {
assumeTrue(runTests);
IJmxTestBean proxy = getProxy();
int result = proxy.add(1, 2);
@ -171,15 +167,14 @@ class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
}
@Test
void testInvokeUnexposedMethodWithException() throws Exception {
void invokeUnexposedMethodWithException() throws Exception {
assumeTrue(runTests);
IJmxTestBean bean = getProxy();
assertThatExceptionOfType(InvalidInvocationException.class).isThrownBy(() ->
bean.dontExposeMe());
assertThatExceptionOfType(InvalidInvocationException.class).isThrownBy(() -> bean.dontExposeMe());
}
@Test
void testTestLazyConnectionToRemote() throws Exception {
void lazyConnectionToRemote() throws Exception {
assumeTrue(runTests);
final int port = SocketUtils.findAvailableTcpPort();
@ -217,7 +212,8 @@ class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
}
}
public void testMXBeanAttributeAccess() throws Exception {
@Test
void mxBeanAttributeAccess() throws Exception {
MBeanClientInterceptor interceptor = new MBeanClientInterceptor();
interceptor.setServer(ManagementFactory.getPlatformMBeanServer());
interceptor.setObjectName("java.lang:type=Memory");
@ -226,7 +222,8 @@ class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
assertThat(proxy.getHeapMemoryUsage().getMax()).isGreaterThan(0);
}
public void testMXBeanOperationAccess() throws Exception {
@Test
void mxBeanOperationAccess() throws Exception {
MBeanClientInterceptor interceptor = new MBeanClientInterceptor();
interceptor.setServer(ManagementFactory.getPlatformMBeanServer());
interceptor.setObjectName("java.lang:type=Threading");
@ -270,12 +267,10 @@ class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
@SuppressWarnings("unused")
protected void populateAttributeDescriptor(Descriptor descriptor, Method getter, Method setter) {
}
@SuppressWarnings("unused")
protected void populateOperationDescriptor(Descriptor descriptor, Method method) {
}
@SuppressWarnings({ "unused", "rawtypes" })
@ -285,7 +280,6 @@ class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
@SuppressWarnings({ "unused", "rawtypes" })
protected void populateMBeanDescriptor(Descriptor mbeanDescriptor, String beanKey, Class beanClass) {
}
}