-
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?
Changes from all commits
21b5fdc
fc97f29
6dfb31f
4115565
e9a131d
bfa4f72
eeb69d3
d385b00
2b50999
956db24
9197a91
6fdeb5d
c7dfb65
008ef39
c963588
39bc398
1327513
c2eaf93
e20750b
e72c7d7
e5554ba
f2e50c5
0594729
b543295
693bdf2
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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <classpath> | ||
| <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
| <classpathentry kind="src" path="src/main"/> | ||
| <classpathentry kind="src" path="src/test"/> | ||
| <classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/> | ||
| <classpathentry kind="lib" path="lib/jacocoant.jar"/> | ||
| <classpathentry kind="lib" path="lib/junit-4.12.jar"/> | ||
| <classpathentry kind="output" path="bin"/> | ||
| </classpath> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # This workflow will build a Java project with Ant | ||
| # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-ant | ||
|
|
||
| name: Java CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ master ] | ||
| pull_request: | ||
| branches: [ master ] | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Set up JDK 11 | ||
| uses: actions/setup-java@v2 | ||
| with: | ||
| java-version: '11' | ||
| distribution: 'temurin' | ||
| - name: Build with Ant | ||
| run: ant -noinput -buildfile build.xml | ||
| - name: Test with Ant | ||
| run: ant -buildfile build.xml test | ||
| - uses: codecov/codecov-action@v1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <projectDescription> | ||
| <name>git_poolobject</name> | ||
| <comment></comment> | ||
| <projects> | ||
| </projects> | ||
| <buildSpec> | ||
| <buildCommand> | ||
| <name>org.eclipse.jdt.core.javabuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| </buildSpec> | ||
| <natures> | ||
| <nature>org.eclipse.jdt.core.javanature</nature> | ||
| </natures> | ||
| </projectDescription> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| language: java | ||
| before_script: | ||
| - sudo apt-get install ant-optional | ||
| before_install: | ||
| - sudo apt-get install jq | ||
| - wget -O ~/codacy-coverage-reporter-assembly-latest.jar $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r .assets[0].browser_download_url) | ||
| after_success: | ||
| - bash <(curl -s https://codecov.io/bash) | ||
| - java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r target/jacoco/jacoco.xml | ||
| jdk: | ||
| - openjdk8 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,63 @@ | ||
| [](https://codecov.io/gh/andonivianez/poolobject) <br /> | ||
|  <br /> | ||
|
|
||
| ======= | ||
|
|
||
| poolobject | ||
| ========== | ||
|
|
||
| Java code example of design creational pattern pool object | ||
| ## **Autores** | ||
| - [Andoni Vianez Ulloa](https://github.com/andonivianez) | ||
| - [Yobana Nido Álvarez](https://github.com/Yobana) | ||
|
|
||
|
|
||
|
|
||
| ## **Objetivos de la práctica** | ||
| - Comprender los objetivos de medición relacionados con la caracterización y la evaluación de productos, procesos y recursos software | ||
| - Comprender, aplicar y analizar técnicas de medición sobre entidades de productos software relacionados con conjuntos de pruebas de software | ||
| - Comprender, aplicar y analizar medidas relacionadas sobre entidades de proceso y recursos de prueba del software | ||
|
|
||
| ## **Enunciado** | ||
| - En la práctica se va simular un pequeño desarrollo de un producto software para realizar mediciones sobre él. El objetivo es establecer un caso de estudio que sirva para caracterizar y evaluar tanto el producto desarrollado como el proceso seguido. | ||
|
|
||
| ## **Preguntas** | ||
|
|
||
| **¿Se ha realizado trabajo en equipo?** | ||
| Sí, hemos participado los dos integrantes del equipo: | ||
|
|
||
| **¿Tiene calidad el conjunto de pruebas disponibles?** | ||
| Sí ya que superan el 94% del coverage en la carpeta principal (main). | ||
|
|
||
| **¿Cuál es el esfuerzo invertido en realizar la actividad?** | ||
| El esfuerzo ha sido compartido entre ambos, repartiéndonos por un lado la creación del fork e indagación de las herramientas, | ||
| y por el otro el desarrollo de los propios tests. El mayor problema (por llamarlo de alguna manera) es la cuestión de los permisos | ||
| en Github, ya que el que no es propietario del fork no puede vincularlo a Codecov. El descubrir cómo funcionan las Actions ha sido interesante, | ||
| mucho más fácil que utilizar una herramienta externa como Travis. | ||
|
|
||
| ======= | ||
|
|
||
|
|
||
| ## **Objetivos de la práctica** | ||
| - Comprender los objetivos de medición relacionados con la caracterización y la evaluación de productos, procesos y recursos software | ||
| - Comprender, aplicar y analizar técnicas de medición sobre entidades de productos software relacionados con conjuntos de pruebas de software | ||
| - Comprender, aplicar y analizar medidas relacionadas sobre entidades de proceso y recursos de prueba del software | ||
|
|
||
| ## **Enunciado** | ||
| - En la práctica se va simular un pequeño desarrollo de un producto software para realizar mediciones sobre él. El objetivo es establecer un caso de estudio que sirva para caracterizar y evaluar tanto el producto desarrollado como el proceso seguido. | ||
|
|
||
| ## **Preguntas** | ||
|
|
||
| **¿Se ha realizado trabajo en equipo?** | ||
| Sí, hemos participado los dos integrantes del equipo: | ||
|
|
||
| **¿Tiene calidad el conjunto de pruebas disponibles?** | ||
| Sí ya que superan el 94% del coverage en la carpeta principal (main). | ||
|
|
||
| **¿Cuál es el esfuerzo invertido en realizar la actividad?** | ||
| El esfuerzo ha sido compartido entre ambos, repartiéndonos por un lado la creación del fork e indagación de las herramientas, | ||
| y por el otro el desarrollo de los propios tests. El mayor problema (por llamarlo de alguna manera) es la cuestión de los permisos | ||
| en Github, ya que el que no es propietario del fork no puede vincularlo a Codecov. El descubrir cómo funcionan las Actions ha sido interesante, | ||
| mucho más fácil que utilizar una herramienta externa como Travis. | ||
|
|
||
| Example to apply good practise in software developmemnt: test and mesurement. | ||
| **¿Cuál es el número de fallos encontrados en el código?** | ||
| No encontramos ningún fallo en el código (compila correctamente tal y como puede verse en Github Actions). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <? versión xml = " 1.0 " ?> | ||
| <! SISTEMA DE COBERTURA DOCTYPE "http://cobertura.sourceforge.net/xml/coverage-04.dtd"> | ||
| < cobertura líneas-válidas = " 8 " líneas-cubiertas = " 8 " línea-tarifa = " 1 " ramas-válidas = " 4 " ramas-cubiertas = " 4 " rama-tasa = " 1 " timestamp = " 1394890504210 " complejidad = " 0 " versión = " 0.1 " > | ||
| < fuentes > | ||
| < fuente >fuentes</ fuente > | ||
| </ fuentes > | ||
| < paquetes > | ||
| < nombre del paquete = " 3 " line-rate = " 1 " branch-rate = " 1 " > | ||
| < clases > | ||
| < nombre de clase = " cc.js " nombre de archivo = " cc.js " line-rate = " 1 " branch-rate = " 1 " > | ||
| < métodos > | ||
| < nombre del método = " normalizar " aciertos = " 11 " firma = " ()V " > | ||
| < líneas > | ||
| < número de línea = " 1 " hits = " 11 " /> | ||
| </ lineas > | ||
| </ método > | ||
| < nombre del método = " getBrand " visitas = " 7 " firma = " ()V " > | ||
| < líneas > | ||
| < número de línea = " 5 " hits = " 7 " /> | ||
| </ lineas > | ||
| </ método > | ||
| </ métodos > | ||
| < líneas > | ||
| < número de línea = " 1 " hits = " 1 " branch = " false " /> | ||
| < número de línea = " 2 " hits = " 11 " branch = " false " /> | ||
| < número de línea = " 5 " hits = " 1 " branch = " false " /> | ||
| < número de línea = " 6 " hits = " 7 " branch = " false " /> | ||
| < número de línea = " 15 " hits = " 7 " branch = " false " /> | ||
| < número de línea = " 17 " hits = " 7 " branch = " false " /> | ||
| < número de línea = " 18 " hits = " 25 " branch = " true " condition-coverage = " 100% (4/4) " /> | ||
| < número de línea = " 20 " hits = " 6 " branch = " false " /> | ||
| </ lineas > | ||
| </ clase > | ||
| </ clases > | ||
| </ paquete > | ||
| </ paquetes > | ||
| </ cobertura > |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,48 +9,113 @@ | |||||||||||||||||||||||||||||||||||||||||||||
| import org.junit.Before; | ||||||||||||||||||||||||||||||||||||||||||||||
| import org.junit.Test; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| import ubu.gii.dass.c01.DuplicatedInstanceException; | ||||||||||||||||||||||||||||||||||||||||||||||
| import ubu.gii.dass.c01.NotFreeInstanceException; | ||||||||||||||||||||||||||||||||||||||||||||||
| import ubu.gii.dass.c01.Reusable; | ||||||||||||||||||||||||||||||||||||||||||||||
| import ubu.gii.dass.c01.ReusablePool; | ||||||||||||||||||||||||||||||||||||||||||||||
| import ubu.gii.dass.c01.Client; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||
| * @author alumno | ||||||||||||||||||||||||||||||||||||||||||||||
| * @author Andoni Vianez Ulloa | ||||||||||||||||||||||||||||||||||||||||||||||
| * @author Yobana Nido Alvarez | ||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||
| public class ReusablePoolTest { | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| private ReusablePool pool; | ||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||
| * @throws java.lang.Exception | ||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||
| @Before | ||||||||||||||||||||||||||||||||||||||||||||||
| public void setUp() throws Exception { | ||||||||||||||||||||||||||||||||||||||||||||||
| pool = ReusablePool.getInstance(); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||
| * @throws java.lang.Exception | ||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||
| @After | ||||||||||||||||||||||||||||||||||||||||||||||
| public void tearDown() throws Exception { | ||||||||||||||||||||||||||||||||||||||||||||||
| pool = null; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||
| * Test method for {@link ubu.gii.dass.c01.ReusablePool#getInstance()}. | ||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||||||||||||||||
| public void testGetInstance() { | ||||||||||||||||||||||||||||||||||||||||||||||
| fail("Not yet implemented"); | ||||||||||||||||||||||||||||||||||||||||||||||
| ReusablePool pool = ReusablePool.getInstance(); | ||||||||||||||||||||||||||||||||||||||||||||||
| // Comprobamos que no es null | ||||||||||||||||||||||||||||||||||||||||||||||
| assertNotNull("Devuelve un objeto nulo", pool); | ||||||||||||||||||||||||||||||||||||||||||||||
| // Comprobamos que el objeto devuelto es una instancia | ||||||||||||||||||||||||||||||||||||||||||||||
| assertTrue(pool instanceof ReusablePool); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ReusablePool pool2 = ReusablePool.getInstance(); | ||||||||||||||||||||||||||||||||||||||||||||||
| // Comprobamos que no es null | ||||||||||||||||||||||||||||||||||||||||||||||
| assertNotNull("Devuelve un objeto nulo", pool2); | ||||||||||||||||||||||||||||||||||||||||||||||
| // Comprobamos que el objeto devuelto es una instancia | ||||||||||||||||||||||||||||||||||||||||||||||
| assertTrue(pool2 instanceof ReusablePool); | ||||||||||||||||||||||||||||||||||||||||||||||
| assertSame("Misma instancia que el Singleton", pool, pool2); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||
| * Test method for {@link ubu.gii.dass.c01.ReusablePool#acquireReusable()}. | ||||||||||||||||||||||||||||||||||||||||||||||
| * @throws NotFreeInstanceException | ||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||||||||||||||||
| public void testAcquireReusable() { | ||||||||||||||||||||||||||||||||||||||||||||||
| fail("Not yet implemented"); | ||||||||||||||||||||||||||||||||||||||||||||||
| public void testAcquireReusable() throws NotFreeInstanceException { | ||||||||||||||||||||||||||||||||||||||||||||||
| Reusable r1, r2, r3 = null; | ||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||
| r1 = pool.acquireReusable(); | ||||||||||||||||||||||||||||||||||||||||||||||
| assertNotNull(r1); | ||||||||||||||||||||||||||||||||||||||||||||||
| assertTrue(r1 instanceof Reusable); | ||||||||||||||||||||||||||||||||||||||||||||||
| r2 = pool.acquireReusable(); | ||||||||||||||||||||||||||||||||||||||||||||||
| assertNotNull(r2); | ||||||||||||||||||||||||||||||||||||||||||||||
| assertTrue(r2 instanceof Reusable); | ||||||||||||||||||||||||||||||||||||||||||||||
| // Se comprueba que no son el mismo objeto | ||||||||||||||||||||||||||||||||||||||||||||||
| assertFalse(r1.util().equals(r2.util())); | ||||||||||||||||||||||||||||||||||||||||||||||
| r3 = pool.acquireReusable(); | ||||||||||||||||||||||||||||||||||||||||||||||
| } catch (NotFreeInstanceException e) { | ||||||||||||||||||||||||||||||||||||||||||||||
| assertNull(r3); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||
| * Test method for {@link ubu.gii.dass.c01.ReusablePool#releaseReusable(ubu.gii.dass.c01.Reusable)}. | ||||||||||||||||||||||||||||||||||||||||||||||
| * @throws NotFreeInstanceException | ||||||||||||||||||||||||||||||||||||||||||||||
| * @throws DuplicatedInstanceException | ||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||||||||||||||||
| public void testReleaseReusable() throws NotFreeInstanceException, DuplicatedInstanceException { | ||||||||||||||||||||||||||||||||||||||||||||||
| Reusable r1, r2 = null; | ||||||||||||||||||||||||||||||||||||||||||||||
| 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); | ||||||||||||||||||||||||||||||||||||||||||||||
|
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. Improve implementation to test throwing of the exception |
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
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); | |
| } | |
| 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 | |
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.