diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml
index 078ec39..9e685be 100644
--- a/.github/workflows/maven-build.yml
+++ b/.github/workflows/maven-build.yml
@@ -2,136 +2,95 @@ name: Maven Package Build
on:
push:
- branches: '*'
+ branches: '**'
pull_request:
- branches: '*'
+ branches: '**'
workflow_dispatch:
+# Cada push lanza un job por proyecto (86 ahora mismo), asi que se cancela
+# la ejecucion anterior de la misma rama cuando llega un commit nuevo.
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
jobs:
+ discover:
+ name: Discover Maven projects
+ runs-on: ubuntu-latest
+
+ outputs:
+ projects: ${{ steps.find.outputs.projects }}
+ count: ${{ steps.find.outputs.count }}
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Find every pom.xml
+ id: find
+ run: |
+ set -euo pipefail
+
+ # Un proyecto = un directorio con pom.xml versionado. Usar git ls-files
+ # en vez de find deja fuera cualquier pom generado (target/, etc.).
+ projects=$(git ls-files '*pom.xml' \
+ | sed -e 's|/pom.xml$||' -e 's|^pom.xml$|.|' \
+ | sort \
+ | jq -R -s -c 'split("\n") | map(select(length > 0))')
+
+ count=$(printf '%s' "$projects" | jq 'length')
+
+ if [ "$count" -eq 0 ]; then
+ echo "No se ha encontrado ningun pom.xml" >&2
+ exit 1
+ fi
+
+ # El limite de GitHub Actions es de 256 jobs por matriz.
+ if [ "$count" -gt 256 ]; then
+ echo "Hay $count proyectos y la matriz admite 256 como maximo" >&2
+ exit 1
+ fi
+
+ echo "projects=$projects" >> "$GITHUB_OUTPUT"
+ echo "count=$count" >> "$GITHUB_OUTPUT"
+
+ echo "Proyectos detectados: $count" >> "$GITHUB_STEP_SUMMARY"
+ printf '%s' "$projects" | jq -r '.[]' | sed 's/^/- /' >> "$GITHUB_STEP_SUMMARY"
+
build:
+ name: Build - ${{ matrix.project }}
+ needs: discover
runs-on: ubuntu-latest
-
+
strategy:
- matrix:
- project:
- # Parte 2 - Web Projects
- - 'parte_2/tema_2.2_web/web_ejem1'
- - 'parte_2/tema_2.2_web/web_ejem2'
- - 'parte_2/tema_2.2_web/web_ejem3'
- - 'parte_2/tema_2.2_web/web_ejem4'
- - 'parte_2/tema_2.2_web/web_ejem5'
- - 'parte_2/tema_2.2_web/web_ejem6'
- - 'parte_2/tema_2.2_web/web_ejem7'
- - 'parte_2/tema_2.2_web/web_ejem8'
- - 'parte_2/tema_2.2_web/web_ejem8b'
- - 'parte_2/tema_2.2_web/web_ejer1'
- - 'parte_2/tema_2.2_web/web_ejer1b'
- - 'parte_2/tema_2.2_web/web_ejer2'
- - 'parte_2/tema_2.2_web/web_ejer3'
- - 'parte_2/tema_2.2_web/web_ejer3_devtools'
- - 'parte_2/tema_2.2_web/web_ejer4'
- - 'parte_2/tema_2.2_web/web_ejer5'
- - 'parte_2/tema_2.2_web/web_ejer6'
- - 'parte_2/tema_2.2_web/web_ejer7'
-
- # Parte 2 - REST Projects
- - 'parte_2/tema_2.3_rest/rest_ejem1'
- - 'parte_2/tema_2.3_rest/rest_ejem2'
- - 'parte_2/tema_2.3_rest/rest_ejem3'
- - 'parte_2/tema_2.3_rest/rest_ejem4'
- - 'parte_2/tema_2.3_rest/rest_ejem5'
- - 'parte_2/tema_2.3_rest/rest_ejem6'
- - 'parte_2/tema_2.3_rest/rest_ejem7'
- - 'parte_2/tema_2.3_rest/rest_ejem8'
- - 'parte_2/tema_2.3_rest/rest_ejem9'
- - 'parte_2/tema_2.3_rest/rest_ejem10'
- - 'parte_2/tema_2.3_rest/rest_ejem11'
- - 'parte_2/tema_2.3_rest/rest_ejer1'
-
- # Parte 2 - Database Projects
- - 'parte_2/tema_2.5_db/bd_ejem1'
- - 'parte_2/tema_2.5_db/bd_ejem2'
- - 'parte_2/tema_2.5_db/bd_ejem3'
- - 'parte_2/tema_2.5_db/bd_ejem4'
- - 'parte_2/tema_2.5_db/bd_ejem5'
- - 'parte_2/tema_2.5_db/bd_ejem6'
- - 'parte_2/tema_2.5_db/bd_ejem7'
- - 'parte_2/tema_2.5_db/bd_ejem8'
- - 'parte_2/tema_2.5_db/bd_ejem9'
- - 'parte_2/tema_2.5_db/bd_ejem10'
- - 'parte_2/tema_2.5_db/bd_ejem11'
- - 'parte_2/tema_2.5_db/bd_ejem12'
- - 'parte_2/tema_2.5_db/bd_ejem13'
- - 'parte_2/tema_2.5_db/bd_ejem14'
- - 'parte_2/tema_2.5_db/bd_ejem15'
- - 'parte_2/tema_2.5_db/bd_ejem16'
- - 'parte_2/tema_2.5_db/bd_ejem17'
- - 'parte_2/tema_2.5_db/bd_ejem18'
- - 'parte_2/tema_2.5_db/bd_ejem19'
- - 'parte_2/tema_2.5_db/bd_ejem20'
- - 'parte_2/tema_2.5_db/bd_ejem21'
- - 'parte_2/tema_2.5_db/bd_ejem22'
- - 'parte_2/tema_2.5_db/bd_ejer1'
- - 'parte_2/tema_2.5_db/bd_ejer2'
-
- # Parte 2 - Deployment Examples
- - 'parte_2/tema_2.6_despliegue/despliegue_ejem1'
- - 'parte_2/tema_2.6_despliegue/despliegue_ejem2'
-
- # Parte 3 - RabbitMQ Projects
- - 'parte_3/tema_3.2_colas/comunicacion-rabbitmq-ejem1-consumer'
- - 'parte_3/tema_3.2_colas/comunicacion-rabbitmq-ejem1-producer'
- - 'parte_3/tema_3.2_colas/comunicacion-rabbitmq-ejem2-consumer'
- - 'parte_3/tema_3.2_colas/comunicacion-rabbitmq-ejem2-producer'
- - 'parte_3/tema_3.2_colas/comunicacion-rabbitmq-ejem3-client'
- - 'parte_3/tema_3.2_colas/comunicacion-rabbitmq-ejem3-service'
-
- # Parte 3 - WebSocket Projects
- - 'parte_3/tema_3.2_websockets/comunicacion-ws-ejem1'
- - 'parte_3/tema_3.2_websockets/comunicacion-ws-ejem2'
-
- # Parte 4 - Testing Projects
- - 'parte_4/tema_4.2/aplicacion-java-enunciado'
- - 'parte_4/tema_4.2/ejemplo-1'
- - 'parte_4/tema_4.2/ejemplo-2'
- - 'parte_4/tema_4.2/ejer4/aplicacion-java-enunciado'
- - 'parte_4/tema_4.2/ejer5/aplicacion-java-enunciado'
- - 'parte_4/tema_4.2/ejer6'
- - 'parte_4/tema_4.2/ejer7'
- - 'parte_4/tema_4.2/ejer8'
-
- # Parte 4 - Docker Projects
- - 'parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem2-consumer'
- - 'parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem2-producer'
- - 'parte_4/tema_4.3/ejemplo-2'
- - 'parte_4/tema_4.3/ejemplo-3'
- - 'parte_4/tema_4.3/ejercicio-1-enunciado'
- - 'parte_4/tema_4.3/ejercicio-1'
-
- # Parte 5 - Performance Projects
- - 'parte_5/ejem0-jmeter'
- - 'parte_5/ejem1-mysql'
- - 'parte_5/ejem2-cache'
- - 'parte_5/ejem3-cache-distribuida'
- - 'parte_5/ejem3-cache-distribuida2'
- - 'parte_5/ejem4-haproxy'
- - 'parte_5/ejem4b-haproxy-ssl-passthrough'
-
fail-fast: false
-
- name: Build - ${{ matrix.project }}
-
+ matrix:
+ project: ${{ fromJson(needs.discover.outputs.projects) }}
+
steps:
- name: Checkout code
uses: actions/checkout@v4
-
+
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
-
+
- name: Build with Maven
- run: mvn clean package -DskipTests
- working-directory: ${{ matrix.project }}
\ No newline at end of file
+ run: mvn -B -ntp clean verify
+ working-directory: ${{ matrix.project }}
+
+ result:
+ name: All projects built
+ needs: [discover, build]
+ if: always()
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Check the matrix result
+ run: |
+ echo "Proyectos: ${{ needs.discover.outputs.count }}"
+ echo "Resultado de la matriz: ${{ needs.build.result }}"
+ test "${{ needs.build.result }}" = "success"
diff --git a/parte_2/tema_2.2_web/web_ejem1/pom.xml b/parte_2/tema_2.2_web/web_ejem1/pom.xml
index 48f5e96..d73e7de 100644
--- a/parte_2/tema_2.2_web/web_ejem1/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejem1/pom.xml
@@ -12,13 +12,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.8
+ 4.0.5
UTF-8
- 17
+ 21
@@ -30,6 +30,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejem1/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejem1/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejem1/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejem2/pom.xml b/parte_2/tema_2.2_web/web_ejem2/pom.xml
index b8a5dda..e078fcb 100644
--- a/parte_2/tema_2.2_web/web_ejem2/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejem2/pom.xml
@@ -12,13 +12,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.8
+ 4.0.5
UTF-8
- 17
+ 21
@@ -30,6 +30,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejem2/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejem2/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejem2/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejem3/pom.xml b/parte_2/tema_2.2_web/web_ejem3/pom.xml
index 0f78b5e..f8e3b7c 100644
--- a/parte_2/tema_2.2_web/web_ejem3/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejem3/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.8
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejem3/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejem3/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejem3/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejem4/pom.xml b/parte_2/tema_2.2_web/web_ejem4/pom.xml
index 027b22f..d36ebec 100644
--- a/parte_2/tema_2.2_web/web_ejem4/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejem4/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.8
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejem4/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejem4/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejem4/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejem5/pom.xml b/parte_2/tema_2.2_web/web_ejem5/pom.xml
index b4327a1..48b3e4c 100644
--- a/parte_2/tema_2.2_web/web_ejem5/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejem5/pom.xml
@@ -12,13 +12,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.8
+ 4.0.5
UTF-8
- 17
+ 21
@@ -30,6 +30,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejem5/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejem5/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejem5/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejem6/pom.xml b/parte_2/tema_2.2_web/web_ejem6/pom.xml
index dcd6b21..1ca63ae 100644
--- a/parte_2/tema_2.2_web/web_ejem6/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejem6/pom.xml
@@ -12,13 +12,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.8
+ 4.0.5
UTF-8
- 17
+ 21
@@ -30,6 +30,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejem6/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejem6/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejem6/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejem7/pom.xml b/parte_2/tema_2.2_web/web_ejem7/pom.xml
index 1077085..27e3721 100644
--- a/parte_2/tema_2.2_web/web_ejem7/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejem7/pom.xml
@@ -12,13 +12,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.8
+ 4.0.5
UTF-8
- 17
+ 21
@@ -30,6 +30,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejem7/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejem7/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejem7/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejem8/pom.xml b/parte_2/tema_2.2_web/web_ejem8/pom.xml
index 5853d58..123573b 100644
--- a/parte_2/tema_2.2_web/web_ejem8/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejem8/pom.xml
@@ -12,13 +12,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.8
+ 4.0.5
UTF-8
- 17
+ 21
@@ -30,6 +30,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejem8/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejem8/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejem8/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejem8b/pom.xml b/parte_2/tema_2.2_web/web_ejem8b/pom.xml
index 3e8d5a1..0a98970 100644
--- a/parte_2/tema_2.2_web/web_ejem8b/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejem8b/pom.xml
@@ -12,13 +12,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -30,6 +30,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejem8b/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejem8b/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejem8b/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejer1/pom.xml b/parte_2/tema_2.2_web/web_ejer1/pom.xml
index 9198f67..8c0de10 100644
--- a/parte_2/tema_2.2_web/web_ejer1/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejer1/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejer1/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejer1/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejer1/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejer1b/pom.xml b/parte_2/tema_2.2_web/web_ejer1b/pom.xml
index f75cb86..f4027db 100644
--- a/parte_2/tema_2.2_web/web_ejer1b/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejer1b/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejer1b/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejer1b/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejer1b/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejer2/pom.xml b/parte_2/tema_2.2_web/web_ejer2/pom.xml
index 2e938de..ef6c442 100644
--- a/parte_2/tema_2.2_web/web_ejer2/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejer2/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejer2/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejer2/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejer2/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejer3/pom.xml b/parte_2/tema_2.2_web/web_ejer3/pom.xml
index ce69487..9422a9b 100644
--- a/parte_2/tema_2.2_web/web_ejer3/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejer3/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejer3/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejer3/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejer3/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejer3_devtools/pom.xml b/parte_2/tema_2.2_web/web_ejer3_devtools/pom.xml
index 8b0c99d..9a9e68a 100644
--- a/parte_2/tema_2.2_web/web_ejer3_devtools/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejer3_devtools/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -33,6 +33,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejer3_devtools/src/test/java/es/codeurjc/web/SmokeTest.java b/parte_2/tema_2.2_web/web_ejer3_devtools/src/test/java/es/codeurjc/web/SmokeTest.java
new file mode 100644
index 0000000..4908cd9
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejer3_devtools/src/test/java/es/codeurjc/web/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.web;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejer4/pom.xml b/parte_2/tema_2.2_web/web_ejer4/pom.xml
index 018fdff..f334f63 100644
--- a/parte_2/tema_2.2_web/web_ejer4/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejer4/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -33,6 +33,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejer4/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.2_web/web_ejer4/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..5914215
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejer4/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.board;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejer5/pom.xml b/parte_2/tema_2.2_web/web_ejer5/pom.xml
index 701932f..33a3afd 100644
--- a/parte_2/tema_2.2_web/web_ejer5/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejer5/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -33,6 +33,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejer5/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.2_web/web_ejer5/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..5914215
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejer5/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.board;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejer6/pom.xml b/parte_2/tema_2.2_web/web_ejer6/pom.xml
index e53bee6..114f60f 100644
--- a/parte_2/tema_2.2_web/web_ejer6/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejer6/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -33,6 +33,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejer6/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.2_web/web_ejer6/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..5914215
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejer6/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.board;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.2_web/web_ejer7/pom.xml b/parte_2/tema_2.2_web/web_ejer7/pom.xml
index 9b8484d..19ceebb 100644
--- a/parte_2/tema_2.2_web/web_ejer7/pom.xml
+++ b/parte_2/tema_2.2_web/web_ejer7/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.8
+ 4.0.5
UTF-8
- 17
+ 21
@@ -33,6 +33,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.2_web/web_ejer7/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.2_web/web_ejer7/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..5914215
--- /dev/null
+++ b/parte_2/tema_2.2_web/web_ejer7/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.board;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.3_rest/rest_ejem1/pom.xml b/parte_2/tema_2.3_rest/rest_ejem1/pom.xml
index fffd993..f7a0c48 100644
--- a/parte_2/tema_2.3_rest/rest_ejem1/pom.xml
+++ b/parte_2/tema_2.3_rest/rest_ejem1/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.3_rest/rest_ejem1/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.3_rest/rest_ejem1/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..5914215
--- /dev/null
+++ b/parte_2/tema_2.3_rest/rest_ejem1/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.board;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.3_rest/rest_ejem10/pom.xml b/parte_2/tema_2.3_rest/rest_ejem10/pom.xml
index 676012d..2d93c1c 100644
--- a/parte_2/tema_2.3_rest/rest_ejem10/pom.xml
+++ b/parte_2/tema_2.3_rest/rest_ejem10/pom.xml
@@ -12,13 +12,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -35,6 +35,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.3_rest/rest_ejem10/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.3_rest/rest_ejem10/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..5914215
--- /dev/null
+++ b/parte_2/tema_2.3_rest/rest_ejem10/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.board;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.3_rest/rest_ejem11/pom.xml b/parte_2/tema_2.3_rest/rest_ejem11/pom.xml
index dbd0172..08550a1 100644
--- a/parte_2/tema_2.3_rest/rest_ejem11/pom.xml
+++ b/parte_2/tema_2.3_rest/rest_ejem11/pom.xml
@@ -12,13 +12,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -35,6 +35,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.3_rest/rest_ejem11/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.3_rest/rest_ejem11/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..5914215
--- /dev/null
+++ b/parte_2/tema_2.3_rest/rest_ejem11/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.board;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.3_rest/rest_ejem2/pom.xml b/parte_2/tema_2.3_rest/rest_ejem2/pom.xml
index 79836c0..34d8f02 100644
--- a/parte_2/tema_2.3_rest/rest_ejem2/pom.xml
+++ b/parte_2/tema_2.3_rest/rest_ejem2/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.3_rest/rest_ejem2/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.3_rest/rest_ejem2/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..5914215
--- /dev/null
+++ b/parte_2/tema_2.3_rest/rest_ejem2/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.board;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.3_rest/rest_ejem3/pom.xml b/parte_2/tema_2.3_rest/rest_ejem3/pom.xml
index f11b93f..ed73579 100644
--- a/parte_2/tema_2.3_rest/rest_ejem3/pom.xml
+++ b/parte_2/tema_2.3_rest/rest_ejem3/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.3_rest/rest_ejem3/src/test/java/es/codeurjc/libreria/SmokeTest.java b/parte_2/tema_2.3_rest/rest_ejem3/src/test/java/es/codeurjc/libreria/SmokeTest.java
new file mode 100644
index 0000000..c1d305c
--- /dev/null
+++ b/parte_2/tema_2.3_rest/rest_ejem3/src/test/java/es/codeurjc/libreria/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.libreria;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.3_rest/rest_ejem4/pom.xml b/parte_2/tema_2.3_rest/rest_ejem4/pom.xml
index 63737e2..64a93cf 100644
--- a/parte_2/tema_2.3_rest/rest_ejem4/pom.xml
+++ b/parte_2/tema_2.3_rest/rest_ejem4/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.3_rest/rest_ejem4/src/test/java/es/codeurjc/libreria/SmokeTest.java b/parte_2/tema_2.3_rest/rest_ejem4/src/test/java/es/codeurjc/libreria/SmokeTest.java
new file mode 100644
index 0000000..c1d305c
--- /dev/null
+++ b/parte_2/tema_2.3_rest/rest_ejem4/src/test/java/es/codeurjc/libreria/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.libreria;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.3_rest/rest_ejem5/pom.xml b/parte_2/tema_2.3_rest/rest_ejem5/pom.xml
index b1e22ee..4834d39 100644
--- a/parte_2/tema_2.3_rest/rest_ejem5/pom.xml
+++ b/parte_2/tema_2.3_rest/rest_ejem5/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.3_rest/rest_ejem5/src/test/java/es/codeurjc/libreria/SmokeTest.java b/parte_2/tema_2.3_rest/rest_ejem5/src/test/java/es/codeurjc/libreria/SmokeTest.java
new file mode 100644
index 0000000..c1d305c
--- /dev/null
+++ b/parte_2/tema_2.3_rest/rest_ejem5/src/test/java/es/codeurjc/libreria/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.libreria;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.3_rest/rest_ejem6/pom.xml b/parte_2/tema_2.3_rest/rest_ejem6/pom.xml
index b530e4d..ebc22b0 100644
--- a/parte_2/tema_2.3_rest/rest_ejem6/pom.xml
+++ b/parte_2/tema_2.3_rest/rest_ejem6/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.3_rest/rest_ejem6/src/test/java/es/codeurjc/libreria/SmokeTest.java b/parte_2/tema_2.3_rest/rest_ejem6/src/test/java/es/codeurjc/libreria/SmokeTest.java
new file mode 100644
index 0000000..c1d305c
--- /dev/null
+++ b/parte_2/tema_2.3_rest/rest_ejem6/src/test/java/es/codeurjc/libreria/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.libreria;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.3_rest/rest_ejem7/pom.xml b/parte_2/tema_2.3_rest/rest_ejem7/pom.xml
index e497724..ecffeb8 100644
--- a/parte_2/tema_2.3_rest/rest_ejem7/pom.xml
+++ b/parte_2/tema_2.3_rest/rest_ejem7/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -29,6 +29,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.3_rest/rest_ejem7/src/test/java/es/codeurjc/books/SmokeTest.java b/parte_2/tema_2.3_rest/rest_ejem7/src/test/java/es/codeurjc/books/SmokeTest.java
new file mode 100644
index 0000000..8e0023e
--- /dev/null
+++ b/parte_2/tema_2.3_rest/rest_ejem7/src/test/java/es/codeurjc/books/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.books;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.3_rest/rest_ejem8/pom.xml b/parte_2/tema_2.3_rest/rest_ejem8/pom.xml
index 7e97173..f3f72a1 100644
--- a/parte_2/tema_2.3_rest/rest_ejem8/pom.xml
+++ b/parte_2/tema_2.3_rest/rest_ejem8/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -25,10 +25,19 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-json
+
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.3_rest/rest_ejem8/src/main/java/es/codeurjc/books/BooksController.java b/parte_2/tema_2.3_rest/rest_ejem8/src/main/java/es/codeurjc/books/BooksController.java
index 7390f08..b59f949 100644
--- a/parte_2/tema_2.3_rest/rest_ejem8/src/main/java/es/codeurjc/books/BooksController.java
+++ b/parte_2/tema_2.3_rest/rest_ejem8/src/main/java/es/codeurjc/books/BooksController.java
@@ -8,9 +8,9 @@
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.node.ArrayNode;
+import tools.jackson.databind.node.ObjectNode;
@RestController
public class BooksController {
diff --git a/parte_2/tema_2.3_rest/rest_ejem8/src/test/java/es/codeurjc/books/SmokeTest.java b/parte_2/tema_2.3_rest/rest_ejem8/src/test/java/es/codeurjc/books/SmokeTest.java
new file mode 100644
index 0000000..8e0023e
--- /dev/null
+++ b/parte_2/tema_2.3_rest/rest_ejem8/src/test/java/es/codeurjc/books/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.books;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.3_rest/rest_ejem9/pom.xml b/parte_2/tema_2.3_rest/rest_ejem9/pom.xml
index b8cf8e9..45f66ce 100644
--- a/parte_2/tema_2.3_rest/rest_ejem9/pom.xml
+++ b/parte_2/tema_2.3_rest/rest_ejem9/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -37,13 +37,18 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
org.springframework.cloud
spring-cloud-dependencies
- 2023.0.0
+ 2025.1.4
pom
import
diff --git a/parte_2/tema_2.3_rest/rest_ejem9/src/test/java/es/codeurjc/books/SmokeTest.java b/parte_2/tema_2.3_rest/rest_ejem9/src/test/java/es/codeurjc/books/SmokeTest.java
new file mode 100644
index 0000000..8e0023e
--- /dev/null
+++ b/parte_2/tema_2.3_rest/rest_ejem9/src/test/java/es/codeurjc/books/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.books;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.3_rest/rest_ejer1/pom.xml b/parte_2/tema_2.3_rest/rest_ejer1/pom.xml
index 873a03a..613fa95 100644
--- a/parte_2/tema_2.3_rest/rest_ejer1/pom.xml
+++ b/parte_2/tema_2.3_rest/rest_ejer1/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -25,6 +25,11 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.3_rest/rest_ejer1/src/test/java/es/codeurjc/items/SmokeTest.java b/parte_2/tema_2.3_rest/rest_ejer1/src/test/java/es/codeurjc/items/SmokeTest.java
new file mode 100644
index 0000000..2430125
--- /dev/null
+++ b/parte_2/tema_2.3_rest/rest_ejer1/src/test/java/es/codeurjc/items/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.codeurjc.items;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem1/pom.xml b/parte_2/tema_2.5_db/bd_ejem1/pom.xml
index a5e03ed..a70794f 100644
--- a/parte_2/tema_2.5_db/bd_ejem1/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem1/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -28,6 +28,11 @@
com.h2database
h2
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
\ No newline at end of file
diff --git a/parte_2/tema_2.5_db/bd_ejem1/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem1/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem1/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem10/pom.xml b/parte_2/tema_2.5_db/bd_ejem10/pom.xml
index ed211f3..000c176 100644
--- a/parte_2/tema_2.5_db/bd_ejem10/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem10/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
\ No newline at end of file
diff --git a/parte_2/tema_2.5_db/bd_ejem10/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem10/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem10/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem11/pom.xml b/parte_2/tema_2.5_db/bd_ejem11/pom.xml
index 566b08a..b5a2e5e 100644
--- a/parte_2/tema_2.5_db/bd_ejem11/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem11/pom.xml
@@ -10,12 +10,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejem11/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem11/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..811d836
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem11/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.board;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem12/pom.xml b/parte_2/tema_2.5_db/bd_ejem12/pom.xml
index ad5749f..950922e 100644
--- a/parte_2/tema_2.5_db/bd_ejem12/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem12/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejem12/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem12/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem12/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem13/pom.xml b/parte_2/tema_2.5_db/bd_ejem13/pom.xml
index 65cb149..f1ce402 100644
--- a/parte_2/tema_2.5_db/bd_ejem13/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem13/pom.xml
@@ -10,13 +10,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejem13/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem13/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem13/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem14/pom.xml b/parte_2/tema_2.5_db/bd_ejem14/pom.xml
index 9a039d9..bb07c20 100644
--- a/parte_2/tema_2.5_db/bd_ejem14/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem14/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
\ No newline at end of file
diff --git a/parte_2/tema_2.5_db/bd_ejem14/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem14/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem14/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem15/pom.xml b/parte_2/tema_2.5_db/bd_ejem15/pom.xml
index 4ea2f6a..b96100f 100644
--- a/parte_2/tema_2.5_db/bd_ejem15/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem15/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
\ No newline at end of file
diff --git a/parte_2/tema_2.5_db/bd_ejem15/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem15/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..811d836
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem15/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.board;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem16/mvnw b/parte_2/tema_2.5_db/bd_ejem16/mvnw
old mode 100644
new mode 100755
index a16b543..1fdbaf2
--- a/parte_2/tema_2.5_db/bd_ejem16/mvnw
+++ b/parte_2/tema_2.5_db/bd_ejem16/mvnw
@@ -8,7 +8,7 @@
# "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
+# 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
@@ -19,7 +19,7 @@
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
-# Maven Start Up Batch script
+# Apache Maven Wrapper startup batch script, version 3.3.0
#
# Required ENV vars:
# ------------------
@@ -27,284 +27,306 @@
#
# Optional ENV vars
# -----------------
-# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
-if [ -z "$MAVEN_SKIP_RC" ] ; then
+if [ -z "$MAVEN_SKIP_RC" ]; then
- if [ -f /etc/mavenrc ] ; then
+ if [ -f /usr/local/etc/mavenrc ]; then
+ . /usr/local/etc/mavenrc
+ fi
+
+ if [ -f /etc/mavenrc ]; then
. /etc/mavenrc
fi
- if [ -f "$HOME/.mavenrc" ] ; then
+ if [ -f "$HOME/.mavenrc" ]; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
-cygwin=false;
-darwin=false;
+cygwin=false
+darwin=false
mingw=false
-case "`uname`" in
- CYGWIN*) cygwin=true ;;
- MINGW*) mingw=true;;
- Darwin*) darwin=true
- # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
- # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
- if [ -z "$JAVA_HOME" ]; then
- if [ -x "/usr/libexec/java_home" ]; then
- export JAVA_HOME="`/usr/libexec/java_home`"
- else
- export JAVA_HOME="/Library/Java/Home"
- fi
+case "$(uname)" in
+CYGWIN*) cygwin=true ;;
+MINGW*) mingw=true ;;
+Darwin*)
+ darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ JAVA_HOME="$(/usr/libexec/java_home)"
+ export JAVA_HOME
+ else
+ JAVA_HOME="/Library/Java/Home"
+ export JAVA_HOME
fi
- ;;
+ fi
+ ;;
esac
-if [ -z "$JAVA_HOME" ] ; then
- if [ -r /etc/gentoo-release ] ; then
- JAVA_HOME=`java-config --jre-home`
+if [ -z "$JAVA_HOME" ]; then
+ if [ -r /etc/gentoo-release ]; then
+ JAVA_HOME=$(java-config --jre-home)
fi
fi
-if [ -z "$M2_HOME" ] ; then
- ## resolve links - $0 may be a link to maven's home
- 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
- done
-
- saveddir=`pwd`
-
- M2_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- M2_HOME=`cd "$M2_HOME" && pwd`
-
- cd "$saveddir"
- # echo Using m2 at $M2_HOME
-fi
-
# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --unix "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+if $cygwin; then
+ [ -n "$JAVA_HOME" ] \
+ && JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
+ [ -n "$CLASSPATH" ] \
+ && CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
-if $mingw ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME="`(cd "$M2_HOME"; pwd)`"
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+if $mingw; then
+ [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] \
+ && JAVA_HOME="$(
+ cd "$JAVA_HOME" || (
+ echo "cannot cd into $JAVA_HOME." >&2
+ exit 1
+ )
+ pwd
+ )"
fi
if [ -z "$JAVA_HOME" ]; then
- javaExecutable="`which javac`"
- if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ javaExecutable="$(which javac)"
+ if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
- if $darwin ; then
- javaHome="`dirname \"$javaExecutable\"`"
- javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ readLink=$(which readlink)
+ if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
+ if $darwin; then
+ javaHome="$(dirname "$javaExecutable")"
+ javaExecutable="$(cd "$javaHome" && pwd -P)/javac"
else
- javaExecutable="`readlink -f \"$javaExecutable\"`"
+ javaExecutable="$(readlink -f "$javaExecutable")"
fi
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ javaHome="$(dirname "$javaExecutable")"
+ javaHome=$(expr "$javaHome" : '\(.*\)/bin')
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+if [ -z "$JAVACMD" ]; then
+ 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"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
- JAVACMD="`which java`"
+ JAVACMD="$(
+ \unset -f command 2>/dev/null
+ \command -v java
+ )"
fi
fi
-if [ ! -x "$JAVACMD" ] ; then
+if [ ! -x "$JAVACMD" ]; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
-if [ -z "$JAVA_HOME" ] ; then
- echo "Warning: JAVA_HOME environment variable is not set."
+if [ -z "$JAVA_HOME" ]; then
+ echo "Warning: JAVA_HOME environment variable is not set." >&2
fi
-CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
-
- if [ -z "$1" ]
- then
- echo "Path not specified to find_maven_basedir"
+ if [ -z "$1" ]; then
+ echo "Path not specified to find_maven_basedir" >&2
return 1
fi
basedir="$1"
wdir="$1"
- while [ "$wdir" != '/' ] ; do
- if [ -d "$wdir"/.mvn ] ; then
+ while [ "$wdir" != '/' ]; do
+ if [ -d "$wdir"/.mvn ]; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
- wdir=`cd "$wdir/.."; pwd`
+ wdir=$(
+ cd "$wdir/.." || exit 1
+ pwd
+ )
fi
# end of workaround
done
- echo "${basedir}"
+ printf '%s' "$(
+ cd "$basedir" || exit 1
+ pwd
+ )"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
- echo "$(tr -s '\n' ' ' < "$1")"
+ # Remove \r in case we run on Windows within Git Bash
+ # and check out the repository with auto CRLF management
+ # enabled. Otherwise, we may read lines that are delimited with
+ # \r\n and produce $'-Xarg\r' rather than -Xarg due to word
+ # splitting rules.
+ tr -s '\r\n' ' ' <"$1"
+ fi
+}
+
+log() {
+ if [ "$MVNW_VERBOSE" = true ]; then
+ printf '%s\n' "$1"
fi
}
-BASE_DIR=`find_maven_basedir "$(pwd)"`
+BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
if [ -z "$BASE_DIR" ]; then
- exit 1;
+ exit 1
fi
+MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+export MAVEN_PROJECTBASEDIR
+log "$MAVEN_PROJECTBASEDIR"
+
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
-if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
- if [ "$MVNW_VERBOSE" = true ]; then
- echo "Found .mvn/wrapper/maven-wrapper.jar"
- fi
+wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
+if [ -r "$wrapperJarPath" ]; then
+ log "Found $wrapperJarPath"
else
- if [ "$MVNW_VERBOSE" = true ]; then
- echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
- fi
- if [ -n "$MVNW_REPOURL" ]; then
- jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ log "Couldn't find $wrapperJarPath, downloading it ..."
+
+ if [ -n "$MVNW_REPOURL" ]; then
+ wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.3.0/maven-wrapper-3.3.0.jar"
+ else
+ wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.0/maven-wrapper-3.3.0.jar"
+ fi
+ while IFS="=" read -r key value; do
+ # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
+ safeValue=$(echo "$value" | tr -d '\r')
+ case "$key" in wrapperUrl)
+ wrapperUrl="$safeValue"
+ break
+ ;;
+ esac
+ done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+ log "Downloading from: $wrapperUrl"
+
+ if $cygwin; then
+ wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
+ fi
+
+ if command -v wget >/dev/null; then
+ log "Found wget ... using wget"
+ [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
- jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
- while IFS="=" read key value; do
- case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
- esac
- done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
- if [ "$MVNW_VERBOSE" = true ]; then
- echo "Downloading from: $jarUrl"
+ elif command -v curl >/dev/null; then
+ log "Found curl ... using curl"
+ [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
+ else
+ curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
fi
- wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+ else
+ log "Falling back to using Java to download"
+ javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
+ # For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
- wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
+ javaSource=$(cygpath --path --windows "$javaSource")
+ javaClass=$(cygpath --path --windows "$javaClass")
fi
-
- if command -v wget > /dev/null; then
- if [ "$MVNW_VERBOSE" = true ]; then
- echo "Found wget ... using wget"
- fi
- if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
- wget "$jarUrl" -O "$wrapperJarPath"
- else
- wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
- fi
- elif command -v curl > /dev/null; then
- if [ "$MVNW_VERBOSE" = true ]; then
- echo "Found curl ... using curl"
- fi
- if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
- curl -o "$wrapperJarPath" "$jarUrl" -f
- else
- curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
- fi
-
- else
- if [ "$MVNW_VERBOSE" = true ]; then
- echo "Falling back to using Java to download"
- fi
- javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
- # For Cygwin, switch paths to Windows format before running javac
- if $cygwin; then
- javaClass=`cygpath --path --windows "$javaClass"`
- fi
- if [ -e "$javaClass" ]; then
- if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
- if [ "$MVNW_VERBOSE" = true ]; then
- echo " - Compiling MavenWrapperDownloader.java ..."
- fi
- # Compiling the Java class
- ("$JAVA_HOME/bin/javac" "$javaClass")
- fi
- if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
- # Running the downloader
- if [ "$MVNW_VERBOSE" = true ]; then
- echo " - Running MavenWrapperDownloader.java ..."
- fi
- ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
- fi
- fi
+ if [ -e "$javaSource" ]; then
+ if [ ! -e "$javaClass" ]; then
+ log " - Compiling MavenWrapperDownloader.java ..."
+ ("$JAVA_HOME/bin/javac" "$javaSource")
+ fi
+ if [ -e "$javaClass" ]; then
+ log " - Running MavenWrapperDownloader.java ..."
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
+ fi
fi
+ fi
fi
##########################################################################################
# End of extension
##########################################################################################
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
-if [ "$MVNW_VERBOSE" = true ]; then
- echo $MAVEN_PROJECTBASEDIR
+# If specified, validate the SHA-256 sum of the Maven wrapper jar file
+wrapperSha256Sum=""
+while IFS="=" read -r key value; do
+ case "$key" in wrapperSha256Sum)
+ wrapperSha256Sum=$value
+ break
+ ;;
+ esac
+done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+if [ -n "$wrapperSha256Sum" ]; then
+ wrapperSha256Result=false
+ if command -v sha256sum >/dev/null; then
+ if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c >/dev/null 2>&1; then
+ wrapperSha256Result=true
+ fi
+ elif command -v shasum >/dev/null; then
+ if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c >/dev/null 2>&1; then
+ wrapperSha256Result=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 'wrapperSha256Sum' from your maven-wrapper.properties." >&2
+ exit 1
+ fi
+ if [ $wrapperSha256Result = false ]; then
+ echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
+ echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
+ echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
+ exit 1
+ fi
fi
+
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
- [ -n "$MAVEN_PROJECTBASEDIR" ] &&
- MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+ [ -n "$JAVA_HOME" ] \
+ && JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
+ [ -n "$CLASSPATH" ] \
+ && CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
+ [ -n "$MAVEN_PROJECTBASEDIR" ] \
+ && MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
-MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+# shellcheck disable=SC2086 # safe args
exec "$JAVACMD" \
$MAVEN_OPTS \
+ $MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
- "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/parte_2/tema_2.5_db/bd_ejem16/mvnw.cmd b/parte_2/tema_2.5_db/bd_ejem16/mvnw.cmd
index c8d4337..b694e6c 100644
--- a/parte_2/tema_2.5_db/bd_ejem16/mvnw.cmd
+++ b/parte_2/tema_2.5_db/bd_ejem16/mvnw.cmd
@@ -1,182 +1,206 @@
-@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 https://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 Maven Start Up Batch script
-@REM
-@REM Required ENV vars:
-@REM JAVA_HOME - location of a JDK home dir
-@REM
-@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
-@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
-@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
-@REM e.g. to debug Maven itself, use
-@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-@REM ----------------------------------------------------------------------------
-
-@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
-@echo off
-@REM set title of command window
-title %0
-@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
-@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
-
-@REM set %HOME% to equivalent of $HOME
-if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
-
-@REM Execute a user defined script before this one
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
-@REM check for pre script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
-if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
-:skipRcPre
-
-@setlocal
-
-set ERROR_CODE=0
-
-@REM To isolate internal variables from possible post scripts, we use another setlocal
-@setlocal
-
-@REM ==== START VALIDATION ====
-if not "%JAVA_HOME%" == "" goto OkJHome
-
-echo.
-echo Error: JAVA_HOME not found in your environment. >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-:OkJHome
-if exist "%JAVA_HOME%\bin\java.exe" goto init
-
-echo.
-echo Error: JAVA_HOME is set to an invalid directory. >&2
-echo JAVA_HOME = "%JAVA_HOME%" >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-@REM ==== END VALIDATION ====
-
-:init
-
-@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
-@REM Fallback to current working directory if not found.
-
-set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
-IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
-
-set EXEC_DIR=%CD%
-set WDIR=%EXEC_DIR%
-:findBaseDir
-IF EXIST "%WDIR%"\.mvn goto baseDirFound
-cd ..
-IF "%WDIR%"=="%CD%" goto baseDirNotFound
-set WDIR=%CD%
-goto findBaseDir
-
-:baseDirFound
-set MAVEN_PROJECTBASEDIR=%WDIR%
-cd "%EXEC_DIR%"
-goto endDetectBaseDir
-
-:baseDirNotFound
-set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
-cd "%EXEC_DIR%"
-
-:endDetectBaseDir
-
-IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
-
-@setlocal EnableExtensions EnableDelayedExpansion
-for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
-@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
-
-:endReadAdditionalConfig
-
-SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
-set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
-set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
-
-FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
- IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
-)
-
-@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
-@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
-if exist %WRAPPER_JAR% (
- if "%MVNW_VERBOSE%" == "true" (
- echo Found %WRAPPER_JAR%
- )
-) else (
- if not "%MVNW_REPOURL%" == "" (
- SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
- )
- if "%MVNW_VERBOSE%" == "true" (
- echo Couldn't find %WRAPPER_JAR%, downloading it ...
- echo Downloading from: %DOWNLOAD_URL%
- )
-
- powershell -Command "&{"^
- "$webclient = new-object System.Net.WebClient;"^
- "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
- "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
- "}"^
- "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
- "}"
- if "%MVNW_VERBOSE%" == "true" (
- echo Finished downloading %WRAPPER_JAR%
- )
-)
-@REM End of extension
-
-@REM Provide a "standardized" way to retrieve the CLI args that will
-@REM work with both Windows and non-Windows executions.
-set MAVEN_CMD_LINE_ARGS=%*
-
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
-if ERRORLEVEL 1 goto error
-goto end
-
-:error
-set ERROR_CODE=1
-
-:end
-@endlocal & set ERROR_CODE=%ERROR_CODE%
-
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
-@REM check for post script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
-if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
-:skipRcPost
-
-@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
-if "%MAVEN_BATCH_PAUSE%" == "on" pause
-
-if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
-
-exit /B %ERROR_CODE%
+@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.0
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo. >&2
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo. >&2
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo. >&2
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo. >&2
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.0/maven-wrapper-3.3.0.jar"
+
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Found %WRAPPER_JAR%
+ )
+) else (
+ if not "%MVNW_REPOURL%" == "" (
+ SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.3.0/maven-wrapper-3.3.0.jar"
+ )
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %WRAPPER_URL%
+ )
+
+ powershell -Command "&{"^
+ "$webclient = new-object System.Net.WebClient;"^
+ "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+ "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+ "}"^
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
+ "}"
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Finished downloading %WRAPPER_JAR%
+ )
+)
+@REM End of extension
+
+@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
+SET WRAPPER_SHA_256_SUM=""
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
+)
+IF NOT %WRAPPER_SHA_256_SUM%=="" (
+ powershell -Command "&{"^
+ "Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash;"^
+ "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
+ "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
+ " Write-Error 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
+ " Write-Error 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
+ " Write-Error 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
+ " exit 1;"^
+ "}"^
+ "}"
+ if ERRORLEVEL 1 goto error
+)
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% ^
+ %JVM_CONFIG_MAVEN_PROPS% ^
+ %MAVEN_OPTS% ^
+ %MAVEN_DEBUG_OPTS% ^
+ -classpath %WRAPPER_JAR% ^
+ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
+ %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
+
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
+
+cmd /C exit /B %ERROR_CODE%
diff --git a/parte_2/tema_2.5_db/bd_ejem16/pom.xml b/parte_2/tema_2.5_db/bd_ejem16/pom.xml
index 06e3252..3382005 100644
--- a/parte_2/tema_2.5_db/bd_ejem16/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem16/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejem16/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem16/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem16/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem17/pom.xml b/parte_2/tema_2.5_db/bd_ejem17/pom.xml
index 71d2128..9325c1b 100644
--- a/parte_2/tema_2.5_db/bd_ejem17/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem17/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -51,6 +51,11 @@
jakarta
provided
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejem17/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem17/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..811d836
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem17/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.board;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem18/pom.xml b/parte_2/tema_2.5_db/bd_ejem18/pom.xml
index 3c201cc..254f98d 100644
--- a/parte_2/tema_2.5_db/bd_ejem18/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem18/pom.xml
@@ -10,13 +10,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejem18/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem18/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem18/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem19/pom.xml b/parte_2/tema_2.5_db/bd_ejem19/pom.xml
index 98a226b..c3aa152 100644
--- a/parte_2/tema_2.5_db/bd_ejem19/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem19/pom.xml
@@ -10,13 +10,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -24,6 +24,10 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-json
+
org.springframework.boot
spring-boot-starter-data-jpa
@@ -36,6 +40,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejem19/src/main/java/es/codeurjc/db/PageImplJacksonSerializer.java b/parte_2/tema_2.5_db/bd_ejem19/src/main/java/es/codeurjc/db/PageImplJacksonSerializer.java
index 081aea8..e35382d 100644
--- a/parte_2/tema_2.5_db/bd_ejem19/src/main/java/es/codeurjc/db/PageImplJacksonSerializer.java
+++ b/parte_2/tema_2.5_db/bd_ejem19/src/main/java/es/codeurjc/db/PageImplJacksonSerializer.java
@@ -1,42 +1,42 @@
package es.codeurjc.db;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import org.springframework.boot.jackson.JsonComponent;
+import tools.jackson.core.JacksonException;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.databind.SerializationContext;
+import tools.jackson.databind.ValueSerializer;
+import org.springframework.boot.jackson.JacksonComponent;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Sort;
-import java.io.IOException;
-@JsonComponent
-public class PageImplJacksonSerializer extends JsonSerializer> {
+@JacksonComponent
+public class PageImplJacksonSerializer extends ValueSerializer> {
@SuppressWarnings("rawtypes")
@Override
- public void serialize(PageImpl page, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
- throws IOException {
+ public void serialize(PageImpl page, JsonGenerator jsonGenerator, SerializationContext serializationContext)
+ throws JacksonException {
jsonGenerator.writeStartObject();
- jsonGenerator.writeObjectField("content", page.getContent());
- jsonGenerator.writeBooleanField("first", page.isFirst());
- jsonGenerator.writeBooleanField("last", page.isLast());
- jsonGenerator.writeNumberField("totalPages", page.getTotalPages());
- jsonGenerator.writeNumberField("totalElements", page.getTotalElements());
- jsonGenerator.writeNumberField("numberOfElements", page.getNumberOfElements());
+ jsonGenerator.writePOJOProperty("content", page.getContent());
+ jsonGenerator.writeBooleanProperty("first", page.isFirst());
+ jsonGenerator.writeBooleanProperty("last", page.isLast());
+ jsonGenerator.writeNumberProperty("totalPages", page.getTotalPages());
+ jsonGenerator.writeNumberProperty("totalElements", page.getTotalElements());
+ jsonGenerator.writeNumberProperty("numberOfElements", page.getNumberOfElements());
- jsonGenerator.writeNumberField("size", page.getSize());
- jsonGenerator.writeNumberField("number", page.getNumber());
+ jsonGenerator.writeNumberProperty("size", page.getSize());
+ jsonGenerator.writeNumberProperty("number", page.getNumber());
Sort sort = page.getSort();
- jsonGenerator.writeArrayFieldStart("sort");
+ jsonGenerator.writeArrayPropertyStart("sort");
for (Sort.Order order : sort) {
jsonGenerator.writeStartObject();
- jsonGenerator.writeStringField("property", order.getProperty());
- jsonGenerator.writeStringField("direction", order.getDirection().name());
- jsonGenerator.writeBooleanField("ignoreCase", order.isIgnoreCase());
- jsonGenerator.writeStringField("nullHandling", order.getNullHandling().name());
+ jsonGenerator.writeStringProperty("property", order.getProperty());
+ jsonGenerator.writeStringProperty("direction", order.getDirection().name());
+ jsonGenerator.writeBooleanProperty("ignoreCase", order.isIgnoreCase());
+ jsonGenerator.writeStringProperty("nullHandling", order.getNullHandling().name());
jsonGenerator.writeEndObject();
}
diff --git a/parte_2/tema_2.5_db/bd_ejem19/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem19/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem19/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem2/pom.xml b/parte_2/tema_2.5_db/bd_ejem2/pom.xml
index c7d3195..9d48228 100644
--- a/parte_2/tema_2.5_db/bd_ejem2/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem2/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
\ No newline at end of file
diff --git a/parte_2/tema_2.5_db/bd_ejem2/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem2/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..811d836
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem2/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.board;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem20/pom.xml b/parte_2/tema_2.5_db/bd_ejem20/pom.xml
index 43ef84e..d73817d 100644
--- a/parte_2/tema_2.5_db/bd_ejem20/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem20/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -38,6 +38,26 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-mysql
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejem20/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem20/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..69c9a0b
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem20/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,41 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.mysql.MySQLContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest(properties = "spring.jpa.hibernate.ddl-auto=create-drop")
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static MySQLContainer mysql = new MySQLContainer("mysql:8.0");
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem21/pom.xml b/parte_2/tema_2.5_db/bd_ejem21/pom.xml
index 2d00c8f..ffd6d54 100644
--- a/parte_2/tema_2.5_db/bd_ejem21/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem21/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -37,6 +37,26 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-mysql
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejem21/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem21/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..c5c5d8a
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem21/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,41 @@
+package es.codeurjc.board;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.mysql.MySQLContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest(properties = "spring.jpa.hibernate.ddl-auto=create-drop")
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static MySQLContainer mysql = new MySQLContainer("mysql:8.0");
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem22/pom.xml b/parte_2/tema_2.5_db/bd_ejem22/pom.xml
index fdebb5e..1595e0e 100644
--- a/parte_2/tema_2.5_db/bd_ejem22/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem22/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.8
+ 4.0.5
UTF-8
- 17
+ 21
@@ -37,6 +37,26 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-mysql
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejem22/src/main/java/es/codeurjc/board/controller/PostController.java b/parte_2/tema_2.5_db/bd_ejem22/src/main/java/es/codeurjc/board/controller/PostController.java
index 997efd5..4cc464c 100644
--- a/parte_2/tema_2.5_db/bd_ejem22/src/main/java/es/codeurjc/board/controller/PostController.java
+++ b/parte_2/tema_2.5_db/bd_ejem22/src/main/java/es/codeurjc/board/controller/PostController.java
@@ -7,7 +7,7 @@
import java.sql.SQLException;
import java.util.List;
-import org.hibernate.engine.jdbc.BlobProxy;
+import org.hibernate.engine.jdbc.proxy.BlobProxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
diff --git a/parte_2/tema_2.5_db/bd_ejem22/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem22/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..c5c5d8a
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem22/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,41 @@
+package es.codeurjc.board;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.mysql.MySQLContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest(properties = "spring.jpa.hibernate.ddl-auto=create-drop")
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static MySQLContainer mysql = new MySQLContainer("mysql:8.0");
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem3/pom.xml b/parte_2/tema_2.5_db/bd_ejem3/pom.xml
index d40ed04..204fa9a 100644
--- a/parte_2/tema_2.5_db/bd_ejem3/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem3/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -37,6 +37,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
\ No newline at end of file
diff --git a/parte_2/tema_2.5_db/bd_ejem3/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem3/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..811d836
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem3/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.board;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem4/pom.xml b/parte_2/tema_2.5_db/bd_ejem4/pom.xml
index ad93b74..290bdfe 100644
--- a/parte_2/tema_2.5_db/bd_ejem4/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem4/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -37,6 +37,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
\ No newline at end of file
diff --git a/parte_2/tema_2.5_db/bd_ejem4/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem4/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..811d836
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem4/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.board;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem5/pom.xml b/parte_2/tema_2.5_db/bd_ejem5/pom.xml
index 8d44eca..c170d8b 100644
--- a/parte_2/tema_2.5_db/bd_ejem5/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem5/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
\ No newline at end of file
diff --git a/parte_2/tema_2.5_db/bd_ejem5/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem5/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem5/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem6/pom.xml b/parte_2/tema_2.5_db/bd_ejem6/pom.xml
index 44b3ec6..c6e16ec 100644
--- a/parte_2/tema_2.5_db/bd_ejem6/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem6/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejem6/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem6/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem6/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem7/pom.xml b/parte_2/tema_2.5_db/bd_ejem7/pom.xml
index 29cba84..c582ca6 100644
--- a/parte_2/tema_2.5_db/bd_ejem7/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem7/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
\ No newline at end of file
diff --git a/parte_2/tema_2.5_db/bd_ejem7/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem7/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem7/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem8/pom.xml b/parte_2/tema_2.5_db/bd_ejem8/pom.xml
index 91e2320..499b583 100644
--- a/parte_2/tema_2.5_db/bd_ejem8/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem8/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
\ No newline at end of file
diff --git a/parte_2/tema_2.5_db/bd_ejem8/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem8/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem8/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejem9/pom.xml b/parte_2/tema_2.5_db/bd_ejem9/pom.xml
index bc83c09..dc5396f 100644
--- a/parte_2/tema_2.5_db/bd_ejem9/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejem9/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
\ No newline at end of file
diff --git a/parte_2/tema_2.5_db/bd_ejem9/src/test/java/es/codeurjc/db/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejem9/src/test/java/es/codeurjc/db/SmokeTest.java
new file mode 100644
index 0000000..b52e2aa
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejem9/src/test/java/es/codeurjc/db/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.db;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejer1/pom.xml b/parte_2/tema_2.5_db/bd_ejer1/pom.xml
index 8b2a758..6005218 100644
--- a/parte_2/tema_2.5_db/bd_ejer1/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejer1/pom.xml
@@ -9,12 +9,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -30,5 +30,10 @@
com.h2database
h2
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejer1/src/test/java/es/codeurjc/items/SmokeTest.java b/parte_2/tema_2.5_db/bd_ejer1/src/test/java/es/codeurjc/items/SmokeTest.java
new file mode 100644
index 0000000..7a7834e
--- /dev/null
+++ b/parte_2/tema_2.5_db/bd_ejer1/src/test/java/es/codeurjc/items/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.items;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_2/tema_2.5_db/bd_ejer2/pom.xml b/parte_2/tema_2.5_db/bd_ejer2/pom.xml
index 19ae76e..5fdca59 100644
--- a/parte_2/tema_2.5_db/bd_ejer2/pom.xml
+++ b/parte_2/tema_2.5_db/bd_ejer2/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -41,6 +41,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_2/tema_2.5_db/bd_ejer2/src/main/java/es/codeurjc/board/controller/PostController.java b/parte_2/tema_2.5_db/bd_ejer2/src/main/java/es/codeurjc/board/controller/PostController.java
index 312f157..bf35adc 100644
--- a/parte_2/tema_2.5_db/bd_ejer2/src/main/java/es/codeurjc/board/controller/PostController.java
+++ b/parte_2/tema_2.5_db/bd_ejer2/src/main/java/es/codeurjc/board/controller/PostController.java
@@ -66,7 +66,7 @@ public String newPost(Model model, Post post, MultipartFile image) throws IOExce
imageService.saveImage(POSTS_FOLDER, post.getId(), image);
- userSession.setUser(post.getUser());
+ userSession.setUser(post.getAuthor());
userSession.incNumPosts();
model.addAttribute("numPosts", userSession.getNumPosts());
diff --git a/parte_2/tema_2.5_db/bd_ejer2/src/main/java/es/codeurjc/board/model/Post.java b/parte_2/tema_2.5_db/bd_ejer2/src/main/java/es/codeurjc/board/model/Post.java
index 44ed78c..10885e3 100644
--- a/parte_2/tema_2.5_db/bd_ejer2/src/main/java/es/codeurjc/board/model/Post.java
+++ b/parte_2/tema_2.5_db/bd_ejer2/src/main/java/es/codeurjc/board/model/Post.java
@@ -12,16 +12,16 @@ public class Post {
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
- private String user;
+ private String author;
private String title;
private String text;
public Post() {
}
- public Post(String user, String title, String text) {
+ public Post(String author, String title, String text) {
super();
- this.user = user;
+ this.author = author;
this.title = title;
this.text = text;
}
@@ -34,12 +34,12 @@ public void setId(long id) {
this.id = id;
}
- public String getUser() {
- return user;
+ public String getAuthor() {
+ return author;
}
- public void setUser(String user) {
- this.user = user;
+ public void setAuthor(String author) {
+ this.author = author;
}
public String getTitle() {
@@ -60,7 +60,7 @@ public void setText(String text) {
@Override
public String toString() {
- return "Post [id=" + id + ", user=" + user + ", title=" + title + ", text=" + text + "]";
+ return "Post [id=" + id + ", author=" + author + ", title=" + title + ", text=" + text + "]";
}
}
diff --git a/parte_2/tema_2.5_db/bd_ejer2/src/main/resources/templates/index.html b/parte_2/tema_2.5_db/bd_ejer2/src/main/resources/templates/index.html
index a26969a..60c0535 100644
--- a/parte_2/tema_2.5_db/bd_ejer2/src/main/resources/templates/index.html
+++ b/parte_2/tema_2.5_db/bd_ejer2/src/main/resources/templates/index.html
@@ -7,7 +7,7 @@ Welcome!
Posts
{{#posts}}
- {{user}} {{title}}
+ {{author}} {{title}}
{{/posts}}
diff --git a/parte_2/tema_2.5_db/bd_ejer2/src/main/resources/templates/new_post.html b/parte_2/tema_2.5_db/bd_ejer2/src/main/resources/templates/new_post.html
index 4a90b75..af81bc4 100644
--- a/parte_2/tema_2.5_db/bd_ejer2/src/main/resources/templates/new_post.html
+++ b/parte_2/tema_2.5_db/bd_ejer2/src/main/resources/templates/new_post.html
@@ -5,7 +5,7 @@
diff --git a/parte_4/tema_4.2/aplicacion-java-enunciado/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java b/parte_4/tema_4.2/aplicacion-java-enunciado/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
new file mode 100644
index 0000000..d61d094
--- /dev/null
+++ b/parte_4/tema_4.2/aplicacion-java-enunciado/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.urjc.code.daw.tablonanuncios;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_4/tema_4.2/ejemplo-1/pom.xml b/parte_4/tema_4.2/ejemplo-1/pom.xml
index 4ac74dc..52ddf59 100644
--- a/parte_4/tema_4.2/ejemplo-1/pom.xml
+++ b/parte_4/tema_4.2/ejemplo-1/pom.xml
@@ -11,7 +11,7 @@
org.springframework.boot
spring-boot-starter-parent
- 3.0.4
+ 4.0.5
@@ -34,6 +34,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_4/tema_4.2/ejemplo-1/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java b/parte_4/tema_4.2/ejemplo-1/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
new file mode 100644
index 0000000..d61d094
--- /dev/null
+++ b/parte_4/tema_4.2/ejemplo-1/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.urjc.code.daw.tablonanuncios;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_4/tema_4.2/ejemplo-2/pom.xml b/parte_4/tema_4.2/ejemplo-2/pom.xml
index b60fa70..73b559e 100644
--- a/parte_4/tema_4.2/ejemplo-2/pom.xml
+++ b/parte_4/tema_4.2/ejemplo-2/pom.xml
@@ -10,17 +10,31 @@
UTF-8
- 17
+ 21
- 17
- 17
+ 21
+ 21
+ 6.0.3
+
+
+ org.junit.jupiter
+ junit-jupiter
+ ${junit-jupiter.version}
+ test
+
+
+
app
+
+ maven-surefire-plugin
+ 3.5.5
+
maven-assembly-plugin
3.3.0
diff --git a/parte_4/tema_4.2/ejemplo-2/src/test/java/es/urjc/code/example/SmokeTest.java b/parte_4/tema_4.2/ejemplo-2/src/test/java/es/urjc/code/example/SmokeTest.java
new file mode 100644
index 0000000..44fc47e
--- /dev/null
+++ b/parte_4/tema_4.2/ejemplo-2/src/test/java/es/urjc/code/example/SmokeTest.java
@@ -0,0 +1,34 @@
+package es.urjc.code.example;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Comprobacion minima: la aplicacion arranca y procesa los argumentos.
+ */
+class SmokeTest {
+
+ @Test
+ void laAplicacionArrancaYLeeLosArgumentos() throws Exception {
+ PrintStream salidaOriginal = System.out;
+ ByteArrayOutputStream capturada = new ByteArrayOutputStream();
+
+ try {
+ System.setOut(new PrintStream(capturada, true, StandardCharsets.UTF_8));
+ Application.main(new String[] { "uno", "dos" });
+ } finally {
+ System.setOut(salidaOriginal);
+ }
+
+ String salida = capturada.toString(StandardCharsets.UTF_8);
+
+ assertTrue(salida.contains("Command line application"));
+ assertTrue(salida.contains("uno"));
+ assertTrue(salida.contains("dos"));
+ }
+}
diff --git a/parte_4/tema_4.2/ejer4/aplicacion-java-enunciado/pom.xml b/parte_4/tema_4.2/ejer4/aplicacion-java-enunciado/pom.xml
index c69e672..52ddf59 100644
--- a/parte_4/tema_4.2/ejer4/aplicacion-java-enunciado/pom.xml
+++ b/parte_4/tema_4.2/ejer4/aplicacion-java-enunciado/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.0.4
+ 4.0.5
UTF-8
- 17
+ 21
es.urjc.code.daw.tablonanuncios.Application
@@ -34,6 +34,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_4/tema_4.2/ejer4/aplicacion-java-enunciado/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java b/parte_4/tema_4.2/ejer4/aplicacion-java-enunciado/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
new file mode 100644
index 0000000..d61d094
--- /dev/null
+++ b/parte_4/tema_4.2/ejer4/aplicacion-java-enunciado/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.urjc.code.daw.tablonanuncios;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_4/tema_4.2/ejer5/aplicacion-java-enunciado/pom.xml b/parte_4/tema_4.2/ejer5/aplicacion-java-enunciado/pom.xml
index c69e672..52ddf59 100644
--- a/parte_4/tema_4.2/ejer5/aplicacion-java-enunciado/pom.xml
+++ b/parte_4/tema_4.2/ejer5/aplicacion-java-enunciado/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.0.4
+ 4.0.5
UTF-8
- 17
+ 21
es.urjc.code.daw.tablonanuncios.Application
@@ -34,6 +34,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_4/tema_4.2/ejer5/aplicacion-java-enunciado/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java b/parte_4/tema_4.2/ejer5/aplicacion-java-enunciado/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
new file mode 100644
index 0000000..d61d094
--- /dev/null
+++ b/parte_4/tema_4.2/ejer5/aplicacion-java-enunciado/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.urjc.code.daw.tablonanuncios;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_4/tema_4.2/ejer6/pom.xml b/parte_4/tema_4.2/ejer6/pom.xml
index ad12357..4111ac3 100644
--- a/parte_4/tema_4.2/ejer6/pom.xml
+++ b/parte_4/tema_4.2/ejer6/pom.xml
@@ -10,13 +10,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.0.4
+ 4.0.5
UTF-8
- 17
+ 21
es.urjc.code.daw.tablonanuncios.Application
@@ -33,6 +33,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_4/tema_4.2/ejer6/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java b/parte_4/tema_4.2/ejer6/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
new file mode 100644
index 0000000..d61d094
--- /dev/null
+++ b/parte_4/tema_4.2/ejer6/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.urjc.code.daw.tablonanuncios;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_4/tema_4.2/ejer7/pom.xml b/parte_4/tema_4.2/ejer7/pom.xml
index 6349932..effbe76 100644
--- a/parte_4/tema_4.2/ejer7/pom.xml
+++ b/parte_4/tema_4.2/ejer7/pom.xml
@@ -10,13 +10,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.0.4
+ 4.0.5
UTF-8
- 17
+ 21
es.urjc.code.daw.tablonanuncios.Application
@@ -33,6 +33,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_4/tema_4.2/ejer7/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java b/parte_4/tema_4.2/ejer7/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
new file mode 100644
index 0000000..d61d094
--- /dev/null
+++ b/parte_4/tema_4.2/ejer7/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.urjc.code.daw.tablonanuncios;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_4/tema_4.2/ejer8/pom.xml b/parte_4/tema_4.2/ejer8/pom.xml
index 4a15499..a1f0eeb 100644
--- a/parte_4/tema_4.2/ejer8/pom.xml
+++ b/parte_4/tema_4.2/ejer8/pom.xml
@@ -10,13 +10,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.0.4
+ 4.0.5
UTF-8
- 17
+ 21
es.urjc.code.daw.tablonanuncios.Application
@@ -33,6 +33,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_4/tema_4.2/ejer8/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java b/parte_4/tema_4.2/ejer8/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
new file mode 100644
index 0000000..d61d094
--- /dev/null
+++ b/parte_4/tema_4.2/ejer8/src/test/java/es/urjc/code/daw/tablonanuncios/SmokeTest.java
@@ -0,0 +1,15 @@
+package es.urjc.code.daw.tablonanuncios;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto de Spring arranca.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Test
+ void elContextoArranca() {
+ }
+}
diff --git a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/pom.xml b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/pom.xml
index f404c5b..144fa2e 100644
--- a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/pom.xml
+++ b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/pom.xml
@@ -10,13 +10,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.4.3
+ 4.0.5
UTF-8
- 17
+ 21
@@ -36,6 +36,26 @@
org.springframework.boot
spring-boot-starter-websocket
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-rabbitmq
+ test
+
diff --git a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/main/java/es/codeurjc/mastercloudapps/amqp/Application.java b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/main/java/es/codeurjc/mastercloudapps/amqp/Application.java
index 7facb9e..86a2f86 100644
--- a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/main/java/es/codeurjc/mastercloudapps/amqp/Application.java
+++ b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/main/java/es/codeurjc/mastercloudapps/amqp/Application.java
@@ -1,7 +1,7 @@
package es.codeurjc.mastercloudapps.amqp;
import org.springframework.amqp.core.Queue;
-import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
+import org.springframework.amqp.support.converter.JacksonJsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -21,6 +21,6 @@ public Queue myQueue() {
@Bean
public MessageConverter messageConverter() {
- return new Jackson2JsonMessageConverter();
+ return new JacksonJsonMessageConverter();
}
}
diff --git a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/main/java/es/codeurjc/mastercloudapps/amqp/ExampleData.java b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/main/java/es/codeurjc/mastercloudapps/amqp/ExampleData.java
index f05eca8..b6c7bb0 100644
--- a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/main/java/es/codeurjc/mastercloudapps/amqp/ExampleData.java
+++ b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/main/java/es/codeurjc/mastercloudapps/amqp/ExampleData.java
@@ -1,6 +1,6 @@
package es.codeurjc.mastercloudapps.amqp;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import tools.jackson.databind.ObjectMapper;
public class ExampleData {
private String data;
diff --git a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/main/java/es/codeurjc/mastercloudapps/amqp/WebSocketHandler.java b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/main/java/es/codeurjc/mastercloudapps/amqp/WebSocketHandler.java
index b48d980..9680613 100644
--- a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/main/java/es/codeurjc/mastercloudapps/amqp/WebSocketHandler.java
+++ b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/main/java/es/codeurjc/mastercloudapps/amqp/WebSocketHandler.java
@@ -10,8 +10,8 @@
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.AbstractWebSocketHandler;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import tools.jackson.core.JacksonException;
+import tools.jackson.databind.ObjectMapper;
@Component
public class WebSocketHandler extends AbstractWebSocketHandler {
@@ -50,7 +50,7 @@ public void sendMessage(ExampleData data) {
try {
json = new ObjectMapper().writeValueAsString(data);
websocketSession.sendMessage(new TextMessage(json));
- } catch (JsonProcessingException e) {
+ } catch (JacksonException e) {
logger.error("Cannot convert to json: " + data.getData());
throw new RuntimeException();
} catch (IOException e) {
diff --git a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/test/java/es/codeurjc/mastercloudapps/amqp/SmokeTest.java b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/test/java/es/codeurjc/mastercloudapps/amqp/SmokeTest.java
new file mode 100644
index 0000000..7ef6e05
--- /dev/null
+++ b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-consumer/src/test/java/es/codeurjc/mastercloudapps/amqp/SmokeTest.java
@@ -0,0 +1,39 @@
+package es.codeurjc.mastercloudapps.amqp;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.amqp.rabbit.connection.Connection;
+import org.springframework.amqp.rabbit.connection.ConnectionFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.rabbitmq.RabbitMQContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y el broker responde.
+ */
+@SpringBootTest
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static RabbitMQContainer rabbit = new RabbitMQContainer("rabbitmq:3.13-management");
+
+ @Autowired
+ private ConnectionFactory connectionFactory;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laColaResponde() {
+ try (Connection conexion = connectionFactory.createConnection()) {
+ assertTrue(conexion.isOpen());
+ }
+ }
+}
diff --git a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/pom.xml b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/pom.xml
index 409635d..976424f 100644
--- a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/pom.xml
+++ b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/pom.xml
@@ -6,7 +6,7 @@
org.springframework.boot
spring-boot-starter-parent
- 3.4.3
+ 4.0.5
@@ -16,7 +16,7 @@
UTF-8
- 17
+ 21
@@ -28,6 +28,26 @@
org.springframework.boot
spring-boot-starter-json
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-rabbitmq
+ test
+
diff --git a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/src/main/java/es/codeurjc/mastercloudapps/amqp/Application.java b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/src/main/java/es/codeurjc/mastercloudapps/amqp/Application.java
index 24a7d00..64a91e4 100644
--- a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/src/main/java/es/codeurjc/mastercloudapps/amqp/Application.java
+++ b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/src/main/java/es/codeurjc/mastercloudapps/amqp/Application.java
@@ -1,7 +1,7 @@
package es.codeurjc.mastercloudapps.amqp;
import org.springframework.amqp.core.Queue;
-import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
+import org.springframework.amqp.support.converter.JacksonJsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -23,6 +23,6 @@ public Queue myQueue() {
@Bean
public MessageConverter messageConverter() {
- return new Jackson2JsonMessageConverter();
+ return new JacksonJsonMessageConverter();
}
}
diff --git a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/src/main/java/es/codeurjc/mastercloudapps/amqp/ExampleData.java b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/src/main/java/es/codeurjc/mastercloudapps/amqp/ExampleData.java
index f05eca8..b6c7bb0 100644
--- a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/src/main/java/es/codeurjc/mastercloudapps/amqp/ExampleData.java
+++ b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/src/main/java/es/codeurjc/mastercloudapps/amqp/ExampleData.java
@@ -1,6 +1,6 @@
package es.codeurjc.mastercloudapps.amqp;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import tools.jackson.databind.ObjectMapper;
public class ExampleData {
private String data;
diff --git a/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/src/test/java/es/codeurjc/mastercloudapps/amqp/SmokeTest.java b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/src/test/java/es/codeurjc/mastercloudapps/amqp/SmokeTest.java
new file mode 100644
index 0000000..7ef6e05
--- /dev/null
+++ b/parte_4/tema_4.3/ejemplo-1/comunicacion-rabbitmq-ejem3-producer/src/test/java/es/codeurjc/mastercloudapps/amqp/SmokeTest.java
@@ -0,0 +1,39 @@
+package es.codeurjc.mastercloudapps.amqp;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.amqp.rabbit.connection.Connection;
+import org.springframework.amqp.rabbit.connection.ConnectionFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.rabbitmq.RabbitMQContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y el broker responde.
+ */
+@SpringBootTest
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static RabbitMQContainer rabbit = new RabbitMQContainer("rabbitmq:3.13-management");
+
+ @Autowired
+ private ConnectionFactory connectionFactory;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laColaResponde() {
+ try (Connection conexion = connectionFactory.createConnection()) {
+ assertTrue(conexion.isOpen());
+ }
+ }
+}
diff --git a/parte_4/tema_4.3/ejemplo-2/pom.xml b/parte_4/tema_4.3/ejemplo-2/pom.xml
index 739edd3..3c1834b 100644
--- a/parte_4/tema_4.3/ejemplo-2/pom.xml
+++ b/parte_4/tema_4.3/ejemplo-2/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.0.4
+ 4.0.5
UTF-8
- 17
+ 21
es.codeurjc.test.tablonanuncios.WebApp
@@ -42,6 +42,26 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-mysql
+ test
+
diff --git a/parte_4/tema_4.3/ejemplo-2/src/test/java/es/codeurjc/test/tablonanuncios/SmokeTest.java b/parte_4/tema_4.3/ejemplo-2/src/test/java/es/codeurjc/test/tablonanuncios/SmokeTest.java
new file mode 100644
index 0000000..d5c404f
--- /dev/null
+++ b/parte_4/tema_4.3/ejemplo-2/src/test/java/es/codeurjc/test/tablonanuncios/SmokeTest.java
@@ -0,0 +1,41 @@
+package es.codeurjc.test.tablonanuncios;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.mysql.MySQLContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest(classes = WebApp.class, properties = "spring.jpa.hibernate.ddl-auto=create-drop")
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static MySQLContainer mysql = new MySQLContainer("mysql:8.0");
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_4/tema_4.3/ejemplo-3/pom.xml b/parte_4/tema_4.3/ejemplo-3/pom.xml
index 739edd3..3c1834b 100644
--- a/parte_4/tema_4.3/ejemplo-3/pom.xml
+++ b/parte_4/tema_4.3/ejemplo-3/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.0.4
+ 4.0.5
UTF-8
- 17
+ 21
es.codeurjc.test.tablonanuncios.WebApp
@@ -42,6 +42,26 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-mysql
+ test
+
diff --git a/parte_4/tema_4.3/ejemplo-3/src/test/java/es/codeurjc/test/tablonanuncios/SmokeTest.java b/parte_4/tema_4.3/ejemplo-3/src/test/java/es/codeurjc/test/tablonanuncios/SmokeTest.java
new file mode 100644
index 0000000..d5c404f
--- /dev/null
+++ b/parte_4/tema_4.3/ejemplo-3/src/test/java/es/codeurjc/test/tablonanuncios/SmokeTest.java
@@ -0,0 +1,41 @@
+package es.codeurjc.test.tablonanuncios;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.mysql.MySQLContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest(classes = WebApp.class, properties = "spring.jpa.hibernate.ddl-auto=create-drop")
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static MySQLContainer mysql = new MySQLContainer("mysql:8.0");
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_4/tema_4.3/ejercicio-1-enunciado/pom.xml b/parte_4/tema_4.3/ejercicio-1-enunciado/pom.xml
index 739edd3..3c1834b 100644
--- a/parte_4/tema_4.3/ejercicio-1-enunciado/pom.xml
+++ b/parte_4/tema_4.3/ejercicio-1-enunciado/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.0.4
+ 4.0.5
UTF-8
- 17
+ 21
es.codeurjc.test.tablonanuncios.WebApp
@@ -42,6 +42,26 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-mysql
+ test
+
diff --git a/parte_4/tema_4.3/ejercicio-1-enunciado/src/test/java/es/codeurjc/test/tablonanuncios/SmokeTest.java b/parte_4/tema_4.3/ejercicio-1-enunciado/src/test/java/es/codeurjc/test/tablonanuncios/SmokeTest.java
new file mode 100644
index 0000000..ebd56e7
--- /dev/null
+++ b/parte_4/tema_4.3/ejercicio-1-enunciado/src/test/java/es/codeurjc/test/tablonanuncios/SmokeTest.java
@@ -0,0 +1,41 @@
+package es.codeurjc.test.tablonanuncios;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.mysql.MySQLContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest(properties = "spring.jpa.hibernate.ddl-auto=create-drop")
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static MySQLContainer mysql = new MySQLContainer("mysql:8.0");
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_4/tema_4.3/ejercicio-1/pom.xml b/parte_4/tema_4.3/ejercicio-1/pom.xml
index 739edd3..3c1834b 100644
--- a/parte_4/tema_4.3/ejercicio-1/pom.xml
+++ b/parte_4/tema_4.3/ejercicio-1/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 3.0.4
+ 4.0.5
UTF-8
- 17
+ 21
es.codeurjc.test.tablonanuncios.WebApp
@@ -42,6 +42,26 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-mysql
+ test
+
diff --git a/parte_4/tema_4.3/ejercicio-1/src/test/java/es/codeurjc/test/tablonanuncios/SmokeTest.java b/parte_4/tema_4.3/ejercicio-1/src/test/java/es/codeurjc/test/tablonanuncios/SmokeTest.java
new file mode 100644
index 0000000..ebd56e7
--- /dev/null
+++ b/parte_4/tema_4.3/ejercicio-1/src/test/java/es/codeurjc/test/tablonanuncios/SmokeTest.java
@@ -0,0 +1,41 @@
+package es.codeurjc.test.tablonanuncios;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.mysql.MySQLContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest(properties = "spring.jpa.hibernate.ddl-auto=create-drop")
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static MySQLContainer mysql = new MySQLContainer("mysql:8.0");
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_5/ejem0-jmeter/mvnw b/parte_5/ejem0-jmeter/mvnw
index bd8896b..1fdbaf2 100755
--- a/parte_5/ejem0-jmeter/mvnw
+++ b/parte_5/ejem0-jmeter/mvnw
@@ -19,277 +19,314 @@
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
-# Apache Maven Wrapper startup batch script, version 3.3.4
+# Apache Maven Wrapper startup batch script, version 3.3.0
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
#
# 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
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
-set -euf
-[ "${MVNW_VERBOSE-}" != debug ] || set -x
+if [ -z "$MAVEN_SKIP_RC" ]; then
+
+ if [ -f /usr/local/etc/mavenrc ]; then
+ . /usr/local/etc/mavenrc
+ fi
+
+ if [ -f /etc/mavenrc ]; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ]; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
-# OS specific support.
-native_path() { printf %s\\n "$1"; }
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false
+darwin=false
+mingw=false
case "$(uname)" in
-CYGWIN* | MINGW*)
- [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
- native_path() { cygpath --path --windows "$1"; }
+CYGWIN*) cygwin=true ;;
+MINGW*) mingw=true ;;
+Darwin*)
+ darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ JAVA_HOME="$(/usr/libexec/java_home)"
+ export JAVA_HOME
+ else
+ JAVA_HOME="/Library/Java/Home"
+ export JAVA_HOME
+ fi
+ fi
;;
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 [ -z "$JAVA_HOME" ]; then
+ if [ -r /etc/gentoo-release ]; then
+ JAVA_HOME=$(java-config --jre-home)
+ fi
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin; then
+ [ -n "$JAVA_HOME" ] \
+ && JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
+ [ -n "$CLASSPATH" ] \
+ && CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw; then
+ [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] \
+ && JAVA_HOME="$(
+ cd "$JAVA_HOME" || (
+ echo "cannot cd into $JAVA_HOME." >&2
+ exit 1
+ )
+ pwd
+ )"
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="$(which javac)"
+ if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=$(which readlink)
+ if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
+ if $darwin; then
+ javaHome="$(dirname "$javaExecutable")"
+ javaExecutable="$(cd "$javaHome" && pwd -P)/javac"
+ else
+ javaExecutable="$(readlink -f "$javaExecutable")"
+ fi
+ javaHome="$(dirname "$javaExecutable")"
+ javaHome=$(expr "$javaHome" : '\(.*\)/bin')
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ]; then
+ 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
+ \unset -f command 2>/dev/null
+ \command -v java
+ )"
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-}"; }
+fi
-die() {
- printf %s\\n "$1" >&2
+if [ ! -x "$JAVACMD" ]; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&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:]'
-}
+fi
-scriptDir="$(dirname "$0")"
-scriptName="$(basename "$0")"
+if [ -z "$JAVA_HOME" ]; then
+ echo "Warning: JAVA_HOME environment variable is not set." >&2
+fi
-# 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 <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
-[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+ if [ -z "$1" ]; then
+ echo "Path not specified to find_maven_basedir" >&2
+ return 1
+ fi
-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${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
-esac
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ]; do
+ if [ -d "$wdir"/.mvn ]; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=$(
+ cd "$wdir/.." || exit 1
+ pwd
+ )
+ fi
+ # end of workaround
+ done
+ printf '%s' "$(
+ cd "$basedir" || exit 1
+ pwd
+ )"
+}
-# 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")"
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ # Remove \r in case we run on Windows within Git Bash
+ # and check out the repository with auto CRLF management
+ # enabled. Otherwise, we may read lines that are delimited with
+ # \r\n and produce $'-Xarg\r' rather than -Xarg due to word
+ # splitting rules.
+ tr -s '\r\n' ' ' <"$1"
+ fi
+}
-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"
+log() {
+ if [ "$MVNW_VERBOSE" = true ]; then
+ printf '%s\n' "$1"
+ fi
}
-if [ -d "$MAVEN_HOME" ]; then
- verbose "found existing MAVEN_HOME at $MAVEN_HOME"
- exec_maven "$@"
+BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
+if [ -z "$BASE_DIR" ]; then
+ exit 1
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
+MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+export MAVEN_PROJECTBASEDIR
+log "$MAVEN_PROJECTBASEDIR"
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
+if [ -r "$wrapperJarPath" ]; then
+ log "Found $wrapperJarPath"
else
- die "cannot create temp dir"
-fi
+ log "Couldn't find $wrapperJarPath, downloading it ..."
-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 [ -n "$MVNW_REPOURL" ]; then
+ wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.3.0/maven-wrapper-3.3.0.jar"
+ else
+ wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.0/maven-wrapper-3.3.0.jar"
+ fi
+ while IFS="=" read -r key value; do
+ # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
+ safeValue=$(echo "$value" | tr -d '\r')
+ case "$key" in wrapperUrl)
+ wrapperUrl="$safeValue"
+ break
+ ;;
+ esac
+ done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+ log "Downloading from: $wrapperUrl"
+
+ if $cygwin; then
+ wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
+ fi
-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")"
+ if command -v wget >/dev/null; then
+ log "Found wget ... using wget"
+ [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+ else
+ wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+ fi
+ elif command -v curl >/dev/null; then
+ log "Found curl ... using curl"
+ [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
+ else
+ curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
+ fi
+ else
+ log "Falling back to using Java to download"
+ javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
+ # For Cygwin, switch paths to Windows format before running javac
+ if $cygwin; then
+ javaSource=$(cygpath --path --windows "$javaSource")
+ javaClass=$(cygpath --path --windows "$javaClass")
+ fi
+ if [ -e "$javaSource" ]; then
+ if [ ! -e "$javaClass" ]; then
+ log " - Compiling MavenWrapperDownloader.java ..."
+ ("$JAVA_HOME/bin/javac" "$javaSource")
+ fi
+ if [ -e "$javaClass" ]; then
+ log " - Running MavenWrapperDownloader.java ..."
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
+ fi
+ fi
+ fi
fi
+##########################################################################################
+# End of extension
+##########################################################################################
-# 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
+# If specified, validate the SHA-256 sum of the Maven wrapper jar file
+wrapperSha256Sum=""
+while IFS="=" read -r key value; do
+ case "$key" in wrapperSha256Sum)
+ wrapperSha256Sum=$value
+ break
+ ;;
+ esac
+done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+if [ -n "$wrapperSha256Sum" ]; then
+ wrapperSha256Result=false
+ if command -v sha256sum >/dev/null; then
+ if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c >/dev/null 2>&1; then
+ wrapperSha256Result=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
+ if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c >/dev/null 2>&1; then
+ wrapperSha256Result=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
+ echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' 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
+ if [ $wrapperSha256Result = false ]; then
+ echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
+ echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
+ echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum 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
-
-# Find the actual extracted directory name (handles snapshots where filename != directory name)
-actualDistributionDir=""
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-# First try the expected directory name (for regular distributions)
-if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
- if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
- actualDistributionDir="$distributionUrlNameMain"
- fi
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$JAVA_HOME" ] \
+ && JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
+ [ -n "$CLASSPATH" ] \
+ && CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
+ [ -n "$MAVEN_PROJECTBASEDIR" ] \
+ && MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
fi
-# If not found, search for any directory with the Maven executable (for snapshots)
-if [ -z "$actualDistributionDir" ]; then
- # enable globbing to iterate over items
- set +f
- for dir in "$TMP_DOWNLOAD_DIR"/*; do
- if [ -d "$dir" ]; then
- if [ -f "$dir/bin/$MVN_CMD" ]; then
- actualDistributionDir="$(basename "$dir")"
- break
- fi
- fi
- done
- set -f
-fi
-
-if [ -z "$actualDistributionDir" ]; then
- verbose "Contents of $TMP_DOWNLOAD_DIR:"
- verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
- die "Could not find Maven distribution directory in extracted archive"
-fi
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
+export MAVEN_CMD_LINE_ARGS
-verbose "Found extracted Maven distribution directory: $actualDistributionDir"
-printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
-mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-clean || :
-exec_maven "$@"
+# shellcheck disable=SC2086 # safe args
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ $MAVEN_DEBUG_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/parte_5/ejem0-jmeter/mvnw.cmd b/parte_5/ejem0-jmeter/mvnw.cmd
index 92450f9..ad14baf 100644
--- a/parte_5/ejem0-jmeter/mvnw.cmd
+++ b/parte_5/ejem0-jmeter/mvnw.cmd
@@ -1,4 +1,3 @@
-<# : batch portion
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@@ -19,171 +18,189 @@
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
-@REM Apache Maven Wrapper startup batch script, version 3.3.4
+@REM Apache Maven Wrapper startup batch script, version 3.3.0
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
@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 MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@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)
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo. >&2
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo. >&2
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo. >&2
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo. >&2
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.0/maven-wrapper-3.3.0.jar"
+
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Found %WRAPPER_JAR%
+ )
+) else (
+ if not "%MVNW_REPOURL%" == "" (
+ SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.3.0/maven-wrapper-3.3.0.jar"
+ )
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %WRAPPER_URL%
+ )
+
+ powershell -Command "&{"^
+ "$webclient = new-object System.Net.WebClient;"^
+ "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+ "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+ "}"^
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
+ "}"
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Finished downloading %WRAPPER_JAR%
+ )
+)
+@REM End of extension
+
+@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
+SET WRAPPER_SHA_256_SUM=""
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%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 -eq $False) { "/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_M2_PATH = "$HOME/.m2"
-if ($env:MAVEN_USER_HOME) {
- $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
-}
-
-if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
- New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
-}
-
-$MAVEN_WRAPPER_DISTS = $null
-if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
- $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
-} else {
- $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
-}
-
-$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
-$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::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
-
-# Find the actual extracted directory name (handles snapshots where filename != directory name)
-$actualDistributionDir = ""
-
-# First try the expected directory name (for regular distributions)
-$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
-$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
-if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
- $actualDistributionDir = $distributionUrlNameMain
-}
-
-# If not found, search for any directory with the Maven executable (for snapshots)
-if (!$actualDistributionDir) {
- Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
- $testPath = Join-Path $_.FullName "bin/$MVN_CMD"
- if (Test-Path -Path $testPath -PathType Leaf) {
- $actualDistributionDir = $_.Name
- }
- }
-}
-
-if (!$actualDistributionDir) {
- Write-Error "Could not find Maven distribution directory in extracted archive"
-}
-
-Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
-Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -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"
+IF NOT %WRAPPER_SHA_256_SUM%=="" (
+ powershell -Command "&{"^
+ "Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash;"^
+ "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
+ "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
+ " Write-Error 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
+ " Write-Error 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
+ " Write-Error 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
+ " exit 1;"^
+ "}"^
+ "}"
+ if ERRORLEVEL 1 goto error
+)
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% ^
+ %JVM_CONFIG_MAVEN_PROPS% ^
+ %MAVEN_OPTS% ^
+ %MAVEN_DEBUG_OPTS% ^
+ -classpath %WRAPPER_JAR% ^
+ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
+ %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
+
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
+
+cmd /C exit /B %ERROR_CODE%
diff --git a/parte_5/ejem0-jmeter/pom.xml b/parte_5/ejem0-jmeter/pom.xml
index fa20aa9..3bbff11 100644
--- a/parte_5/ejem0-jmeter/pom.xml
+++ b/parte_5/ejem0-jmeter/pom.xml
@@ -5,7 +5,7 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.12
+ 4.0.5
es.urjc.code
@@ -58,6 +58,21 @@
spring-boot-starter-test
test
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-mysql
+ test
+
diff --git a/parte_5/ejem0-jmeter/src/test/java/es/urjc/code/ejem0employee/Ejem0EmployeeApplicationTests.java b/parte_5/ejem0-jmeter/src/test/java/es/urjc/code/ejem0employee/Ejem0EmployeeApplicationTests.java
deleted file mode 100644
index df6aa35..0000000
--- a/parte_5/ejem0-jmeter/src/test/java/es/urjc/code/ejem0employee/Ejem0EmployeeApplicationTests.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package es.urjc.code.ejem0employee;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
-@SpringBootTest
-class Ejem0EmployeeApplicationTests {
-
- @Test
- void contextLoads() {
- }
-
-}
diff --git a/parte_5/ejem0-jmeter/src/test/java/es/urjc/code/ejem0employee/SmokeTest.java b/parte_5/ejem0-jmeter/src/test/java/es/urjc/code/ejem0employee/SmokeTest.java
new file mode 100644
index 0000000..a471d1e
--- /dev/null
+++ b/parte_5/ejem0-jmeter/src/test/java/es/urjc/code/ejem0employee/SmokeTest.java
@@ -0,0 +1,41 @@
+package es.urjc.code.ejem0employee;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.mysql.MySQLContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest(properties = "spring.jpa.hibernate.ddl-auto=create-drop")
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static MySQLContainer mysql = new MySQLContainer("mysql:8.0");
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_5/ejem1-jmeter/ejem-1/pom.xml b/parte_5/ejem1-jmeter/ejem-1/pom.xml
index dd4340d..8db2e6f 100644
--- a/parte_5/ejem1-jmeter/ejem-1/pom.xml
+++ b/parte_5/ejem1-jmeter/ejem-1/pom.xml
@@ -10,7 +10,8 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.12
+ 4.0.5
+
@@ -48,6 +49,26 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-mysql
+ test
+
diff --git a/parte_5/ejem1-jmeter/ejem-1/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_5/ejem1-jmeter/ejem-1/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..c5c5d8a
--- /dev/null
+++ b/parte_5/ejem1-jmeter/ejem-1/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,41 @@
+package es.codeurjc.board;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.mysql.MySQLContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest(properties = "spring.jpa.hibernate.ddl-auto=create-drop")
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static MySQLContainer mysql = new MySQLContainer("mysql:8.0");
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_5/ejem1-jmeter/ejem-2-cache-redis/pom.xml b/parte_5/ejem1-jmeter/ejem-2-cache-redis/pom.xml
index c6e093e..730a03f 100644
--- a/parte_5/ejem1-jmeter/ejem-2-cache-redis/pom.xml
+++ b/parte_5/ejem1-jmeter/ejem-2-cache-redis/pom.xml
@@ -10,7 +10,7 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.12
+ 4.0.5
@@ -52,7 +52,31 @@
org.springframework.boot
spring-boot-starter-data-redis
+
+ org.springframework.boot
+ spring-boot-starter-cache
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-mysql
+ test
+
diff --git a/parte_5/ejem1-jmeter/ejem-2-cache-redis/src/main/java/es/codeurjc/board/CacheConfiguration.java b/parte_5/ejem1-jmeter/ejem-2-cache-redis/src/main/java/es/codeurjc/board/CacheConfiguration.java
index 4a7d8a7..31d97d6 100644
--- a/parte_5/ejem1-jmeter/ejem-2-cache-redis/src/main/java/es/codeurjc/board/CacheConfiguration.java
+++ b/parte_5/ejem1-jmeter/ejem-2-cache-redis/src/main/java/es/codeurjc/board/CacheConfiguration.java
@@ -8,9 +8,11 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
-import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.GenericJacksonJsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
+import tools.jackson.databind.ObjectMapper;
+
@Configuration
@EnableCaching
public class CacheConfiguration {
@@ -21,5 +23,5 @@ public RedisCacheConfiguration redisCacheManager() {
.entryTtl(Duration.ofMinutes(10)) // Los productos viven 10 min en caché
.disableCachingNullValues()
.serializeValuesWith(RedisSerializationContext.SerializationPair
- .fromSerializer(new GenericJackson2JsonRedisSerializer())); }
+ .fromSerializer(new GenericJacksonJsonRedisSerializer(new ObjectMapper()))); }
}
diff --git a/parte_5/ejem1-jmeter/ejem-2-cache-redis/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_5/ejem1-jmeter/ejem-2-cache-redis/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..69802ab
--- /dev/null
+++ b/parte_5/ejem1-jmeter/ejem-2-cache-redis/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,46 @@
+package es.codeurjc.board;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.mysql.MySQLContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+import org.testcontainers.containers.GenericContainer;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest(properties = "spring.jpa.hibernate.ddl-auto=create-drop")
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static MySQLContainer mysql = new MySQLContainer("mysql:8.0");
+
+ @Container
+ @ServiceConnection(name = "redis")
+ static GenericContainer> redis = new GenericContainer<>("redis:alpine").withExposedPorts(6379);
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_5/ejem1-jmeter/ejem-2-cache/pom.xml b/parte_5/ejem1-jmeter/ejem-2-cache/pom.xml
index 53c4dd1..1712a1b 100644
--- a/parte_5/ejem1-jmeter/ejem-2-cache/pom.xml
+++ b/parte_5/ejem1-jmeter/ejem-2-cache/pom.xml
@@ -10,7 +10,8 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.12
+ 4.0.5
+
@@ -48,6 +49,26 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-mysql
+ test
+
diff --git a/parte_5/ejem1-jmeter/ejem-2-cache/src/test/java/es/codeurjc/board/SmokeTest.java b/parte_5/ejem1-jmeter/ejem-2-cache/src/test/java/es/codeurjc/board/SmokeTest.java
new file mode 100644
index 0000000..c5c5d8a
--- /dev/null
+++ b/parte_5/ejem1-jmeter/ejem-2-cache/src/test/java/es/codeurjc/board/SmokeTest.java
@@ -0,0 +1,41 @@
+package es.codeurjc.board;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.mysql.MySQLContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest(properties = "spring.jpa.hibernate.ddl-auto=create-drop")
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static MySQLContainer mysql = new MySQLContainer("mysql:8.0");
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_5/ejem3-cache-distribuida/pom.xml b/parte_5/ejem3-cache-distribuida/pom.xml
index a9d8b88..45f8ceb 100644
--- a/parte_5/ejem3-cache-distribuida/pom.xml
+++ b/parte_5/ejem3-cache-distribuida/pom.xml
@@ -11,12 +11,12 @@
org.springframework.boot
spring-boot-starter-parent
- 3.4.4
+ 4.0.5
UTF-8
- 17
+ 21
@@ -41,16 +41,17 @@
h2
-
+
org.springframework.session
- spring-session-hazelcast
+ spring-session-jdbc
+
- com.hazelcast
- hazelcast
+ org.springframework.boot
+ spring-boot-starter-test
+ test
-
diff --git a/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/User.java b/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/AppUser.java
similarity index 91%
rename from parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/User.java
rename to parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/AppUser.java
index 174532b..2d1ec14 100644
--- a/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/User.java
+++ b/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/AppUser.java
@@ -15,7 +15,7 @@
import jakarta.persistence.Id;
@Entity
-public class User {
+public class AppUser {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@@ -28,10 +28,10 @@ public class User {
@ElementCollection(fetch = FetchType.EAGER)
private List roles;
- public User() {
+ public AppUser() {
}
- public User(String name, String password, String... roles) {
+ public AppUser(String name, String password, String... roles) {
this.name = name;
this.passwordHash = new BCryptPasswordEncoder().encode(password);
this.roles = new ArrayList<>(Arrays.asList(roles));
diff --git a/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/Application.java b/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/Application.java
index a014d45..865bdcc 100644
--- a/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/Application.java
+++ b/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/Application.java
@@ -1,33 +1,14 @@
package es.urjc.code.security;
-import java.util.Collections;
-
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Bean;
-import org.springframework.session.hazelcast.config.annotation.web.http.EnableHazelcastHttpSession;
-
-import com.hazelcast.config.Config;
-import com.hazelcast.config.JoinConfig;
+import org.springframework.session.jdbc.config.annotation.web.http.EnableJdbcHttpSession;
@SpringBootApplication
-@EnableHazelcastHttpSession
+@EnableJdbcHttpSession
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
-
- @Bean
- public Config config() {
-
- Config config = new Config();
-
- JoinConfig joinConfig = config.getNetworkConfig().getJoin();
-
- joinConfig.getMulticastConfig().setEnabled(false);
- joinConfig.getTcpIpConfig().setEnabled(true).setMembers(Collections.singletonList("127.0.0.1"));
-
- return config;
- }
}
diff --git a/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/DatabaseUsersLoader.java b/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/DatabaseUsersLoader.java
index b6e6cb0..19bb9d2 100644
--- a/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/DatabaseUsersLoader.java
+++ b/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/DatabaseUsersLoader.java
@@ -14,8 +14,8 @@ public class DatabaseUsersLoader {
@PostConstruct
private void initDatabase() {
- userRepository.save(new User("user", "pass", "ROLE_USER"));
- userRepository.save(new User("admin", "adminpass", "ROLE_USER", "ROLE_ADMIN"));
+ userRepository.save(new AppUser("user", "pass", "ROLE_USER"));
+ userRepository.save(new AppUser("admin", "adminpass", "ROLE_USER", "ROLE_ADMIN"));
}
}
diff --git a/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/SecurityConfiguration.java b/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/SecurityConfiguration.java
index 3117b74..eac4b21 100644
--- a/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/SecurityConfiguration.java
+++ b/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/SecurityConfiguration.java
@@ -1,8 +1,9 @@
+package es.urjc.code.security;
+
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
-import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
@Configuration
public class SecurityConfiguration {
@@ -10,14 +11,15 @@ public class SecurityConfiguration {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
- .authorizeHttpRequests()
+ .authorizeHttpRequests(authorize -> authorize
.anyRequest().authenticated()
- .and()
- .formLogin()
+ )
+ .formLogin(formLogin -> formLogin
+ .permitAll()
+ )
+ .logout(logout -> logout
.permitAll()
- .and()
- .logout()
- .permitAll();
+ );
return http.build();
}
diff --git a/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/UserRepository.java b/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/UserRepository.java
index 3df013f..1d347b9 100644
--- a/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/UserRepository.java
+++ b/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/UserRepository.java
@@ -2,8 +2,8 @@
import org.springframework.data.repository.CrudRepository;
-public interface UserRepository extends CrudRepository {
+public interface UserRepository extends CrudRepository {
- User findByName(String name);
+ AppUser findByName(String name);
}
diff --git a/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/UserRepositoryAuthenticationProvider.java b/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/UserRepositoryAuthenticationProvider.java
index 00cee56..69019d5 100644
--- a/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/UserRepositoryAuthenticationProvider.java
+++ b/parte_5/ejem3-cache-distribuida/src/main/java/es/urjc/code/security/UserRepositoryAuthenticationProvider.java
@@ -23,10 +23,10 @@ public class UserRepositoryAuthenticationProvider implements AuthenticationProvi
@Override
public Authentication authenticate(Authentication auth) throws AuthenticationException {
- User user = userRepository.findByName(auth.getName());
+ AppUser user = userRepository.findByName(auth.getName());
if (user == null) {
- throw new BadCredentialsException("User not found");
+ throw new BadCredentialsException("AppUser not found");
}
String password = (String) auth.getCredentials();
diff --git a/parte_5/ejem3-cache-distribuida/src/test/java/es/urjc/code/security/SmokeTest.java b/parte_5/ejem3-cache-distribuida/src/test/java/es/urjc/code/security/SmokeTest.java
new file mode 100644
index 0000000..82a4c69
--- /dev/null
+++ b/parte_5/ejem3-cache-distribuida/src/test/java/es/urjc/code/security/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.urjc.code.security;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_5/ejem3-cache-distribuida2/pom.xml b/parte_5/ejem3-cache-distribuida2/pom.xml
index 8b577ea..d17fffa 100644
--- a/parte_5/ejem3-cache-distribuida2/pom.xml
+++ b/parte_5/ejem3-cache-distribuida2/pom.xml
@@ -11,7 +11,7 @@
org.springframework.boot
spring-boot-starter-parent
- 3.4.1
+ 4.0.5
@@ -41,14 +41,10 @@
spring-boot-starter-security
-
+
org.springframework.session
- spring-session-hazelcast
-
-
- com.hazelcast
- hazelcast
+ spring-session-jdbc
@@ -56,6 +52,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_5/ejem3-cache-distribuida2/src/main/java/es/codeurjc/daw/library/Application.java b/parte_5/ejem3-cache-distribuida2/src/main/java/es/codeurjc/daw/library/Application.java
index 2e9f351..136ad48 100644
--- a/parte_5/ejem3-cache-distribuida2/src/main/java/es/codeurjc/daw/library/Application.java
+++ b/parte_5/ejem3-cache-distribuida2/src/main/java/es/codeurjc/daw/library/Application.java
@@ -1,36 +1,14 @@
package es.codeurjc.daw.library;
-import java.util.Collections;
-
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Bean;
-import org.springframework.session.hazelcast.config.annotation.web.http.EnableHazelcastHttpSession;
-
-import com.hazelcast.config.Config;
-import com.hazelcast.config.JoinConfig;
-import com.hazelcast.core.Hazelcast;
-import com.hazelcast.core.HazelcastInstance;
+import org.springframework.session.jdbc.config.annotation.web.http.EnableJdbcHttpSession;
@SpringBootApplication
-@EnableHazelcastHttpSession
+@EnableJdbcHttpSession
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
-
- @Bean
- HazelcastInstance config() {
-
- Config config = new Config();
-
- JoinConfig joinConfig = config.getNetworkConfig().getJoin();
-
- joinConfig.getMulticastConfig().setEnabled(false);
- joinConfig.getTcpIpConfig().setEnabled(true).setMembers(Collections.singletonList("127.0.0.1"));
-
- return Hazelcast.newHazelcastInstance(config);
- }
-
}
\ No newline at end of file
diff --git a/parte_5/ejem3-cache-distribuida2/src/main/java/es/codeurjc/daw/library/security/WebSecurityConfig.java b/parte_5/ejem3-cache-distribuida2/src/main/java/es/codeurjc/daw/library/security/WebSecurityConfig.java
index c81b9e0..52a4f76 100644
--- a/parte_5/ejem3-cache-distribuida2/src/main/java/es/codeurjc/daw/library/security/WebSecurityConfig.java
+++ b/parte_5/ejem3-cache-distribuida2/src/main/java/es/codeurjc/daw/library/security/WebSecurityConfig.java
@@ -24,11 +24,8 @@ public PasswordEncoder passwordEncoder() {
@Bean
public DaoAuthenticationProvider authenticationProvider() {
- DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
-
- authProvider.setUserDetailsService(userDetailService);
+ DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(userDetailService);
authProvider.setPasswordEncoder(passwordEncoder());
-
return authProvider;
}
diff --git a/parte_5/ejem3-cache-distribuida2/src/test/java/es/codeurjc/daw/library/SmokeTest.java b/parte_5/ejem3-cache-distribuida2/src/test/java/es/codeurjc/daw/library/SmokeTest.java
new file mode 100644
index 0000000..dc2506d
--- /dev/null
+++ b/parte_5/ejem3-cache-distribuida2/src/test/java/es/codeurjc/daw/library/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.daw.library;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_5/ejem4-haproxy/pom.xml b/parte_5/ejem4-haproxy/pom.xml
index 767245d..ff22648 100644
--- a/parte_5/ejem4-haproxy/pom.xml
+++ b/parte_5/ejem4-haproxy/pom.xml
@@ -15,7 +15,7 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.11
+ 4.0.5
@@ -46,6 +46,26 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ testcontainers-junit-jupiter
+ test
+
+
+ org.testcontainers
+ testcontainers-mysql
+ test
+
diff --git a/parte_5/ejem4-haproxy/src/test/java/es/codeurjc/tablonanuncios/SmokeTest.java b/parte_5/ejem4-haproxy/src/test/java/es/codeurjc/tablonanuncios/SmokeTest.java
new file mode 100644
index 0000000..5e0e00b
--- /dev/null
+++ b/parte_5/ejem4-haproxy/src/test/java/es/codeurjc/tablonanuncios/SmokeTest.java
@@ -0,0 +1,41 @@
+package es.codeurjc.tablonanuncios;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.testcontainers.mysql.MySQLContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest(properties = "spring.jpa.hibernate.ddl-auto=create-drop")
+@Testcontainers
+class SmokeTest {
+
+ @Container
+ @ServiceConnection
+ static MySQLContainer mysql = new MySQLContainer("mysql:8.0");
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}
diff --git a/parte_5/ejem4b-haproxy-ssl-passthrough/pom.xml b/parte_5/ejem4b-haproxy-ssl-passthrough/pom.xml
index ca4548e..a0e578b 100644
--- a/parte_5/ejem4b-haproxy-ssl-passthrough/pom.xml
+++ b/parte_5/ejem4b-haproxy-ssl-passthrough/pom.xml
@@ -9,11 +9,11 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.1
+ 4.0.5
UTF-8
- 17
+ 21
@@ -40,6 +40,11 @@
org.springframework.boot
spring-boot-devtools
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/model/User.java b/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/model/AppUser.java
similarity index 89%
rename from parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/model/User.java
rename to parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/model/AppUser.java
index 61a27b7..cb0f792 100644
--- a/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/model/User.java
+++ b/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/model/AppUser.java
@@ -11,7 +11,7 @@
@Entity
-public class User {
+public class AppUser {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@@ -24,10 +24,10 @@ public class User {
@ElementCollection(fetch = FetchType.EAGER)
private List roles;
- public User() {
+ public AppUser() {
}
- public User(String name, String encodedPassword, String... roles) {
+ public AppUser(String name, String encodedPassword, String... roles) {
this.name = name;
this.encodedPassword = encodedPassword;
this.roles = List.of(roles);
diff --git a/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/repository/UserRepository.java b/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/repository/UserRepository.java
index 682e466..d725005 100644
--- a/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/repository/UserRepository.java
+++ b/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/repository/UserRepository.java
@@ -4,10 +4,10 @@
import org.springframework.data.jpa.repository.JpaRepository;
-import es.codeurjc.daw.library.model.User;
+import es.codeurjc.daw.library.model.AppUser;
-public interface UserRepository extends JpaRepository {
+public interface UserRepository extends JpaRepository {
- Optional findByName(String name);
+ Optional findByName(String name);
}
diff --git a/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/security/RepositoryUserDetailsService.java b/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/security/RepositoryUserDetailsService.java
index 98aaf75..8693f8c 100644
--- a/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/security/RepositoryUserDetailsService.java
+++ b/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/security/RepositoryUserDetailsService.java
@@ -11,7 +11,7 @@
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
-import es.codeurjc.daw.library.model.User;
+import es.codeurjc.daw.library.model.AppUser;
import es.codeurjc.daw.library.repository.UserRepository;
@Service
@@ -23,8 +23,8 @@ public class RepositoryUserDetailsService implements UserDetailsService {
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
- User user = userRepository.findByName(username)
- .orElseThrow(() -> new UsernameNotFoundException("User not found"));
+ AppUser user = userRepository.findByName(username)
+ .orElseThrow(() -> new UsernameNotFoundException("AppUser not found"));
List roles = new ArrayList<>();
for (String role : user.getRoles()) {
diff --git a/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/security/WebSecurityConfig.java b/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/security/WebSecurityConfig.java
index d5f56de..c732b71 100644
--- a/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/security/WebSecurityConfig.java
+++ b/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/security/WebSecurityConfig.java
@@ -5,58 +5,64 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.web.SecurityFilterChain;
@Configuration
@EnableWebSecurity
-public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
+public class WebSecurityConfig {
@Autowired
RepositoryUserDetailsService userDetailsService;
-
+
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder(10, new SecureRandom());
}
- @Override
- protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+ @Bean
+ public DaoAuthenticationProvider authenticationProvider() {
+ DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(userDetailsService);
+ authProvider.setPasswordEncoder(passwordEncoder());
+ return authProvider;
+ }
+
+ @Bean
+ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
+
+ http.authenticationProvider(authenticationProvider());
+
+ http
+ .authorizeHttpRequests(authorize -> authorize
+ // Public pages
+ .requestMatchers("/").permitAll()
+ .requestMatchers("/login").permitAll()
+ .requestMatchers("/loginerror").permitAll()
+ .requestMatchers("/logout").permitAll()
+ // Private pages
+ .requestMatchers("/newbook").hasAnyRole("USER")
+ .requestMatchers("/editbook/*").hasAnyRole("USER")
+ .requestMatchers("/removebook/*").hasAnyRole("ADMIN")
+ .anyRequest().authenticated()
+ )
+ .formLogin(formLogin -> formLogin
+ .loginPage("/login")
+ .usernameParameter("username")
+ .passwordParameter("password")
+ .defaultSuccessUrl("/")
+ .failureUrl("/loginerror")
+ .permitAll()
+ )
+ .logout(logout -> logout
+ .logoutUrl("/logout")
+ .logoutSuccessUrl("/")
+ .permitAll()
+ );
- auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
+ return http.build();
}
-
- @Override
- protected void configure(HttpSecurity http) throws Exception {
-
- // Public pages
- http.authorizeRequests()
- .antMatchers("/").permitAll()
- .antMatchers("/login").permitAll()
- .antMatchers("/loginerror").permitAll()
- .antMatchers("/logout").permitAll()
- // Private pages
- .antMatchers("/newbook").hasAnyRole("USER")
- .antMatchers("/editbook/*").hasAnyRole("USER")
- .antMatchers("/removebook/*").hasAnyRole("ADMIN")
- .anyRequest().authenticated()
- .and()
- // Login form
- .formLogin()
- .loginPage("/login")
- .usernameParameter("username")
- .passwordParameter("password")
- .defaultSuccessUrl("/")
- .failureUrl("/loginerror")
- .and()
- // Logout
- .logout()
- .logoutUrl("/logout")
- .logoutSuccessUrl("/");
- }
}
\ No newline at end of file
diff --git a/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/service/DatabaseInitializer.java b/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/service/DatabaseInitializer.java
index 91a4a98..ed8f16a 100644
--- a/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/service/DatabaseInitializer.java
+++ b/parte_5/ejem4b-haproxy-ssl-passthrough/src/main/java/es/codeurjc/daw/library/service/DatabaseInitializer.java
@@ -5,7 +5,7 @@
import org.springframework.stereotype.Service;
import es.codeurjc.daw.library.model.Book;
-import es.codeurjc.daw.library.model.User;
+import es.codeurjc.daw.library.model.AppUser;
import es.codeurjc.daw.library.repository.BookRepository;
import es.codeurjc.daw.library.repository.UserRepository;
import jakarta.annotation.PostConstruct;
@@ -40,8 +40,8 @@ public void init() {
// Sample users
- userRepository.save(new User("user", passwordEncoder.encode("pass"), "USER"));
- userRepository.save(new User("admin", passwordEncoder.encode("adminpass"), "USER", "ADMIN"));
+ userRepository.save(new AppUser("user", passwordEncoder.encode("pass"), "USER"));
+ userRepository.save(new AppUser("admin", passwordEncoder.encode("adminpass"), "USER", "ADMIN"));
}
}
diff --git a/parte_5/ejem4b-haproxy-ssl-passthrough/src/test/java/es/codeurjc/daw/library/SmokeTest.java b/parte_5/ejem4b-haproxy-ssl-passthrough/src/test/java/es/codeurjc/daw/library/SmokeTest.java
new file mode 100644
index 0000000..dc2506d
--- /dev/null
+++ b/parte_5/ejem4b-haproxy-ssl-passthrough/src/test/java/es/codeurjc/daw/library/SmokeTest.java
@@ -0,0 +1,32 @@
+package es.codeurjc.daw.library;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Comprobacion minima: el contexto arranca y la base de datos responde.
+ */
+@SpringBootTest
+class SmokeTest {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Test
+ void elContextoArranca() {
+ }
+
+ @Test
+ void laBaseDeDatosResponde() throws Exception {
+ try (Connection conexion = dataSource.getConnection()) {
+ assertTrue(conexion.isValid(5));
+ }
+ }
+}