UnserializableTargetObjectTest.java revision 2362
/*
* 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 6332962
* @summary Test that a RequiredModelMBean operation can have a targetObject
* that is not serializable
* @author Eamonn McManus
* @run clean UnserializableTargetObjectTest
* @run build UnserializableTargetObjectTest
* @run main UnserializableTargetObjectTest
*/
/* This test and DescriptorSupportSerialTest basically cover the same thing.
I wrote them at different times and forgot that I had written the earlier
one. However the coverage is slightly different so I'm keeping both. */
public class UnserializableTargetObjectTest {
public static class Resource { // not serializable!
int count;
int operationCount;
public void operation() {
}
public int getCount() {
return count;
}
}
}
new DescriptorSupport(new String[] {
"descriptorType", "name", "targetObject"
}, new Object[] {
});
new DescriptorSupport(new String[] {
"descriptorType", "name", "targetObject"
}, new Object[] {
});
new DescriptorSupport(new String[] {
"descriptorType", "name", "targetObject"
}, new Object[] {
});
new DescriptorSupport(new String[] {
"descriptorType", "name", "getMethod", "setMethod"
}, new Object[] {
"attribute", "Count", "getCount", "setCount"
});
new ModelMBeanOperationInfo("operation description",
new ModelMBeanOperationInfo("getCount description",
new ModelMBeanOperationInfo("setCount description",
"ModelMBean to test targetObject",
new ModelMBeanAttributeInfo[] {countInfo},
null, // no constructors
new ModelMBeanOperationInfo[] {
},
null); // no notifications
if (got != 53)
// Above gets NotSerializableException if resource included in
// serialized form
}
}