commit: r1798 - neon/trunk/test

joe at manyfish.co.uk joe at manyfish.co.uk
Wed Apr 21 16:41:01 EDT 2010


Author: joe
Date: Wed Apr 21 20:41:01 2010
New Revision: 1798

Modified:
   neon/trunk/test/lock.c

Log:
* test/lock.c (fake_session): New function.
  (everywhere): Replace use of make_session with fake_session.


Modified: neon/trunk/test/lock.c
==============================================================================
--- neon/trunk/test/lock.c	(original)
+++ neon/trunk/test/lock.c	Wed Apr 21 20:41:01 2010
@@ -1,6 +1,6 @@
 /* 
    lock tests
-   Copyright (C) 2002-2006, Joe Orton <joe at manyfish.co.uk>
+   Copyright (C) 2002-2010, Joe Orton <joe at manyfish.co.uk>
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -217,6 +217,14 @@
     return OK;
 }
 
+/* Use a fake session forced to use port 7777 to the origin, to
+ * simplify the tests. */
+static int fake_session(ne_session **sess, server_fn fn, void *userdata)
+{
+    return proxied_session_server(sess, "http", "localhost", 7777,
+                                  fn, userdata);
+}
+
 /* regression test for <= 0.18.2, where timeout field was not parsed correctly. */
 static int lock_timeout(void)
 {
@@ -230,7 +238,7 @@
 		     "Lock-Token: <opaquelocktoken:foo>" EOL
 		     "Connection: close\r\n\r\n", rbody, NULL);
 
-    CALL(make_session(&sess, single_serve_string, resp));
+    CALL(fake_session(&sess, single_serve_string, resp));
     ne_free(resp);
 
     ne_fill_server_uri(sess, &lock->uri);
@@ -324,7 +332,7 @@
     
     expect_if = ne_concat("<http://localhost:7777", lockpath, 
 			  "> (<somelocktoken>)", NULL);
-    CALL(make_session(&sess, serve_verify_if, expect_if));
+    CALL(fake_session(&sess, serve_verify_if, expect_if));
     ne_free(expect_if);
 
     ne_fill_server_uri(sess, &lk->uri);
@@ -419,7 +427,7 @@
 
 static int discover(void)
 {
-    ne_session *sess = ne_session_create("http", "localhost", 7777);
+    ne_session *sess;
     char *response;
     int ret;
     struct result_args args;
@@ -428,16 +436,17 @@
 
     args.lock->owner = ne_strdup("someowner");
     args.lock->token = ne_strdup("sometoken");
-
+    args.lock->uri.host = ne_strdup("localhost");
+    args.lock->uri.port = 7777;
+    args.lock->uri.scheme = ne_strdup("http");
+    
     /* default */
     args.result = FAIL;
     t_context("results callback never invoked");
 
-    ne_fill_server_uri(sess, &args.lock->uri);
-    args.lock->uri.path = ne_strdup("/lockme");
-
     response = discover_response("/lockme", args.lock);
-    CALL(spawn_server(7777, serve_discovery, response));
+    CALL(fake_session(&sess, serve_discovery, response));
+    args.lock->uri.path = ne_strdup("/lockme");
 
     ret = ne_lock_discover(sess, "/lockme", discover_result, &args);
     CALL(await_server());
@@ -478,7 +487,7 @@
 		     "Connection: close\r\n\r\n", rbody, NULL);
     ne_free(rbody);
 
-    CALL(make_session(&sess, single_serve_string, resp));
+    CALL(fake_session(&sess, single_serve_string, resp));
     ne_free(resp);
 
     lock = ne_lock_create();
@@ -511,7 +520,7 @@
     ne_session *sess;
     int ret;
     
-    CALL(make_session(&sess, single_serve_string, 
+    CALL(fake_session(&sess, single_serve_string, 
                       "HTTP/1.0 207 OK\r\n" "Connection: close\r\n" "\r\n"
                       "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
                       "<D:multistatus xmlns:D='DAV:'>\n"
@@ -546,7 +555,7 @@
         "\r\n";
     args.count = 2;
 
-    CALL(make_session(&sess, many_serve_string, &args));
+    CALL(fake_session(&sess, many_serve_string, &args));
 
     ne_set_server_auth(sess, no_creds, NULL);
 
@@ -585,7 +594,7 @@
                      "Content-type: application/xml" EOL
                      "Connection: close\r\n\r\n", rbody, NULL);
 
-    CALL(make_session(&sess, single_serve_string, resp));
+    CALL(fake_session(&sess, single_serve_string, resp));
     ne_free(resp);
 
     ne_fill_server_uri(sess, &lock->uri);



More information about the neon-commits mailing list