diff --git a/classpath-test/does-not-exist-anywhere-else b/classpath-test/does-not-exist-anywhere-else new file mode 100644 index 0000000..e69de29 diff --git a/test/puppetlabs/kitchensink/classpath_test.clj b/test/puppetlabs/kitchensink/classpath_test.clj index 21b2bf1..c280d2c 100644 --- a/test/puppetlabs/kitchensink/classpath_test.clj +++ b/test/puppetlabs/kitchensink/classpath_test.clj @@ -1,26 +1,17 @@ (ns puppetlabs.kitchensink.classpath-test (:require [clojure.test :refer :all] - [dynapath.dynamic-classpath :refer [classpath-urls]] - [puppetlabs.kitchensink.classpath :refer [add-classpath - with-additional-classpath-entries]]) - (:import (java.net URL)) - (:refer-clojure :exclude (add-classpath))) + [puppetlabs.kitchensink.classpath :refer [with-additional-classpath-entries]]) + (:import (java.net URL))) (deftest with-additional-classpath-entries-test - (let [paths ["/foo" "/bar"] - get-urls #(into #{} - (classpath-urls (.getContextClassLoader (Thread/currentThread))))] - ;; Called for side effect of ensuring there's a modifiable classloader - ;; without needing to make that function public - (add-classpath "file:/nil") - + (let [paths ["classpath-test"] + get-resource #(-> (Thread/currentThread) + .getContextClassLoader + (.getResource "does-not-exist-anywhere-else"))] (with-additional-classpath-entries paths - (testing "classloader now includes the new paths" - (let [urls (get-urls)] - (is (contains? urls (URL. "file:/foo"))) - (is (contains? urls (URL. "file:/bar")))))) - (testing "classloader has been restored to its previous state" - (let [urls (get-urls)] - (is (not (contains? urls (URL. "file:/foo")))) - (is (not (contains? urls (URL. "file:/bar")))))))) + (testing "classloader now includes the new path" + (is (get-resource)))) + + (testing "classloader no longer includes the new path" + (is (not (get-resource))))))