I am attempting to POST test results to TestRails.
Using test suites and test cases, the tests in question were created using SoapUI. What I currently have will POST directly from SoapUI to TestRails. The company I work for wants to initiate the SoapUI tests using Maven, which is possible with a SoapUI plug-in for the Maven pom file. This part of the process works perfectly.
However, POSTing to the TestRails project only works if I initiate the tests via the SoapUI application. When I run the same tests via Maven, all the test steps complete and are visible in the stack trace, but none of the test case results are sent to TestRails.
What I have done is placed a plug-in in the pom file, which is supposed to connect Maven to TestRails and allow the transfer of the test results, but while there are no errors in the program, no POST is done.
Here's how I have it coded in my pom file:
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>5.1.2</version>
<configuration>
<settingsFile>${projectDir}\soapui-settings.xml</settingsFile>
<iface>mobileAdsService</iface>
<exportwAll>true</exportwAll>
<printReport>true</printReport>
<testFailIgnore>true</testFailIgnore>
<junitReport>true</junitReport>
<outputFolder>${projectDir}\TestResults</outputFolder>
<projectFile>${basedir}\Irdeto-v1.xml</projectFile>
<saveAfterRun>true</saveAfterRun>
</configuration>
<dependencies>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9-RC1</version>
</dependency>
***<dependency>
<groupId>com.codepine.api</groupId>
<artifactId>testrail-api-java-client</artifactId>
<version>1.0.0</version>
</dependency>***
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.10-FINAL</version>
<exclusions>
<exclusion>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<executions>
<execution>
<id>soapui-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
This appears to have been due to a bug in the non-licensed version of SoapUI.
Related
UPDATE: I realized that the problem was related to using the environment variables. When I didn't use them, it worked fine. The situation is exactly the same as this post. I don't know if it is the best solution, but for now I have disabled the test, using #Disabled annotation.
Hi,
I have a Spring Boot application. When I run it locally, I can use the DB just fine. I am able to create entities using my api, they are correctly created on the DB.
But when I run the tests for the app, the following error appears:
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
This is the application.properties:
spring.datasource.url=jdbc:mysql://localhost:${MYSQL_DB_PORT}/myproject-db
spring.datasource.username=${MYSQL_DB_USERNAME}
spring.datasource.password=${MYSQL_DB_PASSWORD}
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
server.servlet.context-path=/myproject-api/v1
(I have the environment variables set on IntelliJ Run Configurations)
These are the dependencies in my pom.xml:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
I know there are a lot of already answered questions about this, but nothing has worked for me so far.
Being in your shoes I would do the following:
setup maven surefire to pick up system properties from profile in ~/.m2/settings.xml, like:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<systemPropertyVariables>
<datasource.url>${db.url}</datasource.url>
<datasource.username>${db.username}</datasource.username>
<datasource.password>${db.password}</datasource.password>
</systemPropertyVariables>
</configuration>
</plugin>
setup maven profile in ~/.m2/settings.xml with the real values of placeholders:
<profiles>
<profile>
<id>localenv</id>
<properties>
<db.url>jdbc:mysql://localhost:3306/myproject-db</db.url>
<db.username>username</db.username>
<db.password>password</db.password>
</properties>
</profile>
</profiles>
place application.properties into src/test/resources with content like:
spring.datasource.url=${datasource.url}
spring.datasource.username=${datasource.username}
spring.datasource.password=${datasource.password}
after that tests should work because IntelliJ recognises such configuration
moreover, you may setup running main spring-boot class via IntelliJ without configuring environment variables but taking advantage of maven profile.
install SpringBoot Patcher plugin
place application.properties at the same level as src folder with content like:
spring.datasource.url=${datasource.url}
spring.datasource.username=${datasource.username}
spring.datasource.password=${datasource.password}
setup spring-boot-maven plugin like:
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>run-app</id>
<goals>
<goal>run</goal>
</goals>
<phase>none</phase>
<configuration>
<mainClass>com.tld.MyCoolaMainClass</mainClass>
<workingDirectory>${project.basedir}</workingDirectory>
<systemPropertyVariables>
<spring.datasource.url>${db.url}</spring.datasource.url>
<spring.datasource.username>${db.username}</spring.datasource.username>
<spring.datasource.password>${db.password}</spring.datasource.password>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
I'm running a little test project where I want my JUL logs to be redirected and appear as log4j2 logs.
I'm using the following Maven dependencies:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.0-M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jul</artifactId>
<version>2.13.3</version>
</dependency>
To use the log4j-jul adapter, I'm supposed to set the system property java.util.logging.manager to org.apache.logging.log4j.jul.LogManager.
When I do that in my project's main method with
System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager");
then logging works as desired. But if I use a JUnit test (run with mvn test) that does the same, like
#Test
public void loggingJULTest() {
System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager");
java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(MainTest.class.getName());
julLogger.info("Info Message from JUL");
julLogger.severe("Severe message from JUL");
julLogger.fine("Fine message from JUL");
}
then the logs appear in JUL style instead.
I tried to add the following configuration to Maven's Surefire Plugin in the pom.xml
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.apache.logging.log4j.jul.LogManager</java.util.logging.manager>
<buildDirectory>${project.build.directory}</buildDirectory>
</systemPropertyVariables>
</configuration>
but then the test gives no output and shows a warning
[WARNING] Corrupted STDOUT by directly writing to native stream in forked JVM 1. See FAQ web page and the dump file[..]
I'm confused about about what I'm supposed to be doing here.
If you are using version 3.0.0-M5 of the maven-surefire-plugin, you need to add <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/> to the configuration.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
...
</configuration>
</plugin>
</plugins>
</build>
Details: According to the Jira issue SUREFIRE-1614
P.S.: In the future for similar questions, please add version information for Java and Maven.
I am creating Rest client using JAX RS Jersey 2. The client works but only in my IDE (IntellIJ IDEA), when I build it with Maven, using maven-assembly-plugin and run the jar it doesn't work anymore.
I get MessageBodyWriter not found for media type=application/json error.
I have tried adding more dependencies that people suggested in other posts but I don't think a dependency is a problem since it runs in the IDE.
Here is the code that throws the exception
return client.target(uri)
.request(MediaType.APPLICATION_JSON)
.post(Entity.entity(transactions.get(0), MediaType.APPLICATION_JSON));
After debugging, when I replace transactions.get(0) with an empty string "", it works.
Here is the pom.xml for maven
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>SequencerControllers</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.25.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.25.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
</dependencies>
Am i missing something? Really bothers me that it runs in the IDE but not when built with Maven since I build it with dependencies.
Check if you have class com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in your resulting JAR. If not, add following dependency:
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.10.0</version>
</dependency>
there's an ordering issue as the Jackson and Jackson / jersey jars don't play well in an "uber" assembly jar. This is because they have same-named files in their individual jars that contain different values.
The assembly plugin will pick one version as the "winner" that gets included in the uber jar. The losing duplicate will not be included and in your case, you are likely getting the wrong copy included in your uber jar.
To fix this, make sure that these 2 entries are moved to the top of the maven dependencies list
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-version}</version>
</dependency>
I also moved this one at the bottom of the dependencies:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
</dependency>
That combination seemed to fix the uber jar issue in my situation.
I want to create Java-classes out of an MySQL-Database using hibernate. Just using eclipse and the Hibernate-Plugin, this works fine (described here: http://www.wikihow.com/Generate-Hibernate-Pojo-Classes-from-DB-Tables), but I want to do it with maven. This, after some tries, does not work.
Generelly, I have an hibernate.cfg.xml and a persistance.xml-file, both with the correct connection-information. I found some threads about howto generate the classes from java (for example How to configure hibernate-tools with maven to generate hibernate.cfg.xml, *.hbm.xml, POJOs and DAOs) and the documentation of the hibernate-maven-plugin (http://mojo.codehaus.org/hibernate3-maven-plugin).
I tried several code snippets, the most promising seems to me from: Maven Java Source Code Generation for Hibernate
I added the file I need, and I got:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
</execution>
</executions>
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>configuration</implementation>
<outputDirectory>target/generated-sources/hibernate3</outputDirectory>
</component>
</components>
<componentProperties>
<drop>true</drop>
<jdk5>true</jdk5>
<configurationfile>/src/main/java/hibernate.cfg.xml</configurationfile>
<packagename>de.unileipzig.database</packagename>
</componentProperties>
</configuration>
</plugin>
But unfortunately, when executing, I get
[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2java (default-cli) on project AWV: Execution default-cli of goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2java failed: An AnnotationConfiguration instance is required to use <mapping class="de.unileipzig.database.objectlist"/> -> [Help 1]
I googled the error, and found on http://www.mkyong.com/hibernate/hibernate-error-an-annotationconfiguration-instance-is-required-to-use/ that one has to add the dependency. It seemed somehow awkward to me, as I am using Hibernate 4 and the Maven Plugin for Hibernate 3 (the hibernate 4 plugin seems not to be practical usable for my case: http://www.smartics.eu/hibernate4-maven-plugin/ ), but I tried adding:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
(As the version specified at the Mykong-Post can't be found in my repositories).
Unfortunately, still, the error occurs. Does anybody have an hint how to solve this problem? Is there just an problem with the annotation-dependeny, or is my usage of the plugin not right?
After the advice of julschi, I added the following code to the plugin:
<plugin>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
</dependencies>
</plugin>
Unfortunately, this did not change anything. When I used the version I use in the project (Hibernate 4.2.7) it results in an error, that org.hibernate.util.StringHelper is not found; it seems to be moved to another package (https://docs.jboss.org/hibernate/orm/4.1/javadocs/org/hibernate/internal/util/StringHelper.html). But if I use the version 3.5.6-FINAL, I just get the same AnnotationConfiguration error.
If someone wants to try it out: the whole POM is here: http://nopaste.info/a70449bee6.html.
maybe create a dependencies section in the plugin part itself, like this:
<plugin>
...
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.2.144</version>
</dependency>
</dependencies>
...
</plugin>
I have a working application that persists to a database using JDO - I want to use a PersistenceCapable class that's in a second java module. Although the app compiles a simple test gives the error:
The class "com.hello.world.Foo" is not persistable This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.
Ok, so the enhancer plugin is not running on the classes in the second module. I'm not sure what i need to do to point the enhancer at that module during the build.
ParentProject
Second Module: com.hello.world.Foo
ParentProject pom.xml with relevant parts - problem is how do i point the enhancer at the second module containing my persistent class?
<dependencies>
<dependency>
<groupId>Second Module</groupId>
<artifactId>Second Module</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>[3.2.0, 3.2.99)</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>[3.2.0, 3.2.99)</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>[3.2.0, 3.2.99)</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>3.3.0-release</version>
<configuration>
<api>JDO</api>
<props>${basedir}/datanucleus.properties</props>
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
got it - i had to add the exact same pom.xml config in the question to the second module and do a mvn install to get those classes enahnced before compiling the parent module. Working on both Jetty and GAE. I thought, wrongly, that the parent module would enhance classes included in the module dependencies.
Thanks for your help DataNucleus!