From 3a2988e913ffc82d854e85afbc783b7f566f7faf Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Mon, 18 May 2009 22:01:27 +0000 Subject: [PATCH] INT-652 --- .../integration/xml/splitter/XPathMessageSplitter.java | 8 +++++++- .../xml/splitter/XPathMessageSplitterTests.java | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/splitter/XPathMessageSplitter.java b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/splitter/XPathMessageSplitter.java index 08c92274c4..08fd2262a7 100644 --- a/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/splitter/XPathMessageSplitter.java +++ b/org.springframework.integration.xml/src/main/java/org/springframework/integration/xml/splitter/XPathMessageSplitter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,6 +105,12 @@ public class XPathMessageSplitter extends AbstractMessageSplitter { payload = xmlPayloadConverter.convertToDocument(payload); result = splitStringPayload(message); } + else { + throw new IllegalArgumentException( + "Unsupported payload type [" + payload.getClass().getName() + + "]. The XPathMessageSplitter only accepts [" + Node.class.getName() + + "] or [java.lang.String] typed payloads."); + } return result; } catch (ParserConfigurationException e) { diff --git a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/splitter/XPathMessageSplitterTests.java b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/splitter/XPathMessageSplitterTests.java index 53adb3157a..864f27f593 100644 --- a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/splitter/XPathMessageSplitterTests.java +++ b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/splitter/XPathMessageSplitterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,4 +95,9 @@ public class XPathMessageSplitterTests { } } + @Test(expected = MessagingException.class) + public void invalidPayloadType() { + splitter.handleMessage(new GenericMessage(123)); + } + }