Skip to content

Commit 141323c

Browse files
Simplify the example
1 parent 9bc441d commit 141323c

File tree

4 files changed

+27
-38
lines changed

4 files changed

+27
-38
lines changed

src/main/clj/try_virgil/core.clj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
(ns try-virgil.core
2-
(:import [try_virgil.SampleLib]))
2+
(:import [try_virgil.JavaLib]))
33

44
(defn greeting
55
[who]
6-
(str "Hello there, " who))
6+
(str "Greeting from Clojure : " who))
77

88
(defn -main[& args]
99
(try
10-
(greeting "Burin")
11-
(println "Let's try to call java")
10+
;; Calling Clojure function
11+
(greeting "Clojure")
1212

13-
(let [java-app (try_virgil.SimpleLib.)]
14-
(.greeting java-app "Max")
15-
(.addNumber java-app 3 4))
13+
(let [java-lib (try_virgil.JavaLib.)]
14+
;; Calling Java function
15+
(.greeting java-lib "Java"))
1616
(catch Exception e
1717
(.printStackTrace e)
1818
(println (str "Unexpected errros: " (.getMessage e))))))

src/main/java/try_virgil/JavaLib.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package try_virgil;
2+
public class JavaLib {
3+
public String greeting(String name) {
4+
return "Greeting from Java : " + name;
5+
}
6+
7+
public static void main(String[] args) {
8+
JavaLib app = new try_virgil.JavaLib();
9+
String message = app.greeting("Duke");
10+
System.out.println(message);
11+
}
12+
}

src/main/java/try_virgil/SimpleLib.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

test/clj/try_virgil/core_test.clj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
(ns try-virgil.core-test
2-
(:import [try_virgil.SampleLib])
2+
(:import [try_virgil.JavaLib])
33
(:require [clojure.test :refer :all]
44
[try-virgil.core :refer :all]))
55

6-
(deftest jvm-hello-tst
7-
(testing "greeting (Java)"
8-
(let [java-lib (try_virgil.SimpleLib.)]
9-
(is (= (.greeting java-lib "Max") "Hi there, Max")))))
6+
(deftest java-greeting-test
7+
(testing "greeting with Java"
8+
(let [java-lib (try_virgil.JavaLib.)]
9+
(is (= (.greeting java-lib "Burin") "Greeting from Java : Burin")))))
1010

11-
(deftest clj-hello-test
12-
(testing "greeting (Clojure)"
13-
(is (= (greeting "Burin") "Hello there, Burin"))))
11+
(deftest clojure-greeting-test
12+
(testing "greeting with Clojure"
13+
(is (= (greeting "Burin") "Greeting from Clojure : Burin"))))

0 commit comments

Comments
 (0)