Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 11 #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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/)
Expand Down
7 changes: 3 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- This configures the compiler to produce Java 8 class files. -->
<!-- The minimum JDK version installed is 8 of course, but newer JDK releases should work too. -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
<!-- This configures the compiler to produce Java 11 class files. -->
<!-- The minimum JDK version installed is 11 of course, but newer JDK releases should work too. -->
<maven.compiler.release>10</maven.compiler.release>

<junit.jupiter.version>5.2.0</junit.jupiter.version>
<junit.platform.version>1.2.0</junit.platform.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.javamavenjunithelloworld;


import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.io.ByteArrayOutputStream;
Expand Down