/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/**
*/
public final class AMXTest
extends AMXTestBase {
public AMXTest() {
}
public static Capabilities
getCapabilities() {
return getOfflineCapableCapabilities(true);
}
/**
Verify that the ObjectName returned from the ATTR_CONTAINER_OBJECT_NAME is the same
as the ObjectName obtained from the getContainer() proxy.
*/
public void
throws Exception {
assert (containerObjectName == null);
} else {
assert (containerObjectName != null);
}
}
public void
throws Exception {
testAll("checkContainerObjectName");
}
/**
due to our template facility ${...}
*/
public void
}
}
if (s.size() != 0) {
}
}
}
public void
throws Exception {
testAll("checkTemplateAttributes");
}
/**
Verify that the ObjectName returned from the MBean is in fact itself.
*/
public void
throws Exception {
}
public void
throws Exception {
testAll("checkSelfObjectName");
}
/**
Verify that the MBean has an ATTR_INTERFACE_NAME Attribute
*/
public void
throws Exception {
assert (interfaceName != null);
}
public void
throws Exception {
testAll("checkInterface");
}
/**
Verify that the MBean has j2eeType and name.
*/
public void
throws Exception {
}
public void
throws Exception {
testAll("checkJ2EETypeAndName");
}
/**
Verify that all j2eeTypes have a proper Container that does actually hold them.
*/
public void
/*
final TypeInfos infos = TypeInfos.getInstance();
final Set<String> j2eeTypesSet = infos.getJ2EETypes();
for( final String j2eeType : j2eeTypesSet )
{
checkContainerChild( j2eeType );
}
*/
}
/**
Verify that each child's Container actually claims the child as a child.
*/
public void
if (!shouldTest(objectName)) {
continue;
}
try {
}
catch (Exception e) {
}
"container is null for: " + objectName;
continue;
}
}
}
/**
Statically verify that the interface for each proxy has a J2EE_TYPE field.
*/
public void
/* final TypeInfos infos = TypeInfos.getInstance();
final Set j2eeTypes = infos.getJ2EETypes();
boolean success = true;
final Iterator iter = j2eeTypes.iterator();
while ( iter.hasNext() )
{
final String j2eeType = (String)iter.next();
final TypeInfo info = infos.getInfo( j2eeType );
final Class theInterface = info.getInterface();
try
{
final String value =
(String)ClassUtil.getFieldValue( theInterface, "J2EE_TYPE" );
assert( value.equals( j2eeType ) ) :
"info and J2EE_TYPE don't match: " + j2eeType + " != " + value;
}
catch( Exception e )
{
trace( "no J2EE_TYPE field found for proxy of type: " + theInterface.getName() );
success = false;
}
}
assert( success );*/
}
/**
Verify that getName() is the same as the 'name' property in the ObjectName.
*/
public void
throws Exception {
if (childProxy instanceof NamedConfigElement) {
}
}
public void
throws Exception {
testAll("checkNameMatchesJ2EEName");
}
private static boolean
return (
}
private static boolean
return (
}
/**
Verify that a proxy getAbcMap(...) Attribute or operation has an appropriate
MBean getAbcObjectNameMap() method.
*/
public void
throws Exception {
if (isMapGetter(method)) {
continue;
}
// verify that a corresponding peer method exists and
// has the right return type and same number and type of parameters
final String peerMethodName =
} else if (isMapGetterName(methodName)) {
}
}
}
}
/**
Verify that the proxy method has a compatible Attribute or operation.
<ul>
<li>a proxy getter must have a corresponding Attribute returning an ObjectName</li>
<li>a proxy operation must have a corresponding operation with matching signature</li>
<li>a proxy operation must have a corresponding operation with compatible return type</li>
</u
*/
private void
final ObjectName objectName,
final Method proxyMethod,
final String mbeanMethodName,
// it's getter
}
} else {
// look for an operation that matches
}
}
if (hasPeer) {
// a proxy return type of AMX should have an Attribute type of ObjectName
} else // return types must match
{
}
hasPeer = true;
}
if (!hasPeer) {
" without corresponding peer Attribute/operation " + mbeanMethodName);
}
}
public void
testMaps()
throws Exception {
testAll("checkMaps");
}
// these are quick checks--other classes may be OK too
"boolean", "byte", "char", "short", "int", "long", "void",
boolean[].class.getName(),
char[].class.getName(),
byte[].class.getName(),
short[].class.getName(),
int[].class.getName(),
long[].class.getName(),
ObjectName.class.getName(),
ObjectName[].class.getName(),
// these are passed as Maps, but declared as their proper types
// in the interface
WebServiceEndpointInfo.class.getName(),
LogQueryResult.class.getName(),
MessageTrace.class.getName()
);
/**
Verify that the type is suitable for the API. It must meet the following constraints
<ul>
<li>that it is an OpenType or a standard Java type or a JMX type</li>
<li>that it is Serializable or an interface</li>
<li>or that it is an array whose elements meet the above constraints</li>
<li>or that it is one of our specific Stats types</li>
</ul>
*/
private boolean
if (!isSuitable) {
if (isArray ||
try {
c == Object.class;
}
catch (ClassNotFoundException e) {
isSuitable = false;
}
if (isArray) {
} else if (isSuitable &&
!c.isInterface()) {
// insist on an interface except for those types explicit in SUITABLE_TYPES
isSuitable = false;
}
}
}
return (isSuitable);
}
/**
Verify:
<ul>
<li>that all return types are suitable for the API</li>
</ul>
*/
public void
throws Exception {
boolean emittedName = false;
if (!isSuitableReturnTypeForAPI(returnType)) {
if (!emittedName) {
emittedName = true;
}
trace("WARNING: unsuitable return type in API: " +
}
}
}
public void
throws Exception {
testAll("checkReturnTypes");
}
/**
Verify:
<ul>
<li>that all Attributes are of standard types and Serializable</li>
</ul>
*/
public void
throws Exception {
boolean emittedName = false;
if (!isSuitableReturnTypeForAPI(type)) {
if (!emittedName) {
emittedName = true;
}
trace("WARNING: unsuitable Attribute type in API: " +
}
}
}
}
public void
throws Exception {
testAll("checkAttributeTypes");
}
/**
Verify:
<ul>
<li>each create() or createAbc() method ends in "Config" if it returns an AMXConfig subclass</li>
<li>each remove() or removeAbc() method ends in "Config"</li>
</ul>
*/
public void
throws Exception {
(!(proxy instanceof SecurityMapConfig))) {
}
if ( //method.getReturnType() == Void.class &&
(!(proxy instanceof SecurityMapConfig))) {
}
}
}
}
}
public void
throws Exception {
testAll("checkCreateRemoveGet");
}
/**
Verify:
<ul>
<li>if the interface name ends in "Config" or "ConfigMgr", then is is an AMXConfig</li>
</ul>
*/
public void
throws Exception {
}
}
}
/**
*/
private boolean
final String suggestedMethod) {
boolean ignore = false;
false
) {
ignore = true;
}
) {
ignore = true;
}
}
return (ignore);
}
/**
Verify that all getAbcConfigMgr() calls return a non-null result.
*/
public void
throws Exception {
// these are created via deployment not directly
continue;
}
continue;
}
final MBeanOperationInfo[] creates =
boolean haveCreate = false;
haveCreate = true;
break;
}
}
assert (haveCreate) :
final MBeanOperationInfo[] removes =
boolean haveRemove = false;
haveRemove = true;
break;
}
}
assert (haveRemove) :
}
}
}
}
public void
throws Exception {
testAll("checkMapsHaveCreateRemove");
}
public void
throws Exception {
testAll("checkImplementsAMXConfig");
}
{
JMXMonitorMgr.class,
AMXStringMonitor.class,
AMXCounterMonitor.class,
AMXGaugeMonitor.class,
EJBModuleMonitor.class,
HTTPServiceMonitor.class,
ApplicationMonitor.class,
});
/**
Verify:
<ul>
<li>verify that if the interface name ends in "Monitor", then it is an AMX, Monitoring</li>
<li>verify that if the interface name ends in "MonitorMgr", then it is an Container</li>
</ul>
*/
public void
throws Exception {
/*
final TypeInfos infos = TypeInfos.getInstance();
final Iterator iter = infos.getJ2EETypes().iterator();
while ( iter.hasNext() )
{
final TypeInfo info = infos.getInfo( (String)iter.next() );
final Class theInterface = info.getInterface();
final String interfaceName = theInterface.getName();
if ( ! MON_IGNORE.contains( theInterface ) )
{
if ( interfaceName.endsWith( "Monitor" ) )
{
if ( ! Monitoring.class.isAssignableFrom( theInterface ) )
{
warning( ClassUtil.stripPackageName( interfaceName ) + " does not implement Monitoring" );
}
}
else if ( interfaceName.endsWith( "MonitorMgr" ) )
{
if ( ! Container.class.isAssignableFrom( theInterface ) )
{
warning( ClassUtil.stripPackageName( interfaceName ) + " does not implement Container" );
}
}
}
}
*/
}
public void
throws IOException, JMException {
final MBeanServerConnection conn =
try {
}
catch (AttributeNotFoundException e) {
}
}
warning("The following MBeans did not return the Attribute InterfaceName:\n" +
assert (false);
throw new Error();
}
}
public void
throws Exception {
}
}
public void
testMisc() {
}
}
public void
final ObjectName objectName,
final MBeanFeatureInfo[] featureInfos) {
}
}
assert (false) : NEWLINE +
}
}
public void
testNoGoofyNames() {
}
}
public void
testToString() {
assert( s.length() != 0 );
}
}
}
}