Permalink
Switch branches/tags
release404401_rc1 release4401test_t1 release4401_t1 release4401_release_point release4401_rc4 release4401_rc3 release4401_rc2 release4401_rc1 release491_t15 release491_t14 release491_t13 release491_t12 release491_t11 release491_t10 release491_t9 release491_t8 release491_t7 release491_t6 release491_t5 release491_t4 release491_t3 release491_t2 release491_t1 release451_t1 release410_t1 release410_rc6 release410_rc5 release410_rc4 release410_rc3 release410_rc2 release410_rc1 release49_t5 release49_t4 release49_t3 release49_t2 release49_t1 release49_release_point release49_rc4 release49_rc3 release49_rc2 release49_rc1 release48_t3 release48_t2 release48_t1 release48_release_point release48_rc1 release47_t3 release47_t2 release47_t1 release47_release_point release47_rc5 release47_rc4 release47_rc3 release47_rc2 release47_rc1 release46_release_point release46_rc4 release46_rc3 release46_rc2 release46_rc1 release45_t4 release45_t3 release45_t2 release45_t1 release45_rc1 release44b_release_point release44b_rc2 release44b_rc1 release44a_rc1 release6.3.1_t2 release6.3.1_t1 release6.3.0_t5 release6.3.0_t4 release6.3.0_t3 release6.3.0_t2 release6.3.0_t1 release6.3.0_release_point release6.3.0_rc3 release6.3.0_rc2 release6.3.0_rc1 release6.2.3_t1 release6.2.3_release_point release6.2.3_rc2 release6.2.3_rc1 release6.2.2_t2 release6.2.2_t1 release6.2.2_release_point release6.2.2_rc3 release6.2.2_rc2 release6.2.2_rc1 release6.2.1_t5 release6.2.1_t4 release6.2.1_t3 release6.2.1_t2 release6.2.1_t1 release6.2.1_release_point release6.2.1_rc1 release6.2.0_t1 release6.2.0_rc4 release6.2.0_rc3
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (65 sloc) 2.55 KB
;; copyright (c) 2011-2016 Franz Inc, Oakland, CA - All rights reserved.
;; This program and the accompanying materials are made available under the
;; terms of the Eclipse Public License v1.0 which accompanies this
;; distribution (see license.txt), and is available at
;; http://www.eclipse.org/legal/epl-v10.html
;;
;; Testing Solr binding
;;
;; To run the test, we need a Solr server running with example data
;; loaded. If you get Solr binary distribution, go down to example/
;; directory and run the following command:
;;
;; $ java -jar start.jar
;;
;; This runs Solr example server in foreground.
;;
;; If this is the first time, you need to populate the example database.
;; In another shell window, go down to example/exampledocs/ directory
;; and run the following command:
;;
;; $ java -jar post.jar *.xml
;;
;; See http://lucene.apache.org/solr/tutorial.html for the details.
;;
(cl:eval-when (:compile-toplevel :load-toplevel)
(cl:require :tester)
(cl:require :regexp2))
(cl:defpackage #:solr.test
(:use #:cl #:excl #:util.test #:solr)
(:export #:run-test #:run-test-solr-server))
(cl:in-package #:solr.test)
(defvar *solr-port* 8983
"default port used by example")
(defvar *e* nil
"with-solr macro binds this to a condition when socket-error occurs.
Intended for diagnostics.")
(defmacro with-solr ((var uri) &body body)
(let ((uri_ (gensym)) (e_ (gensym)))
`(let* ((,uri_ ,uri)
(,var (make-instance 'solr :uri ,uri_)))
(declare (ignorable ,var))
(setf *e* nil)
(handler-case
(progn ,@body)
(socket-error (,e_)
(setf *e* ,e_)
(error "Can't connect to the Solr server at ~a: Maybe it is not running? (original socket error=~s)"
,uri_ (slot-value ,e_ 'excl::identifier)))))))
;; run-test is run by (asdf:oos 'asdf:test-op :solr)
(defun run-test (&key (port *solr-port*))
(with-tests (:name "solr")
(with-solr (solr (format nil "http://localhost:~a/solr" port))
;; Response count
(let ((r (solr-query solr)))
(test '(17 0 10) (solr-result->response-count r)
:multiple-values t)
(test 10 (length (solr-result->doc-nodes r)))
(test 10 (length (solr-result->doc-alist r))))
(let ((r (solr-query solr :param-alist '((:rows . 20)))))
(test '(17 0 17) (solr-result->response-count r)
:multiple-values t))
(let ((r (solr-query solr :param-alist '((:start 10 :rows 20)))))
(test '(17 10 7) (solr-result->response-count r)
:multiple-values t))
)))