Skip to content
Merged
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
63 changes: 63 additions & 0 deletions .github/scripts/run-acceptance-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

# Script to run acceptance tests with different Java and Maven versions
# Usage: ./run-acceptance-tests.sh [java_version] [maven_version]

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"

JAVA_VERSION=${1:-"17"}
MAVEN_VERSION=${2:-"default"}

echo "============================================"
echo "Running HERE Artifact Wagon Acceptance Tests"
echo "============================================"
echo "Java Version: $JAVA_VERSION"
echo "Maven Version: $MAVEN_VERSION"
echo "============================================"

# Set Java version if using SDKMAN
if command -v sdk &> /dev/null; then
echo "Setting Java version using SDKMAN..."
case $JAVA_VERSION in
8)
sdk use java 8.0.392-tem 2>/dev/null || echo "Java 8 not available via SDKMAN, using system default"
;;
17)
sdk use java 17.0.9-tem 2>/dev/null || echo "Java 17 not available via SDKMAN, using system default"
;;
esac
fi

# Check Java version
echo ""
echo "Current Java version:"
java -version
echo ""

# Run tests
cd "$PROJECT_DIR"

if [ "$MAVEN_VERSION" = "default" ]; then
echo "Running tests with default Maven..."
mvn clean test -Pacceptance-tests
else
echo "Running tests with Maven $MAVEN_VERSION..."
if [ -d "$HOME/.m2/maven-$MAVEN_VERSION" ]; then
"$HOME/.m2/maven-$MAVEN_VERSION/bin/mvn" clean test -Pacceptance-tests
else
echo "Maven $MAVEN_VERSION not found at $HOME/.m2/maven-$MAVEN_VERSION"
echo "Using default Maven..."
mvn clean test -Pacceptance-tests
fi
fi

echo ""
echo "============================================"
echo "Tests completed!"
echo "============================================"
echo "View reports at: target/cucumber-reports/cucumber.html"
echo ""

93 changes: 93 additions & 0 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Acceptance Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
acceptance-tests:
name: Acceptance Tests - Java ${{ matrix.java }} - Maven ${{ matrix.maven }}
runs-on: ubuntu-latest

strategy:
matrix:
java: ['17']
maven: ['3.9.0', '3.9.11']
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'

- name: Set up Maven ${{ matrix.maven }}
uses: stCarolas/[email protected]
with:
maven-version: ${{ matrix.maven }}

- name: Verify Java and Maven versions
run: |
echo "Java version:"
java -version
echo "Maven version:"
mvn -version

- name: Configure HERE credentials
env:
OLP_CREDENTIALS: ${{ secrets.OLP_CREDENTIALS }}
run: mkdir -p ~/.here/ && echo $OLP_CREDENTIALS | base64 --decode > ~/.here/credentials.properties

- name: Run acceptance tests
run: |
mvn clean install
mvn clean test -Pacceptance-tests

- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: cucumber-reports-java${{ matrix.java }}-maven${{ matrix.maven }}
path: target/cucumber-reports/
retention-days: 30

- name: Upload surefire reports
if: always()
uses: actions/upload-artifact@v4
with:
name: surefire-reports-java${{ matrix.java }}-maven${{ matrix.maven }}
path: target/surefire-reports/
retention-days: 30

- name: Publish test results
if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: |
target/cucumber-reports/cucumber.xml
target/surefire-reports/*.xml
check_name: Test Results - Java ${{ matrix.java }} - Maven ${{ matrix.maven }}

acceptance-tests-summary:
name: Acceptance Tests Summary
needs: acceptance-tests
runs-on: ubuntu-latest
if: always()

steps:
- name: Check test results
run: |
if [ "${{ needs.acceptance-tests.result }}" = "success" ]; then
echo "All acceptance tests passed!"
else
echo "Some acceptance tests failed"
exit 1
fi

34 changes: 34 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<junit.version>4.13.2</junit.version>
<mockito.version>5.12.0</mockito.version>
<commons-io.version>2.16.1</commons-io.version>
<cucumber.version>7.14.0</cucumber.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -145,6 +146,18 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -226,6 +239,27 @@
</plugins>
</build>
</profile>
<profile>
<id>acceptance-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/AcceptanceTestRunner.java</include>
</includes>
<systemPropertyVariables>
<cucumber.junit-platform.naming-strategy>long</cucumber.junit-platform.naming-strategy>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2018-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* License-Filename: LICENSE
*/

package com.here.platform.artifact.maven.wagon.acceptance;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

/**
* Cucumber test runner for artifact wagon acceptance tests.
* This runner executes all feature files in the features directory.
*/
@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/resources/features",
glue = "com.here.platform.artifact.maven.wagon.acceptance",
plugin = {
"pretty",
"html:target/cucumber-reports/cucumber.html",
"json:target/cucumber-reports/cucumber.json",
"junit:target/cucumber-reports/cucumber.xml"
},
monochrome = true,
tags = "not @ignore"
)
public class AcceptanceTestRunner {

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2018-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* License-Filename: LICENSE
*/

package com.here.platform.artifact.maven.wagon.acceptance;

import io.cucumber.java.After;
import io.cucumber.java.Before;
import io.cucumber.java.Scenario;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Cucumber hooks for managing test lifecycle.
* These hooks run before and after each scenario.
*/
public class Hooks {

private static final Logger LOG = LoggerFactory.getLogger(Hooks.class);

private final TestContext testContext;

public Hooks() {
this.testContext = new TestContext();
}

public Hooks(TestContext testContext) {
this.testContext = testContext;
}

@Before
public void beforeScenario(Scenario scenario) {
LOG.info("Starting scenario: {}", scenario.getName());
LOG.info("Testing with Java version: {}", System.getProperty("java.version"));
}

@After
public void afterScenario(Scenario scenario) {
LOG.info("Finished scenario: {} - Status: {}", scenario.getName(), scenario.getStatus());
cleanupTempFiles();
}

private void cleanupTempFiles() {
LOG.debug("Cleaning up temporary test files");
}

}

Loading