From 1683cf8cef37f526961588f6b13423c83c444747 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Wed, 15 Jun 2016 17:34:50 -0400 Subject: [PATCH] Switch to jacoco --- .travis.yml | 4 +- hapi-fhir-base/pom.xml | 9 +- .../fhir/model/primitive/BaseDateTimeDt.java | 3 +- hapi-fhir-jacoco/pom.xml | 358 ++++++++++++++++++ hapi-fhir-jpaserver-base/pom.xml | 27 +- .../dstu3/FhirResourceDaoDstu3UpdateTest.java | 7 +- .../provider/ResourceProviderDstu2Test.java | 7 +- .../dstu3/ResourceProviderDstu3Test.java | 2 +- hapi-fhir-structures-dstu/pom.xml | 8 + .../fhir/rest/param/DateRangeParamTest.java | 4 +- hapi-fhir-structures-dstu2/pom.xml | 8 + .../primitive/BaseDateTimeDtDstu2Test.java | 40 ++ hapi-fhir-structures-dstu3/pom.xml | 27 +- hapi-fhir-structures-hl7org-dstu2/pom.xml | 10 +- pom.xml | 73 ++-- 15 files changed, 523 insertions(+), 64 deletions(-) create mode 100644 hapi-fhir-jacoco/pom.xml diff --git a/.travis.yml b/.travis.yml index ff46f83cfb0..8f612f083a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ before_script: - export MAVEN_SKIP_RC=true script: -# - mvn -e -B clean install && cd hapi-fhir-cobertura && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID clean test jacoco:report coveralls:report - - mvn -e -B clean install && cd hapi-fhir-cobertura && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report +# - mvn -e -B clean install && cd hapi-fhir-ra && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID clean test jacoco:report coveralls:report + - mvn -e -B clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml index 31ec06039d0..1f1fc2027e5 100644 --- a/hapi-fhir-base/pom.xml +++ b/hapi-fhir-base/pom.xml @@ -144,11 +144,9 @@ ${basedir}/target/classes - ${basedir}/../hapi-fhir-base/target/classes ${basedir}/src/main/java - ${basedir}/../hapi-fhir-base/src/main/java true @@ -161,6 +159,13 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + ${argLine} -Dfile.encoding=UTF-8 -Xmx712m + + org.apache.maven.plugins maven-source-plugin diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java index bbe33bf50bd..5b4f001a5f8 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java @@ -428,7 +428,8 @@ public abstract class BaseDateTimeDt extends BasePrimitive { myPrecision = thePrecision; myFractionalSeconds = ""; if (theValue != null) { - myFractionalSeconds = Integer.toString((int) (theValue.getTime() % 1000)); + String fractionalSeconds = Integer.toString((int) (theValue.getTime() % 1000)); + myFractionalSeconds = StringUtils.leftPad(fractionalSeconds, 3, '0'); } super.setValue(theValue); } diff --git a/hapi-fhir-jacoco/pom.xml b/hapi-fhir-jacoco/pom.xml new file mode 100644 index 00000000000..7d85eed2c89 --- /dev/null +++ b/hapi-fhir-jacoco/pom.xml @@ -0,0 +1,358 @@ + + 4.0.0 + + + + ca.uhn.hapi.fhir + hapi-deployable-pom + 1.6-SNAPSHOT + ../hapi-deployable-pom/pom.xml + + + hapi-fhir-jacoco + jar + + HAPI FHIR - JaCoCo Test Coverage + + + + ca.uhn.hapi.fhir + hapi-fhir-base + 1.6-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-structures-dstu + 1.6-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-structures-dstu2 + 1.6-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-structures-dstu3 + 1.6-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-structures-hl7org-dstu2 + 1.6-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-validation-resources-dstu2 + 1.6-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-validation-resources-dstu3 + 1.6-SNAPSHOT + + + ca.uhn.hapi.fhir + hapi-fhir-jpaserver-base + 1.6-SNAPSHOT + + + + com.phloc + phloc-schematron + + + com.phloc + phloc-commons + + + org.thymeleaf + thymeleaf + + + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + + + + + org.apache.derby + derby + test + + + org.apache.commons + commons-dbcp2 + test + + + + javax.servlet + javax.servlet-api + provided + + + + org.eclipse.jetty + jetty-servlets + test + + + org.eclipse.jetty + jetty-servlet + test + + + org.eclipse.jetty + jetty-server + test + + + org.eclipse.jetty + jetty-util + test + + + xmlunit + xmlunit + test + + + + net.sf.json-lib + json-lib + jdk15 + test + + + commons-logging + commons-logging + + + + + net.sf.json-lib + json-lib + jdk15-sources + test + + + directory-naming + naming-java + test + + + commons-logging + commons-logging + + + + + com.google.guava + guava + + + org.ebaysf.web + cors-filter + test + + + xmlunit + xmlunit + test + + + org.springframework + spring-test + test + + + org.eclipse.jetty.websocket + websocket-api + test + + + org.eclipse.jetty.websocket + websocket-client + test + + + org.eclipse.jetty.websocket + websocket-server + test + + + + + + + + + + + org.apache.maven.plugins + maven-site-plugin + + true + + + + + + + org.jacoco + jacoco-maven-plugin + + + jacoco-merge + + merge + + install + + + + ${basedir}/.. + + hapi-fhir-base/target/jacoco.exec + hapi-fhir-structures-dstu/target/jacoco.exec + hapi-fhir-structures-dstu2/target/jacoco.exec + hapi-fhir-structures-hl7org-dstu2/target/jacoco.exec + hapi-fhir-structures-dstu3/target/jacoco.exec + hapi-fhir-jpaserver-base/target/jacoco.exec + + + + + + + + + org.eluder.coveralls + coveralls-maven-plugin + + UTF-8 + travis-ci + ${env.TRAVIS_JOB_ID} + + ../hapi-fhir-structures-dstu/src/test/java + ../hapi-fhir-structures-dstu2/src/test/java + ../hapi-fhir-structures-hl7org-dstu2/src/test/java + ../hapi-fhir-jpaserver-base/src/test/java + ../hapi-fhir-base/src/main/java + ../hapi-fhir-jpaserver-base/src/main/java + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ../hapi-fhir-base/src/main/java + ../hapi-fhir-jpaserver-base/src/main/java + + + + + + + + org.apache.maven.plugins + maven-install-plugin + + true + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + + + ../hapi-fhir-base/src/test/resources + + + ../hapi-fhir-jpaserver-base/src/test/resources + + + ../hapi-fhir-structures-dstu/src/test/resources + + + ../hapi-fhir-structures-dstu2/src/test/resources + + + ../hapi-fhir-structures-hl7org-dstu2/src/test/resources + + + ../hapi-fhir-structures-dstu3/src/test/resources + + + + + + + org.codehaus.mojo + cobertura-maven-plugin + + + + cobertura + + + + true + + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + ${maven_project_info_plugin_version} + + true + + + + + + diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index 184e33592b7..b51d705dd97 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -335,13 +335,36 @@ + + org.jacoco + jacoco-maven-plugin + + + ${basedir}/target/classes + ${basedir}../hapi-fhir-base/target/classes + + + ${basedir}/src/main/java + ${basedir}/../hapi-fhir-base/src/main/java + + true + + + + default-prepare-agent + + prepare-agent + + + + org.apache.maven.plugins maven-surefire-plugin - alphabetical - + ${argLine} -Dfile.encoding=UTF-8 -Xmx712m + 1 diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3UpdateTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3UpdateTest.java index a90312f0347..3ed2e4c6c13 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3UpdateTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3UpdateTest.java @@ -160,12 +160,13 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test { myPatientDao.create(p, mySrd).getId(); InstantDt start = InstantDt.withCurrentTime(); + ourLog.info("First time: {}", start.getValueAsString()); Thread.sleep(100); p = new Patient(); p.addIdentifier().setSystem("urn:system").setValue(methodName); IIdType id = myPatientDao.create(p, mySrd).getId(); - ourLog.info("Created patient, got it: {}", id); + ourLog.info("Created patient, got ID: {}", id); Thread.sleep(100); @@ -174,7 +175,9 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test { p.addName().addFamily("Hello"); p.setId("Patient/" + methodName); - myPatientDao.update(p, "Patient?_lastUpdated=gt" + start.getValueAsString(), mySrd); + String matchUrl = "Patient?_lastUpdated=gt" + start.getValueAsString(); + ourLog.info("URL is: {}", matchUrl); + myPatientDao.update(p, matchUrl, mySrd); p = myPatientDao.read(id.toVersionless(), mySrd); assertThat(p.getIdElement().toVersionless().toString(), not(containsString("test"))); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java index 2a951bcba0d..a7b9ab6bb02 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java @@ -1559,6 +1559,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { @Test public void testSearchLastUpdatedParamRp() throws InterruptedException { String methodName = "testSearchLastUpdatedParamRp"; + ourLog.info("Starting " + methodName); int sleep = 100; Thread.sleep(sleep); @@ -1668,8 +1669,10 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { @Test public void testSearchReturnsSearchDate() throws Exception { + ourLog.info("Starting testSearchReturnsSearchDate"); + Date before = new Date(); - Thread.sleep(1); + Thread.sleep(100); //@formatter:off ca.uhn.fhir.model.dstu2.resource.Bundle found = ourClient @@ -1680,7 +1683,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { .execute(); //@formatter:on - Thread.sleep(1); + Thread.sleep(100); Date after = new Date(); InstantDt updated = ResourceMetadataKeyEnum.UPDATED.get(found); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java index 7cfcd5a64ba..ba7d09e430f 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java @@ -175,7 +175,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { List preDates = Lists.newArrayList(); List ids = Lists.newArrayList(); for (int i = 0; i < 10; i++) { - Thread.sleep(10); + Thread.sleep(100); preDates.add(new Date()); patient.setId(id); patient.getName().get(0).getFamily().get(0).setValue(methodName + "_i"); diff --git a/hapi-fhir-structures-dstu/pom.xml b/hapi-fhir-structures-dstu/pom.xml index 3c5cc5067dd..fdd034f9bd8 100644 --- a/hapi-fhir-structures-dstu/pom.xml +++ b/hapi-fhir-structures-dstu/pom.xml @@ -149,6 +149,7 @@ ${basedir}/src/main/java ${basedir}/../hapi-fhir-base/src/main/java + true @@ -159,6 +160,13 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + ${argLine} -Dfile.encoding=UTF-8 -Xmx712m + + ca.uhn.hapi.fhir hapi-tinder-plugin diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/param/DateRangeParamTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/param/DateRangeParamTest.java index bc7783f1b3c..288c5f5c856 100644 --- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/param/DateRangeParamTest.java +++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/param/DateRangeParamTest.java @@ -46,12 +46,12 @@ public class DateRangeParamTest { DateRangeParam range = new DateRangeParam(startDateTime, endDateTime); assertEquals("2009-12-31T19:00:00.000-05:00", range.getValuesAsQueryTokens().get(0).getValueAsString()); - assertEquals("2009-12-31T19:00:00.100-05:00", range.getValuesAsQueryTokens().get(1).getValueAsString()); + assertEquals("2009-12-31T19:00:00.001-05:00", range.getValuesAsQueryTokens().get(1).getValueAsString()); // Now try with arguments reversed (should still create same range) range = new DateRangeParam(endDateTime, startDateTime); assertEquals("2009-12-31T19:00:00.000-05:00", range.getValuesAsQueryTokens().get(0).getValueAsString()); - assertEquals("2009-12-31T19:00:00.100-05:00", range.getValuesAsQueryTokens().get(1).getValueAsString()); + assertEquals("2009-12-31T19:00:00.001-05:00", range.getValuesAsQueryTokens().get(1).getValueAsString()); } finally { TimeZone.setDefault(tz); diff --git a/hapi-fhir-structures-dstu2/pom.xml b/hapi-fhir-structures-dstu2/pom.xml index 9ae849eca18..144ab6507e9 100644 --- a/hapi-fhir-structures-dstu2/pom.xml +++ b/hapi-fhir-structures-dstu2/pom.xml @@ -158,6 +158,7 @@ ${basedir}/src/main/java ${basedir}/../hapi-fhir-base/src/main/java + true @@ -168,6 +169,13 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + ${argLine} -Dfile.encoding=UTF-8 -Xmx712m + + ca.uhn.hapi.fhir hapi-tinder-plugin diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtDstu2Test.java index d983eb467b2..ef851daf366 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtDstu2Test.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtDstu2Test.java @@ -35,6 +35,46 @@ public class BaseDateTimeDtDstu2Test { private SimpleDateFormat myDateInstantParser; private FastDateFormat myDateInstantZoneParser; + @Test + public void testFromTime() { + long millis; + InstantDt dt; + + millis = 1466022208001L; + String expected = "2016-06-15T20:23:28.001Z"; + validate(millis, expected); + + millis = 1466022208123L; + expected = "2016-06-15T20:23:28.123Z"; + validate(millis, expected); + + millis = 1466022208100L; + expected = "2016-06-15T20:23:28.100Z"; + validate(millis, expected); + + millis = 1466022208000L; + expected = "2016-06-15T20:23:28.000Z"; + validate(millis, expected); + + } + + + private void validate(long millis, String expected) { + InstantDt dt; + dt = new InstantDt(new Date(millis)); + dt.setTimeZoneZulu(true); + assertEquals(expected, dt.getValueAsString()); + + assertEquals(millis % 1000, dt.getMillis().longValue()); + assertEquals((millis % 1000) * BaseDateTimeDt.NANOS_PER_MILLIS, dt.getNanos().longValue()); + + dt = new InstantDt(); + dt.setTimeZone(TimeZone.getTimeZone("GMT+0:00")); + dt.setValue(new Date(millis)); + assertEquals(expected.replace("Z", "+00:00"), dt.getValueAsString()); + } + + @Test public void testSetPartialsYearFromExisting() { InstantDt dt = new InstantDt("2011-03-11T15:44:13.27564757855254768473697463986328969635-08:00"); diff --git a/hapi-fhir-structures-dstu3/pom.xml b/hapi-fhir-structures-dstu3/pom.xml index 10983c55899..cfd28f6e965 100644 --- a/hapi-fhir-structures-dstu3/pom.xml +++ b/hapi-fhir-structures-dstu3/pom.xml @@ -175,13 +175,34 @@ + + org.jacoco + jacoco-maven-plugin + + + ${basedir}/target/classes + ${basedir}/../hapi-fhir-base/target/classes + + + ${basedir}/src/main/java + ${basedir}/../hapi-fhir-base/src/main/java + + true + + + + default-prepare-agent + + prepare-agent + + + + org.apache.maven.plugins maven-surefire-plugin - - random - false + ${argLine} -Dfile.encoding=UTF-8 -Xmx712m diff --git a/hapi-fhir-structures-hl7org-dstu2/pom.xml b/hapi-fhir-structures-hl7org-dstu2/pom.xml index c837a79e4e5..cec1689e120 100644 --- a/hapi-fhir-structures-hl7org-dstu2/pom.xml +++ b/hapi-fhir-structures-hl7org-dstu2/pom.xml @@ -183,12 +183,13 @@ ${basedir}/target/classes - ${basedir}/../hapi-fhir-base/target/classes + ${basedir}../hapi-fhir-base/target/classes ${basedir}/src/main/java ${basedir}/../hapi-fhir-base/src/main/java + true @@ -199,6 +200,13 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + ${argLine} -Dfile.encoding=UTF-8 -Xmx712m + + org.apache.maven.plugins maven-surefire-plugin diff --git a/pom.xml b/pom.xml index 16f2a01938a..d938b936852 100644 --- a/pom.xml +++ b/pom.xml @@ -804,9 +804,8 @@ true random - ${argLine} -Dfile.encoding=UTF-8 -Xmx712m + -Dfile.encoding=UTF-8 -Xmx712m 1 - @@ -1373,30 +1372,6 @@ - @@ -1406,21 +1381,8 @@ - - org.jacoco - jacoco-maven-plugin - 0.7.7.201606060606 - - - - report - - - ${baseDir}/hapi-fhir-base/target/jacoco.exec - - - - + org.apache.maven.plugins maven-changes-plugin @@ -1569,11 +1531,30 @@ hapi-deployable-pom hapi-fhir-base - + hapi-fhir-base-test-mindeps-client + hapi-fhir-base-test-mindeps-server + hapi-tinder-plugin + hapi-tinder-test + hapi-fhir-structures-dstu + hapi-fhir-validation-resources-dstu2 + hapi-fhir-structures-dstu2 + hapi-fhir-structures-hl7org-dstu2 + hapi-fhir-validation-resources-dstu3 + hapi-fhir-structures-dstu3 + hapi-fhir-jaxrsserver-base + hapi-fhir-jaxrsserver-example + hapi-fhir-jpaserver-base + hapi-fhir-jpaserver-example + restful-server-example + restful-server-example-test + hapi-fhir-testpage-overlay + hapi-fhir-jpaserver-uhnfhirtest + hapi-fhir-android + hapi-fhir-cli + hapi-fhir-dist + examples + hapi-fhir-base-example-embedded-ws + hapi-fhir-jacoco