src/server/plugins/postgresql/pgtest.c

changeset 579
e10457d74fe1
parent 490
d218607f5a7e
equal deleted inserted replaced
578:eb48f716b31c 579:e10457d74fe1
200 xmlDoc *doc = xmlReadMemory(space, size, NULL, NULL, 0); 200 xmlDoc *doc = xmlReadMemory(space, size, NULL, NULL, 0);
201 if(!doc) { 201 if(!doc) {
202 return NULL; 202 return NULL;
203 } 203 }
204 204
205 CxMempool *mp = cxBasicMempoolCreate(64); 205 CxMempool *mp = cxMempoolCreateSimple(64);
206 TestMultistatus *ms = cxMalloc(mp->allocator, sizeof(TestMultistatus)); 206 TestMultistatus *ms = cxMalloc(mp->allocator, sizeof(TestMultistatus));
207 ms->doc = doc; 207 ms->doc = doc;
208 ms->mp = mp; 208 ms->mp = mp;
209 ms->responses = cxHashMapCreate((CxAllocator*)mp->allocator, CX_STORE_POINTERS, 8); 209 ms->responses = cxHashMapCreate((CxAllocator*)mp->allocator, CX_STORE_POINTERS, 8);
210 210
225 225
226 226
227 void test_multistatus_destroy(TestMultistatus *ms) { 227 void test_multistatus_destroy(TestMultistatus *ms) {
228 if(!ms) return; 228 if(!ms) return;
229 xmlFreeDoc(ms->doc); 229 xmlFreeDoc(ms->doc);
230 cxMempoolDestroy(ms->mp); 230 cxMempoolFree(ms->mp);
231 } 231 }
232 232
233 233
234 UCX_TEST(test_pg_conn) { 234 UCX_TEST(test_pg_conn) {
235 char *msg = test_connection ? PQerrorMessage(test_connection) : "no connection"; 235 char *msg = test_connection ? PQerrorMessage(test_connection) : "no connection";
645 UCX_TEST_ASSERT(ms, "propfind1: response is not valid xml"); 645 UCX_TEST_ASSERT(ms, "propfind1: response is not valid xml");
646 646
647 TestResponse *r1 = MAP_GET(ms->responses, "/propfind/"); 647 TestResponse *r1 = MAP_GET(ms->responses, "/propfind/");
648 UCX_TEST_ASSERT(r1, "propfind1: missing /propfind/ response"); 648 UCX_TEST_ASSERT(r1, "propfind1: missing /propfind/ response");
649 649
650 UCX_TEST_ASSERT(ms->responses->size == 1, "propfind1: wrong response count"); 650 UCX_TEST_ASSERT(cxMapSize(ms->responses) == 1, "propfind1: wrong response count");
651 651
652 TestProperty *p = MAP_GET(r1->properties, "DAV:resourcetype"); 652 TestProperty *p = MAP_GET(r1->properties, "DAV:resourcetype");
653 UCX_TEST_ASSERT(p, "propfind1: missing property 'resourcetype'"); 653 UCX_TEST_ASSERT(p, "propfind1: missing property 'resourcetype'");
654 UCX_TEST_ASSERT(p->status == 200, "propfind1: wrong status code for property 'resourcetype'"); 654 UCX_TEST_ASSERT(p->status == 200, "propfind1: wrong status code for property 'resourcetype'");
655 655
677 UCX_TEST_ASSERT(ms, "propfind2: response is not valid xml"); 677 UCX_TEST_ASSERT(ms, "propfind2: response is not valid xml");
678 678
679 r1 = MAP_GET(ms->responses, "/propfind/"); 679 r1 = MAP_GET(ms->responses, "/propfind/");
680 UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/ response"); 680 UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/ response");
681 681
682 UCX_TEST_ASSERT(ms->responses->size == 5, "propfind2: wrong response count"); 682 UCX_TEST_ASSERT(cxMapSize(ms->responses) == 5, "propfind2: wrong response count");
683 683
684 r1 = MAP_GET(ms->responses, "/propfind/res2"); 684 r1 = MAP_GET(ms->responses, "/propfind/res2");
685 UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/res2 response"); 685 UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/res2 response");
686 686
687 p = MAP_GET(r1->properties, "http://example.com/test"); 687 p = MAP_GET(r1->properties, "http://example.com/test");
711 UCX_TEST_ASSERT(ms, "propfind3: response is not valid xml"); 711 UCX_TEST_ASSERT(ms, "propfind3: response is not valid xml");
712 712
713 r1 = MAP_GET(ms->responses, "/propfind/"); 713 r1 = MAP_GET(ms->responses, "/propfind/");
714 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/ response"); 714 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/ response");
715 715
716 UCX_TEST_ASSERT(ms->responses->size == 6, "propfind3: wrong response count"); 716 UCX_TEST_ASSERT(cxMapSize(ms->responses) == 6, "propfind3: wrong response count");
717 717
718 718
719 r1 = MAP_GET(ms->responses, "/propfind/res1"); 719 r1 = MAP_GET(ms->responses, "/propfind/res1");
720 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/sub/res1 response"); 720 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/sub/res1 response");
721 721
773 TestMultistatus *ms = test_parse_multistatus(st->buf->space, st->buf->size); 773 TestMultistatus *ms = test_parse_multistatus(st->buf->space, st->buf->size);
774 UCX_TEST_ASSERT(ms, "propfind1: response is not valid xml"); 774 UCX_TEST_ASSERT(ms, "propfind1: response is not valid xml");
775 775
776 r1 = MAP_GET(ms->responses, "/propfind/"); 776 r1 = MAP_GET(ms->responses, "/propfind/");
777 UCX_TEST_ASSERT(r1, "propfind1: missing /propfind/ response"); 777 UCX_TEST_ASSERT(r1, "propfind1: missing /propfind/ response");
778 UCX_TEST_ASSERT(ms->responses->size == 1, "propfind1: wrong response count"); 778 UCX_TEST_ASSERT(cxMapSize(ms->responses) == 1, "propfind1: wrong response count");
779 779
780 p = MAP_GET(r1->properties, "DAV:resourcetype"); 780 p = MAP_GET(r1->properties, "DAV:resourcetype");
781 UCX_TEST_ASSERT(r1, "propfind1: missing resourcetype property"); 781 UCX_TEST_ASSERT(r1, "propfind1: missing resourcetype property");
782 782
783 testutil_destroy_session(sn); 783 testutil_destroy_session(sn);
798 ms = test_parse_multistatus(st->buf->space, st->buf->size); 798 ms = test_parse_multistatus(st->buf->space, st->buf->size);
799 UCX_TEST_ASSERT(ms, "propfind2: response is not valid xml"); 799 UCX_TEST_ASSERT(ms, "propfind2: response is not valid xml");
800 800
801 r1 = MAP_GET(ms->responses, "/propfind/"); 801 r1 = MAP_GET(ms->responses, "/propfind/");
802 UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/ response"); 802 UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/ response");
803 UCX_TEST_ASSERT(ms->responses->size == 5, "propfind2: wrong response count"); 803 UCX_TEST_ASSERT(cxMapSize(ms->responses) == 5, "propfind2: wrong response count");
804 804
805 r1 = MAP_GET(ms->responses, "/propfind/res1"); 805 r1 = MAP_GET(ms->responses, "/propfind/res1");
806 UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/res1 response"); 806 UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/res1 response");
807 807
808 p = MAP_GET(r1->properties, "DAV:resourcetype"); 808 p = MAP_GET(r1->properties, "DAV:resourcetype");
832 ms = test_parse_multistatus(st->buf->space, st->buf->size); 832 ms = test_parse_multistatus(st->buf->space, st->buf->size);
833 UCX_TEST_ASSERT(ms, "propfind3: response is not valid xml"); 833 UCX_TEST_ASSERT(ms, "propfind3: response is not valid xml");
834 834
835 r1 = MAP_GET(ms->responses, "/propfind/"); 835 r1 = MAP_GET(ms->responses, "/propfind/");
836 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/ response"); 836 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/ response");
837 UCX_TEST_ASSERT(ms->responses->size == 6, "propfind3: wrong response count"); 837 UCX_TEST_ASSERT(cxMapSize(ms->responses) == 6, "propfind3: wrong response count");
838 838
839 r1 = MAP_GET(ms->responses, "/propfind/res1"); 839 r1 = MAP_GET(ms->responses, "/propfind/res1");
840 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/res1 response"); 840 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/res1 response");
841 841
842 p = MAP_GET(r1->properties, "DAV:resourcetype"); 842 p = MAP_GET(r1->properties, "DAV:resourcetype");

mercurial