From 25bf80f2c6c3c6784f78d9d41b5e38a5273a00fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 20 Feb 2017 10:33:44 +0100 Subject: java : add project (ant,ivy,junit,logback) --- java/project/build.xml | 170 +++++++++++++++++++++ java/project/ivy.xml | 26 ++++ java/project/ivysettings.xml | 18 +++ java/project/src/main/ch/asynk/Main.java | 22 +++ java/project/src/main/ch/asynk/MyClass.java | 25 +++ java/project/src/main/ch/asynk/MyException.java | 11 ++ java/project/src/resources/Application.properties | 3 + java/project/src/resources/logback-test.xml | 34 +++++ java/project/src/test/java/ch/asynk/Test00.java | 54 +++++++ java/project/src/test/java/ch/asynk/TestSuite.java | 27 ++++ 10 files changed, 390 insertions(+) create mode 100644 java/project/build.xml create mode 100644 java/project/ivy.xml create mode 100644 java/project/ivysettings.xml create mode 100644 java/project/src/main/ch/asynk/Main.java create mode 100644 java/project/src/main/ch/asynk/MyClass.java create mode 100644 java/project/src/main/ch/asynk/MyException.java create mode 100644 java/project/src/resources/Application.properties create mode 100644 java/project/src/resources/logback-test.xml create mode 100644 java/project/src/test/java/ch/asynk/Test00.java create mode 100644 java/project/src/test/java/ch/asynk/TestSuite.java diff --git a/java/project/build.xml b/java/project/build.xml new file mode 100644 index 0000000..0134266 --- /dev/null +++ b/java/project/build.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/project/ivy.xml b/java/project/ivy.xml new file mode 100644 index 0000000..08505ed --- /dev/null +++ b/java/project/ivy.xml @@ -0,0 +1,26 @@ + + +]> + + + + + + + + + + + + + + + + + + + + diff --git a/java/project/ivysettings.xml b/java/project/ivysettings.xml new file mode 100644 index 0000000..3e44ce3 --- /dev/null +++ b/java/project/ivysettings.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/java/project/src/main/ch/asynk/Main.java b/java/project/src/main/ch/asynk/Main.java new file mode 100644 index 0000000..bb187bf --- /dev/null +++ b/java/project/src/main/ch/asynk/Main.java @@ -0,0 +1,22 @@ +package ch.asynk; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Main +{ + private static Logger logger = null; + + public static void main(String [] args ) + { + logger = LoggerFactory.getLogger(Main.class); + System.out.println("System.out"); + System.err.println("System.err"); + logger.trace("trace"); + logger.debug("debug"); + logger.info("info"); + logger.warn("warn"); + logger.error("error"); + System.exit(0); + } +} diff --git a/java/project/src/main/ch/asynk/MyClass.java b/java/project/src/main/ch/asynk/MyClass.java new file mode 100644 index 0000000..57ef46f --- /dev/null +++ b/java/project/src/main/ch/asynk/MyClass.java @@ -0,0 +1,25 @@ +package ch.asynk; + +import lombok.Getter; + +public class MyClass +{ + static private String msg = "Hello World"; + + private @Getter int n; + + public MyClass() + { + n = 666; + } + + public void print() + { + System.err.println(msg); + } + + public void exception() throws MyException + { + throw new MyException("it's mine"); + } +} diff --git a/java/project/src/main/ch/asynk/MyException.java b/java/project/src/main/ch/asynk/MyException.java new file mode 100644 index 0000000..06203ae --- /dev/null +++ b/java/project/src/main/ch/asynk/MyException.java @@ -0,0 +1,11 @@ +package ch.asynk; + +public class MyException extends Exception +{ + private static final long serialVersionUID = 01235; + + public MyException(String message) + { + super(message); + } +} diff --git a/java/project/src/resources/Application.properties b/java/project/src/resources/Application.properties new file mode 100644 index 0000000..34430cd --- /dev/null +++ b/java/project/src/resources/Application.properties @@ -0,0 +1,3 @@ +app.logfile=MyApp.log +app.version=0.0.1 +app.env=DEV diff --git a/java/project/src/resources/logback-test.xml b/java/project/src/resources/logback-test.xml new file mode 100644 index 0000000..7f49e52 --- /dev/null +++ b/java/project/src/resources/logback-test.xml @@ -0,0 +1,34 @@ + + + MyApp + + + + + + + + + + + + + + + + ${LOG_PATTERN} + + + + + ${LOG_FILE} + + ${LOG_PATTERN} + + + + + + + + diff --git a/java/project/src/test/java/ch/asynk/Test00.java b/java/project/src/test/java/ch/asynk/Test00.java new file mode 100644 index 0000000..aae83d7 --- /dev/null +++ b/java/project/src/test/java/ch/asynk/Test00.java @@ -0,0 +1,54 @@ +package ch.asynk; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.rules.ExpectedException; + +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.hasProperty; + +import ch.asynk.MyClass; + +public class Test00 +{ + private static MyClass my; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @BeforeClass + public static void setUpClass() + { + System.out.println(" BeforeClass : Test00"); + my = new MyClass(); + } + + @AfterClass + public static void tearDownClass() + { + System.out.println(" AfterClass : Test00"); + } + + @Test + public void test_0() + { + assertEquals("n must be equal to 666", my.getN(), 666); + } + + @Test + public void test_1() throws MyException + { + thrown.expect(MyException.class); + thrown.expectMessage("it's mine"); + my.exception(); + } + @Test + public void test_2() throws MyException + { + assertThat(my, hasProperty("n", is(666))); + } +} diff --git a/java/project/src/test/java/ch/asynk/TestSuite.java b/java/project/src/test/java/ch/asynk/TestSuite.java new file mode 100644 index 0000000..3e5d7d8 --- /dev/null +++ b/java/project/src/test/java/ch/asynk/TestSuite.java @@ -0,0 +1,27 @@ +package ch.asynk; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.BeforeClass; +import org.junit.AfterClass; + +@RunWith(Suite.class) + +@Suite.SuiteClasses({ + Test00.class +}) + +public class TestSuite +{ + @BeforeClass + public static void setUpClass() + { + System.out.println("BeforeClass : TestSuite"); + } + + @AfterClass + public static void tearDownClass() + { + System.out.println("AfterClass : TestSuite"); + } +} -- cgit v1.1-2-g2b99