| 26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
| 27 */ |
27 */ |
| 28 |
28 |
| 29 #include "webdav.h" |
29 #include "webdav.h" |
| 30 #include "webdav_resource.h" |
30 #include "webdav_resource.h" |
| |
31 |
| |
32 #include <cx/buffer.h> |
| 31 |
33 |
| 32 CX_TEST_SUBROUTINE(test_default_properties, DavResource *res) { |
34 CX_TEST_SUBROUTINE(test_default_properties, DavResource *res) { |
| 33 CX_TEST_ASSERT(res->contentlength > 0); |
35 CX_TEST_ASSERT(res->contentlength > 0); |
| 34 CX_TEST_ASSERT(res->creationdate > 0); |
36 CX_TEST_ASSERT(res->creationdate > 0); |
| 35 CX_TEST_ASSERT(res->lastmodified > 0); |
37 CX_TEST_ASSERT(res->lastmodified > 0); |
| 101 CX_TEST_ASSERT(!dav_load(res)); |
103 CX_TEST_ASSERT(!dav_load(res)); |
| 102 CX_TEST_ASSERT(res->contentlength == content.length); |
104 CX_TEST_ASSERT(res->contentlength == content.length); |
| 103 dav_session_destroy(sn); |
105 dav_session_destroy(sn); |
| 104 } |
106 } |
| 105 } |
107 } |
| |
108 |
| |
109 CX_TEST(test_dav_store_stream_webdav) { |
| |
110 CX_TEST_DO { |
| |
111 CX_TEST_DO { |
| |
112 FILE *f = fopen("test_dav_store_stream_webdav.txt", "w+"); |
| |
113 cxstring line = cx_str("test_dav_store_stream_webdav test content\n"); |
| |
114 for(int i=0;i<1000;i++) { |
| |
115 fwrite(line.ptr, 1, line.length, f); |
| |
116 } |
| |
117 fseek(f, 0, SEEK_SET); |
| |
118 size_t len = 1000 * line.length; |
| |
119 |
| |
120 DavSession *sn = get_test_webdav_session(); |
| |
121 DavResource *res = dav_resource_new(sn, "/test_store_file.txt"); |
| |
122 dav_set_content(res, f, (dav_read_func)fread, (dav_seek_func)fseek); |
| |
123 |
| |
124 int ret = dav_store(res); |
| |
125 CX_TEST_ASSERT(!ret); |
| |
126 CX_TEST_ASSERT(!dav_load(res)); |
| |
127 CX_TEST_ASSERT(res->contentlength == len); |
| |
128 dav_session_destroy(sn); |
| |
129 fclose(f); |
| |
130 } |
| |
131 } |
| |
132 } |