src/server/test/webdav.c

changeset 415
d938228c382e
parent 376
61d481d3c2e4
equal deleted inserted replaced
414:99a34860c105 415:d938228c382e
310 } 310 }
311 // WebdavResponse is the public interface used by Backends 311 // WebdavResponse is the public interface used by Backends
312 // for adding resources to the response 312 // for adding resources to the response
313 WebdavResponse *response = (WebdavResponse*)ms; 313 WebdavResponse *response = (WebdavResponse*)ms;
314 314
315 UcxList *requests = NULL; 315 WebdavPropfindRequestList *requests = NULL;
316 316
317 // Initialize all Webdav Backends 317 // Initialize all Webdav Backends
318 if(webdav_propfind_init(&backend1, propfind, "/", "/", &requests)) { 318 if(webdav_propfind_init(&backend1, propfind, "/", "/", &requests)) {
319 return NULL; 319 return NULL;
320 } 320 }
701 // TEST 1 701 // TEST 1
702 sn = testutil_session(); 702 sn = testutil_session();
703 rq = testutil_request(sn->pool, "PUT", "/"); 703 rq = testutil_request(sn->pool, "PUT", "/");
704 testutil_request_body(sn, rq, "Hello World!", 12); 704 testutil_request_body(sn, rq, "Hello World!", 12);
705 705
706 UcxBuffer *b1 = rqbody2buffer(sn, rq); 706 CxBuffer b1;
707 UCX_TEST_ASSERT(b1->size == 12, "b1: wrong size"); 707 rqbody2buffer(sn, rq, &b1);
708 UCX_TEST_ASSERT(!memcmp(b1->space,"Hello World!",12), "b1: wrong content"); 708 UCX_TEST_ASSERT(b1.size == 12, "b1: wrong size");
709 709 UCX_TEST_ASSERT(!memcmp(b1.space,"Hello World!",12), "b1: wrong content");
710 ucx_buffer_free(b1); 710
711 cxBufferDestroy(&b1);
711 testutil_destroy_session(sn); 712 testutil_destroy_session(sn);
712 713
713 // 714 //
714 // TEST 2 715 // TEST 2
715 size_t len1 = 25000; 716 size_t len1 = 25000;
719 } 720 }
720 sn = testutil_session(); 721 sn = testutil_session();
721 rq = testutil_request(sn->pool, "PUT", "/"); 722 rq = testutil_request(sn->pool, "PUT", "/");
722 testutil_request_body(sn, rq, (char*)body1, len1); 723 testutil_request_body(sn, rq, (char*)body1, len1);
723 724
724 UcxBuffer *b2 = rqbody2buffer(sn, rq); 725 CxBuffer b2;
725 UCX_TEST_ASSERT(b2->size == len1, "b2: wrong size"); 726 rqbody2buffer(sn, rq, &b2);
726 UCX_TEST_ASSERT(!memcmp(b2->space, body1, len1), "b2: wrong content"); 727 UCX_TEST_ASSERT(b2.size == len1, "b2: wrong size");
727 728 UCX_TEST_ASSERT(!memcmp(b2.space, body1, len1), "b2: wrong content");
728 ucx_buffer_free(b2); 729
730 cxBufferDestroy(&b2);
729 testutil_destroy_session(sn); 731 testutil_destroy_session(sn);
730 732
731 UCX_TEST_END; 733 UCX_TEST_END;
732 } 734 }
733 735
995 Request *rq; 997 Request *rq;
996 WebdavPropfindRequest *propfind; 998 WebdavPropfindRequest *propfind;
997 UCX_TEST_BEGIN; 999 UCX_TEST_BEGIN;
998 UCX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1), "init failed"); 1000 UCX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1), "init failed");
999 1001
1000 UcxList *requests = NULL; 1002 WebdavPropfindRequestList *requests = NULL;
1001 int err = webdav_propfind_init(&backend1, propfind, "/", "/", &requests); 1003 int err = webdav_propfind_init(&backend1, propfind, "/", "/", &requests);
1002 1004
1003 UCX_TEST_ASSERT(!err, "webdav_propfind_init failed"); 1005 UCX_TEST_ASSERT(!err, "webdav_propfind_init failed");
1004 UCX_TEST_ASSERT(requests, "request list is empty"); 1006 UCX_TEST_ASSERT(requests, "request list is empty");
1005 UCX_TEST_ASSERT(ucx_list_size(requests), "request list has wrong size"); 1007 UCX_TEST_ASSERT(cx_linked_list_size(requests, offsetof(WebdavPropfindRequestList, next)), "request list has wrong size");
1006 1008
1007 WebdavPropfindRequest *p1 = requests->data; 1009 WebdavPropfindRequest *p1 = requests->propfind;
1008 WebdavPropfindRequest *p2 = requests->next->data; 1010 WebdavPropfindRequest *p2 = requests->next->propfind;
1009 1011
1010 // backend1 removes the first property from the plist 1012 // backend1 removes the first property from the plist
1011 // backend2 should have one property less 1013 // backend2 should have one property less
1012 1014
1013 UCX_TEST_ASSERT(p1 && p2, "missing requests objects"); 1015 UCX_TEST_ASSERT(p1 && p2, "missing requests objects");

mercurial