You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2017/04/09 21:02:18 UTC
camel git commit: let's better make use of the
TestSupport#assertIsInstanceOf API
Repository: camel
Updated Branches:
refs/heads/master d920f17c4 -> 60fb09108
let's better make use of the TestSupport#assertIsInstanceOf API
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/60fb0910
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/60fb0910
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/60fb0910
Branch: refs/heads/master
Commit: 60fb091088866a885cdb6771736ff8798cae5b1b
Parents: d920f17
Author: Babak Vahdat <bv...@apache.org>
Authored: Sun Apr 9 23:02:05 2017 +0200
Committer: Babak Vahdat <bv...@apache.org>
Committed: Sun Apr 9 23:02:05 2017 +0200
----------------------------------------------------------------------
.../UndertowProducerThrowExceptionOnFailureTest.java | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/60fb0910/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowProducerThrowExceptionOnFailureTest.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowProducerThrowExceptionOnFailureTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowProducerThrowExceptionOnFailureTest.java
index 9675080..e00e5bd 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowProducerThrowExceptionOnFailureTest.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowProducerThrowExceptionOnFailureTest.java
@@ -28,13 +28,8 @@ public class UndertowProducerThrowExceptionOnFailureTest extends BaseUndertowTes
@Test
public void testFailWithoutException() throws Exception {
- try {
- String out = template().requestBody("undertow:http://localhost:{{port}}/fail?throwExceptionOnFailure=false", null, String.class);
- assertEquals("Fail", out);
- } catch (Throwable t) {
- t.printStackTrace();
- fail("Should not throw an exception");
- }
+ String out = template().requestBody("undertow:http://localhost:{{port}}/fail?throwExceptionOnFailure=false", null, String.class);
+ assertEquals("Fail", out);
}
@Test
@@ -43,7 +38,7 @@ public class UndertowProducerThrowExceptionOnFailureTest extends BaseUndertowTes
String out = template().requestBody("undertow:http://localhost:{{port}}/fail?throwExceptionOnFailure=true", null, String.class);
fail("Should throw an exception");
} catch (CamelExecutionException e) {
- HttpOperationFailedException cause = (HttpOperationFailedException) e.getCause();
+ HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
assertEquals(404, cause.getStatusCode());
}
}
@@ -55,11 +50,9 @@ public class UndertowProducerThrowExceptionOnFailureTest extends BaseUndertowTes
.withHeader(Exchange.HTTP_METHOD, "PUT")
.withBody("This is not JSON format")
.request(String.class);
-
fail("Should throw an exception");
} catch (CamelExecutionException e) {
- HttpOperationFailedException httpException = (HttpOperationFailedException) e.getCause();
-
+ HttpOperationFailedException httpException = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
assertEquals(400, httpException.getStatusCode());
assertEquals("text/plain", httpException.getResponseHeaders().get(Exchange.CONTENT_TYPE));
assertEquals("Invalid json data", httpException.getResponseBody());