Skip to content

Commit 5247c88

Browse files
committed
Java: Add test for pom targeting Java 8 but rquiring Java 11
1 parent 6b890ea commit 5247c88

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.example</groupId>
7+
<artifactId>maven-java8-java11-dependency</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
10+
<name>maven-java8-java11-dependency</name>
11+
<description>Test case: Java 8 project with dependency requiring Java 11+</description>
12+
13+
<properties>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
<maven.compiler.source>1.8</maven.compiler.source>
16+
<maven.compiler.target>1.8</maven.compiler.target>
17+
</properties>
18+
19+
<dependencies>
20+
<!-- TestNG 7.7.0 is compiled with Java 11 (class file version 55.0) -->
21+
<dependency>
22+
<groupId>org.testng</groupId>
23+
<artifactId>testng</artifactId>
24+
<version>7.7.0</version>
25+
<scope>test</scope>
26+
</dependency>
27+
</dependencies>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<artifactId>maven-compiler-plugin</artifactId>
33+
<version>3.8.0</version>
34+
</plugin>
35+
<plugin>
36+
<artifactId>maven-surefire-plugin</artifactId>
37+
<version>2.22.1</version>
38+
</plugin>
39+
</plugins>
40+
</build>
41+
</project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pom.xml
2+
src/main/java/com/example/Calculator.java
3+
src/test/java/com/example/CalculatorTest.java
4+
target/maven-archiver/pom.properties
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.example;
2+
3+
public class Calculator {
4+
public int add(int a, int b) {
5+
return a + b;
6+
}
7+
8+
public int multiply(int a, int b) {
9+
return a * b;
10+
}
11+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.example;
2+
3+
import org.testng.Assert;
4+
import org.testng.annotations.Test;
5+
6+
/**
7+
* Test class using TestNG 7.7.0 which requires Java 11+.
8+
*/
9+
public class CalculatorTest {
10+
@Test
11+
public void testAdd() {
12+
Calculator calc = new Calculator();
13+
Assert.assertEquals(calc.add(2, 3), 5);
14+
}
15+
16+
@Test
17+
public void testMultiply() {
18+
Calculator calc = new Calculator();
19+
Assert.assertEquals(calc.multiply(3, 4), 12);
20+
}
21+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test(codeql, java):
2+
codeql.database.create()

0 commit comments

Comments
 (0)