jmeter-maven-plugin blocked at getting service port from "javax.xml.ws.Service" when executing JMX file - web-services

I'm using jmeter-maven-plugin to run Performance test using JMX files:
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.9.0</version>
<dependencies>
<dependency>
<groupId>com.gemalto.pse.pim</groupId>
<artifactId>pim-ws-client</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<testFilesIncluded>
<jMeterTestFile>file_1.jmx</jMeterTestFile>
<jMeterTestFile>file_2.jmx</jMeterTestFile>
</testFilesIncluded>
</configuration>
</execution>
</executions>
</plugin>
The JMX file file_1.jmx execute a method in a class that call a web-service as follows:
final String ENDPOINT_ADDRESS = "http://10.256.45.147:8080/service-ejb/ServiceClass?wsdl";
final QName SERVICE_NAME = new QName(
"http://service.tools.com/", "ServiceClassService");
javax.xml.ws.Service service = javax.xml.ws.Service.create(
new URL(ENDPOINT_ADDRESS), SERVICE_NAME);
IServiceClass myService = dataFinderService.getPort(IServiceClass.class);
The problem is that Jmeter plugin is blocked at execution of file_1.jmx and does not process the file_2.jmx, the process is blocked at:
IServiceClass myService = dataFinderService.getPort(IServiceClass.class);
And when i cancel the execution (type Ctrl+C) the process continues and Jmeter-maven-plugin generate the output report file
Any one have encounter this problem ? ... Thanks a lot in advance :)

The problem is resolved, all what i implimented is right, the problem is just that i should use jmeter-maven-plugin version 1.8.0 instead of 1.9.0 :)

Related

Packages from running integration module are not excluded

I´m running some integration test from module A getting first all the classes from module B, what I´m interested is in not add in the coverture some packages from B, but also some package from A.
I´m using excludes in the jacocco plugin, and all the packages that I´m specify from B are exlude perfectly, but the ones from A it dont
Here my config
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
<executions>
<execution>
<id>prepare-jacoco-service-test-agent</id>
<!-- default pre-integration is to late for the process-exec-maven-plugin -->
<phase>package</phase>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<propertyName>failsafe.argLine</propertyName>
<includes>
<include>com.in*</include>
</includes>
<excludes>
<exclude>com.B.dg.*</exclude>
<exclude>com.B.es.core.server.vertx.*</exclude>
<!--f2e-core-test-->
<exclude>com.B.es.client.service.*</exclude>
<exclude>com.B.es.core.service.test.*</exclude>
<exclude>com.B.es.core.test.helper.*</exclude>
<exclude>com.B.es.coretest.*</exclude>
<!--f2e-mock-->
<exclude>com.A.f2e.*</exclude>
</excludes>
<classDumpDir>${project.build.outputDirectory}</classDumpDir>
<destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
<append>true</append>
</configuration>
</execution>
<execution>
<id>report-jacoco-service-test-results</id>
<goals>
<goal>report-integration</goal>
</goals>
<phase>verify</phase>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
<outputDirectory>${project.build.directory}/coverage-reports/out/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Any idea why any package of module A it´s not excluded?
By configuring exclusions for prepare-agent-integration you specified that packages should be excluded from instrumentation, but not from report. You need to configure exclusions for report-integration instead.

why ElastiMq keeps requiring server and check parameters since I am passing it

I am using AWS SQS for the first time. I work in certain company which blocks us via firewall to connect from our local network to SQS for some reasons beyond my control. I can upload anything I have developed to our TomCat in AWS or even run via our Linux command line with our ec2-user (upload via WinSCP and trigger via Putty).
Since I need to provide certain solution using sqs but I can't debug accessing it from my Eclipse I am interested to mock sqs. Additionally, I see advantages on such approach from test perspective. That said, after few hours searching I found exactly what I need: http://www.schibsted.pl/blog/mocking-amazon-sqs-with-elasticmq/
I downloaded the example (https://github.com/JanGurda/elastc-mq-rule-sample) but I can't start it. I understand that there is an elasticmq embbeded which should be started together with such jar. I tried other way by downloading the elasticmq and started it before running the sample but I am still getting the same output.
Basically, I am getting this output
usage: java -jar project.jar [-h] [-v] {server,check} ...
positional arguments:
{server,check} available commands
optional arguments:
-h, --help show this help message and exit
-v, --version show the application version and exit
It seems I am doing something very silly but I didn't find a north.
PS. I checked and the pom has lombok and elasticmq properly settup.
pom
<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>pl.schibsted.spid</groupId>
<artifactId>elastc-mq-rule-sample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>0.8.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sqs</artifactId>
<version>1.10.1</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-testing</artifactId>
<version>0.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticmq</groupId>
<artifactId>elasticmq-rest-sqs_2.11</artifactId>
<version>0.8.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>pl.schibsted.spid.elasticmq.server.ElasticMqRuleSampleApplication</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>**/ITest*.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
DropwizardAppRule:
public class ITestPingResource {
#ClassRule
public static DropwizardAppRule<ElasticMqRuleSampleApplicationConfiguration> app =
new DropwizardAppRule<>(ElasticMqRuleSampleApplication.class,
ITestPingResource.class.getClassLoader().getResource("test.yml").getPath());
#ClassRule
public static SqsRule sqs = new SqsRule(SqsRuleConfiguration.builder()
.queue("sample-queue").port(8888).build());
private Client client = ClientBuilder.newClient();
#After
public void tearDown() {
sqs.purgeAllQueues();
}
#Test
public void shouldPublishProcessedRequestPayload() throws Exception {
// given
String toSend = "abcdefgh";
// when
Response response = client
.target("http://127.0.0.1:" + app.getLocalPort() + "/ping")
.request().post(Entity.json(toSend));
// then
assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());
List<Message> messagesFromQueue = sqs.getQueue("sample-queue").read(10);
assertEquals(1, messagesFromQueue.size());
assertEquals("ABCDEFGH", messagesFromQueue.get(0).getBody());
}
}
test.yml
queueUrl: http://localhost:8888/queue/sample-queue
awsAccessKey: x
awsSecretKey: x
main:
public class ElasticMqRuleSampleApplication extends Application<ElasticMqRuleSampleApplicationConfiguration> {
public static void main(String[] args) throws Exception {
new ElasticMqRuleSampleApplication().run(args);
}
#Override
public void run(ElasticMqRuleSampleApplicationConfiguration configuration, Environment environment) throws Exception {
PingResource resource = new PingResource(configuration);
environment.jersey().register(resource);
}
}
Demetrio,
The error you get is simply standard output of Dropwizard. You should use “server” parameter to start Dropwizard application. So command you use to start Dropwizard is java -jar <> server.
If you however would like to run sample integration test (which I discussed in my article) just use Maven. Type mvn clean install. It’ll build project and run integration test.
Thanks

axistools-maven-plugin wsdl2java how to set different packages for each wsdl

I want use the axistools-maven-plugin to generate java classes from wsdl.
Now I have this code and it works:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<executions>
<execution>
<id>ax-ws-autogen</id>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<sourceDirectory>src/main/resources/wsdl</sourceDirectory>
<wsdlFiles>
<wsdlFile>myfirstwsdl.wsdl</wsdlFile>
</wsdlFiles>
<packageSpaces>my.package.code.first</packageSpaces>
<testCases>false</testCases>
<serverSide>false</serverSide>
<subPackageByFileName>false</subPackageByFileName>
<outputDirectory>src/main/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Now I need to use another wsdl. So I want add it to this plugin, but in another packages. How can I to do?
I see that I can add wsdl file in <wsdlFiles> tag, but I don't know how to add the new package for the new wsdl.
With CXF I can set different wsdl and packages in the <wsdlOptions> tag, but with axis I don't know how to do.
Can you help me, please?
I solved my problem setting <subPackageByFileName> = true and changing <packageSpace> in a general package:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<executions>
<execution>
<id>ax-ws-autogen</id>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<sourceDirectory>src/main/resources/wsdl</sourceDirectory>
<wsdlFiles>
<wsdlFile>myfirstwsdl.wsdl</wsdlFile>
<wsdlFile>mysecondwsdl.wsdl</wsdlFile>
</wsdlFiles>
<packageSpace>my.package.code</packageSpace>
<testCases>false</testCases>
<serverSide>false</serverSide>
<subPackageByFileName>true</subPackageByFileName>
<outputDirectory>src/main/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
In this way I get a single package my.package.code that contain two packages:
my.package.code.myfirstwsdl with all classes of my first wsdl;
my.package.code.mysecondwsdl with all classes of my second wsdl.

Could cxf maven plugin generate classes for a directory of wsdl files?

I use cxf-codgen-plugin in maven to generate classes for web services. Here is a part of my pom.xml
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.7.1</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/wsdl/ws1.wsdl</wsdl>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/wsdl/ws2.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
The problem is every time I want to add a new WSDL I had to add a line in the pom.xml like this:
<wsdlOption>
<wsdl>${basedir}/wsdl/ws2.wsdl</wsdl>
</wsdlOption>
What I want to do is to specify a directory and cxf will generate classes for all the WSDL files in this directory.
Is there a way to do this?
Thanks.
I found the way to do this:
<configuration>
<sourceRoot>${basedir}/src/main/java</sourceRoot>
<wsdlRoot>${basedir}/wsdl</wsdlRoot>
<includes>
<include>*.wsdl</include>
</includes>

accessing a web service using axis and maven

Im trying to figure out how to access Web Services in Java using Axis.
As far as I understand, Here's what I need to do :
Use WSDL File + Axis tools to generate Java files.
Compile and package generated Java files and then consume those objects by using connection methods on these.
In trying to do this, here's where I'm stuck:
I picked a random Web Service from http://www.service-repository.com/
I used the axistools-maven-plugin in the following manner:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<configuration>
<urls>
<!--<url>http://soap.amazon.com/schemas2/AmazonWebServices.wsdl</url>-->
<!--<url>http://ws.xwebservices.com/XWebEmailValidation/V2/XWebEmailValidation.wsdl</url>-->
<url>http://mathertel.de/AJAXEngine/S02_AJAXCoreSamples/OrteLookup.asmx?WSDL</url>
</urls>
<!--<sourceDirectory>${project.build.sourceDirectory}/wsdl</sourceDirectory>-->
<packageSpace>com.company.wsdl</packageSpace>
<testCases>true</testCases>
<serverSide>true</serverSide>
<subPackageByFileName>true</subPackageByFileName>
<outputDirectory>${project.build.directory}/src/generated-sources</outputDirectory>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
Here's the issue:
I can successfully run mvn generate-sources and it does generate the Java files. But I can't seem to compile these Java files.
When I run mvn clean install it gives me a bunch of compile errors. What step am I missing ?
Based on your answer to one of my comment, my suggestion would be to use a JAX-WS implementation like JAX-WS RI - which is included in Java 6 - or Apache CXF (both are IMO much better WS stacks than the outdated Axis).
Here is an example based on JAX-WS RI and its jaxws-maven-plugin:
<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.stackoverflow</groupId>
<artifactId>Q3479139</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Q3479139</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven 2</name>
<url>http://download.java.net/maven/2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven2-repository.dev.java.net</id>
<url>http://download.java.net/maven/2</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlUrls>
<wsdlUrl>http://ws.xwebservices.com/XWebEmailValidation/V2/XWebEmailValidation.wsdl</wsdlUrl>
</wsdlUrls>
<!-- The name of your generated source package -->
<packageName>com.example.myschema</packageName>
<!-- generate artifacts that run with JAX-WS 2.0 runtime -->
<target>2.0</target>
<!-- Specify where to place generated source files -->
<sourceDestDir>${project.build.directory}/generated-sources/wsimport</sourceDestDir>
</configuration>
</execution>
</executions>
<!-- if you want to use a specific version of JAX-WS, you can do so like this -->
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
And here is a very basic test case (part of the maven project) demonstrating the invocation of the web service using the generated classes:
package com.example.myschema;
import junit.framework.TestCase;
public class EmailValidationTest extends TestCase {
XWebEmailValidationInterface service = new EmailValidation().getEmailValidation();
ValidateEmailRequest request = new ValidateEmailRequest();
ValidateEmailResponse response = null;
public void testEmails() {
request.setEmail("foo#bar.com");
response = service.validateEmail(request);
assertEquals("EMAIL_SERVER_NOT_FOUND", response.getStatus());
request.setEmail("foo#gmail.com");
response = service.validateEmail(request);
assertEquals("NOT_VALID", response.getStatus());
}
}