/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4847959 6191402
* @summary Test newly-generified APIs
* @author Eamonn McManus
* @run clean GenericTest
* @run build GenericTest
* @run main GenericTest
*/
import javax.management.*;
public class GenericTest {
private static int failures;
// Check we are really using the generified version
boolean generic;
String.class);
if (!(findmbstype instanceof ParameterizedType)) {
failures++;
generic = false;
} else {
generic = true;
}
ObjectName.class);
check("Set<ObjectName> MBeanServerConnection.queryNames",
check("queryNames sets same",
ObjectInstance.class);
check("Set<ObjectInstsance> MBeanServer.queryMBeans",
check("Set<ObjectInstsance> MBeanServerConnection.queryMBeans",
check("queryMBeans sets same",
check("Vector<String> AttributeChangeNotificationFilter.getEnabled" +
if (generic) {
check("List<Attribute> AttributeList.asList()",
}
check("new Role(String,List<ObjectName>).getRoleValue() -> " +
if (generic) {
check("List<Role> RoleList.asList()",
}
check("new RoleUnresolved(...List<ObjectName>...).getRoleValue() -> " +
if (generic) {
check("List<RoleUnresolved> RoleUnresolvedList.asList()",
}
// This case basically just tests that we can compile this sort of thing
true, true, false);
new String[] {"item1 descr"},
ct, true, true, false);
tt, true, true, false);
at, true, true, false);
true, true, false);
true, true, false,
5, 1, 9);
true, true, false,
new OpenMBeanAttributeInfo[] {
},
check("CompositeDataSupport(CompositeType, Map<String,?>",
check("Set<String> CompositeType.keySet()",
check("Set<String> TabularType.getIndexNames()",
CompositeData.class);
check("Set<List<?>> TabularDataSupport.keySet()",
check("Collection<CompositeData> TabularDataSupport.values()",
StupidMBean.class,
false);
check("MBeanServerInvocationHandler.newProxyInstance",
check("<T> StandardMBean(T impl, Class<T> intf)",
// Following is based on the package.html for javax.management.relation
// Create the Relation Service MBean
// Create an MBean proxy for easier access to the Relation Service
RelationServiceMBean.class,
false);
// Define the DependsOn relation type
RoleInfo[] dependsOnRoles = {
};
// Now define a relation instance "moduleA DependsOn moduleB"
// Following two lines added to example:
// Query the Relation Service to find what modules moduleA depends on
// Set of ObjectName containing moduleB
check("Map<ObjectName,List<String>> RelationService.findAssociatedMBeans",
check("Map<String,List<String>> RelationService.findReferencingRelations",
check("List<String> RelationService.findRelationsOfType",
check("List<String> RelationService.getAllRelationIds()",
check("List<String> RelationService.getAllRelationTypeNames",
check("Map<ObjectName,List<String>> RelationService.getReferencedMBeans",
ObjectName.class);
check("List<ObjectName> RelationService.getRole",
check("List<RoleInfo> RelationService.getRoleInfos",
// Since there's no RoleInfo.equals and since the RelationTypeSupport
// constructor clones the RoleInfos passed to it, it's tricky to
// test equality here so we check type and size and have done with it
check("List<RoleInfo> RelationType.getRoleInfos",
check("Vector<ObjectName> MBeanServerNotificationFilter." +
"getEnabledObjectNames",
check("Vector<ObjectName> MBeanServerNotificationFilter." +
"getDisabledObjectNames",
check("List<ObjectName> RelationNotification.getMBeansToUnregister",
check("List<ObjectName> RelationNotification.getOldRoleValue",
check("List<ObjectName> RelationNotification.getNewRoleValue",
TimerMBean.class,
false);
check("Vector<Integer> TimerMBean.getNotificationIDs",
check("Vector<Integer> TimerMBean.getAllNotificationIDs",
// ADD NEW TEST CASES ABOVE THIS COMMENT
if (failures == 0)
else {
}
// DO NOT ADD NEW TEST CASES HERE, ADD THEM ABOVE THE PREVIOUS COMMENT
}
public static interface StupidMBean {
public int getFive();
}
public int getFive() {
return 5;
}
}
super(StupidMBean.class);
}
public int getFive() {
return 5;
}
}
}
}
}
}
}
}
/* The fact that we have to call this method is a clear signal that
* the API says List where it means Set.
*/
}
if (cond)
else {
failures++;
}
}
}