From b45f3656944922f516c28374c360943a5ff59002 Mon Sep 17 00:00:00 2001 From: michi Date: Wed, 4 Feb 2015 19:47:54 +0100 Subject: [PATCH] POM review and improvement, and project cleaning. POM was reviewed to update the dependencies of the project to the last version and to improve the test execution. Now it is possible to run the project with the testing database in a Tomcat Server v7.0 using the mvn tomcat7:run goal. In addition, Selenium tests now are executed as integration tests, starting the web server before the test execution and stoping it after the tests end. Finally, support for generating regular and cobertura test reports in HTML format was also added. The project was also cleaned by removing the MANIFEST.MF files and by reallocating the SQL files. --- .../META-INF/MANIFEST.MF | 0 pom.xml | 170 ++++++++++++++---- src/main/webapp/META-INF/context.xml | 9 - src/main/webapp/WEB-INF/web.xml | 6 +- .../es/uvigo/esei/daa/dao/PeopleDAOTest.java | 1 + .../es/uvigo/esei/daa/rest/PeopleTest.java | 5 +- .../es/uvigo/esei/daa/web/PeopleWebTest.java | 1 + .../daa => resources}/mysql-tests-clear.sql | 0 .../esei/daa => resources}/mysql-tests.sql | 0 src/test/resources/mysql.sql | 16 ++ src/test/webapp/META-INF/context.xml | 30 ++++ 11 files changed, 186 insertions(+), 52 deletions(-) rename {src/main/webapp => WebContent}/META-INF/MANIFEST.MF (100%) rename src/test/{java/es/uvigo/esei/daa => resources}/mysql-tests-clear.sql (100%) rename src/test/{java/es/uvigo/esei/daa => resources}/mysql-tests.sql (100%) create mode 100644 src/test/resources/mysql.sql create mode 100644 src/test/webapp/META-INF/context.xml diff --git a/src/main/webapp/META-INF/MANIFEST.MF b/WebContent/META-INF/MANIFEST.MF similarity index 100% rename from src/main/webapp/META-INF/MANIFEST.MF rename to WebContent/META-INF/MANIFEST.MF diff --git a/pom.xml b/pom.xml index 1d4a238..1986eaa 100644 --- a/pom.xml +++ b/pom.xml @@ -16,72 +16,110 @@ - 1.7 - 1.7 + 1.8 + 1.8 + 2.15 + 5.1.34 + 1.10 + 1.4 + 3.0.1 + 4.12 + 2.44.0 + 4.1.4.RELEASE + UTF-8 - - org.glassfish.jersey.test-framework.providers - jersey-test-framework-provider-grizzly2 - 2.5.1 - test - - org.glassfish.jersey.containers jersey-container-servlet - 2.5.1 + ${jersey.version} - + + + javax.servlet + javax.servlet-api + ${java.servlet.version} + provided + + org.glassfish.jersey.media jersey-media-json-jackson - 2.5.1 + ${jersey.version} mysql mysql-connector-java - 5.1.28 + ${mysql.version} commons-codec commons-codec - 1.9 + ${commons.codec.version} junit junit - 4.11 + ${junit.version} test + + + org.glassfish.jersey.test-framework.providers + jersey-test-framework-provider-grizzly2 + ${jersey.version} + commons-dbcp commons-dbcp - 1.4 - test + ${commons.dbcp.version} org.seleniumhq.selenium selenium-java - 2.39.0 + ${selenium.java.version} test org.springframework spring-test - 4.0.0.RELEASE + ${spring.test.version} test + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.6 + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.18.1 + + + integration-tests + + failsafe-report-only + + + + + + + DAAExample @@ -89,39 +127,95 @@ maven-war-plugin org.apache.maven.plugins - 2.1.1 + 2.6 DAAExample + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + **/*WebTest* + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.18.1 + + + **/*WebTest* + + + + + + integration-test + verify + + + + + - maven-antrun-plugin + org.apache.maven.plugins + maven-surefire-report-plugin + 2.18.1 + - test-reports + test-report test + + report-only + + + + integration-test-report + integration-test + + report-only + failsafe-report-only + + + + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.2 + + 9080 + /DAAExample + src/test/webapp/META-INF/context.xml + false + + + + start-tomcat7 + pre-integration-test + + run + - - - - - - - - + true + + + stop-tomcat7 + post-integration-test - run + shutdown - - - ant - ant-junit - 1.6.2 - - diff --git a/src/main/webapp/META-INF/context.xml b/src/main/webapp/META-INF/context.xml index d8b997c..35bc2a7 100644 --- a/src/main/webapp/META-INF/context.xml +++ b/src/main/webapp/META-INF/context.xml @@ -27,13 +27,4 @@ driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/daaexample" /> - - \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 623a8d2..4695925 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -2,7 +2,7 @@ + id="DAAExample" version="3.0"> DAAExample @@ -34,12 +34,12 @@ /rest/* - + \ No newline at end of file diff --git a/src/test/java/es/uvigo/esei/daa/dao/PeopleDAOTest.java b/src/test/java/es/uvigo/esei/daa/dao/PeopleDAOTest.java index 0e527b3..14ecc45 100644 --- a/src/test/java/es/uvigo/esei/daa/dao/PeopleDAOTest.java +++ b/src/test/java/es/uvigo/esei/daa/dao/PeopleDAOTest.java @@ -16,6 +16,7 @@ public class PeopleDAOTest { @BeforeClass public static void setUpBeforeClass() throws Exception { TestUtils.createFakeContext(); + TestUtils.clearTestDatabase(); } @Before diff --git a/src/test/java/es/uvigo/esei/daa/rest/PeopleTest.java b/src/test/java/es/uvigo/esei/daa/rest/PeopleTest.java index e3fc466..c6c92d1 100644 --- a/src/test/java/es/uvigo/esei/daa/rest/PeopleTest.java +++ b/src/test/java/es/uvigo/esei/daa/rest/PeopleTest.java @@ -1,7 +1,7 @@ package es.uvigo.esei.daa.rest; -import static es.uvigo.esei.daa.TestUtils.assertOkStatus; import static es.uvigo.esei.daa.TestUtils.assertBadRequestStatus; +import static es.uvigo.esei.daa.TestUtils.assertOkStatus; import static org.junit.Assert.assertEquals; import java.io.IOException; @@ -14,7 +14,6 @@ import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.codehaus.jackson.jaxrs.JacksonJsonProvider; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; @@ -23,6 +22,8 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + import es.uvigo.esei.daa.TestUtils; import es.uvigo.esei.daa.entities.Person; diff --git a/src/test/java/es/uvigo/esei/daa/web/PeopleWebTest.java b/src/test/java/es/uvigo/esei/daa/web/PeopleWebTest.java index c757d70..42d19bb 100644 --- a/src/test/java/es/uvigo/esei/daa/web/PeopleWebTest.java +++ b/src/test/java/es/uvigo/esei/daa/web/PeopleWebTest.java @@ -26,6 +26,7 @@ public class PeopleWebTest { @BeforeClass public static void setUpBeforeClass() throws Exception { TestUtils.createFakeContext(); + TestUtils.clearTestDatabase(); } @Before diff --git a/src/test/java/es/uvigo/esei/daa/mysql-tests-clear.sql b/src/test/resources/mysql-tests-clear.sql similarity index 100% rename from src/test/java/es/uvigo/esei/daa/mysql-tests-clear.sql rename to src/test/resources/mysql-tests-clear.sql diff --git a/src/test/java/es/uvigo/esei/daa/mysql-tests.sql b/src/test/resources/mysql-tests.sql similarity index 100% rename from src/test/java/es/uvigo/esei/daa/mysql-tests.sql rename to src/test/resources/mysql-tests.sql diff --git a/src/test/resources/mysql.sql b/src/test/resources/mysql.sql new file mode 100644 index 0000000..4f89268 --- /dev/null +++ b/src/test/resources/mysql.sql @@ -0,0 +1,16 @@ +CREATE DATABASE `daaexampletest`; + +CREATE TABLE `daaexampletest`.`people` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + `surname` varchar(100) DEFAULT NULL, + PRIMARY KEY (`id`) +); + +CREATE TABLE `daaexampletest`.`users` ( + `login` varchar(100) NOT NULL, + `password` varbinary(64) DEFAULT NULL, + PRIMARY KEY (`login`) +); + +GRANT ALL ON `daaexampletest`.* TO 'daa'@'localhost' IDENTIFIED BY 'daa'; \ No newline at end of file diff --git a/src/test/webapp/META-INF/context.xml b/src/test/webapp/META-INF/context.xml new file mode 100644 index 0000000..dbba264 --- /dev/null +++ b/src/test/webapp/META-INF/context.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file -- 2.18.1