From d84905b9e1265bec2d849c001793b53ef852f5d6 Mon Sep 17 00:00:00 2001 From: AhmedLotfy02 Date: Wed, 5 Mar 2025 17:03:51 +0200 Subject: [PATCH 1/3] [add]: sample java app with xml resposne Signed-off-by: AhmedLotfy02 --- .../naive-spring-boot/.gitattributes | 2 + spring-boot-xml/naive-spring-boot/.gitignore | 33 +++ .../.mvn/wrapper/maven-wrapper.properties | 19 ++ spring-boot-xml/naive-spring-boot/mvnw | 259 ++++++++++++++++++ spring-boot-xml/naive-spring-boot/mvnw.cmd | 149 ++++++++++ spring-boot-xml/naive-spring-boot/pom.xml | 75 +++++ .../java/com/example/XML/XmlApplication.java | 13 + .../XML/controllers/UserController.java | 15 + .../java/com/example/XML/entities/User.java | 46 ++++ .../src/main/resources/application.properties | 1 + .../com/example/XML/XmlApplicationTests.java | 13 + 11 files changed, 625 insertions(+) create mode 100644 spring-boot-xml/naive-spring-boot/.gitattributes create mode 100644 spring-boot-xml/naive-spring-boot/.gitignore create mode 100644 spring-boot-xml/naive-spring-boot/.mvn/wrapper/maven-wrapper.properties create mode 100755 spring-boot-xml/naive-spring-boot/mvnw create mode 100644 spring-boot-xml/naive-spring-boot/mvnw.cmd create mode 100644 spring-boot-xml/naive-spring-boot/pom.xml create mode 100644 spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/XmlApplication.java create mode 100644 spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/controllers/UserController.java create mode 100644 spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/User.java create mode 100644 spring-boot-xml/naive-spring-boot/src/main/resources/application.properties create mode 100644 spring-boot-xml/naive-spring-boot/src/test/java/com/example/XML/XmlApplicationTests.java diff --git a/spring-boot-xml/naive-spring-boot/.gitattributes b/spring-boot-xml/naive-spring-boot/.gitattributes new file mode 100644 index 00000000..3b41682a --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/.gitattributes @@ -0,0 +1,2 @@ +/mvnw text eol=lf +*.cmd text eol=crlf diff --git a/spring-boot-xml/naive-spring-boot/.gitignore b/spring-boot-xml/naive-spring-boot/.gitignore new file mode 100644 index 00000000..549e00a2 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/spring-boot-xml/naive-spring-boot/.mvn/wrapper/maven-wrapper.properties b/spring-boot-xml/naive-spring-boot/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..d58dfb70 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/spring-boot-xml/naive-spring-boot/mvnw b/spring-boot-xml/naive-spring-boot/mvnw new file mode 100755 index 00000000..19529ddf --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/mvnw @@ -0,0 +1,259 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.3.2 +# +# Optional ENV vars +# ----------------- +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output +# ---------------------------------------------------------------------------- + +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x + +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac + +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" + + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 + fi + fi + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi + fi +} + +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" + done + printf %x\\n $h +} + +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } + +die() { + printf %s\\n "$1" >&2 + exit 1 +} + +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" + +clean || : +exec_maven "$@" diff --git a/spring-boot-xml/naive-spring-boot/mvnw.cmd b/spring-boot-xml/naive-spring-boot/mvnw.cmd new file mode 100644 index 00000000..249bdf38 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/mvnw.cmd @@ -0,0 +1,149 @@ +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.2 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/spring-boot-xml/naive-spring-boot/pom.xml b/spring-boot-xml/naive-spring-boot/pom.xml new file mode 100644 index 00000000..775e2c01 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/pom.xml @@ -0,0 +1,75 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 3.2.3 + + + + com.example + XML + 0.0.1-SNAPSHOT + XML + Demo project for Spring Boot + + 17 + + + + + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.eclipse.persistence + org.eclipse.persistence.moxy + 4.0.2 + + + + javax.annotation + javax.annotation-api + 1.3.2 + + + javax.servlet + javax.servlet-api + 3.1.0 + + + javax.xml.bind + jaxb-api + 2.3.0 + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/XmlApplication.java b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/XmlApplication.java new file mode 100644 index 00000000..9591f7bc --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/XmlApplication.java @@ -0,0 +1,13 @@ +package com.example.XML; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class XmlApplication { + + public static void main(String[] args) { + SpringApplication.run(XmlApplication.class, args); + } + +} diff --git a/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/controllers/UserController.java b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/controllers/UserController.java new file mode 100644 index 00000000..2dd2e459 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/controllers/UserController.java @@ -0,0 +1,15 @@ +package com.example.XML.controllers; + +import com.example.XML.entities.User; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api") +public class UserController { + @GetMapping(value = "/user", produces = "application/xml") + public User getUser() { + return new User("John Doe", 30,"0101233333"); + } +} diff --git a/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/User.java b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/User.java new file mode 100644 index 00000000..37439201 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/User.java @@ -0,0 +1,46 @@ +package com.example.XML.entities; + +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "User") +public class User { + @XmlElement(name = "name") + private String name; + + @XmlElement(name = "age") + private int age; + + @XmlElement(name = "mobile") + private String mobile; + // Constructors, getters, and setters + public User() {} + + public User(String name, int age, String mobile) { + this.name = name; + this.age = age; + this.mobile = mobile; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + public String getMobile() { + return mobile; + } + public void setMobile(String mobile) { + this.mobile = mobile; + } +} \ No newline at end of file diff --git a/spring-boot-xml/naive-spring-boot/src/main/resources/application.properties b/spring-boot-xml/naive-spring-boot/src/main/resources/application.properties new file mode 100644 index 00000000..a7770a32 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=XML diff --git a/spring-boot-xml/naive-spring-boot/src/test/java/com/example/XML/XmlApplicationTests.java b/spring-boot-xml/naive-spring-boot/src/test/java/com/example/XML/XmlApplicationTests.java new file mode 100644 index 00000000..0c7a5b19 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/src/test/java/com/example/XML/XmlApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.XML; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class XmlApplicationTests { + + @Test + void contextLoads() { + } + +} From ec7c59e11050ba13bc0f9397318a32ef1b875a58 Mon Sep 17 00:00:00 2001 From: AhmedLotfy02 Date: Thu, 6 Mar 2025 10:31:56 +0200 Subject: [PATCH 2/3] [add]: readme Signed-off-by: AhmedLotfy02 --- spring-boot-xml/naive-spring-boot/README.md | 39 +++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 spring-boot-xml/naive-spring-boot/README.md diff --git a/spring-boot-xml/naive-spring-boot/README.md b/spring-boot-xml/naive-spring-boot/README.md new file mode 100644 index 00000000..4e9ea8e7 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/README.md @@ -0,0 +1,39 @@ +

Sample java spring boot with xml

+

This project is a Spring Boot application that serves a simple REST API endpoint returning XML responses.

+ +

How to Run

+

Ensure you have Java 17 installed. Then, follow these steps:

+
    +
  1. Clone the repository
  2. +
  3. Navigate into the project directory
  4. +
  5. Build the project: mvn clean install
  6. +
  7. Run the application: mvn spring-boot:run
  8. +
+ +

API Endpoints

+

Get User (Returns XML)

+

Endpoint: GET /api/user

+ +

Testing with Curl

+

To make a request using curl, use the following command:

+
+curl -X GET -H "Accept: application/xml" http://localhost:8080/api/user
+
+ +

Expected XML Response

+
+
+<User>
+<name>John Doe</name>
+<age>30</age>
+<phone>0101233333</phone>
+</User>
+
+
+ +

Dependencies

+
    +
  • Spring Boot
  • +
  • Spring Web
  • +
  • JAXB for XML serialization
  • +
\ No newline at end of file From 80a8188f07d04d89f1b3e5bbe5d8851137991bfd Mon Sep 17 00:00:00 2001 From: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> Date: Tue, 11 Mar 2025 00:59:09 +0530 Subject: [PATCH 3/3] docs: add support for xml Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> --- spring-boot-xml/naive-spring-boot/keploy.yml | 70 ++++ .../naive-spring-boot/keploy/.gitignore | 2 + .../keploy/test-set-1/tests/test-1.yaml | 43 +++ .../keploy/test-set-1/tests/test-2.yaml | 43 +++ .../keploy/test-set-2/tests/test-1.yaml | 351 ++++++++++++++++++ .../keploy/test-set-2/tests/test-2.yaml | 351 ++++++++++++++++++ .../keploy/test-set-2/tests/test-3.yaml | 351 ++++++++++++++++++ .../keploy/test-set-2/tests/test-4.yaml | 192 ++++++++++ .../XML/controllers/UserController.java | 33 +- .../java/com/example/XML/entities/People.java | 25 ++ .../java/com/example/XML/entities/User.java | 6 +- .../com/example/XML/entities/UserList.java | 49 +++ 12 files changed, 1513 insertions(+), 3 deletions(-) create mode 100755 spring-boot-xml/naive-spring-boot/keploy.yml create mode 100644 spring-boot-xml/naive-spring-boot/keploy/.gitignore create mode 100755 spring-boot-xml/naive-spring-boot/keploy/test-set-1/tests/test-1.yaml create mode 100755 spring-boot-xml/naive-spring-boot/keploy/test-set-1/tests/test-2.yaml create mode 100755 spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-1.yaml create mode 100755 spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-2.yaml create mode 100755 spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-3.yaml create mode 100755 spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-4.yaml create mode 100644 spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/People.java create mode 100644 spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/UserList.java diff --git a/spring-boot-xml/naive-spring-boot/keploy.yml b/spring-boot-xml/naive-spring-boot/keploy.yml new file mode 100755 index 00000000..f993004a --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/keploy.yml @@ -0,0 +1,70 @@ +# Generated by Keploy (2-dev) +path: "" +appId: 0 +appName: naive-spring-boot +command: java -jar target/XML-0.0.1-SNAPSHOT.jar +templatize: + testSets: [] +port: 0 +e2e: false +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: "" +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: { + header.Date: [], + body: { + # To ignore some values for a field, pass regex patterns to the corresponding array value + "UserList": [], + } + } + test-sets: {} + delay: 5 + host: "" + port: 0 + apiTimeout: 5 + skipCoverage: false + coverageReportPath: "" + ignoreOrdering: true + mongoPassword: default@123 + language: "" + removeUnusedMocks: false + fallBackOnMiss: false + jacocoAgentPath: "" + basePath: "" + mocking: true + ignoredTests: {} + disableLineCoverage: false + disableMockUpload: true + useLocalMock: false + updateTemplate: false +record: + filters: [] + baseUrl: "" + recordTimer: 0s +configPath: "" +bypassRules: [] +generateGithubActions: false +keployContainer: keploy-v2 +keployNetwork: keploy-network +cmdType: native +contract: + services: [] + tests: [] + path: "" + download: false + generate: false + driven: consumer + mappings: + servicesMapping: {} + self: s1 +inCi: false + +# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file. diff --git a/spring-boot-xml/naive-spring-boot/keploy/.gitignore b/spring-boot-xml/naive-spring-boot/keploy/.gitignore new file mode 100644 index 00000000..5137843b --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/keploy/.gitignore @@ -0,0 +1,2 @@ + +/reports/ diff --git a/spring-boot-xml/naive-spring-boot/keploy/test-set-1/tests/test-1.yaml b/spring-boot-xml/naive-spring-boot/keploy/test-set-1/tests/test-1.yaml new file mode 100755 index 00000000..3c1e6d96 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/keploy/test-set-1/tests/test-1.yaml @@ -0,0 +1,43 @@ +# Generated by Keploy (2-dev) +version: api.keploy.io/v1beta1 +kind: Http +name: test-1 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8080/api/user + header: + Accept: application/xml + Host: localhost:8080 + User-Agent: curl/7.88.1 + body: "" + timestamp: 2025-03-06T15:41:11.988665142+05:30 + resp: + body: + User: + age: "30" + mobile: "0101233333" + name: John Does + status_code: 200 + header: + Content-Type: application/xml + Date: Thu, 06 Mar 2025 10:11:12 GMT + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2025-03-06T15:41:15.041036767+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1741255875 +curl: | + curl --request GET \ + --url http://localhost:8080/api/user \ + --header 'Accept: application/xml' \ + --header 'Host: localhost:8080' \ + --header 'User-Agent: curl/7.88.1' \ +respType: xml diff --git a/spring-boot-xml/naive-spring-boot/keploy/test-set-1/tests/test-2.yaml b/spring-boot-xml/naive-spring-boot/keploy/test-set-1/tests/test-2.yaml new file mode 100755 index 00000000..53a0d7ce --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/keploy/test-set-1/tests/test-2.yaml @@ -0,0 +1,43 @@ +# Generated by Keploy (2-dev) +version: api.keploy.io/v1beta1 +kind: Http +name: test-2 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8080/api/user + header: + Accept: application/xml + Host: localhost:8080 + User-Agent: curl/7.88.1 + body: "" + timestamp: 2025-03-06T15:41:16.64255575+05:30 + resp: + body: + User: + age: "30" + mobile: "0101233333" + name: John Doe + status_code: 200 + header: + Content-Type: application/xml + Date: Thu, 06 Mar 2025 10:11:16 GMT + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2025-03-06T15:41:19.740844643+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1741255879 +curl: | + curl --request GET \ + --url http://localhost:8080/api/user \ + --header 'Accept: application/xml' \ + --header 'Host: localhost:8080' \ + --header 'User-Agent: curl/7.88.1' \ +respType: xml diff --git a/spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-1.yaml b/spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-1.yaml new file mode 100755 index 00000000..1e4bfa63 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-1.yaml @@ -0,0 +1,351 @@ +# Generated by Keploy (0.11.10) +version: api.keploy.io/v1beta1 +kind: Http +name: test-1 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8080/api/people + header: + Accept: application/xml + Host: localhost:8080 + User-Agent: curl/8.7.1 + body: "" + timestamp: 2025-03-10T23:55:51.714370497+05:30 + resp: + body: + People: + UserList: + - User: + - age: "21" + mobile: "987654321" + name: User 1 + - age: "22" + mobile: "987654322" + name: User 2 + - age: "23" + mobile: "987654323" + name: User 3 + - age: "24" + mobile: "987654324" + name: User 4 + - age: "25" + mobile: "987654325" + name: User 5 + - age: "26" + mobile: "987654326" + name: User 6 + - age: "27" + mobile: "987654327" + name: User 7 + - age: "28" + mobile: "987654328" + name: User 8 + - age: "29" + mobile: "987654329" + name: User 9 + - age: "20" + mobile: "9876543210" + name: User 10 + - age: "21" + mobile: "9876543211" + name: User 11 + - age: "22" + mobile: "9876543212" + name: User 12 + - age: "23" + mobile: "9876543213" + name: User 13 + - age: "24" + mobile: "9876543214" + name: User 14 + - age: "25" + mobile: "9876543215" + name: User 15 + - age: "26" + mobile: "9876543216" + name: User 16 + - age: "27" + mobile: "9876543217" + name: User 17 + - age: "28" + mobile: "9876543218" + name: User 18 + - age: "29" + mobile: "9876543219" + name: User 19 + - age: "20" + mobile: "9876543220" + name: User 20 + groupName: Group 1 + - User: + - age: "21" + mobile: "9876543221" + name: User 21 + - age: "22" + mobile: "9876543222" + name: User 22 + - age: "23" + mobile: "9876543223" + name: User 23 + - age: "24" + mobile: "9876543224" + name: User 24 + - age: "25" + mobile: "9876543225" + name: User 25 + - age: "26" + mobile: "9876543226" + name: User 26 + - age: "27" + mobile: "9876543227" + name: User 27 + - age: "28" + mobile: "9876543228" + name: User 28 + - age: "29" + mobile: "9876543229" + name: User 29 + - age: "20" + mobile: "9876543230" + name: User 30 + - age: "21" + mobile: "9876543231" + name: User 31 + - age: "22" + mobile: "9876543232" + name: User 32 + - age: "23" + mobile: "9876543233" + name: User 33 + - age: "24" + mobile: "9876543234" + name: User 34 + - age: "25" + mobile: "9876543235" + name: User 35 + - age: "26" + mobile: "9876543236" + name: User 36 + - age: "27" + mobile: "9876543237" + name: User 37 + - age: "28" + mobile: "9876543238" + name: User 38 + - age: "29" + mobile: "9876543239" + name: User 39 + - age: "20" + mobile: "9876543240" + name: User 40 + groupName: Group 2 + - User: + - age: "21" + mobile: "9876543241" + name: User 41 + - age: "22" + mobile: "9876543242" + name: User 42 + - age: "23" + mobile: "9876543243" + name: User 43 + - age: "24" + mobile: "9876543244" + name: User 44 + - age: "25" + mobile: "9876543245" + name: User 45 + - age: "26" + mobile: "9876543246" + name: User 46 + - age: "27" + mobile: "9876543247" + name: User 47 + - age: "28" + mobile: "9876543248" + name: User 48 + - age: "29" + mobile: "9876543249" + name: User 49 + - age: "20" + mobile: "9876543250" + name: User 50 + - age: "21" + mobile: "9876543251" + name: User 51 + - age: "22" + mobile: "9876543252" + name: User 52 + - age: "23" + mobile: "9876543253" + name: User 53 + - age: "24" + mobile: "9876543254" + name: User 54 + - age: "25" + mobile: "9876543255" + name: User 55 + - age: "26" + mobile: "9876543256" + name: User 56 + - age: "27" + mobile: "9876543257" + name: User 57 + - age: "28" + mobile: "9876543258" + name: User 58 + - age: "29" + mobile: "9876543259" + name: User 59 + - age: "20" + mobile: "9876543260" + name: User 60 + groupName: Group 3 + - User: + - age: "21" + mobile: "9876543261" + name: User 61 + - age: "22" + mobile: "9876543262" + name: User 62 + - age: "23" + mobile: "9876543263" + name: User 63 + - age: "24" + mobile: "9876543264" + name: User 64 + - age: "25" + mobile: "9876543265" + name: User 65 + - age: "26" + mobile: "9876543266" + name: User 66 + - age: "27" + mobile: "9876543267" + name: User 67 + - age: "28" + mobile: "9876543268" + name: User 68 + - age: "29" + mobile: "9876543269" + name: User 69 + - age: "20" + mobile: "9876543270" + name: User 70 + - age: "21" + mobile: "9876543271" + name: User 71 + - age: "22" + mobile: "9876543272" + name: User 72 + - age: "23" + mobile: "9876543273" + name: User 73 + - age: "24" + mobile: "9876543274" + name: User 74 + - age: "25" + mobile: "9876543275" + name: User 75 + - age: "26" + mobile: "9876543276" + name: User 76 + - age: "27" + mobile: "9876543277" + name: User 77 + - age: "28" + mobile: "9876543278" + name: User 78 + - age: "29" + mobile: "9876543279" + name: User 79 + - age: "20" + mobile: "9876543280" + name: User 80 + groupName: Group 4 + - User: + - age: "21" + mobile: "9876543281" + name: User 81 + - age: "22" + mobile: "9876543282" + name: User 82 + - age: "23" + mobile: "9876543283" + name: User 83 + - age: "24" + mobile: "9876543284" + name: User 84 + - age: "25" + mobile: "9876543285" + name: User 85 + - age: "26" + mobile: "9876543286" + name: User 86 + - age: "27" + mobile: "9876543287" + name: User 87 + - age: "28" + mobile: "9876543288" + name: User 88 + - age: "29" + mobile: "9876543289" + name: User 89 + - age: "20" + mobile: "9876543290" + name: User 90 + - age: "21" + mobile: "9876543291" + name: User 91 + - age: "22" + mobile: "9876543292" + name: User 92 + - age: "23" + mobile: "9876543293" + name: User 93 + - age: "24" + mobile: "9876543294" + name: User 94 + - age: "25" + mobile: "9876543295" + name: User 95 + - age: "26" + mobile: "9876543296" + name: User 96 + - age: "27" + mobile: "9876543297" + name: User 97 + - age: "28" + mobile: "9876543298" + name: User 98 + - age: "29" + mobile: "9876543299" + name: User 99 + - age: "20" + mobile: "98765432100" + name: User 100 + groupName: Group 5 + status_code: 200 + header: + Content-Type: application/xml + Date: Mon, 10 Mar 2025 18:25:52 GMT + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2025-03-10T23:55:55.135343658+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1741631155 +curl: | + curl --request GET \ + --url http://localhost:8080/api/people \ + --header 'Host: localhost:8080' \ + --header 'User-Agent: curl/8.7.1' \ + --header 'Accept: application/xml' \ +respType: xml diff --git a/spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-2.yaml b/spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-2.yaml new file mode 100755 index 00000000..51516f94 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-2.yaml @@ -0,0 +1,351 @@ +# Generated by Keploy (0.11.10) +version: api.keploy.io/v1beta1 +kind: Http +name: test-2 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8080/api/people + header: + Accept: application/xml + Host: localhost:8080 + User-Agent: curl/8.7.1 + body: "" + timestamp: 2025-03-10T23:56:35.246524486+05:30 + resp: + body: + People: + UserList: + - User: + - age: "21" + mobile: "987654321" + name: User 1 + - age: "22" + mobile: "987654322" + name: User 2 + - age: "23" + mobile: "987654323" + name: User 3 + - age: "24" + mobile: "987654324" + name: User 4 + - age: "25" + mobile: "987654325" + name: User 5 + - age: "26" + mobile: "987654326" + name: User 6 + - age: "27" + mobile: "987654327" + name: User 7 + - age: "28" + mobile: "987654328" + name: User 8 + - age: "29" + mobile: "987654329" + name: User 9 + - age: "20" + mobile: "9876543210" + name: User 10 + - age: "21" + mobile: "9876543211" + name: User 11 + - age: "22" + mobile: "9876543212" + name: User 12 + - age: "23" + mobile: "9876543213" + name: User 13 + - age: "24" + mobile: "9876543214" + name: User 14 + - age: "25" + mobile: "9876543215" + name: User 15 + - age: "26" + mobile: "9876543216" + name: User 16 + - age: "27" + mobile: "9876543217" + name: User 17 + - age: "28" + mobile: "9876543218" + name: User 18 + - age: "29" + mobile: "9876543219" + name: User 19 + - age: "20" + mobile: "9876543220" + name: User 20 + groupName: Group 1 + - User: + - age: "21" + mobile: "9876543221" + name: User 21 + - age: "22" + mobile: "9876543222" + name: User 22 + - age: "23" + mobile: "9876543223" + name: User 23 + - age: "24" + mobile: "9876543224" + name: User 24 + - age: "25" + mobile: "9876543225" + name: User 25 + - age: "26" + mobile: "9876543226" + name: User 26 + - age: "27" + mobile: "9876543227" + name: User 27 + - age: "28" + mobile: "9876543228" + name: User 28 + - age: "29" + mobile: "9876543229" + name: User 29 + - age: "20" + mobile: "9876543230" + name: User 30 + - age: "21" + mobile: "9876543231" + name: User 31 + - age: "22" + mobile: "9876543232" + name: User 32 + - age: "23" + mobile: "9876543233" + name: User 33 + - age: "24" + mobile: "9876543234" + name: User 34 + - age: "25" + mobile: "9876543235" + name: User 35 + - age: "26" + mobile: "9876543236" + name: User 36 + - age: "27" + mobile: "9876543237" + name: User 37 + - age: "28" + mobile: "9876543238" + name: User 38 + - age: "29" + mobile: "9876543239" + name: User 39 + - age: "20" + mobile: "9876543240" + name: User 40 + groupName: Group 2 + - User: + - age: "21" + mobile: "9876543241" + name: User 41 + - age: "22" + mobile: "9876543242" + name: User 42 + - age: "23" + mobile: "9876543243" + name: User 43 + - age: "24" + mobile: "9876543244" + name: User 44 + - age: "25" + mobile: "9876543245" + name: User 45 + - age: "26" + mobile: "9876543246" + name: User 46 + - age: "27" + mobile: "9876543247" + name: User 47 + - age: "28" + mobile: "9876543248" + name: User 48 + - age: "29" + mobile: "9876543249" + name: User 49 + - age: "20" + mobile: "9876543250" + name: User 50 + - age: "21" + mobile: "9876543251" + name: User 51 + - age: "22" + mobile: "9876543252" + name: User 52 + - age: "23" + mobile: "9876543253" + name: User 53 + - age: "24" + mobile: "9876543254" + name: User 54 + - age: "25" + mobile: "9876543255" + name: User 55 + - age: "26" + mobile: "9876543256" + name: User 56 + - age: "27" + mobile: "9876543257" + name: User 57 + - age: "28" + mobile: "9876543258" + name: User 58 + - age: "29" + mobile: "9876543259" + name: User 59 + - age: "20" + mobile: "9876543260" + name: User 60 + groupName: Group 3 + - User: + - age: "21" + mobile: "9876543261" + name: User 61 + - age: "22" + mobile: "9876543262" + name: User 62 + - age: "23" + mobile: "9876543263" + name: User 63 + - age: "24" + mobile: "9876543264" + name: User 64 + - age: "25" + mobile: "9876543265" + name: User 65 + - age: "26" + mobile: "9876543266" + name: User 66 + - age: "27" + mobile: "9876543267" + name: User 67 + - age: "28" + mobile: "9876543268" + name: User 68 + - age: "29" + mobile: "9876543269" + name: User 69 + - age: "20" + mobile: "9876543270" + name: User 70 + - age: "21" + mobile: "9876543271" + name: User 71 + - age: "22" + mobile: "9876543272" + name: User 72 + - age: "23" + mobile: "9876543273" + name: User 73 + - age: "24" + mobile: "9876543274" + name: User 74 + - age: "25" + mobile: "9876543275" + name: User 75 + - age: "26" + mobile: "9876543276" + name: User 76 + - age: "27" + mobile: "9876543277" + name: User 77 + - age: "28" + mobile: "9876543278" + name: User 78 + - age: "29" + mobile: "9876543279" + name: User 79 + - age: "20" + mobile: "9876543280" + name: User 80 + groupName: Group 4 + - User: + - age: "21" + mobile: "9876543281" + name: User 81 + - age: "22" + mobile: "9876543282" + name: User 82 + - age: "23" + mobile: "9876543283" + name: User 83 + - age: "24" + mobile: "9876543284" + name: User 84 + - age: "25" + mobile: "9876543285" + name: User 85 + - age: "26" + mobile: "9876543286" + name: User 86 + - age: "27" + mobile: "9876543287" + name: User 87 + - age: "28" + mobile: "9876543288" + name: User 88 + - age: "29" + mobile: "9876543289" + name: User 89 + - age: "20" + mobile: "9876543290" + name: User 90 + - age: "21" + mobile: "9876543291" + name: User 91 + - age: "22" + mobile: "9876543292" + name: User 92 + - age: "23" + mobile: "9876543293" + name: User 93 + - age: "24" + mobile: "9876543294" + name: User 94 + - age: "25" + mobile: "9876543295" + name: User 95 + - age: "26" + mobile: "9876543296" + name: User 96 + - age: "27" + mobile: "9876543297" + name: User 97 + - age: "28" + mobile: "9876543298" + name: User 98 + - age: "29" + mobile: "9876543299" + name: User 99 + - age: "20" + mobile: "98765432100" + name: User 100 + groupName: Group 5 + status_code: 200 + header: + Content-Type: application/xml + Date: Mon, 10 Mar 2025 18:26:35 GMT + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2025-03-10T23:56:38.161497468+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1741631198 +curl: | + curl --request GET \ + --url http://localhost:8080/api/people \ + --header 'Host: localhost:8080' \ + --header 'User-Agent: curl/8.7.1' \ + --header 'Accept: application/xml' \ +respType: xml diff --git a/spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-3.yaml b/spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-3.yaml new file mode 100755 index 00000000..579fcaed --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-3.yaml @@ -0,0 +1,351 @@ +# Generated by Keploy (0.11.10) +version: api.keploy.io/v1beta1 +kind: Http +name: test-3 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8080/api/people + header: + Accept: application/xml + Host: localhost:8080 + User-Agent: curl/8.7.1 + body: "" + timestamp: 2025-03-10T23:56:36.103072906+05:30 + resp: + body: + People: + UserList: + - User: + - age: "21" + mobile: "987654321" + name: User 1 + - age: "22" + mobile: "987654322" + name: User 2 + - age: "23" + mobile: "987654323" + name: User 3 + - age: "24" + mobile: "987654324" + name: User 4 + - age: "25" + mobile: "987654325" + name: User 5 + - age: "26" + mobile: "987654326" + name: User 6 + - age: "27" + mobile: "987654327" + name: User 7 + - age: "28" + mobile: "987654328" + name: User 8 + - age: "29" + mobile: "987654329" + name: User 9 + - age: "20" + mobile: "9876543210" + name: User 10 + - age: "21" + mobile: "9876543211" + name: User 11 + - age: "22" + mobile: "9876543212" + name: User 12 + - age: "23" + mobile: "9876543213" + name: User 13 + - age: "24" + mobile: "9876543214" + name: User 14 + - age: "25" + mobile: "9876543215" + name: User 15 + - age: "26" + mobile: "9876543216" + name: User 16 + - age: "27" + mobile: "9876543217" + name: User 17 + - age: "28" + mobile: "9876543218" + name: User 18 + - age: "29" + mobile: "9876543219" + name: User 19 + - age: "20" + mobile: "9876543220" + name: User 20 + groupName: Group 1 + - User: + - age: "21" + mobile: "9876543221" + name: User 21 + - age: "22" + mobile: "9876543222" + name: User 22 + - age: "23" + mobile: "9876543223" + name: User 23 + - age: "24" + mobile: "9876543224" + name: User 24 + - age: "25" + mobile: "9876543225" + name: User 25 + - age: "26" + mobile: "9876543226" + name: User 26 + - age: "27" + mobile: "9876543227" + name: User 27 + - age: "28" + mobile: "9876543228" + name: User 28 + - age: "29" + mobile: "9876543229" + name: User 29 + - age: "20" + mobile: "9876543230" + name: User 30 + - age: "21" + mobile: "9876543231" + name: User 31 + - age: "22" + mobile: "9876543232" + name: User 32 + - age: "23" + mobile: "9876543233" + name: User 33 + - age: "24" + mobile: "9876543234" + name: User 34 + - age: "25" + mobile: "9876543235" + name: User 35 + - age: "26" + mobile: "9876543236" + name: User 36 + - age: "27" + mobile: "9876543237" + name: User 37 + - age: "28" + mobile: "9876543238" + name: User 38 + - age: "29" + mobile: "9876543239" + name: User 39 + - age: "20" + mobile: "9876543240" + name: User 40 + groupName: Group 2 + - User: + - age: "21" + mobile: "9876543241" + name: User 41 + - age: "22" + mobile: "9876543242" + name: User 42 + - age: "23" + mobile: "9876543243" + name: User 43 + - age: "24" + mobile: "9876543244" + name: User 44 + - age: "25" + mobile: "9876543245" + name: User 45 + - age: "26" + mobile: "9876543246" + name: User 46 + - age: "27" + mobile: "9876543247" + name: User 47 + - age: "28" + mobile: "9876543248" + name: User 48 + - age: "29" + mobile: "9876543249" + name: User 49 + - age: "20" + mobile: "9876543250" + name: User 50 + - age: "21" + mobile: "9876543251" + name: User 51 + - age: "22" + mobile: "9876543252" + name: User 52 + - age: "23" + mobile: "9876543253" + name: User 53 + - age: "24" + mobile: "9876543254" + name: User 54 + - age: "25" + mobile: "9876543255" + name: User 55 + - age: "26" + mobile: "9876543256" + name: User 56 + - age: "27" + mobile: "9876543257" + name: User 57 + - age: "28" + mobile: "9876543258" + name: User 58 + - age: "29" + mobile: "9876543259" + name: User 59 + - age: "20" + mobile: "9876543260" + name: User 60 + groupName: Group 3 + - User: + - age: "21" + mobile: "9876543261" + name: User 61 + - age: "22" + mobile: "9876543262" + name: User 62 + - age: "23" + mobile: "9876543263" + name: User 63 + - age: "24" + mobile: "9876543264" + name: User 64 + - age: "25" + mobile: "9876543265" + name: User 65 + - age: "26" + mobile: "9876543266" + name: User 66 + - age: "27" + mobile: "9876543267" + name: User 67 + - age: "28" + mobile: "9876543268" + name: User 68 + - age: "29" + mobile: "9876543269" + name: User 69 + - age: "20" + mobile: "9876543270" + name: User 70 + - age: "21" + mobile: "9876543271" + name: User 71 + - age: "22" + mobile: "9876543272" + name: User 72 + - age: "23" + mobile: "9876543273" + name: User 73 + - age: "24" + mobile: "9876543274" + name: User 74 + - age: "25" + mobile: "9876543275" + name: User 75 + - age: "26" + mobile: "9876543276" + name: User 76 + - age: "27" + mobile: "9876543277" + name: User 77 + - age: "28" + mobile: "9876543278" + name: User 78 + - age: "29" + mobile: "9876543279" + name: User 79 + - age: "20" + mobile: "9876543280" + name: User 80 + groupName: Group 4 + - User: + - age: "21" + mobile: "9876543281" + name: User 81 + - age: "22" + mobile: "9876543282" + name: User 82 + - age: "23" + mobile: "9876543283" + name: User 83 + - age: "24" + mobile: "9876543284" + name: User 84 + - age: "25" + mobile: "9876543285" + name: User 85 + - age: "26" + mobile: "9876543286" + name: User 86 + - age: "27" + mobile: "9876543287" + name: User 87 + - age: "28" + mobile: "9876543288" + name: User 88 + - age: "29" + mobile: "9876543289" + name: User 89 + - age: "20" + mobile: "9876543290" + name: User 90 + - age: "21" + mobile: "9876543291" + name: User 91 + - age: "22" + mobile: "9876543292" + name: User 92 + - age: "23" + mobile: "9876543293" + name: User 93 + - age: "24" + mobile: "9876543294" + name: User 94 + - age: "25" + mobile: "9876543295" + name: User 95 + - age: "26" + mobile: "9876543296" + name: User 96 + - age: "27" + mobile: "9876543297" + name: User 97 + - age: "28" + mobile: "9876543298" + name: User 98 + - age: "29" + mobile: "9876543299" + name: User 99 + - age: "20" + mobile: "98765432100" + name: User 100 + groupName: Group 5 + status_code: 200 + header: + Content-Type: application/xml + Date: Mon, 10 Mar 2025 18:26:35 GMT + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2025-03-10T23:56:39.186153662+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1741631199 +curl: | + curl --request GET \ + --url http://localhost:8080/api/people \ + --header 'Accept: application/xml' \ + --header 'Host: localhost:8080' \ + --header 'User-Agent: curl/8.7.1' \ +respType: xml diff --git a/spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-4.yaml b/spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-4.yaml new file mode 100755 index 00000000..969b8f86 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/keploy/test-set-2/tests/test-4.yaml @@ -0,0 +1,192 @@ +# Generated by Keploy (0.11.10) +version: api.keploy.io/v1beta1 +kind: Http +name: test-4 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8080/api/users + header: + Accept: application/xml + Host: localhost:8080 + User-Agent: curl/8.7.1 + body: "" + timestamp: 2025-03-10T23:57:56.716239336+05:30 + resp: + body: + UserList: + User: + - age: "26" + mobile: "999999991" + name: User 1 + - age: "27" + mobile: "999999992" + name: User 2 + - age: "28" + mobile: "999999993" + name: User 3 + - age: "29" + mobile: "999999994" + name: User 4 + - age: "30" + mobile: "999999995" + name: User 5 + - age: "31" + mobile: "999999996" + name: User 6 + - age: "32" + mobile: "999999997" + name: User 7 + - age: "33" + mobile: "999999998" + name: User 8 + - age: "34" + mobile: "999999999" + name: User 9 + - age: "25" + mobile: "9999999910" + name: User 10 + - age: "26" + mobile: "9999999911" + name: User 11 + - age: "27" + mobile: "9999999912" + name: User 12 + - age: "28" + mobile: "9999999913" + name: User 13 + - age: "29" + mobile: "9999999914" + name: User 14 + - age: "30" + mobile: "9999999915" + name: User 15 + - age: "31" + mobile: "9999999916" + name: User 16 + - age: "32" + mobile: "9999999917" + name: User 17 + - age: "33" + mobile: "9999999918" + name: User 18 + - age: "34" + mobile: "9999999919" + name: User 19 + - age: "25" + mobile: "9999999920" + name: User 20 + - age: "26" + mobile: "9999999921" + name: User 21 + - age: "27" + mobile: "9999999922" + name: User 22 + - age: "28" + mobile: "9999999923" + name: User 23 + - age: "29" + mobile: "9999999924" + name: User 24 + - age: "30" + mobile: "9999999925" + name: User 25 + - age: "31" + mobile: "9999999926" + name: User 26 + - age: "32" + mobile: "9999999927" + name: User 27 + - age: "33" + mobile: "9999999928" + name: User 28 + - age: "34" + mobile: "9999999929" + name: User 29 + - age: "25" + mobile: "9999999930" + name: User 30 + - age: "26" + mobile: "9999999931" + name: User 31 + - age: "27" + mobile: "9999999932" + name: User 32 + - age: "28" + mobile: "9999999933" + name: User 33 + - age: "29" + mobile: "9999999934" + name: User 34 + - age: "30" + mobile: "99999999357879" + name: User 35 + - age: "31" + mobile: "9999999936" + name: User 36 + - age: "32" + mobile: "9999999937" + name: User 37 + - age: "33" + mobile: "9999999938" + name: User 38 + - age: "34" + mobile: "9999999939" + name: User 39 + - age: "25" + mobile: "9999999940" + name: User 40 + - age: "26" + mobile: "9999999941" + name: User 41 + - age: "27" + mobile: "9999999942" + name: User 42 + - age: "28" + mobile: "9999999943" + name: User 43 + - age: "29" + mobile: "9999999944" + name: User 44 + - age: "30" + mobile: "9999999945" + name: User 45 + - age: "31" + mobile: "9999999946" + name: User 46 + - age: "32" + mobile: "9999999947" + name: User 47 + - age: "33" + mobile: "9999999948" + name: User 48 + - age: "34" + mobile: "9999999949" + name: User 49 + - age: "25" + mobile: "9999999950" + name: User 50 + groupName: Main Group + status_code: 200 + header: + Content-Type: application/xml + Date: Mon, 10 Mar 2025 18:27:56 GMT + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2025-03-10T23:57:59.8553577+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1741631279 +curl: | + curl --request GET \ + --url http://localhost:8080/api/users \ + --header 'Host: localhost:8080' \ + --header 'User-Agent: curl/8.7.1' \ + --header 'Accept: application/xml' \ +respType: xml diff --git a/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/controllers/UserController.java b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/controllers/UserController.java index 2dd2e459..7cd6fafc 100644 --- a/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/controllers/UserController.java +++ b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/controllers/UserController.java @@ -1,15 +1,46 @@ package com.example.XML.controllers; +import com.example.XML.entities.People; import com.example.XML.entities.User; +import com.example.XML.entities.UserList; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; +import java.util.List; + @RestController @RequestMapping("/api") public class UserController { + @GetMapping(value = "/user", produces = "application/xml") public User getUser() { - return new User("John Doe", 30,"0101233333"); + return new User("John Doe", 30, "0101233333"); + } + + @GetMapping(value = "/users", produces = "application/xml") + public UserList getUsers() { + List users = new ArrayList<>(); + for (int i = 1; i <= 50; i++) { + users.add(new User("User " + i, 25 + (i % 10), "99999999" + i)); + } + return new UserList("Main Group", users); // ✅ Fixed + } + + @GetMapping(value = "/people", produces = "application/xml") + public People getPeople() { + List userLists = new ArrayList<>(); + + // Creating multiple UserLists to add to People + for (int j = 1; j <= 5; j++) { // 5 groups of users + List users = new ArrayList<>(); + for (int i = 1; i <= 20; i++) { // Each group contains 20 users + users.add(new User("User " + ((j - 1) * 20 + i), 20 + (i % 10), "98765432" + ((j - 1) * 20 + i))); + } + userLists.add(new UserList("Group " + j, users)); // ✅ Fixed + } + + return new People(userLists); } } diff --git a/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/People.java b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/People.java new file mode 100644 index 00000000..250eb075 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/People.java @@ -0,0 +1,25 @@ +package com.example.XML.entities; + +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement(name = "People") +public class People { + @XmlElement(name = "UserList") + private List userLists; + + public People() {} + + public People(List userLists) { + this.userLists = userLists; + } + + public List getUserLists() { + return userLists; + } + + public void setUserLists(List userLists) { + this.userLists = userLists; + } +} diff --git a/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/User.java b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/User.java index 37439201..139c3500 100644 --- a/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/User.java +++ b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/User.java @@ -13,7 +13,7 @@ public class User { @XmlElement(name = "mobile") private String mobile; - // Constructors, getters, and setters + public User() {} public User(String name, int age, String mobile) { @@ -37,10 +37,12 @@ public int getAge() { public void setAge(int age) { this.age = age; } + public String getMobile() { return mobile; } + public void setMobile(String mobile) { this.mobile = mobile; } -} \ No newline at end of file +} diff --git a/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/UserList.java b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/UserList.java new file mode 100644 index 00000000..e0dc4648 --- /dev/null +++ b/spring-boot-xml/naive-spring-boot/src/main/java/com/example/XML/entities/UserList.java @@ -0,0 +1,49 @@ +package com.example.XML.entities; + +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import java.util.List; +import java.util.ArrayList; + +@XmlRootElement(name = "UserList") +public class UserList { + + @XmlElement(name = "groupName") + private String groupName; + + @XmlElement(name = "User") + private List users; + + // No-arg constructor required by JAXB + public UserList() { + this.groupName = "Default Group"; // Set a default name + this.users = new ArrayList<>(); + } + + public UserList(String groupName, List users) { + this.groupName = groupName; + this.users = users != null ? users : new ArrayList<>(); + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users != null ? users : new ArrayList<>(); + } + + public void addUser(User user) { + if (user != null) { + this.users.add(user); + } + } +}