@Test
public void testProcessInChunks() throws Exception {

    CONNECT connect = new CONNECT();
    connect.cleanSession(false);
    connect.clientId(new UTF8Buffer("test"));
    connect.userName(new UTF8Buffer("user"));
    connect.password(new UTF8Buffer("pass"));
    DataByteArrayOutputStream output = new DataByteArrayOutputStream();
    wireFormat.marshal(connect.encode(), output);
    Buffer marshalled = output.toBuffer();
    DataByteArrayInputStream input = new DataByteArrayInputStream(marshalled);
    int first = marshalled.length() / 2;
    int second = marshalled.length() - first;
    codec.parse(input, first);
    codec.parse(input, second);
    assertTrue(!frames.isEmpty());
    assertEquals(1, frames.size());
    connect = new CONNECT().decode(frames.get(0));
    LOG.info("Unmarshalled: {}", connect);
    assertFalse(connect.cleanSession());
    assertEquals("user", connect.userName().toString());
    assertEquals("pass", connect.password().toString());
    assertEquals("test", connect.clientId().toString());
}