Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions .github/workflows/Java17CImaven.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#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

Expand All @@ -22,19 +24,56 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
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 }}




# 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

# 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
# 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 }}

39 changes: 39 additions & 0 deletions .github/workflows/Javamaven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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 }}



6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
101 changes: 80 additions & 21 deletions src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,120 @@
*/
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;
import org.junit.jupiter.api.Test;
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 {
}

/**
* 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()}.
*
* @author Ahmad Mareie Pascual
* Fecha: 09/02/2025
* @throws Exception
*
*/
@Test
@DisplayName("testAcquireReusable")
@Disabled("Not implemented yet")

public void testAcquireReusable() {

@DisplayName("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<Reusable> reusables = (Vector<Reusable>) reusablesField.get(pool);
return reusables.size();
}

/**
* 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("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 {

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");
}

}

}