summaryrefslogtreecommitdiff
path: root/libxerces-c/tests
diff options
context:
space:
mode:
Diffstat (limited to 'libxerces-c/tests')
-rw-r--r--libxerces-c/tests/.gitignore3
-rw-r--r--libxerces-c/tests/build/.gitignore3
-rw-r--r--libxerces-c/tests/build/bootstrap.build8
-rw-r--r--libxerces-c/tests/build/root.build23
-rw-r--r--libxerces-c/tests/buildfile4
l---------libxerces-c/tests/dom-print/DOMPrint1
-rw-r--r--libxerces-c/tests/dom-print/buildfile6
-rw-r--r--libxerces-c/tests/dom-print/testscript20
-rw-r--r--libxerces-c/tests/net-accessor/NetAccessorTest.cpp167
-rw-r--r--libxerces-c/tests/net-accessor/buildfile11
-rw-r--r--libxerces-c/tests/net-accessor/handle-exception-as-error.patch35
-rw-r--r--libxerces-c/tests/net-accessor/testscript34
l---------libxerces-c/tests/psvi-writer/PSVIWriter1
-rw-r--r--libxerces-c/tests/psvi-writer/buildfile11
-rw-r--r--libxerces-c/tests/psvi-writer/testscript21
l---------libxerces-c/tests/sax-print/SAXPrint1
-rw-r--r--libxerces-c/tests/sax-print/buildfile6
-rw-r--r--libxerces-c/tests/sax-print/testscript20
l---------libxerces-c/tests/sax2-print/SAX2Print1
-rw-r--r--libxerces-c/tests/sax2-print/buildfile6
-rw-r--r--libxerces-c/tests/sax2-print/testscript20
21 files changed, 402 insertions, 0 deletions
diff --git a/libxerces-c/tests/.gitignore b/libxerces-c/tests/.gitignore
new file mode 100644
index 0000000..2e508a9
--- /dev/null
+++ b/libxerces-c/tests/.gitignore
@@ -0,0 +1,3 @@
+driver
+test/
+test-*/
diff --git a/libxerces-c/tests/build/.gitignore b/libxerces-c/tests/build/.gitignore
new file mode 100644
index 0000000..4a730a3
--- /dev/null
+++ b/libxerces-c/tests/build/.gitignore
@@ -0,0 +1,3 @@
+config.build
+root/
+bootstrap/
diff --git a/libxerces-c/tests/build/bootstrap.build b/libxerces-c/tests/build/bootstrap.build
new file mode 100644
index 0000000..2a03b3a
--- /dev/null
+++ b/libxerces-c/tests/build/bootstrap.build
@@ -0,0 +1,8 @@
+# file : tests/build/bootstrap.build
+# license : Apache License 2.0; see accompanying LICENSE file
+
+project = # Unnamed subproject.
+
+using config
+using dist
+using test
diff --git a/libxerces-c/tests/build/root.build b/libxerces-c/tests/build/root.build
new file mode 100644
index 0000000..7bf1cba
--- /dev/null
+++ b/libxerces-c/tests/build/root.build
@@ -0,0 +1,23 @@
+# file : tests/build/root.build
+# license : Apache License 2.0; see accompanying LICENSE file
+
+cxx.std = latest
+
+using cxx
+
+hxx{*}: extension = hpp
+cxx{*}: extension = cpp
+
+if ($cxx.target.system == 'win32-msvc')
+ cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
+
+if ($cxx.class == 'msvc')
+ cxx.coptions += /wd4251 /wd4275 /wd4800
+
+# Every exe{} in this subproject is by default a test.
+#
+exe{*}: test = true
+
+# Specify the test target for cross-testing.
+#
+test.target = $cxx.target
diff --git a/libxerces-c/tests/buildfile b/libxerces-c/tests/buildfile
new file mode 100644
index 0000000..f1869ed
--- /dev/null
+++ b/libxerces-c/tests/buildfile
@@ -0,0 +1,4 @@
+# file : tests/buildfile
+# license : Apache License 2.0; see accompanying LICENSE file
+
+./: {*/ -build/}
diff --git a/libxerces-c/tests/dom-print/DOMPrint b/libxerces-c/tests/dom-print/DOMPrint
new file mode 120000
index 0000000..d73574d
--- /dev/null
+++ b/libxerces-c/tests/dom-print/DOMPrint
@@ -0,0 +1 @@
+../../../upstream/samples/src/DOMPrint \ No newline at end of file
diff --git a/libxerces-c/tests/dom-print/buildfile b/libxerces-c/tests/dom-print/buildfile
new file mode 100644
index 0000000..76619a3
--- /dev/null
+++ b/libxerces-c/tests/dom-print/buildfile
@@ -0,0 +1,6 @@
+# file : tests/dom-print/buildfile
+# license : Apache License 2.0; see accompanying LICENSE file
+
+import libs = libxerces-c%lib{xerces-c}
+
+exe{driver}: DOMPrint/{hxx cxx}{*} $libs testscript
diff --git a/libxerces-c/tests/dom-print/testscript b/libxerces-c/tests/dom-print/testscript
new file mode 100644
index 0000000..f281d3f
--- /dev/null
+++ b/libxerces-c/tests/dom-print/testscript
@@ -0,0 +1,20 @@
+# file : tests/dom-print/testscript
+# license : Apache License 2.0; see accompanying LICENSE file
+
+: utf8
+:
+{
+ cat <<EOI >=f;
+ <?xml version="1.0" encoding="UTF-8"?>
+ <msg>
+ Mitteleuropäische catégorie
+ </msg>
+ EOI
+
+ $* -wfpp=on f >>~%EOO%
+ %<\?xml version="1.0" encoding="UTF-8".*\?>%
+ <msg>
+ Mitteleuropäische catégorie
+ </msg>
+ EOO
+}
diff --git a/libxerces-c/tests/net-accessor/NetAccessorTest.cpp b/libxerces-c/tests/net-accessor/NetAccessorTest.cpp
new file mode 100644
index 0000000..c2affbd
--- /dev/null
+++ b/libxerces-c/tests/net-accessor/NetAccessorTest.cpp
@@ -0,0 +1,167 @@
+/*
+ * 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.
+ */
+
+/*
+ * $Id$
+ *
+ */
+
+
+// ---------------------------------------------------------------------------
+// Includes
+// ---------------------------------------------------------------------------
+#include <xercesc/util/PlatformUtils.hpp>
+#include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/XMLURL.hpp>
+#include <xercesc/util/XMLNetAccessor.hpp>
+#include <xercesc/util/BinInputStream.hpp>
+
+#if defined(XERCES_NEW_IOSTREAMS)
+#include <iostream>
+#else
+#include <iostream.h>
+#endif
+
+XERCES_CPP_NAMESPACE_USE
+
+
+inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& os, const XMLCh* xmlStr)
+{
+ char* transcoded = XMLString::transcode(xmlStr);
+ os << transcoded;
+ XMLString::release(&transcoded);
+ return os;
+}
+
+
+void
+exercise(BinInputStream& stream)
+{
+ static float percents[] = { 1.0, 0.5, 0.25, 0.1, 0.15, 0.113, 0.333, 0.0015, 0.0013 };
+ int numPercents = sizeof(percents) / sizeof(float);
+
+ const unsigned int bufferMax = 4096;
+ XMLByte buffer[bufferMax];
+
+ int iteration = 0;
+ unsigned int bytesRead = 0;
+ do {
+ // Calculate a percentage of our maximum buffer size, going through
+ // them round-robin
+ float percent = percents[iteration % numPercents];
+ unsigned int bufCnt = (unsigned int)(bufferMax * percent);
+
+ // Check to make sure we didn't go out of bounds
+ if (bufCnt <= 0)
+ bufCnt = 1;
+ if (bufCnt > bufferMax)
+ bufCnt = bufferMax;
+
+ // Read bytes into our buffer
+ bytesRead = stream.readBytes(buffer, bufCnt);
+ //XERCES_STD_QUALIFIER cerr << "Read " << bytesRead << " bytes into a " << bufCnt << " byte buffer\n";
+
+ if (bytesRead > 0)
+ {
+ // Write the data to standard out
+ XERCES_STD_QUALIFIER cout.write((char*)buffer, bytesRead);
+ }
+
+ ++iteration;
+ } while (bytesRead > 0);
+}
+
+
+// ---------------------------------------------------------------------------
+// Program entry point
+// ---------------------------------------------------------------------------
+int
+main(int argc, char** argv)
+{
+ // Init the XML platform
+ try
+ {
+ XMLPlatformUtils::Initialize();
+ }
+
+ catch(const XMLException& toCatch)
+ {
+ XERCES_STD_QUALIFIER cout << "Error during platform init! Message:\n"
+ << toCatch.getMessage() << XERCES_STD_QUALIFIER endl;
+ return 1;
+ }
+
+ // Look for our one and only parameter
+ if (argc != 2)
+ {
+ XERCES_STD_QUALIFIER cerr << "Usage: NetAccessorTest url\n"
+ "\n"
+ "This test reads data from the given url and writes the result\n"
+ "to standard output.\n"
+ "\n"
+ "A variety of buffer sizes is are used during the test.\n"
+ "\n"
+ ;
+ exit(1);
+ }
+
+ // Get the URL
+ char* url = argv[1];
+
+ int r = 1;
+
+ // Do the test
+ try
+ {
+ XMLURL xmlURL(url);
+
+ // Get the netaccessor
+ XMLNetAccessor* na = XMLPlatformUtils::fgNetAccessor;
+ if (na == 0)
+ {
+ XERCES_STD_QUALIFIER cerr << "No netaccessor is available. Aborting.\n";
+ exit(2);
+ }
+
+ // Build a binary input stream
+ BinInputStream* is = na->makeNew(xmlURL);
+ if (is == 0)
+ {
+ XERCES_STD_QUALIFIER cerr << "No binary input stream created. Aborting.\n";
+ exit(3);
+ }
+
+ // Exercise the inputstream
+ exercise(*is);
+
+ // Delete the is
+ delete is;
+ r = 0;
+ }
+ catch(const XMLException& toCatch)
+ {
+ XERCES_STD_QUALIFIER cerr << "Exception during test:\n "
+ << toCatch.getMessage()
+ << XERCES_STD_QUALIFIER endl;
+ }
+
+ // And call the termination method
+ XMLPlatformUtils::Terminate();
+
+ return r;
+}
+
diff --git a/libxerces-c/tests/net-accessor/buildfile b/libxerces-c/tests/net-accessor/buildfile
new file mode 100644
index 0000000..ab3f79f
--- /dev/null
+++ b/libxerces-c/tests/net-accessor/buildfile
@@ -0,0 +1,11 @@
+# file : tests/net-accessor/buildfile
+# license : Apache License 2.0; see accompanying LICENSE file
+
+import libs = libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{*} $libs testscript
+
+# Disable MSVC warnings that pop up with /W3.
+#
+if ($cxx.class == 'msvc')
+ cxx.coptions += /wd4267 /wd4305
diff --git a/libxerces-c/tests/net-accessor/handle-exception-as-error.patch b/libxerces-c/tests/net-accessor/handle-exception-as-error.patch
new file mode 100644
index 0000000..674e5ba
--- /dev/null
+++ b/libxerces-c/tests/net-accessor/handle-exception-as-error.patch
@@ -0,0 +1,35 @@
+diff --git a/libxerces-c/tests/net-accessor/NetAccessorTest.cpp b/libxerces-c/tests/net-accessor/NetAccessorTest.cpp
+index 3bb735b..c2affbd 100644
+--- a/libxerces-c/tests/net-accessor/NetAccessorTest.cpp
++++ b/libxerces-c/tests/net-accessor/NetAccessorTest.cpp
+@@ -122,6 +122,8 @@ main(int argc, char** argv)
+ // Get the URL
+ char* url = argv[1];
+
++ int r = 1;
++
+ // Do the test
+ try
+ {
+@@ -148,11 +150,11 @@ main(int argc, char** argv)
+
+ // Delete the is
+ delete is;
+-
++ r = 0;
+ }
+ catch(const XMLException& toCatch)
+ {
+- XERCES_STD_QUALIFIER cout << "Exception during test:\n "
++ XERCES_STD_QUALIFIER cerr << "Exception during test:\n "
+ << toCatch.getMessage()
+ << XERCES_STD_QUALIFIER endl;
+ }
+@@ -160,6 +162,6 @@ main(int argc, char** argv)
+ // And call the termination method
+ XMLPlatformUtils::Terminate();
+
+- return 0;
++ return r;
+ }
+
diff --git a/libxerces-c/tests/net-accessor/testscript b/libxerces-c/tests/net-accessor/testscript
new file mode 100644
index 0000000..993423b
--- /dev/null
+++ b/libxerces-c/tests/net-accessor/testscript
@@ -0,0 +1,34 @@
+# file : tests/net-accessor/testscript
+# license : Apache License 2.0; see accompanying LICENSE file
+
+: http
+:
+$* 'http://www.example.com' >>~%EOO%
+ %.+
+ EOO
+
+# If we want to test how HTTPS URLs are handled, we need to make it work
+# always (see how the curl utility is packaged for details).
+#
+#\
+: https
+:
+: Test that an HTTPS URL is queried successfully using libcurl via the system
+: SSL backend on Windows and MacOS/Clang and fails for other targets that use
+: the OpenSSL backend by default.
+:
+if ($cxx.target.class == 'windows' || \
+ $cxx.target.class == 'macos' && $cxx.id == 'clang-apple')
+{
+ $* 'https://www.example.com' >>~%EOO%
+ %.+
+ EOO
+}
+else
+{
+ $* 'https://www.example.com' 2>>~%EOE% != 0
+ Exception during test:
+ %.+
+ EOE
+}
+#\
diff --git a/libxerces-c/tests/psvi-writer/PSVIWriter b/libxerces-c/tests/psvi-writer/PSVIWriter
new file mode 120000
index 0000000..92efd5c
--- /dev/null
+++ b/libxerces-c/tests/psvi-writer/PSVIWriter
@@ -0,0 +1 @@
+../../../upstream/samples/src/PSVIWriter \ No newline at end of file
diff --git a/libxerces-c/tests/psvi-writer/buildfile b/libxerces-c/tests/psvi-writer/buildfile
new file mode 100644
index 0000000..9a5d84d
--- /dev/null
+++ b/libxerces-c/tests/psvi-writer/buildfile
@@ -0,0 +1,11 @@
+# file : tests/psvi-writer/buildfile
+# license : Apache License 2.0; see accompanying LICENSE file
+
+import libs = libxerces-c%lib{xerces-c}
+
+exe{driver}: PSVIWriter/{hxx cxx}{*} $libs testscript
+
+# Disable MSVC warnings that pop up with /W3.
+#
+if ($cxx.class == 'msvc')
+ cxx.coptions += /wd4267
diff --git a/libxerces-c/tests/psvi-writer/testscript b/libxerces-c/tests/psvi-writer/testscript
new file mode 100644
index 0000000..5c3b58f
--- /dev/null
+++ b/libxerces-c/tests/psvi-writer/testscript
@@ -0,0 +1,21 @@
+# file : tests/psvi-writer/testscript
+# license : Apache License 2.0; see accompanying LICENSE file
+
+: utf8
+:
+{
+ cat <<EOI >=f;
+ <?xml version="1.0" encoding="UTF-8"?>
+ <msg>
+ Mitteleuropäische catégorie
+ </msg>
+ EOI
+
+ $* f >>~%EOO%
+ %.+
+ %\s*<textContent>%
+ %\s*Mitteleuropäische catégorie%
+ %\s*</textContent>%
+ %.+
+ EOO
+}
diff --git a/libxerces-c/tests/sax-print/SAXPrint b/libxerces-c/tests/sax-print/SAXPrint
new file mode 120000
index 0000000..7c61024
--- /dev/null
+++ b/libxerces-c/tests/sax-print/SAXPrint
@@ -0,0 +1 @@
+../../../upstream/samples/src/SAXPrint \ No newline at end of file
diff --git a/libxerces-c/tests/sax-print/buildfile b/libxerces-c/tests/sax-print/buildfile
new file mode 100644
index 0000000..ed3d22b
--- /dev/null
+++ b/libxerces-c/tests/sax-print/buildfile
@@ -0,0 +1,6 @@
+# file : tests/sax-print/buildfile
+# license : Apache License 2.0; see accompanying LICENSE file
+
+import libs = libxerces-c%lib{xerces-c}
+
+exe{driver}: SAXPrint/{hxx cxx}{*} $libs testscript
diff --git a/libxerces-c/tests/sax-print/testscript b/libxerces-c/tests/sax-print/testscript
new file mode 100644
index 0000000..cbc62e4
--- /dev/null
+++ b/libxerces-c/tests/sax-print/testscript
@@ -0,0 +1,20 @@
+# file : tests/sax-print/testscript
+# license : Apache License 2.0; see accompanying LICENSE file
+
+: utf8
+:
+{
+ cat <<EOI >=f;
+ <?xml version="1.0" encoding="UTF-8"?>
+ <msg>
+ Mitteleuropäische catégorie
+ </msg>
+ EOI
+
+ $* -x=UTF-8 f >>:EOO
+ <?xml version="1.0" encoding="UTF-8"?>
+ <msg>
+ Mitteleuropäische catégorie
+ </msg>
+ EOO
+}
diff --git a/libxerces-c/tests/sax2-print/SAX2Print b/libxerces-c/tests/sax2-print/SAX2Print
new file mode 120000
index 0000000..9f0238e
--- /dev/null
+++ b/libxerces-c/tests/sax2-print/SAX2Print
@@ -0,0 +1 @@
+../../../upstream/samples/src/SAX2Print \ No newline at end of file
diff --git a/libxerces-c/tests/sax2-print/buildfile b/libxerces-c/tests/sax2-print/buildfile
new file mode 100644
index 0000000..fd4875d
--- /dev/null
+++ b/libxerces-c/tests/sax2-print/buildfile
@@ -0,0 +1,6 @@
+# file : tests/sax2-print/buildfile
+# license : Apache License 2.0; see accompanying LICENSE file
+
+import libs = libxerces-c%lib{xerces-c}
+
+exe{driver}: SAX2Print/{hxx cxx}{*} $libs testscript
diff --git a/libxerces-c/tests/sax2-print/testscript b/libxerces-c/tests/sax2-print/testscript
new file mode 100644
index 0000000..6fedae3
--- /dev/null
+++ b/libxerces-c/tests/sax2-print/testscript
@@ -0,0 +1,20 @@
+# file : tests/sax2-print/testscript
+# license : Apache License 2.0; see accompanying LICENSE file
+
+: utf8
+:
+{
+ cat <<EOI >=f;
+ <?xml version="1.0" encoding="UTF-8"?>
+ <msg>
+ Mitteleuropäische catégorie
+ </msg>
+ EOI
+
+ $* -x=UTF-8 f >>:EOO
+ <?xml version="1.0" encoding="UTF-8"?>
+ <msg>
+ Mitteleuropäische catégorie
+ </msg>
+ EOO
+}