use of com.ctrip.xpipe.redis.core.protocal.protocal.AbstractBulkStringEoFJudger.BulkStringLengthEofJudger in project x-pipe by ctripcorp.
the class BulkStringEofJudgerTest method testLen.
@Test
public void testLen() {
int expectedLen = 1 << 20;
BulkStringLengthEofJudger judger = new BulkStringLengthEofJudger(expectedLen);
for (int i = 0; i < expectedLen - 1; i++) {
JudgeResult result = judger.end(Unpooled.wrappedBuffer("a".getBytes()));
Assert.assertFalse(result.isEnd());
Assert.assertEquals(1, result.getReadLen());
}
JudgeResult result = judger.end(Unpooled.wrappedBuffer("a".getBytes()));
Assert.assertTrue(result.isEnd());
Assert.assertEquals(1, result.getReadLen());
result = judger.end(Unpooled.wrappedBuffer("a".getBytes()));
Assert.assertTrue(result.isEnd());
Assert.assertEquals(0, result.getReadLen());
try {
result = judger.end(Unpooled.wrappedBuffer("a".getBytes()));
Assert.fail();
} catch (Exception e) {
}
}
Aggregations