perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r6247 - trunk/perfsonar-base/messaging/src/test/java/net/geant/per fsonar/messaging/xpath
Subject: perfsonar development work
List archive
[pS-dev] [GEANT/SA2/ps-java-services] r6247 - trunk/perfsonar-base/messaging/src/test/java/net/geant/per fsonar/messaging/xpath
Chronological Thread
- From:
- To:
- Subject: [pS-dev] [GEANT/SA2/ps-java-services] r6247 - trunk/perfsonar-base/messaging/src/test/java/net/geant/per fsonar/messaging/xpath
- Date: Mon, 25 Mar 2013 12:39:38 +0000 (GMT)
- Authentication-results: sfpop-ironport01.merit.edu; dkim=neutral (message not signed) header.i=none
Author: psnc.pietrzak
Date: 2013-03-25 12:39:38 +0000 (Mon, 25 Mar 2013)
New Revision: 6247
Added:
trunk/perfsonar-base/messaging/src/test/java/net/geant/perfsonar/messaging/xpath/InvalidDeserializerConfigurationTest.java
Log:
Added example with invalid xpath and a lack of namespace.
Added:
trunk/perfsonar-base/messaging/src/test/java/net/geant/perfsonar/messaging/xpath/InvalidDeserializerConfigurationTest.java
===================================================================
---
trunk/perfsonar-base/messaging/src/test/java/net/geant/perfsonar/messaging/xpath/InvalidDeserializerConfigurationTest.java
(rev 0)
+++
trunk/perfsonar-base/messaging/src/test/java/net/geant/perfsonar/messaging/xpath/InvalidDeserializerConfigurationTest.java
2013-03-25 12:39:38 UTC (rev 6247)
@@ -0,0 +1,42 @@
+package net.geant.perfsonar.messaging.xpath;
+
+import static net.geant.perfsonar.messaging.XPathDeserializer.any;
+import static net.geant.perfsonar.messaging.XPathDeserializer.whenXPath;
+import net.geant.perfsonar.messaging.XPathDeserializer;
+import net.geant.perfsonar.mp.sshtelnet.Command;
+import net.geant.perfsonar.templates.NMWG;
+
+import org.jaxen.saxpath.SAXPathException;
+import org.jaxen.saxpath.XPathSyntaxException;
+import org.junit.Before;
+import org.junit.Test;
+import org.xml.sax.InputSource;
+
+public class InvalidDeserializerConfigurationTest {
+
+ private static final String REQUEST_ID = "request1";
+ private XPathDeserializer deserializer;
+
+ @Before
+ public void givenDeserializer() {
+ XPathDeserializer.clearConfiguration();
+ deserializer = new XPathDeserializer();
+ }
+
+ @Test(expected = XPathSyntaxException.class)
+ public void shouldThrowWhenInvalidXPath() throws Exception {
+ whenXPath("invalid xpath").then(Command.class).setSyntax(
+ any(String.class));
+
+ deserializer.deserialize(new
InputSource(NMWG.toEchoRequest(REQUEST_ID)));
+ }
+
+ @Test(expected=SAXPathException.class)
+ public void shouldThrowWhenNamespaceIsNotDefined() throws Exception {
+ whenXPath(
+
"nmwg:message/nmwg:metadata/select:parameters/nmwg:parameter[name=startTime]/text()")
+
.then(Command.class).setSyntax(any(String.class));
+
+ deserializer.deserialize(new
InputSource(NMWG.toEchoRequest(REQUEST_ID)));
+ }
+}
- [pS-dev] [GEANT/SA2/ps-java-services] r6247 - trunk/perfsonar-base/messaging/src/test/java/net/geant/per fsonar/messaging/xpath, svn-noreply, 03/25/2013
Archive powered by MHonArc 2.6.16.