Author: bvahdat Date: Tue Jan 22 06:29:25 2013 New Revision: 1436759 URL: http://svn.apache.org/viewvc?rev=1436759&view=rev Log: CAMEL-5983: Better make use of ProducerTemplate.sendBody() instead of ProducerTemplate.request() API so that effectively an exception is thrown and not only gets attached on the returned Exchange. This would better match to the original purpose of this test.
Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java?rev=1436759&r1=1436758&r2=1436759&view=diff ============================================================================== --- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java (original) +++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java Tue Jan 22 06:29:25 2013 @@ -40,14 +40,16 @@ public class JettyHttpProducerSimulate40 // give Jetty time to startup properly Thread.sleep(1000); - Exchange exchange = template.request(url, null); - - assertNotNull(exchange.getException()); - HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, exchange.getException()); - assertEquals(404, cause.getStatusCode()); - assertEquals("http//0.0.0.0:" + getPort() + "/bar", cause.getUri()); - assertEquals("Page not found", cause.getResponseBody()); - assertNotNull(cause.getResponseHeaders()); + try { + template.sendBody(url, null); + fail("Should have thrown exception"); + } catch (Exception e) { + HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause()); + assertEquals(404, cause.getStatusCode()); + assertEquals("http//0.0.0.0:" + getPort() + "/bar", cause.getUri()); + assertEquals("Page not found", cause.getResponseBody()); + assertNotNull(cause.getResponseHeaders()); + } } @Override