use of com.ctrip.xpipe.redis.core.protocal.protocal.AbstractBulkStringEoFJudger.BulkStringEofMarkJudger in project x-pipe by ctripcorp.
the class BulkStringEofJudgerTest method testEofMarkSmall.
@Test
public void testEofMarkSmall() {
byte[] eofmark = randomString(RedisClientProtocol.RUN_ID_LENGTH).getBytes();
BulkStringEofMarkJudger judger = new BulkStringEofMarkJudger(eofmark);
for (int i = 0; i < (1 << 20); i++) {
JudgeResult result = judger.end(Unpooled.wrappedBuffer(randomString(1).getBytes()));
Assert.assertFalse(result.isEnd());
Assert.assertEquals(1, result.getReadLen());
}
for (int i = 0; i < eofmark.length; i++) {
JudgeResult result = judger.end(Unpooled.wrappedBuffer(new byte[] { eofmark[i] }));
Assert.assertEquals(1, result.getReadLen());
if (i < eofmark.length - 1) {
Assert.assertFalse(result.isEnd());
} else {
Assert.assertTrue(result.isEnd());
}
}
}
use of com.ctrip.xpipe.redis.core.protocal.protocal.AbstractBulkStringEoFJudger.BulkStringEofMarkJudger in project x-pipe by ctripcorp.
the class BulkStringEofJudgerTest method testEofMarkBig.
@Test
public void testEofMarkBig() {
byte[] eofmark = randomString(RedisClientProtocol.RUN_ID_LENGTH).getBytes();
BulkStringEofMarkJudger judger = new BulkStringEofMarkJudger(eofmark);
String data = randomString();
JudgeResult result = judger.end(Unpooled.wrappedBuffer(data.getBytes()));
Assert.assertFalse(result.isEnd());
Assert.assertEquals(data.length(), result.getReadLen());
String real = randomString() + new String(eofmark);
result = judger.end(Unpooled.wrappedBuffer(real.getBytes()));
Assert.assertTrue(result.isEnd());
Assert.assertEquals(real.length(), result.getReadLen());
}
Aggregations