@Test
  public void testFragmentedUnmarshalling() throws IOException {
    MarshallerFactory marshallerFactory = createMarshallerFactory();
    MarshallingConfiguration configuration = createMarshallingConfig();

    DecoderEmbedder<Object> decoder =
        new DecoderEmbedder<Object>(createDecoder(marshallerFactory, configuration, 0));

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
    marshaller.start(Marshalling.createByteOutput(bout));
    marshaller.writeObject(testObject);
    marshaller.finish();
    marshaller.close();

    byte[] testBytes = bout.toByteArray();

    ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(testBytes);
    ChannelBuffer slice = buffer.readSlice(2);

    decoder.offer(slice);
    decoder.offer(buffer);
    assertTrue(decoder.finish());

    String unmarshalled = (String) decoder.poll();

    Assert.assertEquals(testObject, unmarshalled);

    Assert.assertNull(decoder.poll());
  }
  @Test
  public void testTooBigObject() throws IOException {
    MarshallerFactory marshallerFactory = createMarshallerFactory();
    MarshallingConfiguration configuration = createMarshallingConfig();

    MarshallingDecoder mDecoder = createDecoder(marshallerFactory, configuration, 1);
    DecoderEmbedder<Object> decoder = new DecoderEmbedder<Object>(mDecoder);

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
    marshaller.start(Marshalling.createByteOutput(bout));
    marshaller.writeObject(testObject);
    marshaller.finish();
    marshaller.close();

    byte[] testBytes = bout.toByteArray();

    try {
      decoder.offer(ChannelBuffers.wrappedBuffer(testBytes));
      fail();
    } catch (CodecEmbedderException e) {
      assertEquals(TooLongFrameException.class, e.getCause().getClass());
    }
  }