X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=test%2Ftest_solr.c;h=e075ee1c29f5383d0b69efadb16481ebdb2d0b17;hp=a25765c19c19eb05cdeebb6155ae1ab04c2e4ad7;hb=70ce06b6fcbe3a53e94111ecedf0312848647c1b;hpb=5242cb5a8634bfa38b9333ff7f903e718ac6e292 diff --git a/test/test_solr.c b/test/test_solr.c index a25765c..e075ee1 100644 --- a/test/test_solr.c +++ b/test/test_solr.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2012 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ #if HAVE_CONFIG_H @@ -8,6 +8,7 @@ #include #include +#include #if YAZ_HAVE_XML2 #include #endif @@ -65,9 +66,11 @@ void tst_encoding(void) Z_SRW_PDU *sr = yaz_srw_get_pdu(odr, Z_SRW_searchRetrieve_request, "1.2"); + sr->u.request->query = "title:solr"; YAZ_CHECK(compare_solr_req( odr, sr, 0, - "GET Default/select? HTTP/1.1\r\n" + "GET Default/select?defType=lucene&q=title%3Asolr " + "HTTP/1.1\r\n" "User-Agent: YAZ/" YAZ_VERSION "\r\n" "Host: localhost\r\n" "Content-Type: text/xml\r\n\r\n")); @@ -76,9 +79,11 @@ void tst_encoding(void) { Z_SRW_PDU *sr = yaz_srw_get_pdu(odr, Z_SRW_searchRetrieve_request, "1.2"); + sr->u.request->query = "title:solr"; YAZ_CHECK(compare_solr_req( odr, sr, "utf-8", - "GET Default/select? HTTP/1.1\r\n" + "GET Default/select?defType=lucene&q=title%3Asolr " + "HTTP/1.1\r\n" "User-Agent: YAZ/" YAZ_VERSION "\r\n" "Host: localhost\r\n" "Content-Type: text/xml; charset=utf-8\r\n\r\n")); @@ -88,14 +93,14 @@ void tst_encoding(void) Z_SRW_PDU *sr = yaz_srw_get_pdu(odr, Z_SRW_searchRetrieve_request, "1.2"); - sr->u.request->query_type = Z_SRW_query_type_cql; - sr->u.request->query.cql = "title:solr"; + sr->u.request->query = "title:solr"; sr->u.request->startRecord = odr_intdup(odr, 3); sr->u.request->maximumRecords = odr_intdup(odr, 10); YAZ_CHECK(compare_solr_req( odr, sr, 0, - "GET Default/select?q=title%3Asolr&start=2&rows=10" + "GET Default/select?defType=lucene&q=title%3Asolr&" + "start=2&rows=10" " HTTP/1.1\r\n" "User-Agent: YAZ/" YAZ_VERSION "\r\n" "Host: localhost\r\n" @@ -106,8 +111,7 @@ void tst_encoding(void) Z_SRW_PDU *sr = yaz_srw_get_pdu(odr, Z_SRW_searchRetrieve_request, "1.2"); - sr->u.request->query_type = Z_SRW_query_type_cql; - sr->u.request->query.cql = "title:solr"; + sr->u.request->query = "title:solr"; sr->u.request->startRecord = odr_intdup(odr, 3); sr->u.request->maximumRecords = odr_intdup(odr, 10); sr->u.request->facetList = yaz_pqf_parse_facet_list( @@ -115,7 +119,8 @@ void tst_encoding(void) YAZ_CHECK(compare_solr_req( odr, sr, 0, - "GET Default/select?q=title%3Asolr&start=2&rows=10" + "GET Default/select?defType=lucene&q=title%3Asolr&" + "start=2&rows=10" "&facet=true&facet.mincount=1&facet.field=date" "&facet.field=title_exact&f.title_exact.facet.limit=17" " HTTP/1.1\r\n" @@ -148,6 +153,7 @@ int check_response(ODR o, const char *content, Z_SRW_searchRetrieveResponse **p) odr_setbuf(o, http_response, strlen(http_response), 0); + *p = 0; r = z_GDU(o, &gdu, 0, 0); if (!r || gdu->which != Z_GDU_HTTP_Response) return 0; @@ -176,14 +182,16 @@ void tst_decoding(void) "0" "\n" "\n", &response)); - YAZ_CHECK_EQ(*response->numberOfRecords, 91); - YAZ_CHECK_EQ(response->num_records, 0); - YAZ_CHECK(response->records == 0); - YAZ_CHECK_EQ(response->num_diagnostics, 0); - YAZ_CHECK(response->diagnostics == 0); - YAZ_CHECK(response->nextRecordPosition == 0); - YAZ_CHECK(response->facetList == 0); - + if (response) + { + YAZ_CHECK_EQ(*response->numberOfRecords, 91); + YAZ_CHECK_EQ(response->num_records, 0); + YAZ_CHECK(response->records == 0); + YAZ_CHECK_EQ(response->num_diagnostics, 0); + YAZ_CHECK(response->diagnostics == 0); + YAZ_CHECK(response->nextRecordPosition == 0); + YAZ_CHECK(response->facetList == 0); + } odr_reset(odr); YAZ_CHECK( @@ -232,12 +240,15 @@ void tst_decoding(void) "44" "3" "", &response)); + if (response) + { #if HAVE_LONG_LONG - YAZ_CHECK(*response->numberOfRecords == 91000000000LL); + YAZ_CHECK(*response->numberOfRecords == 91000000000LL); #endif - YAZ_CHECK_EQ(response->num_records, 1); - YAZ_CHECK(response->records); - if (response->records) + YAZ_CHECK_EQ(response->num_records, 1); + YAZ_CHECK(response->records); + } + if (response && response->records) { const char *doc = "Alenius, Hans," @@ -273,12 +284,14 @@ void tst_decoding(void) YAZ_CHECK(record->recordData_len == strlen(doc) && !memcmp(record->recordData_buf, doc, record->recordData_len)); } - YAZ_CHECK_EQ(response->num_diagnostics, 0); - YAZ_CHECK(response->diagnostics == 0); - YAZ_CHECK(response->nextRecordPosition == 0); - - YAZ_CHECK(response->facetList); - if (response->facetList) + if (response) + { + YAZ_CHECK_EQ(response->num_diagnostics, 0); + YAZ_CHECK(response->diagnostics == 0); + YAZ_CHECK(response->nextRecordPosition == 0); + YAZ_CHECK(response->facetList); + } + if (response && response->facetList) { Z_FacetList *facetList = response->facetList; @@ -329,14 +342,51 @@ void tst_decoding(void) odr_destroy(odr); #endif } + +void tst_yaz_700(void) +{ + ODR odr = odr_createmem(ODR_ENCODE); + int r; + const char *url = + "http://localhost:9036/XXX/cproxydebug-7/node102/p/105/c=content_connector" + "a=usr/pw#&? r=cfusr/cfpw p=1.2.3.4:80/www.indexdata.com/staff/"; + int use_full_host = 0; + Z_GDU *gdu_req = z_get_HTTP_Request_uri(odr, url, 0, use_full_host); + Z_HTTP_Request *hreq = gdu_req->u.HTTP_Request; + hreq->method = "GET"; + + hreq->content_buf = odr_strdup(odr, ""); + hreq->content_len = 0; + + r = z_GDU(odr, &gdu_req, 0, 0); + YAZ_CHECK(r); + if (r) + { + int len; + char *buf = odr_getbuf(odr, &len, 0); + ODR decode = odr_createmem(ODR_DECODE); + YAZ_CHECK(buf); + if (buf) + { + odr_setbuf(decode, buf, len, 0); + r = z_GDU(decode, &gdu_req, 0, 0); + YAZ_CHECK(r); + } + odr_destroy(decode); + } + odr_destroy(odr); +} + + int main(int argc, char **argv) { YAZ_CHECK_INIT(argc, argv); #if YAZ_HAVE_XML2 LIBXML_TEST_VERSION; #endif - tst_encoding(); +// tst_encoding(); tst_decoding(); + tst_yaz_700(); YAZ_CHECK_TERM; }