Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ charset = utf-8
[*.xml]
indent_style = space
indent_size = 2
max_line_length = 150

[*.java]
indent_style = space
indent_size = 4
max_line_length = 250

# Tab indentation (no size specified)
[Makefile]
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/build-on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
name: build and test on pull request
on:
pull_request:
branches: [master]
branches: [main]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Malware Scanner # https://github.com/dell/common-github-actions/blob/main/malware-scanner/README.md
uses: dell/common-github-actions/malware-scanner@main
with:
directories: .
options: -ri
- name: Set up JDK 8 for x64
uses: actions/setup-java@v4
with:
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/scan-codecoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: scan-codecoverage
on:
pull_request:
branches: [main]
jobs:
scan-codecoverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up JDK 21 for x64
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "temurin"
architecture: x64
- run: mvn test
- run: mvn jacoco:report
- run:
- run: zip -r coverage-report-html.zip jacoco/*
working-directory: target/site/
- uses: actions/upload-artifact@v4
with:
name: code-coverage
path: target/site/coverage-report-html.zip
# runs jacoco check which has 100% coverage rules. see pom.xml
- run: mvn verify
2 changes: 1 addition & 1 deletion .github/workflows/scan-malware.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: scan-malware
on:
pull_request:
branches: [master]
branches: [main]
jobs:
scan-malware:
runs-on: ubuntu-latest
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/scan-semgrep.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: scan-semgrep
on:
pull_request: {}
workflow_dispatch: {}
merge_group:
types: [checks_requested]
pull_request:
branches: [main]
jobs:
scan-semgrep:
name: semgrep/ci
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ output.xml
.settings
.DS_Store
.dccache
bar.xml
14 changes: 10 additions & 4 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@

```
mvn package -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true
java -jar target/java-junit-xml-merger-0.0.1-jar-with-dependencies.jar
java -jar target/java-junit-xml-merger.jar
```

### Testcoverage

[Run OpenClover](http://openclover.org/) with maven:
We use jacoco and have enforced 100% coverage

```bash
mvn clean clover:setup test clover:aggregate clover:clover
mvn clean
mvn test
mvn verify
mvn jacoco:report
```

Now look into `target/site/clover/`
Now look into `target/site/jacoco/` and open `index.html` in the browser.
Should look like so:

<img width="1043" height="216" alt="image" src="https://github.com/user-attachments/assets/36b98e8a-5a60-4e51-83e9-43a717047845" />
Empty file removed Jenkinsfile
Empty file.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

[![](https://codeclou.github.io/java-junit-xml-merger/img/github-product-logo-java-merger.png)](https://github.com/codeclou/java-junit-xml-merger)

[![](https://codeclou.github.io/doc/badges/generated/test-coverage-100.svg?v2)](https://codeclou.github.io/java-junit-xml-merger/test-coverage/1.0.1/)
![](https://codeclou.github.io/doc/badges/generated/test-coverage-100.svg?v2)

----


Expand Down
90 changes: 60 additions & 30 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?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/maven-v4_0_0.xsd">
<?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/maven-v4_0_0.xsd"
>
<modelVersion>4.0.0</modelVersion>
<groupId>io.codeclou</groupId>
<artifactId>java-junit-xml-merger</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<organization>
<name>codeclou.io</name>
<url>http://codeclou.io/</url>
Expand All @@ -22,7 +25,8 @@
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
<version>1.11.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand All @@ -33,19 +37,7 @@
<dependency>
<groupId>com.openpojo</groupId>
<artifactId>openpojo</artifactId>
<version>0.8.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock.version}</version>
<version>0.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -54,20 +46,9 @@
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito-common</artifactId>
<version>1.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.openclover</groupId>
<artifactId>clover-maven-plugin</artifactId>
<version>4.2.0</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
Expand All @@ -93,10 +74,59 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.14</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>1</minimum>
<!-- WE AIM FOR 100% COVERAGE -->
</limit>
<limit>
<counter>CLASS</counter>
<value>MISSEDCOUNT</value>
<maximum>0</maximum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<powermock.version>1.7.0</powermock.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@
*/
package io.codeclou.java.junit.xml.merger;

import io.codeclou.java.junit.xml.merger.model.TestSuite;
import org.junit.Test;
import org.mockito.internal.util.reflection.Whitebox;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.*;

import io.codeclou.java.junit.xml.merger.model.TestSuite;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.*;
import org.junit.Test;
import org.mockito.internal.util.reflection.Whitebox;

public class JunitXmlParserTest {

Expand All @@ -53,7 +52,7 @@ public void testParseSuites() throws Exception {
assertFalse(c.isEmpty());
assertEquals(2, c.size());
assertEquals(l.get(0).getName(), "ut.io.codeclou.customfield.editor.model.rest.SortModelTestOne");
assertEquals(l.get(1). getName(), "ut.io.codeclou.customfield.editor.model.rest.SortModelTestTwo");
assertEquals(l.get(1).getName(), "ut.io.codeclou.customfield.editor.model.rest.SortModelTestTwo");
}

@Test
Expand Down Expand Up @@ -93,7 +92,7 @@ public void testRunInvalidInput1() throws Exception {

@Test
public void testRunInvalidInput2() throws Exception {
String[] args = {"-i=foo"};
String[] args = { "-i=foo" };
JunitXmlParser parser = new JunitXmlParser();
parser.run(args);
Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(parser, "hasCmdLineParameterErrors");
Expand All @@ -102,16 +101,28 @@ public void testRunInvalidInput2() throws Exception {

@Test
public void testRunInvalidInput3() throws Exception {
String[] args = {"-i=foo", "-o=bar.xml"};
String[] args = { "-i=foo", "-o=bar.xml" };
JunitXmlParser parser = new JunitXmlParser();
parser.run(args);
Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(parser, "hasCmdLineParameterErrors");
assertTrue(hasCmdLineParameterErrors);
}

@Test
public void testRunInvalidXmlFiles() throws Exception {
// GIVEN
String[] args = { "-i=src/test/resources/invalid-files/", "-o=bar.xml", "-s=foo bar" };
JunitXmlParser parser = new JunitXmlParser();
// WHEN
parser.run(args);
// THEN
Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(parser, "hasCmdLineParameterErrors");
assertFalse(hasCmdLineParameterErrors);
}

@Test
public void testRunValidInputWithInvalidFolders() throws Exception {
String[] args = {"-i=foo", "-o=?x/bar.xml", "-s=foo"};
String[] args = { "-i=foo", "-o=?x/bar.xml", "-s=foo" };
JunitXmlParser parser = new JunitXmlParser();
parser.run(args);
Boolean hasFileNotFoundErrors = (Boolean) Whitebox.getInternalState(parser, "hasFileNotFoundErrors");
Expand All @@ -120,7 +131,7 @@ public void testRunValidInputWithInvalidFolders() throws Exception {

@Test
public void testRunValidInputWithValidFolders() throws Exception {
String[] args = {"-i=src/test/resources/", "-o=output.xml", "-s=foo bar"};
String[] args = { "-i=src/test/resources/", "-o=output.xml", "-s=foo bar" };
JunitXmlParser parser = new JunitXmlParser();
parser.run(args);
Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(parser, "hasCmdLineParameterErrors");
Expand All @@ -133,7 +144,7 @@ public void testRunValidInputWithValidFolders() throws Exception {
public void testRunValidInputWithEmptyInputFolder() throws Exception {
File emptyDir = new File("src/test/resources/empty/");
emptyDir.mkdir();
String[] args = {"-i=src/test/resources/empty/", "-o=output.xml", "-s=foo bar"};
String[] args = { "-i=src/test/resources/empty/", "-o=output.xml", "-s=foo bar" };
JunitXmlParser parser = new JunitXmlParser();
parser.run(args);
Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(parser, "hasCmdLineParameterErrors");
Expand Down
24 changes: 6 additions & 18 deletions src/test/java/io/codeclou/java/junit/xml/merger/MergerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,18 @@
*/
package io.codeclou.java.junit.xml.merger;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import static org.powermock.api.mockito.PowerMockito.whenNew;

@RunWith(PowerMockRunner.class)
public class MergerTest {

@Mock
private JunitXmlParser junitXmlParser;

@Before
public void init() throws Exception {
whenNew(JunitXmlParser.class).withNoArguments().thenReturn(junitXmlParser);
}

@Test
@PrepareForTest({Merger.class})
public void testMergerValidInput() throws Exception {
String[] args = {"-i foo", "-i bar"};
String[] args = { "-i foo", "-i bar" };
Merger.main(args);
}

@Test
public void testCoverage() throws Exception {
new Merger();
}
}
13 changes: 13 additions & 0 deletions src/test/resources/invalid-files/testsuites.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites>
<testsuite tests="3" failures="0" name="ut.io.codeclou.customfield.editor.model.rest.SortModelTestOne" time="0.029" errors="0" skipped="0">
<testcase classname="ut.io.codeclou.customfield.editor.model.rest.SortModelTest" name="testIsValid" time="0"/>
<testcase classname="ut.io.codeclou.customfield.editor.model.rest.SortModelTest" name="testToSortCollator" time="0.029"/>
<testcase classname="ut.io.codeclou.customfield.editor.model.rest.SortModelTest" name="testIsDescending" time="0"/>
</testsuite>
<testsuite tests="3" failures="0" name="ut.io.codeclou.customfield.editor.model.rest.SortModelTestTwo" time="0.029" errors="0" skipped="0">
<testcase classname="ut.io.codeclou.customfield.editor.model.rest.SortModelTest" name="testIsValid" time="0"/>
<testcase classname="ut.io.codeclou.customfield.editor.model.rest.SortModelTest" name="testToSortCollator" time="0.029"/>
<testcase classname="ut.io.codeclou.customfield.editor.model.rest.SortModelTest" name="testIsDescending" time="0"/>
</testsuite>
</testsuites>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<noxml>testsuites fails</noxml>
1 change: 1 addition & 0 deletions src/test/resources/testsuites_invalid_xml.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<noxml>testsuites fails</noxml>