assertEquals(EntityStates.T_START_MULTIPART, entity.getState());
entity.advance();
assertEquals(EntityStates.T_PREAMBLE, entity.getState());
assertEquals("Hello!", IOUtils.toString(entity.getContentStream()));
EntityStateMachine p1 = entity.advance();
assertNotNull(p1);
assertEquals(EntityStates.T_START_BODYPART, p1.getState());
p1.advance();
assertEquals(EntityStates.T_START_HEADER, p1.getState());
p1.advance();
assertEquals(EntityStates.T_FIELD, p1.getState());
assertEquals("Content-Type", p1.getField().getName());
assertEquals(" text/plain; charset=US-ASCII", p1.getField().getBody());
p1.advance();
assertEquals(EntityStates.T_END_HEADER, p1.getState());
p1.advance();
assertEquals(EntityStates.T_BODY, p1.getState());
assertEquals("blah blah blah", IOUtils.toString(p1.getContentStream()));
p1.advance();
assertEquals(EntityStates.T_END_BODYPART, p1.getState());
p1.advance();
assertEquals(EntityStates.T_END_OF_STREAM, p1.getState());
EntityStateMachine p2 = entity.advance();
assertNotNull(p2);
assertEquals(EntityStates.T_START_BODYPART, p2.getState());
p2.advance();
assertEquals(EntityStates.T_START_HEADER, p2.getState());
p2.advance();
assertEquals(EntityStates.T_FIELD, p2.getState());
assertEquals("Content-Type", p2.getField().getName());
assertEquals(" text/plain; charset=US-ASCII", p2.getField().getBody());
p2.advance();
assertEquals(EntityStates.T_END_HEADER, p2.getState());
p2.advance();
assertEquals(EntityStates.T_BODY, p2.getState());
assertEquals("yada yada yada", IOUtils.toString(p2.getContentStream()));
p2.advance();
assertEquals(EntityStates.T_END_BODYPART, p2.getState());
p2.advance();
assertEquals(EntityStates.T_END_OF_STREAM, p2.getState());
entity.advance();
assertEquals(EntityStates.T_EPILOGUE, entity.getState());
assertEquals("Goodbye!", IOUtils.toString(entity.getContentStream()));
entity.advance();