Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'avbranco/master'
- Loading branch information
Showing
17 changed files
with
144 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(ns postal.main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/clj/com/draines/postal/sendmail.clj → src/postal/sendmail.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(ns postal.test.core | ||
(:use [postal.core] | ||
[postal.sendmail :only [sendmail-send]] | ||
[postal.smtp :only [smtp-send]] | ||
[postal.stress :only [spam]])) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(ns postal.test.date | ||
(:use [postal.date]) | ||
(:import [java.util Date] | ||
[java.text SimpleDateFormat ParsePosition])) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(ns postal.test.main | ||
(:use [postal.main])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
(ns postal.test.message | ||
(:use [postal.message] | ||
[clojure.test :only [run-tests deftest is]] | ||
[postal.date :only [make-date]]) | ||
(:import [java.util Properties UUID] | ||
[javax.mail Session Message$RecipientType] | ||
[javax.mail.internet MimeMessage InternetAddress | ||
AddressException])) | ||
|
||
(deftest test-simple | ||
(let [m {:from "fee@bar.dom" | ||
:to "Foo Bar <foo@bar.dom>" | ||
:cc ["baz@bar.dom" "Quux <quux@bar.dom>"] | ||
:date (java.util.Date.) | ||
:subject "Test" | ||
:body "Test!"}] | ||
(is (= "Subject: Test" (re-find #"Subject: Test" (message->str m)))) | ||
(is (re-find #"Cc: baz@bar.dom, Quux <quux@bar.dom>" (message->str m))))) | ||
|
||
(deftest test-multipart | ||
(let [m {:from "foo@bar.dom" | ||
:to "baz@bar.dom" | ||
:subject "Test" | ||
:body [{:type "text/html" | ||
:content "<b>some html</b>"}]}] | ||
(is (= "multipart/mixed" (re-find #"multipart/mixed" (message->str m)))) | ||
(is (= "Content-Type: text/html" | ||
(re-find #"Content-Type: text/html" (message->str m)))) | ||
(is (= "some html" (re-find #"some html" (message->str m)))))) | ||
|
||
(deftest test-inline | ||
(let [f (doto (java.io.File/createTempFile "_postal-" ".txt")) | ||
_ (doto (java.io.PrintWriter. f) | ||
(.println "tempfile contents") (.close)) | ||
m {:from "foo@bar.dom" | ||
:to "baz@bar.dom" | ||
:subject "Test" | ||
:body [{:type :inline | ||
:content f}]}] | ||
(is (= "tempfile" (re-find #"tempfile" (message->str m)))) | ||
(.delete f))) | ||
|
||
(deftest test-attachment | ||
(let [f1 (doto (java.io.File/createTempFile "_postal-" ".txt")) | ||
_ (doto (java.io.PrintWriter. f1) | ||
(.println "tempfile contents") (.close)) | ||
f2 "/etc/resolv.conf" | ||
m {:from "foo@bar.dom" | ||
:to "baz@bar.dom" | ||
:subject "Test" | ||
:body [{:type :attachment | ||
:content f1} | ||
{:type :attachment | ||
:content f2}]}] | ||
(is (= "tempfile" (re-find #"tempfile" (message->str m)))) | ||
(.delete f1))) | ||
|
||
(deftest test-fixture | ||
(let [from "foo@bar.dom" | ||
to "baz@bar.dom" | ||
tag "[TEST]"] | ||
(is (re-find #"^\[TEST" (:subject (make-fixture from to :tag tag)))))) | ||
|
||
(deftest test-extra-headers | ||
(let [m {:from "foo@bar.dom" | ||
:to "baz@bar.dom" | ||
:subject "Test" | ||
:User-Agent "Lorem Ipsum" | ||
:body "Foo!"}] | ||
(is (re-find #"User-Agent: Lorem Ipsum" (message->str m))))) | ||
|
||
(deftest test-bad-addrs | ||
(let [m {:from "foo @bar.dom" | ||
:to "badddz@@@bar.dom" | ||
:subject "Test" | ||
:body "Bad recipient!"}] | ||
(is (not (re-find #"badddz" (message->str m)))) | ||
(is (not (re-find #"foo @bar" (message->str m)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(ns postal.test.sendmail | ||
(:use [postal.message :only [message->str sender recipients]])) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(ns postal.test.smtp | ||
(:use [postal.message :only [make-jmessage]]) | ||
(:import [javax.mail Transport Session])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(ns postal.test.stress | ||
(:import [java.util Date] | ||
[java.text SimpleDateFormat] | ||
[java.util.concurrent CountDownLatch]) | ||
(:use [clojure.test] | ||
[postal.stress] | ||
[postal.smtp :only [smtp-send]] | ||
[postal.message :only [make-fixture]])) | ||
|
||
|
||
(deftest test-partition-work | ||
(is (= [5 5] (partition-work 10 2))) | ||
(is (= [3 3 3 1] (partition-work 10 3))) | ||
(is (= [111 111 111 111 111 111 111 111 111 111 3] | ||
(partition-work 1113 10)))) | ||
|
||
|