Reset StreamCache in getBodyAs to be able to re-read it, see #2724
This commit is contained in:
parent
04c30fb9d0
commit
99b02c0826
3 changed files with 32 additions and 4 deletions
|
|
@ -8,6 +8,7 @@ import akka.actor.ActorSystem;
|
|||
import akka.dispatch.Mapper;
|
||||
import akka.japi.Function;
|
||||
import org.apache.camel.NoTypeConversionAvailableException;
|
||||
import org.apache.camel.converter.stream.InputStreamCache;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
|
@ -100,6 +101,14 @@ public class MessageJavaTestBase {
|
|||
message("test1" , createMap("A", "1")).withHeaders(createMap("C", "3")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeAbleToReReadStreamCacheBody() throws Exception {
|
||||
CamelMessage msg = new CamelMessage(new InputStreamCache("test1".getBytes("utf-8")), empty);
|
||||
assertEquals("test1", msg.getBodyAs(String.class, camel.context()));
|
||||
// re-read
|
||||
assertEquals("test1", msg.getBodyAs(String.class, camel.context()));
|
||||
}
|
||||
|
||||
private static Set<String> createSet(String... entries) {
|
||||
HashSet<String> set = new HashSet<String>();
|
||||
set.addAll(Arrays.asList(entries));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue