aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.examples.test/src/org/jacoco/examples/MBeanClientTest.java
blob: 09a60ade1988146ac88c2eff9ff1b6d913d1c9df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*******************************************************************************
 * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
 * This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *    Marc R. Hoffmann - initial API and implementation
 *
 *******************************************************************************/
package org.jacoco.examples;

import static org.junit.Assert.assertEquals;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import org.jacoco.agent.rt.IAgent;
import org.junit.Test;

/**
 * Tests for {@link MBeanClient}.
 */
public class MBeanClientTest {

	@Test
	public void testMBeanInterfaceCompatibility() {
		Set<String> expected = getDeclaredMethods(IAgent.class);
		Set<String> actual = getDeclaredMethods(MBeanClient.IProxy.class);
		assertEquals(expected, actual);
	}

	private Set<String> getDeclaredMethods(Class<?> clazz) {
		Set<String> methods = new HashSet<String>();
		for (Method m : clazz.getDeclaredMethods()) {
			methods.add(String.format("%s %s(%s)", m.getReturnType().getName(),
					m.getName(), Arrays.asList(m.getParameterTypes())));
		}
		return methods;
	}

}