use of org.glassfish.admin.amx.util.AMXDebugStuff in project Payara by payara.
the class CoverageInfoAnalyzer method getCoverage.
public Map<String, CoverageInfo> getCoverage(final Set<AMX> candidates) {
final Map<String, CoverageInfo> coverageMap = new HashMap<String, CoverageInfo>();
for (final AMX amx : candidates) {
final AMXDebugStuff debug = mTestUtil.asAMXDebugStuff(amx);
final CoverageInfo coverageInfo = debug.getCoverageInfo();
assert (coverageInfo != null);
handleSpecialCases(coverageInfo);
final String j2eeType = amx.getJ2EEType();
final CoverageInfo existing = coverageMap.get(j2eeType);
if (existing != null) {
existing.merge(coverageInfo);
} else {
coverageMap.put(j2eeType, coverageInfo);
}
}
return coverageMap;
}
use of org.glassfish.admin.amx.util.AMXDebugStuff in project Payara by payara.
the class RunMeFirstTest method initCoverageInfos.
private void initCoverageInfos() {
final Set<AMX> all = getAllAMX();
// set the AMX-DEBUG flags on
final String AMX_DEBUG = "-DAMX-DEBUG.enabled=true";
final String AMX_DEBUG2 = "-DAMX-DEBUG=true";
// set AMX-DEBUG.enabled=true in all ConfigConfig JVM options
final Map<String, ConfigConfig> configs = getDomainConfig().getConfigsConfig().getConfigConfigMap();
for (final ConfigConfig config : configs.values()) {
final JavaConfig jc = config.getJavaConfig();
final String[] opt = jc.getJVMOptions();
final Set<String> jvmOptions = GSetUtil.newStringSet(opt == null ? new String[0] : opt);
if (!(jvmOptions.contains(AMX_DEBUG) || jvmOptions.contains(AMX_DEBUG2))) {
jvmOptions.add(AMX_DEBUG);
jc.setJVMOptions(GSetUtil.toStringArray(jvmOptions));
// don't warn for default-config; it's not used by a running server
if (!config.getName().equals("default-config")) {
warning("Enabled AMX-DEBUG for config " + config.getName() + " (restart required)");
}
}
}
// setup default stuff
final AMXDebugSupportMBean debug = getAMXDebugSupportMBean();
debug.setAll(true);
debug.setDefaultDebug(true);
debug.getOutputIDs();
for (final AMX amx : all) {
final AMXDebugStuff debugStuff = getTestUtil().asAMXDebugStuff(amx);
if (debugStuff == null) {
continue;
}
try {
debugStuff.enableAMXDebug(true);
} catch (Throwable t) {
warning("Couldn't enableAMXDebug() for " + amx.getJ2EEType());
}
try {
debugStuff.enableCoverageInfo(true);
debugStuff.clearCoverageInfo();
} catch (Throwable t) {
warning("Couldn't enableCoverageInfo for " + amx.getJ2EEType());
}
}
}
use of org.glassfish.admin.amx.util.AMXDebugStuff in project Payara by payara.
the class TestUtil method asAMXDebugStuff.
public AMXDebugStuff asAMXDebugStuff(final AMX amx) {
final String[] attrNames = Util.getExtra(amx).getAttributeNames();
AMXDebugStuff result = null;
if (GSetUtil.newUnmodifiableStringSet(attrNames).contains("AMXDebug")) {
final ProxyFactory factory = Util.getExtra(amx).getProxyFactory();
try {
final Class amxClass = ClassUtil.getClassFromName(Util.getExtra(amx).getInterfaceName());
final Class[] interfaces = new Class[] { amxClass, AMXDebugStuff.class };
final ObjectName objectName = Util.getObjectName(amx);
return (AMXDebugStuff) factory.newProxyInstance(objectName, interfaces);
} catch (Exception e) {
trace(ExceptionUtil.toString(e));
throw new RuntimeException(e);
}
}
return result;
}
use of org.glassfish.admin.amx.util.AMXDebugStuff in project Payara by payara.
the class AMXTest method testToString.
public void testToString() {
final long start = now();
final Set<AMX> all = getAllAMX();
for (final AMX amx : all) {
final AMXDebugStuff debug = getTestUtil().asAMXDebugStuff(amx);
if (debug != null) {
final String s = debug.getImplString(true);
assert (s.length() != 0);
}
}
printElapsed("testToString", all.size(), start);
}
Aggregations