soapUI and JUnit dependency issue - maven

I'm trying to use soapUI integrated to JUnit. I've tried to add the dependencies as mentioned here but it doesn't work. Some classes are not found.
In this post, it is proposed to add the soapui/lib directory to the classpath but this is not really a good practice with Maven.
Do you know which dependency(ies) to add to my project in order to integrate soapUI to JUnit?
Thanks

Depending on what you're trying to do with SoapUI, you may be able to use its Maven plugin, rather than try to integrate it with JUnit: http://www.soapui.org/Test-Automation/maven-2x.html. You can use this to e.g. start a SoapUI mock server, run integration tests that call a web service, then stop the mock server upon completion of the tests. See also the Failsafe plugin if you want to do this.
Failing that, you could add the Maven plugin to your test classpath. This should also pull in all of the dependencies required to run SoapUI itself:
<dependencies>
<dependency>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>4.5.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>eviware</id>
<url>http://www.eviware.com/repository/maven2/</url>
</repository>
</repositories>

You need to create an ext folder under your project and add your dependencies there. This is the directory SoapUI runner will look into, for all your external dependencies.

Related

In a Springboot Maven project, how to reference from another Jar?

I have a SpringBoot Maven project. I am dependent on another set of libraries. Currently am pointing to their repository path , downloading it to .m2 repository and using.
But the repository website is not reliable. SO I wanted to package the dependent libraries as part of JAR in the resources folder.
After putting the jars in resource folder. How can I get references of the Types/libraries ?
Currently:
<dependencies>
<dependency>
<groupId>org.dcm4che</groupId>
<artifactId>dcm4che-core</artifactId>
<version>5.23.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>www.dcm4che.org</id>
<name>dcm4che Repository</name>
<url>https://www.dcm4che.org/maven2</url>
</repository>
</repositories>
You can put all your libraries in a single folder either in your project or in some folder in your local. You can then add them to your maven POM.
Lets say you put all your jars in a folder called libs in your base project directory. You can then add something similar to the below in your maven POM.
<groupId>com.abc.xyz</groupId>
<artifactId>my-artifact-id</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/libs/my-jar-name.jar</systemPath>
You need to use the scope system. Excerpt from Maven website,
Scope : system - This scope is similar to provided except that you
have to provide the JAR which contains it explicitly. The artifact is
always available and is not looked up in a repository.
Maven Documentation
If you read further, it also mentions that this has been deprecated. So, its a nice quickfix or a hack but then the best thing would be to set up a repository manager as suggested by others.

Munit in Jenkins with dependency on Domain projects

I have Mule Project "A" which refers a Domain Project "X". I would like to run my MUnits for Project "A" in Jenkins but it fails as it's unable to find the dependency Domain project "X".
To resolve this I added the "dependency" for domain project"A" in, project "X" pom. xml. But no luck.
Please give me details how it can be resolved to run my MUnits ion Jenkins as a post-build action.
Thanks,
Ikram
to be able to do that I had to:
First, add the domain dependency in your pom with "test" scope
<dependency>
<groupId>com.mygroupid</groupId>
<artifactId>mule-domain-id</artifactId>
<version>1.0.0</version>
<scope>test</scope>
<type>zip</type>
</dependency>
Second, you have to install the domain artifact in one artifact repository (Nexus for example).This way, the dependency is accessible from Jenkins. And then add that repository to your pom.xml
<repositories>
<repository>
<id>alm-nexus</id>
<name>ALM Nexus Repo</name>
<url>https://nexus.alm.corp/repository/maven-public</url>
<layout>default</layout>
</repository>
</repositories>
One important thing when runing MUnits in Jenkins is the following. The root folder name has to be exactly the same as the artifactId, so in Jenkins you have to set the workspace with a custom one
If using a Jenkinsfile you can do this with the following:
customWorkspace
"${env.JOB_NAME}/${env.BUILD_ID}/artifact-id-has-to-go-here"
With these steps we are able to have a working pipeline with MUnit testing as one of the stages.

Maven doesn't find an existing remote artifact

I'm trying to use docker-compose-rule to run docker-compose files in junit integration tests.
I use the following dependency in my pom.xml file:
<dependency>
<groupId>com.palantir.docker.compose</groupId>
<artifactId>docker-compose-rule-core</artifactId>
<version>0.32.0</version>
<type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/com.palantir.docker.compose/docker-compose-rule-junit4 -->
<dependency>
<groupId>com.palantir.docker.compose</groupId>
<artifactId>docker-compose-rule-junit4</artifactId>
<version>0.32.0</version>
</dependency>
but for some reason the artifact is not found by maven (for none of the available versions).
As far as I can say, the artifact is found in the jcenter as shows in bintray.
It also exists on maven repository.
Can someone please tell why can't I use these libraries?
Alternatively, can I reference maven to take the library from a specific url with a specific jar file, for example from github, or from here?
According to mvnrepository, the jar you are looking for is not in the maven default Central repository, but is in the Palantir repository. You can add
<repositories>
<repository>
<id>Palantir</id>
<url>https://dl.bintray.com/palantir/releases/</url>
</repository>
</repositories>
into your pom.xml, and try again.

Use maven to "extend" existing jar file

My project contains a couple of class which have to be integrated into an final jar file.
So my current "workflow" looks like:
mvn compile && jar uf contribution.jar -C target/classes .
I guess this could be done with the maven-jar plugin or through maven-assemblies but can't figure out how.
Simple - add the element <packaging>jar</packaging> to your pom.xml and invoke the following:
mvn package
See Maven build lifecycle for more information. It really is a must-read if you're planning to use Maven for you project.
Edit
Thanks for the update, I know understand what you mean. There may be a better way to do this, but this is what I use:
Maven will automatically include this jar if you add it as a dependency in the usual way, i.e:
<dependencies>
...
<dependency>
<groupId>some.group</groupId>
<artifactId>contribution</artifactId>
<version>1.0.0</version>
</dependency>
...
</dependencies>
The question is how to ensure that maven can find the jar? If the jar were in the Maven Global repository it would find it automatically, so always check this first. If not, then you will have to create your own repository to store custom jars. This may not be the most clever way to do it, but it's how I do it. Note that this is not the same thing as the cache stored in the .m2 folder.
Let's say we want to use c:\maven\repo as our local. To do this, first ensure the folder exists then add the following lines to your pom.xml:
<repositories>
<repository>
<id>my-repo</id>
<url>file://c:\maven\repo</url>
</repository>
</repositories>
Next, you will need to manually add the contribution jar to this repo. To do this execute the mvn deploy:deploy-file command and give it the appropriate values. See here for more information.
Now when build/compile/package your original project, it should include contribution.jar in the packaging as it is a dependency.
Hope this helps :)

Skipping Maven Test Dependency

I am working on a project that use maven for building. What I am trying to do is to skip the test dependency. Basically running the maven build without the presence of artifact in my maven repository.
eg
<artifactId>example</artifactId>
<scope>test</scope>
This is from the pom file of my project and I have to maven build my project without having artifact example.
I have searched for solution such as use "-DskipTests=true" or "-Dmaven.test.skip=true". In my case they did skip the running of the tests but it still complains missing dependency file.
Does anyone know a way to run maven build without having to have test artifact in the maven repository?
Thanks.
See https://issues.apache.org/jira/browse/MNG-4192. I think the only way around it is to move the test-scoped dependency into a Maven profile.
Here is an example:
<profile>
<id>test-with-extra-dependency</id>
<dependencies>
<dependency>
<groupId>org.example.groupid</groupId>
<artifactId>artifact-id</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
You should now be able to run a build without tests:
mvn clean install -Dmaven.test.skip=true -DskipTests=true
After that you can run the tests with the profile enabled:
mvn test --activate-profiles test-with-extra-dependency
I wouldn't advise it, but this can be useful in case of a circular dependency between the current module and the test dependency, i.e. you can build the module, then build the test dependency using the build result, and finally test the module with the test dependency. If you find yourself wanting to do that, please try to restructure your project to eliminate the circular dependency (eg by moving the tests to a third module).

Resources