Get It:
Download
Change Log
Learn It:
Install
Tutorial
API Doc
Discuss It:
Mailing List
Follow It:
Code

Tutorial Part 10. Testing your application via HTTP

Functions and macros to test your application via HTTP

Note: To use http-test-get-instance-by-oid, a slot value must be surrounded by a tag with an id attribute whose value is a slot id. You can get the slot id by slot-id.

Testing an application generated by genpages macro

application codes

(eval-when (:compile-toplevel :load-toplevel :execute)
  (asdf:oos 'asdf:load-op :web4r))

(in-package :cl-user)
(defpackage :wiki (:use :cl :web4r))
(in-package :wiki)

(ele:open-store *example-bdb*)

(defpclass wiki ()
  ((title :length 256 :index t)
   (body  :length 3000)))
(genpages wiki)

(start-server)

test codes

(let ((class 'wiki))
  (with-new-cookie
    (let ((oid (http-test-make-instance class :title "title1" :body "body1")))
      (http-test-get-instance-by-oid class oid)
      (http-test-update-instance class oid '((title . "title1c") (body . "body1c")))
      (http-test-drop-instance-by-oid class oid))))

Testing the blog application with authentication made in the Tutorial Part 9

test codes

(let ((class 'blog)
      (id    "user1")
      (pass  "pass1"))
  (with-new-cookie
    (http-test-regist `((id    . ,id)
                        (pass  . ,pass)
                        (email . "1@1.com")
                        (blog-title . "user1's blog")))
    (http-test-login :id id :pass pass)
    (let ((oid (http-test-make-instance class :title "title1" :body "body1")))
      (http-test-get-instance-by-oid class oid)
      (http-test-update-instance class oid '((title . "title1c") (body . "body1c")))
      (http-test-drop-instance-by-oid class oid))
    (http-test-logout)))

Debug mode

debug-mode-on turns debug mode on and debug-mode-off turns it off.

Debug mode does two things when lisp errors happen.

  1. Show lisp errors as html via HTTP
  2. Write lisp errors and its back traces to *debug-log-file*