Skip to content

Instantly share code, notes, and snippets.

@svdberg
Created March 1, 2012 16:10
Show Gist options
  • Save svdberg/1950883 to your computer and use it in GitHub Desktop.
Save svdberg/1950883 to your computer and use it in GitHub Desktop.
Property resolver tests
(ns propertyresolver.test.core
(:use [propertyresolver.core])
(:use [clojure.test])
(:use midje.sweet))
;; "PropertyResolver resolve single reference"
(facts "replace should resolve a single reference"
(let [map-with-placeholder {:jndiname "${jndi.ref}" :jndi.ref "MyQueue"}]
(expand-placeholders map-with-placeholder map-with-placeholder) => {:jndi.ref "MyQueue" :jndiname "MyQueue"}))
(facts "replace multiple references"
(let [map-with-multiple-placeholders {:name "${first.name} ${last.name}"
:first.name "Elton" :last.name "John"}]
(expand-placeholders map-with-multiple-placeholders map-with-multiple-placeholders) =>
{:first.name "Elton" :last.name "John" :name "Elton John"}))
(facts "resolve chained references"
(let [chained-references {:a "link to ${b}"
:b "another link to ${c}"
:c "target"}]
(expand-placeholders chained-references chained-references) =>
{:c "target" :a "link to another link to target" :b "another link to target"}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment