/*
* 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 6337061
* @summary Test that ModelMBeanInfoSupport.getDescriptors(null) also
* returns the MBean's descriptor.
* @author Eamonn McManus, Daniel Fuchs
* @run clean GetAllDescriptorsTest
* @run build GetAllDescriptorsTest
*/
import javax.management.*;
public class GetAllDescriptorsTest {
public static class Resource {
public int getNumber() {
return number;
}
public void setNumber(int n) {
number = n;
}
public int addOne(int x) {
return x + 1;
}
}
// doesn't look like an attribute so not seen by caching logic
}
}
int errorCount = 0;
for (int i = 0; i < NTESTS; i++) {
try {
test(i);
} catch (Throwable e) {
errorCount++;
boolean first = true;
do {
first = false;
e.printStackTrace();
if (e instanceof MBeanException)
}
e = nexte;
} while (e != null);
}
}
if (errorCount == 0) {
// JTReg doesn't like System.exit(0);
return;
} else {
}
}
String.class});
new Class[] {Notification.class});
new Class[] {NotificationListener.class,
String.class,
Object.class});
"local attr", true, true, false,
"local attr 2", true, true, false,
new ModelMBeanOperationInfo("setManagedResource descr",
new ModelMBeanOperationInfo("sendNotification descr",
new ModelMBeanOperationInfo("AddAttributeChangeNL descr",
"Resourcish resource",
null);
on,
switch (testno) {
case 0: {
/* Check getDescriptors("") on original MBeanInfo */
break;
}
case 1: {
/* Check getDescriptors(null) on original MBeanInfo */
break;
}
case 2: {
/* Check getDescriptors("") on retrieved MBeanInfo */
break;
}
case 3: {
/* Check getDescriptors(null) on retrieved MBeanInfo */
break;
}
default:
break;
}
}
/* Removes descriptor from the list and returns it. Returns {@code null}
if descriptor is not found */
Descriptor item) {
else return null;
}
/* Check that all descriptors have been returned */
int errCount = 0;
// checks that MBean's descriptor is returned.
//
errCount++;
}
// checks that MBean's attributes descriptors are returned.
//
name);
errCount++;
}
}
// checks that MBean's operations descriptors are returned.
//
name);
errCount++;
}
}
// checks that MBean's notifications descriptors are returned.
//
name);
errCount++;
}
}
if (errCount > 0) {
" errors");
// Check that there are no additional descriptors
//
throw new RuntimeException(string+
": Unexpected remaining descriptors: "+list);
}
}