Skip to content

Conversation

@Yobana
Copy link

@Yobana Yobana commented Feb 24, 2022

Se ha modificado el código del testGetinstance

andoni-ubu and others added 25 commits February 23, 2022 23:42
meta los reports y ficheros no necesarios, y comienzo de construcción
del ReusablePoolTest
Añadido flujo para poder compilar Java con Ant
Conseguimos casi un 94% de coverage sobre el main.
Añadida línea para codecov, ya que no reportaba datos.
Eliminados del gitignore, porque creo que esta dando problemas con
Codecov
Fix con el apellido de Yobana, que no compilaba el test sin darme
cuenta.
Daba un error de compilación, por lo que hemos hecho algo más complejo
el método y ahora compila correctamente sin errores.
Faltaba el test con ant
Se ha modificado el TestGetInstance
Añadidos comentarios al Código
Se modifica el readme añadiendo el enunciado y las preguntas solicitadas por el profesor.
Se han respondido las preguntas solicitadas por el profesor.
Se actualizan los archivos del repositorio de Andoni que estuvimos trabajando
Actualizamos para que lo envie a codacy
Añadimos datos codacy
Se mejora la legibilidad de código
@clopezno clopezno self-requested a review March 3, 2025 12:16
@clopezno clopezno self-assigned this Mar 3, 2025
@clopezno clopezno requested a review from Copilot March 3, 2025 12:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This pull request updates the testing and CI configuration for the project while also modifying tests for the ReusablePool singleton functionality. Key changes include:

  • Adding a new GitHub Actions workflow for building and testing the Java project with Ant.
  • Updating the README with new workflow and code coverage badges and details.
  • Modifying Travis CI configuration to install additional dependencies and report coverage.
  • Enhancing and implementing unit tests in ReusablePoolTest.java and making minor formatting updates in Client.java.

Reviewed Changes

File Description
.github/workflows/ant.yml Added a new GitHub Actions workflow to build and test the Java project with Ant
README.md Updated documentation with badges and detailed project/testing information
.travis.yml Adjusted configuration to install dependencies and add codacy coverage reporting
src/test/ubu/gii/dass/test/c01/ReusablePoolTest.java Modified and implemented tests for singleton instance, reusable acquisition/release, and Client test
src/main/ubu/gii/dass/c01/Client.java Reformatted variable declarations for clarity

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (4)

src/test/ubu/gii/dass/test/c01/ReusablePoolTest.java:100

  • Instead of printing the stack trace in this test catch block, consider failing the test so that unexpected exceptions do not pass silently.
e.printStackTrace();

src/test/ubu/gii/dass/test/c01/ReusablePoolTest.java:102

  • [nitpick] Using assertTrue(true) in the catch block does not explicitly verify the exception; consider using an assertion method (e.g., assertThrows) to confirm the expected exception is thrown.
assertTrue(true);

src/test/ubu/gii/dass/test/c01/ReusablePoolTest.java:79

  • [nitpick] To clearly validate that the exception is thrown when no reusable instance is available, consider using the expected exception mechanism or assertThrows instead of asserting null on r3.
assertNull(r3);

README.md:4

  • [nitpick] The use of '=======' as a separator may cause confusion; consider using standard markdown header syntax for clarity.
=======

@clopezno clopezno requested a review from Copilot March 3, 2025 12:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This pull request updates the testing of the ReusablePool singleton and its related behaviors while also enhancing the CI configuration and project documentation. Key changes include:

  • Adding a new GitHub Actions workflow (ant.yml) for building and testing the Java project with Ant.
  • Updating Travis configuration to install additional dependencies and run Codacy coverage reporting.
  • Enhancing test cases in ReusablePoolTest.java to verify singleton behavior, reusable acquisition and release, and client execution.

Reviewed Changes

File Description
.github/workflows/ant.yml New workflow file for Ant-based Java CI and testing.
.travis.yml Added before_install steps and updated after_success commands for coverage reporting.
README.md Updated documentation including badges and additional project information.
src/test/ubu/gii/dass/test/c01/ReusablePoolTest.java Revised tests to explicitly validate singleton behavior and exception handling.
src/main/ubu/gii/dass/c01/Client.java Adjusted variable declarations for clarity in the main method.

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

.travis.yml:3

  • Consider adding the '-y' flag (e.g. 'sudo apt-get install -y ant-optional') to ensure non-interactive installation in the CI environment.
- sudo apt-get install ant-optional

src/test/ubu/gii/dass/test/c01/ReusablePoolTest.java:79

  • Instead of relying on a null check in the exception catch block, consider explicitly asserting that a NotFreeInstanceException is thrown when no reusable instance can be acquired.
assertNull(r3);

Comment on lines +91 to +103
try {
r1 = pool.acquireReusable();
String hash1 = r1.util(); // Guardamos
pool.releaseReusable(r1); // Liberamos
r2 = pool.acquireReusable(); // Cogemos un nuevo reusable
assertTrue(hash1.equals(r2.util()));
pool.releaseReusable(r2); // Liberamos
pool.releaseReusable(r2); // Liberamos y salta la excepción
} catch (NotFreeInstanceException e) {
e.printStackTrace();
} catch (DuplicatedInstanceException e) {
assertTrue(true);
}
Copy link

Copilot AI Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than printing the stack trace on NotFreeInstanceException, use assertion methods to explicitly validate that a DuplicatedInstanceException is thrown when attempting to release the same instance twice.

Suggested change
try {
r1 = pool.acquireReusable();
String hash1 = r1.util(); // Guardamos
pool.releaseReusable(r1); // Liberamos
r2 = pool.acquireReusable(); // Cogemos un nuevo reusable
assertTrue(hash1.equals(r2.util()));
pool.releaseReusable(r2); // Liberamos
pool.releaseReusable(r2); // Liberamos y salta la excepción
} catch (NotFreeInstanceException e) {
e.printStackTrace();
} catch (DuplicatedInstanceException e) {
assertTrue(true);
}
r1 = pool.acquireReusable();
String hash1 = r1.util(); // Guardamos
pool.releaseReusable(r1); // Liberamos
r2 = pool.acquireReusable(); // Cogemos un nuevo reusable
assertTrue(hash1.equals(r2.util()));
pool.releaseReusable(r2); // Liberamos
assertThrows(DuplicatedInstanceException.class, () -> {
pool.releaseReusable(r2); // Liberamos y salta la excepción
});

Copilot uses AI. Check for mistakes.
} catch (NotFreeInstanceException e) {
e.printStackTrace();
} catch (DuplicatedInstanceException e) {
assertTrue(true);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve implementation to test throwing of the exception

@Test
public void testReleaseReusable() {
fail("Not yet implemented");
public void testClient() throws NotFreeInstanceException, DuplicatedInstanceException {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not neccesary test this class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants