From 2dd8fd112985f08480ec1c3ce863baed9ae94cb1 Mon Sep 17 00:00:00 2001 From: Jeroen Hoek Date: Fri, 10 Aug 2018 14:43:49 +0200 Subject: [PATCH] Java 11 --- README.md | 4 +++- pom.xml | 7 +++---- .../java/com/example/javamavenjunithelloworld/Hello.java | 2 +- .../com/example/javamavenjunithelloworld/HelloApp.java | 4 ++-- .../com/example/javamavenjunithelloworld/HelloTest.java | 1 - 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 934b71e0..c3780e8c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # A Java/Maven/JUnit HelloWorld example +**This branch targeting Java 11 is work-in-progress.** + A „Hello World!” sample written in Java using Maven for the build, that showcases a few very simple tests. This example demonstrates: -* A simple Java 8 application with tests +* A simple Java 11 application with tests * Unit tests written with [JUnit 5](https://junit.org/junit5/) * Integration tests written with [JUnit 5](https://junit.org/junit5/) * Code coverage reports via [JaCoCo](https://www.jacoco.org/jacoco/) diff --git a/pom.xml b/pom.xml index 1c0d7dda..a2cf4004 100644 --- a/pom.xml +++ b/pom.xml @@ -14,10 +14,9 @@ UTF-8 UTF-8 - - - 1.8 - ${maven.compiler.source} + + + 10 5.2.0 1.2.0 diff --git a/src/main/java/com/example/javamavenjunithelloworld/Hello.java b/src/main/java/com/example/javamavenjunithelloworld/Hello.java index 7338993b..c76bf0e0 100644 --- a/src/main/java/com/example/javamavenjunithelloworld/Hello.java +++ b/src/main/java/com/example/javamavenjunithelloworld/Hello.java @@ -35,7 +35,7 @@ public void setTimes(int times) { * @param printer PrintStream to write output to. */ public void sayHello(PrintStream printer) { - for (short i = 0; i < times; i++) { + for (var i = 0; i < times; i++) { printer.println(HELLO); } } diff --git a/src/main/java/com/example/javamavenjunithelloworld/HelloApp.java b/src/main/java/com/example/javamavenjunithelloworld/HelloApp.java index e23da4f0..8b05cee8 100644 --- a/src/main/java/com/example/javamavenjunithelloworld/HelloApp.java +++ b/src/main/java/com/example/javamavenjunithelloworld/HelloApp.java @@ -18,7 +18,7 @@ public class HelloApp { */ public static void main(String[] args) { - int times = DEFAULT_TIMES; + var times = DEFAULT_TIMES; if (args.length >= 1) { try { times = Integer.valueOf(args[0]); @@ -29,7 +29,7 @@ public static void main(String[] args) { } } - Hello hi = new Hello(); + var hi = new Hello(); try { hi.setTimes(times); } catch (IllegalArgumentException e) { diff --git a/src/test/java/com/example/javamavenjunithelloworld/HelloTest.java b/src/test/java/com/example/javamavenjunithelloworld/HelloTest.java index 7bfd1f0b..a9ce025a 100644 --- a/src/test/java/com/example/javamavenjunithelloworld/HelloTest.java +++ b/src/test/java/com/example/javamavenjunithelloworld/HelloTest.java @@ -1,7 +1,6 @@ package com.example.javamavenjunithelloworld; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream;