TestUtils Class — netty Architecture
Architecture documentation for the TestUtils class in TestUtils.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 1dee7150_7837_4c34_2e0a_b594ae531484["TestUtils"] afb57783_4b36_8e10_b5fb_f72f3688fb57["TestUtils.java"] 1dee7150_7837_4c34_2e0a_b594ae531484 -->|defined in| afb57783_4b36_8e10_b5fb_f72f3688fb57 d75da533_144a_c7de_966c_b12d5906fe28["isSctpSupported()"] 1dee7150_7837_4c34_2e0a_b594ae531484 -->|method| d75da533_144a_c7de_966c_b12d5906fe28 7b932b1b_6a2d_9fb4_8ce4_0b4db9fe066b["String()"] 1dee7150_7837_4c34_2e0a_b594ae531484 -->|method| 7b932b1b_6a2d_9fb4_8ce4_0b4db9fe066b b193577e_fe85_de46_bec3_7adf34e92b24["dump()"] 1dee7150_7837_4c34_2e0a_b594ae531484 -->|method| b193577e_fe85_de46_bec3_7adf34e92b24 f25a8461_3618_94fd_3176_45bda8f59b4f["compressHeapDumps()"] 1dee7150_7837_4c34_2e0a_b594ae531484 -->|method| f25a8461_3618_94fd_3176_45bda8f59b4f fe85b50f_9460_570e_a10e_a37f696b7aba["dumpHeap()"] 1dee7150_7837_4c34_2e0a_b594ae531484 -->|method| fe85b50f_9460_570e_a10e_a37f696b7aba 7ab9ccb0_64b3_3a1f_4e64_f959334b854c["dumpThreads()"] 1dee7150_7837_4c34_2e0a_b594ae531484 -->|method| 7ab9ccb0_64b3_3a1f_4e64_f959334b854c df9a60d1_525c_7795_eefb_6dcc560e5f20["TestUtils()"] 1dee7150_7837_4c34_2e0a_b594ae531484 -->|method| df9a60d1_525c_7795_eefb_6dcc560e5f20
Relationship Graph
Source Code
testsuite/src/main/java/io/netty/testsuite/util/TestUtils.java lines 44–243
public final class TestUtils {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(TestUtils.class);
private static final Method hotspotMXBeanDumpHeap;
private static final Object hotspotMXBean;
private static final long DUMP_PROGRESS_LOGGING_INTERVAL = TimeUnit.SECONDS.toNanos(5);
static {
// Retrieve the hotspot MXBean and its class if available.
Object mxBean;
Method mxBeanDumpHeap;
try {
Class<?> clazz = Class.forName("com.sun.management.HotSpotDiagnosticMXBean");
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
mxBean = ManagementFactory.newPlatformMXBeanProxy(
server, "com.sun.management:type=HotSpotDiagnostic", clazz);
mxBeanDumpHeap = clazz.getMethod("dumpHeap", String.class, boolean.class);
} catch (Exception ignored) {
mxBean = null;
mxBeanDumpHeap = null;
}
hotspotMXBean = mxBean;
hotspotMXBeanDumpHeap = mxBeanDumpHeap;
}
/**
* Return {@code true} if SCTP is supported by the running os.
*
*/
public static boolean isSctpSupported() {
String os = System.getProperty("os.name").toLowerCase(Locale.US);
if ("unix".equals(os) || "linux".equals(os) || "sun".equals(os) || "solaris".equals(os)) {
try {
// Try to open a SCTP Channel, by using reflection to make it compile also on
// operation systems that not support SCTP like OSX and Windows
Class<?> sctpChannelClass = Class.forName("com.sun.nio.sctp.SctpChannel");
Channel channel = (Channel) sctpChannelClass.getMethod("open").invoke(null);
try {
channel.close();
} catch (IOException e) {
// ignore
}
} catch (UnsupportedOperationException e) {
// This exception may get thrown if the OS does not have
// the shared libs installed.
System.out.print("Not supported: " + e.getMessage());
return false;
} catch (Throwable t) {
if (!(t instanceof IOException)) {
return false;
}
}
return true;
}
return false;
}
/**
* Returns the method name of the current test.
*/
public static String testMethodName(TestInfo testInfo) {
String testMethodName = testInfo.getTestMethod().map(new Function<Method, String>() {
@Override
public String apply(Method method) {
return method.getName();
}
}).orElse("[unknown method]");
if (testMethodName.contains("[")) {
testMethodName = testMethodName.substring(0, testMethodName.indexOf('['));
}
return testMethodName;
}
public static void dump(String filenamePrefix) throws IOException {
ObjectUtil.checkNotNull(filenamePrefix, "filenamePrefix");
final String timestamp = timestamp();
Source
Frequently Asked Questions
What is the TestUtils class?
TestUtils is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/util/TestUtils.java.
Where is TestUtils defined?
TestUtils is defined in testsuite/src/main/java/io/netty/testsuite/util/TestUtils.java at line 44.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free