-
Notifications
You must be signed in to change notification settings - Fork 135
Modificado testGet instance #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
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.
Eliminados del gitignore, porque creo que esta dando problemas con Codecov
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
Se mejora la legibilidad de código
volcado desde Yobana
There was a problem hiding this 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.
=======
There was a problem hiding this 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);
| 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); | ||
| } |
Copilot
AI
Mar 3, 2025
There was a problem hiding this comment.
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.
| 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 | |
| }); |
| } catch (NotFreeInstanceException e) { | ||
| e.printStackTrace(); | ||
| } catch (DuplicatedInstanceException e) { | ||
| assertTrue(true); |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
Se ha modificado el código del testGetinstance