Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub #333: Fix MBeanClient example
This fixes the MBeanClient example and adds a unit test to ensure interface compatibility in future.
- Loading branch information
Showing
4 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
org.jacoco.examples.test/src/org/jacoco/examples/MBeanClientTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2009, 2015 Mountainminds GmbH & Co. KG and Contributors | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* 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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters