NettyRuntimeTests Class — netty Architecture
Architecture documentation for the NettyRuntimeTests class in NettyRuntimeTests.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD f8a8d4a2_21ee_fb99_d44b_e7434e8cbd80["NettyRuntimeTests"] fbbd4074_8258_3d8b_111e_a023ac1d2b7e["NettyRuntimeTests.java"] f8a8d4a2_21ee_fb99_d44b_e7434e8cbd80 -->|defined in| fbbd4074_8258_3d8b_111e_a023ac1d2b7e ccd9205c_1b4c_db30_0dc4_98d3f5b88f10["testIllegalSet()"] f8a8d4a2_21ee_fb99_d44b_e7434e8cbd80 -->|method| ccd9205c_1b4c_db30_0dc4_98d3f5b88f10 a215ec4a_2017_7157_a2b8_fb0924beb05f["testMultipleSets()"] f8a8d4a2_21ee_fb99_d44b_e7434e8cbd80 -->|method| a215ec4a_2017_7157_a2b8_fb0924beb05f e7e663b1_d4d8_96ff_d69c_116d81285c0f["testSetAfterGet()"] f8a8d4a2_21ee_fb99_d44b_e7434e8cbd80 -->|method| e7e663b1_d4d8_96ff_d69c_116d81285c0f aa4f4027_a4c5_47e6_fd4c_ce729be0199c["testRacingGetAndGet()"] f8a8d4a2_21ee_fb99_d44b_e7434e8cbd80 -->|method| aa4f4027_a4c5_47e6_fd4c_ce729be0199c dc2e2d32_6bd0_143d_25aa_c746f2b8409a["Runnable()"] f8a8d4a2_21ee_fb99_d44b_e7434e8cbd80 -->|method| dc2e2d32_6bd0_143d_25aa_c746f2b8409a ae47057b_ae5b_56d0_505e_850862868238["testRacingGetAndSet()"] f8a8d4a2_21ee_fb99_d44b_e7434e8cbd80 -->|method| ae47057b_ae5b_56d0_505e_850862868238 accfe2dd_3f42_98e0_a20a_7c29a7bb509c["testGetWithSystemProperty()"] f8a8d4a2_21ee_fb99_d44b_e7434e8cbd80 -->|method| accfe2dd_3f42_98e0_a20a_7c29a7bb509c 91d829ae_f079_1aae_f292_baab7c434dd6["testGet()"] f8a8d4a2_21ee_fb99_d44b_e7434e8cbd80 -->|method| 91d829ae_f079_1aae_f292_baab7c434dd6 c66ca834_66fc_0dc3_a0c7_18e526fa3476["await()"] f8a8d4a2_21ee_fb99_d44b_e7434e8cbd80 -->|method| c66ca834_66fc_0dc3_a0c7_18e526fa3476
Relationship Graph
Source Code
common/src/test/java/io/netty/util/NettyRuntimeTests.java lines 32–202
public class NettyRuntimeTests {
@Test
public void testIllegalSet() {
final NettyRuntime.AvailableProcessorsHolder holder = new NettyRuntime.AvailableProcessorsHolder();
for (final int i : new int[] { -1, 0 }) {
try {
holder.setAvailableProcessors(i);
fail();
} catch (final IllegalArgumentException e) {
assertThat(e.getMessage()).contains("(expected: > 0)");
}
}
}
@Test
public void testMultipleSets() {
final NettyRuntime.AvailableProcessorsHolder holder = new NettyRuntime.AvailableProcessorsHolder();
holder.setAvailableProcessors(1);
try {
holder.setAvailableProcessors(2);
fail();
} catch (final IllegalStateException e) {
assertThat(e.getMessage()).contains("availableProcessors is already set to [1], rejecting [2]");
}
}
@Test
public void testSetAfterGet() {
final NettyRuntime.AvailableProcessorsHolder holder = new NettyRuntime.AvailableProcessorsHolder();
holder.availableProcessors();
try {
holder.setAvailableProcessors(1);
fail();
} catch (final IllegalStateException e) {
assertThat(e.getMessage()).contains("availableProcessors is already set");
}
}
@Test
public void testRacingGetAndGet() throws InterruptedException {
final NettyRuntime.AvailableProcessorsHolder holder = new NettyRuntime.AvailableProcessorsHolder();
final CyclicBarrier barrier = new CyclicBarrier(3);
final AtomicReference<IllegalStateException> firstReference = new AtomicReference<IllegalStateException>();
final Runnable firstTarget = getRunnable(holder, barrier, firstReference);
final Thread firstGet = new Thread(firstTarget);
firstGet.start();
final AtomicReference<IllegalStateException> secondRefernce = new AtomicReference<IllegalStateException>();
final Runnable secondTarget = getRunnable(holder, barrier, secondRefernce);
final Thread secondGet = new Thread(secondTarget);
secondGet.start();
// release the hounds
await(barrier);
// wait for the hounds
await(barrier);
firstGet.join();
secondGet.join();
assertNull(firstReference.get());
assertNull(secondRefernce.get());
}
private static Runnable getRunnable(
final NettyRuntime.AvailableProcessorsHolder holder,
final CyclicBarrier barrier,
final AtomicReference<IllegalStateException> reference) {
return new Runnable() {
@Override
public void run() {
await(barrier);
try {
holder.availableProcessors();
} catch (final IllegalStateException e) {
reference.set(e);
}
await(barrier);
Source
Frequently Asked Questions
What is the NettyRuntimeTests class?
NettyRuntimeTests is a class in the netty codebase, defined in common/src/test/java/io/netty/util/NettyRuntimeTests.java.
Where is NettyRuntimeTests defined?
NettyRuntimeTests is defined in common/src/test/java/io/netty/util/NettyRuntimeTests.java at line 32.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free