Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'

- name: Setup Gradle
Expand All @@ -33,7 +33,7 @@ jobs:
test-suite:
strategy:
matrix:
java: ['17', '11', '8']
java: ['21', '17', '11', '8']
runs-on: ubuntu-latest
name: Run test suite with Java ${{ matrix.java }}
needs: build-and-check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
persist-credentials: false
- uses: actions/setup-java@v5
with:
java-version: "17"
java-version: "21"
distribution: "temurin"
cache: gradle
- name: Setup node
Expand Down
2 changes: 0 additions & 2 deletions agent/bin/test_install
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ for d in build/fixtures/*; do
./mvnw package -quiet -DskipTests -Dcheckstyle.skip=true -Dspring-javaformat.skip=true
cd -
done

../gradlew testClasses
57 changes: 30 additions & 27 deletions agent/bin/test_projects
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
#!/usr/bin/env bash

fixture_dir=$PWD/build/fixtures
set -eo pipefail

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

cd "${AGENT_DIR}"

mkdir -p build/fixtures

# shellcheck source=../test/helper.bash
source "test/helper.bash"
export ANNOTATION_JAR="$(find_annotation_jar)"
ANNOTATION_JAR="$(find_annotation_jar)"
export ANNOTATION_JAR

function install_petclinic (
function install_petclinic() {
local repo="$1"; shift
local ref=${1:-main}
local pkg="$(basename $repo)"
local pkg
pkg="$(basename "$repo")"

if [[ -d "build/fixtures/${pkg}" ]]; then
echo "Fixture already exists: ${pkg}"
Expand Down Expand Up @@ -43,7 +51,7 @@ function install_petclinic (


cd ../../..
)
}

function install_scala_test_app {
if [[ -d "test/scala/play-samples" ]]; then
Expand All @@ -53,14 +61,13 @@ function install_scala_test_app {
cd test/scala
rm -rf play-samples
local branch=3.0.x
case "${JAVA_VERSION}" in
1.8*)
branch=2.8.x
;;
11.*)
branch=2.9.x
;;
esac
if is_java 17; then
branch=3.0.x
elif is_java 11; then
branch=2.9.x
else
branch=2.8.x
fi
git clone --no-checkout https://github.com/playframework/play-samples.git --depth 1 --branch $branch
cd play-samples
git sparse-checkout set play-scala-rest-api-example
Expand All @@ -69,20 +76,16 @@ function install_scala_test_app {
cd ../../..
}

case "${JAVA_VERSION}" in
1.8*|11.*)
install_petclinic "land-of-apps/spring-petclinic" old-java-support
;;
17.*)
# The spring-petclinic main branch now requires Java 25. This is the last commit that supports Java 17.
install_petclinic "spring-projects/spring-petclinic" "3aa79e3944ab1b626288f5d0629e61643ab8fb4a"
install_petclinic "spring-petclinic/spring-framework-petclinic"
;;
*) # For Java 25+
install_petclinic "spring-projects/spring-petclinic" "main"
install_petclinic "spring-petclinic/spring-framework-petclinic"
;;
esac
if is_java 25; then
install_petclinic "spring-projects/spring-petclinic" "main"
install_petclinic "spring-petclinic/spring-framework-petclinic"
elif is_java 17; then
# The spring-petclinic main branch now requires Java 25. This is the last commit that supports Java 17.
install_petclinic "spring-projects/spring-petclinic" "3aa79e3944ab1b626288f5d0629e61643ab8fb4a"
install_petclinic "spring-petclinic/spring-framework-petclinic"
else
install_petclinic "land-of-apps/spring-petclinic" old-java-support
fi

patch -N -p1 -d build/fixtures/spring-petclinic < test/petclinic/pom.patch

Expand Down
4 changes: 2 additions & 2 deletions agent/bin/test_run
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ set -x
# * just doing bats -r test doesn't discover a setup_suite.bash file correctly. http_client uses
# one, so it needs to be run separately

bats -r test/!(http_client)
bats -r test/http_client
bats -r test/!(http_client)/
bats -r test/http_client/
28 changes: 14 additions & 14 deletions agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ plugins {
}

repositories {
jcenter()
mavenCentral()
}

Expand Down Expand Up @@ -75,6 +74,7 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.junit.jupiter:junit-jupiter-params'
testImplementation 'org.junit.vintage:junit-vintage-engine'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

testImplementation 'com.github.stefanbirkner:system-rules:1.19.0'
testImplementation 'com.github.stefanbirkner:system-lambda:1.2.1'
Expand All @@ -85,8 +85,7 @@ dependencies {
}

compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
options.release = 8
}

jar {
Expand All @@ -97,11 +96,11 @@ jar {
}
}

apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'com.gradleup.shadow'

shadowJar {
baseName = 'appmap'
classifier = ''
archiveBaseName = 'appmap'
archiveClassifier = ''
minimize() {
// tinylog computes the dependencies it needs at runtime, so don't exclude
// anything.
Expand Down Expand Up @@ -162,6 +161,7 @@ test {
dependsOn cleanTest
exclude 'com/appland/appmap/integration/**'
// systemProperty "appmap.log.level", "debug"
jvmArgs '--add-opens', 'java.base/java.lang=ALL-UNNAMED'
}

task relocateShadowJar(type: ShadowRelocation) {
Expand All @@ -179,16 +179,16 @@ tasks.shadowJar.dependsOn tasks.relocateShadowJar

jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.enabled true
xml.required = false
csv.required = false
html.required = true
}
}

// extra artifacts used in publishing
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
classifier = 'sources'
archiveClassifier = 'sources'
}

// for some reason this block generates empty Javadoc
Expand All @@ -198,7 +198,7 @@ javadoc {
}

task mockJavadocJar(type: Jar) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}

Expand All @@ -212,8 +212,8 @@ publishing {

// 1. coordinates (parameterized)

groupId publishGroupId
artifactId publishArtifactId
groupId = publishGroupId
artifactId = publishArtifactId

// version defined globally

Expand Down Expand Up @@ -271,4 +271,4 @@ if (project.hasProperty("signingKey")) {
}
}

tasks.publishToMavenLocal.dependsOn(check, integrationTest)
tasks.publishToMavenLocal.dependsOn(check, integrationTest)
20 changes: 20 additions & 0 deletions agent/test/access/MyClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package access;

public class MyClass {
public void myMethod() {
// do nothing
}

public void callNonPublic() {
myPackageMethod();
myPrivateMethod();
}

String myPackageMethod() {
return "package method";
}

private String myPrivateMethod() {
return "private method";
}
}
3 changes: 2 additions & 1 deletion agent/test/access/RecordPackage.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package access;

import java.io.IOException;
import java.io.OutputStreamWriter;

import com.appland.appmap.record.Recorder;
import com.appland.appmap.record.Recording;
import com.appland.appmap.test.fixture.MyClass;

public class RecordPackage {
public static void main(String[] argv) {
Expand Down
21 changes: 12 additions & 9 deletions agent/test/access/access.bats
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ load '../helper'

sep="$JAVA_PATH_SEPARATOR"
AGENT_JAR="$(find_agent_jar)"
wd=$(getcwd)
test_cp="${wd}/test/access${sep}${wd}/build/classes/java/test"

# Resolves to .../agent/test
TEST_DIR="$(dirname "$BATS_TEST_DIRNAME")"

# test_cp must include 'test' (for access package) and 'test/access' (for default package)
test_cp="${TEST_DIR}${sep}${TEST_DIR}/access"
java_cmd="java -javaagent:'${AGENT_JAR}' -cp '${test_cp}'"

setup() {
javac -cp "${AGENT_JAR}${sep}${test_cp}" test/access/*.java

cd test/access
cd "$BATS_TEST_DIRNAME" || exit
javac -cp "${AGENT_JAR}" -sourcepath "$TEST_DIR" ./*.java
_configure_logging
}

Expand All @@ -22,7 +25,7 @@ setup() {
# functionaly it enables is pretty useless, though, so it seems harmless to
# hijack it.
@test "testProtected" {
local cmd="${java_cmd} RecordPackage"
local cmd="${java_cmd} access.RecordPackage"
[[ $BATS_VERBOSE_RUN == 1 ]] && echo "cmd: $cmd" >&3

# Exactly 4 events means that MyClass.myPrivateMethod was not recorded
Expand All @@ -31,7 +34,7 @@ setup() {
}

@test "testPrivate" {
local cmd="${java_cmd} -Dappmap.record.private=true RecordPackage"
local cmd="${java_cmd} -Dappmap.record.private=true access.RecordPackage"
[[ $BATS_VERBOSE_RUN == 1 ]] && echo "cmd: $cmd" >&3

# 6 events means that both myPackageMethod and myPrivateMethod were recorded
Expand All @@ -40,15 +43,15 @@ setup() {
}

@test "outside git repo" {
cp -v "$(_top_level)/agent/appmap.yml" "$BATS_TEST_TMPDIR"/.
cp -v "appmap.yml" "$BATS_TEST_TMPDIR"/.
cd "$BATS_TEST_TMPDIR"

# sanity check
run git rev-parse --show-top-level
assert_output -p 'not a git repository'
assert_failure

local cmd="${java_cmd} RecordPackage"
local cmd="${java_cmd} access.RecordPackage"
[[ $BATS_VERBOSE_RUN == 1 ]] && echo "cmd: $cmd" >&3
run bash -c "eval \"$cmd\" 2>/dev/null"
assert_success
Expand Down
2 changes: 1 addition & 1 deletion agent/test/access/appmap.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test-access
packages:
- path: com.appland.appmap.test.fixture
- path: access
- path: HelloWorld
4 changes: 2 additions & 2 deletions agent/test/classloading/classloading.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ setup_file() {
# it's easy to do (the test for BATS_VERSION will add -q to the command line
# when run as a test, but not when run in a shell).
run \
./gradlew ${BATS_VERSION+-q} -PappmapJar="$AGENT_JAR" run --args "TestSafeClassForName"
gradlew ${BATS_VERSION+-q} -PappmapJar="$AGENT_JAR" run --args "TestSafeClassForName"
assert_success
}

@test "Proxy" {
run --separate-stderr \
./gradlew ${BATS_VERSION+-q} -PappmapJar="$AGENT_JAR" run --args "TestProxy"
gradlew ${BATS_VERSION+-q} -PappmapJar="$AGENT_JAR" run --args "TestProxy"
assert_success
assert_json_eq ".events[0].defined_class" "com.appland.appmap.test.fixture.helloworld.HelloWorld"
assert_json_eq ".events[0].method_id" "getGreeting"
Expand Down
Binary file not shown.

This file was deleted.

Loading