From e8025256fa32ac74dee34da5ca49b0c8ac41508e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 6 May 2005 11:11:37 +0000 Subject: [PATCH] Added two SOAP tests --- test/Makefile.am | 9 ++++++-- test/tstsoap1.c | 40 +++++++++++++++++++++++++++++++++++ test/tstsoap2.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 test/tstsoap1.c create mode 100644 test/tstsoap2.c diff --git a/test/Makefile.am b/test/Makefile.am index cff0364..c5c9ab8 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -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 index 0000000..2dd013c --- /dev/null +++ b/test/tstsoap1.c @@ -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 +#if HAVE_XML2 +#include +#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 index 0000000..0fd766e --- /dev/null +++ b/test/tstsoap2.c @@ -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 +#if HAVE_XML2 +#include + +#include +#include + +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; +} -- 1.7.10.4