You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2018/11/26 21:30:13 UTC
incubator-unomi git commit: UNOMI-214 Fix integration tests
Repository: incubator-unomi
Updated Branches:
refs/heads/master b8722499a -> 3bd954931
UNOMI-214 Fix integration tests
Signed-off-by: Serge Huber <sh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/3bd95493
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/3bd95493
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/3bd95493
Branch: refs/heads/master
Commit: 3bd954931df40639cabcb56c37359be940c12946
Parents: b872249
Author: Serge Huber <sh...@apache.org>
Authored: Mon Nov 26 22:30:06 2018 +0100
Committer: Serge Huber <sh...@apache.org>
Committed: Mon Nov 26 22:30:06 2018 +0100
----------------------------------------------------------------------
.../core/processor/LineSplitFailureHandler.java | 12 +++++++++++-
.../java/org/apache/unomi/itests/TestUtils.java | 19 ++++++++++++++++---
2 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/3bd95493/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitFailureHandler.java
----------------------------------------------------------------------
diff --git a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitFailureHandler.java b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitFailureHandler.java
index 78ecf5b..7543e48 100644
--- a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitFailureHandler.java
+++ b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitFailureHandler.java
@@ -34,7 +34,17 @@ public class LineSplitFailureHandler implements Processor {
public void process(Exchange exchange) throws Exception {
logger.debug("Route: {}, Error: {}", exchange.getProperty(Exchange.FAILURE_ROUTE_ID), exchange.getProperty(Exchange.EXCEPTION_CAUGHT));
ImportLineError importLineError = new ImportLineError();
- importLineError.setErrorCode(((BadProfileDataFormatException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT)).getCause().getMessage());
+ if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) instanceof BadProfileDataFormatException) {
+ importLineError.setErrorCode(((BadProfileDataFormatException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT)).getCause().getMessage());
+ } else if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) instanceof Throwable) {
+ Throwable rootCause = (Throwable) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+ while (rootCause.getCause() != null) {
+ rootCause = rootCause.getCause();
+ }
+ importLineError.setErrorCode(rootCause.getMessage());
+ } else {
+ importLineError.setErrorCode(exchange.getProperty(Exchange.EXCEPTION_CAUGHT).toString());
+ }
importLineError.setLineContent(exchange.getIn().getBody(String.class));
importLineError.setLineNb(((Integer) exchange.getProperty("CamelSplitIndex") + 1));
exchange.getIn().setHeader(RouterConstants.HEADER_FAILED_MESSAGE, new Boolean(true));
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/3bd95493/itests/src/test/java/org/apache/unomi/itests/TestUtils.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/unomi/itests/TestUtils.java b/itests/src/test/java/org/apache/unomi/itests/TestUtils.java
index d98d394..7cc9733 100644
--- a/itests/src/test/java/org/apache/unomi/itests/TestUtils.java
+++ b/itests/src/test/java/org/apache/unomi/itests/TestUtils.java
@@ -17,18 +17,31 @@
package org.apache.unomi.itests;
-import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
+import org.apache.unomi.persistence.spi.CustomObjectMapper;
import java.io.IOException;
public class TestUtils {
public static <T> T retrieveResourceFromResponse(HttpResponse response, Class<T> clazz) throws IOException {
+ if (response == null) {
+ return null;
+ }
+ if (response.getEntity() == null) {
+ return null;
+ }
String jsonFromResponse = EntityUtils.toString(response.getEntity());
- ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- return mapper.readValue(jsonFromResponse, clazz);
+ // ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ ObjectMapper mapper = CustomObjectMapper.getObjectMapper();
+ try {
+ T value = mapper.readValue(jsonFromResponse, clazz);
+ return value;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return null;
}
}