This commit is contained in:
Grahame Grieve 2020-05-08 12:01:08 +10:00
commit 3afd2a9c32
7 changed files with 213 additions and 18 deletions

62
azure-pipelines.yml Normal file
View File

@ -0,0 +1,62 @@
trigger:
branches:
include:
- '*'
strategy:
matrix:
linux:
imageName: "ubuntu-16.04"
# mac:
# imageName: "macos-10.14"
# windows:
# imageName: "vs2017-win2016"
maxParallel: 3
pool:
vmImage: $(imageName)
variables:
currentImage: $(imageName)
codecov: $(CODECOV_TOKEN)
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
[xml]$pomXml = Get-Content .\pom.xml
# version
Write-Host $pomXml.project.version
$version=$pomXml.project.version
Write-Host "##vso[task.setvariable variable=version]$version"
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'clean package'
- bash: echo Current version => $(version)
displayName: 'version'
- script: bash <(curl https://codecov.io/bash) -t $(codecov)
displayName: 'codecov'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/org.hl7.fhir.report/target/site/jacoco-aggregate/jacoco.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/org.hl7.fhir.report/target/site/jacoco-aggregate/'
- task: PublishPipelineArtifact@1
condition: eq(variables.currentImage, 'ubuntu-16.04')
inputs:
targetPath: "$(System.DefaultWorkingDirectory)/org.hl7.fhir.validation/target/org.hl7.fhir.validation-$(version).jar"
artifactName: Validator

View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>4.2.26-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.hl7.fhir.report</artifactId>
<packaging>bundle</packaging>
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<jacoco_version>0.8.5</jacoco_version>
</properties>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.convertors</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.r5</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.antlr</groupId>
<artifactId>ST4</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.utilities</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.validation</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco_version}</version>
<executions>
<execution>
<id>report-aggregate</id>
<phase>prepare-package</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
<configuration>
<title>JaCoCo</title>
<footer>Code Coverage Report for FHIR core libs ${project.version}</footer>
<includes>
<!-- Analyze class files only to exclude shaded agent JAR from report -->
<include>**/*.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<!-- The report project pulls in resources from all the other packages, which results in some duplicate
classes being pulled in. This will need to be fixed eventually, but for now, we can just disable the
check on this package. It's only purpose is to aggregate the reports.-->
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,6 +1,7 @@
package org.hl7.fhir.utilities.tests;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -9,8 +10,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
public class XhtmlNodeTest {
private static final Logger ourLog = LoggerFactory.getLogger(XhtmlNodeTest.class);
@ -24,12 +23,12 @@ public class XhtmlNodeTest {
// Entity that appears in XHTML not not in XML
XhtmlNode node = new XhtmlNode();
node.setValueAsString("<div>&reg;</div>");
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">®</div>", node.getValueAsString());
Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">®</div>", node.getValueAsString());
// Entity that appears in both
node = new XhtmlNode();
node.setValueAsString("<div>&lt;</div>");
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">&lt;</div>", node.getValueAsString());
Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">&lt;</div>", node.getValueAsString());
}
/**
@ -39,24 +38,24 @@ public class XhtmlNodeTest {
public void testLangAttributePreserved() {
XhtmlNode dt = new XhtmlNode();
dt.setValueAsString("<div xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-US\">help i'm a bug</div>");
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-US\">help i'm a bug</div>", dt.getValueAsString());
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-US\">help i'm a bug</div>", new XhtmlNode().setValue(dt.getValue()).getValueAsString());
Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-US\">help i'm a bug</div>", dt.getValueAsString());
Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-US\">help i'm a bug</div>", new XhtmlNode().setValue(dt.getValue()).getValueAsString());
}
@Test
public void testParseRsquo() {
XhtmlNode dt = new XhtmlNode();
dt.setValueAsString("It&rsquo;s January again");
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">Its January again</div>", dt.getValueAsString());
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">Its January again</div>", new XhtmlNode().setValue(dt.getValue()).getValueAsString());
Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">Its January again</div>", dt.getValueAsString());
Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">Its January again</div>", new XhtmlNode().setValue(dt.getValue()).getValueAsString());
}
@Test
public void testProcessingInstructionNotPreserved() {
XhtmlNode dt = new XhtmlNode();
dt.setValueAsString("<?xml version=\"1.0\" encoding=\"UTF-8\"?><div xmlns=\"http://www.w3.org/1999/xhtml\">help i'm a bug</div>");
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">help i'm a bug</div>", dt.getValueAsString());
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">help i'm a bug</div>", new XhtmlNode().setValue(dt.getValue()).getValueAsString());
Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">help i'm a bug</div>", dt.getValueAsString());
Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">help i'm a bug</div>", new XhtmlNode().setValue(dt.getValue()).getValueAsString());
}
@Test
@ -71,7 +70,7 @@ public class XhtmlNodeTest {
String output = node.getValueAsString();
ourLog.info(output);
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\"><img src=\"http://pbs.twimg.com/profile_images/544507893991485440/r_vo3uj2_bigger.png\" alt=\"Twitter Avatar\"/>@fhirabend</div>", output);
Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\"><img src=\"http://pbs.twimg.com/profile_images/544507893991485440/r_vo3uj2_bigger.png\" alt=\"Twitter Avatar\"/>@fhirabend</div>", output);
}
@Test

View File

@ -13,7 +13,7 @@ import java.net.URISyntaxException;
public class ValidatorGui {
private static final int GUI_FRONTEND_PORT = 8080;
private static final int GUI_FRONTEND_PORT = 8081;
private static final String PAGE_ADDRESS = "http://localhost:" + GUI_FRONTEND_PORT + "/home";
private static final String WEB_APP_FILE_LOCATION = "/public";
private static Javalin app;
@ -32,6 +32,10 @@ public class ValidatorGui {
start(new CliContext(), validationEngine, false);
}
public static int getPort() {
return GUI_FRONTEND_PORT;
}
public static void start(CliContext currentContext, ValidationEngine validationEngine, boolean bootBrowser) {
app = Javalin.create();
new RestEndpoints().initRestEndpoints(app, currentContext, validationEngine);

View File

@ -24,7 +24,7 @@ class ValidatorGuiTest {
options.addArguments("--headless");
options.addArguments("--disable-gpu");
WebDriver driver = new ChromeDriver(options);
driver.get("http://localhost:8080/home");
driver.get("http://localhost:" + ValidatorGui.getPort() + "/home");
Assertions.assertTrue(driver.getPageSource().contains(HTML_TITLE_TAG));
driver.quit();

View File

@ -7,6 +7,7 @@ import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.client.HttpClientBuilder;
import org.hl7.fhir.validation.cli.BaseRestTest;
import org.hl7.fhir.validation.cli.ValidatorGui;
import org.hl7.fhir.validation.cli.model.CliContext;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
@ -16,7 +17,7 @@ import java.io.IOException;
class HttpGetContextTest extends BaseRestTest {
private final String GET_CONTEXT_URL = "http://localhost:8080/context";
private final String GET_CONTEXT_URL = "http://localhost:" + ValidatorGui.getPort() + "/context";
@Test
@DisplayName("Testing status code on get context endpoint.")

47
pom.xml
View File

@ -20,6 +20,7 @@
<validator_test_case_version>1.1.13-SNAPSHOT</validator_test_case_version>
<junit_jupiter_version>5.6.2</junit_jupiter_version>
<maven_surefire_version>3.0.0-M4</maven_surefire_version>
<jacoco_version>0.8.5</jacoco_version>
</properties>
<artifactId>org.hl7.fhir.core</artifactId>
@ -119,7 +120,6 @@
<version>0.13</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
@ -129,10 +129,11 @@
<module>org.hl7.fhir.dstu3</module>
<module>org.hl7.fhir.r4</module>
<module>org.hl7.fhir.r5</module>
<!--<module>org.hl7.fhir.rdf</module>-->
<module>org.hl7.fhir.convertors</module>
<module>org.hl7.fhir.validation</module>
<module>org.hl7.fhir.validation.cli</module>
<!-- The report project exists only to aggregate the test results from the other projects into a central report. -->
<module>org.hl7.fhir.report</module>
</modules>
<build>
@ -160,8 +161,13 @@
<configuration>
<trimStackTrace>false</trimStackTrace>
<testFailureIgnore>false</testFailureIgnore>
<argLine>-Xmx4096m</argLine>
<!-- We need to include the ${argLine} here so the Jacoco test arguments are included in the
Surefire testing run. This may appear as an error in some IDEs, but it will run regardless. -->
<argLine>${argLine} -Xmx4096m</argLine>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
<excludes>
<exclude>org/hl7/fhir/validation/cli/**</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
@ -272,7 +278,40 @@
<skipUpdateLicense>true</skipUpdateLicense>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco_version}</version>
<configuration>
<excludes>
<!-- These files blow away the JVM limit on file size. Until we refactor, we need to ignore or
Jacoco complains and won't run the validator tests. -->
<exclude>org/hl7/fhir/r5/formats/JsonParser</exclude>
<exclude>org/hl7/fhir/r5/formats/XmlParser</exclude>
<exclude>org/hl7/fhir/r4/formats/JsonParser</exclude>
<exclude>org/hl7/fhir/r4/formats/XmlParser</exclude>
<exclude>org/hl7/fhir/r4/**/*</exclude>
<exclude>org/hl7/fhir/dstu3/**/*</exclude>
<exclude>org/hl7/fhir/dstu2/**/*</exclude>
<exclude>org/hl7/fhir/dstu2016may/**/*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>