From 160e834e93715e27348de21598ce21dc884c1140 Mon Sep 17 00:00:00 2001 From: Michael Gaare Date: Wed, 28 Sep 2022 23:49:05 -0400 Subject: [PATCH] Fix parsing wsdl from jar - When an app uses paos and is packaged as a jar/uberjar with a WSDL file in the jar, the `parse` function was throwing and not loading it correctly - Added a test jar with a "hello.wsdl" file for test coverage --- deps.edn | 3 ++- pom.xml | 2 +- src/paos/wsdl.clj | 9 ++++++--- test/paos/wsdl_test.clj | 8 ++++++++ test_resources/test.jar | Bin 0 -> 955 bytes 5 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 test/paos/wsdl_test.clj create mode 100644 test_resources/test.jar diff --git a/deps.edn b/deps.edn index d6b1c50..63dcd5e 100644 --- a/deps.edn +++ b/deps.edn @@ -21,7 +21,8 @@ :1.11 {:override-deps {org.clojure/clojure {:mvn/version "1.11.0-alpha1"}}} :test {:extra-paths ["test" "test_resources"] - :extra-deps {clj-http/clj-http {:mvn/version "3.12.2"}}} + :extra-deps {clj-http/clj-http {:mvn/version "3.12.2"} + test/jar {:local/root "./test_resources/test.jar"}}} :runner {:extra-deps {io.github.cognitect-labs/test-runner {:git/url "https://github.com/cognitect-labs/test-runner" diff --git a/pom.xml b/pom.xml index 26ccbb6..a436499 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 io.xapix paos - 0.2.5 + 0.2.6-SNAPSHOT paos diff --git a/src/paos/wsdl.clj b/src/paos/wsdl.clj index 76692b0..d7c909e 100644 --- a/src/paos/wsdl.clj +++ b/src/paos/wsdl.clj @@ -66,7 +66,7 @@ (defn net-url->wsdl [net-url] (-> net-url - (java.net.URL.) + (io/as-url) make-wsdl)) (defn wsdl-content->wsdl [wsdl-content] @@ -80,11 +80,14 @@ (defn ->wsdl [path-or-content] (cond - (.exists (io/file path-or-content)) + (try + (.exists (io/file path-or-content)) + (catch IllegalArgumentException e + false)) (file->wsdl path-or-content) (try - (java.net.URL. path-or-content) + (io/as-url path-or-content) (catch MalformedURLException e false)) (net-url->wsdl path-or-content) diff --git a/test/paos/wsdl_test.clj b/test/paos/wsdl_test.clj new file mode 100644 index 0000000..7fd088b --- /dev/null +++ b/test/paos/wsdl_test.clj @@ -0,0 +1,8 @@ +(ns paos.wsdl-test + (:require [paos.wsdl :as sut] + [clojure.test :as t] + [clojure.java.io :as io])) + +(t/deftest parse-from-jar + (t/is (map? (sut/parse (io/resource "hello.wsdl"))) + "should be able to parse from URL to classpath JAR")) diff --git a/test_resources/test.jar b/test_resources/test.jar new file mode 100644 index 0000000000000000000000000000000000000000..cca4c41f365c900cd987b02b6a83de4fb2cc54ac GIT binary patch literal 955 zcmWIWW@Zs#;Nak35ZGxG%76qo8CV#6T|*poJ^kGD|D9rBU}gyLX6FE@V1g`?1*sb8_~`{D_nsX;RrS~A8-L> zGg5PM^7YD#Q*!Qx9z1v1fX6Q1U+^pAEcqRwsX`ozeD)lHDmxZVsES=;#_8#`eY^U} zNhZ0bX6v48vG|u$|1N!f-oq0X#y$nT7Lp8m-Hx)qsJ__n>#T-Ib;|_BRm`7H+GTsL z_--kwtlhIbQ|qA*+s$UZl@cG8+?IRJ=#~C4@SJo0?O{`w!j_n+@wzr^CrMCPm8jAxZhh`KSMoBuy+ zUGIY4&!3l1bD8<1G{x)pHn9^iOU!Q`nQGScaoqvAkjDbQH{8GLxpe8@t^(!o C`%ZNL literal 0 HcmV?d00001