assertEquals(isAdmin, connection.invoke(securityMBean, "canInvoke",
new Object [] {serviceMBean.toString(), "getServices", new String [] {}},
new String [] {String.class.getName(), String.class.getName(), String[].class.getName()}));
Map<String, List<String>> map = new HashMap<String, List<String>>();
TabularData td = (TabularData) connection.invoke(securityMBean, "canInvoke", new Object [] {map}, new String [] {Map.class.getName()});
assertEquals(0, td.size());
Map<String, List<String>> map2 = new HashMap<String, List<String>>();
map2.put(systemMBean.toString(), Collections.<String>emptyList());
map2.put(serviceMBean.toString(), Arrays.asList("getServices(boolean)", "getServices(long)", "getServices(long,boolean)", "getServices()"));
TabularData td2 = (TabularData) connection.invoke(securityMBean, "canInvoke", new Object [] {map2}, new String [] {Map.class.getName()});
assertEquals(5, td2.size());
CompositeData cd1 = td2.get(new Object [] {serviceMBean.toString(), "getServices(boolean)"});
assertEquals(serviceMBean.toString(), cd1.get("ObjectName"));
assertEquals("getServices(boolean)", cd1.get("Method"));
assertTrue((Boolean) cd1.get("CanInvoke"));
CompositeData cd2 = td2.get(new Object [] {serviceMBean.toString(), "getServices(long)"});
assertEquals(serviceMBean.toString(), cd2.get("ObjectName"));
assertEquals("getServices(long)", cd2.get("Method"));
assertEquals(isManager, cd2.get("CanInvoke"));
CompositeData cd3 = td2.get(new Object [] {serviceMBean.toString(), "getServices(long,boolean)"});
assertEquals(serviceMBean.toString(), cd3.get("ObjectName"));
assertEquals("getServices(long,boolean)", cd3.get("Method"));
assertEquals(isAdmin, cd3.get("CanInvoke"));
CompositeData cd4 = td2.get(new Object [] {serviceMBean.toString(), "getServices()"});
assertEquals(serviceMBean.toString(), cd4.get("ObjectName"));
assertEquals("getServices()", cd4.get("Method"));
assertEquals(isAdmin, cd4.get("CanInvoke"));
CompositeData cd5 = td2.get(new Object [] {systemMBean.toString(), ""});
assertEquals(systemMBean.toString(), cd5.get("ObjectName"));
assertEquals("", cd5.get("Method"));
assertTrue((Boolean) cd5.get("CanInvoke"));
Map<String, List<String>> map3 = new HashMap<String, List<String>>();
map3.put(serviceMBean.toString(), Collections.singletonList("getServices"));
TabularData td3 = (TabularData) connection.invoke(securityMBean, "canInvoke", new Object [] {map3}, new String [] {Map.class.getName()});
assertEquals(1, td3.size());
CompositeData cd6 = td3.get(new Object [] {serviceMBean.toString(), "getServices"});
assertEquals(serviceMBean.toString(), cd6.get("ObjectName"));
assertEquals("getServices", cd6.get("Method"));
assertTrue((Boolean) cd6.get("CanInvoke"));
Map<String, List<String>> map4 = new HashMap<String, List<String>>();
map4.put(systemMBean.toString(), Collections.singletonList("halt"));
TabularData td4 = (TabularData) connection.invoke(securityMBean, "canInvoke", new Object [] {map4}, new String [] {Map.class.getName()});
assertEquals(1, td4.size());
CompositeData cd7 = td4.get(new Object [] {systemMBean.toString(), "halt"});
assertEquals(systemMBean.toString(), cd7.get("ObjectName"));
assertEquals("halt", cd7.get("Method"));
assertEquals(isAdmin, cd7.get("CanInvoke"));
}