/*
* 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 6713777
* @summary Test that exception messages include all relevant information
* @author Eamonn McManus
*/
public class ExceptionDiagnosisTest {
// ------ Illegal MXBeans ------
// Test that all of BdelloidMXBean, Rotifer, and File appear in the
// exception messages. File is not an allowed type because of recursive
// getters like "File getParentFile()".
public static interface BdelloidMXBean {
}
return null;
}
}
public static class Rotifer {
return null;
}
}
// Test that all of IndirectHashMapMXBean, HashMapContainer, and
// HashMap<String,String> appear in the exception messages.
// HashMap<String,String> is not an allowed type because only the
// java.util interface such as Map are allowed with generic parameters,
// not their concrete implementations like HashMap.
public static interface IndirectHashMapMXBean {
}
return null;
}
}
public static class HashMapContainer {
}
// ------ MXBeans that are legal but where proxies are not ------
// Test that all of BlimMXBean, BlimContainer, Blim, and Blam appear
// in the exception messages for a proxy for this MXBean. Blam is
// legal in MXBeans but is not reconstructible so you cannot make
// a proxy for BlimMXBean.
public static interface BlimMXBean {
}
return null;
}
}
public static class BlimContainer {
}
public static class Blim {
}
public static class Blam {
public Blam(int x) {}
}
// ------ Property name differing only in case ------
public static interface CaseProbMXBean {
}
}
public static class CaseProb {
@ConstructorProperties({"urlPath"})
}
testMXBeans(new IndirectHashMap(),
IndirectHashMapMXBean.class, HashMapContainer.class,
testCaseProb();
else
}
throws Exception {
try {
} catch (NotCompliantMBeanException e) {
}
}
private static <T> void testProxies(
throws Exception {
if (m.getDeclaringClass() == mxbeanClass)
}
fail("TEST BUG: expected to find exactly one method in " +
}
try {
try {
} catch (InvocationTargetException e) {
else
}
} catch (IllegalArgumentException e) {
}
}
try {
fail("No exception from proxy method getCaseProb");
} catch (IllegalArgumentException e) {
+ messageChain);
} else {
fail("Exception chain for CaseProb does not mention property" +
" URLPath differing only in case");
}
}
}
private static void checkExceptionChain(
// Now check that each of the classes is mentioned in those messages
name);
}
}
}
return msg;
}
}
}