From 096c4819c0e9ee18ec0db86fcd6a427d8f2a7d59 Mon Sep 17 00:00:00 2001
From: kibeom lee <70303094+2012160085@users.noreply.github.com>
Date: Fri, 15 Sep 2023 03:08:57 +0900
Subject: [PATCH] add tests -Added jpaapp.JpaApplication for H2 and Spring Data
JPA testing. -Excluded JPA auto-configuration from other test apps to prevent
interference. -Implemented one async and one sync test case in JpaAppTest
---
.../pom.xml | 40 +++++++++++++
.../serverless/proxy/spring/JpaAppTest.java | 52 ++++++++++++++++
.../proxy/spring/jpaapp/DatabaseConfig.java | 23 ++++++++
.../proxy/spring/jpaapp/JpaApplication.java | 17 ++++++
.../proxy/spring/jpaapp/LambdaHandler.java | 59 +++++++++++++++++++
.../spring/jpaapp/MessageController.java | 31 ++++++++++
.../securityapp/SecurityApplication.java | 5 +-
.../spring/servletapp/ServletApplication.java | 4 +-
.../spring/slowapp/SlowTestApplication.java | 4 +-
.../webfluxapp/WebFluxTestApplication.java | 4 +-
10 files changed, 235 insertions(+), 4 deletions(-)
create mode 100644 aws-serverless-java-container-springboot3/src/test/java/com/amazonaws/serverless/proxy/spring/JpaAppTest.java
create mode 100644 aws-serverless-java-container-springboot3/src/test/java/com/amazonaws/serverless/proxy/spring/jpaapp/DatabaseConfig.java
create mode 100644 aws-serverless-java-container-springboot3/src/test/java/com/amazonaws/serverless/proxy/spring/jpaapp/JpaApplication.java
create mode 100644 aws-serverless-java-container-springboot3/src/test/java/com/amazonaws/serverless/proxy/spring/jpaapp/LambdaHandler.java
create mode 100644 aws-serverless-java-container-springboot3/src/test/java/com/amazonaws/serverless/proxy/spring/jpaapp/MessageController.java
diff --git a/aws-serverless-java-container-springboot3/pom.xml b/aws-serverless-java-container-springboot3/pom.xml
index cc907f952..56c617738 100644
--- a/aws-serverless-java-container-springboot3/pom.xml
+++ b/aws-serverless-java-container-springboot3/pom.xml
@@ -191,6 +191,46 @@
test
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+ 3.1.3
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+
+
+ org.apache.tomcat.embed
+ tomcat-embed-core
+
+
+ org.apache.tomcat.embed
+ tomcat-embed-websocket
+
+
+
+
+ com.h2database
+ h2
+ 2.2.222
+ test
+
+
+
diff --git a/aws-serverless-java-container-springboot3/src/test/java/com/amazonaws/serverless/proxy/spring/JpaAppTest.java b/aws-serverless-java-container-springboot3/src/test/java/com/amazonaws/serverless/proxy/spring/JpaAppTest.java
new file mode 100644
index 000000000..a111e510a
--- /dev/null
+++ b/aws-serverless-java-container-springboot3/src/test/java/com/amazonaws/serverless/proxy/spring/JpaAppTest.java
@@ -0,0 +1,52 @@
+package com.amazonaws.serverless.proxy.spring;
+
+import com.amazonaws.serverless.proxy.internal.testutils.AwsProxyRequestBuilder;
+import com.amazonaws.serverless.proxy.internal.testutils.MockLambdaContext;
+import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
+import com.amazonaws.serverless.proxy.spring.jpaapp.LambdaHandler;
+import com.amazonaws.serverless.proxy.spring.jpaapp.MessageController;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class JpaAppTest {
+
+ LambdaHandler handler;
+ MockLambdaContext lambdaContext = new MockLambdaContext();
+
+ private String type;
+
+ public static Collection