Skip to content

Commit 679dcd9

Browse files
committed
update integration tests, remove integrant from core projects
1 parent 82c2202 commit 679dcd9

6 files changed

Lines changed: 100 additions & 114 deletions

File tree

cronut-javax/project.clj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(defproject io.factorhouse/cronut-javax "1.0.0"
22

3-
:description "A Clojure companion to Quartz"
3+
:description "A Clojure companion to Quartz with Javax compatibility"
44

55
:url "https://github.com/factorhouse/cronut"
66

@@ -14,8 +14,7 @@
1414
[org.quartz-scheduler/quartz "2.4.0" :exclusions [org.slf4j/slf4j-api]]]
1515

1616
:profiles {:dev {:resource-paths ["dev-resources"]
17-
:dependencies [[integrant "0.13.1"]
18-
[ch.qos.logback/logback-classic "1.3.15"]
17+
:dependencies [[ch.qos.logback/logback-classic "1.3.15"]
1918
[org.slf4j/slf4j-api "2.0.17"]
2019
[org.clojure/core.async "1.8.741"]
2120
[clj-kondo "2025.06.05"]]}

cronut-javax/src/cronut/integrant.clj

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
(ns cronut.integration-test
22
(:require [clojure.core.async :as async]
3-
[clojure.java.io :as io]
43
[clojure.tools.logging :as log]
5-
[cronut.integrant :as cig]
6-
[integrant.core :as ig])
4+
[cronut :as cronut]
5+
[cronut.trigger :as trigger])
76
(:import (java.util UUID)
87
(org.quartz Job)))
98

@@ -12,34 +11,49 @@
1211
(execute [this _job-context]
1312
(log/info "Defrecord Impl:" this)))
1413

15-
(defmethod ig/init-key :dep/one
16-
[_ config]
17-
config)
18-
19-
(defmethod ig/init-key :test.job/one
20-
[_ config]
21-
(reify Job
22-
(execute [_this _job-context]
23-
(log/info "Reified Impl:" config))))
24-
25-
(defmethod ig/init-key :test.job/two
26-
[_ config]
27-
(map->TestDefrecordJobImpl config))
28-
29-
(defmethod ig/init-key :test.job/three
30-
[_ config]
31-
(reify Job
32-
(execute [_this _job-context]
33-
(let [rand-id (str (UUID/randomUUID))]
34-
(log/info rand-id "Reified Impl (Job Delay 7s):" config)
35-
(async/<!! (async/timeout 7000))
36-
(log/info rand-id "Finished")))))
37-
38-
(defn init-system
39-
"Convenience for starting integrant systems with cronut data-readers"
40-
([]
41-
(init-system (slurp (io/resource "config.edn"))))
42-
([config]
43-
(init-system config nil))
44-
([config readers]
45-
(ig/init (ig/read-string {:readers (merge cig/data-readers readers)} config))))
14+
(def reify-job (reify Job
15+
(execute [_this _job-context]
16+
(let [rand-id (str (UUID/randomUUID))]
17+
(log/info rand-id "Reified Impl (Job Delay 7s)")
18+
(async/<!! (async/timeout 7000))
19+
(log/info rand-id "Finished")))))
20+
21+
;(do (require '[cronut.integration-test :as it])
22+
; (it/test-system))
23+
(defn test-system
24+
[]
25+
(let [scheduler (cronut/scheduler {:concurrent-execution-disallowed? true})]
26+
(cronut/clear scheduler)
27+
28+
(async/<!! (async/timeout 2000))
29+
30+
(log/info "scheduling defrecord job on 1s interval")
31+
(cronut/schedule-job scheduler
32+
(trigger/interval 1000)
33+
(map->TestDefrecordJobImpl {:identity ["test-group" "test-name"]
34+
:description "test job"
35+
:recover? true
36+
:durable? false}))
37+
38+
;; demonstrate scheduler can start with jobs, and jobs can start after scheduler
39+
(cronut/start scheduler)
40+
41+
(async/<!! (async/timeout 2000))
42+
43+
;; demonstrates concurrency disallowed (every second job runs, 10s interval between jobs that should run every 5s)
44+
(log/info "scheduling reify/7s/no-misfire job on 5s interval")
45+
(cronut/schedule-job scheduler
46+
(trigger/builder {:type :cron
47+
:cron "*/5 * * * * ?"
48+
:misfire :do-nothing})
49+
reify-job)
50+
51+
(async/<!! (async/timeout 15000))
52+
53+
54+
(log/info "deleting job test-group/test-name")
55+
(cronut/delete-job scheduler "test-name" "test-group")
56+
57+
(async/<!! (async/timeout 15000))
58+
59+
(cronut/shutdown scheduler)))

cronut/project.clj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(defproject io.factorhouse/cronut "1.0.0"
22

3-
:description "A Clojure companion to Quartz"
3+
:description "A Clojure companion to Quartz with Jakarta compatibility"
44

55
:url "https://github.com/factorhouse/cronut"
66

@@ -14,8 +14,7 @@
1414
[org.quartz-scheduler/quartz "2.5.0" :exclusions [org.slf4j/slf4j-api]]]
1515

1616
:profiles {:dev {:resource-paths ["dev-resources"]
17-
:dependencies [[integrant "0.13.1"]
18-
[ch.qos.logback/logback-classic "1.5.18"]
17+
:dependencies [[ch.qos.logback/logback-classic "1.5.18"]
1918
[org.slf4j/slf4j-api "2.0.17"]
2019
[org.clojure/core.async "1.8.741"]
2120
[clj-kondo "2025.06.05"]]}

cronut/src/cronut/integrant.clj

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
(ns cronut.integration-test
22
(:require [clojure.core.async :as async]
3-
[clojure.java.io :as io]
43
[clojure.tools.logging :as log]
5-
[cronut.integrant :as cig]
6-
[integrant.core :as ig])
4+
[cronut :as cronut]
5+
[cronut.trigger :as trigger])
76
(:import (java.util UUID)
87
(org.quartz Job)))
98

@@ -12,34 +11,49 @@
1211
(execute [this _job-context]
1312
(log/info "Defrecord Impl:" this)))
1413

15-
(defmethod ig/init-key :dep/one
16-
[_ config]
17-
config)
18-
19-
(defmethod ig/init-key :test.job/one
20-
[_ config]
21-
(reify Job
22-
(execute [_this _job-context]
23-
(log/info "Reified Impl:" config))))
24-
25-
(defmethod ig/init-key :test.job/two
26-
[_ config]
27-
(map->TestDefrecordJobImpl config))
28-
29-
(defmethod ig/init-key :test.job/three
30-
[_ config]
31-
(reify Job
32-
(execute [_this _job-context]
33-
(let [rand-id (str (UUID/randomUUID))]
34-
(log/info rand-id "Reified Impl (Job Delay 7s):" config)
35-
(async/<!! (async/timeout 7000))
36-
(log/info rand-id "Finished")))))
37-
38-
(defn init-system
39-
"Convenience for starting integrant systems with cronut data-readers"
40-
([]
41-
(init-system (slurp (io/resource "config.edn"))))
42-
([config]
43-
(init-system config nil))
44-
([config readers]
45-
(ig/init (ig/read-string {:readers (merge cig/data-readers readers)} config))))
14+
(def reify-job (reify Job
15+
(execute [_this _job-context]
16+
(let [rand-id (str (UUID/randomUUID))]
17+
(log/info rand-id "Reified Impl (Job Delay 7s)")
18+
(async/<!! (async/timeout 7000))
19+
(log/info rand-id "Finished")))))
20+
21+
;(do (require '[cronut.integration-test :as it])
22+
; (it/test-system))
23+
(defn test-system
24+
[]
25+
(let [scheduler (cronut/scheduler {:concurrent-execution-disallowed? true})]
26+
(cronut/clear scheduler)
27+
28+
(async/<!! (async/timeout 2000))
29+
30+
(log/info "scheduling defrecord job on 1s interval")
31+
(cronut/schedule-job scheduler
32+
(trigger/interval 1000)
33+
(map->TestDefrecordJobImpl {:identity ["test-group" "test-name"]
34+
:description "test job"
35+
:recover? true
36+
:durable? false}))
37+
38+
;; demonstrate scheduler can start with jobs, and jobs can start after scheduler
39+
(cronut/start scheduler)
40+
41+
(async/<!! (async/timeout 2000))
42+
43+
;; demonstrates concurrency disallowed (every second job runs, 10s interval between jobs that should run every 5s)
44+
(log/info "scheduling reify/7s/no-misfire job on 5s interval")
45+
(cronut/schedule-job scheduler
46+
(trigger/builder {:type :cron
47+
:cron "*/5 * * * * ?"
48+
:misfire :do-nothing})
49+
reify-job)
50+
51+
(async/<!! (async/timeout 15000))
52+
53+
54+
(log/info "deleting job test-group/test-name")
55+
(cronut/delete-job scheduler "test-name" "test-group")
56+
57+
(async/<!! (async/timeout 15000))
58+
59+
(cronut/shutdown scheduler)))

0 commit comments

Comments
 (0)