Apache Sling JUnit Core

Clone this repo:
  1. b4c6363 Merge pull request #35 from apache/maia/task-run-13 by Carsten Ziegeler · 2 days ago master
  2. 862aaf8 Merge branch 'master' into maia/task-run-13 by Carsten Ziegeler · 2 days ago
  3. dc9e5c7 fix(servlet): sanitize sessionId before logging to prevent log injection by Carsten Ziegeler · 2 days ago
  4. 4df92e9 Merge pull request #34 from apache/maia/task-run-10 by Carsten Ziegeler · 2 days ago
  5. 679e8a0 chore: upgrade sling-bundle-parent to 66 and junit-jupiter to 6.0.3 by Carsten Ziegeler · 2 days ago

Apache Sling

Build Status Test Status Coverage Sonarcloud Status JavaDoc Maven Central junit License

Apache Sling JUnit Core

This module is part of the Apache Sling project.

Runs JUnit tests in an OSGi framework and provides the JUnit/Hamcrest APIs used by remote test bundles.

What this bundle provides

  • Test discovery and execution inside a running Sling/OSGi runtime.
  • Servlet-based test endpoints with HTML, JSON, XML, and text renderers.
  • Runtime support for JUnit 4, plus optional JUnit 5 (Jupiter/Platform) integration when JUnit 5 classes are available.
  • Exported JUnit and Hamcrest packages for remote test bundles.

Build and test

Use Maven from the repository root:

mvn -B -ntp clean package
mvn -B -ntp test
mvn -B -ntp clean verify

Notes:

  • verify is heavier than test because it also runs Maven Invoker integration tests from src/it.
  • Running src/it/annotations-it directly requires -Dannotations.bundle.version=<version>.

Repository structure

  • src/main/java - Bundle APIs and implementation.
  • src/main/resources - Static resources (for example junit.css).
  • src/test/java - Unit tests (JUnit 4 and JUnit 5).
  • src/it/annotations-it - Integration tests (Maven Invoker / Pax Exam).
  • bnd.bnd - OSGi manifest instructions, including exported JUnit/Hamcrest packages.

Key dependencies and runtime behavior

  • Uses jakarta.json-api (migration from javax.json).
  • Uses org.apache.commons:commons-lang3 3.18.0.
  • JUnit 4.13.2 and Hamcrest 1.3 are exported for remote test compatibility.
  • JUnit 5 support is optional at runtime and activated when platform classes are present.