You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/12/27 11:27:07 UTC
svn commit: r1819329 -
/axis/axis2/java/core/trunk/modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/sample/WrapTests.java
Author: veithen
Date: Wed Dec 27 11:27:07 2017
New Revision: 1819329
URL: http://svn.apache.org/viewvc?rev=1819329&view=rev
Log:
Clean up test case:
- Fix indentation.
- Eliminate instances of the catch-and-fail testing anti-pattern.
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/sample/WrapTests.java
Modified: axis/axis2/java/core/trunk/modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/sample/WrapTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/sample/WrapTests.java?rev=1819329&r1=1819328&r2=1819329&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/sample/WrapTests.java (original)
+++ axis/axis2/java/core/trunk/modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/sample/WrapTests.java Wed Dec 27 11:27:07 2017
@@ -49,477 +49,415 @@ public class WrapTests extends AbstractT
return getTestSetup(new TestSuite(WrapTests.class));
}
- /**
- * Get theDocLitWrap Prxoy
- * @return DocLitWrapProxy
- */
- private DocLitWrap getProxy() {
- DocLitWrapService service = new DocLitWrapService();
- DocLitWrap proxy = service.getDocLitWrapPort();
- BindingProvider p = (BindingProvider) proxy;
- p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
- return proxy;
- }
-
- public void testTwoWaySync(){
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String reqString = "Test twoWay Sync";
- DocLitWrap proxy = getProxy();
-
- String response = proxy.twoWay(reqString);
- TestLogger.logger.debug("Sync Response =" + response);
- TestLogger.logger.debug("------------------------------");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
-
- public void testOneWayVoidWithNoInputParams(){
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
+ /**
+ * Get theDocLitWrap Prxoy
+ * @return DocLitWrapProxy
+ */
+ private DocLitWrap getProxy() {
+ DocLitWrapService service = new DocLitWrapService();
+ DocLitWrap proxy = service.getDocLitWrapPort();
+ BindingProvider p = (BindingProvider) proxy;
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+ return proxy;
+ }
- DocLitWrapService service = new DocLitWrapService();
- DocLitWrap proxy = getProxy();
- proxy.oneWayVoid();
-
- // Repeat to ensure correct behavior
- proxy.oneWayVoid();
+ public void testTwoWaySync(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ String reqString = "Test twoWay Sync";
+ DocLitWrap proxy = getProxy();
+
+ String response = proxy.twoWay(reqString);
+ TestLogger.logger.debug("Sync Response =" + response);
+ TestLogger.logger.debug("------------------------------");
+ }
- TestLogger.logger.debug("------------------------------");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
+ public void testOneWayVoidWithNoInputParams(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ DocLitWrapService service = new DocLitWrapService();
+ DocLitWrap proxy = getProxy();
+ proxy.oneWayVoid();
+
+ // Repeat to ensure correct behavior
+ proxy.oneWayVoid();
- public void testTwoWayHolder(){
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String holderString = new String("Test twoWay Sync");
- Integer holderInteger = new Integer(0);
- Holder<String> strHolder = new Holder<String>(holderString);
- Holder<Integer> intHolder = new Holder<Integer>(holderInteger);
- DocLitWrap proxy = getProxy();
- proxy.twoWayHolder(strHolder, intHolder);
- TestLogger.logger.debug("Holder Response String =" + strHolder.value);;
- TestLogger.logger.debug("Holder Response Integer =" + intHolder.value);
-
- // Repeat to ensure correct behavior
- proxy.twoWayHolder(strHolder, intHolder);
- TestLogger.logger.debug("Holder Response String =" + strHolder.value);;
- TestLogger.logger.debug("Holder Response Integer =" + intHolder.value);
- TestLogger.logger.debug("------------------------------");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
+ TestLogger.logger.debug("------------------------------");
+ }
- public void testTwoWayWithHeadersAndHolders(){
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- Header header = new Header();
- header.setOut(0);
- HeaderPart0 hp0= new HeaderPart0();
- hp0.setHeaderType("Client setup Header Type for HeaderPart0");
- HeaderPart1 hp1 = new HeaderPart1();
- hp1.setHeaderType("Client setup Header Type for HeaderPart0");
- Holder<HeaderPart0> holder = new Holder<HeaderPart0>(hp0);
- DocLitWrap proxy = getProxy();
- HeaderResponse hr = proxy.header(header, holder, hp1);
- hp0=holder.value;
- TestLogger.logger.debug("Holder Response String =" + hp0.getHeaderType());
- TestLogger.logger.debug("Header Response Long =" + hr.getOut());
-
- // Repeat to ensure correct behavior
- hr = proxy.header(header, holder, hp1);
- hp0=holder.value;
- TestLogger.logger.debug("Holder Response String =" + hp0.getHeaderType());
- TestLogger.logger.debug("Header Response Long =" + hr.getOut());
- TestLogger.logger.debug("------------------------------");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
+ public void testTwoWayHolder(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ String holderString = new String("Test twoWay Sync");
+ Integer holderInteger = new Integer(0);
+ Holder<String> strHolder = new Holder<String>(holderString);
+ Holder<Integer> intHolder = new Holder<Integer>(holderInteger);
+ DocLitWrap proxy = getProxy();
+ proxy.twoWayHolder(strHolder, intHolder);
+ TestLogger.logger.debug("Holder Response String =" + strHolder.value);;
+ TestLogger.logger.debug("Holder Response Integer =" + intHolder.value);
+
+ // Repeat to ensure correct behavior
+ proxy.twoWayHolder(strHolder, intHolder);
+ TestLogger.logger.debug("Holder Response String =" + strHolder.value);;
+ TestLogger.logger.debug("Holder Response Integer =" + intHolder.value);
+ TestLogger.logger.debug("------------------------------");
+ }
- public void testTwoWayHolderAsync(){
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String holderString = new String("Test twoWay Sync");
- Integer holderInteger = new Integer(0);
- Holder<String> strHolder = new Holder<String>(holderString);
- Holder<Integer> intHolder = new Holder<Integer>(holderInteger);
- DocLitWrap proxy = getProxy();
- proxy.twoWayHolder(strHolder, intHolder);
- TestLogger.logger.debug("Holder Response String =" + strHolder.value);;
- TestLogger.logger.debug("Holder Response Integer =" + intHolder.value);
-
- // Repeat
- proxy.twoWayHolder(strHolder, intHolder);
- TestLogger.logger.debug("Holder Response String =" + strHolder.value);;
- TestLogger.logger.debug("Holder Response Integer =" + intHolder.value);
- TestLogger.logger.debug("------------------------------");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
+ public void testTwoWayWithHeadersAndHolders(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ Header header = new Header();
+ header.setOut(0);
+ HeaderPart0 hp0= new HeaderPart0();
+ hp0.setHeaderType("Client setup Header Type for HeaderPart0");
+ HeaderPart1 hp1 = new HeaderPart1();
+ hp1.setHeaderType("Client setup Header Type for HeaderPart0");
+ Holder<HeaderPart0> holder = new Holder<HeaderPart0>(hp0);
+ DocLitWrap proxy = getProxy();
+ HeaderResponse hr = proxy.header(header, holder, hp1);
+ hp0=holder.value;
+ TestLogger.logger.debug("Holder Response String =" + hp0.getHeaderType());
+ TestLogger.logger.debug("Header Response Long =" + hr.getOut());
+
+ // Repeat to ensure correct behavior
+ hr = proxy.header(header, holder, hp1);
+ hp0=holder.value;
+ TestLogger.logger.debug("Holder Response String =" + hp0.getHeaderType());
+ TestLogger.logger.debug("Header Response Long =" + hr.getOut());
+ TestLogger.logger.debug("------------------------------");
+ }
- /**
- * This is a test of a doc/lit echo test
- */
- public void testEchoString() {
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String request = "hello world";
-
- DocLitWrap proxy = getProxy();
- String response = proxy.echoStringWSGEN1(request);
- assertTrue(response.equals(request));
-
- // Repeat
- response = proxy.echoStringWSGEN1(request);
- assertTrue(response.equals(request));
- TestLogger.logger.debug("------------------------------");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
+ public void testTwoWayHolderAsync(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ String holderString = new String("Test twoWay Sync");
+ Integer holderInteger = new Integer(0);
+ Holder<String> strHolder = new Holder<String>(holderString);
+ Holder<Integer> intHolder = new Holder<Integer>(holderInteger);
+ DocLitWrap proxy = getProxy();
+ proxy.twoWayHolder(strHolder, intHolder);
+ TestLogger.logger.debug("Holder Response String =" + strHolder.value);;
+ TestLogger.logger.debug("Holder Response Integer =" + intHolder.value);
- /**
- * This is a test of a doc/lit method that passes the
- * request in a header. This can only be reproduced via
- * annotations and WSGEN. WSImport will not allow this.
- */
- public void testEchoStringWSGEN1() {
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String request = "hello world";
-
- DocLitWrap proxy = getProxy();
- String response = proxy.echoStringWSGEN1(request);
- assertTrue(response.equals(request));
-
- // Repeat
- response = proxy.echoStringWSGEN1(request);
- assertTrue(response.equals(request));
- TestLogger.logger.debug("------------------------------");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
+ // Repeat
+ proxy.twoWayHolder(strHolder, intHolder);
+ TestLogger.logger.debug("Holder Response String =" + strHolder.value);;
+ TestLogger.logger.debug("Holder Response Integer =" + intHolder.value);
+ TestLogger.logger.debug("------------------------------");
+ }
- /**
- * This is a test of a doc/lit method that passes the
- * response in a header. This can only be reproduced via
- * annotations and WSGEN. WSImport will not allow this.
- */
+ /**
+ * This is a test of a doc/lit echo test
+ */
+ public void testEchoString() {
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ String request = "hello world";
+
+ DocLitWrap proxy = getProxy();
+ String response = proxy.echoStringWSGEN1(request);
+ assertTrue(response.equals(request));
+
+ // Repeat
+ response = proxy.echoStringWSGEN1(request);
+ assertTrue(response.equals(request));
+ TestLogger.logger.debug("------------------------------");
+ }
+
+ /**
+ * This is a test of a doc/lit method that passes the
+ * request in a header. This can only be reproduced via
+ * annotations and WSGEN. WSImport will not allow this.
+ */
+ public void testEchoStringWSGEN1() {
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ String request = "hello world";
+
+ DocLitWrap proxy = getProxy();
+ String response = proxy.echoStringWSGEN1(request);
+ assertTrue(response.equals(request));
+
+ // Repeat
+ response = proxy.echoStringWSGEN1(request);
+ assertTrue(response.equals(request));
+ TestLogger.logger.debug("------------------------------");
+ }
- public void testEchoStringWSGEN2() {
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String request = "hello world 2";
-
- DocLitWrap proxy = getProxy();
- String response = proxy.echoStringWSGEN2(request);
- assertTrue(response.equals(request));
-
- // Repeat
- response = proxy.echoStringWSGEN2(request);
- assertTrue(response.equals(request));
- TestLogger.logger.debug("------------------------------");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
+ /**
+ * This is a test of a doc/lit method that passes the
+ * response in a header. This can only be reproduced via
+ * annotations and WSGEN. WSImport will not allow this.
+ */
+
+ public void testEchoStringWSGEN2() {
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ String request = "hello world 2";
+
+ DocLitWrap proxy = getProxy();
+ String response = proxy.echoStringWSGEN2(request);
+ assertTrue(response.equals(request));
- /**
- * This is a test of a doc/lit echo test with xml chars.
- */
- public void testEchoString_xmlchars() {
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String request = XMLCHARS;
-
- DocLitWrap proxy = getProxy();
- String response = proxy.echoStringWSGEN1(request);
- assertTrue(response.equals(request));
-
- // Repeat
- response = proxy.echoStringWSGEN1(request);
- assertTrue(response.equals(request));
- TestLogger.logger.debug("------------------------------");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
+ // Repeat
+ response = proxy.echoStringWSGEN2(request);
+ assertTrue(response.equals(request));
+ TestLogger.logger.debug("------------------------------");
+ }
+
+ /**
+ * This is a test of a doc/lit echo test with xml chars.
+ */
+ public void testEchoString_xmlchars() {
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ String request = XMLCHARS;
+
+ DocLitWrap proxy = getProxy();
+ String response = proxy.echoStringWSGEN1(request);
+ assertTrue(response.equals(request));
- /**
- * This is a test of a doc/lit method that passes the
- * request in a header. This can only be reproduced via
- * annotations and WSGEN. WSImport will not allow this.
- */
- public void testEchoStringWSGEN1_xmlchars() {
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String request = XMLCHARS;
-
- DocLitWrap proxy = getProxy();
- String response = proxy.echoStringWSGEN1(request);
- assertTrue(response.equals(request));
-
- // Repeat
- response = proxy.echoStringWSGEN1(request);
- assertTrue(response.equals(request));
- TestLogger.logger.debug("------------------------------");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
+ // Repeat
+ response = proxy.echoStringWSGEN1(request);
+ assertTrue(response.equals(request));
+ TestLogger.logger.debug("------------------------------");
+ }
+
+ /**
+ * This is a test of a doc/lit method that passes the
+ * request in a header. This can only be reproduced via
+ * annotations and WSGEN. WSImport will not allow this.
+ */
+ public void testEchoStringWSGEN1_xmlchars() {
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ String request = XMLCHARS;
+
+ DocLitWrap proxy = getProxy();
+ String response = proxy.echoStringWSGEN1(request);
+ assertTrue(response.equals(request));
+
+ // Repeat
+ response = proxy.echoStringWSGEN1(request);
+ assertTrue(response.equals(request));
+ TestLogger.logger.debug("------------------------------");
+ }
- /**
- * This is a test of a doc/lit method that passes the
- * response in a header. This can only be reproduced via
- * annotations and WSGEN. WSImport will not allow this.
- */
+ /**
+ * This is a test of a doc/lit method that passes the
+ * response in a header. This can only be reproduced via
+ * annotations and WSGEN. WSImport will not allow this.
+ */
+
+ public void testEchoStringWSGEN2_xmlchars() {
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+
+ String request = XMLCHARS;
+
+ DocLitWrap proxy = getProxy();
+ String response = proxy.echoStringWSGEN2(request);
+ assertTrue(response.equals(request));
+
+ // Repeat
+ response = proxy.echoStringWSGEN2(request);
+ assertTrue(response.equals(request));
+ TestLogger.logger.debug("------------------------------");
+ }
+ /**
+ * Test to validate whether a JAXBCustomBuilder is plugged in
+ * on the server.
+ */
+ public void testJAXBCB_Server1(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
- public void testEchoStringWSGEN2_xmlchars() {
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String request = XMLCHARS;
-
- DocLitWrap proxy = getProxy();
- String response = proxy.echoStringWSGEN2(request);
- assertTrue(response.equals(request));
-
- // Repeat
- response = proxy.echoStringWSGEN2(request);
- assertTrue(response.equals(request));
- TestLogger.logger.debug("------------------------------");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
- /**
- * Test to validate whether a JAXBCustomBuilder is plugged in
- * on the server.
- */
- public void testJAXBCB_Server1(){
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String reqString = "JAXBCustomBuilderServer1";
- DocLitWrap proxy = getProxy();
-
- // Start Monitoring
- proxy.twoWay("JAXBCustomBuilderMonitorStart");
-
- String response = proxy.twoWay(reqString);
- // The returned response will contain the number of JAXBCustomBuilders
- // for the server this could be any number 0 or greater.
- TestLogger.logger.debug("Response 1 =" + response);
- String response2 = proxy.twoWay(reqString);
- TestLogger.logger.debug("Response 2 =" + response2);
- // The returned response will contain the number of JAXBCustomBuilders
- // this could be any number 1 or greater. The assumption is that
- // the JAXBCustomBuilder will be installed on the second invoke
- Integer r = Integer.parseInt(response2);
- assertTrue(r.intValue() >= 1);
- TestLogger.logger.debug("------------------------------");
-
- // End Monitoring
- proxy.twoWay("JAXBCustomBuilderMonitorEnd");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
+ String reqString = "JAXBCustomBuilderServer1";
+ DocLitWrap proxy = getProxy();
- /**
- * Test to validate whether a JAXBCustomBuilder is plugged in
- * and used on the server.
- */
- public void testJAXBCB_Server2(){
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String reqString = "JAXBCustomBuilderServer2";
- DocLitWrap proxy = getProxy();
-
- // Start Monitoring
- proxy.twoWay("JAXBCustomBuilderMonitorStart");
-
- String response = proxy.twoWay(reqString);
- // The returned response will contain the number of JAXBCustomBuilders
- // usages.
- TestLogger.logger.debug("Response 1 =" + response);
- Integer r1 = Integer.parseInt(response);
- String response2 = proxy.twoWay(reqString);
- TestLogger.logger.debug("Response 2 =" + response2);
- // The returned response will contain the number of JAXBCustomBuilders
- // usages. This should be greater than the first response
- Integer r2 = Integer.parseInt(response2);
- assertTrue(r2.intValue() > r1.intValue());
- TestLogger.logger.debug("------------------------------");
-
+ // Start Monitoring
+ proxy.twoWay("JAXBCustomBuilderMonitorStart");
+
+ String response = proxy.twoWay(reqString);
+ // The returned response will contain the number of JAXBCustomBuilders
+ // for the server this could be any number 0 or greater.
+ TestLogger.logger.debug("Response 1 =" + response);
+ String response2 = proxy.twoWay(reqString);
+ TestLogger.logger.debug("Response 2 =" + response2);
+ // The returned response will contain the number of JAXBCustomBuilders
+ // this could be any number 1 or greater. The assumption is that
+ // the JAXBCustomBuilder will be installed on the second invoke
+ Integer r = Integer.parseInt(response2);
+ assertTrue(r.intValue() >= 1);
+ TestLogger.logger.debug("------------------------------");
+
+ // End Monitoring
+ proxy.twoWay("JAXBCustomBuilderMonitorEnd");
+ }
+
+ /**
+ * Test to validate whether a JAXBCustomBuilder is plugged in
+ * and used on the server.
+ */
+ public void testJAXBCB_Server2(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
- // End Monitoring
- proxy.twoWay("JAXBCustomBuilderMonitorEnd");
- }catch(Exception e){
- e.printStackTrace();
- fail();
- }
- }
+ String reqString = "JAXBCustomBuilderServer2";
+ DocLitWrap proxy = getProxy();
- /**
- * Test to validate whether a JAXBCustomBuilder is plugged and used
- * on the client
- */
- public void testJAXBCB_Client(){
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String reqString = "JAXBCustomBuilderClient";
- DocLitWrap proxy = getProxy();
-
- // Start Monitoring
- JAXBCustomBuilderMonitor.setMonitoring(true);
- JAXBCustomBuilderMonitor.clear();
-
- // Invoke the web services
- proxy.twoWay(reqString);
-
- // The second invoke should trigger the fast
- // unmarshalling of the response
- proxy.twoWay(reqString);
-
-
- // The returned response unmarshalling should try
- // the JAXBCustomBuilder
- int totalBuilders = JAXBCustomBuilderMonitor.getTotalBuilders();
- assertTrue(totalBuilders >= 1);
- int totalCreates = JAXBCustomBuilderMonitor.getTotalCreates();
- assertTrue(totalCreates >= 1);
-
- TestLogger.logger.debug("------------------------------");
-
- }catch(Exception e){
- e.printStackTrace();
- fail();
- } finally {
- JAXBCustomBuilderMonitor.setMonitoring(false);
- }
- }
+ // Start Monitoring
+ proxy.twoWay("JAXBCustomBuilderMonitorStart");
- /**
- * Test to validate whether a JAXBCustomBuilder is plugged and used
- * on the client
- */
- public void testJAXBCB_Client_withHighFidelity(){
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String reqString = "JAXBCustomBuilderClient";
- DocLitWrap proxy = getProxy();
-
- BindingProvider p = (BindingProvider) proxy;
- p.getRequestContext().put(org.apache.axis2.jaxws.Constants.JAXWS_PAYLOAD_HIGH_FIDELITY, Boolean.TRUE);
-
- // Start Monitoring
- JAXBCustomBuilderMonitor.setMonitoring(true);
- JAXBCustomBuilderMonitor.clear();
-
+ String response = proxy.twoWay(reqString);
+ // The returned response will contain the number of JAXBCustomBuilders
+ // usages.
+ TestLogger.logger.debug("Response 1 =" + response);
+ Integer r1 = Integer.parseInt(response);
+ String response2 = proxy.twoWay(reqString);
+ TestLogger.logger.debug("Response 2 =" + response2);
+ // The returned response will contain the number of JAXBCustomBuilders
+ // usages. This should be greater than the first response
+ Integer r2 = Integer.parseInt(response2);
+ assertTrue(r2.intValue() > r1.intValue());
+ TestLogger.logger.debug("------------------------------");
+
+
+ // End Monitoring
+ proxy.twoWay("JAXBCustomBuilderMonitorEnd");
+ }
+
+ /**
+ * Test to validate whether a JAXBCustomBuilder is plugged and used
+ * on the client
+ */
+ public void testJAXBCB_Client(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+ try{
+ String reqString = "JAXBCustomBuilderClient";
+ DocLitWrap proxy = getProxy();
+
+ // Start Monitoring
+ JAXBCustomBuilderMonitor.setMonitoring(true);
+ JAXBCustomBuilderMonitor.clear();
+
+ // Invoke the web services
+ proxy.twoWay(reqString);
+
+ // The second invoke should trigger the fast
+ // unmarshalling of the response
+ proxy.twoWay(reqString);
+
+
+ // The returned response unmarshalling should try
+ // the JAXBCustomBuilder
+ int totalBuilders = JAXBCustomBuilderMonitor.getTotalBuilders();
+ assertTrue(totalBuilders >= 1);
+ int totalCreates = JAXBCustomBuilderMonitor.getTotalCreates();
+ assertTrue(totalCreates >= 1);
+
+ TestLogger.logger.debug("------------------------------");
+
+ } finally {
+ JAXBCustomBuilderMonitor.setMonitoring(false);
+ }
+ }
+
+ /**
+ * Test to validate whether a JAXBCustomBuilder is plugged and used
+ * on the client
+ */
+ public void testJAXBCB_Client_withHighFidelity(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+ try{
+ String reqString = "JAXBCustomBuilderClient";
+ DocLitWrap proxy = getProxy();
+
+ BindingProvider p = (BindingProvider) proxy;
+ p.getRequestContext().put(org.apache.axis2.jaxws.Constants.JAXWS_PAYLOAD_HIGH_FIDELITY, Boolean.TRUE);
+
+ // Start Monitoring
+ JAXBCustomBuilderMonitor.setMonitoring(true);
+ JAXBCustomBuilderMonitor.clear();
+
+ // Invoke the web services
+ proxy.twoWay(reqString);
+
+ // The second invoke should trigger the fast
+ // unmarshalling of the response
+ proxy.twoWay(reqString);
+
+
+ // The returned response unmarshalling should try
+ // the JAXBCustomBuilder
+ int totalBuilders = JAXBCustomBuilderMonitor.getTotalBuilders();
+ assertTrue(totalBuilders >= 1);
+ int totalCreates = JAXBCustomBuilderMonitor.getTotalCreates();
+ assertTrue("Expected 0, but received " + totalCreates, totalCreates == 0);
+
+ TestLogger.logger.debug("------------------------------");
+
+ } finally {
+ JAXBCustomBuilderMonitor.setMonitoring(false);
+ }
+ }
+
+ /**
+ * Test to validate whether a JAXBCustomBuilder is plugged in
+ * on the client. Also makes sure that the JAXBCustomBuilder
+ * falls back to normal processing when faults are thrown.
+ */
+ public void testJAXBCB_Fault(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+ try{
+ String reqNormalString = "JAXBCustomBuilderClient";
+ String reqFaultString = "JAXBCustomBuilderFault";
+ DocLitWrap proxy = getProxy();
+
+ // Start Monitoring
+ JAXBCustomBuilderMonitor.setMonitoring(true);
+ JAXBCustomBuilderMonitor.clear();
+
+ try {
// Invoke the web services
- proxy.twoWay(reqString);
-
- // The second invoke should trigger the fast
- // unmarshalling of the response
- proxy.twoWay(reqString);
-
+ proxy.twoWay(reqNormalString);
+ // This second invoke will cause
+ // an exception to be thrown.
+ proxy.twoWay(reqFaultString);
+
+ // An exception was expected
+ assertTrue(false);
+ } catch (WebServiceException wse) {
+ // An exception is expected
// The returned response unmarshalling should try
- // the JAXBCustomBuilder
+ // the JAXBCustomBuilder but fallback to normal unmarshalling
+ // due to the presense of a SOAPFault
int totalBuilders = JAXBCustomBuilderMonitor.getTotalBuilders();
assertTrue(totalBuilders >= 1);
int totalCreates = JAXBCustomBuilderMonitor.getTotalCreates();
- assertTrue("Expected 0, but received " + totalCreates, totalCreates == 0);
-
- TestLogger.logger.debug("------------------------------");
-
- }catch(Exception e){
- e.printStackTrace();
- fail();
- } finally {
- JAXBCustomBuilderMonitor.setMonitoring(false);
- }
- }
-
- /**
- * Test to validate whether a JAXBCustomBuilder is plugged in
- * on the client. Also makes sure that the JAXBCustomBuilder
- * falls back to normal processing when faults are thrown.
- */
- public void testJAXBCB_Fault(){
- TestLogger.logger.debug("------------------------------");
- TestLogger.logger.debug("Test : " + getName());
- try{
- String reqNormalString = "JAXBCustomBuilderClient";
- String reqFaultString = "JAXBCustomBuilderFault";
- DocLitWrap proxy = getProxy();
-
- // Start Monitoring
- JAXBCustomBuilderMonitor.setMonitoring(true);
- JAXBCustomBuilderMonitor.clear();
-
- try {
- // Invoke the web services
- proxy.twoWay(reqNormalString);
-
- // This second invoke will cause
- // an exception to be thrown.
- proxy.twoWay(reqFaultString);
-
- // An exception was expected
- assertTrue(false);
- } catch (WebServiceException wse) {
- // An exception is expected
- // The returned response unmarshalling should try
- // the JAXBCustomBuilder but fallback to normal unmarshalling
- // due to the presense of a SOAPFault
- int totalBuilders = JAXBCustomBuilderMonitor.getTotalBuilders();
- assertTrue(totalBuilders >= 1);
- int totalCreates = JAXBCustomBuilderMonitor.getTotalCreates();
- assertTrue(totalCreates == 0);
-
- }
- TestLogger.logger.debug("------------------------------");
-
- } catch(Exception e){
- e.printStackTrace();
- fail();
- } finally {
- JAXBCustomBuilderMonitor.setMonitoring(false);
- }
+ assertTrue(totalCreates == 0);
+
+ }
+ TestLogger.logger.debug("------------------------------");
+
+ } finally {
+ JAXBCustomBuilderMonitor.setMonitoring(false);
}
-
+ }
+
}