How to integrate and use ReportNG - automated-tests

Added the following .jar files to TestNG suite
reportng-1.1.4.jar
velocity-dep-1.4.jar
guice-3.0.jar
turned off the default listeners of the same. But reportNG is not working. The results are shown by TestNG.

Add velocity-1.4.jar too.It is different from velocity-dep-1.4.jar.
Also add the listener for HTMLReporter in your xml file.
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
</listeners>
In case you wanted to know all the jars needed you can use maven dependency in a dummy project . This will download the jars on maven build and you can copy the jars from there for your project.
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
</dependency>

Related

karaf: linking my code to a jar file

I am writing a karaf bundle which depends on an external jar library. I understand I may import this bundle in my features.xml using wrap but this means it gets loaded into its own classloader.
What I want is for my bundle's classloader to load whatever I access in this jar file and I want to make direct method calls to the classes in this jar file. How can I do this?
I don't want a new bundle - just a library that I can link my application to.
Thanks,
You can try to embed the external jar when building your bundle as follow:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
...,
root_package_in_external_jar*,
...
</Export-Package>
<Import-Package>
...
</Import-Package>
<Embed-Dependency>your_external_jar</Embed-Dependency>
</instructions>
</configuration>
</plugin>

Embedding Dependency in JAR with maven-bundle-plugin not working

I'm suceeded with adding OSGi specific meta-data to the MANIFEST of the flying-saucer-pdf Maven artifact. However, I do not succeed with embedding the dependencies and transitive dependencies of that artifact into the created JAR file.
I was using the original sources from flying-saucer-pdf taken from GitHub [1] and added the following statements to the pom.xml file:
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<instructions>
<Embed-Dependency>itext</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</execution>
</executions>
</plugin>
The artifact has a dependency declared to itext version 2.1.7 in its original pom.xml which I did not touch. I also did not mess with the original packaging type of the artifact which is jar.
Unfortunately, this does only part of the work. The MANIFEST.MF seems correct and contains the expected OSGi tags:
Manifest-Version: 1.0
Bundle-Description: Flying Saucer is a CSS 2.1 renderer written in Jav
a. This artifact supports PDF output.
Bundle-License: http://www.gnu.org/licenses/lgpl.html
Bundle-SymbolicName: org.xhtmlrenderer.flying-saucer-pdf
Archiver-Version: Plexus Archiver
Built-By: u0400072
Bnd-LastModified: 1478168053263
Bundle-ManifestVersion: 2
Embed-Dependency: itext
Import-Package: com.apple.mrj,com.lowagie.toolbox,javax.crypto,javax.i
mageio,javax.imageio.metadata,javax.imageio.plugins.jpeg,javax.imagei
o.stream,javax.swing,javax.xml.parsers,javax.xml.transform,javax.xml.
transform.dom,javax.xml.transform.sax,javax.xml.transform.stream,org.
bouncycastle.asn1,org.bouncycastle.asn1.cmp,org.bouncycastle.asn1.cms
,org.bouncycastle.asn1.ocsp,org.bouncycastle.asn1.pkcs,org.bouncycast
le.asn1.tsp,org.bouncycastle.asn1.x509,org.bouncycastle.cms,org.bounc
ycastle.crypto,org.bouncycastle.crypto.engines,org.bouncycastle.crypt
o.modes,org.bouncycastle.crypto.paddings,org.bouncycastle.crypto.para
ms,org.bouncycastle.jce.provider,org.bouncycastle.ocsp,org.bouncycast
le.tsp,org.w3c.dom,org.xhtmlrenderer.context,org.xhtmlrenderer.css.co
nstants,org.xhtmlrenderer.css.extend,org.xhtmlrenderer.css.parser,org
.xhtmlrenderer.css.sheet,org.xhtmlrenderer.css.style,org.xhtmlrendere
r.css.style.derived,org.xhtmlrenderer.css.value,org.xhtmlrenderer.ext
end,org.xhtmlrenderer.layout,org.xhtmlrenderer.render,org.xhtmlrender
er.resource,org.xhtmlrenderer.simple.extend,org.xhtmlrenderer.swing,o
rg.xhtmlrenderer.util,org.xml.sax,org.xml.sax.helpers
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.6))"
Tool: Bnd-3.2.0.201605172007
Embedded-Artifacts: itext-2.1.7.jar;g="com.lowagie";a="itext";v="2.1.7
"
Export-Package: org.xhtmlrenderer.pdf;uses:="org.w3c.dom,org.xhtmlrend
erer.css.constants,org.xhtmlrenderer.css.parser,org.xhtmlrenderer.css
.style,org.xhtmlrenderer.css.value,org.xhtmlrenderer.extend,org.xhtml
renderer.layout,org.xhtmlrenderer.render,org.xhtmlrenderer.resource,o
rg.xhtmlrenderer.simple.extend,org.xhtmlrenderer.swing,org.xml.sax";v
ersion="9.0.10",org.xhtmlrenderer.pdf.util;uses:="org.w3c.dom,org.xht
mlrenderer.pdf";version="9.0.10",org.xhtmlrenderer.simple;uses:="java
x.swing,org.w3c.dom,org.xhtmlrenderer.css.extend,org.xhtmlrenderer.cs
s.sheet,org.xhtmlrenderer.extend,org.xhtmlrenderer.layout,org.xhtmlre
nderer.swing,org.xhtmlrenderer.util";version="9.0.10"
Bundle-Name: Flying Saucer PDF Rendering
Bundle-Version: 9.0.10.SNAPSHOT
Bundle-ClassPath: .,itext-2.1.7.jar
Embed-Transitive: true
Created-By: Apache Maven Bundle Plugin
Build-Jdk: 1.8.0_102
But the itext library is not put into the resulting JAR, i.e. the Bundle-ClassPath entry of the MANIFEST points to a missing content.
In addition I tried to create an entirely new artifact which declares a dependency to the original flying-saucer-pdf artifact and re-bundles it as an OSGi bundle flowing this answer [2] here on StackOverflow and this worked.
The only real difference that I can see is the packaging type 'bundle' vs. 'jar'. But I cannot change that packaging type in the original flying-saucer-pdf artifact since everything needs to stay as is for non-OSGi-usages in order to get that change accepted as a Push Request.
Do you guys know if this embedding dependencies with the maven-bundle-plugin can actually work with the packaging type 'jar'? Or does it need the packaging type 'bundle'?
I appreciate any response and hint of what I could try to get that re-bundling done directly within the original artifact.
Thank you very much.
Regards
Timo Rohrberg
There are two ways to use the maven bundle plugin.
The first way is to use
<extensions>true</extensions> and <packaging>bundle</packaging>
In this case the maven bundle plugin is in charge of all build steps and can influence the jar file contents.
The second way is to use the manifest goal and add the manifest in the jar plugin. In this case maven bundle plugin can only influence the jar. It can not embed any other library or copy over external private classes.
So if you need embedding then the only way is to change the packaging.
So I think there are two solutions that do not influence the original jar too much.
Do not embed and install the dependencies as bundles
Create a spearate module in the build to create a bundle that is then available additionally to the original jar

Adding of external jar file into classpath for jBoss 7

I would like to include external jar files into classpath for all configurations of jBoss7.
Is there any way to do this without moving my files somewhere into jboss lib directories? Or better - is there any way to include all jar files in some external directory?
No answer actually outlines exactly what to do here so here goes.
In your jboss-deployment-structure.xml file, which should be in webapp/WEB-INF you need to add the module reference :
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<dependencies>
<module name="javaee.api">
<imports>
<exclude path="org/apache/xml/security/**" />
</imports>
</module>
<module name="com.sun.xml.bind" slot="main" />
<module name="com.mycompany.mypackage" slot="1_0" />
<module name="com.oracle.ojdbc14" slot="main" />
</dependencies>
</deployment>
</jboss-deployment-structure>
then copy the jar file this dir :
C:\[JBoss-Home]\modules\com\mycompany\mypackage\1_0
There's a directory called modules where you can put your jars. But to know how to do that you should read this guide. You may also create a global module that is accessible to all deployments. Look at this doc.

Sonar Analysis for website project - ASP.NET

I was trying to build and analyze a asp.net website project using maven
Command I used :
mvn sonar:sonar -e
I have single pom file in my root directory(same directory where website.sln is stored).
Directory structure:
|---Website (website project file)
|
|---website.sln
|---pom.xml
|
Result of executing command was : Build Error -Embedded error: Unable to execute maven plugin
I did same things and I could successfully build a web application project and console application project(which have visual studio project file). I thing reason for not working for website project is it does not have .csproj file inside website folder.
So how could successfully build and analyze a website project using maven.
Could someone please help me to fix this issue.
this is my pom file:
http://maven.apache.org/maven-v4_0_0.xsd">
<groupId>MindTree</groupId>
<artifactId>webbssite</artifactId>
<version>1.0</version>
<modelVersion>4.0.0</modelVersion>
<name>Maya</name>
<packaging>sln</packaging>
<url>http://maven.apache.org</url>
<properties>
<!--
NOTE : the versions and parameters may be defined as properties.
Prefer this option to the plugin configuration as it may be accessible to several plugins
-->
<!-- Name of the solution file, located in the same directory as the pom.xml -->
<visual.studio.solution>website.sln</visual.studio.solution>
<!-- Name pattern to recognize the test assemblies, so that unit tests are only launched on those,
and so that those are excluded from code coverage -->
<visual.test.project.pattern>*.Tests</visual.test.project.pattern>
<!-- Version of the .Net tools, which may be 2.0 or 3.5 only -->
<dotnet.tool.version>4.0</dotnet.tool.version>
<sonar.language>cs</sonar.language>
<msbuild.configurations>Debug</msbuild.configurations>
<maven.site.generateReports>false</maven.site.generateReports>
<sonar.dynamicAnalysis>false</sonar.dynamicAnalysis>
<sonar.cpd.skip>true</sonar.cpd.skip>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.sonar-plugins.dotnet</groupId>
<artifactId>maven-dotnet-plugin</artifactId>
<version>0.6</version>
<configuration>
<solutionName>website.sln</solutionName>
<language>cs</language>
<toolVersion>3.5</toolVersion>
<Platform>x86</Platform>
<buildConfigurations>Release,Debug</buildConfigurations>
<rebuild>true</rebuild>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
You should rather send a mail to the user mailing list.
Anyway I have the feeling there is a misunderstanding between the "maven dotnet plugin" and the "sonar maven plugin".
The "maven dotnet plugin" provides the ability to build dotnet visual studio solution with maven. It relies mostly on msbuild.
The "sonar maven dotnet plugin" alows to bootstrap a sonar analysis with maven.
Check out the second pom example on the following page : Maven .NET Plugin
Both plugins need to be configured if you want to use maven to build and analyse your solution.
That being said, you should know that neither maven nor those two plugins are mandatory to analyse a C# project with sonar. You could use whatever build tool you want to compile your solution (i.e. msbuild, nant)and you could use the simple sonar java runner to trigger the analysis.
Check out the official wiki and feel free to ask questions to the user mailing list.
You can subscribe easily here : Support

Bundling wsdl in jar with CXF wsdl2java

I'm working on an implementation that will use a wsdl that I have gotten from a vendor. Our project is running on Spring and CXF, and I'd like to create a jar that will allow me to access this vendor's wsdl services, but I'm running into classpath issues.
Using CXF's wsdl2java I am able to generate code that acts like this:
WSDL_LOCATION = new URL("file:SomeService.wsdl");
The service requires the wsdl to be in the classpath, but I would like to bundle it in the jar so that it is distributable as a stand-alone jar. Using the wsdl2java tool, I am able to specify the string in the URL instantiation to whatever I would like. However, I have not found a combination of a custom string and wsdl file location inside the jar that works.
The only way I have gotten this to work as I want is to put the wsdl file in the same folder that the SomeService.class is and use the following line:
WSDL_LOCATION = TrackService.class.getResource("TrackService_v4.wsdl");
However, this has the downside of me having to manually edit the java code and compile it myself. This is undesirable because we would eventually like to make this process part of our maven build and have wsdl2java do the generation and compilation by itself automatically.
I am OK with the wsdl being anywhere in the jar, but I don't know what to pass in to wsdl2java to have it reference a file inside the jar.
Does anyone have any suggestions or experience doing this?
You need to specify the classpath wsdl location as follows to generate the stubs that uses ClassLoader to load this wsdl as classpath resource:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.4.3</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>2.4.3</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf
</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/yourWSDL.wsdl</wsdl>
<extraargs>
<extraarg>**-wsdlLocation**</extraarg>
<extraarg>**classpath:yourWSDL.wsdl**</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
I've run into the same issue - I've got the following workaround but I'm still searching for something cleaner.
Keep your wsdls in src/main/resources/wsdl
Do the following when you create your TrackService:
URL wsdlUrl = TrackService.class.getResource( "/wsdl/TrackService_v4.wsdl" );
TrackService service = new TrackService( wsdlUrl );
The ideal solution would be to pass the location as a <wsdlLocation/> element into the CXF wsdl2java plugin. Then your client code could call the default constructor. However the stub code that is generated does not allow you to specify a wsdl file that is on the classpath.
The CXF Documentation solves it in the same way:
URL wsdl = getClass().getResource("wsdl/greeting.wsdl");
SOAPService service = new SOAPService(wsdl, serviceName);
Another option provided is the JaxWsProxyFactoryBean:
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
proxyFactory.setServiceClass(MyService.class);
proxyFactory.setWsdlLocation("/wsdl/MyService.wsdl");
If you also need to adjust the endpoint URL then you could add:
proxyFactory.setAddress("http://192.168.0.2:6666/");

Resources