GlobalEventExecutorTest Class — netty Architecture
Architecture documentation for the GlobalEventExecutorTest class in GlobalEventExecutorTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD f5a88566_416e_7970_655d_74968e21adb8["GlobalEventExecutorTest"] 44309757_2eb4_5cd2_89e2_4f4eaea13a2f["GlobalEventExecutorTest.java"] f5a88566_416e_7970_655d_74968e21adb8 -->|defined in| 44309757_2eb4_5cd2_89e2_4f4eaea13a2f 8db08280_f5f0_f88a_32ce_ecf039dd0c8c["setUp()"] f5a88566_416e_7970_655d_74968e21adb8 -->|method| 8db08280_f5f0_f88a_32ce_ecf039dd0c8c 18fde39f_bab9_995e_d922_cf54eb7ed932["testAutomaticStartStop()"] f5a88566_416e_7970_655d_74968e21adb8 -->|method| 18fde39f_bab9_995e_d922_cf54eb7ed932 f52cce85_0dbd_2013_8c9d_bcb4404863a2["testScheduledTasks()"] f5a88566_416e_7970_655d_74968e21adb8 -->|method| f52cce85_0dbd_2013_8c9d_bcb4404863a2 1daf62c2_7d3f_df4c_401c_94f838678ae9["testThreadGroup()"] f5a88566_416e_7970_655d_74968e21adb8 -->|method| 1daf62c2_7d3f_df4c_401c_94f838678ae9 114aae51_9c1b_3b1a_69d4_33071e4e71da["testTakeTask()"] f5a88566_416e_7970_655d_74968e21adb8 -->|method| 114aae51_9c1b_3b1a_69d4_33071e4e71da d3bf0caa_8e0d_653b_67ee_796c6213c734["testTakeTaskAlwaysHasTask()"] f5a88566_416e_7970_655d_74968e21adb8 -->|method| d3bf0caa_8e0d_653b_67ee_796c6213c734
Relationship Graph
Source Code
common/src/test/java/io/netty/util/concurrent/GlobalEventExecutorTest.java lines 32–177
public class GlobalEventExecutorTest {
private static final GlobalEventExecutor e = GlobalEventExecutor.INSTANCE;
@BeforeEach
public void setUp() throws Exception {
// Wait until the global executor is stopped (just in case there is a task running due to previous test cases)
for (;;) {
if (e.thread == null || !e.thread.isAlive()) {
break;
}
Thread.sleep(50);
}
}
@Test
@Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testAutomaticStartStop() throws Exception {
final TestRunnable task = new TestRunnable(500);
e.execute(task);
// Ensure the new thread has started.
Thread thread = e.thread;
assertNotNull(thread);
assertTrue(thread.isAlive());
thread.join();
assertTrue(task.ran.get());
// Ensure another new thread starts again.
task.ran.set(false);
e.execute(task);
assertNotSame(e.thread, thread);
thread = e.thread;
thread.join();
assertTrue(task.ran.get());
}
@Test
@Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testScheduledTasks() throws Exception {
TestRunnable task = new TestRunnable(0);
ScheduledFuture<?> f = e.schedule(task, 1500, TimeUnit.MILLISECONDS);
f.sync();
assertTrue(task.ran.get());
// Ensure the thread is still running.
Thread thread = e.thread;
assertNotNull(thread);
assertTrue(thread.isAlive());
thread.join();
}
// ensure that when a task submission causes a new thread to be created, the thread inherits the thread group of the
// submitting thread
@Test
@Timeout(value = 2000, unit = TimeUnit.MILLISECONDS)
public void testThreadGroup() throws InterruptedException {
final ThreadGroup group = new ThreadGroup("group");
final AtomicReference<ThreadGroup> capturedGroup = new AtomicReference<ThreadGroup>();
final Thread thread = new Thread(group, new Runnable() {
@Override
public void run() {
final Thread t = e.threadFactory.newThread(new Runnable() {
@Override
public void run() {
}
});
capturedGroup.set(t.getThreadGroup());
}
});
thread.start();
thread.join();
assertEquals(group, capturedGroup.get());
}
Source
Frequently Asked Questions
What is the GlobalEventExecutorTest class?
GlobalEventExecutorTest is a class in the netty codebase, defined in common/src/test/java/io/netty/util/concurrent/GlobalEventExecutorTest.java.
Where is GlobalEventExecutorTest defined?
GlobalEventExecutorTest is defined in common/src/test/java/io/netty/util/concurrent/GlobalEventExecutorTest.java at line 32.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free