MultiSearchProcessorTest Class — netty Architecture
Architecture documentation for the MultiSearchProcessorTest class in MultiSearchProcessorTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a8e37b86_7953_7ee3_77cd_bf0850236222["MultiSearchProcessorTest"] 5a6ae38e_efba_1a07_5c71_3d67fd4c30e4["MultiSearchProcessorTest.java"] a8e37b86_7953_7ee3_77cd_bf0850236222 -->|defined in| 5a6ae38e_efba_1a07_5c71_3d67fd4c30e4 d97b0206_22d8_e3a9_f1a7_1303fbc74f3c["testSearchForMultiple()"] a8e37b86_7953_7ee3_77cd_bf0850236222 -->|method| d97b0206_22d8_e3a9_f1a7_1303fbc74f3c c275d49d_392d_9cdc_8b28_e7829b98d873["testSearchForMultipleOverlapping()"] a8e37b86_7953_7ee3_77cd_bf0850236222 -->|method| c275d49d_392d_9cdc_8b28_e7829b98d873 99afa85b_b5de_25c2_ede5_3c8adf8e69c1["findLongerNeedleInCaseOfSuffixMatch()"] a8e37b86_7953_7ee3_77cd_bf0850236222 -->|method| 99afa85b_b5de_25c2_ede5_3c8adf8e69c1 116a4472_a951_e809_485f_110d4e496074["bytes()"] a8e37b86_7953_7ee3_77cd_bf0850236222 -->|method| 116a4472_a951_e809_485f_110d4e496074
Relationship Graph
Source Code
buffer/src/test/java/io/netty/buffer/search/MultiSearchProcessorTest.java lines 25–107
public class MultiSearchProcessorTest {
@Test
public void testSearchForMultiple() {
final ByteBuf haystack = Unpooled.copiedBuffer("one two three one", CharsetUtil.UTF_8);
final int length = haystack.readableBytes();
final MultiSearchProcessor processor = AbstractMultiSearchProcessorFactory.newAhoCorasicSearchProcessorFactory(
bytes("one"),
bytes("two"),
bytes("three")
).newSearchProcessor();
assertEquals(-1, processor.getFoundNeedleId());
assertEquals(2, haystack.forEachByte(processor));
assertEquals(0, processor.getFoundNeedleId()); // index of "one" in needles[]
assertEquals(6, haystack.forEachByte(3, length - 3, processor));
assertEquals(1, processor.getFoundNeedleId()); // index of "two" in needles[]
assertEquals(12, haystack.forEachByte(7, length - 7, processor));
assertEquals(2, processor.getFoundNeedleId()); // index of "three" in needles[]
assertEquals(16, haystack.forEachByte(13, length - 13, processor));
assertEquals(0, processor.getFoundNeedleId()); // index of "one" in needles[]
assertEquals(-1, haystack.forEachByte(17, length - 17, processor));
haystack.release();
}
@Test
public void testSearchForMultipleOverlapping() {
final ByteBuf haystack = Unpooled.copiedBuffer("abcd", CharsetUtil.UTF_8);
final int length = haystack.readableBytes();
final MultiSearchProcessor processor = AbstractMultiSearchProcessorFactory.newAhoCorasicSearchProcessorFactory(
bytes("ab"),
bytes("bc"),
bytes("cd")
).newSearchProcessor();
assertEquals(1, haystack.forEachByte(processor));
assertEquals(0, processor.getFoundNeedleId()); // index of "ab" in needles[]
assertEquals(2, haystack.forEachByte(2, length - 2, processor));
assertEquals(1, processor.getFoundNeedleId()); // index of "bc" in needles[]
assertEquals(3, haystack.forEachByte(3, length - 3, processor));
assertEquals(2, processor.getFoundNeedleId()); // index of "cd" in needles[]
haystack.release();
}
@Test
public void findLongerNeedleInCaseOfSuffixMatch() {
final ByteBuf haystack = Unpooled.copiedBuffer("xabcx", CharsetUtil.UTF_8);
final MultiSearchProcessor processor1 = AbstractMultiSearchProcessorFactory.newAhoCorasicSearchProcessorFactory(
bytes("abc"),
bytes("bc")
).newSearchProcessor();
assertEquals(3, haystack.forEachByte(processor1)); // end of "abc" in haystack
assertEquals(0, processor1.getFoundNeedleId()); // index of "abc" in needles[]
final MultiSearchProcessor processor2 = AbstractMultiSearchProcessorFactory.newAhoCorasicSearchProcessorFactory(
bytes("bc"),
bytes("abc")
).newSearchProcessor();
assertEquals(3, haystack.forEachByte(processor2)); // end of "abc" in haystack
assertEquals(1, processor2.getFoundNeedleId()); // index of "abc" in needles[]
haystack.release();
}
private static byte[] bytes(String s) {
return s.getBytes(CharsetUtil.UTF_8);
}
Source
Frequently Asked Questions
What is the MultiSearchProcessorTest class?
MultiSearchProcessorTest is a class in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/search/MultiSearchProcessorTest.java.
Where is MultiSearchProcessorTest defined?
MultiSearchProcessorTest is defined in buffer/src/test/java/io/netty/buffer/search/MultiSearchProcessorTest.java at line 25.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free