-
Notifications
You must be signed in to change notification settings - Fork 136
Revisión Pruebas ReusablePool #18
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?
Changes from all commits
7528962
670d371
c5f8c41
cf83565
5473a87
cd6b156
1d8a15e
bfa4157
03dab69
77e33ee
71b387e
a909884
7437046
a106e2a
ab80633
88a57a2
0fecd70
0b0c58f
875ea68
c3450c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,3 +20,6 @@ | |
|
|
||
| #mvn target | ||
| /target | ||
|
|
||
| #Eclipse folders | ||
| /.settings | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,61 +3,136 @@ | |
| */ | ||
| package ubu.gii.dass.c01; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
| import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertSame; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
| import static org.junit.jupiter.api.Assertions.fail; | ||
|
|
||
| import org.junit.jupiter.api.AfterAll; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Disabled; | ||
|
|
||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** | ||
| * @author alumno | ||
| * | ||
| */ | ||
| public class ReusablePoolTest { | ||
| private static final int num = 2; | ||
|
|
||
| /* | ||
| * Funcionalidad: Se ejecuta después de cada prueba e intenta adquirir todas las instancias reutilizables | ||
| * del pool y luego libera nuevas instancias para restablecer el estado del pool. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Este comentario no es necesario. |
||
| * | ||
| * @throws NotFreeInstanceException si no hay instancias libres disponibles en el pool. | ||
| * @throws DuplicatedInstanceException si una instancia se libera más de una vez. | ||
| */ | ||
| @AfterEach | ||
| public void despues() { | ||
| ReusablePool pool = ReusablePool.getInstance(); | ||
| System.out.println("Antes" + pool); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No se incluyen System.out.println en los test |
||
| try { | ||
| while (true) { | ||
| pool.acquireReusable(); | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. El objetivo de @AfterEach es liberar todo lo que se haya reservado en @beforeeach. Esta porción de código no procede. |
||
| } catch (NotFreeInstanceException e) { | ||
| try { | ||
| System.out.println("Med" + pool); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No se incluyen |
||
|
|
||
| for (int i = 0; i < ReusablePoolTest.num; i++) { | ||
| pool.releaseReusable(new Reusable()); | ||
| } | ||
| } catch (Exception e1) { | ||
|
|
||
| } | ||
| } | ||
| System.out.println("Despues" + pool); | ||
|
|
||
|
|
||
| @BeforeAll | ||
| public static void setUp(){ | ||
| } | ||
|
|
||
|
|
||
| @AfterAll | ||
| public static void tearDown() throws Exception { | ||
| public static void tearDown() { | ||
| } | ||
|
|
||
| /** | ||
| * Test method for {@link ubu.gii.dass.c01.ReusablePool#getInstance()}. | ||
| */ | ||
| @Test | ||
| @DisplayName("testGetInstance") | ||
| @Disabled("Not implemented yet") | ||
| @Test | ||
| @DisplayName("testGetInstance") | ||
| public void testGetInstance() { | ||
|
|
||
| ReusablePool pool1 = ReusablePool.getInstance(); | ||
| ReusablePool pool2 = ReusablePool.getInstance(); | ||
| assertNotNull(pool1); | ||
| assertNotNull(pool2); | ||
| assertSame(pool1, pool2); | ||
| assertEquals(pool1, pool2); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Añadir mensajes descriptivos del caso de prueba en los assert ayuda a mejorar la comprensión en caso de producirse el error detectado por la prueba. Este comentario de revisión intenta mejorar la facilidad de mantenimiento. |
||
| } | ||
|
|
||
| /** | ||
| * Test method for {@link ubu.gii.dass.c01.ReusablePool#acquireReusable()}. | ||
| */ | ||
| @Test | ||
| @DisplayName("testAcquireReusable") | ||
| @Disabled("Not implemented yet") | ||
|
|
||
| @DisplayName("testAcquireReusable") | ||
| public void testAcquireReusable() { | ||
|
|
||
| ReusablePool pool = ReusablePool.getInstance(); | ||
| System.out.println(pool); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No se añade un system.out.println a una caso de prueba |
||
| try { | ||
| for (int i = 0; i < ReusablePoolTest.num; i++) { | ||
| pool.acquireReusable(); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Se necesita probar que pool.acquireReusable() retorna un objeto de Reusable. |
||
| } | ||
| } catch (NotFreeInstanceException e) { | ||
| fail("No deberia de llegar aqui"); | ||
| } | ||
| assertThrows(NotFreeInstanceException.class, () -> { | ||
| pool.acquireReusable(); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Test method for {@link ubu.gii.dass.c01.ReusablePool#releaseReusable(ubu.gii.dass.c01.Reusable)}. | ||
| * Test method for | ||
| * {@link ubu.gii.dass.c01.ReusablePool#releaseReusable(ubu.gii.dass.c01.Reusable)}. | ||
| */ | ||
| @Test | ||
| @DisplayName("testReleaseReusable") | ||
| @Disabled("Not implemented yet") | ||
| @DisplayName("testReleaseReusable") | ||
| public void testReleaseReusable() { | ||
|
|
||
| ReusablePool pool = ReusablePool.getInstance(); | ||
| Reusable reusable = null; | ||
| try { | ||
| reusable = pool.acquireReusable(); | ||
| } catch (NotFreeInstanceException e) { | ||
| fail("No debería llegar aquí"); | ||
| } | ||
| try { | ||
| pool.releaseReusable(reusable); | ||
| } catch (DuplicatedInstanceException e) { | ||
| fail("No debería llegar aquí"); | ||
| } | ||
| Reusable finalReusable = reusable; | ||
| assertThrows(DuplicatedInstanceException.class, () -> pool.releaseReusable(finalReusable)); | ||
| } | ||
|
|
||
| /** | ||
| * Test method for {@link ubu.gii.dass.c01.Reusable#util}. | ||
| */ | ||
| @Test | ||
| @DisplayName("testReusableUtil") | ||
| public void testReusableUtil() { | ||
| assertNotEquals((new Reusable()).util(), (new Reusable()).util()); | ||
| } | ||
|
|
||
| /** | ||
| * Test method for {@link ubu.gii.dass.c01.Client}. | ||
| */ | ||
| @Test | ||
| @DisplayName("testClient") | ||
| public void testClient() { | ||
| assertNotNull(new Client()); | ||
| assertDoesNotThrow(() -> Client.main(null)); | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esta prueba esta fuera del contexto de prueba Reusablepool se debería eliminar de este fichero. Además, Reusable es una implementación de compromiso que no debería ser probada. Entiendo que se ha añadido para conseguir el 100% de cobertura del sistema. Si se quiere eliminar el seguimiento de su cobertura se puede indicar en el fichero de configuración de |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
Dos comentarios