Skip to content

Commit

Permalink
gh-177 classpath unit test is working
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew O. Smith committed Jun 30, 2015
1 parent 5b6d7b4 commit 586abde
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/main/lisp/malabar-http.el
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
(malabar-project-port malabar-mode-project-file)
service
args)))
(message "%s" url)
(with-current-buffer (url-retrieve-synchronously url)
(goto-char url-http-end-of-headers)
(setq json-array-type (or array-type 'vector)
Expand Down
59 changes: 44 additions & 15 deletions src/test/lisp/malabar-ede-maven.ert
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,52 @@
(getenv "PWD")
(expand-file-name "../../..")))

(defun malabar-ede-maven-expected-classpath (malabar-project-dir repo)
(let ((basic-project-dir (expand-file-name "src/test/project/basic" malabar-project-dir)))

(list (expand-file-name "src/test/java" basic-project-dir)
(expand-file-name "src/main/java" basic-project-dir)
(expand-file-name "target/test-classes" basic-project-dir)
(expand-file-name "target/classes" basic-project-dir)
(expand-file-name "target/classes" basic-project-dir)
(expand-file-name "junit/junit/3.8.1/junit-3.8.1.jar" repo))))

(defun malabar-ede-maven-wait-for-server (retries)
"Make sure the malabar server is up. Wait RETRIES seconds"
(with-current-buffer "*groovy*"
(save-match-data
(when (> retries 0)
(let ((s (buffer-substring-no-properties (point-min) (min 1000 (point-max)))))
(if (not (string-match "HttpServerImpl" s))
(progn
(message "Malabar Server is not up, %d tries left %s ...." retries s )
(sit-for 1 t)
(malabar-ede-maven-wait-for-server (1- retries)))
t))))))



(ert-deftest malabar-ede-maven-doh ()
(should (= 1 1)))


(ert-deftest malabar-ede-maven-classpath ()
(with-temp-buffer
(add-to-list 'load-path (expand-file-name "src/main/lisp/" (malabar-ede-maven-project-dir)))
(message "Load %s" (load "malabar-ede-maven.el"))
(let ((file-name (expand-file-name java-file (malabar-ede-maven-project-dir))))
(insert-file-contents-literally file-name t)
(setq buffer-file-name file-name)
(setq default-directory (file-name-directory file-name))
(java-mode)
(malabar-java-mode)
(let ((ede-project (ede-current-project)))
(message "%s" (object-print ede-project))
(should (equal "Malabar Maven<basic>" (oref ede-project name)))
(should (equal 'malabar-ede-maven2-project (object-class ede-project)))
(should (equal "hamster" (ede-java-classpath ede-project)))))))
"Verify that the classpath is returned from a malabar server."
(should (malabar-ede-maven-wait-for-server 20))
(let ((malabar-project-dir (malabar-ede-maven-project-dir)))
(with-temp-buffer
(add-to-list 'load-path (expand-file-name "src/main/lisp/" malabar-project-dir))
(message "Load %s" (load "malabar-ede-maven.el"))
(let ((file-name (expand-file-name java-file malabar-project-dir)))
(insert-file-contents-literally file-name t)
(setq buffer-file-name file-name)
(setq default-directory (file-name-directory file-name))
(java-mode)
(malabar-java-mode)
(let ((ede-project (ede-current-project))
(repo (expand-file-name malabar-package-maven-repo)))
(message "%s" (object-print ede-project))
(should (equal "Malabar Maven<basic>" (oref ede-project name)))
(should (equal 'malabar-ede-maven2-project (object-class ede-project)))
(should (equal (malabar-ede-maven-expected-classpath malabar-project-dir repo)
(ede-java-classpath ede-project))))))))

0 comments on commit 586abde

Please sign in to comment.