Skip to content

Commit 1a76b3b

Browse files
maxxlessdmitriy-abramov
authored andcommitted
[SDKJAVA-526] add acceptance tests for different Maven versions
Signed-off-by: Maksym Leshchyshyn <[email protected]>
1 parent e3de2ec commit 1a76b3b

File tree

11 files changed

+675
-0
lines changed

11 files changed

+675
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
# Script to run acceptance tests with different Java and Maven versions
4+
# Usage: ./run-acceptance-tests.sh [java_version] [maven_version]
5+
6+
set -e
7+
8+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
10+
11+
JAVA_VERSION=${1:-"17"}
12+
MAVEN_VERSION=${2:-"default"}
13+
14+
echo "============================================"
15+
echo "Running HERE Artifact Wagon Acceptance Tests"
16+
echo "============================================"
17+
echo "Java Version: $JAVA_VERSION"
18+
echo "Maven Version: $MAVEN_VERSION"
19+
echo "============================================"
20+
21+
# Set Java version if using SDKMAN
22+
if command -v sdk &> /dev/null; then
23+
echo "Setting Java version using SDKMAN..."
24+
case $JAVA_VERSION in
25+
8)
26+
sdk use java 8.0.392-tem 2>/dev/null || echo "Java 8 not available via SDKMAN, using system default"
27+
;;
28+
17)
29+
sdk use java 17.0.9-tem 2>/dev/null || echo "Java 17 not available via SDKMAN, using system default"
30+
;;
31+
esac
32+
fi
33+
34+
# Check Java version
35+
echo ""
36+
echo "Current Java version:"
37+
java -version
38+
echo ""
39+
40+
# Run tests
41+
cd "$PROJECT_DIR"
42+
43+
if [ "$MAVEN_VERSION" = "default" ]; then
44+
echo "Running tests with default Maven..."
45+
mvn clean test -Pacceptance-tests
46+
else
47+
echo "Running tests with Maven $MAVEN_VERSION..."
48+
if [ -d "$HOME/.m2/maven-$MAVEN_VERSION" ]; then
49+
"$HOME/.m2/maven-$MAVEN_VERSION/bin/mvn" clean test -Pacceptance-tests
50+
else
51+
echo "Maven $MAVEN_VERSION not found at $HOME/.m2/maven-$MAVEN_VERSION"
52+
echo "Using default Maven..."
53+
mvn clean test -Pacceptance-tests
54+
fi
55+
fi
56+
57+
echo ""
58+
echo "============================================"
59+
echo "Tests completed!"
60+
echo "============================================"
61+
echo "View reports at: target/cucumber-reports/cucumber.html"
62+
echo ""
63+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Acceptance Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
acceptance-tests:
11+
name: Acceptance Tests - Java ${{ matrix.java }} - Maven ${{ matrix.maven }}
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
java: ['17']
17+
maven: ['3.9.0', '3.9.11']
18+
fail-fast: false
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up JDK ${{ matrix.java }}
25+
uses: actions/setup-java@v4
26+
with:
27+
java-version: ${{ matrix.java }}
28+
distribution: 'temurin'
29+
cache: 'maven'
30+
31+
- name: Set up Maven ${{ matrix.maven }}
32+
uses: stCarolas/[email protected]
33+
with:
34+
maven-version: ${{ matrix.maven }}
35+
36+
- name: Verify Java and Maven versions
37+
run: |
38+
echo "Java version:"
39+
java -version
40+
echo "Maven version:"
41+
mvn -version
42+
43+
- name: Configure HERE credentials
44+
env:
45+
OLP_CREDENTIALS: ${{ secrets.OLP_CREDENTIALS }}
46+
run: mkdir -p ~/.here/ && echo $OLP_CREDENTIALS | base64 --decode > ~/.here/credentials.properties
47+
48+
- name: Run acceptance tests
49+
run: |
50+
mvn clean install
51+
mvn clean test -Pacceptance-tests
52+
53+
- name: Upload test reports
54+
if: always()
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: cucumber-reports-java${{ matrix.java }}-maven${{ matrix.maven }}
58+
path: target/cucumber-reports/
59+
retention-days: 30
60+
61+
- name: Upload surefire reports
62+
if: always()
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: surefire-reports-java${{ matrix.java }}-maven${{ matrix.maven }}
66+
path: target/surefire-reports/
67+
retention-days: 30
68+
69+
- name: Publish test results
70+
if: always()
71+
uses: EnricoMi/publish-unit-test-result-action@v2
72+
with:
73+
files: |
74+
target/cucumber-reports/cucumber.xml
75+
target/surefire-reports/*.xml
76+
check_name: Test Results - Java ${{ matrix.java }} - Maven ${{ matrix.maven }}
77+
78+
acceptance-tests-summary:
79+
name: Acceptance Tests Summary
80+
needs: acceptance-tests
81+
runs-on: ubuntu-latest
82+
if: always()
83+
84+
steps:
85+
- name: Check test results
86+
run: |
87+
if [ "${{ needs.acceptance-tests.result }}" = "success" ]; then
88+
echo "All acceptance tests passed!"
89+
else
90+
echo "Some acceptance tests failed"
91+
exit 1
92+
fi
93+

pom.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<junit.version>4.13.2</junit.version>
5959
<mockito.version>5.12.0</mockito.version>
6060
<commons-io.version>2.16.1</commons-io.version>
61+
<cucumber.version>7.14.0</cucumber.version>
6162
</properties>
6263

6364
<dependencies>
@@ -145,6 +146,18 @@
145146
<scope>test</scope>
146147
</dependency>
147148

149+
<dependency>
150+
<groupId>io.cucumber</groupId>
151+
<artifactId>cucumber-java</artifactId>
152+
<version>${cucumber.version}</version>
153+
<scope>test</scope>
154+
</dependency>
155+
<dependency>
156+
<groupId>io.cucumber</groupId>
157+
<artifactId>cucumber-junit</artifactId>
158+
<version>${cucumber.version}</version>
159+
<scope>test</scope>
160+
</dependency>
148161
</dependencies>
149162

150163
<build>
@@ -226,6 +239,27 @@
226239
</plugins>
227240
</build>
228241
</profile>
242+
<profile>
243+
<id>acceptance-tests</id>
244+
<build>
245+
<plugins>
246+
<plugin>
247+
<groupId>org.apache.maven.plugins</groupId>
248+
<artifactId>maven-surefire-plugin</artifactId>
249+
<version>3.0.0</version>
250+
<configuration>
251+
<includes>
252+
<include>**/*Test.java</include>
253+
<include>**/AcceptanceTestRunner.java</include>
254+
</includes>
255+
<systemPropertyVariables>
256+
<cucumber.junit-platform.naming-strategy>long</cucumber.junit-platform.naming-strategy>
257+
</systemPropertyVariables>
258+
</configuration>
259+
</plugin>
260+
</plugins>
261+
</build>
262+
</profile>
229263
</profiles>
230264

231265
</project>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (C) 2018-2025 HERE Europe B.V.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
package com.here.platform.artifact.maven.wagon.acceptance;
21+
22+
import io.cucumber.junit.Cucumber;
23+
import io.cucumber.junit.CucumberOptions;
24+
import org.junit.runner.RunWith;
25+
26+
/**
27+
* Cucumber test runner for artifact wagon acceptance tests.
28+
* This runner executes all feature files in the features directory.
29+
*/
30+
@RunWith(Cucumber.class)
31+
@CucumberOptions(
32+
features = "src/test/resources/features",
33+
glue = "com.here.platform.artifact.maven.wagon.acceptance",
34+
plugin = {
35+
"pretty",
36+
"html:target/cucumber-reports/cucumber.html",
37+
"json:target/cucumber-reports/cucumber.json",
38+
"junit:target/cucumber-reports/cucumber.xml"
39+
},
40+
monochrome = true,
41+
tags = "not @ignore"
42+
)
43+
public class AcceptanceTestRunner {
44+
45+
}
46+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (C) 2018-2025 HERE Europe B.V.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
package com.here.platform.artifact.maven.wagon.acceptance;
21+
22+
import io.cucumber.java.After;
23+
import io.cucumber.java.Before;
24+
import io.cucumber.java.Scenario;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
28+
/**
29+
* Cucumber hooks for managing test lifecycle.
30+
* These hooks run before and after each scenario.
31+
*/
32+
public class Hooks {
33+
34+
private static final Logger LOG = LoggerFactory.getLogger(Hooks.class);
35+
36+
private final TestContext testContext;
37+
38+
public Hooks() {
39+
this.testContext = new TestContext();
40+
}
41+
42+
public Hooks(TestContext testContext) {
43+
this.testContext = testContext;
44+
}
45+
46+
@Before
47+
public void beforeScenario(Scenario scenario) {
48+
LOG.info("Starting scenario: {}", scenario.getName());
49+
LOG.info("Testing with Java version: {}", System.getProperty("java.version"));
50+
}
51+
52+
@After
53+
public void afterScenario(Scenario scenario) {
54+
LOG.info("Finished scenario: {} - Status: {}", scenario.getName(), scenario.getStatus());
55+
cleanupTempFiles();
56+
}
57+
58+
private void cleanupTempFiles() {
59+
LOG.debug("Cleaning up temporary test files");
60+
}
61+
62+
}
63+

0 commit comments

Comments
 (0)