ConstantPoolTest Class — netty Architecture
Architecture documentation for the ConstantPoolTest class in ConstantPoolTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c22de75b_e5fe_b5d4_e96a_04ad688a0dfb["ConstantPoolTest"] 85be841b_76f2_f4b2_9efd_5fa65e37dda1["ConstantPoolTest.java"] c22de75b_e5fe_b5d4_e96a_04ad688a0dfb -->|defined in| 85be841b_76f2_f4b2_9efd_5fa65e37dda1 75d2a0d7_71be_c26c_fd79_bb59aae48bd2["testCannotProvideNullName()"] c22de75b_e5fe_b5d4_e96a_04ad688a0dfb -->|method| 75d2a0d7_71be_c26c_fd79_bb59aae48bd2 682afe8a_747b_5098_c26f_320abfef2898["testUniqueness()"] c22de75b_e5fe_b5d4_e96a_04ad688a0dfb -->|method| 682afe8a_747b_5098_c26f_320abfef2898 15b65c0a_dd4f_8dcf_67c2_fe22108bde8f["testIdUniqueness()"] c22de75b_e5fe_b5d4_e96a_04ad688a0dfb -->|method| 15b65c0a_dd4f_8dcf_67c2_fe22108bde8f 1a30cabc_fd45_8f08_1cab_511b94566948["testCompare()"] c22de75b_e5fe_b5d4_e96a_04ad688a0dfb -->|method| 1a30cabc_fd45_8f08_1cab_511b94566948 455c0855_ac33_81a7_48c7_4e9b48ae6823["testComposedName()"] c22de75b_e5fe_b5d4_e96a_04ad688a0dfb -->|method| 455c0855_ac33_81a7_48c7_4e9b48ae6823
Relationship Graph
Source Code
common/src/test/java/io/netty/util/ConstantPoolTest.java lines 31–109
public class ConstantPoolTest {
static final class TestConstant extends AbstractConstant<TestConstant> {
TestConstant(int id, String name) {
super(id, name);
}
}
private static final ConstantPool<TestConstant> pool = new ConstantPool<TestConstant>() {
@Override
protected TestConstant newConstant(int id, String name) {
return new TestConstant(id, name);
}
};
@Test
public void testCannotProvideNullName() {
assertThrows(NullPointerException.class, new Executable() {
@Override
public void execute() {
pool.valueOf(null);
}
});
}
@Test
@SuppressWarnings("RedundantStringConstructorCall")
public void testUniqueness() {
TestConstant a = pool.valueOf(new String("Leroy"));
TestConstant b = pool.valueOf(new String("Leroy"));
assertSame(a, b);
}
@Test
public void testIdUniqueness() {
TestConstant one = pool.valueOf("one");
TestConstant two = pool.valueOf("two");
assertNotEquals(one.id(), two.id());
}
@Test
public void testCompare() {
TestConstant a = pool.valueOf("a_alpha");
TestConstant b = pool.valueOf("b_beta");
TestConstant c = pool.valueOf("c_gamma");
TestConstant d = pool.valueOf("d_delta");
TestConstant e = pool.valueOf("e_epsilon");
Set<TestConstant> set = new TreeSet<TestConstant>();
set.add(b);
set.add(c);
set.add(e);
set.add(d);
set.add(a);
TestConstant[] array = set.toArray(new TestConstant[0]);
assertEquals(5, array.length);
// Sort by name
Arrays.sort(array, new Comparator<TestConstant>() {
@Override
public int compare(TestConstant o1, TestConstant o2) {
return o1.name().compareTo(o2.name());
}
});
assertSame(a, array[0]);
assertSame(b, array[1]);
assertSame(c, array[2]);
assertSame(d, array[3]);
assertSame(e, array[4]);
}
@Test
public void testComposedName() {
TestConstant a = pool.valueOf(Object.class, "A");
assertEquals("java.lang.Object#A", a.name());
}
}
Source
Frequently Asked Questions
What is the ConstantPoolTest class?
ConstantPoolTest is a class in the netty codebase, defined in common/src/test/java/io/netty/util/ConstantPoolTest.java.
Where is ConstantPoolTest defined?
ConstantPoolTest is defined in common/src/test/java/io/netty/util/ConstantPoolTest.java at line 31.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free