camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAMEL-6294) StreamCache doesn't work as expected
Date Sun, 26 May 2013 13:05:20 GMT

     [ https://issues.apache.org/jira/browse/CAMEL-6294?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Claus Ibsen updated CAMEL-6294:
-------------------------------

    Fix Version/s:     (was: 2.10.5)
                   Future
       Issue Type: Improvement  (was: Bug)

Stream cache has been implemented like this since 1.x days.


                
> StreamCache doesn't work as expected
> ------------------------------------
>
>                 Key: CAMEL-6294
>                 URL: https://issues.apache.org/jira/browse/CAMEL-6294
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.10.4
>         Environment: Debian 6.0
>            Reporter: Ulrich Kramer
>            Assignee: Willem Jiang
>             Fix For: Future
>
>         Attachments: cached.tgz, cached.tgz
>
>
> The following Unittests fail:
> {code}
> package com.sap.camel.util;
> import java.io.InputStream;
> import junit.framework.Assert;
> import org.apache.camel.CamelContext;
> import org.apache.camel.Exchange;
> import org.apache.camel.Message;
> import org.apache.camel.converter.stream.CachedOutputStream;
> import org.apache.camel.impl.DefaultCamelContext;
> import org.apache.camel.impl.DefaultExchange;
> import org.testng.annotations.Test;
> public class StreamCacheBugs {
> 	
> 	private CamelContext context;
> 	public void setUp() {
> 		
> 		context = new DefaultCamelContext();
> 	}
> 	@Test
> 	public void multipleConvertionsYielsToEmptyBody() throws Exception {
> 		Exchange exchange = new DefaultExchange(context);
> 		Message msg = exchange.getIn();
> 		CachedOutputStream out = new CachedOutputStream(exchange);
> 		out.write("Hello World".getBytes());
> 		msg.setBody(out.getStreamCache());
> 		Assert.assertEquals(msg.getBody(String.class), "Hello World");
> 		Assert.assertEquals(msg.getBody(String.class), "Hello World");
> 	}
> 	@Test
> 	public void closingInputStreamYieldsToException() throws Exception {
> 		Exchange exchange = new DefaultExchange(context);
> 		Message msg = exchange.getIn();
> 		CachedOutputStream out = new CachedOutputStream(exchange);
> 		for ( int i = 0 ; i < 10000; i++) out.write("0123456789".getBytes());
> 		msg.setBody(out.getStreamCache());
> 		InputStream in = msg.getBody(InputStream.class);
> 		in.read();
> 		in.close();
> 		msg.getBody(String.class);
> 	}
> 	
> 	@Test
> 	public void cachedOutputStreamsShouldBeClosable() throws Exception {
> 		Exchange exchange = new DefaultExchange(context);
> 		Message msg = exchange.getIn();
> 		CachedOutputStream out = new CachedOutputStream(exchange);
> 		for ( int i = 0 ; i < 10000; i++) out.write("0123456789".getBytes());
> 		msg.setBody(out.getStreamCache());
> 		out.close();
> 		msg.getBody(String.class);
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message