You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2017/01/24 20:28:28 UTC
svn commit: r1780115 -
/jmeter/trunk/test/src/org/apache/jmeter/util/XPathUtilTest.java
Author: fschumacher
Date: Tue Jan 24 20:28:28 2017
New Revision: 1780115
URL: http://svn.apache.org/viewvc?rev=1780115&view=rev
Log:
Add some tests for XPathUtil
Added:
jmeter/trunk/test/src/org/apache/jmeter/util/XPathUtilTest.java (with props)
Added: jmeter/trunk/test/src/org/apache/jmeter/util/XPathUtilTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/util/XPathUtilTest.java?rev=1780115&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/util/XPathUtilTest.java (added)
+++ jmeter/trunk/test/src/org/apache/jmeter/util/XPathUtilTest.java Tue Jan 24 20:28:28 2017
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.jmeter.util;
+
+import static org.junit.Assert.*;
+
+import java.io.PrintStream;
+
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+
+public class XPathUtilTest {
+
+ @Test
+ public void testFormatXmlSimple() {
+ assertThat(XPathUtil.formatXml("<one foo='bar'>Test</one>"),
+ CoreMatchers.is("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<one foo=\"bar\">Test</one>\n"));
+ }
+
+ @Test
+ public void testFormatXmlComplex() {
+ assertThat(
+ XPathUtil.formatXml(
+ "<one foo='bar'><two/><three><four p=\"1\"/></three>...</one>"),
+ CoreMatchers.is("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<one foo=\"bar\">\n" + " <two/>\n" + " <three>\n"
+ + " <four p=\"1\"/>\n" + " </three>" + "..."
+ + "</one>\n"));
+ }
+
+ @Test()
+ public void testFormatXmlInvalid() {
+ PrintStream origErr = System.err;
+ // The parser will print an error, so let it go somewhere, where we will
+ // not see it
+ System.setErr(null);
+ assertThat("No well formed xml here", CoreMatchers
+ .is(XPathUtil.formatXml("No well formed xml here")));
+ System.setErr(origErr);
+ }
+}
Propchange: jmeter/trunk/test/src/org/apache/jmeter/util/XPathUtilTest.java
------------------------------------------------------------------------------
svn:eol-style = native