From 770602e1ea3b5bba564d7ed72ee8ae9e7d37bb82 Mon Sep 17 00:00:00 2001 From: Esti-D <116215483+Esti-D@users.noreply.github.com> Date: Sat, 8 Feb 2025 21:04:20 +0100 Subject: [PATCH 1/9] Create Javamaven.yml --- .github/workflows/Javamaven.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/Javamaven.yml diff --git a/.github/workflows/Javamaven.yml b/.github/workflows/Javamaven.yml new file mode 100644 index 00000000..33a92282 --- /dev/null +++ b/.github/workflows/Javamaven.yml @@ -0,0 +1,33 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + From b07576cac14536516bd32185c98becb7c138c7ac Mon Sep 17 00:00:00 2001 From: Esti-D <116215483+Esti-D@users.noreply.github.com> Date: Sun, 9 Feb 2025 10:12:07 +0100 Subject: [PATCH 2/9] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 47c98e44..b6ec4192 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,9 @@ Authors: - Carlos Lopez Nozal - Jesus Alonso Abad + +Alumnos grupo: +- Luis Ignacio de Luna +- Ahmad Marie Pascual +- Adrian Zamora +- Estíbalitz Díez From 8d245d7ca0f879cc3b921794222932feadfacc6e Mon Sep 17 00:00:00 2001 From: Esti-D <116215483+Esti-D@users.noreply.github.com> Date: Sun, 9 Feb 2025 10:24:46 +0100 Subject: [PATCH 3/9] Update Javamaven.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codecov añadido en workflow javamaven --- .github/workflows/Javamaven.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/Javamaven.yml b/.github/workflows/Javamaven.yml index 33a92282..13b28ed9 100644 --- a/.github/workflows/Javamaven.yml +++ b/.github/workflows/Javamaven.yml @@ -29,5 +29,11 @@ jobs: cache: maven - name: Build with Maven run: mvn -B package --file pom.xml + + - name: Check test coverage + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + From 9cf294c282cbfebc6c8b5ac5a7f4920322783a0b Mon Sep 17 00:00:00 2001 From: Esti-D <116215483+Esti-D@users.noreply.github.com> Date: Sun, 9 Feb 2025 10:27:12 +0100 Subject: [PATCH 4/9] Update Java17CImaven.yml delete - archivo original del repositorio clopezno --- .github/workflows/Java17CImaven.yml | 38 ----------------------------- 1 file changed, 38 deletions(-) diff --git a/.github/workflows/Java17CImaven.yml b/.github/workflows/Java17CImaven.yml index 038cd61b..139597f9 100644 --- a/.github/workflows/Java17CImaven.yml +++ b/.github/workflows/Java17CImaven.yml @@ -1,40 +1,2 @@ -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -name: Java CI with Maven - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - name: Build with Maven - run: mvn -B package --file pom.xml - - # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - - name: Update dependency graph - uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 - # Optional: Upload coverage report - - name: Check test coverage - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} From 3e180c6f74f9801c32562375e63ffbe0016ff980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Ignacio=20de=20Luna=20G=C3=B3mez?= Date: Sun, 9 Feb 2025 13:00:59 +0100 Subject: [PATCH 5/9] =?UTF-8?q?testReleaseReusable:=20Implementaci=C3=B3n?= =?UTF-8?q?=20del=20test=20para=20liberar=20y=20reutilizar=20objetos=20en?= =?UTF-8?q?=20ReusablePool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ubu/gii/dass/c01/ReusablePoolTest.java | 66 +++++++++++++------ 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java b/src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java index 4e8c38d0..013d01ed 100644 --- a/src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java +++ b/src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java @@ -3,6 +3,8 @@ */ package ubu.gii.dass.c01; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.AfterAll; @@ -11,20 +13,16 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Disabled; - - /** * @author alumno * */ public class ReusablePoolTest { - @BeforeAll - public static void setUp(){ + public static void setUp() { } - @AfterAll public static void tearDown() throws Exception { } @@ -32,32 +30,62 @@ public static void tearDown() throws Exception { /** * Test method for {@link ubu.gii.dass.c01.ReusablePool#getInstance()}. */ - @Test - @DisplayName("testGetInstance") - @Disabled("Not implemented yet") + @Test + @DisplayName("testGetInstance") + @Disabled("Not implemented yet") public void testGetInstance() { - + } /** * Test method for {@link ubu.gii.dass.c01.ReusablePool#acquireReusable()}. */ @Test - @DisplayName("testAcquireReusable") - @Disabled("Not implemented yet") + @DisplayName("testAcquireReusable") + @Disabled("Not implemented yet") public void testAcquireReusable() { - + } /** - * Test method for {@link ubu.gii.dass.c01.ReusablePool#releaseReusable(ubu.gii.dass.c01.Reusable)}. - */ - @Test - @DisplayName("testReleaseReusable") - @Disabled("Not implemented yet") - public void testReleaseReusable() { - + * Test method for + * {@link ubu.gii.dass.c01.ReusablePool#releaseReusable(ubu.gii.dass.c01.Reusable)}. + * Realizado por: Luis Ignacio de Luna Gómez + * Fecha: 09/02/2025 + * @throws DuplicatedInstanceException + */ + @Test + @DisplayName("testReleaseReusable") + //@Disabled("Not implemented yet") //Desactivar para poder ejectuar la prueba + public void testReleaseReusable() throws DuplicatedInstanceException { + + try { + // Creo una instancia del pool + ReusablePool pool = ReusablePool.getInstance(); + + // Adquiero un objeto reutilizable + Reusable objeto = pool.acquireReusable(); + + assertNotNull(objeto, "El objeto adquirido no debe ser nulo"); + + // Libero el objeto reutilizable + pool.releaseReusable(objeto); + + // Adquiero un objeto reutilizable de nuevo + Reusable objetoNuevo = pool.acquireReusable(); + assertSame(objeto, objetoNuevo, "El objeto adquirido debe ser el mismo que el liberado"); + + //Verifico que el pool sigue permitiendonos la adquisición de objetos + Reusable objetoVerificador = pool.acquireReusable(); + assertNotNull(objetoVerificador, "El objeto adquirido no debe ser nulo"); + } + + catch (NotFreeInstanceException e) { + e.printStackTrace(); + assertTrue(false, "No debería lanzar excepción"); + } + } } From 7b11794f3ba3dd6d05fc23d6b88f21e6cb0cfee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Ignacio=20de=20Luna=20G=C3=B3mez?= Date: Sun, 9 Feb 2025 13:08:00 +0100 Subject: [PATCH 6/9] =?UTF-8?q?Corrigiendo=20workflow:=20Copia=20de=20conf?= =?UTF-8?q?iguraci=C3=B3n=20desde=20javamaven.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Java17CImaven.yml | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/.github/workflows/Java17CImaven.yml b/.github/workflows/Java17CImaven.yml index 139597f9..f4056e89 100644 --- a/.github/workflows/Java17CImaven.yml +++ b/.github/workflows/Java17CImaven.yml @@ -1,2 +1,43 @@ +#copio el archivo para ver si soluciona el problema por el que no me da el test ok + +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Check test coverage + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + + From f25e8b7da759db5e5b0a4da25c4ced949a9d0508 Mon Sep 17 00:00:00 2001 From: Esti-D <116215483+Esti-D@users.noreply.github.com> Date: Sun, 9 Feb 2025 13:20:45 +0100 Subject: [PATCH 7/9] Update Java17CImaven.yml duplicate javamaven --- .github/workflows/Java17CImaven.yml | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/Java17CImaven.yml b/.github/workflows/Java17CImaven.yml index 139597f9..72a47960 100644 --- a/.github/workflows/Java17CImaven.yml +++ b/.github/workflows/Java17CImaven.yml @@ -1,2 +1,38 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Check test coverage + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + From 4fb976c6f29e7666a2ef79236a1e1c11053782b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Ignacio=20de=20Luna=20G=C3=B3mez?= Date: Sun, 9 Feb 2025 13:25:57 +0100 Subject: [PATCH 8/9] =?UTF-8?q?testReleaseReusable:=20Implementaci=C3=B3n?= =?UTF-8?q?=20del=20test=20para=20liberar=20y=20reutilizar=20objetos=20en?= =?UTF-8?q?=20ReusablePool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java b/src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java index 013d01ed..e86c6373 100644 --- a/src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java +++ b/src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java @@ -56,7 +56,8 @@ public void testAcquireReusable() { * @throws DuplicatedInstanceException */ @Test - @DisplayName("testReleaseReusable") + @DisplayName("git commit -m \"testReleaseReusable: Implementación del test para liberar y reutilizar objetos en ReusablePool\"\r\n" + // + "") //@Disabled("Not implemented yet") //Desactivar para poder ejectuar la prueba public void testReleaseReusable() throws DuplicatedInstanceException { From ada3e70bbc53fa5f4ec09987d993b4e24be00204 Mon Sep 17 00:00:00 2001 From: AhmadMarPas Date: Sun, 9 Feb 2025 20:56:55 +0100 Subject: [PATCH 9/9] Implementado el test testAcquireReusable --- .../ubu/gii/dass/c01/ReusablePoolTest.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java b/src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java index e86c6373..137c8c15 100644 --- a/src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java +++ b/src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java @@ -3,9 +3,14 @@ */ package ubu.gii.dass.c01; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import java.lang.reflect.Field; +import java.util.Vector; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -39,15 +44,40 @@ public void testGetInstance() { /** * Test method for {@link ubu.gii.dass.c01.ReusablePool#acquireReusable()}. + * + * @author Ahmad Mareie Pascual + * Fecha: 09/02/2025 + * @throws Exception + * */ @Test @DisplayName("testAcquireReusable") - @Disabled("Not implemented yet") - - public void testAcquireReusable() { - + public void testAcquireReusable() throws Exception { + ReusablePool pool = ReusablePool.getInstance(); + Reusable external = new Reusable(); // Asumiendo constructor público + int initialSize = getPoolSize(pool); + pool.releaseReusable(external); // Agregar nueva instancia externa + assertEquals(initialSize + 1, getPoolSize(pool), "Superado el límite de tamaño del pool"); + // Adquirimos todas las instancias (originales + externa) + for (int i = 0; i < initialSize + 1; i++) { + pool.acquireReusable(); + } + try { + pool.acquireReusable(); + fail("Debería lanzar NotFreeInstanceException"); + } catch (NotFreeInstanceException e) { + System.err.println(e.getMessage()); + } } + // Método helper para obtener el tamaño del pool usando reflection + private int getPoolSize(ReusablePool pool) throws Exception { + Field reusablesField = ReusablePool.class.getDeclaredField("reusables"); + reusablesField.setAccessible(true); + Vector reusables = (Vector) reusablesField.get(pool); + return reusables.size(); + } + /** * Test method for * {@link ubu.gii.dass.c01.ReusablePool#releaseReusable(ubu.gii.dass.c01.Reusable)}.