Skip to content

Commit

Permalink
Merge pull request jenkins-docs#499 from NotMyFault/cleanup
Browse files Browse the repository at this point in the history
Make this demo work on Java 17 onwards
  • Loading branch information
MarkEWaite authored Dec 16, 2022
2 parents d429203 + 9adc465 commit 635d3f8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ buildNumber.properties

# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar

.idea
19 changes: 11 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<url>https://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -24,7 +24,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.10.1</version>
</plugin>
</plugins>
</pluginManagement>
Expand All @@ -33,7 +33,7 @@
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
Expand All @@ -47,7 +47,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<version>3.1.0</version>
<executions>
<execution>
<id>enforce-maven</id>
Expand All @@ -57,8 +57,11 @@
<configuration>
<rules>
<requireMavenVersion>
<version>[3.5.4,)</version>
<version>[3.8.6,)</version>
</requireMavenVersion>
<requireJavaVersion>
<version>[11,)</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/mycompany/app/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
/**
* Hello world!
*/
public class App
{
public class App {

private final String message = "Hello World!";

Expand Down
15 changes: 9 additions & 6 deletions src/test/java/com/mycompany/app/AppTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.mycompany.app;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import org.junit.Before;
import org.junit.Test;
import org.junit.After;
import static org.junit.Assert.*;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

/**
* Unit test for simple App.
Expand All @@ -15,7 +18,7 @@ public class AppTest

private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();

@Before
@BeforeEach
public void setUpStreams() {
System.setOut(new PrintStream(outContent));
}
Expand All @@ -40,7 +43,7 @@ public void testAppMain()
}
}

@After
@AfterEach
public void cleanUpStreams() {
System.setOut(null);
}
Expand Down

0 comments on commit 635d3f8

Please sign in to comment.