Target runtime WildFly is unpacked after maven tests - java

I'm currently building a new package for Hibernate project Hibernate Search and I need to run some unit tests in a managed WildFly container using Arquillian. When I use the command mvn clean install, I got the below error :
org.jboss.arquillian.container.spi.ConfigurationException: jbossHome '${project.build.directory}/node1/wildfly-${org.wildfly}' must exist
This property is configured in ./src/test/resources/arquillian.xml. Having this exception is "normal" because it has reason: the target folder ./target/node1/wildfly-10.0.0.Final does not exist. However, this path should have been configured in maven pom.xml. So I try to run maven install without tests :
Mincongs-MBP:gsoc-hsearch mincong$ mvn clean install -DskipTests=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Hibernate Search - JSR352 5.6.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # hs-jsr352 ---
[INFO] Deleting /Users/mincong/Documents/GitHub/gsoc-hsearch/target
[INFO]
[INFO] --- dependencypath-maven-plugin:1.1.1:set (set-all) # hs-jsr352 ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # hs-jsr352 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # hs-jsr352 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 16 source files to /Users/mincong/Documents/GitHub/gsoc-hsearch/target/classes
[INFO] /Users/mincong/Documents/GitHub/gsoc-hsearch/src/main/java/org/hibernate/search/jsr352/internal/IndexingContext.java: Some input files use or override a deprecated API.
[INFO] /Users/mincong/Documents/GitHub/gsoc-hsearch/src/main/java/org/hibernate/search/jsr352/internal/IndexingContext.java: Recompile with -Xlint:deprecation for details.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # hs-jsr352 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) # hs-jsr352 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to /Users/mincong/Documents/GitHub/gsoc-hsearch/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) # hs-jsr352 ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.6:war (default-war) # hs-jsr352 ---
[INFO] Packaging webapp
[INFO] Assembling webapp [hs-jsr352] in [/Users/mincong/Documents/GitHub/gsoc-hsearch/target/hs-jsr352-5.6.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/mincong/Documents/GitHub/gsoc-hsearch/src/main/webapp]
[INFO] Webapp assembled in [113 msecs]
[INFO] Building war: /Users/mincong/Documents/GitHub/gsoc-hsearch/target/hs-jsr352-5.6.0-SNAPSHOT.war
[INFO]
[INFO] --- maven-dependency-plugin:2.6:unpack (unpack) # hs-jsr352 ---
[INFO] Configured Artifact: org.wildfly:wildfly-dist:10.0.0.Final:zip
[INFO] Unpacking /Users/mincong/.m2/repository/org/wildfly/wildfly-dist/10.0.0.Final/wildfly-dist-10.0.0.Final.zip to /Users/mincong/Documents/GitHub/gsoc-hsearch/target/node1 with includes "" and excludes ""
[INFO]
[INFO] --- maven-resources-plugin:2.6:copy-resources (configure-as-node-node1) # hs-jsr352 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/mincong/Documents/GitHub/gsoc-hsearch/src/wildflyConfig
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # hs-jsr352 ---
[INFO] Installing /Users/mincong/Documents/GitHub/gsoc-hsearch/target/hs-jsr352-5.6.0-SNAPSHOT.war to /Users/mincong/.m2/repository/io/github/mincongh/hs-jsr352/5.6.0-SNAPSHOT/hs-jsr352-5.6.0-SNAPSHOT.war
[INFO] Installing /Users/mincong/Documents/GitHub/gsoc-hsearch/pom.xml to /Users/mincong/.m2/repository/io/github/mincongh/hs-jsr352/5.6.0-SNAPSHOT/hs-jsr352-5.6.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.274 s
[INFO] Finished at: 2016-06-18T16:01:51+02:00
[INFO] Final Memory: 36M/280M
[INFO] ------------------------------------------------------------------------
And I noticed that :
Tests are located at step 7
WildFly installation is located at step 9
So tests are launched before runtime setup. Therefore, my questions are:
How to make sure the managed runtime WildFly 10 get unpacked before the tests ?
For my test class DeployementTest, is it part of the pre-integration / integration test ?
If yes, should I use an additional module for it ?
I'm really new on all these fields. Please forgive me if I'm mixing words up or asking stupid questions ... Thanks for your help !
Here're some related files that might be helpful :
./pom.xml
./src/test/resources/arquillian.xml
./src/test/java/org/hibernate/search/jsr352/DeploymentTest.java
./pom.xml
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.mincongh</groupId>
<artifactId>hs-jsr352</artifactId>
<version>5.6.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Hibernate Search - JSR352</name>
<description>New implementation mass-indexer using JSR 352</description>
<properties>
<org.jboss.arquillian.version>1.1.1.Final</org.jboss.arquillian.version>
<org.wildfly>10.0.0.Final</org.wildfly>
<org.wildfly.arquillian>8.2.1.Final</org.wildfly.arquillian>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<profiles>
<profile>
<id>perf</id>
<properties>
<org.hibernate.search.enable_performance_tests>true</org.hibernate.search.enable_performance_tests>
</properties>
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.11.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.5.3.Final</version>
<!--
<exclusions>
<exclusion>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</exclusion>
</exclusions>
-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.batch</groupId>
<artifactId>javax.batch-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<!-- Not sure the version of EJB, this is provided by GlassFish -->
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>${org.wildfly.arquillian}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.logmanager</groupId>
<artifactId>log4j-jboss-logmanager</artifactId>
</exclusion>
<!-- This exclusion is needed to be able to setup the project in Windows:
it otherwise includes transitive dependency to the JDK JConsole -->
<exclusion>
<artifactId>wildfly-patching</artifactId>
<groupId>org.wildfly</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<!-- Allows to find the absolute path to dependencies -->
<groupId>org.bitstrings.maven.plugins</groupId>
<artifactId>dependencypath-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>set-all</id>
<goals>
<goal>set</goal>
</goals>
<configuration>
<propertySets>
<propertySet>
<includes>
<include>org.jboss.byteman:byteman:jar</include>
</includes>
</propertySet>
</propertySets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<runOrder>alphabetical</runOrder>
<systemPropertyVariables>
<!-- See HSEARCH-1444 -->
<hibernate.service.allow_crawling>false</hibernate.service.allow_crawling>
<com.sun.management.jmxremote>true</com.sun.management.jmxremote>
<org.hibernate.search.enable_performance_tests>${org.hibernate.search.enable_performance_tests}</org.hibernate.search.enable_performance_tests>
</systemPropertyVariables>
<additionalClasspathElements>
<!-- Needed by Byteman to load the agent on demand -->
<additionalClasspathElement>${jdk-toolsjar}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>unpack</id>
<phase>pre-integration-test</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${org.wildfly}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/node1</outputDirectory>
</artifactItem>
<!--
<artifactItem>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-modules</artifactId>
<version>${project.version}</version>
<classifier>wildfly-10-dist</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/node1/wildfly-${org.wildfly}/modules</outputDirectory>
</artifactItem>
-->
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<!-- Copy the AS configuration files so we can use our custom configurations -->
<execution>
<id>configure-as-node-node1</id>
<!-- <phase>pre-integration-test</phase> -->
<phase>integration-test</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/node1/wildfly-${org.wildfly}</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${basedir}/src/wildflyConfig</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
./src/test/resources/arquillian.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate Search, full-text search for your domain model
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<defaultProtocol type="Servlet 3.0" />
<!-- Uncomment in order to inspect deployments -->
<!--
<engine>
<property name="deploymentExportPath">target/deployments</property>
</engine>
-->
<group qualifier="Grid" default="true">
<container qualifier="container.active-1" mode="suite" default="true">
<configuration>
<property name="jbossHome">${project.build.directory}/node1/wildfly-${org.wildfly}</property>
<!-- Needed for JMS tests -->
<property name="serverConfig">standalone-full-testqueues.xml</property>
<property name="javaVmArguments">-javaagent:${byteman.agent.path}=script:${byteman.script.path} -Xmx512m -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1</property>
<!-- To debug the Arquillian managed application server: -->
<!-- property name="javaVmArguments">-javaagent:${byteman.agent.path}=script:${byteman.script.path} -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y -Xmx512m -Dorg.jboss.remoting-jmx.timeout=300 -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1</property -->
</configuration>
</container>
</group>
</arquillian>
./src/test/java/org/hibernate/search/jsr352/DeploymentTest.java
package org.hibernate.search.jsr352;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
#RunWith(Arquillian.class)
public class DeploymentTest {
#Deployment
public static WebArchive createDeployment() {
WebArchive war = ShrinkWrap.create(WebArchive.class)
.addPackages(true, "io.github.mincongh")
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addAsResource("META-INF/batch-jobs/mass-index.xml");
System.out.println(war.toString(true));
return war;
}
#Test
public void startJob() {
// TODO: add tasks here
}
}

Perhaps you're mixing up Maven Surefire and Failsafe plugins.
DeploymentTest above is a unit test, not an IT test, that will be executed by Surefire. Therefore, if you're looking to unpack WildFly using maven-dependency-plugin, you'll need to bind unpack to a phase such as <phase>process-test-classes</phase>, that will execute before Surefire does in the test phase.
Maven Lifecycle Reference:
https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference

Related

How to find package name once Maven dependency is added

I'm attempting to use the socket.io implementation for Java. I need 2 dependencies: 1) Engine.IO Java Server and 2) Socket.IO Server Java. I'm struggling to import the actual Java packages once the dependencies have been added to my pom.xml. Looking at the javadocs for Engine.IO Java Server, it looks like the package name to import should be io.socket.engineio.server. However, this results in an error (details below). For other dependencies that I add, what's the best way to find the package name to actually import the dependency in my Java source code?
I'm not using an IDE like IntelliJ/Eclipse. I'm just using a more simple text editor (VSCode) and a terminal. Also, I've ensured the dependencies are actually downloaded and installed in my ~/.m2/repository directory. Here are my files/terminal output.
Pom.xml
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>game-server</artifactId>
<version>1.0-SNAPSHOT</version>
<name>game-server</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.socket</groupId>
<artifactId>engine.io-server</artifactId>
<version>6.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.socket</groupId>
<artifactId>socket.io-server</artifactId>
<version>4.0.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.mycompany.app.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
App.java
package com.mycompany.app;
import io.socket.engineio.server;
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
Terminal Output
$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< com.mycompany.app:game-server >--------------------
[INFO] Building game-server 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) # game-server ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/josh/Repos/game/game-server/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # game-server ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/josh/Repos/game/game-server/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/josh/Repos/game/game-server/src/main/java/com/mycompany/app/App.java:[3,26] package io.socket.engineio does not exis

Junit test cases not running using maven

I am trying to run a maven test for the following pom. But no tests re getting picked up. Though in the maven tests its showing that the test is being compiled. I am using JUnit 4.12. I tried several things and found out that the parent pom is causing the issues. If I remove the parent pom and give its own group id and artifact Id it's working.
Can some please explain to me why it's not working with the parent pom and provide a solution for it.
<parent>
<groupId>com.test</groupId>
<artifactId>test-parent</artifactId>
<version>20.6.0</version>
</parent>
<artifactId>ai_one_click</artifactId>
<name>one_click</name>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>data_model</artifactId>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.23.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<executions>
<execution>
<configuration>
<includes> <include>**/Test1.java</include> </includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # ai_one_click ---
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-cli) # ai_one_click ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to one_click\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-cli) # ai_one_click ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
I tried with various maven commands
clean surefire:test
clean test
clean -D maven.test.failure.ignore=true compiler:testCompile surefire:test
test -Dtest=Test1

com.thoughtworks.xstream.converters.ConversionException while running jmeter script using maven eclipse

I have integrated my jmeter script with maven. I have jmeter plugin manager also. While running it, i am getting java.lang.IllegalArgumentException which is resulting into above exception. I have added dependency for jmeter plugin manager and xstream but still i am getting same error.
exactly same kind of issue has been discussed here, but the content now has been removed.
https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/issues/194
pom file -
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test_framework</groupId>
<artifactId>api_test_plan</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>dkc_api_test_plan</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<ThreadCount.thread1>10</ThreadCount.thread1>
</properties>
<build>
<plugins>
<!-- jmeter plugin to run jmeter through maven build -->
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<resultsFileFormat>xml</resultsFileFormat>
<generateReports>false</generateReports>
<testResultsTimestamp>false</testResultsTimestamp>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins:pom:1.3.1</artifact>
</jmeterExtensions>
<!-- inputFile>${project.build.directory}/jmeter/results/CreateOrderLoadTest.jtl</inputFile -->
</configuration>
</plugin>
<!--surefire plugin to generate html reports -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<outputFolder>${project.build.directory}/target/surefire-reports</outputFolder>
<printReport>true</printReport>
<exportAll>true</exportAll>
</configuration>
</plugin>
<!-- plugin> <groupId>com.lazerycode.jmeter</groupId> <artifactId>jmeter-analysis-maven-plugin</artifactId>
<version>1.0.4</version> <configuration> <source>${project.build.directory}/jmeter/results/dkc_sales.jtl</source>
</configuration> <executions> <execution> <id>create-html-report</id> <phase>verify</phase>
<goals> <goal>analyze</goal> </goals> </execution> </executions> </plugin -->
</plugins>
<!-- https://mvnrepository.com/artifact/junit/junit -->
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_java</artifactId>
<version>3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/kg.apc/jmeter-plugins-manager <dependency>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins-manager</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
</project> ```
-------------------------------------------------------
[INFO] P E R F O R M A N C E T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO]
[INFO] Executing test: myFile.jmx
[INFO] Starting process with:[java, -Xms512M, -Xmx512M, -jar, ApacheJMeter-4.0.jar, -d, D:\Projects\....
[INFO] Error in NonGUIDriver java.lang.IllegalArgumentException: Problem loading XML from:'D:\Projects\\target\jmeter\testFiles\myFile.jmx', missing class com.thoughtworks.xstream.converters.ConversionException:
[INFO] ---- Debugging information ----
[INFO] cause-exception : com.thoughtworks.xstream.converters.ConversionException
[INFO] cause-message :
[INFO] first-jmeter-class : org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
[INFO] class : org.apache.jmeter.save.ScriptWrapper
[INFO] required-type : org.apache.jorphan.collections.ListedHashTree
[INFO] converter-type : org.apache.jmeter.save.ScriptWrapperConverter
[INFO] path : /jmeterTestPlan/hashTree/hashTree/hashTree[3]/hashTree[5]/hashTree[4]/hashTree[3]/com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor
[INFO] line number : 3610
[INFO] version : 4.0 r1823414
[INFO] -------------------------------
[INFO] Completed Test: D:\Projects\Project_Name\api_test_plan\target\jmeter\testFiles\myFile.jmx
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 29.003 s
[INFO] Finished at: 2019-04-19T12:53:28+05:30
[INFO] Final Memory: 38M/282M
[INFO] ------------------------------------------------------------------------
[INFO] Shutdown detected, destroying JMeter process...**strong text**
Don’t use pom dependencies as you did in:
kg.apc:jmeter-plugins:pom:1.3.1
It should work

Blank Allure report due to misconfigured pom.xml

I'm trying to use Allure - framework to generate a report for my Rest Assured tests. I run tests with mvn test -Dtest=${MyClass} command and all tests pass, and then generate a report using mvn allure:report. After all, I start jetty server mvn jetty:run and when I navigate to localhost I can see a completely empty report (there is only template with no info).
This seems to be a misconfiguration problem, but what am I doing wrong? Here is my pom.xml:
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testtask</groupId>
<artifactId>com.testtask</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
<maven.surefire.plugin.version>3.0.0-M3</maven.surefire.plugin.version>
<aspectj.version>1.9.3.RC1</aspectj.version>
<jetty.maven.plugin.version>9.3.9.v20160517</jetty.maven.plugin.version>
<allure.maven.version>2.10.0</allure.maven.version>
<rest.assured.version>3.3.0</rest.assured.version>
<allure.rest.assured.version>2.10.0</allure.rest.assured.version>
<allure.testng.version>2.10.0</allure.testng.version>
<junit.version>4.12</junit.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!--Running tests-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<!--Server to view the report-->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.maven.plugin.version}</version>
<configuration>
<webAppSourceDirectory>${project.build.directory}/site/allure-maven-plugin</webAppSourceDirectory>
<stopKey>stop</stopKey>
<stopPort>1234</stopPort>
</configuration>
</plugin>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>${allure.maven.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<!--Rest Assured section-->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest.assured.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<version>${rest.assured.version}</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>xml-path</artifactId>
<version>${rest.assured.version}</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>${rest.assured.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-rest-assured</artifactId> <!--generates attachment for allure-->
<version>${allure.rest.assured.version}</version>
</dependency>
<!--Allure TestNG Dependency-->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>${allure.testng.version}</version>
</dependency>
<!-- Java 6 = JAX-B Version 2.0 -->
<!-- Java 7 = JAX-B Version 2.2.3 -->
<!-- Java 8 = JAX-B Version 2.2.8 -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
mvn allure:report
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.testtask:com.testtask >----------------------
[INFO] Building com.testtask 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- allure-maven:2.10.0:report (default-cli) # com.testtask ---
[INFO] Allure installation directory C:\PRJ\X\PetAPI/.allure
[INFO] Try to finding out allure 2.8.1
[INFO] Generate Allure report (report) with version 2.8.1
[INFO] Generate Allure report to C:\PRJ\X\PetAPI\target\site/allure-maven-plugin
[INFO] Found results directory C:\PRJ\X\PetAPI\target\allure-results
[INFO] Can't find information about categories.
[INFO] Generate report to C:\PRJ\X\PetAPI\target\site\allure-maven-plugin
Report successfully generated to C:\PRJ\X\PetAPI\target\site\allure-maven-plugin
[INFO] Report generated successfully.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.631 s
[INFO] Finished at: 2019-03-16T18:48:34+04:00
[INFO] ------------------------------------------------------------------------
mvn jetty:run
...
[INFO] --- jetty-maven-plugin:9.3.9.v20160517:run (default-cli) # com.testtask ---
[INFO] Configuring Jetty for project: com.testtask
[INFO] Webapp source directory = C:\PRJ\X\PetAPI\target\site\allure-maven-plugin
[INFO] Reload Mechanic: automatic
[INFO] Classes = C:\PRJ\X\PetAPI\target\classes
[INFO] Logging initialized #7207ms
[INFO] Context path = /
[INFO] Tmp directory = C:\PRJ\X\PetAPI\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = null
[INFO] Webapp directory = C:\PRJ\X\PetAPI\target\site\allure-maven-plugin
[INFO] jetty-9.3.9.v20160517
[INFO] Started o.e.j.m.p.JettyWebAppContext#4a734c04{/,file:///C:/PRJ/X/PetAPI/target/site/allure-maven-plugin/,AVAILABLE}{file:///C:/PRJ/X/PetAPI/target/site/allure-maven-plugin/}
[INFO] Started ServerConnector#24841372{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started #12047ms
[INFO] Started Jetty Server
Solution found: it was necessary to add a dependency on TestNG
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
and remove the dependency on Junit.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
Currently an Allure report is generated correctly

Maven can't read my Cucumber Test

I'm currently receiving this log when running 'mvn test'
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Envirosite-Regression 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Envirosite-Regression ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\christian.nuval\Envirosite-Regression\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # Envirosite-Regression ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Envirosite-Regression ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # Envirosite-Regression ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # Envirosite-Regression ---
[INFO] Surefire report directory: C:\Users\christian.nuval\Envirosite-Regression\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.EnvirositeRegression.bdd.IssueTest
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator#7a46a697
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.385 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.374 s
[INFO] Finished at: 2016-07-21T16:32:18+08:00
[INFO] Final Memory: 12M/225M
[INFO] ------------------------------------------------------------------------
My pom.xml looks like this :
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.EnvirositeRegression.bdd</groupId>
<artifactId>Envirosite-Regression</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Envirosite-Regression</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.1.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openqa.selenium.core</groupId>
<artifactId>selenium-core</artifactId>
<version>1.0-20080914.225453</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.14</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>cucumber-tests</id>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
My IssueTest.java looks like this :
package com.EnvirositeRegression.bdd;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#CucumberOptions(
format = { "pretty", "html:target/cucumber" },
glue = "com.EnvirositeRegression.bdd",
features = "SiteSearchTool.feature"
)
public class IssueTest {
}
I don't know why the IssueTest.Java is not properly read even though I added it as an inclusion in my build configuration of maven-surefire-plugin.
Please advise.
Your logs are showing SUCCESS with no executed tests because there are no tests to run i.e. no tests are written in your IssueTest. Try an example test-case, then run mvn test.
public class IssueTest {
#Test
public void exampleReturnsTrue()
{
assertTrue("This will succeed.", true);
}
}
A side-note:
If your tests are located where there supposed to be (./src/tests/java/); I suppose your pom.xml could do without the <configuration> [...] </configuration> clause, so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
You have 2 configuration tags one after another - try to remove one of them and see. Also, it's a good idea in cases like that to debug maven execution with -X flag.

Categories

Resources