Home | History | Annotate | Download | only in examples
      1 /*******************************************************************************
      2  * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
      3  * All rights reserved. This program and the accompanying materials
      4  * are made available under the terms of the Eclipse Public License v1.0
      5  * which accompanies this distribution, and is available at
      6  * http://www.eclipse.org/legal/epl-v10.html
      7  *
      8  * Contributors:
      9  *    Marc R. Hoffmann - initial API and implementation
     10  *
     11  *******************************************************************************/
     12 package org.jacoco.examples;
     13 
     14 import static org.junit.Assert.assertEquals;
     15 
     16 import java.lang.reflect.Method;
     17 import java.util.Arrays;
     18 import java.util.HashSet;
     19 import java.util.Set;
     20 
     21 import org.jacoco.agent.rt.IAgent;
     22 import org.junit.Test;
     23 
     24 /**
     25  * Tests for {@link MBeanClient}.
     26  */
     27 public class MBeanClientTest {
     28 
     29 	@Test
     30 	public void testMBeanInterfaceCompatibility() {
     31 		Set<String> expected = getDeclaredMethods(IAgent.class);
     32 		Set<String> actual = getDeclaredMethods(MBeanClient.IProxy.class);
     33 		assertEquals(expected, actual);
     34 	}
     35 
     36 	private Set<String> getDeclaredMethods(Class<?> clazz) {
     37 		Set<String> methods = new HashSet<String>();
     38 		for (Method m : clazz.getDeclaredMethods()) {
     39 			methods.add(String.format("%s %s(%s)", m.getReturnType().getName(),
     40 					m.getName(), Arrays.asList(m.getParameterTypes())));
     41 		}
     42 		return methods;
     43 	}
     44 
     45 }
     46