Running Jest --coverage with frontend-maven-plugin resutls in empty coverage info - maven

I've set up my package.json to run jest with coverage :
"scripts": {
"sonar": "node sonar-project.js",
"test": "jest --coverage",
"test-analyze": "npm run test && npm run sonar"
},
running npm test will ouput correct lcov.info and lcov-report in HTML format. Standard ouput looks like:
C:\sandbox2\frontend>npm test
> sandbox2-front#0.0.1 test C:\sandbox2\frontend
> jest --coverage
PASS test/Converter.spec.ts
√ Test celsius to Fahrentheit (3 ms)
√ kelvinToCelcius
--------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|-------------------
All files | 89.66 | 66.67 | 66.67 | 89.66 |
Converter.ts | 89.66 | 66.67 | 66.67 | 89.66 | 21,28-29
--------------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 0.858 s, estimated 1 s
Ran all test suites.
I'm running the (supposedly) same command through Maven with frontend-maven-plugin, with the ad hoc configuration in my pom.xml:
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<configuration>
<workingDirectory>.</workingDirectory>
<installDirectory>target</installDirectory>
<npmRegistryURL>https://ci.knowesia.com/npmjs/</npmRegistryURL>
<nodeVersion>${node.version}</nodeVersion>
</configuration>
<execution>
<id>npm-test</id>
<goals>
<goal>npm</goal>
</goals>
<phase>test</phase>
<configuration>
<arguments>run test</arguments>
</configuration>
</execution>
Despite everything looks fine, in the end my coverage reports (lcov.info, converage-final.json) are regenerated but empty.
This can be seen from standard output (you'll notice that no coverage info is displayed here):
[INFO] Running 'npm test --registry=https://internalciurl/npmjs/' in C:\sandbox2\frontend
[INFO]
[INFO] > sandbox2-front#0.0.1 test C:\sandbox2\frontend
[INFO] > jest --coverage
[INFO]
[INFO] PASS test/Converter.spec.ts
[INFO] â?? Test celsius to Fahrentheit (3 ms)
[INFO] â?? kelvinToCelcius
[INFO]
[INFO] ----------|---------|----------|---------|---------|-------------------
[INFO] File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
[INFO] ----------|---------|----------|---------|---------|-------------------
[INFO] All files | 0 | 0 | 0 | 0 |
[INFO] ----------|---------|----------|---------|---------|-------------------
[INFO] Test Suites: 1 passed, 1 total
[INFO] Tests: 2 passed, 2 total
[INFO] Snapshots: 0 total
[INFO] Time: 0.94 s, estimated 1 s
[INFO] Ran all test suites.
Are there any specific configuration to do? Is it an issue in the frontend-maven-plugin?

Related

How to pass sh command inside withCredentials for maven in Jenkins file

I'm always getting the not found error in the 6th line(Dsonar.branch.name) of the code from my Jenkinsfile below. If I swap the 6th line as Dsonar.sources it says the source is not found.
withCredentials([string(credentialsId: 'sonar_token', variable: 'token')]) {
sh"""
mvn sonar:sonar \
-Dsonar.projectKey=app \
-Dsonar.host.url=https://sonarqube.test.dev \
-Dsonar.login="917336a835asdf3528c863498"\
-Dsonar.exclusions=$env.WORKSPACE/apps/core-app/src/test
-Dsonar.branch.name=$env.BRANCH_NAME
-Dsonar.sources=$env.WORKSPACE/apps/
-Dsonar.exclusions=$env.WORKSPACE/registry/apps/support-app/src/test
-Dsonar.exclusions=src/apitest/**,src/test/**
"""
}
Error below,
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:13 min
[INFO] Finished at: 2022-01-18T07:15:59Z
[INFO] ------------------------------------------------------------------------
+ -Dsonar.branch.name=feature/docker-build
/home/jenkins/agent/workspace/nt-registry_feature_docker-build#tmp/durable-d9e51887/script.sh: 3: -Dsonar.branch.name=feature/docker-build: not found
I have used the function below instead sh command. It works as expected.
sonarResult = sonarqubeScan(
serverName: 'sonarqube',
sonarScannerExec: "$env.WORKSPACE/sonar-scanner-4.0.0.1744-linux/bin/sonar-scanner",
credentialsId: 'sonar_token',
sources: ".",
addlArgs: config.sonar.sonarAdditionalArguments
)

maven: disable surefire console errors (or fix console errors encoding)

i have maven project that just runs some groovy-based tests
it has Cyrillic testcase names and assertion text
as a result the surefire report TEST-dbtest.DBSourceTest.xml correctly generated in UTF-8 encoding with Cyrillic chars - as expected
<?xml version="1.0" encoding="UTF-8"?>
...
<testcase name="get connections" classname="dbtest.DBSourceTest$1" time="0.301"/>
<testcase name="заповнення тарифів" classname="dbtest.DBSourceTest$1" time="0.269">
<failure message="_1C.firstRow(sql).count_fail==0 По кожній культурі ..." type="Assertion failed">
<![CDATA[Assertion failed:
assert _1C.firstRow(sql).count_fail==0
| | | | |
| | | 303 false
| | /*
| | для всех:
| | По кожній культурі ...
but in console i see the question marks ? instead of Cyrillic chars for all exceptions occurred during tests even i specified encoding UTF-8 everywhere i know.
[ERROR] Failures:
[ERROR] ?????????? ???????
assert _1C.firstRow(sql).count_fail==0
| | | | |
| | | 303 false
| | /*
| | ??? ????:
| | ?? ?????? ???????? ...
i tried different versions
the surefire plugin 2.21.0 prints all the Cyrillic to console with question marks
the surefire plugin 2.12.4 prints the test summary correctly but failed assertions with question marks
test: .\sql\checksource\AB-01-заповнення тарифів.sql
...
Tests run: 15, Failures: 9, Errors: 0, Skipped: 0, Time elapsed: 1.772 sec <<< FAILURE!
Assertion failed:
assert _1C.firstRow(sql).count_fail==0
| | | | |
| | | 303 false
| | /*
| | ??? ????:
SO, I want to achieve one of:
disable failed assertions output to console
fix console output encoding for failed assertions to UTF-8
below is my current config
i tried to disable the console output but errors with question marks still there..
pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>dbtest</groupId>
<artifactId>dbtest</artifactId>
<name>dbtest project</name>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<printSummary>false</printSummary>
<trimStackTrace>false</trimStackTrace>
<argLine>-Dfile.encoding=UTF-8</argLine>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
...
</plugins>
</build>
</project>
command line to start maven:
mvn clean test -q -Dfile.encoding=UTF-8 1>log.txt 2>&1

Run a specific test in a single test class with Spock and Maven

I am using Spock framework for testing (1.0-groovy-2.4 release). Junit offers this option to run a specific test using the command line (with Maven):
mvn -Dtest=TestCircle#mytest test
Question: How can I do this with Spock?
This version has a dependency on Junit 4.12, it is stated in Junit documentation that this feature is supported only for Junit 4.x, basically Spock should propose something similar.
I use:
Windows: mvn -Dtest="TestCircle#my test" test
*Nix: mvn "-Dtest=TestCircle#my test" test
It works perfectly with surefire 2.19.1 and junit 4.8.1.
The following is the code example and the execution output:
import spock.lang.Specification
class HelloSpec extends Specification {
def sayHello() {
given: "A person's name is given as a method parameter."
def greeting = "Hello Petri";
expect: "Should say hello to the person whose name is given as a method parameter"
greeting == "Hello Petri";
println "hello from HelloSpec"
}
def sayHi() {
expect:
1==1
println "sayHi from HelloSpec"
}
def "say hi to spock" () {
expect:
true
println "say hi to spock from HelloSpec"
}
}
# mvn test "-Dtest=HelloSpec#say hi to spock"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Auto Test 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # auto-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # auto-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # auto-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 122 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # auto-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- gmaven-plugin:1.4:testCompile (compile-test) # auto-test ---
[INFO] Compiled 42 Groovy classes
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) # auto-test ---
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running HelloSpec
say hi to spock from HelloSpec
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.558 sec - in HelloSpec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.169s
[INFO] Finished at: Fri Jul 01 14:19:20 CST 2016
[INFO] Final Memory: 31M/736M
[INFO] ------------------------------------------------------------------------
# mvn test "-Dtest=HelloSpec#sayHi"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Auto Test 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # auto-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # auto-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # auto-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 122 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # auto-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- gmaven-plugin:1.4:testCompile (compile-test) # auto-test ---
[INFO] Compiled 42 Groovy classes
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) # auto-test ---
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running HelloSpec
sayHi from HelloSpec
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.539 sec - in HelloSpec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.187s
[INFO] Finished at: Fri Jul 01 14:19:49 CST 2016
[INFO] Final Memory: 31M/736M
[INFO] ------------------------------------------------------------------------
# mvn test "-Dtest=HelloSpec#sayHello"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Auto Test 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # auto-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # auto-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # auto-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 122 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # auto-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- gmaven-plugin:1.4:testCompile (compile-test) # auto-test ---
[INFO] Compiled 42 Groovy classes
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) # auto-test ---
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running HelloSpec
hello from HelloSpec
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.515 sec - in HelloSpec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.170s
[INFO] Finished at: Fri Jul 01 14:20:14 CST 2016
[INFO] Final Memory: 31M/736M
[INFO] ------------------------------------------------------------------------
Hope this help.
After a further investigation, the answer is most probably: No, you can't invoke specific test methods with Spock using that Surefire Plugin feature. Below the reason.
Given the following Spock test case:
import spock.lang.Specification
class HelloSpec extends Specification {
def hello = new Main();
def sayHello() {
given: "A person's name is given as a method parameter."
def greeting = hello.sayHello("Petri");
expect: "Should say hello to the person whose name is given as a method parameter"
greeting == "Hello Petri";
println "hello from HelloSpec"
}
}
And given the following plugins configuration:
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>addTestSources</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<fileset>
<directory>${pom.basedir}/src/test/java</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</fileset>
</sources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/*Spec.java</include>
</includes>
</configuration>
</plugin>
It runs fine as part of the Maven test phase executing mvn clean test:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.sample.HelloSpec
hello from HelloSpec
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.314 sec - in com.sample.HelloSpec
Even executing mvn clean test -Dtest=HelloSpec you get exactly the same result as above, successfully execution.
So, why we can't run a single method?
If we execute the javap command on the HelloSpec sample test above we get the following output:
Compiled from "HelloSpec.groovy"
public class com.sample.HelloSpec extends spock.lang.Specification implements groovy.lang.GroovyObject {
public static transient boolean __$stMC;
public com.sample.HelloSpec();
public void $spock_feature_0_0();
protected groovy.lang.MetaClass $getStaticMetaClass();
public groovy.lang.MetaClass getMetaClass();
public void setMetaClass(groovy.lang.MetaClass);
public java.lang.Object invokeMethod(java.lang.String, java.lang.Object);
public java.lang.Object getProperty(java.lang.String);
public void setProperty(java.lang.String, java.lang.Object);
public java.lang.Object getHello();
public void setHello(java.lang.Object);
}
So in the generated bytecode there is no sayHello method, because Spock changes methods name in order to allow spaces in them. So the method name you write is never actually the real method name as part of the compiled class.
In this case, the method name is most probably $spock_feature_0_0, not something really friendly.
This is also confirmed in this answer and the comments of Peter Niederwieser, author of Spock actually, so a more than reliable source.
You could try running the following:
mvn clean test -Dtest=HelloSpec#*spock*
which should indeed match the real method name, but you would however get an error
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.sample.HelloSpec
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.007 sec <<< FAILURE! - in com.sample.HelloSpec
initializationError(org.junit.runner.manipulation.Filter) Time elapsed: 0.006 sec <<< ERROR!
java.lang.Exception: No tests found matching Method $spock_feature_0_0(com.sample.HelloSpec) from org.junit.internal.requests.ClassRequest#282ba1e
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:35)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:275)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:149)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Results :
Tests in error:
Filter.initializationError » No tests found matching Method $spock_feature_0_...
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
This is most likely because with the direct invocation name we are bypassing the glue between JUnit and Spock and as such the execution fails.
Have you tried this (https://groups.google.com/forum/#!topic/spockframework/KVDkA9QxC4U):
Windows: mvn -Dtest="TestCircle#my test" test
*Nix: mvn "-Dtest=TestCircle#my test" test

Unable to run test for spring-xd-samples (rss-feed-source)

Preface: I have tried for several days to solve this problem on my own before bothering any of you nice people. Apologies in advance.
My problem: Tests hang for my custom source module as well as the spring-xd-samples project rss-feed-source.
I am running spring-xd 1.1.1.RELEASE on Java 1.7 OSX 10.9.5 and see the same result with mvn in the terminal as well as in Spring Tool Suite. It may be worth mentioning that I have no issue running spring's xd-amdin, xd-container, xd-singlenode, or xd-shell executables.
FeedSourceModuleIntegrationTest is where the several second hang occurs.
/**
* Start the single node container, binding random unused ports, etc. to not conflict with any other instances
* running on this host. Configure the ModuleRegistry to include the project module.
*/
#BeforeClass
public static void setUp() {
RandomConfigurationSupport randomConfigSupport = new RandomConfigurationSupport();
application = new SingleNodeApplication().run(); // Hang occurs here!
SingleNodeIntegrationTestSupport singleNodeIntegrationTestSupport = new SingleNodeIntegrationTestSupport(application);
singleNodeIntegrationTestSupport.addModuleRegistry(new SingletonModuleRegistry(ModuleType.source, "feed"));
}
FeedConfigurationTest Works just fine!
Here is the terminal output:
(may need to scroll)
$ cd rss-feed-source
$ mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building rss-feed-source 1.0.0.BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # rss-feed-source ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # rss-feed-source ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/food_meister/Documents/spring-xd-samples/rss-feed-source/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # rss-feed-source ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # rss-feed-source ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/food_mesiter/Documents/spring-xd-samples/rss-feed-source/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.18:test (default-test) # rss-feed-source ---
[INFO] Surefire report directory: /Users/food_meister/Documents/spring-xd-samples/rss-feed-source/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.acme.FeedConfigurationTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.749 sec - in com.acme.FeedConfigurationTest
Running com.acme.FeedSourceModuleIntegrationTest
_____ __ _______
/ ___| (-) \ \ / / _ \
\ `--. _ __ _ __ _ _ __ __ _ \ V /| | | |
`--. \ '_ \| '__| | '_ \ / _` | / ^ \| | | |
/\__/ / |_) | | | | | | | (_| | / / \ \ |/ /
\____/| .__/|_| |_|_| |_|\__, | \/ \/___/
| | __/ |
|_| |___/
1.1.1.RELEASE eXtreme Data
Started : SingleNodeApplication
Documentation: https://github.com/spring-projects/spring-xd/wiki
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.026 sec - in com.acme.FeedSourceModuleIntegrationTest
[2015-04-11 23:14:01,577] WARN Failed to unregister MBean InMemoryDataTree (org.apache.zookeeper.jmx.MBeanRegistry:117)
[2015-04-11 23:14:01,578] WARN Error during unregister (org.apache.zookeeper.jmx.MBeanRegistry:134)
javax.management.InstanceNotFoundException: org.apache.ZooKeeperService:name0=StandaloneServer_port-1,name1=InMemoryDataTree
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1095)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.exclusiveUnregisterMBean(DefaultMBeanServerInterceptor.java:427)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.unregisterMBean(DefaultMBeanServerInterceptor.java:415)
at com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean(JmxMBeanServer.java:546)
at org.apache.zookeeper.jmx.MBeanRegistry.unregister(MBeanRegistry.java:115)
at org.apache.zookeeper.jmx.MBeanRegistry.unregister(MBeanRegistry.java:132)
at org.apache.zookeeper.server.ZooKeeperServer.unregisterJMX(ZooKeeperServer.java:465)
at org.apache.zookeeper.server.ZooKeeperServer.shutdown(ZooKeeperServer.java:458)
at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:116)
at org.springframework.xd.dirt.zookeeper.EmbeddedZooKeeper$ServerRunnable.run(EmbeddedZooKeeper.java:240)
at java.lang.Thread.run(Thread.java:745)
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.890 s
[INFO] Finished at: 2015-04-11T23:14:01-07:00
[INFO] Final Memory: 35M/455M
[INFO] ------------------------------------------------------------------------
It's not clear what you are asking...
Running com.acme.FeedSourceModuleIntegrationTest
...
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.026 sec - in com.acme.FeedSourceModuleIntegrationTest
Indicates the test ran ok (no errors or failures).
When I run it in STS, yes there's a delay during the startup (it takes a while to start the single node) but the test runs to successful completion, giving me a green bar.

How can I create one checksum of two files in Maven to use it in the name of a directory

I'm creating a directory (local Eclipse b3 Aggregator/P2 mirror) with Maven.
Two configuration files (A.target, B.target) are used two create this directory.
If these configuration files change a new mirror directory should be created.
I want to add the checksum of the configuration files to the name of the mirror directory (e.g. mirror_65eb5293d29682a3414e8889a84104ee).
I could use the 'maven-assembly-plugin' to create a jar containing the configuration files but how do I create the checksum of this jar?
The 'checksum-maven-plugin' only writes the checksum into a csv file which I would have to parse somehow.
Is there a way to create the checksum into a property so that I can use it to add it to the name of the directory?
UPDATE:
My solution for now is to use a shell script to create the checksum and write it to a properties file.
#!/bin/bash
os=$(uname)
if [[ "$os" == "Linux" ]];
then
checksum=$(cat {A,B}.target | md5sum | awk '{print $1}')
elif [[ "$os" == "Darwin" ]]; then
checksum=$(cat {A,B}.target | md5 -q)
else
echo "unknown OS ${os}"
exit 1
fi
printf "checksum=%s" "${checksum}" > ./checksum.properties
Then I can use the properties-maven-plugin to read the checksum from this properties file.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>./checksum.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
Use the following after adapting your configuration files' location(s):
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>set-property</id>
<phase>process-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<scripts>
<script>
import java.nio.file.Path
import java.nio.file.FileSystems
import java.nio.file.Files
import java.io.BufferedInputStream
import java.security.MessageDigest
import javax.xml.bind.annotation.adapters.HexBinaryAdapter
Path pathA = FileSystems.getDefault().getPath('src/main/resources/A.target')
Path pathB = FileSystems.getDefault().getPath('src/main/resources/B.target')
byte[] configsBytes = new byte[Files.size(pathA) + Files.size(pathB)]
InputStream inA = new BufferedInputStream(Files.newInputStream(pathA))
inA.read(configsBytes)
inA.close()
InputStream inB = new BufferedInputStream(Files.newInputStream(pathB))
inB.read(configsBytes, (int)Files.size(pathA), (int)Files.size(pathB))
inB.close()
MessageDigest md5 = MessageDigest.getInstance('MD5')
// from http://stackoverflow.com/a/12514417/1744774
String digest = new HexBinaryAdapter().marshal(md5.digest(configsBytes))
log.info(String.format('Setting property configs.checksum to %s', digest))
project.properties.setProperty('configs.checksum', digest)
// InvocationTargetException: No such property: configs
//log.info(String.format('Property configs.checksum=%s', "${configs.checksum}"))
</script>
</scripts>
</configuration>
</execution>
<execution>
<id>use-property</id>
<phase>process-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<scripts>
<script>
// ...
log.info(String.format('Property configs.checksum=%s', "${configs.checksum}"))
// ...
</script>
</scripts>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Output:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building main 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- gmavenplus-plugin:1.5:execute (set-property) # main ---
[INFO] Using Groovy 2.4.3 to perform execute.
[INFO] Setting property configs.checksum to 567A4B1644EA9ACB6FC047C1B4C5624B
[INFO]
[INFO] --- gmavenplus-plugin:1.5:execute (use-property) # main ---
[INFO] Using Groovy 2.4.3 to perform execute.
[INFO] Property configs.checksum=567A4B1644EA9ACB6FC047C1B4C5624B
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.682 s
[INFO] Finished at: 2015-06-06T06:34:30+01:00
[INFO] Final Memory: 14M/111M
[INFO] ------------------------------------------------------------------------

Resources