Maven verify doesn't execute Cucumber-Serenity integration tests with fail-safe - integration-testing

I have below POM in my project.
mvn clean verify -P it
POM:
<build>
<pluginManagement>
<plugins>
.....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-plugin.version}</version>
<configuration>
<skipTests>false</skipTests>
<excludes>
<exclude>**/*CucumberTests.java</exclude>
<exclude>**/IT*.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-plugin.version}</version>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skipTests>false</skipTests>
<testFailureIgnore>true</testFailureIgnore>
<excludes>
<exclude>none</exclude>
</excludes>
<includes>
<include>**/*CucumberTests.java</include>
<include>**/*IT.java</include>
</includes>
<systemPropertyVariables>
<it.server.port>${random.http.port}</it.server.port>
<it.jmx.port>${random.jmx.port}</it.jmx.port>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.9.RELEASE</version>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
<configuration>
<skip>false</skip>
<wait>2000</wait>
<!-- Max retry count -->
<maxAttempts>180</maxAttempts>
<jmxPort>${random.jmx.port}</jmxPort>
<arguments>
<argument>--server.port=${random.http.port}</argument>
<argument>--spring.profiles.active=${spring.profile}</argument>
</arguments>
<jvmArguments>
-Djava.security.egd=file:///dev/urandom
</jvmArguments>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
<configuration>
<skip>false</skip>
<jmxPort>${random.jmx.port}</jmxPort>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
...
</plugin>
</plugins>
</build>
Test class:
import org.junit.runner.RunWith;
import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
#RunWith(CucumberWithSerenity.class)
#CucumberOptions(
plugin = {"pretty"},
glue = {"my.stepdefinitions"},
tags = {"#Demo"},
features = "src/it/resources/features/"
)
public class MicroServiceCucumberTests {
}
path: src/it/java
Basically it trigger sure-fire and then startup the app and just stuck there without executing maven-failsafe-plugin:2.21.0:integration-test (integration-tests)
Versions are being used:
<serenity.plugin.version>2.4.34</serenity.plugin.version>
<serenity.version>2.4.34</serenity.version>
<serenity.cucumber.version>2.4.34</serenity.cucumber.version>
<cucumber.version>6.10.4</cucumber.version>
<maven-plugin.version>3.0.0-M5</maven-plugin.version>
<java.version>1.8</java.version>

After digging further into logs what I noticed was, app didn't start up properly and stuck with below logs
DEBUG] Application argument(s): --server.port=54110 --spring.profiles.active=it
[DEBUG] Connecting to local MBeanServer at port 54111
[DEBUG] Waiting for spring application to start...
[DEBUG] MBean server at port 54111 is not up yet...
[DEBUG] Spring application is not ready yet, waiting 2000ms (attempt 1)
[DEBUG] MBean server at port 54111 is not up yet...
[DEBUG] Spring application is not ready yet, waiting 2000ms (attempt 2)
This solution worked for me https://stackoverflow.com/a/65952986/2303693
Adding below within the spring-boot-maven-plugin in the POM did the trick.
<configuration>
<fork>false</fork>
</configuration>
However same code worked in iOS machine without above fix. Further still not sure what caused the issue in Windows.

Related

How to use a custom response class instead of using the spring default ResponseEntity

I am using openapi-generator-maven-plugin for generating the classes. Using the following dependency
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.0.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${swagger.gen.product.componentsYaml}</inputSpec>
<generatorName>spring</generatorName>
<modelPackage>${swagger.gen.srcPackage}.model</modelPackage>
<apiPackage>${swagger.gen.srcPackage}.api.controller</apiPackage>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<sourceFolder>src/main/java</sourceFolder>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
</configOptions>
<verbose>true</verbose>
<generateSupportingFiles>true</generateSupportingFiles>
<generateApiTests>true</generateApiTests>
<generateModelTests>true</generateModelTests>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>
The java api generating have the return type org.springframework.http.ResponseEntity.
Instead of using the default response type I want
to use a custom one. Is there any way to implement this?

I can't debug an application using netbeans 11 with JavaFX 12

I've downloaded netbeans 11 with support for java 12
So I followed up the steps from the Gluon webpage running JavaFX and Netbeans Non modular with maven > https://openjfx.io/openjfx-docs/#next-steps
I have configured as showed in the instructions the action to run this app.
Run Project
clean javafx:run
But there is nothing specified to debug the project.
Is there a way to debug this javaFX project?
<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>com.mycompany</groupId>
<artifactId>SimonSaysGFX</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>12.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>12.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>12.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>12</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.2</version>
<configuration>
<mainClass>com.mycompany.simonsaysgfx.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<name>SimonSaysGFX</name>
</project>
If you see the documentation of the javafx-maven-plugin, you can add some VM arguments to the run goal in order to debug your project in NetBeans.
However, to keep the usual run goal ready to just run the project and not debug, without commenting out the added options, we can add a second execution to the plugin.
Modify your plugin like this:
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.2</version>
<executions>
<execution>
<!-- Default configuration for running -->
<id>default-cli</id>
<configuration>
<mainClass>com.mycompany.simonsaysgfx.App</mainClass>
</configuration>
</execution>
<execution>
<!-- Configuration for debugging -->
<id>debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8000</option>
</options>
<mainClass>com.mycompany.simonsaysgfx.App</mainClass>
</configuration>
</execution>
</executions>
</plugin>
Now you can run from command line:
mvn clean javafx:run
to run as usual your application, and:
mvn clean javafx:run#debug
to start debug mode. Then you will see something like:
[INFO] --- javafx-maven-plugin:0.0.2:run (debug) # Project ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /path/to/project/target/classes
Listening for transport dt_socket at address: 8000
At this point, you need to set your breakpoints and attach a debugger from NetBeans -> Debug -> Attach Debugger to port 8000:
Click OK and you will be able to debug your projects.
Note that you can also define custom NetBeans actions to use the Run and Debug buttons. Add a nbactions.xml file to the root of your project, with this two actions:
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<goals>
<goal>clean</goal>
<goal>javafx:run</goal>
</goals>
</action>
<action>
<actionName>jlink</actionName>
<goals>
<goal>clean</goal>
<goal>javafx:jlink</goal>
</goals>
</action>
<action>
<actionName>debug</actionName>
<goals>
<goal>clean</goal>
<goal>javafx:run#debug</goal>
</goals>
</action>
</actions>
Now you can use NetBeans run and debug buttons.
José's answer is good. Just go little bit further.
In pom.xml set the
address=${jpda.address} instead of address=*:8000
<execution>
<!-- Configuration for debugging -->
<id>debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</option>
</options>
<mainClass>cz.masci.mvcpattern.mvc.App</mainClass>
</configuration>
</execution>
Be aware of set server=n, otherwise the application will not start.
In the debug action set jpda.listen=true property
...
<action>
<actionName>debug</actionName>
<goals>
<goal>clean</goal>
<goal>javafx:run#debug</goal>
</goals>
<properties>
<jpda.listen>true</jpda.listen>
</properties>
</action>
Then you don't need to attach debuger anymore. Netbeans does it for you.

When using Maven Assembly Plugin - Manifest.MF is not packaged in the correct order

Failed to install artifact: C:\Test\7\config\analyzers\analyzers-7.0.0-13-SNAPSHOT-jar-with-dependencies.jar: org.osgi.framework.BundleException: The bundle file:/C:/Test/7/config/analyzers/analyzers-7.0.0-13-SNAPSHOT-jar-with-dependencies.jar does not have a META-INF/MANIFEST.MF! Make sure, META-INF and MANIFEST.MF are the first 2 entries in your JAR!
org.osgi.framework.BundleException: The bundle file:/C:/Palamida/7.0-v4/config/analyzers/analyzers-7.0.0-13-SNAPSHOT-jar-with-dependencies.jar does not have a META-INF/MANIFEST.MF! Make sure, META-INF and MANIFEST.MF are the first 2 entries in your JAR!
at org.apache.felix.fileinstall.internal.DirectoryWatcher.installOrUpdateBundle(DirectoryWatcher.java:1004)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:952)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:871)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:485)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312)
The 1st part of the error claims there is no MANIFEST.MF but checking manually reveals it is there. The 2nd part of the error claims the MANIFEST.MF is not one of the 1st two entries in the jar which I have not been able to verify. Is there a configuration issue with my assembly plugin?
My pom.xml containing my maven-assembly-plugin config:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
I am also using maven-bundle-plugin with the manifest goal, which outputs a manifest.mf which is consumed by assembly-plugin, but I don't believe that should be causing any interference.
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<finalName>${name.project}</finalName>
<archive>
<manifest>
<mainClass>br.com.car.view</mainClass>
</manifest>
<manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Way to use manifest command File in your maven (pom) configuration file

How to force delays on starting each thread while using Grid?

I try to run in paralel TestSuites using Grid. This is part of my pom.xml.
How can I force 2sec delays between threads startings? Here are 4 threads max and only 3 Suites to run, so all 3 of them are started at the same time.
After starting node with:
java -jar selenium-server-standalone-2.25.0.jar -role webdriver -hub
http://localhost:4444/grid/register -port 5556 -browser
browserName=chrome,version=23,platform=WINDOWS,maxInstances=4
it causes 2 of 3 instances conflict in app due to some known reasons. It is required at least 2 sec diff in thread strating time.
How can it be done?
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12.4</version>
<executions>
<execution>
<id>integration-test-chrome</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
<configuration>
<forkMode>perthread</forkMode>
<threadCount>4</threadCount>
<includes>
<include>**/HomeSuiteWithoutFailedTests.java</include>
<include>**/QuotaSuiteWithoutFailedTests.java</include>
<include>**/SpywareSuiteWithoutFailedTests.java</include>
</includes>
<systemPropertyVariables>
<browser>${browser}</browser>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
Resolved the issue with adding random sleep before init of driver for suite.

Error reading assemblies: No assembly descriptors found

I get Error reading assemblies: No assembly descriptors found when building my project. I'm trying to set permissions for my .sh files and exclude a nasty .jar file that makes my application crash...I don't think the problem is about that though....
My maven-assembly plugin is added like this in my pom.xml file:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/src.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
My assembly descriptor looks like this:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>my-assembly-descriptor</id>
<formats>
<format>jar</format>
<format>war</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>${project.build.directory}</outputDirectory>
<includes>
<include>*.sh</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<excludes>
<exclude>spring-2.5.4.jar</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
The structure in my project is:
Interface - src - main - assembly - src.xml
- pom.xml
When trying to do Run as -> Debug as -> and then in goal putting
assembly:single
I get the same error. I tried in console, with assembly:assembly, and I got nothing. I even tried to put a wrong path to my assembly descriptor, but the error didn't change. When putting ${basedir}/ before the path to my assembly descriptor, I get the same.
I have Ubuntu 10.10 Maverick Meerkat, and I'm working with Eclipse EE,...
Thanks!
I have been using version 2.3 of maven-assembly-plugin, but I believe the problem is the same: if the assembly configuration is declared inside an execution, it works from mvn package, but does not work from mvn assembly:assembly.
The solution I have found is to declare the configuration in the top-level configuration of the plugin, and keep the execution as small as possible:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/standalone.xml</descriptor>
</descriptors>
<finalName>standalone</finalName>
</configuration>
<executions>
<execution>
<id>standalone</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
It seems that you have configured the assembly plugin in <build>...<pluginManagement>...<plugins>. It should work if you configure the plugin in <build>...<plugins>.
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/src.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I was also facing the same issue with below command
$mvn clean assembly:single
But below command worked for me
$mvn clean assembly:assembly

Resources