diff --git a/.github/workflows/gradle.yaml b/.github/workflows/gradle.yaml
index 075af79..718eb94 100644
--- a/.github/workflows/gradle.yaml
+++ b/.github/workflows/gradle.yaml
@@ -16,9 +16,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- - name: Set up JDK 11
+ - name: Set up JDK 17
uses: actions/setup-java@v1
with:
- java-version: 11
+ java-version: 17
- name: Build
run: ./gradlew check
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 9fd08b3..add5eb9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,6 @@
buildscript {
ext {
- springBootVersion = '2.7.7'
+ springBootVersion = '3.3.4'
}
repositories {
mavenLocal()
@@ -22,13 +22,14 @@ plugins {
id 'jacoco'
id 'pmd'
id 'com.github.ben-manes.versions' version '0.20.0'
- id "info.solidsoft.pitest" version '1.3.0'
- id 'io.spring.dependency-management' version '1.0.9.RELEASE'
+ id "info.solidsoft.pitest" version '1.7.4'
+ id 'org.springframework.boot' version '3.3.4'
+ id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.owasp.dependencycheck' version '8.0.1'
- id 'org.sonarqube' version '2.8'
- id "org.flywaydb.flyway" version "6.2.0"
+ id 'org.sonarqube' version '4.2.1.3168'
+ id "org.flywaydb.flyway" version "8.5.2"
id 'maven-publish'
- id 'uk.gov.hmcts.java' version '0.12.0'
+ id 'uk.gov.hmcts.java' version '0.12.39'
}
apply plugin: 'java-library'
@@ -38,19 +39,14 @@ apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
def versions = [
- lombok : '1.18.22',
- gradlePitest : '1.3.0',
- pitest : '1.4.2',
- reformLogging : '5.1.9',
- serenity : '2.0.23',
- sonarPitest : '0.5',
- springBoot : '2.7.7',
- springHystrix : '2.1.1.RELEASE',
- springfoxSwagger : '2.9.2',
- camel : '3.8.0',
- jackson : '2.13.1',
- springVersion : '5.3.20',
- log4j : '2.17.1'
+ logback : '1.5.8',
+ gradlePitest : '1.5.1',
+ pitest : '1.16.1',
+ reformLogging : '6.1.5',
+ serenity : '2.2.12',
+ camel : '4.8.0',
+ jackson : '2.17.2',
+ log4j : '2.23.1'
]
@@ -108,11 +104,11 @@ java {
}
compileJava {
- options.compilerArgs << '-parameters' << '-Xlint:deprecation' << "-Xlint:unchecked" << "-Werror"
+ options.compilerArgs << '-parameters' << '-Xlint:deprecation' << "-Xlint:unchecked"
}
compileTestJava {
- options.compilerArgs << '-Xlint:deprecation' << "-Xlint:unchecked" << "-Werror"
+ options.compilerArgs << '-Xlint:deprecation' << "-Xlint:unchecked"
}
sourceSets {
@@ -156,16 +152,10 @@ idea {
}
}
-// Fix for CVE-2021-21295 & need to be removed with new Azure blob version
configurations.all {
- resolutionStrategy.eachDependency { details ->
- if (details.requested.group == 'io.netty') {
- details.useVersion "4.1.77.Final"
- }
- if (details.requested.group == 'com.ibm.icu') {
- details.useVersion "66.1"
- }
- }
+ exclude group: 'org.apache.groovy', module: 'groovy'
+ exclude group: 'org.apache.groovy', module: 'groovy-xml'
+ exclude group: 'org.apache.groovy', module: 'groovy-json'
}
configurations {
@@ -239,8 +229,8 @@ pitest {
]
threads = 10
enableDefaultIncrementalAnalysis = true
- historyInputLocation = ['build/reports/pitest/fastermutationtesting']
- historyOutputLocation = ['build/reports/pitest/fastermutationtestingoutput']
+ historyInputLocation = 'build/reports/pitest/fastermutationtesting'
+ historyOutputLocation = 'build/reports/pitest/fastermutationtestingoutput'
outputFormats = ['XML', 'HTML']
timestampedReports = true
mutationThreshold = 90
@@ -278,46 +268,46 @@ repositories {
}
dependencies {
- api group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
- implementation (group: 'org.springframework.boot', name: 'spring-boot-starter-json', version: versions.springBoot) {
+ implementation (group: 'org.springframework.boot', name: 'spring-boot-starter-json') {
exclude group: 'org.glassfish', module: 'jakarta.el'
}
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc'
- implementation (group: 'org.springframework.boot', name: 'spring-boot-starter-cache', version: versions.springBoot){
+ implementation (group: 'org.springframework.boot', name: 'spring-boot-starter-cache'){
exclude group: 'org.glassfish', module: 'jakarta.el'
}
- implementation (group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: versions.springBoot) {
+ implementation (group: 'org.springframework.boot', name: 'spring-boot-starter-mail') {
exclude group: 'org.glassfish', module: 'jakarta.el'
}
- api group: 'org.springframework.boot', name: 'spring-boot-starter-batch', version: versions.springBoot
-
- implementation group: 'org.springframework', name: 'spring-core', version: versions.springVersion
- implementation group: 'org.springframework', name: 'spring-beans', version: versions.springVersion
- implementation group: 'org.springframework', name: 'spring-aop', version: versions.springVersion
- implementation group: 'org.springframework', name: 'spring-aspects', version: versions.springVersion
- implementation group: 'org.springframework', name: 'spring-context', version: versions.springVersion
- implementation group: 'org.springframework', name: 'spring-context-support', version: versions.springVersion
- implementation group: 'org.springframework', name: 'spring-expression', version: versions.springVersion
- implementation group: 'org.springframework', name: 'spring-jcl', version: versions.springVersion
- implementation group: 'org.springframework', name: 'spring-jdbc', version: versions.springVersion
- implementation group: 'org.springframework', name: 'spring-orm', version: versions.springVersion
- implementation group: 'org.springframework', name: 'spring-tx', version: versions.springVersion
- implementation group: 'org.springframework', name: 'spring-web', version: versions.springVersion
- implementation group: 'org.springframework', name: 'spring-webmvc', version: versions.springVersion
+ api group: 'org.springframework.boot', name: 'spring-boot-starter-batch'
+
+ implementation group: 'org.springframework', name: 'spring-core'
+ implementation group: 'org.springframework', name: 'spring-beans'
+ implementation group: 'org.springframework', name: 'spring-aop'
+ implementation group: 'org.springframework', name: 'spring-aspects'
+ implementation group: 'org.springframework', name: 'spring-context'
+ implementation group: 'org.springframework', name: 'spring-context-support'
+ implementation group: 'org.springframework', name: 'spring-expression'
+ implementation group: 'org.springframework', name: 'spring-jcl'
+ implementation group: 'org.springframework', name: 'spring-jdbc'
+ implementation group: 'org.springframework', name: 'spring-orm'
+ implementation group: 'org.springframework', name: 'spring-tx'
+ implementation group: 'org.springframework', name: 'spring-web'
+ implementation group: 'org.springframework', name: 'spring-webmvc'
implementation group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '3.0.4'
- implementation (group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.2.1') {
- force = true
- }
- implementation (group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: versions.jackson) {
- force = true
- }
+ implementation (group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jackson)
+ implementation (group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: versions.jackson)
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: versions.jackson
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: versions.jackson
- implementation group: 'com.fasterxml.jackson', name: 'jackson-bom', version: '2.13.2.20220324', ext: 'pom'
+ implementation group: 'com.fasterxml.jackson', name: 'jackson-bom', version: versions.jackson, ext: 'pom'
+ implementation (group: 'commons-fileupload', name: 'commons-fileupload') {
+ version {
+ strictly '1.5'
+ }
+ }
implementation group: 'io.github.openfeign.form', name: 'feign-form', version: '3.8.0'
implementation (group: 'io.github.openfeign.form', name: 'feign-form-spring', version: '3.8.0') {
exclude group: 'commons-io', module: 'commons-io'
@@ -332,58 +322,64 @@ dependencies {
exclude group: 'org.apache.tomcat.embed', module: 'tomcat-embed-core'
exclude group: 'org.apache.tomcat.embed', module: 'tomcat-embed-websocket'
}
- implementation ('com.github.hmcts:service-auth-provider-java-client:4.0.3') {
+ implementation ('com.github.hmcts:service-auth-provider-java-client:5.1.0') {
exclude group: 'org.springframework.cloud', module: 'spring-cloud-openfeign-core'
}
- implementation group: 'org.springframework.security', name: 'spring-security-crypto', version: '5.7.1'
- implementation 'net.logstash.logback:logstash-logback-encoder:6.4'
+ implementation group: 'org.springframework.security', name: 'spring-security-crypto', version: '5.8.5'
- implementation group: 'com.microsoft.azure', name: 'azure-storage-blob', version: '11.0.0'
+ implementation group: 'com.azure', name: 'azure-storage-blob', version: '12.24.0'
-
- implementation group: 'org.springframework.security', name: 'spring-security-core', version: '5.7.5'
+ implementation group: 'org.springframework.security', name: 'spring-security-core', version: '5.8.5'
implementation group: 'org.bouncycastle', name: 'bcpkix-jdk18on', version: '1.72'
implementation group: 'org.flywaydb', name: 'flyway-core', version: '5.2.4'
- implementation group: 'org.postgresql', name: 'postgresql', version: '42.3.3'
+ implementation group: 'org.postgresql', name: 'postgresql', version: '42.3.8'
- implementation group: 'com.google.guava', name: 'guava', version: '30.1-jre'
+ implementation group: 'com.google.guava', name: 'guava', version: '32.0.0-jre'
implementation group: 'org.apache.commons', name: 'commons-vfs2', version: '2.4.1'
implementation group: 'com.jcraft', name: 'jsch', version: '0.1.55'
implementation 'commons-io:commons-io:2.8.0'
+ implementation group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
+
api group: 'org.apache.camel.springboot', name: 'camel-spring-boot-starter', version:versions.camel
implementation group: 'org.apache.camel', name: 'camel-csv', version: versions.camel
implementation group: 'org.apache.camel', name: 'camel-sql', version: versions.camel
api group: 'org.apache.camel', name: 'camel-spring-batch', version: versions.camel
+ testImplementation group: 'org.apache.camel', name: 'camel-test-spring', version: '3.22.2'
- api group: 'org.apache.camel.springboot', name: 'camel-azure-starter', version:versions.camel
+ api group: 'org.apache.camel.springboot', name: 'camel-azure-storage-blob-starter', version:versions.camel
+ // api group: 'org.apache.camel.springboot', name: 'camel-azure-storage-queue-starter', version:versions.camel
api group: 'org.apache.camel.springboot', name: 'camel-bindy-starter', version:versions.camel
implementation group: 'org.apache.camel.springboot', name: 'camel-jdbc-starter', version:versions.camel
implementation group: 'org.apache.camel', name: 'camel-bean-validator', version: versions.camel
implementation group: 'org.apache.camel.springboot', name: 'camel-spring-boot-starter', version: versions.camel
implementation group: 'org.apache.camel', name: 'camel-core', version: versions.camel
- implementation group: 'org.apache.camel', name: 'spi-annotations', version: '3.4.1'
+ implementation group: 'org.apache.camel', name: 'spi-annotations', version: versions.camel
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: versions.log4j
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: versions.log4j
implementation group: 'org.apache.logging.log4j', name: 'log4j', version: versions.log4j
implementation group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: versions.log4j
- implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.10'
- implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.10'
+ implementation group: 'ch.qos.logback', name: 'logback-core', version: versions.logback
+ implementation group: 'ch.qos.logback', name: 'logback-classic', version: versions.logback
+ implementation 'net.logstash.logback:logstash-logback-encoder:8.0'
- implementation group: 'org.springframework.cloud', name: 'spring-cloud-config-server', version: '3.1.5'
+ implementation group: 'org.springframework.cloud', name: 'spring-cloud-config-server', version: '4.1.3'
implementation group: 'com.opencsv', name: 'opencsv', version: '3.7'
api group: 'commons-lang', name: 'commons-lang', version: '2.6'
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
implementation 'com.sendgrid:sendgrid-java:4.7.2'
+ implementation group: 'jakarta.el', name: 'jakarta.el-api', version: '5.0.0'
+ implementation group: 'org.glassfish.expressly', name: 'expressly', version: '5.0.0'
+
compileOnly group: 'org.projectlombok', name: 'lombok', version: versions.lombok
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
testCompileOnly group: 'org.projectlombok', name: 'lombok', version: versions.lombok
@@ -395,7 +391,7 @@ dependencies {
smokeTestCompileOnly group: 'org.projectlombok', name: 'lombok', version: versions.lombok
smokeTestAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
- testImplementation (group: 'io.rest-assured', name: 'rest-assured', version: '4.3.1') {
+ testImplementation (group: 'io.rest-assured', name: 'rest-assured', version: '4.5.1') {
exclude group: "com.sun.xml.bind", module: "jaxb-osgi"
}
testImplementation("org.hamcrest:hamcrest-junit:2.0.0.0") {
@@ -407,7 +403,8 @@ dependencies {
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.4.6'
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '3.4.6'
testImplementation group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.9'
- testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: versions.springBoot
+ testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
+ testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testImplementation group: 'org.springframework.batch', name: 'spring-batch-test', version: '4.2.4.RELEASE'
testImplementation group: 'org.pitest', name: 'pitest', version: versions.pitest
@@ -415,27 +412,21 @@ dependencies {
testImplementation 'org.codehaus.sonar-plugins:sonar-pitest-plugin:0.5'
- testImplementation group: 'org.apache.camel', name: 'camel-test-spring', version: versions.camel
- testImplementation group: 'org.apache.camel', name: 'camel-test', version: versions.camel
+ testImplementation group: 'org.apache.camel', name: 'camel-test-spring-junit5', version: versions.camel
+ testImplementation group: 'org.apache.camel', name: 'camel-test-junit5', version: versions.camel
testImplementation group: 'org.testcontainers', name: 'postgresql', version: '1.12.5'
- testImplementation group: 'org.postgresql', name: 'postgresql', version: '42.3.3'
+ testImplementation group: 'org.postgresql', name: 'postgresql', version: '42.3.8'
- integrationTestImplementation group: 'org.apache.camel', name: 'camel-test-spring', version: versions.camel
- integrationTestImplementation group: 'org.apache.camel', name: 'camel-test', version: versions.camel
+ integrationTestImplementation group: 'org.apache.camel', name: 'camel-test-spring-junit5', version: versions.camel
+ integrationTestImplementation group: 'org.apache.camel', name: 'camel-test-junit5', version: versions.camel
integrationTestImplementation group: 'org.testcontainers', name: 'postgresql', version: '1.12.5'
- integrationTestImplementation group: 'org.postgresql', name: 'postgresql', version: '42.3.3'
+ integrationTestImplementation group: 'org.postgresql', name: 'postgresql', version: '42.3.8'
- testImplementation(group: 'org.yaml', name: 'snakeyaml', version: '1.23') {
- force = true
- }
+ testImplementation(group: 'org.yaml', name: 'snakeyaml', version: '1.23')
- integrationTestImplementation(group: 'org.yaml', name: 'snakeyaml', version: '1.23') {
- force = true
- }
+ integrationTestImplementation(group: 'org.yaml', name: 'snakeyaml', version: '1.23')
- functionalTestImplementation(group: 'org.yaml', name: 'snakeyaml', version: '1.23') {
- force = true
- }
+ functionalTestImplementation(group: 'org.yaml', name: 'snakeyaml', version: '1.23')
integrationTestImplementation sourceSets.main.runtimeClasspath
integrationTestImplementation sourceSets.test.runtimeClasspath
@@ -483,6 +474,10 @@ tasks.jar {
// java flag that configures the deployed applications
applicationDefaultJvmArgs = ["-Dfile.encoding=UTF-8"]
+tasks.named("bootDistZip").configure { dependsOn("jar")}
+tasks.named("bootDistTar").configure { dependsOn("jar")}
+tasks.named("bootStartScripts").configure { dependsOn("jar")}
+
test {
useJUnitPlatform()
}
diff --git a/config/owasp/suppressions.xml b/config/owasp/suppressions.xml
index c45d062..24043a9 100644
--- a/config/owasp/suppressions.xml
+++ b/config/owasp/suppressions.xml
@@ -14,4 +14,12 @@
]]>
CVE-2016-1000027
+
+ CVE-2022-45688
+ CVE-2022-30187
+ CVE-2023-35116
+ CVE-2008-7271
+ CVE-2010-4647
+ CVE-2023-20859
+ CVE-2022-1471
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 758de96..7454180 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 35541ca..a1f2792 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Fri Aug 03 13:37:52 BST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
diff --git a/gradlew b/gradlew
index cccdd3d..1b6c787 100755
--- a/gradlew
+++ b/gradlew
@@ -1,78 +1,129 @@
-#!/usr/bin/env sh
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed 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
+#
+# https://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.
+#
##############################################################################
-##
-## Gradle start up script for UN*X
-##
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
##############################################################################
# Attempt to set APP_HOME
+
# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
+
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
+APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
+MAX_FD=maximum
warn () {
echo "$*"
-}
+} >&2
die () {
echo
echo "$*"
echo
exit 1
-}
+} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
# Determine the Java command to use to start the JVM.
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"
+ JAVACMD=$JAVA_HOME/jre/sh/java
else
- JAVACMD="$JAVA_HOME/bin/java"
+ JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD="java"
+ JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@@ -89,84 +140,95 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
fi
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
fi
- i=$((i+1))
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index f955316..107acd3 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
diff --git a/jitpack.yml b/jitpack.yml
index 07f2fd5..f225f68 100644
--- a/jitpack.yml
+++ b/jitpack.yml
@@ -1,5 +1,5 @@
jdk:
- - openjdk11
+ - openjdk17
install:
- ./gradlew build publishToMavenLocal
\ No newline at end of file
diff --git a/src/main/java/uk/gov/hmcts/reform/data/ingestion/DataIngestionLibraryRunner.java b/src/main/java/uk/gov/hmcts/reform/data/ingestion/DataIngestionLibraryRunner.java
index bb0c130..0b6d458 100644
--- a/src/main/java/uk/gov/hmcts/reform/data/ingestion/DataIngestionLibraryRunner.java
+++ b/src/main/java/uk/gov/hmcts/reform/data/ingestion/DataIngestionLibraryRunner.java
@@ -1,23 +1,23 @@
package uk.gov.hmcts.reform.data.ingestion;
-import com.microsoft.azure.storage.CloudStorageAccount;
-import com.microsoft.azure.storage.StorageException;
-import com.microsoft.azure.storage.blob.CloudBlobClient;
-import com.microsoft.azure.storage.blob.CloudBlobContainer;
-import com.microsoft.azure.storage.blob.CloudBlockBlob;
+import com.azure.storage.blob.BlobClient;
+import com.azure.storage.blob.BlobContainerClient;
+import com.azure.storage.blob.BlobServiceClient;
+import com.azure.storage.blob.BlobServiceClientBuilder;
+import com.azure.storage.common.StorageSharedKeyCredential;
import lombok.extern.slf4j.Slf4j;
import org.apache.camel.CamelContext;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import uk.gov.hmcts.reform.data.ingestion.camel.service.AuditServiceImpl;
import uk.gov.hmcts.reform.data.ingestion.configuration.AzureBlobConfig;
import java.net.URISyntaxException;
+import java.time.OffsetDateTime;
import java.util.Date;
import java.util.Optional;
import java.util.function.BiPredicate;
@@ -57,8 +57,7 @@ public class DataIngestionLibraryRunner {
private AzureBlobConfig azureBlobConfig;
@Autowired
- @Qualifier("credscloudStorageAccount")
- private CloudStorageAccount cloudStorageAccount;
+ private BlobServiceClientBuilder blobServiceClientBuilder;
@Value("${route.judicial-user-profile-orchestration.file-name:Personal}")
protected String fileName;
@@ -79,21 +78,31 @@ public void run(Job job, JobParameters params) throws Exception {
log.info("{}:: Data Ingestion Library job run completed::", logComponentName);
}
- protected Optional getFileTimestamp(String fileName) throws URISyntaxException, StorageException {
+ protected Optional getFileTimestamp(String fileName) throws URISyntaxException {
camelContext.getGlobalOptions()
.put(SCHEDULER_START_TIME, String.valueOf(new Date().getTime()));
- CloudBlobClient blobClient = cloudStorageAccount.createCloudBlobClient();
- CloudBlobContainer container =
- blobClient.getContainerReference(azureBlobConfig.getContainerName());
+ StorageSharedKeyCredential credential = new StorageSharedKeyCredential(
+ azureBlobConfig.getAccountName(), azureBlobConfig.getAccountKey());
+ String uri = String.format("https://%s.blob.core.windows.net", azureBlobConfig.getAccountName());
- CloudBlockBlob cloudBlockBlob = container.getBlockBlobReference(fileName);
+ BlobServiceClient blobClient = blobServiceClientBuilder
+ .endpoint(uri)
+ .credential(credential)
+ .buildClient();
+ camelContext.getRegistry().bind("client", blobClient);
+
+ BlobContainerClient blobContainerClient = blobClient.getBlobContainerClient(
+ azureBlobConfig.getContainerName());
+
+ BlobClient cloudBlockBlob = blobContainerClient.getBlobClient(fileName);
Optional fileTimestamp = Optional.empty();
if (cloudBlockBlob.exists()) {
- cloudBlockBlob.downloadAttributes();
- fileTimestamp = Optional.ofNullable(cloudBlockBlob.getProperties().getLastModified());
+ OffsetDateTime lastModified = cloudBlockBlob.getProperties().getLastModified();
+ Date lastModifiedDate = new Date(lastModified.toInstant().toEpochMilli());
+ fileTimestamp = Optional.ofNullable(lastModifiedDate);
}
return fileTimestamp;
}
diff --git a/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/processor/FileReadProcessor.java b/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/processor/FileReadProcessor.java
index 602205f..d25f7bd 100644
--- a/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/processor/FileReadProcessor.java
+++ b/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/processor/FileReadProcessor.java
@@ -1,9 +1,10 @@
package uk.gov.hmcts.reform.data.ingestion.camel.processor;
-import com.microsoft.azure.storage.CloudStorageAccount;
-import com.microsoft.azure.storage.blob.CloudBlobClient;
-import com.microsoft.azure.storage.blob.CloudBlobContainer;
-import com.microsoft.azure.storage.blob.CloudBlockBlob;
+import com.azure.storage.blob.BlobClient;
+import com.azure.storage.blob.BlobContainerClient;
+import com.azure.storage.blob.BlobServiceClient;
+import com.azure.storage.blob.BlobServiceClientBuilder;
+import com.azure.storage.common.StorageSharedKeyCredential;
import lombok.extern.slf4j.Slf4j;
import org.apache.camel.CamelContext;
import org.apache.camel.ConsumerTemplate;
@@ -12,7 +13,6 @@
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import uk.gov.hmcts.reform.data.ingestion.camel.exception.RouteFailedException;
@@ -21,10 +21,11 @@
import uk.gov.hmcts.reform.data.ingestion.camel.util.BlobStatus;
import uk.gov.hmcts.reform.data.ingestion.configuration.AzureBlobConfig;
+import java.time.OffsetDateTime;
import java.util.Date;
import java.util.function.BiPredicate;
-import static net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils.isEmpty;
+import static org.apache.commons.lang.StringUtils.isEmpty;
import static org.apache.commons.lang.time.DateUtils.isSameDay;
import static uk.gov.hmcts.reform.data.ingestion.camel.util.BlobStatus.NEW;
import static uk.gov.hmcts.reform.data.ingestion.camel.util.BlobStatus.NOT_EXISTS;
@@ -64,11 +65,11 @@ public class FileReadProcessor implements Processor {
@Autowired
private AuditServiceImpl auditService;
+ @Autowired
+ private BlobServiceClientBuilder blobServiceClientBuilder;
private Date fileTimeStamp;
- @Autowired
- @Qualifier("credscloudStorageAccount")
- private CloudStorageAccount cloudStorageAccount;
+ private BlobServiceClient blobClient;
/**
* Consumes files only if it is not Stale and stores it in message body.
@@ -80,6 +81,17 @@ public void process(Exchange exchange) {
log.info("{}:: FileReadProcessor starts::", logComponentName);
final String blobFilePath = (String) exchange.getProperty(BLOBPATH);
final CamelContext context = exchange.getContext();
+
+ StorageSharedKeyCredential credential = new StorageSharedKeyCredential(
+ azureBlobConfig.getAccountName(), azureBlobConfig.getAccountKey());
+ String uri = String.format("https://%s.blob.core.windows.net", azureBlobConfig.getAccountName());
+
+ blobClient = blobServiceClientBuilder
+ .endpoint(uri)
+ .credential(credential)
+ .buildClient();
+ context.getRegistry().bind("client", blobClient);
+
final ConsumerTemplate consumer = context.createConsumerTemplate();
RouteProperties routeProperties = (RouteProperties) exchange.getIn().getHeader(ROUTE_DETAILS);
String fileName = routeProperties.getFileName();
@@ -109,12 +121,10 @@ public void process(Exchange exchange) {
*/
private BlobStatus getFileStatusInBlobContainer(RouteProperties routeProperties, String schedulerTime) {
try {
+ BlobContainerClient blobContainerClient = blobClient.getBlobContainerClient(
+ azureBlobConfig.getContainerName());
- CloudBlobClient blobClient = cloudStorageAccount.createCloudBlobClient();
- CloudBlobContainer container =
- blobClient.getContainerReference(azureBlobConfig.getContainerName());
-
- CloudBlockBlob cloudBlockBlob = container.getBlockBlobReference(routeProperties.getFileName());
+ BlobClient cloudBlockBlob = blobContainerClient.getBlobClient(routeProperties.getFileName());
//if scheduler time not set via camel context then set as current date else camel context pass current
// data time
@@ -123,8 +133,8 @@ private BlobStatus getFileStatusInBlobContainer(RouteProperties routeProperties,
}
if (cloudBlockBlob.exists()) {
- cloudBlockBlob.downloadAttributes();
- fileTimeStamp = cloudBlockBlob.getProperties().getLastModified();
+ OffsetDateTime lastModified = cloudBlockBlob.getProperties().getLastModified();
+ fileTimeStamp = new Date(lastModified.toInstant().toEpochMilli());
BlobStatus blobStatus;
Date today = new Date(Long.parseLong(schedulerTime));
diff --git a/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/route/DataLoadRoute.java b/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/route/DataLoadRoute.java
index 5068f3f..66842f3 100644
--- a/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/route/DataLoadRoute.java
+++ b/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/route/DataLoadRoute.java
@@ -29,7 +29,7 @@
import java.util.List;
import java.util.Optional;
-import javax.annotation.Resource;
+import jakarta.annotation.Resource;
import javax.sql.DataSource;
import static java.util.Objects.nonNull;
diff --git a/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/validator/DatePattern.java b/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/validator/DatePattern.java
index f3dd92a..be4288a 100644
--- a/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/validator/DatePattern.java
+++ b/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/validator/DatePattern.java
@@ -8,8 +8,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import javax.validation.Constraint;
-import javax.validation.Payload;
+import jakarta.validation.Constraint;
+import jakarta.validation.Payload;
@Target({METHOD, FIELD, PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
diff --git a/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/validator/DatePatternValidator.java b/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/validator/DatePatternValidator.java
index 0684fb1..6458dda 100644
--- a/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/validator/DatePatternValidator.java
+++ b/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/validator/DatePatternValidator.java
@@ -6,8 +6,8 @@
import static java.util.regex.Pattern.compile;
import static org.apache.commons.lang.StringUtils.isEmpty;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
+import jakarta.validation.ConstraintValidator;
+import jakarta.validation.ConstraintValidatorContext;
public class DatePatternValidator implements ConstraintValidator {
diff --git a/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/validator/JsrValidatorInitializer.java b/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/validator/JsrValidatorInitializer.java
index f36c51f..8ca3c50 100644
--- a/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/validator/JsrValidatorInitializer.java
+++ b/src/main/java/uk/gov/hmcts/reform/data/ingestion/camel/validator/JsrValidatorInitializer.java
@@ -1,5 +1,10 @@
package uk.gov.hmcts.reform.data.ingestion.camel.validator;
+import jakarta.annotation.PostConstruct;
+import jakarta.validation.ConstraintViolation;
+import jakarta.validation.Validation;
+import jakarta.validation.Validator;
+import jakarta.validation.ValidatorFactory;
import lombok.extern.slf4j.Slf4j;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
@@ -31,11 +36,6 @@
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import javax.annotation.PostConstruct;
-import javax.validation.ConstraintViolation;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
import static java.lang.Boolean.TRUE;
import static uk.gov.hmcts.reform.data.ingestion.camel.util.MappingConstants.ROUTE_DETAILS;
@@ -132,25 +132,25 @@ public void auditJsrExceptions(Exchange exchange) {
//jsrThresholdLimit=0 we keeping log of all JSR & if jsrThresholdLimit > 0 we
// keeping log of JSR for the threshold limit and fails application after that limit
List> violationList = constraintViolations.stream()
- .limit(jsrThresholdLimit == 0 ? constraintViolations.size() : jsrThresholdLimit)
- .collect(Collectors.toList());
+ .limit(jsrThresholdLimit == 0 ? constraintViolations.size() : jsrThresholdLimit)
+ .collect(Collectors.toList());
jdbcTemplate.batchUpdate(
- invalidJsrSql,
- violationList,
- 10,
- new ParameterizedPreparedStatementSetter>() {
- public void setValues(PreparedStatement ps, ConstraintViolation argument) throws SQLException {
- ps.setString(1, routeProperties.getTableName());
- ps.setTimestamp(2, new Timestamp(Long.valueOf(schedulerTime)));
- ps.setString(3, globalOptions.get(SCHEDULER_NAME));
- ps.setString(4, getKeyFiled(argument.getRootBean()));
- ps.setString(5, argument.getPropertyPath().toString());
- ps.setString(6, argument.getMessage());
- ps.setTimestamp(7, new Timestamp(new Date().getTime()));
- ps.setLong(8, getRowId(argument.getRootBean()));
- }
- });
+ invalidJsrSql,
+ violationList,
+ 10,
+ new ParameterizedPreparedStatementSetter>() {
+ public void setValues(PreparedStatement ps, ConstraintViolation argument) throws SQLException {
+ ps.setString(1, routeProperties.getTableName());
+ ps.setTimestamp(2, new Timestamp(Long.valueOf(schedulerTime)));
+ ps.setString(3, globalOptions.get(SCHEDULER_NAME));
+ ps.setString(4, getKeyFiled(argument.getRootBean()));
+ ps.setString(5, argument.getPropertyPath().toString());
+ ps.setString(6, argument.getMessage());
+ ps.setTimestamp(7, new Timestamp(new Date().getTime()));
+ ps.setLong(8, getRowId(argument.getRootBean()));
+ }
+ });
TransactionStatus status = platformTransactionManager.getTransaction(def);
platformTransactionManager.commit(status);
@@ -167,7 +167,7 @@ public void auditJsrExceptions(List> keys, String fieldInErro
Exchange exchange) {
log.info("{}:: JsrValidatorInitializer data processing audit start for skipping parent table violation {}",
- logComponentName);
+ logComponentName);
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setName("Jsr exception logs");
@@ -177,27 +177,27 @@ public void auditJsrExceptions(List> keys, String fieldInErro
String schedulerTime = globalOptions.get(SCHEDULER_START_TIME);
jdbcTemplate.batchUpdate(
- invalidJsrSql,
- keys,
- jdbcBatchSize,
- new ParameterizedPreparedStatementSetter>() {
- @Override
- public void setValues(PreparedStatement ps, Pair argument) throws SQLException {
- ps.setString(1, routeProperties.getTableName());
- ps.setTimestamp(2, new Timestamp(Long.valueOf(schedulerTime)));
- ps.setString(3, globalOptions.get(SCHEDULER_NAME));
- ps.setString(4, argument.getLeft());
- ps.setString(5, fieldInError);
- ps.setString(6, errorMessage);
- ps.setTimestamp(7, new Timestamp(new Date().getTime()));
- ps.setLong(8, argument.getRight());
- }
- });
+ invalidJsrSql,
+ keys,
+ jdbcBatchSize,
+ new ParameterizedPreparedStatementSetter>() {
+ @Override
+ public void setValues(PreparedStatement ps, Pair argument) throws SQLException {
+ ps.setString(1, routeProperties.getTableName());
+ ps.setTimestamp(2, new Timestamp(Long.valueOf(schedulerTime)));
+ ps.setString(3, globalOptions.get(SCHEDULER_NAME));
+ ps.setString(4, argument.getLeft());
+ ps.setString(5, fieldInError);
+ ps.setString(6, errorMessage);
+ ps.setTimestamp(7, new Timestamp(new Date().getTime()));
+ ps.setLong(8, argument.getRight());
+ }
+ });
TransactionStatus status = platformTransactionManager.getTransaction(def);
platformTransactionManager.commit(status);
log.info("{}:: JsrValidatorInitializer data processing audit complete for skipping parent table violation::",
- logComponentName);
+ logComponentName);
}
/**
@@ -212,7 +212,7 @@ private String getKeyFiled(Object bean) {
for (Field field : objectClass.getDeclaredFields()) {
DataField dataField = AnnotationUtils.findAnnotation(field,
- DataField.class);
+ DataField.class);
if (dataField.pos() == 1) {
field.setAccessible(TRUE);
return (String) field.get(bean);
diff --git a/src/main/java/uk/gov/hmcts/reform/data/ingestion/configuration/BlobStorageCredentials.java b/src/main/java/uk/gov/hmcts/reform/data/ingestion/configuration/BlobStorageCredentials.java
index 2698b7b..3865282 100644
--- a/src/main/java/uk/gov/hmcts/reform/data/ingestion/configuration/BlobStorageCredentials.java
+++ b/src/main/java/uk/gov/hmcts/reform/data/ingestion/configuration/BlobStorageCredentials.java
@@ -1,8 +1,7 @@
package uk.gov.hmcts.reform.data.ingestion.configuration;
-import com.microsoft.azure.storage.CloudStorageAccount;
-import com.microsoft.azure.storage.StorageCredentials;
-import com.microsoft.azure.storage.StorageCredentialsAccountAndKey;
+import com.azure.storage.blob.BlobServiceClientBuilder;
+import com.azure.storage.common.StorageSharedKeyCredential;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
@@ -16,16 +15,16 @@ public class BlobStorageCredentials {
@Autowired
@Qualifier("credsreg")
- StorageCredentials storageCredentials;
+ StorageSharedKeyCredential storageCredentials;
@Bean(name = "credsreg")
- public StorageCredentials credentials() {
- return new StorageCredentialsAccountAndKey(azureBlobConfig.getAccountName(), azureBlobConfig.getAccountKey());
+ public StorageSharedKeyCredential credentials() {
+ return new StorageSharedKeyCredential(azureBlobConfig.getAccountName(), azureBlobConfig.getAccountKey());
}
- @Bean(name = "credscloudStorageAccount")
- public CloudStorageAccount cloudStorageAccount() throws Exception {
- return new CloudStorageAccount(storageCredentials,
- true);
+ @Bean(name = "clientBuilder")
+ public BlobServiceClientBuilder clientBuilder() {
+ return new BlobServiceClientBuilder();
}
+
}
\ No newline at end of file
diff --git a/src/main/java/uk/gov/hmcts/reform/data/ingestion/configuration/DataSourceConfig.java b/src/main/java/uk/gov/hmcts/reform/data/ingestion/configuration/DataSourceConfig.java
index 6e348dc..1fb2c74 100644
--- a/src/main/java/uk/gov/hmcts/reform/data/ingestion/configuration/DataSourceConfig.java
+++ b/src/main/java/uk/gov/hmcts/reform/data/ingestion/configuration/DataSourceConfig.java
@@ -5,6 +5,7 @@
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
@@ -34,6 +35,7 @@ public class DataSourceConfig {
@Bean
+ @Primary
public DataSource dataSource() {
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
dataSourceBuilder.driverClassName("org.postgresql.Driver");
@@ -54,6 +56,7 @@ public DataSource springJdbcDataSource() {
}
@Bean(name = "txManager")
+ @Primary
public PlatformTransactionManager txManager() {
PlatformTransactionManager platformTransactionManager = new DataSourceTransactionManager(dataSource());
return platformTransactionManager;
@@ -77,8 +80,6 @@ public SpringTransactionPolicy getSpringTransactionRequired() {
return springTransactionPolicy;
}
-
-
public DefaultTransactionDefinition defaultTransactionDefinition() {
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
if (nonNull(transactionDefinition)
diff --git a/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/DataIngestionLibraryRunnerTest.java b/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/DataIngestionLibraryRunnerTest.java
index c50d6ef..3c17f9f 100644
--- a/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/DataIngestionLibraryRunnerTest.java
+++ b/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/DataIngestionLibraryRunnerTest.java
@@ -1,15 +1,19 @@
package uk.gov.hmcts.reform.data.ingestion.camel;
-import com.microsoft.azure.storage.CloudStorageAccount;
-import com.microsoft.azure.storage.blob.BlobProperties;
-import com.microsoft.azure.storage.blob.CloudBlobClient;
-import com.microsoft.azure.storage.blob.CloudBlobContainer;
-import com.microsoft.azure.storage.blob.CloudBlockBlob;
+import com.azure.storage.blob.BlobClient;
+import com.azure.storage.blob.BlobContainerClient;
+import com.azure.storage.blob.BlobServiceClient;
+import com.azure.storage.blob.BlobServiceClientBuilder;
+import com.azure.storage.blob.models.BlobProperties;
+import com.azure.storage.common.StorageSharedKeyCredential;
import org.apache.camel.CamelContext;
+import org.apache.camel.spi.Registry;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
@@ -19,10 +23,13 @@
import uk.gov.hmcts.reform.data.ingestion.camel.service.AuditServiceImpl;
import uk.gov.hmcts.reform.data.ingestion.configuration.AzureBlobConfig;
-import java.util.Date;
+import java.time.OffsetDateTime;
+import java.util.Base64;
+import static org.apache.camel.spring.util.ReflectionUtils.setField;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.MockitoAnnotations.openMocks;
@@ -44,20 +51,17 @@ class DataIngestionLibraryRunnerTest {
@Mock
CamelContext camelContext;
- @Mock
- CloudStorageAccount cloudStorageAccount;
-
@Mock
AzureBlobConfig azureBlobConfig;
@Mock
- CloudBlobClient blobClient;
+ BlobServiceClient blobClient;
@Mock
- CloudBlobContainer container;
+ BlobContainerClient container;
@Mock
- CloudBlockBlob cloudBlockBlob;
+ BlobClient cloudBlockBlob;
@Mock
BlobProperties blobProperties;
@@ -68,12 +72,23 @@ class DataIngestionLibraryRunnerTest {
@BeforeEach
void setUp() throws Exception {
openMocks(this);
- when(cloudStorageAccount.createCloudBlobClient()).thenReturn(blobClient);
+ Mockito.when(camelContext.getRegistry()).thenReturn(mock(Registry.class));
when(azureBlobConfig.getContainerName()).thenReturn("test");
- when(blobClient.getContainerReference(anyString())).thenReturn(container);
- when(container.getBlockBlobReference(any())).thenReturn(cloudBlockBlob);
+ when(azureBlobConfig.getAccountName()).thenReturn("test-account-name");
+ when(azureBlobConfig.getAccountKey()).thenReturn(
+ new String(Base64.getEncoder().encode("test-account-key".getBytes())));
+ when(blobClient.getBlobContainerClient(anyString())).thenReturn(container);
+ when(container.getBlobClient(any())).thenReturn(cloudBlockBlob);
when(cloudBlockBlob.getProperties()).thenReturn(blobProperties);
- when(blobProperties.getLastModified()).thenReturn(new Date());
+ when(cloudBlockBlob.exists()).thenReturn(true);
+ when(blobProperties.getLastModified()).thenReturn(OffsetDateTime.now());
+
+ BlobServiceClientBuilder mockBuilder = PowerMockito.mock(BlobServiceClientBuilder.class);
+ Mockito.when(mockBuilder.endpoint(anyString())).thenReturn(mockBuilder);
+ Mockito.when(mockBuilder.credential(any(StorageSharedKeyCredential.class))).thenReturn(mockBuilder);
+ Mockito.when(mockBuilder.buildClient()).thenReturn(blobClient);
+ setField(dataIngestionLibraryRunner.getClass()
+ .getDeclaredField("blobServiceClientBuilder"), dataIngestionLibraryRunner, mockBuilder);
}
@Test
diff --git a/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/processor/ExceptionProcessorTest.java b/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/processor/ExceptionProcessorTest.java
index 8e698ec..8af8024 100644
--- a/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/processor/ExceptionProcessorTest.java
+++ b/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/processor/ExceptionProcessorTest.java
@@ -4,7 +4,7 @@
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.spi.Registry;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
@@ -53,7 +53,7 @@ public class ExceptionProcessorTest extends CamelTestSupport {
FileResponseProcessor fileResponseProcessor = mock(FileResponseProcessor.class);
@BeforeEach
- public void setUp() {
+ public void init() {
MockitoAnnotations.openMocks(this);
}
diff --git a/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/processor/FileReaderTest.java b/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/processor/FileReaderTest.java
index a2b6f9c..2e90237 100644
--- a/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/processor/FileReaderTest.java
+++ b/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/processor/FileReaderTest.java
@@ -1,22 +1,29 @@
package uk.gov.hmcts.reform.data.ingestion.camel.processor;
-import com.microsoft.azure.storage.CloudStorageAccount;
-import com.microsoft.azure.storage.blob.BlobProperties;
-import com.microsoft.azure.storage.blob.CloudBlobClient;
-import com.microsoft.azure.storage.blob.CloudBlobContainer;
-import com.microsoft.azure.storage.blob.CloudBlockBlob;
+import com.azure.storage.blob.BlobClient;
+import com.azure.storage.blob.BlobContainerClient;
+import com.azure.storage.blob.BlobServiceClient;
+import com.azure.storage.blob.BlobServiceClientBuilder;
+import com.azure.storage.blob.models.BlobProperties;
+import com.azure.storage.common.StorageSharedKeyCredential;
import lombok.SneakyThrows;
import org.apache.camel.CamelContext;
import org.apache.camel.ConsumerTemplate;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
+import org.apache.camel.spi.Registry;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import org.powermock.api.mockito.PowerMockito;
import uk.gov.hmcts.reform.data.ingestion.camel.exception.RouteFailedException;
import uk.gov.hmcts.reform.data.ingestion.camel.route.beans.RouteProperties;
import uk.gov.hmcts.reform.data.ingestion.camel.service.AuditServiceImpl;
import uk.gov.hmcts.reform.data.ingestion.configuration.AzureBlobConfig;
+import java.time.Instant;
+import java.time.OffsetDateTime;
+import java.time.ZoneId;
import java.util.Date;
import static org.apache.camel.spring.util.ReflectionUtils.setField;
@@ -29,6 +36,7 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.openMocks;
import static uk.gov.hmcts.reform.data.ingestion.camel.util.MappingConstants.ROUTE_DETAILS;
import static uk.gov.hmcts.reform.data.ingestion.camel.util.MappingConstants.BLOBPATH;
import static uk.gov.hmcts.reform.data.ingestion.camel.util.MappingConstants.SCHEDULER_START_TIME;
@@ -36,28 +44,38 @@
public class FileReaderTest {
- Exchange exchangeMock = mock(Exchange.class);
- Message messageMock = mock(Message.class);
- RouteProperties routePropertiesMock = mock(RouteProperties.class);
- CamelContext camelContext = mock(CamelContext.class);
+ @Mock
+ Exchange exchangeMock;
+ @Mock
+ Message messageMock;
+ @Mock
+ RouteProperties routePropertiesMock;
+ @Mock
+ CamelContext camelContext;
FileReadProcessor fileReadProcessor = spy(new FileReadProcessor());
- AzureBlobConfig azureBlobConfig = mock(AzureBlobConfig.class);
- CloudBlobClient blobClient = mock(CloudBlobClient.class);
- CloudStorageAccount cloudStorageAccount = mock(CloudStorageAccount.class);
- CloudBlobContainer container = mock(CloudBlobContainer.class);
- CloudBlockBlob cloudBlockBlob = mock(CloudBlockBlob.class);
- BlobProperties blobProperties = mock(BlobProperties.class);
- AuditServiceImpl auditService = mock(AuditServiceImpl.class);
- ConsumerTemplate consumerTemplate = mock(ConsumerTemplate.class);
+ @Mock
+ AzureBlobConfig azureBlobConfig;
+ BlobServiceClient blobClient = PowerMockito.mock(BlobServiceClient.class);
+ BlobContainerClient container = PowerMockito.mock(BlobContainerClient.class);
+ @Mock
+ BlobClient cloudBlockBlob;
+ BlobProperties blobProperties = PowerMockito.mock(BlobProperties.class);
+ @Mock
+ AuditServiceImpl auditService;
+ @Mock
+ ConsumerTemplate consumerTemplate;
@BeforeEach
public void setUp() throws Exception {
+ openMocks(this);
+
when(exchangeMock.getIn()).thenReturn(messageMock);
when(exchangeMock.getIn().getHeader(ROUTE_DETAILS)).thenReturn(routePropertiesMock);
when(exchangeMock.getProperty(BLOBPATH)).thenReturn("blobpath");
when(exchangeMock.getContext()).thenReturn(camelContext);
when(exchangeMock.getMessage()).thenReturn(messageMock);
+ when(camelContext.getRegistry()).thenReturn(mock(Registry.class));
when(routePropertiesMock.getFileName()).thenReturn("test-file");
setField(fileReadProcessor.getClass()
.getDeclaredField("azureBlobConfig"), fileReadProcessor, azureBlobConfig);
@@ -65,18 +83,22 @@ public void setUp() throws Exception {
when(azureBlobConfig.getAccountName()).thenReturn("accountName");
setField(fileReadProcessor.getClass()
.getDeclaredField("auditService"), fileReadProcessor, auditService);
- setField(fileReadProcessor.getClass()
- .getDeclaredField("cloudStorageAccount"), fileReadProcessor, cloudStorageAccount);
setField(fileReadProcessor.getClass()
.getDeclaredField("azureBlobConfig"), fileReadProcessor, azureBlobConfig);
when(azureBlobConfig.getContainerName()).thenReturn("test");
when(cloudBlockBlob.getProperties()).thenReturn(blobProperties);
- when(blobProperties.getLastModified()).thenReturn(new Date());
- when(cloudStorageAccount.createCloudBlobClient()).thenReturn(blobClient);
- when(blobClient.getContainerReference(anyString())).thenReturn(container);
- when(container.getBlockBlobReference(any())).thenReturn(cloudBlockBlob);
+ when(blobProperties.getLastModified()).thenReturn(OffsetDateTime.now());
+ when(blobClient.getBlobContainerClient(anyString())).thenReturn(container);
+ when(container.getBlobClient(any())).thenReturn(cloudBlockBlob);
when(exchangeMock.getContext().createConsumerTemplate()).thenReturn(consumerTemplate);
when(camelContext.getGlobalOption(SCHEDULER_START_TIME)).thenReturn(String.valueOf(new Date().getTime()));
+
+ BlobServiceClientBuilder mockBuilder = PowerMockito.mock(BlobServiceClientBuilder.class);
+ when(mockBuilder.endpoint(anyString())).thenReturn(mockBuilder);
+ when(mockBuilder.credential(any(StorageSharedKeyCredential.class))).thenReturn(mockBuilder);
+ when(mockBuilder.buildClient()).thenReturn(blobClient);
+ setField(fileReadProcessor.getClass()
+ .getDeclaredField("blobServiceClientBuilder"), fileReadProcessor, mockBuilder);
}
@Test
@@ -94,8 +116,8 @@ void testProcessStaleFileForJRDWhenAuditingCompletedOnPreviousDay() {
when(cloudBlockBlob.exists()).thenReturn(true);
doNothing().when(auditService).auditException(any(), any());
when(routePropertiesMock.getStartRoute()).thenReturn("direct:JRD");
- when(blobProperties.getLastModified()).thenReturn(new Date(
- new Date().getTime() - MILLIS_IN_A_DAY));
+ when(blobProperties.getLastModified()).thenReturn(OffsetDateTime.ofInstant(
+ Instant.ofEpochMilli(new Date().getTime() - MILLIS_IN_A_DAY), ZoneId.systemDefault()));
fileReadProcessor.process(exchangeMock);
verify(fileReadProcessor).process(exchangeMock);
}
@@ -122,8 +144,8 @@ public void testProcessNonExistFile() {
@Test
@SneakyThrows
public void testProcessNewFile() {
- when(blobProperties.getLastModified()).thenReturn(new Date(
- new Date().getTime() - 1 * 24 * 60 * 60 * 1000));
+ when(blobProperties.getLastModified()).thenReturn(OffsetDateTime.ofInstant(
+ Instant.ofEpochMilli(new Date().getTime() - 1 * 24 * 60 * 60 * 1000), ZoneId.systemDefault()));
when(cloudBlockBlob.exists()).thenReturn(true);
doNothing().when(auditService).auditException(any(), any());
when(consumerTemplate.receiveBody(anyString(), anyInt())).thenReturn("testbody");
diff --git a/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/util/DataLoadUtilTest.java b/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/util/DataLoadUtilTest.java
index 5c405f7..9f3f4fe 100644
--- a/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/util/DataLoadUtilTest.java
+++ b/src/test/java/uk/gov/hmcts/reform/data/ingestion/camel/util/DataLoadUtilTest.java
@@ -1,28 +1,31 @@
package uk.gov.hmcts.reform.data.ingestion.camel.util;
import org.apache.camel.CamelContext;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringTest;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import uk.gov.hmcts.reform.data.ingestion.camel.helper.JrdTestSupport;
import java.sql.Timestamp;
-@SpringBootTest
-@Configuration()
-@ContextConfiguration(classes = DataLoadUtil.class)
-public class DataLoadUtilTest extends CamelTestSupport {
+import static org.junit.Assert.assertNotNull;
+
+@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
+@ContextConfiguration(classes = {DataLoadUtil.class, CamelAutoConfiguration.class})
+@CamelSpringTest
+public class DataLoadUtilTest {
@Autowired
DataLoadUtil dataLoadUtil;
+ @Autowired
+ private CamelContext camelContext;
+
@Test
public void setGlobalConstant() throws Exception {
- CamelContext camelContext = createCamelContext();
- camelContext.start();
dataLoadUtil.setGlobalConstant(camelContext, "judicial_leaf_scheduler");
assertNotNull("judicial_leaf_scheduler", camelContext.getGlobalOption(MappingConstants.SCHEDULER_NAME));
}