Skip to content

Commit

Permalink
Merge pull request #21 from maddingo/issue18
Browse files Browse the repository at this point in the history
#18 added JaCoCo code coverage
  • Loading branch information
maddingo authored Dec 26, 2016
2 parents fc71bdc + a960248 commit ef5e3e2
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 27 deletions.
57 changes: 57 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@
<artifactId>maven-site-plugin</artifactId>
<version>3.6</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down Expand Up @@ -201,6 +206,45 @@
<artifactId>versioneye-maven-plugin</artifactId>
<version>3.11.0</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.60</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -269,6 +313,19 @@
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>

<reportSets>
<reportSet>
<reports>
<!-- select non-aggregate reports -->
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>

Expand Down
55 changes: 28 additions & 27 deletions test-util/src/main/java/no/maddin/niofs/commons/AbstractTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,33 @@
*/
public abstract class AbstractTest {

/**
* Test parameters provided by <code>${user.dir}/nio-test.xml</code>.
*/
protected static Properties testprops = new Properties();

@BeforeClass
public static void initProps() throws IOException {
File testpropsFile = new File(System.getProperty("user.dir"), "nio-test.xml");

Assume.assumeTrue("Can read " + testpropsFile.getAbsolutePath(), testpropsFile.canRead());

testprops.loadFromXML(new FileInputStream(testpropsFile));
}

protected URI createTestUri(String scheme, String host, int port, String path) throws URISyntaxException {
String username = getProperty(scheme, "nio.user");
String password = getProperty(scheme, "nio.password");

return new URI(scheme, username + ':' + password, host, port, path, null, null);
}

public String getProperty(String schema, String key) {
String value = testprops.getProperty(schema+'.'+key);
if (value == null) {
value = testprops.getProperty(key);
/**
* Test parameters provided by <code>${user.dir}/nio-test.xml</code>.
*/
protected static Properties testprops = new Properties();

@BeforeClass
public static void initProps() throws IOException {
File testpropsFile = new File(System.getProperty("user.dir"), "nio-test.xml");

Assume.assumeTrue("Can read " + testpropsFile.getAbsolutePath(), testpropsFile.canRead());


testprops.loadFromXML(new FileInputStream(testpropsFile));
}

protected URI createTestUri(String scheme, String host, int port, String path) throws URISyntaxException {
String username = getProperty(scheme, "nio.user");
String password = getProperty(scheme, "nio.password");

return new URI(scheme, username + ':' + password, host, port, path, null, null);
}

public String getProperty(String schema, String key) {
String value = testprops.getProperty(schema+'.'+key);
if (value == null) {
value = testprops.getProperty(key);
}
return value;
}
return value;
}
}

0 comments on commit ef5e3e2

Please sign in to comment.