Added two SOAP tests
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 6 May 2005 11:11:37 +0000 (11:11 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 6 May 2005 11:11:37 +0000 (11:11 +0000)
test/Makefile.am
test/tstsoap1.c [new file with mode: 0644]
test/tstsoap2.c [new file with mode: 0644]

index cff0364..c5c9ab8 100644 (file)
@@ -1,8 +1,9 @@
 ## Copyright (C) 1994-2004, Index Data
 ## All rights reserved.
-## $Id: Makefile.am,v 1.5 2005-02-25 09:37:53 adam Exp $
+## $Id: Makefile.am,v 1.6 2005-05-06 11:11:37 adam Exp $
 
-check_PROGRAMS = tsticonv tstnmem tstmatchstr tstwrbuf tstodr tstccl tstlog
+check_PROGRAMS = tsticonv tstnmem tstmatchstr tstwrbuf tstodr tstccl tstlog \
+ tstsoap1 tstsoap2
 check_SCRIPTS = tstcql.sh tstmarc.sh
 
 TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
@@ -41,3 +42,7 @@ tstccl_SOURCES = tstccl.c
 
 tstlog_SOURCES = tstlog.c
 
+tstsoap1_SOURCES = tstsoap1.c
+
+tstsoap2_SOURCES = tstsoap2.c
+
diff --git a/test/tstsoap1.c b/test/tstsoap1.c
new file mode 100644 (file)
index 0000000..2dd013c
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 1995-2005, Index Data ApS
+ * See the file LICENSE for details.
+ *
+ * $Id: tstsoap1.c,v 1.1 2005-05-06 11:11:37 adam Exp $
+ */
+
+#include <stdlib.h>
+#if HAVE_XML2
+#include <libxml/parser.h>
+#endif
+
+int main(int argc, char **argv)
+{
+#if HAVE_XML2
+    LIBXML_TEST_VERSION;
+
+    if (argc <= 1)
+    {
+       xmlChar *buf_out;
+       int len_out;
+       xmlDocPtr doc = xmlNewDoc("1.0");
+#if 0
+       const char *val = "jordbær"; /* makes xmlDocDumpMemory hang .. */
+#else
+       const char *val = "jordbaer"; /* OK */
+#endif
+       xmlNodePtr top = xmlNewNode(0, "top");
+       
+       xmlNewTextChild(top, 0, "sub", val);
+       xmlDocSetRootElement(doc, top);
+       
+       xmlDocDumpMemory(doc, &buf_out, &len_out);
+       printf("%*s", len_out, buf_out);
+    }
+#endif
+    return 0;
+}
+
+
diff --git a/test/tstsoap2.c b/test/tstsoap2.c
new file mode 100644 (file)
index 0000000..0fd766e
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 1995-2005, Index Data ApS
+ * See the file LICENSE for details.
+ *
+ * $Id: tstsoap2.c,v 1.1 2005-05-06 11:11:37 adam Exp $
+ */
+
+#include <stdlib.h>
+#if HAVE_XML2
+#include <libxml/parser.h>
+
+#include <yaz/srw.h>
+#include <yaz/soap.h>
+
+static void tst_srw(void)
+{
+    const char *charset = 0;
+    char *content_buf = 0;
+    int content_len;
+    int ret;
+    ODR o = odr_createmem(ODR_ENCODE);
+    Z_SOAP_Handler h[2] = {
+        {"http://www.loc.gov/zing/srw/", 0, (Z_SOAP_fun) yaz_srw_codec},
+        {0, 0, 0}
+    };
+    Z_SRW_PDU *sr = yaz_srw_get(o, Z_SRW_searchRetrieve_request);
+    Z_SOAP *p = odr_malloc(o, sizeof(*p));
+
+#if 0
+    sr->u.request->query.cql = "jordbær"; 
+#else
+    sr->u.request->query.cql = "jordbaer"; 
+#endif
+
+    p->which = Z_SOAP_generic;
+    p->u.generic = odr_malloc(o, sizeof(*p->u.generic));
+    p->u.generic->no = 0;
+    p->u.generic->ns = 0;
+    p->u.generic->p = sr;
+    p->ns = "http://schemas.xmlsoap.org/soap/envelope/";
+
+    ret = z_soap_codec_enc(o, &p, &content_buf, &content_len, h, charset);
+    odr_destroy(o);
+    if (ret)
+    {
+       printf("z_soap_codec_enc failed\n");
+       exit(1);
+    }
+}
+#endif
+
+int main(int argc, char **argv)
+{
+#if HAVE_XML2
+    LIBXML_TEST_VERSION
+    if (argc <= 1)
+    {
+       tst_srw();
+    }
+#endif
+    return 0;
+}