Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JBWS-3947] Use POJO endpoints instead of EJB3 ones by default to avo…
…id Weld CDI overhead
- Loading branch information
Showing
3 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
modules/testsuite/perf-tests/src/test/java/org/jboss/ws/bench/JAXWSBenchmarkPOJO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package org.jboss.ws.bench; | ||
|
||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
import java.net.URL; | ||
|
||
import javax.xml.namespace.QName; | ||
import javax.xml.ws.Service; | ||
|
||
import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient; | ||
import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext; | ||
import org.apache.jmeter.samplers.SampleResult; | ||
import org.jboss.test.ws.jaxws.benchmark.test.datatypes.EndpointDoc; | ||
import org.jboss.wsf.test.JBossWSTestHelper; | ||
|
||
public class JAXWSBenchmarkPOJO extends AbstractJavaSamplerClient | ||
{ | ||
private final String endpointURL = "http://" + JBossWSTestHelper.getServerHost() + ":" + JBossWSTestHelper.getServerPort() + "/jaxws-benchmark-datatypes-pojo/EndpointPOJODocImpl"; | ||
private final String targetNS = "http://datatypes.test.benchmark.jaxws.ws.test.jboss.org/"; | ||
private EndpointDoc ep; | ||
|
||
@Override | ||
public void setupTest(JavaSamplerContext context) { | ||
super.setupTest(context); | ||
try { | ||
this.ep = prepare(); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public void teardownTest(JavaSamplerContext context) { | ||
super.teardownTest(context); | ||
this.ep = null; | ||
} | ||
|
||
@Override | ||
public SampleResult runTest(JavaSamplerContext ctx) | ||
{ | ||
final SampleResult sampleResult = new SampleResult(); | ||
sampleResult.sampleStart(); | ||
|
||
try { | ||
performIteration(ep); | ||
sampleResult.setSuccessful(true); | ||
} catch (Exception e) { | ||
sampleResult.setSuccessful(false); | ||
sampleResult.setResponseMessage("Exception: " + e); | ||
StringWriter stringWriter = new StringWriter(); | ||
e.printStackTrace(new PrintWriter(stringWriter)); | ||
sampleResult.setResponseData(stringWriter.toString(), "UTF-8"); | ||
sampleResult.setDataType(SampleResult.TEXT); | ||
} finally { | ||
sampleResult.sampleEnd(); | ||
} | ||
|
||
return sampleResult; | ||
} | ||
|
||
public EndpointDoc prepare() throws Exception | ||
{ | ||
URL wsdlURL = new URL(endpointURL + "?wsdl"); | ||
QName serviceName = new QName(targetNS, "EndpointDocService"); | ||
|
||
Service service = Service.create(wsdlURL, serviceName); | ||
return service.getPort(EndpointDoc.class); | ||
} | ||
|
||
public void performIteration(Object port) throws Exception | ||
{ | ||
for (int i = 0; i < 100; i++) { | ||
double par = Math.random(); | ||
double ret = ((EndpointDoc)port).increaseDouble(par); | ||
if (!((par + 1) == (ret))) | ||
{ | ||
throw new Exception("Unexpected result: " + ret); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters