cobertura code coverage for jetty server - jetty

Hi I am trying to get code coverage for my web application.
I Instrumented my compiled classes then I deployed it in jetty server.
then i ran my test cases from http client and i was expecting cobertura.ser file to be generated at server but it is not generated when I stop jetty server.
please let me know how can i get code coverage for web application from jetty.
I'm using java 1.7
I am not using maven.
I followed the steps based on below link.
Java: measure code coverage for remote scripting tests .

This is probably due to the fact that Cobertura dumps coverage data when the VM exits, not when the server stops.
You can have a look at the alternative maven plugin I wrote for Cobertura and its companion example project:
https://github.com/QualInsight/qualinsight-mojo-cobertura
https://github.com/pawlakm/qualinsight-mojo-cobertura-example
The documentation provided by the first link describes how to configure Jetty and with a small extension that dumps coverage data during server stop (see "Gathering IT test coverage data when running instrumented code on Jetty") This documentation is for Jetty 9.3, however the second link provides running examples for Jetty 7.6, 8.1, 9.2 and 9.3.
In your context, you should use wartest-jetty9.2.x module as it aimed at Jetty 9.2.x and JDK1.7. Have a look at the module's (and its parent) pom.xml file, as well as jetty.xml file
Do not hesitate to give feedback and ask questions, I'll do my best to help you.
Regards,

Related

what are the advantages of using maven to generate a WS client from a WSDL?

My WSDL contains 20 web services and I have to generate a WS client to invoke those web services.
I started with wsdl2java to generate the sub then I developed the JSP files and servlets and it seems to work, I am using Axis2 with Tomcat 7 on Eclipse, but many developers use Maven to do the work so I wonder what are the advantages of using Maven to create the client ?
I am a newbie so can you please explain to me this point in a level that I can understand.
Maven itself won't do it for you, it may only be used to trigger generate code for you. So it does not matter whether you use ant or maven or gradle from command line or within eclipse - in the end you always call the same mechanism to generate the portable artifacts from the WSDL.

How to change PaxExam port

I have a successfully running suite of integration tests using PaxExam. I run the tests using Maven. The purpose of the tests is to test REST web services implemented through Apache CXF running in Karaf.
The tests run on my machine but fail during Jenkins build due to port conflict. The CXF uses port 8181 which seems to be the default Jetty port. Is there a way to change this port declaratively or programmatically in the tests suite?
I tried using a variety of PaxExam options listed here:
http://team.ops4j.org/wiki/display/PAXEXAM3/Configuration+Options, but to no avail.
Thank you.
Do you use Pax-Exam-Karaf or do you use plain Pax-Exam,
if it's Pax-Exam-Karaf use the following for your configuration:
KarafDistributionOption.editConfigurationFilePut("etc/org.ops4j.pax.web.cfg",
"org.osgi.service.http.port", "alternative-port"),
if it's plain Pax-Exam:
systemProperty("org.osgi.service.http.port").value("8181")
You might also take a look on how Karaf does it's regression testing at Karaf Regression Test or take a look at the pax-web itests at Pax-Web Integration Tests

TestNG unit test at maven install, install ->deploy to jetty ->start jetty ->run test -> stop server

I have a maven project.
I want to test (spring) controller class and also wrote a test class.To successfully run this test class,I want the web app to be deployed in the (jetty )server.
How I can achieve this, when I execute maven clean install.project is
built->deployed to server->start server->run test->stop server
I have been looking at jetty plugin and cargo plugin but still finding it difficult to do what I want.
If you want to unit test your spring controllers, you do not need to have your web application deployed to jetty. Spring framework has testing support as documented here.
There are many examples in the web. You can also refer to the test classes here which uses testNG.
If you do want to run tests in jetty, then refer to these instructions. Essentially you would bind the jetty start and stop to pre-integration-test and post-integration-test phases.

Using Axis to generate a web service implementation that calls another web service

I need to provide an implementation of a web service for which I have the WSDL, to run under Weblogic 9.2.
I aim to use the Axis (1, not 2) tools for this , having tried and failed to make it work with thw weblogic web service generation tools (due to an inability to set the authentication - see my other question here),
This web service needs to make calls to another web service (for which I also have the WSDL).
I can use the Axis tools to generate the client stubs etc.
But how do I do the two in combination? Is there a tutorial or other step by step guide? I have googled and found some mailing list postings, but they're about specific issues.
If someone's done it, could they share the relevant parts of their build.xml for this?
If I used the weblogic web service generation tools, there's a tool that in one go generates the skeleton implementation of the web service and the client stubs for the web service it calls - is there something similar in Axis?
Any gotchas if I just try to mash up the skeleton and client generation output from WSDL2Java?
Update:
Got this to work.
Used the Eclipse tools to build the client, then the service, allowing the second to overwrite the duplicate files from the first. We then had some issues with the client_deploy.wsdd file (see my other question How do I refer to a client_deploy.wsdd file that's in WEB-INF?) and with jar versions (needed to update the jars that Axis uses to newer version), then it just worked.
Speaking for axis2, you can create the client stub like this (I reckon axis1 is not much different):
/wsdl2java.sh -uri webservice.wsdl -p com.your.client.package -d adb -s -o output_folder_client
Once you have the client package you should be able to use it in your own webservice implementation by just importing it, creating a client instance and submitting requests.

quickstart jboss (or tomcat) + beans tutorial

I'm a little daunted by the endless myriad options in Eclipse for starting a Java EE project that would run on jboss. I know what I'm doing once I have an environment that's configured, but was hoping someone could point me to a step by step tutorial on how to go from writing my first class to actually having jboss pick it up on startup and act on it.
I assume the tutorial would need to involve the part of the task that has ANT generate a war file.
EJB 3 Tutorial explaining Ant and showing how to create a session and entity beans with annotations and JBoss