diff --git a/.github/dependency-review-config.yml b/.github/dependency-review-config.yml
index 6d737ee55..2ea218503 100644
--- a/.github/dependency-review-config.yml
+++ b/.github/dependency-review-config.yml
@@ -27,4 +27,6 @@ allow-licenses:
- 'BSD-3-Clause-No-Nuclear-License-2014'
- 'BSD-3-Clause-No-Nuclear-Warranty'
- 'BSD-3-Clause-Open-MPI'
-comment-summary-in-pr: on-failure
\ No newline at end of file
+ # TT: D290816995
+ - 'UPL-1.0'
+comment-summary-in-pr: on-failure
diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml
index bde305dce..98e1eae6e 100644
--- a/.github/workflows/check-build.yml
+++ b/.github/workflows/check-build.yml
@@ -2,15 +2,13 @@
#
# Description:
# Runs the build for every java version we support
-#
+#
# Triggers:
# - pull_request: when a PR is sent to us
# - push: when code is pushed to a specified branch
#
# Notes:
-# The matrix build for this workflow is unusual, we need to make it dyanmic since
-# we need to change java versions we build for depending on the branch.
-
+# Builds against Java 11, 17, and 21 which are the supported versions.
on:
workflow_dispatch:
@@ -38,7 +36,7 @@ on:
push:
branches:
- main
- paths: # add other modules when there are under e2e tests
+ paths:
- 'powertools-batch/**'
- 'powertools-core/**'
- 'powertools-cloudformation/**'
@@ -60,34 +58,16 @@ on:
- '.github/workflows/**'
name: Build
+permissions:
+ contents: read
run-name: Build - ${{ github.event_name }}
jobs:
- setup:
- runs-on: ubuntu-latest
- outputs:
- build_matrix: ${{ format('{0}{1}', steps.build_matrix_v1.outputs.build_matrix, steps.build_matrix_v1.outputs.build_matrix) }}
- steps:
- - id: base
- name: Base
- run: |
- echo build_version=$(test ${{ github.ref }} == "v2" && echo "v2" || echo "v1") >> $GITHUB_OUTPUT
- - id: build_matrix_v1
- name: Build matrix (v1)
- if: ${{ steps.base.outputs.build_version == 'v1' }}
- run: |
- echo build_matrix='["8", "11", "17", "21"]' >> "$GITHUB_OUTPUT"
- - id: build_matrix_v2
- name: Build matrix (v2)
- if: ${{ steps.base.outputs.build_version == 'v2' }}
- run: |
- echo build_matrix='["11", "17", "21"]'>> "$GITHUB_OUTPUT"
- build:
+ java-build:
runs-on: ubuntu-latest
strategy:
matrix:
java:
- - 8
- 11
- 17
- 21
@@ -103,6 +83,35 @@ jobs:
cache: maven
- id: build-maven
name: Build (Maven)
- if: ${{ matrix.java != '8' }}
run: |
- mvn -B install --file pom.xml
\ No newline at end of file
+ mvn -B -q install --file pom.xml
+
+ graalvm-build:
+ runs-on: ubuntu-latest
+ steps:
+ - id: checkout
+ name: Checkout repository
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ - name: Setup GraalVM
+ uses: graalvm/setup-graalvm@7f488cf82a3629ee755e4e97342c01d6bed318fa # v1.3.5
+ with:
+ java-version: "21"
+ distribution: "graalvm"
+ cache: maven
+ - id: graalvm-native-test
+ name: GraalVM Native Test
+ run: |
+ # Build the entire project first to ensure test-jar dependencies are available
+ mvn -B -q install -DskipTests
+
+ # Find modules with graalvm-native profile and run tests recursively.
+ # This will make sure to discover new GraalVM supported modules automatically in the future.
+ find . -name "pom.xml" -path "./powertools-*" | while read module; do
+ if grep -q "graalvm-native" "$module"; then
+ module_dir=$(dirname "$module")
+ echo "Regenerating GraalVM metadata for $module_dir"
+ mvn -B -q -f "$module" -Pgenerate-graalvm-files clean test
+ echo "Running GraalVM native tests for $module_dir"
+ mvn -B -q -f "$module" -Pgraalvm-native test
+ fi
+ done
diff --git a/pom.xml b/pom.xml
index 5896ffeb7..f6ccb5056 100644
--- a/pom.xml
+++ b/pom.xml
@@ -101,7 +101,6 @@
3.11.3
3.3.1
3.2.1
- 5.10.0
1.14.1
3.5.3
0.8.13
@@ -115,8 +114,8 @@
1.12.781
2.18.0
1.7.0
- 5.18.0
- 5.18.0
+ 5.19.1-SNAPSHOT
+ 5.19.1-SNAPSHOT
2.3.0
1.5.0
@@ -132,6 +131,21 @@
+
+
+
+ Central Portal Snapshots
+ central-portal-snapshots
+ https://central.sonatype.com/repository/maven-snapshots/
+
+ false
+
+
+ true
+
+
+
+
@@ -323,7 +337,7 @@
org.junit-pioneer
junit-pioneer
- 2.0.0
+ ${junit-pioneer.version}
test
diff --git a/powertools-common/pom.xml b/powertools-common/pom.xml
index 9f8456842..ea9baa98c 100644
--- a/powertools-common/pom.xml
+++ b/powertools-common/pom.xml
@@ -14,8 +14,8 @@
-->
+ 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.0.0
powertools-common
@@ -77,13 +77,13 @@
test
- org.mockito
- mockito-core
+ org.slf4j
+ slf4j-simple
test
- org.slf4j
- slf4j-simple
+ org.mockito
+ mockito-core
test
@@ -94,7 +94,6 @@
org.mockito
mockito-subclass
- 5.18.0
test
@@ -105,7 +104,9 @@
maven-surefire-plugin
3.5.3
- -Dmockito.mock.maker=subclass -Dorg.graalvm.nativeimage.imagecode=agent -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-common,experimental-class-define-support
+
+ -Dorg.graalvm.nativeimage.imagecode=agent
+ -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-common,experimental-class-define-support
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
@@ -120,7 +121,6 @@
org.mockito
mockito-subclass
- 5.18.0
test
@@ -129,7 +129,7 @@
org.graalvm.buildtools
native-maven-plugin
- 0.11.0
+ 0.11.0
true
@@ -146,33 +146,10 @@
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--no-fallback
- -Dorg.graalvm.nativeimage.imagecode=agent
- -H:ClassInitialization=net.bytebuddy.ClassFileVersion:rerun
- -H:ClassInitialization=net.bytebuddy.utility.dispatcher.JavaDispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.Invoker$Dispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.GraalImageCode:rerun
- --initialize-at-build-time=org.slf4j.simple.SimpleLogger
- --initialize-at-build-time=org.slf4j.LoggerFactory
- --initialize-at-build-time=org.junit.Ignore
- --initialize-at-build-time=java.lang.annotation.Annotation
- --initialize-at-build-time=org.junit.runners.model.FrameworkField
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$1
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$2
- --initialize-at-build-time=net.bytebuddy.utility.dispatcher.JavaDispatcher$DynamicClassLoader
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$ForLoadedType
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$ForLoadedMethod
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Super$Instantiation$2
-
- --trace-class-initialization=net.bytebuddy.description.type.TypeDescription$ForLoadedType,net.bytebuddy.description.method.MethodDescription$ForLoadedMethod,net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
-
--verbose
--native-image-info
-H:+UnlockExperimentalVMOptions
- -H:Log=registerResource:5
+ -H:+ReportExceptionStackTraces
@@ -192,5 +169,18 @@
src/main/resources
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
diff --git a/powertools-common/src/test/java/software/amazon/lambda/powertools/common/internal/LambdaHandlerProcessorTest.java b/powertools-common/src/test/java/software/amazon/lambda/powertools/common/internal/LambdaHandlerProcessorTest.java
index 15d7bccdb..17732cdf0 100644
--- a/powertools-common/src/test/java/software/amazon/lambda/powertools/common/internal/LambdaHandlerProcessorTest.java
+++ b/powertools-common/src/test/java/software/amazon/lambda/powertools/common/internal/LambdaHandlerProcessorTest.java
@@ -33,14 +33,14 @@
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
-class LambdaHandlerProcessorTest {
+import software.amazon.lambda.powertools.common.stubs.TestLambdaContext;
- private Signature signature = mock(Signature.class);
- private ProceedingJoinPoint pjpMock = mock(ProceedingJoinPoint.class);
+class LambdaHandlerProcessorTest {
@Test
void isHandlerMethod_shouldRecognizeRequestHandler() {
- Object[] args = {new Object(), mock(Context.class)};
+ Context context = new TestLambdaContext();
+ Object[] args = { new Object(), context };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(RequestHandler.class, args);
assertThat(LambdaHandlerProcessor.isHandlerMethod(pjpMock)).isTrue();
@@ -48,7 +48,7 @@ void isHandlerMethod_shouldRecognizeRequestHandler() {
@Test
void isHandlerMethod_shouldRecognizeRequestStreamHandler() {
- Object[] args = {mock(InputStream.class), mock(OutputStream.class), mock(Context.class)};
+ Object[] args = { mock(InputStream.class), mock(OutputStream.class), new TestLambdaContext() };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(RequestStreamHandler.class, args);
assertThat(LambdaHandlerProcessor.isHandlerMethod(pjpMock)).isTrue();
@@ -65,7 +65,7 @@ void isHandlerMethod_shouldReturnFalse() {
@Test
void placedOnRequestHandler_shouldRecognizeRequestHandler() {
- Object[] args = {new Object(), mock(Context.class)};
+ Object[] args = { new Object(), new TestLambdaContext() };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(RequestHandler.class, args);
assertThat(LambdaHandlerProcessor.placedOnRequestHandler(pjpMock)).isTrue();
@@ -73,7 +73,7 @@ void placedOnRequestHandler_shouldRecognizeRequestHandler() {
@Test
void placedOnStreamHandler_shouldRecognizeRequestStreamHandler() {
- Object[] args = {mock(InputStream.class), mock(OutputStream.class), mock(Context.class)};
+ Object[] args = { mock(InputStream.class), mock(OutputStream.class), new TestLambdaContext() };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(RequestStreamHandler.class, args);
assertThat(LambdaHandlerProcessor.placedOnStreamHandler(pjpMock)).isTrue();
@@ -81,7 +81,7 @@ void placedOnStreamHandler_shouldRecognizeRequestStreamHandler() {
@Test
void placedOnRequestHandler_shouldInvalidateOnWrongNoOfArgs() {
- Object[] args = {new Object()};
+ Object[] args = { new Object() };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(RequestHandler.class, args);
boolean isPlacedOnRequestHandler = LambdaHandlerProcessor.placedOnRequestHandler(pjpMock);
@@ -91,7 +91,7 @@ void placedOnRequestHandler_shouldInvalidateOnWrongNoOfArgs() {
@Test
void placedOnRequestHandler_shouldInvalidateOnWrongTypeOfArgs() {
- Object[] args = {new Object(), new Object()};
+ Object[] args = { new Object(), new Object() };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(RequestHandler.class, args);
boolean isPlacedOnRequestHandler = LambdaHandlerProcessor.placedOnRequestHandler(pjpMock);
@@ -101,7 +101,7 @@ void placedOnRequestHandler_shouldInvalidateOnWrongTypeOfArgs() {
@Test
void placedOnStreamHandler_shouldInvalidateOnWrongNoOfArgs() {
- Object[] args = {new Object()};
+ Object[] args = { new Object() };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(RequestStreamHandler.class, args);
boolean isPlacedOnStreamHandler = LambdaHandlerProcessor.placedOnStreamHandler(pjpMock);
@@ -111,7 +111,7 @@ void placedOnStreamHandler_shouldInvalidateOnWrongNoOfArgs() {
@Test
void placedOnStreamHandler_shouldInvalidateOnWrongTypeOfArgs() {
- Object[] args = {new Object(), new Object(), new Object()};
+ Object[] args = { new Object(), new Object(), new Object() };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(RequestStreamHandler.class, args);
boolean isPlacedOnStreamHandler = LambdaHandlerProcessor.placedOnStreamHandler(pjpMock);
@@ -121,7 +121,7 @@ void placedOnStreamHandler_shouldInvalidateOnWrongTypeOfArgs() {
@Test
void placedOnStreamHandler_shouldInvalidateOnTypeOfArgs_invalidOutputStreamArg() {
- Object[] args = {mock(InputStream.class), new Object(), mock(Context.class)};
+ Object[] args = { mock(InputStream.class), new Object(), new TestLambdaContext() };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(RequestStreamHandler.class, args);
boolean isPlacedOnStreamHandler = LambdaHandlerProcessor.placedOnStreamHandler(pjpMock);
@@ -131,7 +131,7 @@ void placedOnStreamHandler_shouldInvalidateOnTypeOfArgs_invalidOutputStreamArg()
@Test
void placedOnStreamHandler_shouldInvalidateOnTypeOfArgs_invalidContextArg() {
- Object[] args = {mock(InputStream.class), mock(OutputStream.class), new Object()};
+ Object[] args = { mock(InputStream.class), mock(OutputStream.class), new Object() };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(RequestStreamHandler.class, args);
boolean isPlacedOnStreamHandler = LambdaHandlerProcessor.placedOnStreamHandler(pjpMock);
@@ -144,9 +144,9 @@ void placedOnStreamHandler_shouldInvalidateOnTypeOfArgs_invalidContextArg() {
void getXrayTraceId_present() {
String traceID = "Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1\"";
- Optional xRayTraceId = LambdaHandlerProcessor.getXrayTraceId();
+ Optional xRayTraceId = LambdaHandlerProcessor.getXrayTraceId();
- assertThat(xRayTraceId.isPresent()).isTrue();
+ assertThat(xRayTraceId).isPresent();
assertThat(traceID.split(";")[0].replace(LambdaConstants.ROOT_EQUALS, "")).isEqualTo(xRayTraceId.get());
}
@@ -161,7 +161,7 @@ void getXrayTraceId_notPresent() {
@Test
void extractContext_fromRequestHandler() {
- Object[] args = {new Object(), mock(Context.class)};
+ Object[] args = { new Object(), new TestLambdaContext() };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(RequestHandler.class, args);
Context context = LambdaHandlerProcessor.extractContext(pjpMock);
@@ -171,7 +171,7 @@ void extractContext_fromRequestHandler() {
@Test
void extractContext_fromStreamRequestHandler() {
- Object[] args = {mock(InputStream.class), mock(OutputStream.class), mock(Context.class)};
+ Object[] args = { mock(InputStream.class), mock(OutputStream.class), new TestLambdaContext() };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(RequestStreamHandler.class, args);
Context context = LambdaHandlerProcessor.extractContext(pjpMock);
@@ -181,7 +181,7 @@ void extractContext_fromStreamRequestHandler() {
@Test
void extractContext_notKnownHandler() {
- Object[] args = {new Object()};
+ Object[] args = { new Object() };
ProceedingJoinPoint pjpMock = mockRequestHandlerPjp(Object.class, args);
Context context = LambdaHandlerProcessor.extractContext(pjpMock);
@@ -230,10 +230,15 @@ void serviceName_Undefined() {
assertThat(LambdaHandlerProcessor.serviceName()).isEqualTo(LambdaConstants.SERVICE_UNDEFINED);
}
- private ProceedingJoinPoint mockRequestHandlerPjp(Class handlerClass, Object[] handlerArgs) {
+ private ProceedingJoinPoint mockRequestHandlerPjp(Class> handlerClass, Object[] handlerArgs) {
+ ProceedingJoinPoint pjp = mock(ProceedingJoinPoint.class);
+ Signature signature = mock(Signature.class);
+
when(signature.getDeclaringType()).thenReturn(handlerClass);
- when(pjpMock.getArgs()).thenReturn(handlerArgs);
- when(pjpMock.getSignature()).thenReturn(signature);
- return pjpMock;
+ when(signature.getName()).thenReturn("handleRequest");
+ when(pjp.getSignature()).thenReturn(signature);
+ when(pjp.getArgs()).thenReturn(handlerArgs);
+
+ return pjp;
}
}
diff --git a/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/testutils/TestContext.java b/powertools-common/src/test/java/software/amazon/lambda/powertools/common/stubs/TestLambdaContext.java
similarity index 73%
rename from powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/testutils/TestContext.java
rename to powertools-common/src/test/java/software/amazon/lambda/powertools/common/stubs/TestLambdaContext.java
index c4f5e4455..6b66b66b7 100644
--- a/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/testutils/TestContext.java
+++ b/powertools-common/src/test/java/software/amazon/lambda/powertools/common/stubs/TestLambdaContext.java
@@ -12,14 +12,14 @@
*
*/
-package software.amazon.lambda.powertools.metrics.testutils;
+package software.amazon.lambda.powertools.common.stubs;
+import com.amazonaws.services.lambda.runtime.ClientContext;
+import com.amazonaws.services.lambda.runtime.CognitoIdentity;
import com.amazonaws.services.lambda.runtime.Context;
+import com.amazonaws.services.lambda.runtime.LambdaLogger;
-/**
- * Simple Lambda context implementation for unit tests
- */
-public class TestContext implements Context {
+public class TestLambdaContext implements Context {
@Override
public String getAwsRequestId() {
return "test-request-id";
@@ -42,27 +42,27 @@ public String getFunctionName() {
@Override
public String getFunctionVersion() {
- return "test-version";
+ return "1";
}
@Override
public String getInvokedFunctionArn() {
- return "test-arn";
+ return "arn:aws:lambda:us-east-1:123456789012:function:test";
}
@Override
- public com.amazonaws.services.lambda.runtime.CognitoIdentity getIdentity() {
+ public CognitoIdentity getIdentity() {
return null;
}
@Override
- public com.amazonaws.services.lambda.runtime.ClientContext getClientContext() {
+ public ClientContext getClientContext() {
return null;
}
@Override
public int getRemainingTimeInMillis() {
- return 1000;
+ return 30000;
}
@Override
@@ -71,7 +71,7 @@ public int getMemoryLimitInMB() {
}
@Override
- public com.amazonaws.services.lambda.runtime.LambdaLogger getLogger() {
+ public LambdaLogger getLogger() {
return null;
}
}
diff --git a/powertools-logging/pom.xml b/powertools-logging/pom.xml
index 7757be572..7a288870a 100644
--- a/powertools-logging/pom.xml
+++ b/powertools-logging/pom.xml
@@ -14,8 +14,8 @@
-->
+ 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.0.0
@@ -67,11 +67,6 @@
junit-jupiter-engine
test
-
- org.mockito
- mockito-core
- test
-
org.slf4j
slf4j-simple
@@ -112,18 +107,17 @@
jsonassert
test
+
+ software.amazon.lambda
+ powertools-common
+ ${project.version}
+ test-jar
+ test
+
generate-graalvm-files
-
-
- org.mockito
- mockito-subclass
- 5.18.0
- test
-
-
@@ -131,7 +125,9 @@
maven-surefire-plugin
3.5.3
- -Dmockito.mock.maker=subclass -Dorg.graalvm.nativeimage.imagecode=agent -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging,experimental-class-define-support
+
+ -Dorg.graalvm.nativeimage.imagecode=agent
+ -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging,experimental-class-define-support
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
@@ -142,20 +138,12 @@
graalvm-native
-
-
- org.mockito
- mockito-subclass
- 5.18.0
- test
-
-
org.graalvm.buildtools
native-maven-plugin
- 0.11.0
+ 0.11.0
true
@@ -172,30 +160,10 @@
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--no-fallback
- -Dorg.graalvm.nativeimage.imagecode=agent
- -H:ClassInitialization=net.bytebuddy.ClassFileVersion:rerun
- -H:ClassInitialization=net.bytebuddy.utility.dispatcher.JavaDispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.Invoker$Dispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.GraalImageCode:rerun
- --initialize-at-build-time=org.slf4j.simple.SimpleLogger
- --initialize-at-build-time=org.slf4j.LoggerFactory
- --initialize-at-build-time=org.junit.Ignore
- --initialize-at-build-time=java.lang.annotation.Annotation
- --initialize-at-build-time=org.junit.runners.model.FrameworkField
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$1
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$2
- --initialize-at-build-time=net.bytebuddy.utility.dispatcher.JavaDispatcher$DynamicClassLoader
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$ForLoadedType
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$ForLoadedMethod
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Super$Instantiation$2
-
- --trace-class-initialization=net.bytebuddy.description.type.TypeDescription$ForLoadedType,net.bytebuddy.description.method.MethodDescription$ForLoadedMethod,net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
-
--verbose
+ --native-image-info
+ -H:+UnlockExperimentalVMOptions
+ -H:+ReportExceptionStackTraces
diff --git a/powertools-logging/powertools-logging-log4j/pom.xml b/powertools-logging/powertools-logging-log4j/pom.xml
index 88e1ced39..836f8c53f 100644
--- a/powertools-logging/powertools-logging-log4j/pom.xml
+++ b/powertools-logging/powertools-logging-log4j/pom.xml
@@ -1,7 +1,7 @@
+ 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.0.0
@@ -51,11 +51,6 @@
junit-jupiter-engine
test
-
- org.mockito
- mockito-core
- test
-
org.junit-pioneer
junit-pioneer
@@ -91,18 +86,17 @@
jsonassert
test
+
+ software.amazon.lambda
+ powertools-common
+ ${project.version}
+ test-jar
+ test
+
generate-graalvm-files
-
-
- org.mockito
- mockito-subclass
- 5.18.0
- test
-
-
@@ -110,7 +104,9 @@
maven-surefire-plugin
3.5.3
- -Dmockito.mock.maker=subclass -Dorg.graalvm.nativeimage.imagecode=agent -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-log4j,experimental-class-define-support
+
+ -Dorg.graalvm.nativeimage.imagecode=agent
+ -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-log4j,experimental-class-define-support
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
@@ -121,20 +117,12 @@
graalvm-native
-
-
- org.mockito
- mockito-subclass
- 5.18.0
- test
-
-
org.graalvm.buildtools
native-maven-plugin
- 0.11.0
+ 0.11.0
true
@@ -148,33 +136,16 @@
powertools-logging-log4j
+
+ --initialize-at-build-time=org.junit.platform.launcher.core.DiscoveryIssueNotifier$1
+
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--no-fallback
- -Dorg.graalvm.nativeimage.imagecode=agent
- -H:ClassInitialization=net.bytebuddy.ClassFileVersion:rerun
- -H:ClassInitialization=net.bytebuddy.utility.dispatcher.JavaDispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.Invoker$Dispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.GraalImageCode:rerun
- --initialize-at-build-time=org.slf4j.simple.SimpleLogger
- --initialize-at-build-time=org.slf4j.LoggerFactory
- --initialize-at-build-time=org.junit.Ignore
- --initialize-at-build-time=java.lang.annotation.Annotation
- --initialize-at-build-time=org.junit.runners.model.FrameworkField
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$1
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$2
- --initialize-at-build-time=net.bytebuddy.utility.dispatcher.JavaDispatcher$DynamicClassLoader
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$ForLoadedType
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$ForLoadedMethod
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Super$Instantiation$2
-
- --trace-class-initialization=net.bytebuddy.description.type.TypeDescription$ForLoadedType,net.bytebuddy.description.method.MethodDescription$ForLoadedMethod,net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
-
--verbose
+ --native-image-info
+ -H:+UnlockExperimentalVMOptions
+ -H:+ReportExceptionStackTraces
@@ -234,5 +205,4 @@
-
diff --git a/powertools-logging/powertools-logging-log4j/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/PowerToolsResolverFactoryTest.java b/powertools-logging/powertools-logging-log4j/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/PowerToolsResolverFactoryTest.java
index 4cf798a47..7ea81d690 100644
--- a/powertools-logging/powertools-logging-log4j/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/PowerToolsResolverFactoryTest.java
+++ b/powertools-logging/powertools-logging-log4j/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/PowerToolsResolverFactoryTest.java
@@ -17,37 +17,36 @@
import static org.apache.commons.lang3.reflect.FieldUtils.writeStaticField;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.openMocks;
-import com.amazonaws.services.lambda.runtime.Context;
import java.io.File;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.file.NoSuchFileException;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
+
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
-import org.mockito.Mock;
import org.slf4j.MDC;
+
+import com.amazonaws.services.lambda.runtime.Context;
+
import software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor;
+import software.amazon.lambda.powertools.common.stubs.TestLambdaContext;
import software.amazon.lambda.powertools.logging.internal.handler.PowertoolsLogEnabled;
@Order(1)
class PowerToolsResolverFactoryTest {
- @Mock
private Context context;
@BeforeEach
void setUp() throws IllegalAccessException, IOException {
- openMocks(this);
MDC.clear();
writeStaticField(LambdaHandlerProcessor.class, "IS_COLD_START", null, true);
- setupContext();
+ context = new TestLambdaContext();
// Make sure file is cleaned up before running tests
try {
FileChannel.open(Paths.get("target/logfile.json"), StandardOpenOption.WRITE).truncate(0).close();
@@ -58,7 +57,7 @@ void setUp() throws IllegalAccessException, IOException {
}
@AfterEach
- void cleanUp() throws IOException{
+ void cleanUp() throws IOException {
FileChannel.open(Paths.get("target/logfile.json"), StandardOpenOption.WRITE).truncate(0).close();
FileChannel.open(Paths.get("target/ecslogfile.json"), StandardOpenOption.WRITE).truncate(0).close();
}
@@ -70,7 +69,7 @@ void shouldLogInJsonFormat() {
File logFile = new File("target/logfile.json");
assertThat(contentOf(logFile)).contains(
- "{\"level\":\"DEBUG\",\"message\":\"Test debug event\",\"cold_start\":true,\"function_arn\":\"arn:aws:lambda:eu-west-1:012345678910:function:testFunction:1\",\"function_memory_size\":1024,\"function_name\":\"testFunction\",\"function_request_id\":\"RequestId\",\"function_version\":\"1\",\"service\":\"testLog4j\",\"timestamp\":")
+ "{\"level\":\"DEBUG\",\"message\":\"Test debug event\",\"cold_start\":true,\"function_arn\":\"arn:aws:lambda:us-east-1:123456789012:function:test\",\"function_memory_size\":128,\"function_name\":\"test-function\",\"function_request_id\":\"test-request-id\",\"function_version\":\"1\",\"service\":\"testLog4j\",\"timestamp\":")
.contains("\"xray_trace_id\":\"1-63441c4a-abcdef012345678912345678\",\"myKey\":\"myValue\"}\n");
}
@@ -81,15 +80,7 @@ void shouldLogInEcsFormat() {
File logFile = new File("target/ecslogfile.json");
assertThat(contentOf(logFile)).contains(
- "\"ecs.version\":\"1.2.0\",\"log.level\":\"DEBUG\",\"message\":\"Test debug event\",\"service.name\":\"testLog4j\",\"service.version\":\"1\",\"log.logger\":\"software.amazon.lambda.powertools.logging.internal.handler.PowertoolsLogEnabled\",\"process.thread.name\":\"main\",\"cloud.provider\":\"aws\",\"cloud.service.name\":\"lambda\",\"cloud.region\":\"eu-central-1\",\"cloud.account.id\":\"012345678910\",\"faas.id\":\"arn:aws:lambda:eu-west-1:012345678910:function:testFunction:1\",\"faas.name\":\"testFunction\",\"faas.version\":\"1\",\"faas.memory\":1024,\"faas.execution\":\"RequestId\",\"faas.coldstart\":true,\"trace.id\":\"1-63441c4a-abcdef012345678912345678\",\"myKey\":\"myValue\"}\n");
+ "\"ecs.version\":\"1.2.0\",\"log.level\":\"DEBUG\",\"message\":\"Test debug event\",\"service.name\":\"testLog4j\",\"service.version\":\"1\",\"log.logger\":\"software.amazon.lambda.powertools.logging.internal.handler.PowertoolsLogEnabled\",\"process.thread.name\":\"main\",\"cloud.provider\":\"aws\",\"cloud.service.name\":\"lambda\",\"cloud.region\":\"eu-central-1\",\"cloud.account.id\":\"123456789012\",\"faas.id\":\"arn:aws:lambda:us-east-1:123456789012:function:test\",\"faas.name\":\"test-function\",\"faas.version\":\"1\",\"faas.memory\":128,\"faas.execution\":\"test-request-id\",\"faas.coldstart\":true,\"trace.id\":\"1-63441c4a-abcdef012345678912345678\",\"myKey\":\"myValue\"}\n");
}
- private void setupContext() {
- when(context.getFunctionName()).thenReturn("testFunction");
- when(context.getInvokedFunctionArn()).thenReturn(
- "arn:aws:lambda:eu-west-1:012345678910:function:testFunction:1");
- when(context.getFunctionVersion()).thenReturn("1");
- when(context.getMemoryLimitInMB()).thenReturn(1024);
- when(context.getAwsRequestId()).thenReturn("RequestId");
- }
}
diff --git a/powertools-logging/powertools-logging-log4j/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/PowertoolsResolverArgumentsTest.java b/powertools-logging/powertools-logging-log4j/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/PowertoolsResolverArgumentsTest.java
index 463ad043d..5432e45ae 100644
--- a/powertools-logging/powertools-logging-log4j/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/PowertoolsResolverArgumentsTest.java
+++ b/powertools-logging/powertools-logging-log4j/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/PowertoolsResolverArgumentsTest.java
@@ -16,11 +16,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.openMocks;
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.services.lambda.runtime.events.SQSEvent;
import java.io.File;
import java.io.IOException;
import java.nio.channels.FileChannel;
@@ -29,27 +25,29 @@
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.util.Collections;
+
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
-import org.mockito.Mock;
import org.slf4j.MDC;
+import com.amazonaws.services.lambda.runtime.Context;
+import com.amazonaws.services.lambda.runtime.events.SQSEvent;
+
+import software.amazon.lambda.powertools.common.stubs.TestLambdaContext;
import software.amazon.lambda.powertools.logging.internal.PowertoolsLoggedFields;
import software.amazon.lambda.powertools.logging.internal.handler.PowertoolsArguments;
@Order(2)
class PowertoolsResolverArgumentsTest {
- @Mock
private Context context;
@BeforeEach
void setUp() throws IOException {
- openMocks(this);
MDC.clear();
- setupContext();
+ context = new TestLambdaContext();
try {
FileChannel.open(Paths.get("target/logfile.json"), StandardOpenOption.WRITE).truncate(0).close();
@@ -61,7 +59,7 @@ void setUp() throws IOException {
@AfterEach
void cleanUp() throws IOException {
- //Make sure file is cleaned up before running full stack logging regression
+ // Make sure file is cleaned up before running full stack logging regression
FileChannel.open(Paths.get("target/logfile.json"), StandardOpenOption.WRITE).truncate(0).close();
FileChannel.open(Paths.get("target/ecslogfile.json"), StandardOpenOption.WRITE).truncate(0).close();
}
@@ -74,7 +72,7 @@ void shouldLogArgumentsAsJsonWhenUsingRawJson() {
msg.setMessageId("1212abcd");
msg.setBody("plop");
msg.setEventSource("eb");
- msg.setAwsRegion("eu-west-1");
+ msg.setAwsRegion("us-east-1");
SQSEvent.MessageAttribute attribute = new SQSEvent.MessageAttribute();
attribute.setStringListValues(Arrays.asList("val1", "val2", "val3"));
msg.setMessageAttributes(Collections.singletonMap("keyAttribute", attribute));
@@ -86,7 +84,7 @@ void shouldLogArgumentsAsJsonWhenUsingRawJson() {
File logFile = new File("target/logfile.json");
assertThat(contentOf(logFile))
.contains(
- "\"input\":{\"awsRegion\":\"eu-west-1\",\"body\":\"plop\",\"eventSource\":\"eb\",\"messageAttributes\":{\"keyAttribute\":{\"stringListValues\":[\"val1\",\"val2\",\"val3\"]}},\"messageId\":\"1212abcd\"}")
+ "\"input\":{\"awsRegion\":\"us-east-1\",\"body\":\"plop\",\"eventSource\":\"eb\",\"messageAttributes\":{\"keyAttribute\":{\"stringListValues\":[\"val1\",\"val2\",\"val3\"]}},\"messageId\":\"1212abcd\"}")
.contains("\"message\":\"1212abcd\"")
.contains("\"message\":\"Message body = plop and id = \\\"1212abcd\\\"\"");
// Reserved keys should be ignored
@@ -106,7 +104,7 @@ void shouldLogArgumentsAsJsonWhenUsingKeyValue() {
msg.setMessageId("1212abcd");
msg.setBody("plop");
msg.setEventSource("eb");
- msg.setAwsRegion("eu-west-1");
+ msg.setAwsRegion("us-east-1");
SQSEvent.MessageAttribute attribute = new SQSEvent.MessageAttribute();
attribute.setStringListValues(Arrays.asList("val1", "val2", "val3"));
msg.setMessageAttributes(Collections.singletonMap("keyAttribute", attribute));
@@ -118,7 +116,7 @@ void shouldLogArgumentsAsJsonWhenUsingKeyValue() {
File logFile = new File("target/logfile.json");
assertThat(contentOf(logFile))
.contains(
- "\"input\":{\"awsRegion\":\"eu-west-1\",\"body\":\"plop\",\"eventSource\":\"eb\",\"messageAttributes\":{\"keyAttribute\":{\"stringListValues\":[\"val1\",\"val2\",\"val3\"]}},\"messageId\":\"1212abcd\"}")
+ "\"input\":{\"awsRegion\":\"us-east-1\",\"body\":\"plop\",\"eventSource\":\"eb\",\"messageAttributes\":{\"keyAttribute\":{\"stringListValues\":[\"val1\",\"val2\",\"val3\"]}},\"messageId\":\"1212abcd\"}")
.contains("\"message\":\"1212abcd\"")
.contains("\"message\":\"Message body = plop and id = \\\"1212abcd\\\"\"");
@@ -131,11 +129,4 @@ void shouldLogArgumentsAsJsonWhenUsingKeyValue() {
});
}
- private void setupContext() {
- when(context.getFunctionName()).thenReturn("testFunction");
- when(context.getInvokedFunctionArn()).thenReturn("testArn");
- when(context.getFunctionVersion()).thenReturn("1");
- when(context.getMemoryLimitInMB()).thenReturn(10);
- when(context.getAwsRequestId()).thenReturn("RequestId");
- }
}
diff --git a/powertools-logging/powertools-logging-logback/pom.xml b/powertools-logging/powertools-logging-logback/pom.xml
index 41750ec70..433a3774a 100644
--- a/powertools-logging/powertools-logging-logback/pom.xml
+++ b/powertools-logging/powertools-logging-logback/pom.xml
@@ -1,7 +1,7 @@
+ 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.0.0
powertools-parent
@@ -49,8 +49,10 @@
test
- org.mockito
- mockito-core
+ software.amazon.lambda
+ powertools-common
+ ${project.version}
+ test-jar
test
@@ -88,14 +90,6 @@
generate-graalvm-files
-
-
- org.mockito
- mockito-subclass
- 5.18.0
- test
-
-
@@ -103,7 +97,12 @@
maven-surefire-plugin
3.5.3
- -Dmockito.mock.maker=subclass -Dorg.graalvm.nativeimage.imagecode=agent -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback,experimental-class-define-support
+
+ -Dorg.graalvm.nativeimage.imagecode=agent
+ -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback,experimental-class-define-support
+ --add-opens java.base/java.util=ALL-UNNAMED
+ --add-opens java.base/java.lang=ALL-UNNAMED
+
@@ -111,20 +110,12 @@
graalvm-native
-
-
- org.mockito
- mockito-subclass
- 5.18.0
- test
-
-
org.graalvm.buildtools
native-maven-plugin
- 0.11.0
+ 0.11.0
true
@@ -136,37 +127,18 @@
-
- true
- Standard
-
powertools-logging-logback
- --no-fallback
- -Dorg.graalvm.nativeimage.imagecode=agent
- -H:ClassInitialization=net.bytebuddy.ClassFileVersion:rerun
- -H:ClassInitialization=net.bytebuddy.utility.dispatcher.JavaDispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.Invoker$Dispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.GraalImageCode:rerun
- --initialize-at-build-time=org.slf4j.simple.SimpleLogger
- --initialize-at-build-time=org.slf4j.LoggerFactory
- --initialize-at-build-time=org.junit.Ignore
- --initialize-at-build-time=java.lang.annotation.Annotation
- --initialize-at-build-time=org.junit.runners.model.FrameworkField
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$1
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$2
- --initialize-at-build-time=net.bytebuddy.utility.dispatcher.JavaDispatcher$DynamicClassLoader
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$ForLoadedType
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$ForLoadedMethod
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Super$Instantiation$2
- --trace-class-initialization=net.bytebuddy.description.type.TypeDescription$ForLoadedType,net.bytebuddy.description.method.MethodDescription$ForLoadedMethod,net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
+ --initialize-at-build-time=org.junit.platform.launcher.core.DiscoveryIssueNotifier$1
+ --add-opens java.base/java.util=ALL-UNNAMED
+ --add-opens java.base/java.lang=ALL-UNNAMED
+ --no-fallback
--verbose
+ --native-image-info
+ -H:+UnlockExperimentalVMOptions
+ -H:+ReportExceptionStackTraces
@@ -227,6 +199,4 @@
-
-
diff --git a/powertools-logging/powertools-logging-logback/src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback/jni-config.json b/powertools-logging/powertools-logging-logback/src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback/jni-config.json
index 2c4de0562..753dafdea 100644
--- a/powertools-logging/powertools-logging-logback/src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback/jni-config.json
+++ b/powertools-logging/powertools-logging-logback/src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback/jni-config.json
@@ -15,10 +15,6 @@
"name":"org.apache.maven.surefire.booter.ForkedBooter",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
},
-{
- "name":"sun.instrument.InstrumentationImpl",
- "methods":[{"name":"","parameterTypes":["long","boolean","boolean","boolean"] }, {"name":"loadClassAndCallAgentmain","parameterTypes":["java.lang.String","java.lang.String"] }, {"name":"loadClassAndCallPremain","parameterTypes":["java.lang.String","java.lang.String"] }, {"name":"transform","parameterTypes":["java.lang.Module","java.lang.ClassLoader","java.lang.String","java.lang.Class","java.security.ProtectionDomain","byte[]","boolean"] }]
-},
{
"name":"sun.management.VMManagementImpl",
"fields":[{"name":"compTimeMonitoringSupport"}, {"name":"currentThreadCpuTimeSupport"}, {"name":"objectMonitorUsageSupport"}, {"name":"otherThreadCpuTimeSupport"}, {"name":"remoteDiagnosticCommandsSupport"}, {"name":"synchronizerUsageSupport"}, {"name":"threadAllocatedMemorySupport"}, {"name":"threadContentionMonitoringSupport"}]
diff --git a/powertools-logging/powertools-logging-logback/src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback/reflect-config.json b/powertools-logging/powertools-logging-logback/src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback/reflect-config.json
index 0d3bdbe7e..683933a77 100644
--- a/powertools-logging/powertools-logging-logback/src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback/reflect-config.json
+++ b/powertools-logging/powertools-logging-logback/src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback/reflect-config.json
@@ -21,11 +21,7 @@
"methods":[{"name":"valueOf","parameterTypes":["java.lang.String"] }]
},
{
- "name":"com.amazonaws.services.lambda.runtime.Context",
- "queryAllDeclaredMethods":true,
- "queryAllPublicMethods":true,
- "queryAllDeclaredConstructors":true,
- "methods":[{"name":"getAwsRequestId","parameterTypes":[] }, {"name":"getClientContext","parameterTypes":[] }, {"name":"getFunctionName","parameterTypes":[] }, {"name":"getFunctionVersion","parameterTypes":[] }, {"name":"getIdentity","parameterTypes":[] }, {"name":"getInvokedFunctionArn","parameterTypes":[] }, {"name":"getLogGroupName","parameterTypes":[] }, {"name":"getLogStreamName","parameterTypes":[] }, {"name":"getLogger","parameterTypes":[] }, {"name":"getMemoryLimitInMB","parameterTypes":[] }, {"name":"getRemainingTimeInMillis","parameterTypes":[] }]
+ "name":"com.amazonaws.services.lambda.runtime.Context"
},
{
"name":"com.amazonaws.services.lambda.runtime.events.SQSEvent$MessageAttribute",
@@ -49,12 +45,6 @@
"name":"com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl",
"methods":[{"name":"","parameterTypes":[] }]
},
-{
- "name":"com.sun.tools.attach.VirtualMachine"
-},
-{
- "name":"java.io.FilePermission"
-},
{
"name":"java.io.IOException"
},
@@ -66,132 +56,64 @@
},
{
"name":"java.io.Serializable",
- "queryAllDeclaredMethods":true,
- "queryAllDeclaredConstructors":true
-},
-{
- "name":"java.lang.Class",
- "methods":[{"name":"forName","parameterTypes":["java.lang.String"] }, {"name":"getAnnotatedInterfaces","parameterTypes":[] }, {"name":"getAnnotatedSuperclass","parameterTypes":[] }, {"name":"getDeclaredMethod","parameterTypes":["java.lang.String","java.lang.Class[]"] }, {"name":"getMethod","parameterTypes":["java.lang.String","java.lang.Class[]"] }, {"name":"getModule","parameterTypes":[] }, {"name":"getNestHost","parameterTypes":[] }, {"name":"getNestMembers","parameterTypes":[] }, {"name":"getPermittedSubclasses","parameterTypes":[] }, {"name":"getRecordComponents","parameterTypes":[] }, {"name":"isNestmateOf","parameterTypes":["java.lang.Class"] }, {"name":"isRecord","parameterTypes":[] }, {"name":"isSealed","parameterTypes":[] }]
-},
-{
- "name":"java.lang.ClassLoader",
- "methods":[{"name":"getDefinedPackage","parameterTypes":["java.lang.String"] }, {"name":"getUnnamedModule","parameterTypes":[] }, {"name":"registerAsParallelCapable","parameterTypes":[] }]
+ "queryAllDeclaredMethods":true
},
{
"name":"java.lang.Cloneable",
"queryAllDeclaredMethods":true
},
{
- "name":"java.lang.Module",
- "methods":[{"name":"addExports","parameterTypes":["java.lang.String","java.lang.Module"] }, {"name":"addReads","parameterTypes":["java.lang.Module"] }, {"name":"canRead","parameterTypes":["java.lang.Module"] }, {"name":"getClassLoader","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }, {"name":"getPackages","parameterTypes":[] }, {"name":"getResourceAsStream","parameterTypes":["java.lang.String"] }, {"name":"isExported","parameterTypes":["java.lang.String"] }, {"name":"isExported","parameterTypes":["java.lang.String","java.lang.Module"] }, {"name":"isNamed","parameterTypes":[] }, {"name":"isOpen","parameterTypes":["java.lang.String","java.lang.Module"] }]
-},
-{
- "name":"java.lang.Object",
- "queryAllDeclaredMethods":true,
- "queryAllDeclaredConstructors":true,
- "methods":[{"name":"","parameterTypes":[] }, {"name":"clone","parameterTypes":[] }, {"name":"getClass","parameterTypes":[] }, {"name":"toString","parameterTypes":[] }]
-},
-{
- "name":"java.lang.ProcessHandle",
- "methods":[{"name":"current","parameterTypes":[] }, {"name":"pid","parameterTypes":[] }]
-},
-{
- "name":"java.lang.Runtime",
- "methods":[{"name":"version","parameterTypes":[] }]
-},
-{
- "name":"java.lang.Runtime$Version",
- "methods":[{"name":"feature","parameterTypes":[] }]
+ "name":"java.lang.Iterable",
+ "queryAllDeclaredMethods":true
},
{
- "name":"java.lang.RuntimePermission"
+ "name":"java.lang.Object"
},
{
- "name":"java.lang.StackWalker"
+ "name":"java.lang.String"
},
{
- "name":"java.lang.String"
+ "name":"java.util.AbstractCollection",
+ "allDeclaredFields":true,
+ "queryAllDeclaredMethods":true
},
{
- "name":"java.lang.System",
- "methods":[{"name":"getSecurityManager","parameterTypes":[] }]
+ "name":"java.util.AbstractList",
+ "allDeclaredFields":true,
+ "queryAllDeclaredMethods":true
},
{
- "name":"java.lang.annotation.Retention",
- "queryAllDeclaredMethods":true,
- "queryAllDeclaredConstructors":true
+ "name":"java.util.AbstractMap",
+ "allDeclaredFields":true,
+ "queryAllDeclaredMethods":true
},
{
- "name":"java.lang.annotation.Target",
+ "name":"java.util.Arrays$ArrayList",
+ "allDeclaredFields":true,
"queryAllDeclaredMethods":true,
"queryAllDeclaredConstructors":true
},
{
- "name":"java.lang.invoke.MethodHandle",
- "methods":[{"name":"bindTo","parameterTypes":["java.lang.Object"] }, {"name":"invokeWithArguments","parameterTypes":["java.lang.Object[]"] }]
-},
-{
- "name":"java.lang.invoke.MethodHandles",
- "methods":[{"name":"lookup","parameterTypes":[] }]
-},
-{
- "name":"java.lang.invoke.MethodHandles$Lookup",
- "methods":[{"name":"findVirtual","parameterTypes":["java.lang.Class","java.lang.String","java.lang.invoke.MethodType"] }]
-},
-{
- "name":"java.lang.invoke.MethodType",
- "methods":[{"name":"methodType","parameterTypes":["java.lang.Class","java.lang.Class[]"] }]
-},
-{
- "name":"java.lang.reflect.AccessibleObject",
- "methods":[{"name":"setAccessible","parameterTypes":["boolean"] }]
-},
-{
- "name":"java.lang.reflect.AnnotatedArrayType",
- "methods":[{"name":"getAnnotatedGenericComponentType","parameterTypes":[] }]
-},
-{
- "name":"java.lang.reflect.AnnotatedType",
- "methods":[{"name":"getType","parameterTypes":[] }]
-},
-{
- "name":"java.lang.reflect.Executable",
- "methods":[{"name":"getAnnotatedExceptionTypes","parameterTypes":[] }, {"name":"getAnnotatedParameterTypes","parameterTypes":[] }, {"name":"getAnnotatedReceiverType","parameterTypes":[] }, {"name":"getParameterCount","parameterTypes":[] }, {"name":"getParameters","parameterTypes":[] }]
-},
-{
- "name":"java.lang.reflect.Method",
- "methods":[{"name":"getAnnotatedReturnType","parameterTypes":[] }]
-},
-{
- "name":"java.lang.reflect.Parameter",
- "methods":[{"name":"getModifiers","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }, {"name":"isNamePresent","parameterTypes":[] }]
-},
-{
- "name":"java.net.NetPermission"
-},
-{
- "name":"java.net.SocketPermission"
-},
-{
- "name":"java.net.URLPermission",
- "methods":[{"name":"","parameterTypes":["java.lang.String","java.lang.String"] }]
-},
-{
- "name":"java.security.AccessController",
- "methods":[{"name":"doPrivileged","parameterTypes":["java.security.PrivilegedAction"] }, {"name":"doPrivileged","parameterTypes":["java.security.PrivilegedExceptionAction"] }]
+ "name":"java.util.Collection",
+ "queryAllDeclaredMethods":true
},
{
- "name":"java.security.AllPermission"
+ "name":"java.util.Collections$SingletonMap",
+ "allDeclaredFields":true,
+ "queryAllDeclaredMethods":true,
+ "queryAllDeclaredConstructors":true
},
{
- "name":"java.security.SecurityPermission"
+ "name":"java.util.List",
+ "queryAllDeclaredMethods":true
},
{
- "name":"java.util.PropertyPermission"
+ "name":"java.util.Map",
+ "queryAllDeclaredMethods":true
},
{
- "name":"java.util.concurrent.ForkJoinTask",
- "fields":[{"name":"aux"}, {"name":"status"}]
+ "name":"java.util.RandomAccess",
+ "queryAllDeclaredMethods":true
},
{
"name":"java.util.concurrent.atomic.AtomicBoolean",
@@ -202,13 +124,7 @@
"fields":[{"name":"value"}]
},
{
- "name":"javax.smartcardio.CardPermission"
-},
-{
- "name":"jdk.internal.misc.Unsafe"
-},
-{
- "name":"kotlin.jvm.JvmInline"
+ "name":"kotlin.Metadata"
},
{
"name":"org.apiguardian.api.API",
@@ -282,9 +198,5 @@
"name":"software.amazon.lambda.powertools.logging.logback.LambdaJsonEncoder",
"queryAllPublicMethods":true,
"methods":[{"name":"","parameterTypes":[] }]
-},
-{
- "name":"sun.reflect.ReflectionFactory",
- "methods":[{"name":"getReflectionFactory","parameterTypes":[] }, {"name":"newConstructorForSerialization","parameterTypes":["java.lang.Class","java.lang.reflect.Constructor"] }]
}
]
diff --git a/powertools-logging/powertools-logging-logback/src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback/resource-config.json b/powertools-logging/powertools-logging-logback/src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback/resource-config.json
index dea71883a..2fc3c56bd 100644
--- a/powertools-logging/powertools-logging-logback/src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback/resource-config.json
+++ b/powertools-logging/powertools-logging-logback/src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-logging-logback/resource-config.json
@@ -8,20 +8,10 @@
"pattern":"\\QMETA-INF/services/java.time.zone.ZoneRulesProvider\\E"
}, {
"pattern":"\\QMETA-INF/services/javax.xml.parsers.SAXParserFactory\\E"
- }, {
- "pattern":"\\QMETA-INF/services/org.apache.maven.surefire.spi.MasterProcessChannelProcessorFactory\\E"
- }, {
- "pattern":"\\QMETA-INF/services/org.assertj.core.configuration.Configuration\\E"
- }, {
- "pattern":"\\QMETA-INF/services/org.assertj.core.presentation.Representation\\E"
}, {
"pattern":"\\QMETA-INF/services/org.slf4j.spi.SLF4JServiceProvider\\E"
}, {
"pattern":"\\QMETA-INF/services/software.amazon.lambda.powertools.logging.internal.LoggingManager\\E"
- }, {
- "pattern":"\\Qlogback-test.scmo\\E"
- }, {
- "pattern":"\\Qlogback-test.xml\\E"
}, {
"pattern":"\\Qlogback.scmo\\E"
}]},
diff --git a/powertools-logging/powertools-logging-logback/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaEcsEncoderTest.java b/powertools-logging/powertools-logging-logback/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaEcsEncoderTest.java
index 7e8977508..65277e3d6 100644
--- a/powertools-logging/powertools-logging-logback/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaEcsEncoderTest.java
+++ b/powertools-logging/powertools-logging-logback/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaEcsEncoderTest.java
@@ -17,8 +17,6 @@
import static org.apache.commons.lang3.reflect.FieldUtils.writeStaticField;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.openMocks;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
@@ -36,7 +34,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
-import org.mockito.Mock;
+import software.amazon.lambda.powertools.common.stubs.TestLambdaContext;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor;
@@ -48,16 +46,13 @@ class LambdaEcsEncoderTest {
private static final Logger logger = (Logger) LoggerFactory.getLogger(LambdaEcsEncoderTest.class.getName());
-
- @Mock
private Context context;
@BeforeEach
void setUp() throws IllegalAccessException, IOException {
- openMocks(this);
MDC.clear();
writeStaticField(LambdaHandlerProcessor.class, "IS_COLD_START", null, true);
- setupContext();
+ context = new TestLambdaContext();
// Make sure file is cleaned up before running tests
try {
FileChannel.open(Paths.get("target/ecslogfile.json"), StandardOpenOption.WRITE).truncate(0).close();
@@ -67,7 +62,7 @@ void setUp() throws IllegalAccessException, IOException {
}
@AfterEach
- void cleanUp() throws IOException{
+ void cleanUp() throws IOException {
FileChannel.open(Paths.get("target/ecslogfile.json"), StandardOpenOption.WRITE).truncate(0).close();
}
@@ -78,7 +73,7 @@ void shouldLogInEcsFormat() {
File logFile = new File("target/ecslogfile.json");
assertThat(contentOf(logFile)).contains(
- "\"ecs.version\":\"1.2.0\",\"log.level\":\"DEBUG\",\"message\":\"Test debug event\",\"service.name\":\"testLogback\",\"service.version\":\"1\",\"log.logger\":\"software.amazon.lambda.powertools.logging.internal.handler.PowertoolsLogEnabled\",\"process.thread.name\":\"main\",\"cloud.provider\":\"aws\",\"cloud.service.name\":\"lambda\",\"cloud.region\":\"eu-west-1\",\"cloud.account.id\":\"012345678910\",\"faas.id\":\"arn:aws:lambda:eu-west-1:012345678910:function:testFunction:1\",\"faas.name\":\"testFunction\",\"faas.version\":\"1\",\"faas.memory\":\"1024\",\"faas.execution\":\"RequestId\",\"faas.coldstart\":\"true\",\"trace.id\":\"1-63441c4a-abcdef012345678912345678\",\"myKey\":\"myValue\"}\n");
+ "\"ecs.version\":\"1.2.0\",\"log.level\":\"DEBUG\",\"message\":\"Test debug event\",\"service.name\":\"testLogback\",\"service.version\":\"1\",\"log.logger\":\"software.amazon.lambda.powertools.logging.internal.handler.PowertoolsLogEnabled\",\"process.thread.name\":\"main\",\"cloud.provider\":\"aws\",\"cloud.service.name\":\"lambda\",\"cloud.region\":\"us-east-1\",\"cloud.account.id\":\"123456789012\",\"faas.id\":\"arn:aws:lambda:us-east-1:123456789012:function:test\",\"faas.name\":\"test-function\",\"faas.version\":\"1\",\"faas.memory\":\"128\",\"faas.execution\":\"test-request-id\",\"faas.coldstart\":\"true\",\"trace.id\":\"1-63441c4a-abcdef012345678912345678\",\"myKey\":\"myValue\"}\n");
}
private final LoggingEvent loggingEvent = new LoggingEvent("fqcn", logger, Level.INFO, "message", null, null);
@@ -94,7 +89,8 @@ void shouldNotLogFunctionInfo() {
String result = new String(encoded, StandardCharsets.UTF_8);
// THEN
- assertThat(result).contains("\"faas.id\":\"arn:aws:lambda:eu-west-1:012345678910:function:testFunction:1\",\"faas.name\":\"testFunction\",\"faas.version\":\"1\",\"faas.memory\":\"1024\",\"faas.execution\":\"RequestId\",\"faas.coldstart\":\"false\"");
+ assertThat(result).contains(
+ "\"faas.id\":\"arn:aws:lambda:us-east-1:123456789012:function:test\",\"faas.name\":\"test-function\",\"faas.version\":\"1\",\"faas.memory\":\"128\",\"faas.execution\":\"test-request-id\",\"faas.coldstart\":\"false\"");
// WHEN (includeFaasInfo = false)
encoder.setIncludeFaasInfo(false);
@@ -116,7 +112,8 @@ void shouldNotLogCloudInfo() {
String result = new String(encoded, StandardCharsets.UTF_8);
// THEN
- assertThat(result).contains("\"cloud.provider\":\"aws\",\"cloud.service.name\":\"lambda\",\"cloud.region\":\"eu-west-1\",\"cloud.account.id\":\"012345678910\"");
+ assertThat(result).contains(
+ "\"cloud.provider\":\"aws\",\"cloud.service.name\":\"lambda\",\"cloud.region\":\"us-east-1\",\"cloud.account.id\":\"123456789012\"");
// WHEN (includeCloudInfo = false)
encoder.setIncludeCloudInfo(false);
@@ -132,14 +129,16 @@ void shouldLogException() {
// GIVEN
LambdaEcsEncoder encoder = new LambdaEcsEncoder();
encoder.start();
- LoggingEvent errorloggingEvent = new LoggingEvent("fqcn", logger, Level.INFO, "Error", new IllegalStateException("Unexpected value"), null);
+ LoggingEvent errorloggingEvent = new LoggingEvent("fqcn", logger, Level.INFO, "Error",
+ new IllegalStateException("Unexpected value"), null);
// WHEN
byte[] encoded = encoder.encode(errorloggingEvent);
String result = new String(encoded, StandardCharsets.UTF_8);
// THEN
- assertThat(result).contains("\"message\":\"Error\",\"error.message\":\"Unexpected value\",\"error.type\":\"java.lang.IllegalStateException\",\"error.stack_trace\":\"[software.amazon.lambda.powertools.logging.internal.LambdaEcsEncoderTest.shouldLogException");
+ assertThat(result).contains(
+ "\"message\":\"Error\",\"error.message\":\"Unexpected value\",\"error.type\":\"java.lang.IllegalStateException\",\"error.stack_trace\":\"[software.amazon.lambda.powertools.logging.internal.LambdaEcsEncoderTest.shouldLogException");
// WHEN (configure a custom throwableConverter)
encoder = new LambdaEcsEncoder();
@@ -150,7 +149,8 @@ void shouldLogException() {
result = new String(encoded, StandardCharsets.UTF_8);
// THEN (stack is logged with root cause first)
- assertThat(result).contains("\"message\":\"Error\",\"error.message\":\"Unexpected value\",\"error.type\":\"java.lang.IllegalStateException\",\"error.stack_trace\":\"java.lang.IllegalStateException: Unexpected value\\n");
+ assertThat(result).contains(
+ "\"message\":\"Error\",\"error.message\":\"Unexpected value\",\"error.type\":\"java.lang.IllegalStateException\",\"error.stack_trace\":\"java.lang.IllegalStateException: Unexpected value\\n");
}
private void setMDC() {
@@ -165,12 +165,4 @@ private void setMDC() {
MDC.put(PowertoolsLoggedFields.SERVICE.getName(), "Service");
}
- private void setupContext() {
- when(context.getFunctionName()).thenReturn("testFunction");
- when(context.getInvokedFunctionArn()).thenReturn(
- "arn:aws:lambda:eu-west-1:012345678910:function:testFunction:1");
- when(context.getFunctionVersion()).thenReturn("1");
- when(context.getMemoryLimitInMB()).thenReturn(1024);
- when(context.getAwsRequestId()).thenReturn("RequestId");
- }
}
diff --git a/powertools-logging/powertools-logging-logback/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaJsonEncoderTest.java b/powertools-logging/powertools-logging-logback/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaJsonEncoderTest.java
index c0eecf6f3..912e2fde9 100644
--- a/powertools-logging/powertools-logging-logback/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaJsonEncoderTest.java
+++ b/powertools-logging/powertools-logging-logback/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaJsonEncoderTest.java
@@ -19,8 +19,6 @@
import static org.apache.commons.lang3.reflect.FieldUtils.writeStaticField;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.openMocks;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
@@ -29,7 +27,6 @@
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.util.JSONPObject;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -51,7 +48,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
-import org.mockito.Mock;
+import software.amazon.lambda.powertools.common.stubs.TestLambdaContext;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor;
@@ -69,16 +66,15 @@
@Order(2)
class LambdaJsonEncoderTest {
private static final Logger logger = (Logger) LoggerFactory.getLogger(LambdaJsonEncoderTest.class.getName());
+ private final LoggingEvent loggingEvent = new LoggingEvent("fqcn", logger, Level.INFO, "message", null, null);
- @Mock
private Context context;
@BeforeEach
void setUp() throws IllegalAccessException, IOException {
- openMocks(this);
MDC.clear();
writeStaticField(LambdaHandlerProcessor.class, "IS_COLD_START", null, true);
- setupContext();
+ context = new TestLambdaContext();
// Make sure file is cleaned up before running tests
try {
FileChannel.open(Paths.get("target/logfile.json"), StandardOpenOption.WRITE).truncate(0).close();
@@ -88,7 +84,7 @@ void setUp() throws IllegalAccessException, IOException {
}
@AfterEach
- void cleanUp() throws IOException{
+ void cleanUp() throws IOException {
FileChannel.open(Paths.get("target/logfile.json"), StandardOpenOption.WRITE).truncate(0).close();
}
@@ -103,7 +99,7 @@ void shouldLogInJsonFormat() {
// THEN
File logFile = new File("target/logfile.json");
assertThat(contentOf(logFile)).contains(
- "{\"level\":\"DEBUG\",\"message\":\"Test debug event\",\"cold_start\":true,\"function_arn\":\"arn:aws:lambda:eu-west-1:012345678910:function:testFunction:1\",\"function_memory_size\":1024,\"function_name\":\"testFunction\",\"function_request_id\":\"RequestId\",\"function_version\":1,\"service\":\"testLogback\",\"xray_trace_id\":\"1-63441c4a-abcdef012345678912345678\",\"myKey\":\"myValue\",\"timestamp\":");
+ "{\"level\":\"DEBUG\",\"message\":\"Test debug event\",\"cold_start\":true,\"function_arn\":\"arn:aws:lambda:us-east-1:123456789012:function:test\",\"function_memory_size\":128,\"function_name\":\"test-function\",\"function_request_id\":\"test-request-id\",\"function_version\":1,\"service\":\"testLogback\",\"xray_trace_id\":\"1-63441c4a-abcdef012345678912345678\",\"myKey\":\"myValue\",\"timestamp\":");
}
@Test
@@ -114,7 +110,7 @@ void shouldLogArgumentsAsJsonWhenUsingRawJson() {
msg.setMessageId("1212abcd");
msg.setBody("plop");
msg.setEventSource("eb");
- msg.setAwsRegion("eu-west-1");
+ msg.setAwsRegion("eu-central-1");
SQSEvent.MessageAttribute attribute = new SQSEvent.MessageAttribute();
attribute.setStringListValues(Arrays.asList("val1", "val2", "val3"));
msg.setMessageAttributes(Collections.singletonMap("keyAttribute", attribute));
@@ -125,7 +121,8 @@ void shouldLogArgumentsAsJsonWhenUsingRawJson() {
// THEN
File logFile = new File("target/logfile.json");
assertThat(contentOf(logFile))
- .contains("\"input\":{\"awsRegion\":\"eu-west-1\",\"body\":\"plop\",\"eventSource\":\"eb\",\"messageAttributes\":{\"keyAttribute\":{\"stringListValues\":[\"val1\",\"val2\",\"val3\"]}},\"messageId\":\"1212abcd\"}")
+ .contains(
+ "\"input\":{\"awsRegion\":\"eu-central-1\",\"body\":\"plop\",\"eventSource\":\"eb\",\"messageAttributes\":{\"keyAttribute\":{\"stringListValues\":[\"val1\",\"val2\",\"val3\"]}},\"messageId\":\"1212abcd\"}")
.contains("\"message\":\"1212abcd\"")
// Should auto-escape double quotes around id
.contains("\"message\":\"Message body = plop and id = \\\"1212abcd\\\"\"");
@@ -146,7 +143,7 @@ void shouldLogArgumentsAsJsonWhenUsingKeyValue() {
msg.setMessageId("1212abcd");
msg.setBody("plop");
msg.setEventSource("eb");
- msg.setAwsRegion("eu-west-1");
+ msg.setAwsRegion("eu-central-1");
SQSEvent.MessageAttribute attribute = new SQSEvent.MessageAttribute();
attribute.setStringListValues(Arrays.asList("val1", "val2", "val3"));
msg.setMessageAttributes(Collections.singletonMap("keyAttribute", attribute));
@@ -157,7 +154,8 @@ void shouldLogArgumentsAsJsonWhenUsingKeyValue() {
// THEN
File logFile = new File("target/logfile.json");
assertThat(contentOf(logFile))
- .contains("\"input\":{\"awsRegion\":\"eu-west-1\",\"body\":\"plop\",\"eventSource\":\"eb\",\"messageAttributes\":{\"keyAttribute\":{\"stringListValues\":[\"val1\",\"val2\",\"val3\"]}},\"messageId\":\"1212abcd\"}")
+ .contains(
+ "\"input\":{\"awsRegion\":\"eu-central-1\",\"body\":\"plop\",\"eventSource\":\"eb\",\"messageAttributes\":{\"keyAttribute\":{\"stringListValues\":[\"val1\",\"val2\",\"val3\"]}},\"messageId\":\"1212abcd\"}")
.contains("\"message\":\"1212abcd\"")
// Should auto-escape double quotes around id
.contains("\"message\":\"Message body = plop and id = \\\"1212abcd\\\"\"");
@@ -170,8 +168,6 @@ void shouldLogArgumentsAsJsonWhenUsingKeyValue() {
});
}
- private final LoggingEvent loggingEvent = new LoggingEvent("fqcn", logger, Level.INFO, "message", null, null);
-
@Test
void shouldNotLogPowertoolsInfo() {
// GIVEN
@@ -192,7 +188,8 @@ void shouldNotLogPowertoolsInfo() {
String result = new String(encoded, StandardCharsets.UTF_8);
// THEN
- assertThat(result).contains("{\"level\":\"INFO\",\"message\":\"message\",\"cold_start\":false,\"function_arn\":\"arn:aws:lambda:eu-west-1:012345678910:function:testFunction:1\",\"function_memory_size\":1024,\"function_name\":\"testFunction\",\"function_request_id\":\"RequestId\",\"function_version\":1,\"sampling_rate\":0.2,\"service\":\"Service\",\"timestamp\":");
+ assertThat(result).contains(
+ "{\"level\":\"INFO\",\"message\":\"message\",\"cold_start\":false,\"function_arn\":\"arn:aws:lambda:us-east-1:123456789012:function:test\",\"function_memory_size\":128,\"function_name\":\"test-function\",\"function_request_id\":\"test-request-id\",\"function_version\":1,\"sampling_rate\":0.2,\"service\":\"Service\",\"timestamp\":");
// WHEN (powertoolsInfo = false)
encoder.setIncludePowertoolsInfo(false);
@@ -200,7 +197,8 @@ void shouldNotLogPowertoolsInfo() {
result = new String(encoded, StandardCharsets.UTF_8);
// THEN (no powertools info in logs)
- assertThat(result).doesNotContain("cold_start", "function_arn", "function_memory_size", "function_name", "function_request_id", "function_version", "sampling_rate", "service");
+ assertThat(result).doesNotContain("cold_start", "function_arn", "function_memory_size", "function_name",
+ "function_request_id", "function_version", "sampling_rate", "service");
}
@Test
@@ -212,20 +210,22 @@ void shouldLogStructuredArgumentsAsNewEntries() {
msg.setMessageId("1212abcd");
msg.setBody("plop");
msg.setEventSource("eb");
- msg.setAwsRegion("eu-west-1");
+ msg.setAwsRegion("eu-central-1");
SQSEvent.MessageAttribute attribute = new SQSEvent.MessageAttribute();
attribute.setStringListValues(Arrays.asList("val1", "val2", "val3"));
msg.setMessageAttributes(Collections.singletonMap("keyAttribute", attribute));
StructuredArgument argument = StructuredArguments.entry("msg", msg);
// WHEN
- LoggingEvent loggingEvent = new LoggingEvent("fqcn", logger, Level.INFO, "A message", null, new Object[]{argument});
- byte[] encoded = encoder.encode(loggingEvent);
+ LoggingEvent structuredLoggingEvent = new LoggingEvent("fqcn", logger, Level.INFO, "A message", null,
+ new Object[] { argument });
+ byte[] encoded = encoder.encode(structuredLoggingEvent);
String result = new String(encoded, StandardCharsets.UTF_8);
// THEN (logged as JSON)
assertThat(result)
- .contains("\"message\":\"A message\",\"msg\":{\"awsRegion\":\"eu-west-1\",\"body\":\"plop\",\"eventSource\":\"eb\",\"messageAttributes\":{\"keyAttribute\":{\"stringListValues\":[\"val1\",\"val2\",\"val3\"]}},\"messageId\":\"1212abcd\"}");
+ .contains(
+ "\"message\":\"A message\",\"msg\":{\"awsRegion\":\"eu-central-1\",\"body\":\"plop\",\"eventSource\":\"eb\",\"messageAttributes\":{\"keyAttribute\":{\"stringListValues\":[\"val1\",\"val2\",\"val3\"]}},\"messageId\":\"1212abcd\"}");
}
@Test
@@ -252,7 +252,7 @@ void shouldLogEventForHandlerWhenEnvVariableSetToTrue() {
SQSEvent.SQSMessage message = new SQSEvent.SQSMessage();
message.setBody("body");
message.setMessageId("1234abcd");
- message.setAwsRegion("eu-west-1");
+ message.setAwsRegion("eu-central-1");
// WHEN
requestHandler.handleRequest(message, context);
@@ -260,8 +260,9 @@ void shouldLogEventForHandlerWhenEnvVariableSetToTrue() {
// THEN
File logFile = new File("target/logfile.json");
assertThat(contentOf(logFile))
- .contains("\"message\":\"Handler Event\"")
- .contains("\"event\":{\"awsRegion\":\"eu-west-1\",\"body\":\"body\",\"messageId\":\"1234abcd\"}");
+ .contains("\"message\":\"Handler Event\"")
+ .contains(
+ "\"event\":{\"awsRegion\":\"eu-central-1\",\"body\":\"body\",\"messageId\":\"1234abcd\"}");
} finally {
LoggingConstants.POWERTOOLS_LOG_EVENT = false;
}
@@ -288,7 +289,10 @@ void shouldLogEventAsStringForStreamHandler() throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
// WHEN
- requestStreamHandler.handleRequest(new ByteArrayInputStream(new ObjectMapper().writeValueAsBytes(Collections.singletonMap("key", "value"))), output, context);
+ requestStreamHandler.handleRequest(
+ new ByteArrayInputStream(
+ new ObjectMapper().writeValueAsBytes(Collections.singletonMap("key", "value"))),
+ output, context);
// THEN
assertThat(new String(output.toByteArray(), StandardCharsets.UTF_8))
@@ -345,7 +349,8 @@ void shouldLogResponseForStreamHandler() throws IOException {
String input = "BobThe Sponge";
// WHEN
- requestStreamHandler.handleRequest(new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8)), output, context);
+ requestStreamHandler.handleRequest(new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8)), output,
+ context);
// THEN
assertThat(new String(output.toByteArray(), StandardCharsets.UTF_8))
@@ -353,8 +358,8 @@ void shouldLogResponseForStreamHandler() throws IOException {
File logFile = new File("target/logfile.json");
assertThat(contentOf(logFile))
- .contains("\"message\":\"Handler Response\"")
- .contains("\"response\":\""+input+"\"");
+ .contains("\"message\":\"Handler Response\"")
+ .contains("\"response\":\"" + input + "\"");
}
@Test
@@ -368,7 +373,8 @@ void shouldLogThreadInfo() {
String result = new String(encoded, StandardCharsets.UTF_8);
// THEN
- assertThat(result).contains("\"thread\":\"main\",\"thread_id\":"+ Thread.currentThread().getId() +",\"thread_priority\":5");
+ assertThat(result).contains(
+ "\"thread\":\"main\",\"thread_id\":" + Thread.currentThread().getId() + ",\"thread_priority\":5");
}
@Test
@@ -388,7 +394,7 @@ void shouldLogTimestampDifferently() {
// THEN
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone(timeZone));
- assertThat(result).contains("\"timestamp\":\""+simpleDateFormat.format(date)+"\"");
+ assertThat(result).contains("\"timestamp\":\"" + simpleDateFormat.format(date) + "\"");
}
@Test
@@ -396,7 +402,8 @@ void shouldLogException() {
// GIVEN
LambdaJsonEncoder encoder = new LambdaJsonEncoder();
encoder.start();
- LoggingEvent errorloggingEvent = new LoggingEvent("fqcn", logger, Level.INFO, "Error", new IllegalStateException("Unexpected value"), null);
+ LoggingEvent errorloggingEvent = new LoggingEvent("fqcn", logger, Level.INFO, "Error",
+ new IllegalStateException("Unexpected value"), null);
// WHEN
byte[] encoded = encoder.encode(errorloggingEvent);
@@ -406,7 +413,8 @@ void shouldLogException() {
assertThat(result).contains("\"message\":\"Error\",\"error\":{")
.contains("\"message\":\"Unexpected value\"")
.contains("\"name\":\"java.lang.IllegalStateException\"")
- .contains("\"stack\":\"[software.amazon.lambda.powertools.logging.internal.LambdaJsonEncoderTest.shouldLogException");
+ .contains(
+ "\"stack\":\"[software.amazon.lambda.powertools.logging.internal.LambdaJsonEncoderTest.shouldLogException");
// WHEN (configure a custom throwableConverter)
encoder = new LambdaJsonEncoder();
@@ -422,12 +430,4 @@ void shouldLogException() {
.contains("\"stack\":\"java.lang.IllegalStateException: Unexpected value\\n");
}
- private void setupContext() {
- when(context.getFunctionName()).thenReturn("testFunction");
- when(context.getInvokedFunctionArn()).thenReturn(
- "arn:aws:lambda:eu-west-1:012345678910:function:testFunction:1");
- when(context.getFunctionVersion()).thenReturn("1");
- when(context.getMemoryLimitInMB()).thenReturn(1024);
- when(context.getAwsRequestId()).thenReturn("RequestId");
- }
}
diff --git a/powertools-logging/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspectTest.java b/powertools-logging/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspectTest.java
index aba4664fe..751d195b5 100644
--- a/powertools-logging/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspectTest.java
+++ b/powertools-logging/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspectTest.java
@@ -18,8 +18,6 @@
import static org.apache.commons.lang3.reflect.FieldUtils.writeStaticField;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.openMocks;
import static software.amazon.lambda.powertools.logging.internal.PowertoolsLoggedFields.FUNCTION_ARN;
import static software.amazon.lambda.powertools.logging.internal.PowertoolsLoggedFields.FUNCTION_COLD_START;
import static software.amazon.lambda.powertools.logging.internal.PowertoolsLoggedFields.FUNCTION_MEMORY_SIZE;
@@ -54,7 +52,6 @@
import org.junitpioneer.jupiter.ClearEnvironmentVariable;
import org.junitpioneer.jupiter.SetEnvironmentVariable;
import org.junitpioneer.jupiter.SetSystemProperty;
-import org.mockito.Mock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
@@ -72,6 +69,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor;
+import software.amazon.lambda.powertools.common.stubs.TestLambdaContext;
import software.amazon.lambda.powertools.logging.argument.StructuredArgument;
import software.amazon.lambda.powertools.logging.handlers.PowertoolsLogAlbCorrelationId;
import software.amazon.lambda.powertools.logging.handlers.PowertoolsLogApiGatewayHttpApiCorrelationId;
@@ -99,15 +97,13 @@ class LambdaLoggingAspectTest {
private RequestStreamHandler requestStreamHandler;
private RequestHandler
generate-graalvm-files
-
-
- org.mockito
- mockito-subclass
- test
-
-
org.apache.maven.plugins
maven-surefire-plugin
- -Dmockito.mock.maker=subclass -Dorg.graalvm.nativeimage.imagecode=agent
+
+ -Dorg.graalvm.nativeimage.imagecode=agent
-agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-metrics,experimental-class-define-support
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
@@ -162,13 +154,6 @@
graalvm-native
-
-
- org.mockito
- mockito-subclass
- test
-
-
@@ -191,40 +176,10 @@
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--no-fallback
- -Dorg.graalvm.nativeimage.imagecode=agent
- -H:ClassInitialization=net.bytebuddy.ClassFileVersion:rerun
- -H:ClassInitialization=net.bytebuddy.utility.dispatcher.JavaDispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.Invoker$Dispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.GraalImageCode:rerun
- --initialize-at-build-time=org.slf4j.simple.SimpleLogger
- --initialize-at-build-time=org.slf4j.LoggerFactory
- --initialize-at-build-time=org.junit.Ignore
- --initialize-at-build-time=java.lang.annotation.Annotation
- --initialize-at-build-time=org.junit.runners.model.FrameworkField
-
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
-
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic
-
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$1
-
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$2
-
- --initialize-at-build-time=net.bytebuddy.utility.dispatcher.JavaDispatcher$DynamicClassLoader
-
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
-
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
-
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$ForLoadedType
-
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$ForLoadedMethod
-
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Super$Instantiation$2
-
- --trace-class-initialization=net.bytebuddy.description.type.TypeDescription$ForLoadedType,net.bytebuddy.description.method.MethodDescription$ForLoadedMethod,net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
-
--verbose
+ --native-image-info
+ -H:+UnlockExperimentalVMOptions
+ -H:+ReportExceptionStackTraces
diff --git a/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/ConfigurationPrecedenceTest.java b/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/ConfigurationPrecedenceTest.java
index 1bf3b6a69..ecc7c13a1 100644
--- a/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/ConfigurationPrecedenceTest.java
+++ b/powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/ConfigurationPrecedenceTest.java
@@ -34,7 +34,7 @@
import software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor;
import software.amazon.lambda.powertools.metrics.model.MetricUnit;
-import software.amazon.lambda.powertools.metrics.testutils.TestContext;
+import software.amazon.lambda.powertools.common.stubs.TestLambdaContext;
/**
* Tests to verify the hierarchy of precedence for configuration:
@@ -89,7 +89,7 @@ void annotationShouldOverrideBuilderAndEnvironment() throws Exception {
.build();
RequestHandler
-
\ No newline at end of file
+
diff --git a/powertools-parameters/powertools-parameters-tests/pom.xml b/powertools-parameters/powertools-parameters-tests/pom.xml
index abd2a02d2..6dcf2c4ae 100644
--- a/powertools-parameters/powertools-parameters-tests/pom.xml
+++ b/powertools-parameters/powertools-parameters-tests/pom.xml
@@ -1,7 +1,7 @@
+ 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.0.0
software.amazon.lambda
@@ -50,6 +50,11 @@
mockito-core
test
+
+ org.mockito
+ mockito-junit-jupiter
+ test
+
org.slf4j
slf4j-simple
@@ -97,7 +102,6 @@
org.mockito
mockito-subclass
- 5.18.0
test
@@ -108,7 +112,9 @@
maven-surefire-plugin
3.5.3
- -Dmockito.mock.maker=subclass -Dorg.graalvm.nativeimage.imagecode=agent -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-parameters,experimental-class-define-support
+
+ -Dorg.graalvm.nativeimage.imagecode=agent
+ -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-parameters,experimental-class-define-support
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
@@ -123,7 +129,13 @@
org.mockito
mockito-subclass
- 5.18.0
+ test
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter-params
test
@@ -132,7 +144,7 @@
org.graalvm.buildtools
native-maven-plugin
- 0.11.0
+ 0.11.0
true
@@ -149,33 +161,10 @@
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--no-fallback
- -Dorg.graalvm.nativeimage.imagecode=agent
- -H:ClassInitialization=net.bytebuddy.ClassFileVersion:rerun
- -H:ClassInitialization=net.bytebuddy.utility.dispatcher.JavaDispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.Invoker$Dispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.GraalImageCode:rerun
- --initialize-at-build-time=org.slf4j.simple.SimpleLogger
- --initialize-at-build-time=org.slf4j.LoggerFactory
- --initialize-at-build-time=org.junit.Ignore
- --initialize-at-build-time=java.lang.annotation.Annotation
- --initialize-at-build-time=org.junit.runners.model.FrameworkField
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$1
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$2
- --initialize-at-build-time=net.bytebuddy.utility.dispatcher.JavaDispatcher$DynamicClassLoader
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$ForLoadedType
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$ForLoadedMethod
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Super$Instantiation$2
-
- --trace-class-initialization=net.bytebuddy.description.type.TypeDescription$ForLoadedType,net.bytebuddy.description.method.MethodDescription$ForLoadedMethod,net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
-
--verbose
--native-image-info
-H:+UnlockExperimentalVMOptions
- -H:Log=registerResource:5
+ -H:+ReportExceptionStackTraces
diff --git a/powertools-parameters/powertools-parameters-tests/src/test/java/software/amazon/lambda/powertools/parameters/BaseProviderTest.java b/powertools-parameters/powertools-parameters-tests/src/test/java/software/amazon/lambda/powertools/parameters/BaseProviderTest.java
index 5fa740253..cbc8f5b30 100644
--- a/powertools-parameters/powertools-parameters-tests/src/test/java/software/amazon/lambda/powertools/parameters/BaseProviderTest.java
+++ b/powertools-parameters/powertools-parameters-tests/src/test/java/software/amazon/lambda/powertools/parameters/BaseProviderTest.java
@@ -20,7 +20,6 @@
import static java.time.temporal.ChronoUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.mockito.MockitoAnnotations.openMocks;
import static software.amazon.lambda.powertools.parameters.transform.Transformer.base64;
import static software.amazon.lambda.powertools.parameters.transform.Transformer.json;
@@ -30,8 +29,10 @@
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
+
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+
import software.amazon.lambda.powertools.parameters.cache.CacheManager;
import software.amazon.lambda.powertools.parameters.transform.ObjectToDeserialize;
import software.amazon.lambda.powertools.parameters.transform.TransformationManager;
@@ -43,13 +44,10 @@ public class BaseProviderTest {
CacheManager cacheManager;
TransformationManager transformationManager;
BasicProvider provider;
-
boolean getFromStore = false;
@BeforeEach
public void setup() {
- openMocks(this);
-
clock = Clock.systemDefaultZone();
cacheManager = new CacheManager();
transformationManager = new TransformationManager();
@@ -197,8 +195,8 @@ public void get_basicTransformation_shouldTransformInString() {
public void get_complexTransformation_shouldTransformInObject() {
provider.setValue("{\"foo\":\"Foo\", \"bar\":42, \"baz\":123456789}");
- ObjectToDeserialize objectToDeserialize =
- provider.withTransformation(json).get("foo", ObjectToDeserialize.class);
+ ObjectToDeserialize objectToDeserialize = provider.withTransformation(json).get("foo",
+ ObjectToDeserialize.class);
assertThat(objectToDeserialize).matches(
o -> o.getFoo().equals("Foo")
diff --git a/powertools-parameters/powertools-parameters-tests/src/test/java/software/amazon/lambda/powertools/parameters/ParamProvidersIntegrationTest.java b/powertools-parameters/powertools-parameters-tests/src/test/java/software/amazon/lambda/powertools/parameters/ParamProvidersIntegrationTest.java
index 7d790d140..6b3cf7641 100644
--- a/powertools-parameters/powertools-parameters-tests/src/test/java/software/amazon/lambda/powertools/parameters/ParamProvidersIntegrationTest.java
+++ b/powertools-parameters/powertools-parameters-tests/src/test/java/software/amazon/lambda/powertools/parameters/ParamProvidersIntegrationTest.java
@@ -19,17 +19,19 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.openMocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+
import org.assertj.core.data.MapEntry;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest;
@@ -43,27 +45,26 @@
import software.amazon.lambda.powertools.parameters.secrets.SecretsProvider;
import software.amazon.lambda.powertools.parameters.ssm.SSMProvider;
+@ExtendWith(MockitoExtension.class)
public class ParamProvidersIntegrationTest {
-
@Mock
SsmClient ssmClient;
@Mock
DynamoDbClient ddbClient;
+
@Captor
ArgumentCaptor ssmParamCaptor;
+
@Captor
ArgumentCaptor ssmParamByPathCaptor;
+
@Mock
SecretsManagerClient secretsManagerClient;
+
@Captor
ArgumentCaptor secretsCaptor;
- @BeforeEach
- public void setup() throws IllegalAccessException {
- openMocks(this);
- }
-
@Test
public void ssmProvider_get() {
SSMProvider ssmProvider = SSMProvider.builder()
diff --git a/powertools-serialization/pom.xml b/powertools-serialization/pom.xml
index d6cc33891..7e4e2af15 100644
--- a/powertools-serialization/pom.xml
+++ b/powertools-serialization/pom.xml
@@ -14,8 +14,8 @@
-->
+ 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.0.0
@@ -54,6 +54,11 @@
junit-jupiter-api
test
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
org.slf4j
slf4j-simple
@@ -93,14 +98,6 @@
generate-graalvm-files
-
-
- org.mockito
- mockito-subclass
- 5.18.0
- test
-
-
@@ -108,7 +105,9 @@
maven-surefire-plugin
3.5.3
- -Dmockito.mock.maker=subclass -Dorg.graalvm.nativeimage.imagecode=agent -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-serialization,experimental-class-define-support
+
+ -Dorg.graalvm.nativeimage.imagecode=agent
+ -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-serialization,experimental-class-define-support
@@ -116,20 +115,12 @@
graalvm-native
-
-
- org.mockito
- mockito-subclass
- 5.18.0
- test
-
-
org.graalvm.buildtools
native-maven-plugin
- 0.11.0
+ 0.11.0
true
@@ -141,37 +132,15 @@
-
- true
- Standard
-
powertools-serialization
+ --add-opens java.base/java.util=ALL-UNNAMED
+ --add-opens java.base/java.lang=ALL-UNNAMED
--no-fallback
- -Dorg.graalvm.nativeimage.imagecode=agent
- -H:ClassInitialization=net.bytebuddy.ClassFileVersion:rerun
- -H:ClassInitialization=net.bytebuddy.utility.dispatcher.JavaDispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.Invoker$Dispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.GraalImageCode:rerun
- --initialize-at-build-time=org.slf4j.simple.SimpleLogger
- --initialize-at-build-time=org.slf4j.LoggerFactory
- --initialize-at-build-time=org.junit.Ignore
- --initialize-at-build-time=java.lang.annotation.Annotation
- --initialize-at-build-time=org.junit.runners.model.FrameworkField
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$1
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$2
- --initialize-at-build-time=net.bytebuddy.utility.dispatcher.JavaDispatcher$DynamicClassLoader
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$ForLoadedType
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$ForLoadedMethod
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Super$Instantiation$2
-
- --trace-class-initialization=net.bytebuddy.description.type.TypeDescription$ForLoadedType,net.bytebuddy.description.method.MethodDescription$ForLoadedMethod,net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
-
--verbose
+ --native-image-info
+ -H:+UnlockExperimentalVMOptions
+ -H:+ReportExceptionStackTraces
diff --git a/powertools-tracing/pom.xml b/powertools-tracing/pom.xml
index cb7f8218f..67de0be7d 100644
--- a/powertools-tracing/pom.xml
+++ b/powertools-tracing/pom.xml
@@ -14,8 +14,8 @@
-->
+ 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.0.0
powertools-tracing
@@ -87,8 +87,10 @@
test
- org.mockito
- mockito-core
+ software.amazon.lambda
+ powertools-common
+ ${project.version}
+ test-jar
test
@@ -121,14 +123,6 @@
generate-graalvm-files
-
-
- org.mockito
- mockito-subclass
- 5.18.0
- test
-
-
@@ -136,7 +130,9 @@
maven-surefire-plugin
3.5.3
- -Dmockito.mock.maker=subclass -Dorg.graalvm.nativeimage.imagecode=agent -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-tracing,experimental-class-define-support
+
+ -Dorg.graalvm.nativeimage.imagecode=agent
+ -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-tracing,experimental-class-define-support
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
@@ -147,20 +143,12 @@
graalvm-native
-
-
- org.mockito
- mockito-subclass
- 5.18.0
- test
-
-
org.graalvm.buildtools
native-maven-plugin
- 0.11.0
+ 0.11.0
true
@@ -178,35 +166,10 @@
--add-opens java.base/java.lang=ALL-UNNAMED
--enable-url-protocols=http
--no-fallback
- -Dorg.graalvm.nativeimage.imagecode=agent
- -H:ClassInitialization=net.bytebuddy.ClassFileVersion:rerun
- -H:ClassInitialization=net.bytebuddy.utility.dispatcher.JavaDispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.Invoker$Dispatcher:rerun
- -H:ClassInitialization=net.bytebuddy.utility.GraalImageCode:rerun
- -H:IncludeResources=version.properties
- -H:IncludeResources=unreadable.properties
- --initialize-at-build-time=org.slf4j.simple.SimpleLogger
- --initialize-at-build-time=org.slf4j.LoggerFactory
- --initialize-at-build-time=org.junit.Ignore
- --initialize-at-build-time=java.lang.annotation.Annotation
- --initialize-at-build-time=org.junit.runners.model.FrameworkField
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$1
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$2
- --initialize-at-build-time=net.bytebuddy.utility.dispatcher.JavaDispatcher$DynamicClassLoader
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase
- --initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$ForLoadedType
- --initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$ForLoadedMethod
- --initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Super$Instantiation$2
-
- --trace-class-initialization=net.bytebuddy.description.type.TypeDescription$ForLoadedType,net.bytebuddy.description.method.MethodDescription$ForLoadedMethod,net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
-
--verbose
--native-image-info
-H:+UnlockExperimentalVMOptions
- -H:Log=registerResource:5
+ -H:+ReportExceptionStackTraces
diff --git a/powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/TracingUtilsTest.java b/powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/TracingUtilsTest.java
index 01f25f37a..db9807dbd 100644
--- a/powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/TracingUtilsTest.java
+++ b/powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/TracingUtilsTest.java
@@ -16,17 +16,15 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
import static software.amazon.lambda.powertools.tracing.TracingUtils.withEntitySubsegment;
-import com.amazonaws.services.lambda.runtime.Context;
-import com.amazonaws.xray.AWSXRay;
-import com.amazonaws.xray.entities.Entity;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import com.amazonaws.xray.AWSXRay;
+import com.amazonaws.xray.entities.Entity;
+
class TracingUtilsTest {
@BeforeEach
void setUp() {
@@ -55,8 +53,7 @@ void shouldSetAnnotationOnCurrentSubSegment() {
.contains(
entry("stringKey", "val"),
entry("numberKey", 10),
- entry("booleanKey", false)
- );
+ entry("booleanKey", false));
}
@Test
@@ -76,10 +73,8 @@ void shouldSetMetadataOnCurrentSubSegment() {
assertThat(AWSXRay.getTraceEntity().getMetadata())
.hasSize(1)
.containsKey("service_undefined")
- .satisfies(map ->
- assertThat(map.get("service_undefined"))
- .containsEntry("key", "val")
- );
+ .satisfies(map -> assertThat(map.get("service_undefined"))
+ .containsEntry("key", "val"));
}
@Test
@@ -92,21 +87,14 @@ void shouldNotSetMetaDataIfNoCurrentSubSegment() {
@Test
void shouldInvokeCodeBlockWrappedWithinSubsegment() {
- Context test = mock(Context.class);
-
- TracingUtils.withSubsegment("testSubSegment", subsegment ->
- {
+ TracingUtils.withSubsegment("testSubSegment", subsegment -> {
subsegment.putAnnotation("key", "val");
subsegment.putMetadata("key", "val");
- test.getFunctionName();
});
- verify(test).getFunctionName();
-
assertThat(AWSXRay.getTraceEntity().getSubsegments())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getName())
.isEqualTo("## testSubSegment");
@@ -142,21 +130,14 @@ void shouldAddAnnotationIfValidCharactersInKey() {
@Test
void shouldInvokeCodeBlockWrappedWithinNamespacedSubsegment() {
- Context test = mock(Context.class);
-
- TracingUtils.withSubsegment("testNamespace", "testSubSegment", subsegment ->
- {
+ TracingUtils.withSubsegment("testNamespace", "testSubSegment", subsegment -> {
subsegment.putAnnotation("key", "val");
subsegment.putMetadata("key", "val");
- test.getFunctionName();
});
- verify(test).getFunctionName();
-
assertThat(AWSXRay.getTraceEntity().getSubsegments())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getName())
.isEqualTo("## testSubSegment");
@@ -174,25 +155,18 @@ void shouldInvokeCodeBlockWrappedWithinNamespacedSubsegment() {
@Test
void shouldInvokeCodeBlockWrappedWithinEntitySubsegment() throws InterruptedException {
- Context test = mock(Context.class);
-
Entity traceEntity = AWSXRay.getTraceEntity();
- Thread thread = new Thread(() -> withEntitySubsegment("testSubSegment", traceEntity, subsegment ->
- {
+ Thread thread = new Thread(() -> withEntitySubsegment("testSubSegment", traceEntity, subsegment -> {
subsegment.putAnnotation("key", "val");
- test.getFunctionName();
}));
thread.start();
thread.join();
- verify(test).getFunctionName();
-
assertThat(AWSXRay.getTraceEntity().getSubsegments())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getName())
.isEqualTo("## testSubSegment");
@@ -207,26 +181,19 @@ void shouldInvokeCodeBlockWrappedWithinEntitySubsegment() throws InterruptedExce
@Test
void shouldInvokeCodeBlockWrappedWithinNamespacedEntitySubsegment() throws InterruptedException {
- Context test = mock(Context.class);
-
Entity traceEntity = AWSXRay.getTraceEntity();
- Thread thread =
- new Thread(() -> withEntitySubsegment("testNamespace", "testSubSegment", traceEntity, subsegment ->
- {
+ Thread thread = new Thread(
+ () -> withEntitySubsegment("testNamespace", "testSubSegment", traceEntity, subsegment -> {
subsegment.putAnnotation("key", "val");
- test.getFunctionName();
}));
thread.start();
thread.join();
- verify(test).getFunctionName();
-
assertThat(AWSXRay.getTraceEntity().getSubsegments())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getName())
.isEqualTo("## testSubSegment");
diff --git a/powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspectTest.java b/powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspectTest.java
index 1d108ed5f..4d2e481b1 100644
--- a/powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspectTest.java
+++ b/powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspectTest.java
@@ -18,8 +18,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.assertj.core.api.Assertions.catchThrowable;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.openMocks;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -29,7 +27,6 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetEnvironmentVariable;
-import org.mockito.Mock;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
@@ -37,6 +34,7 @@
import com.amazonaws.xray.AWSXRay;
import software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor;
+import software.amazon.lambda.powertools.common.stubs.TestLambdaContext;
import software.amazon.lambda.powertools.tracing.handlers.PowerToolDisabled;
import software.amazon.lambda.powertools.tracing.handlers.PowerToolDisabledForStream;
import software.amazon.lambda.powertools.tracing.handlers.PowerTracerToolEnabled;
@@ -50,7 +48,6 @@
import software.amazon.lambda.powertools.tracing.handlers.PowerTracerToolEnabledWithNoMetaData;
import software.amazon.lambda.powertools.tracing.nonhandler.PowerToolNonHandler;
-
@SetEnvironmentVariable(key = "POWERTOOLS_TRACER_CAPTURE_RESPONSE", value = "false")
@SetEnvironmentVariable(key = "POWERTOOLS_TRACER_CAPTURE_ERROR", value = "false")
class LambdaTracingAspectTest {
@@ -58,14 +55,12 @@ class LambdaTracingAspectTest {
private RequestStreamHandler streamHandler;
private PowerToolNonHandler nonHandlerMethod;
- @Mock
private Context context;
@BeforeEach
void setUp() throws IllegalAccessException {
- openMocks(this);
writeStaticField(LambdaHandlerProcessor.class, "IS_COLD_START", null, true);
- setupContext();
+ context = new TestLambdaContext();
requestHandler = new PowerTracerToolEnabled();
streamHandler = new PowerTracerToolEnabledForStream();
nonHandlerMethod = new PowerToolNonHandler();
@@ -86,8 +81,7 @@ void shouldCaptureNonHandlerMethod() {
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .anySatisfy(segment ->
- assertThat(segment.getName()).isEqualTo("## doSomething"));
+ .anySatisfy(segment -> assertThat(segment.getName()).isEqualTo("## doSomething"));
}
@Test
@@ -99,8 +93,7 @@ void shouldCaptureNonHandlerMethodWithCustomSegmentName() {
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .anySatisfy(segment ->
- assertThat(segment.getName()).isEqualTo("custom"));
+ .anySatisfy(segment -> assertThat(segment.getName()).isEqualTo("custom"));
}
@Test
@@ -112,15 +105,14 @@ void shouldCaptureTraces() {
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(2)
.containsEntry("ColdStart", true)
.containsEntry("Service", "lambdaHandler");
assertThat(subsegment.getMetadata())
- .hasSize(0);
+ .isEmpty();
});
}
@@ -134,8 +126,7 @@ void shouldCaptureTracesWithResponseMetadata() {
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(2)
.containsEntry("ColdStart", true)
@@ -159,8 +150,7 @@ void shouldCaptureTracesWithExceptionMetaData() {
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(2)
.containsEntry("ColdStart", true)
@@ -185,8 +175,7 @@ void shouldCaptureTracesForStream() throws IOException {
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(2)
.containsEntry("ColdStart", true)
@@ -204,8 +193,7 @@ void shouldCaptureTracesForStreamWithResponseMetadata() throws IOException {
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(2)
.containsEntry("ColdStart", true)
@@ -246,8 +234,7 @@ void shouldCaptureTracesWithNoMetadata() {
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(2)
.containsEntry("ColdStart", true)
@@ -269,8 +256,7 @@ void shouldCaptureTracesForStreamWithNoMetadata() throws IOException {
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(2)
.containsEntry("ColdStart", true)
@@ -291,8 +277,7 @@ void shouldNotCaptureTracesIfDisabledViaEnvironmentVariable() {
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(2)
.containsEntry("ColdStart", true)
@@ -315,8 +300,7 @@ void shouldCaptureTracesIfExplicitlyEnabledAndEnvironmentVariableIsDisabled() {
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(2)
.containsEntry("ColdStart", true)
@@ -339,8 +323,7 @@ void shouldCaptureTracesForSelfReferencingReturnTypesViaCustomMapper() {
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getMetadata())
.hasSize(1)
.containsKey("lambdaHandler");
@@ -368,8 +351,7 @@ void shouldCaptureTracesIfExplicitlyEnabledBothAndEnvironmentVariableIsDisabled(
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(2)
.containsEntry("ColdStart", true)
@@ -396,8 +378,7 @@ void shouldNotCaptureTracesWithExceptionMetaDataIfDisabledViaEnvironmentVariable
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(2)
.containsEntry("ColdStart", true)
@@ -420,8 +401,7 @@ void shouldCaptureTracesWithExceptionMetaDataEnabledExplicitlyAndEnvironmentVari
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
.hasSize(1)
- .allSatisfy(subsegment ->
- {
+ .allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(2)
.containsEntry("ColdStart", true)
@@ -437,10 +417,4 @@ void shouldCaptureTracesWithExceptionMetaDataEnabledExplicitlyAndEnvironmentVari
});
}
- private void setupContext() {
- when(context.getFunctionName()).thenReturn("testFunction");
- when(context.getInvokedFunctionArn()).thenReturn("testArn");
- when(context.getFunctionVersion()).thenReturn("1");
- when(context.getMemoryLimitInMB()).thenReturn(10);
- }
}