Author: veithen
Date: Mon Dec 25 20:14:42 2017
New Revision: 1819261
URL: http://svn.apache.org/viewvc?rev=1819261&view=rev
Log:
Replace tabs with spaces.
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SoapMessageProviderTests.java
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/StringProviderTests.java
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/tests/RPCLitEnumTests.java
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/HeadersHandlerTests.java
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleByteArrayTests.java
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/NonWrapTests.java
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/asyncdoclit/client/AsyncClient.java
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SoapMessageProviderTests.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SoapMessageProviderTests.java?rev=1819261&r1=1819260&r2=1819261&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SoapMessageProviderTests.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SoapMessageProviderTests.java
Mon Dec 25 20:14:42 2017
@@ -51,477 +51,477 @@ import org.apache.axis2.jaxws.provider.s
*
*/
public class SoapMessageProviderTests extends AbstractTestCase {
- private String endpointUrl =
"http://localhost:6060/axis2/services/SoapMessageProviderService.SoapMessageProviderPort";
- private QName serviceName = new
QName("http://soapmsg.soapbinding.provider.jaxws.axis2.apache.org",
"SOAPBindingSoapMessageProviderService");
- private QName portName = new
QName("http://soapmsg.soapbinding.provider.jaxws.axis2.apache.org",
"SoapMessageProviderPort");
-
- private String reqMsgStart = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>" +
- "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>";
- ;
-
- private String reqMsgEnd = "</soap:Body></soap:Envelope>";
-
- private String XML_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
- SoapMessageProvider.XML_REQUEST +
- "</invoke_str></ns2:invokeOp>";
- private String EMPTYBODY_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
- SoapMessageProvider.XML_EMPTYBODY_REQUEST +
- "</invoke_str></ns2:invokeOp>";
- private String CHECKHEADERS_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
- SoapMessageProvider.XML_CHECKHEADERS_REQUEST +
- "</invoke_str></ns2:invokeOp>";
- private String ATTACHMENT_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
- SoapMessageProvider.XML_ATTACHMENT_REQUEST +
- "</invoke_str></ns2:invokeOp>";
- private String MTOM_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
- SoapMessageProvider.XML_MTOM_REQUEST +
- "</invoke_str>" +
- SoapMessageProvider.MTOM_REF +
- "</ns2:invokeOp>";
- private String SWAREF_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
- SoapMessageProvider.XML_SWAREF_REQUEST +
- "</invoke_str>" +
- SoapMessageProvider.SWAREF_REF +
- "</ns2:invokeOp>";
- private String XML_FAULT_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
- SoapMessageProvider.XML_FAULT_REQUEST +
- "</invoke_str></ns2:invokeOp>";
- private String XML_WSE_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
- SoapMessageProvider.XML_WSE_REQUEST +
- "</invoke_str></ns2:invokeOp>";
- private String XML_SOAP12_FAULT_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
- SoapMessageProvider.XML_SOAP12_FAULT_REQUEST +
- "</invoke_str></ns2:invokeOp>";
- private String XML_SOAP12_RESPONSE_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
- SoapMessageProvider.XML_SOAP12_RESPONSE +
- "</invoke_str></ns2:invokeOp>";
-
- public static Test suite() {
+ private String endpointUrl =
"http://localhost:6060/axis2/services/SoapMessageProviderService.SoapMessageProviderPort";
+ private QName serviceName = new
QName("http://soapmsg.soapbinding.provider.jaxws.axis2.apache.org",
"SOAPBindingSoapMessageProviderService");
+ private QName portName = new
QName("http://soapmsg.soapbinding.provider.jaxws.axis2.apache.org",
"SoapMessageProviderPort");
+
+ private String reqMsgStart = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>";
+ ;
+
+ private String reqMsgEnd = "</soap:Body></soap:Envelope>";
+
+ private String XML_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String EMPTYBODY_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_EMPTYBODY_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String CHECKHEADERS_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_CHECKHEADERS_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String ATTACHMENT_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_ATTACHMENT_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String MTOM_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_MTOM_REQUEST +
+ "</invoke_str>" +
+ SoapMessageProvider.MTOM_REF +
+ "</ns2:invokeOp>";
+ private String SWAREF_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_SWAREF_REQUEST +
+ "</invoke_str>" +
+ SoapMessageProvider.SWAREF_REF +
+ "</ns2:invokeOp>";
+ private String XML_FAULT_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_FAULT_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String XML_WSE_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_WSE_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String XML_SOAP12_FAULT_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_SOAP12_FAULT_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String XML_SOAP12_RESPONSE_INVOKE = "<ns2:invokeOp
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_SOAP12_RESPONSE +
+ "</invoke_str></ns2:invokeOp>";
+
+ public static Test suite() {
return getTestSetup(new TestSuite(SoapMessageProviderTests.class));
}
- /**
- * Sends an SOAPMessage containing only xml data
- * Provider will throw a Fault
- */
- public void testProviderSOAPMessageSOAPFault() throws Exception {
-
- // Create the dispatch
- Dispatch<SOAPMessage> dispatch = createDispatch();
-
- // Create the SOAPMessage
- String msg = reqMsgStart + XML_FAULT_INVOKE + reqMsgEnd;
- MessageFactory factory = MessageFactory.newInstance();
- SOAPMessage request = factory.createMessage(null,
- new ByteArrayInputStream(msg.getBytes()));
-
- // Test the transport headers by sending a content description
-
request.setContentDescription(SoapMessageProvider.XML_FAULT_REQUEST);
-
- try {
- // Dispatch
- System.out.println(">> Invoking
SOAPMessageProviderDispatch");
- SOAPMessage response = dispatch.invoke(request);
- assertTrue("Expected failure", false);
- } catch (SOAPFaultException e) {
- // Okay
- SOAPFault fault = e.getFault();
- assertTrue(fault != null);
- assertTrue(fault.getFaultString().equals("sample
fault"));
- QName expectedFaultCode = new
QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Client");
-
assertTrue(fault.getFaultCodeAsQName().equals(expectedFaultCode));
- assertTrue(fault.getDetail() != null);
- DetailEntry de = (DetailEntry)
fault.getDetail().getDetailEntries().next();
- assertTrue(de != null);
- assertTrue(de.getLocalName().equals("detailEntry"));
- assertTrue(de.getValue().equals("sample detail"));
- assertTrue(fault.getFaultActor().equals("sample
actor"));
- }
-
- // Try a second time
- try {
- // Dispatch
- System.out.println(">> Invoking
SOAPMessageProviderDispatch");
- SOAPMessage response = dispatch.invoke(request);
- assertTrue("Expected failure", false);
- } catch (SOAPFaultException e) {
- // Okay
- SOAPFault fault = e.getFault();
- assertTrue(fault != null);
- assertTrue(fault.getFaultString().equals("sample
fault"));
- QName expectedFaultCode = new
QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Client");
-
assertTrue(fault.getFaultCodeAsQName().equals(expectedFaultCode));
- assertTrue(fault.getDetail() != null);
- DetailEntry de = (DetailEntry)
fault.getDetail().getDetailEntries().next();
- assertTrue(de != null);
- assertTrue(de.getLocalName().equals("detailEntry"));
- assertTrue(de.getValue().equals("sample detail"));
- assertTrue(fault.getFaultActor().equals("sample
actor"));
- }
- }
-
-
- /**
- * Sends an SOAPMessage containing only xml data
- * Provider will throw a generic WebServicesException
- */
- public void testProviderSOAPMessageWebServiceException() throws
Exception {
-
- // Create the dispatch
- Dispatch<SOAPMessage> dispatch = createDispatch();
-
- // Create the SOAPMessage
- String msg = reqMsgStart + XML_WSE_INVOKE + reqMsgEnd;
- MessageFactory factory = MessageFactory.newInstance();
- SOAPMessage request = factory.createMessage(null,
- new ByteArrayInputStream(msg.getBytes()));
-
- // Test the transport headers by sending a content description
-
request.setContentDescription(SoapMessageProvider.XML_WSE_REQUEST);
-
- try {
- // Dispatch
- System.out.println(">> Invoking
SOAPMessageProviderDispatch");
- SOAPMessage response = dispatch.invoke(request);
- assertTrue("Expected failure", false);
- } catch (SOAPFaultException e) {
- // Okay...SOAPFaultException should be thrown
- SOAPFault fault = e.getFault();
- assertTrue(fault != null);
- assertTrue(fault.getFaultString().equals("A WSE was
thrown"));
- }
-
- // Try a second time
- try {
- // Dispatch
- System.out.println(">> Invoking
SOAPMessageProviderDispatch");
- SOAPMessage response = dispatch.invoke(request);
- assertTrue("Expected failure", false);
- } catch (SOAPFaultException e) {
- // Okay...SOAPFaultException should be thrown
- SOAPFault fault = e.getFault();
- assertTrue(fault != null);
- assertTrue(fault.getFaultString().equals("A WSE was
thrown"));
- }
- }
-
-
- /**
- * Sends an SOAPMessage containing xml data and raw attachments to the
web service.
- * Receives a response containing xml data and the same raw attachments.
- */
-
- public void testProviderSOAPMessageRawAttachment(){
- // Raw Attachments are attachments that are not referenced in
the xml with MTOM or SWARef.
- // Currently there is no support in Axis 2 for these kinds of
attachments.
- // The belief is that most customers will use MTOM. Some
legacy customers will use SWARef.
- // Raw Attachments may be so old that no customers need this
behavior.
- try{
- // Create the dispatch
- Dispatch<SOAPMessage> dispatch = createDispatch();
-
- // Create the SOAPMessage
- String msg = reqMsgStart + ATTACHMENT_INVOKE +
reqMsgEnd;
- MessageFactory factory = MessageFactory.newInstance();
- SOAPMessage request = factory.createMessage(null,
- new
ByteArrayInputStream(msg.getBytes()));
-
- // Add the Attachment
- AttachmentPart ap =
request.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT,
"text/xml");
- ap.setContentId(SoapMessageProvider.ID);
- request.addAttachmentPart(ap);
-
- // Dispatch
- System.out.println(">> Invoking
SOAPMessageProviderDispatch");
- SOAPMessage response = dispatch.invoke(request);
-
- // Check assertions and get the data element
- SOAPElement dataElement = assertResponseXML(response,
SoapMessageProvider.XML_ATTACHMENT_RESPONSE);
- assertTrue(countAttachments(response) == 1);
-
- // Get the Attachment
- AttachmentPart attachmentPart = (AttachmentPart)
response.getAttachments().next();
-
- // Check the attachment
- StreamSource contentSS = (StreamSource)
attachmentPart.getContent();
- String content =
SoapMessageProvider.getAsString(contentSS);
- assertTrue(content != null);
-
assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
-
- // Print out the response
- System.out.println(">> Response [" +
response.toString() + "]");
-
-
- // Try a second time
- // Dispatch
- System.out.println(">> Invoking
SOAPMessageProviderDispatch");
- response = dispatch.invoke(request);
-
- // Check assertions and get the data element
- dataElement = assertResponseXML(response,
SoapMessageProvider.XML_ATTACHMENT_RESPONSE);
- assertTrue(countAttachments(response) == 1);
-
- // Get the Attachment
- attachmentPart = (AttachmentPart)
response.getAttachments().next();
-
- // Check the attachment
- contentSS = (StreamSource) attachmentPart.getContent();
- content = SoapMessageProvider.getAsString(contentSS);
- assertTrue(content != null);
-
assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
-
- // Print out the response
- System.out.println(">> Response [" +
response.toString() + "]");
-
- }catch(Exception e){
- e.printStackTrace();
- fail("Caught exception " + e);
- }
-
- }
-
- /**
- * Sends an SOAPMessage containing xml data and mtom attachment.
- * Receives a response containing xml data and the mtom attachment.
- */
- public void testProviderSOAPMessageMTOM(){
- try{
- // Create the dispatch
- Dispatch<SOAPMessage> dispatch = createDispatch();
-
- // MTOM should be automatically detected. There is no
need to set it
- //Binding binding = dispatch.getBinding();
- //SOAPBinding soapBinding = (SOAPBinding) binding;
- //soapBinding.setMTOMEnabled(true);
-
- // Create the SOAPMessage
- String msg = reqMsgStart + MTOM_INVOKE + reqMsgEnd;
- MessageFactory factory = MessageFactory.newInstance();
- SOAPMessage request = factory.createMessage(null,
- new
ByteArrayInputStream(msg.getBytes()));
-
- // Add the Attachment
- AttachmentPart ap =
request.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT,
"text/xml");
- ap.setContentId(SoapMessageProvider.ID);
- request.addAttachmentPart(ap);
-
- // Dispatch
- System.out.println(">> Invoking
SOAPMessageProviderDispatch");
- SOAPMessage response = dispatch.invoke(request);
-
- // Check assertions and get the data element
- SOAPElement dataElement = assertResponseXML(response,
SoapMessageProvider.XML_MTOM_RESPONSE);
- assertTrue(countAttachments(response) == 1);
-
- // Get the Attachment
- AttachmentPart attachmentPart = (AttachmentPart)
response.getAttachments().next();
-
- // Check the attachment
- StreamSource contentSS = (StreamSource)
attachmentPart.getContent();
- String content =
SoapMessageProvider.getAsString(contentSS);
- assertTrue(content != null);
-
assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
-
- // Print out the response
- System.out.println(">> Response [" +
response.toString() + "]");
-
-
- // Try a second time
- // Dispatch
- System.out.println(">> Invoking
SOAPMessageProviderDispatch");
- response = dispatch.invoke(request);
-
- // Check assertions and get the data element
- dataElement = assertResponseXML(response,
SoapMessageProvider.XML_MTOM_RESPONSE);
- assertTrue(countAttachments(response) == 1);
-
- // Get the Attachment
- attachmentPart = (AttachmentPart)
response.getAttachments().next();
-
- // Check the attachment
- contentSS = (StreamSource) attachmentPart.getContent();
- content = SoapMessageProvider.getAsString(contentSS);
- assertTrue(content != null);
-
assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
-
- // Print out the response
- System.out.println(">> Response [" +
response.toString() + "]");
-
- }catch(Exception e){
- e.printStackTrace();
- fail("Caught exception " + e);
- }
-
- }
-
- /**
- * Sends an SOAPMessage containing xml data and a swaref attachment to
the web service.
- * Receives a response containing xml data and the swaref attachment
attachment.
- */
- public void testProviderSOAPMessageSWARef(){
- try{
- // Create the dispatch
- Dispatch<SOAPMessage> dispatch = createDispatch();
-
- // Create the SOAPMessage
- String msg = reqMsgStart + SWAREF_INVOKE + reqMsgEnd;
- MessageFactory factory = MessageFactory.newInstance();
- SOAPMessage request = factory.createMessage(null,
- new
ByteArrayInputStream(msg.getBytes()));
-
- // Add the Attachment
- AttachmentPart ap =
request.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT,
"text/xml");
- ap.setContentId(SoapMessageProvider.ID);
- request.addAttachmentPart(ap);
-
- // Dispatch
- System.out.println(">> Invoking
SOAPMessageProviderDispatch");
- SOAPMessage response = dispatch.invoke(request);
-
- // Check assertions and get the data element
- SOAPElement dataElement = assertResponseXML(response,
SoapMessageProvider.XML_SWAREF_RESPONSE);
- assertTrue(countAttachments(response) == 1);
-
- // Get the Attachment
- AttachmentPart attachmentPart = (AttachmentPart)
response.getAttachments().next();
-
- // Check the attachment
- StreamSource contentSS = (StreamSource)
attachmentPart.getContent();
- String content =
SoapMessageProvider.getAsString(contentSS);
- assertTrue(content != null);
-
assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
- assertEquals(SoapMessageProvider.ID,
attachmentPart.getContentId());
-
- // Print out the response
- System.out.println(">> Response [" +
response.toString() + "]");
-
-
-
- // Try a second time
- // Dispatch
- System.out.println(">> Invoking
SOAPMessageProviderDispatch");
- response = dispatch.invoke(request);
-
- // Check assertions and get the data element
- dataElement = assertResponseXML(response,
SoapMessageProvider.XML_SWAREF_RESPONSE);
- assertTrue(countAttachments(response) == 1);
-
- // Get the Attachment
- attachmentPart = (AttachmentPart)
response.getAttachments().next();
-
- // Check the attachment
- contentSS = (StreamSource) attachmentPart.getContent();
- content = SoapMessageProvider.getAsString(contentSS);
- assertTrue(content != null);
-
assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
- assertEquals(SoapMessageProvider.ID,
attachmentPart.getContentId());
-
- // Print out the response
- System.out.println(">> Response [" +
response.toString() + "]");
-
- }catch(Exception e){
- e.printStackTrace();
- fail("Caught exception " + e);
- }
-
- }
-
- /* This is a negative test case for a Provider that has NO SOAPBinding
restriction
- * Dispatch will send a SOAP11 request and Provider will send a SOAP12
Response.
- */
- public void testSoap11RequestWithSoap12Response(){
- SOAPMessage request = null;
- Dispatch<SOAPMessage> dispatch = null;
- try{
- // Create the dispatch
- dispatch = createDispatch();
- // Create the SOAPMessage
- String msg = reqMsgStart + XML_SOAP12_RESPONSE_INVOKE +
reqMsgEnd;
- MessageFactory factory = MessageFactory.newInstance();
- request = factory.createMessage(null,
- new
ByteArrayInputStream(msg.getBytes()));
- }catch(Exception e){
- e.printStackTrace();
- fail("Caught Exception "+e);
- }
- try{
- SOAPMessage response = dispatch.invoke(request);
- assertTrue("Expecting Failure", false);
- }catch(SOAPFaultException e){
- SOAPFault fault = e.getFault();
- assertTrue(fault != null);
- assertTrue(fault.getFaultString().equals("Request SOAP
message protocol is version 1.1, but Response SOAP message is configured for
SOAP 1.2. This is not supported."));
- }
-
- }
- /**
- * @return
- * @throws Exception
- */
- private Dispatch<SOAPMessage> createDispatch() throws Exception {
-
-
- Service svc = Service.create(serviceName);
- svc.addPort(portName,null, endpointUrl);
- Dispatch<SOAPMessage> dispatch =
- svc.createDispatch(portName, SOAPMessage.class,
Service.Mode.MESSAGE);
- return dispatch;
- }
-
- /**
- * @return
- * @throws Exception
- */
- private Dispatch<String> createStringDispatch() throws Exception {
-
-
- Service svc = Service.create(serviceName);
- svc.addPort(portName,null, endpointUrl);
- Dispatch<String> dispatch =
- svc.createDispatch(portName, String.class,
Service.Mode.PAYLOAD);
- return dispatch;
- }
-
- /**
- * Common assertion checking of the response
- * @param msg
- * @param expectedText
- * @return SOAPElement representing the data element
- */
- private SOAPElement assertResponseXML(SOAPMessage msg, String
expectedText) throws Exception {
- assertTrue(msg != null);
- SOAPBody body = msg.getSOAPBody();
- assertTrue(body != null);
-
- Node invokeElement = (Node) body.getFirstChild();
- assertTrue(invokeElement instanceof SOAPElement);
- assertEquals(SoapMessageProvider.RESPONSE_NAME,
invokeElement.getLocalName());
-
- Node dataElement = (Node) invokeElement.getFirstChild();
- assertTrue(dataElement instanceof SOAPElement);
- assertEquals(SoapMessageProvider.RESPONSE_DATA_NAME,
dataElement.getLocalName());
-
- // TODO AXIS2 SAAJ should (but does not) support the
getTextContent();
- // String text = dataElement.getTextContent();
- String text = dataElement.getValue();
- assertEquals("Found ("+ text + ") but expected (" +
expectedText + ")", expectedText, text);
-
- return (SOAPElement) dataElement;
- }
-
- /**
- * Count Attachments
- * @param msg
- * @return
- */
- private int countAttachments(SOAPMessage msg) {
- Iterator it = msg.getAttachments();
- int count = 0;
- assertTrue(it != null);
- while (it.hasNext()) {
- it.next();
- count++;
- }
- return count;
- }
+ /**
+ * Sends an SOAPMessage containing only xml data
+ * Provider will throw a Fault
+ */
+ public void testProviderSOAPMessageSOAPFault() throws Exception {
+
+ // Create the dispatch
+ Dispatch<SOAPMessage> dispatch = createDispatch();
+
+ // Create the SOAPMessage
+ String msg = reqMsgStart + XML_FAULT_INVOKE + reqMsgEnd;
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage request = factory.createMessage(null,
+ new ByteArrayInputStream(msg.getBytes()));
+
+ // Test the transport headers by sending a content description
+ request.setContentDescription(SoapMessageProvider.XML_FAULT_REQUEST);
+
+ try {
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+ assertTrue("Expected failure", false);
+ } catch (SOAPFaultException e) {
+ // Okay
+ SOAPFault fault = e.getFault();
+ assertTrue(fault != null);
+ assertTrue(fault.getFaultString().equals("sample fault"));
+ QName expectedFaultCode = new
QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Client");
+ assertTrue(fault.getFaultCodeAsQName().equals(expectedFaultCode));
+ assertTrue(fault.getDetail() != null);
+ DetailEntry de = (DetailEntry)
fault.getDetail().getDetailEntries().next();
+ assertTrue(de != null);
+ assertTrue(de.getLocalName().equals("detailEntry"));
+ assertTrue(de.getValue().equals("sample detail"));
+ assertTrue(fault.getFaultActor().equals("sample actor"));
+ }
+
+ // Try a second time
+ try {
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+ assertTrue("Expected failure", false);
+ } catch (SOAPFaultException e) {
+ // Okay
+ SOAPFault fault = e.getFault();
+ assertTrue(fault != null);
+ assertTrue(fault.getFaultString().equals("sample fault"));
+ QName expectedFaultCode = new
QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Client");
+ assertTrue(fault.getFaultCodeAsQName().equals(expectedFaultCode));
+ assertTrue(fault.getDetail() != null);
+ DetailEntry de = (DetailEntry)
fault.getDetail().getDetailEntries().next();
+ assertTrue(de != null);
+ assertTrue(de.getLocalName().equals("detailEntry"));
+ assertTrue(de.getValue().equals("sample detail"));
+ assertTrue(fault.getFaultActor().equals("sample actor"));
+ }
+ }
+
+
+ /**
+ * Sends an SOAPMessage containing only xml data
+ * Provider will throw a generic WebServicesException
+ */
+ public void testProviderSOAPMessageWebServiceException() throws Exception {
+
+ // Create the dispatch
+ Dispatch<SOAPMessage> dispatch = createDispatch();
+
+ // Create the SOAPMessage
+ String msg = reqMsgStart + XML_WSE_INVOKE + reqMsgEnd;
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage request = factory.createMessage(null,
+ new ByteArrayInputStream(msg.getBytes()));
+
+ // Test the transport headers by sending a content description
+ request.setContentDescription(SoapMessageProvider.XML_WSE_REQUEST);
+
+ try {
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+ assertTrue("Expected failure", false);
+ } catch (SOAPFaultException e) {
+ // Okay...SOAPFaultException should be thrown
+ SOAPFault fault = e.getFault();
+ assertTrue(fault != null);
+ assertTrue(fault.getFaultString().equals("A WSE was thrown"));
+ }
+
+ // Try a second time
+ try {
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+ assertTrue("Expected failure", false);
+ } catch (SOAPFaultException e) {
+ // Okay...SOAPFaultException should be thrown
+ SOAPFault fault = e.getFault();
+ assertTrue(fault != null);
+ assertTrue(fault.getFaultString().equals("A WSE was thrown"));
+ }
+ }
+
+
+ /**
+ * Sends an SOAPMessage containing xml data and raw attachments to the web
service.
+ * Receives a response containing xml data and the same raw attachments.
+ */
+
+ public void testProviderSOAPMessageRawAttachment(){
+ // Raw Attachments are attachments that are not referenced in the xml
with MTOM or SWARef.
+ // Currently there is no support in Axis 2 for these kinds of
attachments.
+ // The belief is that most customers will use MTOM. Some legacy
customers will use SWARef.
+ // Raw Attachments may be so old that no customers need this behavior.
+ try{
+ // Create the dispatch
+ Dispatch<SOAPMessage> dispatch = createDispatch();
+
+ // Create the SOAPMessage
+ String msg = reqMsgStart + ATTACHMENT_INVOKE + reqMsgEnd;
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage request = factory.createMessage(null,
+ new ByteArrayInputStream(msg.getBytes()));
+
+ // Add the Attachment
+ AttachmentPart ap =
request.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT,
"text/xml");
+ ap.setContentId(SoapMessageProvider.ID);
+ request.addAttachmentPart(ap);
+
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+
+ // Check assertions and get the data element
+ SOAPElement dataElement = assertResponseXML(response,
SoapMessageProvider.XML_ATTACHMENT_RESPONSE);
+ assertTrue(countAttachments(response) == 1);
+
+ // Get the Attachment
+ AttachmentPart attachmentPart = (AttachmentPart)
response.getAttachments().next();
+
+ // Check the attachment
+ StreamSource contentSS = (StreamSource)
attachmentPart.getContent();
+ String content = SoapMessageProvider.getAsString(contentSS);
+ assertTrue(content != null);
+
assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+
+ // Print out the response
+ System.out.println(">> Response [" + response.toString() + "]");
+
+
+ // Try a second time
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ response = dispatch.invoke(request);
+
+ // Check assertions and get the data element
+ dataElement = assertResponseXML(response,
SoapMessageProvider.XML_ATTACHMENT_RESPONSE);
+ assertTrue(countAttachments(response) == 1);
+
+ // Get the Attachment
+ attachmentPart = (AttachmentPart) response.getAttachments().next();
+
+ // Check the attachment
+ contentSS = (StreamSource) attachmentPart.getContent();
+ content = SoapMessageProvider.getAsString(contentSS);
+ assertTrue(content != null);
+
assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+
+ // Print out the response
+ System.out.println(">> Response [" + response.toString() + "]");
+
+ }catch(Exception e){
+ e.printStackTrace();
+ fail("Caught exception " + e);
+ }
+
+ }
+
+ /**
+ * Sends an SOAPMessage containing xml data and mtom attachment.
+ * Receives a response containing xml data and the mtom attachment.
+ */
+ public void testProviderSOAPMessageMTOM(){
+ try{
+ // Create the dispatch
+ Dispatch<SOAPMessage> dispatch = createDispatch();
+
+ // MTOM should be automatically detected. There is no need to set
it
+ //Binding binding = dispatch.getBinding();
+ //SOAPBinding soapBinding = (SOAPBinding) binding;
+ //soapBinding.setMTOMEnabled(true);
+
+ // Create the SOAPMessage
+ String msg = reqMsgStart + MTOM_INVOKE + reqMsgEnd;
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage request = factory.createMessage(null,
+ new ByteArrayInputStream(msg.getBytes()));
+
+ // Add the Attachment
+ AttachmentPart ap =
request.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT,
"text/xml");
+ ap.setContentId(SoapMessageProvider.ID);
+ request.addAttachmentPart(ap);
+
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+
+ // Check assertions and get the data element
+ SOAPElement dataElement = assertResponseXML(response,
SoapMessageProvider.XML_MTOM_RESPONSE);
+ assertTrue(countAttachments(response) == 1);
+
+ // Get the Attachment
+ AttachmentPart attachmentPart = (AttachmentPart)
response.getAttachments().next();
+
+ // Check the attachment
+ StreamSource contentSS = (StreamSource)
attachmentPart.getContent();
+ String content = SoapMessageProvider.getAsString(contentSS);
+ assertTrue(content != null);
+
assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+
+ // Print out the response
+ System.out.println(">> Response [" + response.toString() + "]");
+
+
+ // Try a second time
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ response = dispatch.invoke(request);
+
+ // Check assertions and get the data element
+ dataElement = assertResponseXML(response,
SoapMessageProvider.XML_MTOM_RESPONSE);
+ assertTrue(countAttachments(response) == 1);
+
+ // Get the Attachment
+ attachmentPart = (AttachmentPart) response.getAttachments().next();
+
+ // Check the attachment
+ contentSS = (StreamSource) attachmentPart.getContent();
+ content = SoapMessageProvider.getAsString(contentSS);
+ assertTrue(content != null);
+
assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+
+ // Print out the response
+ System.out.println(">> Response [" + response.toString() + "]");
+
+ }catch(Exception e){
+ e.printStackTrace();
+ fail("Caught exception " + e);
+ }
+
+ }
+
+ /**
+ * Sends an SOAPMessage containing xml data and a swaref attachment to the
web service.
+ * Receives a response containing xml data and the swaref attachment
attachment.
+ */
+ public void testProviderSOAPMessageSWARef(){
+ try{
+ // Create the dispatch
+ Dispatch<SOAPMessage> dispatch = createDispatch();
+
+ // Create the SOAPMessage
+ String msg = reqMsgStart + SWAREF_INVOKE + reqMsgEnd;
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage request = factory.createMessage(null,
+ new ByteArrayInputStream(msg.getBytes()));
+
+ // Add the Attachment
+ AttachmentPart ap =
request.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT,
"text/xml");
+ ap.setContentId(SoapMessageProvider.ID);
+ request.addAttachmentPart(ap);
+
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+
+ // Check assertions and get the data element
+ SOAPElement dataElement = assertResponseXML(response,
SoapMessageProvider.XML_SWAREF_RESPONSE);
+ assertTrue(countAttachments(response) == 1);
+
+ // Get the Attachment
+ AttachmentPart attachmentPart = (AttachmentPart)
response.getAttachments().next();
+
+ // Check the attachment
+ StreamSource contentSS = (StreamSource)
attachmentPart.getContent();
+ String content = SoapMessageProvider.getAsString(contentSS);
+ assertTrue(content != null);
+
assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+ assertEquals(SoapMessageProvider.ID,
attachmentPart.getContentId());
+
+ // Print out the response
+ System.out.println(">> Response [" + response.toString() + "]");
+
+
+
+ // Try a second time
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ response = dispatch.invoke(request);
+
+ // Check assertions and get the data element
+ dataElement = assertResponseXML(response,
SoapMessageProvider.XML_SWAREF_RESPONSE);
+ assertTrue(countAttachments(response) == 1);
+
+ // Get the Attachment
+ attachmentPart = (AttachmentPart) response.getAttachments().next();
+
+ // Check the attachment
+ contentSS = (StreamSource) attachmentPart.getContent();
+ content = SoapMessageProvider.getAsString(contentSS);
+ assertTrue(content != null);
+
assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+ assertEquals(SoapMessageProvider.ID,
attachmentPart.getContentId());
+
+ // Print out the response
+ System.out.println(">> Response [" + response.toString() + "]");
+
+ }catch(Exception e){
+ e.printStackTrace();
+ fail("Caught exception " + e);
+ }
+
+ }
+
+ /* This is a negative test case for a Provider that has NO SOAPBinding
restriction
+ * Dispatch will send a SOAP11 request and Provider will send a SOAP12
Response.
+ */
+ public void testSoap11RequestWithSoap12Response(){
+ SOAPMessage request = null;
+ Dispatch<SOAPMessage> dispatch = null;
+ try{
+ // Create the dispatch
+ dispatch = createDispatch();
+ // Create the SOAPMessage
+ String msg = reqMsgStart + XML_SOAP12_RESPONSE_INVOKE + reqMsgEnd;
+ MessageFactory factory = MessageFactory.newInstance();
+ request = factory.createMessage(null,
+ new ByteArrayInputStream(msg.getBytes()));
+ }catch(Exception e){
+ e.printStackTrace();
+ fail("Caught Exception "+e);
+ }
+ try{
+ SOAPMessage response = dispatch.invoke(request);
+ assertTrue("Expecting Failure", false);
+ }catch(SOAPFaultException e){
+ SOAPFault fault = e.getFault();
+ assertTrue(fault != null);
+ assertTrue(fault.getFaultString().equals("Request SOAP message
protocol is version 1.1, but Response SOAP message is configured for SOAP 1.2.
This is not supported."));
+ }
+
+ }
+ /**
+ * @return
+ * @throws Exception
+ */
+ private Dispatch<SOAPMessage> createDispatch() throws Exception {
+
+
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName,null, endpointUrl);
+ Dispatch<SOAPMessage> dispatch =
+ svc.createDispatch(portName, SOAPMessage.class,
Service.Mode.MESSAGE);
+ return dispatch;
+ }
+
+ /**
+ * @return
+ * @throws Exception
+ */
+ private Dispatch<String> createStringDispatch() throws Exception {
+
+
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName,null, endpointUrl);
+ Dispatch<String> dispatch =
+ svc.createDispatch(portName, String.class, Service.Mode.PAYLOAD);
+ return dispatch;
+ }
+
+ /**
+ * Common assertion checking of the response
+ * @param msg
+ * @param expectedText
+ * @return SOAPElement representing the data element
+ */
+ private SOAPElement assertResponseXML(SOAPMessage msg, String
expectedText) throws Exception {
+ assertTrue(msg != null);
+ SOAPBody body = msg.getSOAPBody();
+ assertTrue(body != null);
+
+ Node invokeElement = (Node) body.getFirstChild();
+ assertTrue(invokeElement instanceof SOAPElement);
+ assertEquals(SoapMessageProvider.RESPONSE_NAME,
invokeElement.getLocalName());
+
+ Node dataElement = (Node) invokeElement.getFirstChild();
+ assertTrue(dataElement instanceof SOAPElement);
+ assertEquals(SoapMessageProvider.RESPONSE_DATA_NAME,
dataElement.getLocalName());
+
+ // TODO AXIS2 SAAJ should (but does not) support the getTextContent();
+ // String text = dataElement.getTextContent();
+ String text = dataElement.getValue();
+ assertEquals("Found ("+ text + ") but expected (" + expectedText +
")", expectedText, text);
+
+ return (SOAPElement) dataElement;
+ }
+
+ /**
+ * Count Attachments
+ * @param msg
+ * @return
+ */
+ private int countAttachments(SOAPMessage msg) {
+ Iterator it = msg.getAttachments();
+ int count = 0;
+ assertTrue(it != null);
+ while (it.hasNext()) {
+ it.next();
+ count++;
+ }
+ return count;
+ }
}
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/StringProviderTests.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/StringProviderTests.java?rev=1819261&r1=1819260&r2=1819261&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/StringProviderTests.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/StringProviderTests.java
Mon Dec 25 20:14:42 2017
@@ -36,63 +36,63 @@ import junit.framework.TestSuite;
import org.apache.axis2.jaxws.framework.AbstractTestCase;
public class StringProviderTests extends AbstractTestCase {
- private String endpointUrl =
"http://localhost:6060/axis2/services/SOAPBindingStringProviderService.SOAPBindingStringProviderPort";
- private QName serviceName = new
QName("http://StringProvider.soapbinding.provider.jaxws.axis2.apache.org",
"SOAPBindingStringProviderService");
- private QName portName = new
QName("http://StringProvider.soapbinding.provider.jaxws.axis2.apache.org",
"SOAPBindingStringProviderPort");
-
- private static final String SOAP11_NS_URI =
"http://schemas.xmlsoap.org/soap/envelope/";
- private static final String SOAP12_NS_URI =
"http://www.w3.org/2003/05/soap-envelope";
- public static final String SOAP11_ENVELOPE_HEAD = "<?xml version='1.0'
encoding='utf-8'?>" +
- "<soapenv:Envelope xmlns:soapenv=\"" + SOAP11_NS_URI + "\">" +
- "<soapenv:Header />" +
- "<soapenv:Body>";
-
- public static final String SOAP12_ENVELOPE_HEAD =
- "<?xml version='1.0' encoding='utf-8'?>" +
- "<soapenv:Envelope xmlns:soapenv=\"" + SOAP12_NS_URI + "\">" +
- "<soapenv:Header />" +
- "<soapenv:Body>";
-
- public static final String SOAP11_ENVELOPE_TAIL =
- "</soapenv:Body>" +
- "</soapenv:Envelope>";
-
- public static final String SOAP12_ENVELOPE_TAIL =
- "</soapenv:Body>" +
- "</soapenv:Envelope>";
-
- public static Test suite() {
+ private String endpointUrl =
"http://localhost:6060/axis2/services/SOAPBindingStringProviderService.SOAPBindingStringProviderPort";
+ private QName serviceName = new
QName("http://StringProvider.soapbinding.provider.jaxws.axis2.apache.org",
"SOAPBindingStringProviderService");
+ private QName portName = new
QName("http://StringProvider.soapbinding.provider.jaxws.axis2.apache.org",
"SOAPBindingStringProviderPort");
+
+ private static final String SOAP11_NS_URI =
"http://schemas.xmlsoap.org/soap/envelope/";
+ private static final String SOAP12_NS_URI =
"http://www.w3.org/2003/05/soap-envelope";
+ public static final String SOAP11_ENVELOPE_HEAD = "<?xml version='1.0'
encoding='utf-8'?>" +
+ "<soapenv:Envelope xmlns:soapenv=\"" + SOAP11_NS_URI + "\">" +
+ "<soapenv:Header />" +
+ "<soapenv:Body>";
+
+ public static final String SOAP12_ENVELOPE_HEAD =
+ "<?xml version='1.0' encoding='utf-8'?>" +
+ "<soapenv:Envelope xmlns:soapenv=\"" + SOAP12_NS_URI + "\">" +
+ "<soapenv:Header />" +
+ "<soapenv:Body>";
+
+ public static final String SOAP11_ENVELOPE_TAIL =
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static final String SOAP12_ENVELOPE_TAIL =
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static Test suite() {
return getTestSetup(new TestSuite(StringProviderTests.class));
}
/*
* This test case makes sure that we receive a soap11 response for a soap11
request.
*/
- public void testsoap11request(){
- System.out.println("---------------------------------------");
- System.out.println("test: " + getName());
- try{
- Service svc = Service.create(serviceName);
- svc.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING,
endpointUrl);
-
- Dispatch<String> dispatch =
- svc.createDispatch(portName, String.class,
Service.Mode.MESSAGE);
- String xmlMessage =
SOAP11_ENVELOPE_HEAD+"<invokeOp>soap11 request</invokeOp>"+SOAP11_ENVELOPE_TAIL;
- String response = dispatch.invoke(xmlMessage);
-
- MessageFactory factory = MessageFactory.newInstance();
- SOAPMessage soapMessage = factory.createMessage(null,
new ByteArrayInputStream(response.getBytes()));
-
assertTrue(getVersionURI(soapMessage).equals(SOAP11_NS_URI));
- }catch(Exception e){
- System.out.println("Failure while sending soap 11
request");
- System.out.println(e.getMessage());
- fail();
- }
-
- }
-
- private String getVersionURI(SOAPMessage soapMessage)throws
SOAPException{
- SOAPPart sp = soapMessage.getSOAPPart();
- SOAPEnvelope envelope = sp.getEnvelope();
- return envelope.getNamespaceURI();
- }
+ public void testsoap11request(){
+ System.out.println("---------------------------------------");
+ System.out.println("test: " + getName());
+ try{
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
+
+ Dispatch<String> dispatch =
+ svc.createDispatch(portName, String.class,
Service.Mode.MESSAGE);
+ String xmlMessage = SOAP11_ENVELOPE_HEAD+"<invokeOp>soap11
request</invokeOp>"+SOAP11_ENVELOPE_TAIL;
+ String response = dispatch.invoke(xmlMessage);
+
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage soapMessage = factory.createMessage(null, new
ByteArrayInputStream(response.getBytes()));
+ assertTrue(getVersionURI(soapMessage).equals(SOAP11_NS_URI));
+ }catch(Exception e){
+ System.out.println("Failure while sending soap 11 request");
+ System.out.println(e.getMessage());
+ fail();
+ }
+
+ }
+
+ private String getVersionURI(SOAPMessage soapMessage)throws SOAPException{
+ SOAPPart sp = soapMessage.getSOAPPart();
+ SOAPEnvelope envelope = sp.getEnvelope();
+ return envelope.getNamespaceURI();
+ }
}
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/tests/RPCLitEnumTests.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/tests/RPCLitEnumTests.java?rev=1819261&r1=1819260&r2=1819261&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/tests/RPCLitEnumTests.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/rpclit/enumtype/tests/RPCLitEnumTests.java
Mon Dec 25 20:14:42 2017
@@ -34,13 +34,13 @@ import javax.xml.ws.Holder;
public class RPCLitEnumTests extends AbstractTestCase {
- String axisEndpoint =
"http://localhost:6060/axis2/services/RPCLitEnumService.PortTypeImplPort";
+ String axisEndpoint =
"http://localhost:6060/axis2/services/RPCLitEnumService.PortTypeImplPort";
- public static Test suite() {
+ public static Test suite() {
return getTestSetup(new TestSuite(RPCLitEnumTests.class));
}
- public void testEnumSimpleType(){
+ public void testEnumSimpleType(){
TestLogger.logger.debug("------------------------------");
TestLogger.logger.debug("Test : " + getName());
try{
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java?rev=1819261&r1=1819260&r2=1819261&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
Mon Dec 25 20:14:42 2017
@@ -74,7 +74,7 @@ import org.apache.axis2.jaxws.spi.Servic
import org.test.addnumbershandler.AddNumbersHandlerResponse;
public class AddNumbersHandlerTests extends AbstractTestCase {
-
+
String axisEndpoint =
"http://localhost:6060/axis2/services/AddNumbersHandlerService.AddNumbersHandlerPortTypeImplPort";
String invalidAxisEndpoint =
"http://invalidHostName:6060/axis2/services/AddNumbersHandlerService.AddNumbersHandlerPortTypeImplPort";
@@ -107,14 +107,14 @@ public class AddNumbersHandlerTests exte
* 3) General handler framework functionality; make sure handlers are
instantiated and called
*/
public void testAddNumbersHandler() {
- try{
+ try{
TestLogger.logger.debug("----------------------------------");
TestLogger.logger.debug("test: " + getName());
-
+
AddNumbersHandlerService service = new AddNumbersHandlerService();
AddNumbersHandlerPortType proxy =
service.getAddNumbersHandlerPort();
-
- BindingProvider p = (BindingProvider)proxy;
+
+ BindingProvider p = (BindingProvider)proxy;
p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
axisEndpoint);
int total = proxy.addNumbersHandler(10, 10);
@@ -149,11 +149,11 @@ public class AddNumbersHandlerTests exte
assertEquals(expected_calls, log);
TestLogger.logger.debug("----------------------------------");
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
+ } catch(Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
/**
* Client app sends MAXVALUE, MAXVALUE as params to add.
@@ -771,8 +771,8 @@ public class AddNumbersHandlerTests exte
assertTrue("Exception should be SOAPFaultException", e instanceof
SOAPFaultException);
//AXIS2-2417 - assertEquals(((SOAPFaultException)e).getMessage(),
"AddNumbersLogicalHandler2 was here");
assertTrue(((SOAPFaultException)e).getMessage().contains("Got
value 101. " +
- "AddNumbersHandlerPortTypeImpl.addNumbersHandler method
is " +
- "correctly throwing this exception as part of
testing"));
+ "AddNumbersHandlerPortTypeImpl.addNumbersHandler method is
" +
+ "correctly throwing this exception as part of testing"));
String log = readLogFile();
String expected_calls = "AddNumbersClientLogicalHandler
HANDLE_MESSAGE_OUTBOUND\n"
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/HeadersHandlerTests.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/HeadersHandlerTests.java?rev=1819261&r1=1819260&r2=1819261&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/HeadersHandlerTests.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/HeadersHandlerTests.java
Mon Dec 25 20:14:42 2017
@@ -96,43 +96,43 @@ public class HeadersHandlerTests extends
*/
String acoh1, acoh2, acoh3, acoh4, acoh5, acoh6;
SOAPFactory sf = SOAPFactory.newInstance();
- try {
- Map<QName, List<String>> requestHeaders = new HashMap<QName,
List<String>>();
-
- // QName used here should match the key for the list set on the
requestCtx
- acoh1 =
TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME,
TestHeaders.CONTENT_SMALL1);
-
- // QName used here should match the key for the list set on the
requestCtx
- acoh2 =
TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME,
TestHeaders.CONTENT_SMALL2);
-
- // QName used here should match the key for the list set on the
requestCtx
- acoh3 =
TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME,
TestHeaders.CONTENT_SMALL3);
-
- // QName used here should match the key for the list set on the
requestCtx
- acoh4 =
TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME,
TestHeaders.CONTENT_SMALL4);
-
- // create additional header strings that will need to be
checked:
- acoh5 =
TestHeaders.createHeaderXMLString(TestHeaders.ACOH3_HEADER_QNAME,
TestHeaders.CONTENT_LARGE);
- acoh6 =
TestHeaders.createHeaderXMLString(TestHeaders.ACOH4_HEADER_QNAME,
TestHeaders.CONTENT_SMALL4);
-
- List<String> list1 = new ArrayList<String>();
- list1.add(acoh1);
- list1.add(acoh2);
-
- List<String> list2 = new ArrayList<String>();
- list2.add(acoh3);
- list2.add(acoh4);
-
- requestHeaders.put(TestHeaders.ACOH1_HEADER_QNAME, list1);
- requestHeaders.put(TestHeaders.ACOH2_HEADER_QNAME, list2);
- requestCtx.put(Constants.JAXWS_OUTBOUND_SOAP_HEADERS,
requestHeaders);
- } catch (Throwable e) {
- fail(e.getMessage());
- return;
- }
-
- // some handlers decrement the value, so we can confirm SOAP body
manipulation does not corrupt the headers
- int numOfHandlerHitsInFlow = 3;
+ try {
+ Map<QName, List<String>> requestHeaders = new HashMap<QName,
List<String>>();
+
+ // QName used here should match the key for the list set on the
requestCtx
+ acoh1 =
TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME,
TestHeaders.CONTENT_SMALL1);
+
+ // QName used here should match the key for the list set on the
requestCtx
+ acoh2 =
TestHeaders.createHeaderXMLString(TestHeaders.ACOH1_HEADER_QNAME,
TestHeaders.CONTENT_SMALL2);
+
+ // QName used here should match the key for the list set on the
requestCtx
+ acoh3 =
TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME,
TestHeaders.CONTENT_SMALL3);
+
+ // QName used here should match the key for the list set on the
requestCtx
+ acoh4 =
TestHeaders.createHeaderXMLString(TestHeaders.ACOH2_HEADER_QNAME,
TestHeaders.CONTENT_SMALL4);
+
+ // create additional header strings that will need to be checked:
+ acoh5 =
TestHeaders.createHeaderXMLString(TestHeaders.ACOH3_HEADER_QNAME,
TestHeaders.CONTENT_LARGE);
+ acoh6 =
TestHeaders.createHeaderXMLString(TestHeaders.ACOH4_HEADER_QNAME,
TestHeaders.CONTENT_SMALL4);
+
+ List<String> list1 = new ArrayList<String>();
+ list1.add(acoh1);
+ list1.add(acoh2);
+
+ List<String> list2 = new ArrayList<String>();
+ list2.add(acoh3);
+ list2.add(acoh4);
+
+ requestHeaders.put(TestHeaders.ACOH1_HEADER_QNAME, list1);
+ requestHeaders.put(TestHeaders.ACOH2_HEADER_QNAME, list2);
+ requestCtx.put(Constants.JAXWS_OUTBOUND_SOAP_HEADERS,
requestHeaders);
+ } catch (Throwable e) {
+ fail(e.getMessage());
+ return;
+ }
+
+ // some handlers decrement the value, so we can confirm SOAP body
manipulation does not corrupt the headers
+ int numOfHandlerHitsInFlow = 3;
int intParam1 = 10;
int intParam2 = 10;
@@ -155,7 +155,7 @@ public class HeadersHandlerTests extends
String log = readLogFile();
String expected_calls =
- // client outbound
+ // client outbound
"HeadersClientLogicalHandler HANDLE_MESSAGE_OUTBOUND\n"
+ "HeadersClientLogicalHandler CHECKED_HEADER "+acoh1+"\n"
+ "HeadersClientLogicalHandler CHECKED_HEADER "+acoh2+"\n"
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleByteArrayTests.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleByteArrayTests.java?rev=1819261&r1=1819260&r2=1819261&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleByteArrayTests.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleByteArrayTests.java
Mon Dec 25 20:14:42 2017
@@ -57,31 +57,31 @@ public class MtomSampleByteArrayTests ex
public void _testAttachmentByteArrayAPI11() throws Exception {
TestLogger.logger.debug("----------------------------------");
TestLogger.logger.debug("test: " + getName());
-
- String imageResourceDir = IMAGE_DIR;
-
- Service svc = Service.create(QNAME_SERVICE);
- svc.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT);
-
- JAXBContext jbc =
JAXBContext.newInstance("org.apache.axis2.jaxws.sample.mtom1");
- Dispatch<Object> dispatch = svc.createDispatch(QNAME_PORT, jbc,
Service.Mode.PAYLOAD);
-
- SOAPBinding binding = (SOAPBinding)dispatch.getBinding();
- binding.setMTOMEnabled(true);
-
- Image image = ImageIO.read (new
File(imageResourceDir+File.separator+"test.jpg"));
- ImageDepot imageDepot = new ObjectFactory().createImageDepot();
- imageDepot.setImageData(image);
+
+ String imageResourceDir = IMAGE_DIR;
+
+ Service svc = Service.create(QNAME_SERVICE);
+ svc.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT);
+
+ JAXBContext jbc =
JAXBContext.newInstance("org.apache.axis2.jaxws.sample.mtom1");
+ Dispatch<Object> dispatch = svc.createDispatch(QNAME_PORT, jbc,
Service.Mode.PAYLOAD);
+
+ SOAPBinding binding = (SOAPBinding)dispatch.getBinding();
+ binding.setMTOMEnabled(true);
+
+ Image image = ImageIO.read (new
File(imageResourceDir+File.separator+"test.jpg"));
+ ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+ imageDepot.setImageData(image);
setText(imageDepot);
-
- //Create a request bean with imagedepot bean as value
- ObjectFactory factory = new ObjectFactory();
- Invoke request = factory.createInvoke();
- request.setInput(imageDepot);
-
- SendImageResponse response = (SendImageResponse)
dispatch.invoke(request);
-
- assertNotNull(response);
+
+ //Create a request bean with imagedepot bean as value
+ ObjectFactory factory = new ObjectFactory();
+ Invoke request = factory.createInvoke();
+ request.setInput(imageDepot);
+
+ SendImageResponse response = (SendImageResponse)
dispatch.invoke(request);
+
+ assertNotNull(response);
assertNotNull(response.getOutput().getImageData());
checkText(response.getOutput());
@@ -103,7 +103,7 @@ public class MtomSampleByteArrayTests ex
TestLogger.logger.debug("test: " + getName());
String imageResourceDir = IMAGE_DIR;
-
+
Service svc = Service.create(QNAME_SERVICE);
svc.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT);
@@ -145,28 +145,28 @@ public class MtomSampleByteArrayTests ex
TestLogger.logger.debug("----------------------------------");
TestLogger.logger.debug("test: " + getName());
-
- String imageResourceDir = IMAGE_DIR;
-
- Service svc = Service.create(QNAME_SERVICE);
- svc.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_MTOM_BINDING,
URL_ENDPOINT);
-
- JAXBContext jbc =
JAXBContext.newInstance("org.apache.axis2.jaxws.sample.mtom1");
- Dispatch<Object> dispatch = svc.createDispatch(QNAME_PORT, jbc,
Service.Mode.PAYLOAD);
-
- Image image = ImageIO.read (new
File(imageResourceDir+File.separator+"test.jpg"));
- ImageDepot imageDepot = new ObjectFactory().createImageDepot();
- imageDepot.setImageData(image);
+
+ String imageResourceDir = IMAGE_DIR;
+
+ Service svc = Service.create(QNAME_SERVICE);
+ svc.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_MTOM_BINDING,
URL_ENDPOINT);
+
+ JAXBContext jbc =
JAXBContext.newInstance("org.apache.axis2.jaxws.sample.mtom1");
+ Dispatch<Object> dispatch = svc.createDispatch(QNAME_PORT, jbc,
Service.Mode.PAYLOAD);
+
+ Image image = ImageIO.read (new
File(imageResourceDir+File.separator+"test.jpg"));
+ ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+ imageDepot.setImageData(image);
setText(imageDepot);
-
- //Create a request bean with imagedepot bean as value
- ObjectFactory factory = new ObjectFactory();
- Invoke request = factory.createInvoke();
- request.setInput(imageDepot);
-
- SendImageResponse response = (SendImageResponse)
dispatch.invoke(request);
-
- assertNotNull(response);
+
+ //Create a request bean with imagedepot bean as value
+ ObjectFactory factory = new ObjectFactory();
+ Invoke request = factory.createInvoke();
+ request.setInput(imageDepot);
+
+ SendImageResponse response = (SendImageResponse)
dispatch.invoke(request);
+
+ assertNotNull(response);
assertNotNull(response.getOutput().getImageData());
checkText(response.getOutput());
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/NonWrapTests.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/NonWrapTests.java?rev=1819261&r1=1819260&r2=1819261&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/NonWrapTests.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/NonWrapTests.java
Mon Dec 25 20:14:42 2017
@@ -40,12 +40,12 @@ import java.util.concurrent.Future;
public class NonWrapTests extends AbstractTestCase {
- String axisEndpoint =
"http://localhost:6060/axis2/services/DocLitNonWrapService.DocLitNonWrapPortTypeImplPort";
-
+ String axisEndpoint =
"http://localhost:6060/axis2/services/DocLitNonWrapService.DocLitNonWrapPortTypeImplPort";
+
public static Test suite() {
return getTestSetup(new TestSuite(NonWrapTests.class));
}
-
+
public void testTwoWaySync(){
TestLogger.logger.debug("------------------------------");
TestLogger.logger.debug("Test : " + getName());
@@ -55,7 +55,7 @@ public class NonWrapTests extends Abstra
DocLitNonWrapService service = new DocLitNonWrapService();
DocLitNonWrapPortType proxy = service.getDocLitNonWrapPort();
- BindingProvider p = (BindingProvider)proxy;
+ BindingProvider p = (BindingProvider)proxy;
p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
axisEndpoint);
ReturnType returnValue = proxy.twoWay(twoWay);
@@ -79,8 +79,8 @@ public class NonWrapTests extends Abstra
DocLitNonWrapService service = new DocLitNonWrapService();
DocLitNonWrapPortType proxy = service.getDocLitNonWrapPort();
- BindingProvider p = (BindingProvider)proxy;
-
p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
axisEndpoint);
+ BindingProvider p = (BindingProvider)proxy;
+
p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
axisEndpoint);
ReturnType returnValue = proxy.twoWay(twoWay);
@@ -114,7 +114,7 @@ public class NonWrapTests extends Abstra
DocLitNonWrapService service = new DocLitNonWrapService();
DocLitNonWrapPortType proxy = service.getDocLitNonWrapPort();
- BindingProvider p = (BindingProvider)proxy;
+ BindingProvider p = (BindingProvider)proxy;
p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
axisEndpoint);
AsyncCallback callback = new AsyncCallback();
@@ -145,7 +145,7 @@ public class NonWrapTests extends Abstra
DocLitNonWrapService service = new DocLitNonWrapService();
DocLitNonWrapPortType proxy = service.getDocLitNonWrapPort();
- BindingProvider p = (BindingProvider)proxy;
+ BindingProvider p = (BindingProvider)proxy;
p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
axisEndpoint);
proxy.twoWayHolder(holder);
@@ -165,7 +165,7 @@ public class NonWrapTests extends Abstra
fail();
}
}
-
+
public void testTwoWayHolderAsync(){
TestLogger.logger.debug("------------------------------");
TestLogger.logger.debug("Test : " + getName());
@@ -179,7 +179,7 @@ public class NonWrapTests extends Abstra
DocLitNonWrapService service = new DocLitNonWrapService();
DocLitNonWrapPortType proxy = service.getDocLitNonWrapPort();
- BindingProvider p = (BindingProvider)proxy;
+ BindingProvider p = (BindingProvider)proxy;
p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
axisEndpoint);
AsyncCallback callback = new AsyncCallback();
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/asyncdoclit/client/AsyncClient.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/asyncdoclit/client/AsyncClient.java?rev=1819261&r1=1819260&r2=1819261&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/asyncdoclit/client/AsyncClient.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/asyncdoclit/client/AsyncClient.java
Mon Dec 25 20:14:42 2017
@@ -30,119 +30,119 @@ public class AsyncClient {
private static final String DOCLITWR_ASYNC_ENDPOINT =
"http://localhost:6060/axis2/services/AsyncService2.DocLitWrappedPortImplPort";
- private static final int max_isasleep_check = 30;
-
- /**
- * Auxiliary method used for doiing isAsleep checks. Will perform
isAsleep
- * up to a MAX_ISASLEEP_CHECK number of checks. Will sleep for
- * SLEEP_ISASLEEP_SEC seconds in between requests. If reaches maximum
number
- * fo retries then will fail the test
- */
- public static boolean isAsleepCheck(String MESSAGE, AsyncPort port)
throws Exception {
- boolean asleep = false;
- int check = 5; //Constants.MAX_ISASLEEP_CHECK;
- String msg = null;
-
- final long start = System.currentTimeMillis();
-
- System.out.println("AsyncClient.isAsleepCheck(" + MESSAGE + ")
Enter");
-
- do {
- try {
- msg = port.isAsleep();
- } catch (Exception e){
- System.out.println("AsyncClient.isAsleepCheck
Exception on isAsleep:" + e);
- throw e;
- }
-
- asleep = (msg != null);
-
- // fail the test if we ran out of checks
- if ((check--) == 0) {
- System.out.println("AsyncClient.isAsleepCheck="
+ asleep
- + " after " +
(/*Constants.MAX_ISASLEEP_CHECK*/ max_isasleep_check - check)
- + " tries");
- throw new RuntimeException("Server did not
receive sleep after several retries");
- }
-
- // sleep for a bit
- try {
- Thread.sleep(/*Constants.SLEEP_ISASLEEP_SEC*/ 1
* 1000);
- } catch (InterruptedException e) {
- System.out.println("AsyncClient.isAsleepCheck
(ignored error) "
- + e);
- }
-
- } while (!asleep);
-
- System.out.println("AsyncClient.isAsleepCheck() asleep=" +
asleep + " after "
- + (/*Constants.MAX_ISASLEEP_CHECK*/
max_isasleep_check - check) + " tries");
-
- if (asleep) {
- System.out.println("AsyncClient.isAsleepCheck sleeping
on:" + msg);
- if (!MESSAGE.equals(msg)) {
- throw new RuntimeException("Sleeping on an
incorrect message");
- }
- }
-
- long mins = (System.currentTimeMillis() - start) / 1000;
- System.out.println("AsyncClient.isAsleepCheck() Exit, time=" +
mins + "min");
-
- return true;
- }
-
- /**
- * Auxiliary method used for obtaining a proxy pre-configured with a
- * specific Executor
- */
- public static AsyncPort getPort(Executor ex) {
- AsyncService service = new AsyncService();
-
- if (ex != null) service.setExecutor(ex);
-
- AsyncPort port = service.getAsyncPort();
- if (port == null) {
- throw new RuntimeException("service.getAsyncPort() is
null");
- }
-
- Map<String, Object> rc = ((BindingProvider)
port).getRequestContext();
- rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- DOCLITWR_ASYNC_ENDPOINT);
//Constants.DOCLITWR_ASYNC_ENDPOINT);
-
- System.out.println("AsyncClient.getPort() = "
- + DOCLITWR_ASYNC_ENDPOINT);
//Constants.DOCLITWR_ASYNC_ENDPOINT);
-
- return port;
- }
-
- /**
- * Auxiliary method used to wait for a monitor for a certain amount of
time
- * before timing out
- *
- * @param monitor
- */
- public static void waitBlocking(Future<?> monitor) throws Exception {
-
- System.out.println("AsyncClient.waitBlocking() Enter");
-
- // wait for request to complete
- int sec = /*Constants.CLIENT_MAX_SLEEP_SEC*/ max_isasleep_check;
- while (!monitor.isDone() && !monitor.isCancelled()) {
- Thread.sleep(1000);
- sec--;
- if (sec <= 0) break;
- }
-
- if (sec <= 0) {
- System.out.println("AsyncClient.waitBlocking Exit,
timeout after"
- + /*Constants.CLIENT_MAX_SLEEP_SEC*/
max_isasleep_check + " sec");
-
- throw new TimeoutException(
- "Stopped waiting for Async response
after "
- +
/*Constants.CLIENT_MAX_SLEEP_SEC*/ max_isasleep_check + " sec");
- } else {
- System.out.println("AsyncClient.waitBlocking Exit, " +
sec
- + "sec remaining");
- }
- }
+ private static final int max_isasleep_check = 30;
+
+ /**
+ * Auxiliary method used for doiing isAsleep checks. Will perform isAsleep
+ * up to a MAX_ISASLEEP_CHECK number of checks. Will sleep for
+ * SLEEP_ISASLEEP_SEC seconds in between requests. If reaches maximum
number
+ * fo retries then will fail the test
+ */
+ public static boolean isAsleepCheck(String MESSAGE, AsyncPort port) throws
Exception {
+ boolean asleep = false;
+ int check = 5; //Constants.MAX_ISASLEEP_CHECK;
+ String msg = null;
+
+ final long start = System.currentTimeMillis();
+
+ System.out.println("AsyncClient.isAsleepCheck(" + MESSAGE + ") Enter");
+
+ do {
+ try {
+ msg = port.isAsleep();
+ } catch (Exception e){
+ System.out.println("AsyncClient.isAsleepCheck Exception on
isAsleep:" + e);
+ throw e;
+ }
+
+ asleep = (msg != null);
+
+ // fail the test if we ran out of checks
+ if ((check--) == 0) {
+ System.out.println("AsyncClient.isAsleepCheck=" + asleep
+ + " after " + (/*Constants.MAX_ISASLEEP_CHECK*/
max_isasleep_check - check)
+ + " tries");
+ throw new RuntimeException("Server did not receive sleep after
several retries");
+ }
+
+ // sleep for a bit
+ try {
+ Thread.sleep(/*Constants.SLEEP_ISASLEEP_SEC*/ 1 * 1000);
+ } catch (InterruptedException e) {
+ System.out.println("AsyncClient.isAsleepCheck (ignored error) "
+ + e);
+ }
+
+ } while (!asleep);
+
+ System.out.println("AsyncClient.isAsleepCheck() asleep=" + asleep + "
after "
+ + (/*Constants.MAX_ISASLEEP_CHECK*/ max_isasleep_check -
check) + " tries");
+
+ if (asleep) {
+ System.out.println("AsyncClient.isAsleepCheck sleeping on:" + msg);
+ if (!MESSAGE.equals(msg)) {
+ throw new RuntimeException("Sleeping on an incorrect message");
+ }
+ }
+
+ long mins = (System.currentTimeMillis() - start) / 1000;
+ System.out.println("AsyncClient.isAsleepCheck() Exit, time=" + mins +
"min");
+
+ return true;
+ }
+
+ /**
+ * Auxiliary method used for obtaining a proxy pre-configured with a
+ * specific Executor
+ */
+ public static AsyncPort getPort(Executor ex) {
+ AsyncService service = new AsyncService();
+
+ if (ex != null) service.setExecutor(ex);
+
+ AsyncPort port = service.getAsyncPort();
+ if (port == null) {
+ throw new RuntimeException("service.getAsyncPort() is null");
+ }
+
+ Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
+ rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ DOCLITWR_ASYNC_ENDPOINT); //Constants.DOCLITWR_ASYNC_ENDPOINT);
+
+ System.out.println("AsyncClient.getPort() = "
+ + DOCLITWR_ASYNC_ENDPOINT);
//Constants.DOCLITWR_ASYNC_ENDPOINT);
+
+ return port;
+ }
+
+ /**
+ * Auxiliary method used to wait for a monitor for a certain amount of time
+ * before timing out
+ *
+ * @param monitor
+ */
+ public static void waitBlocking(Future<?> monitor) throws Exception {
+
+ System.out.println("AsyncClient.waitBlocking() Enter");
+
+ // wait for request to complete
+ int sec = /*Constants.CLIENT_MAX_SLEEP_SEC*/ max_isasleep_check;
+ while (!monitor.isDone() && !monitor.isCancelled()) {
+ Thread.sleep(1000);
+ sec--;
+ if (sec <= 0) break;
+ }
+
+ if (sec <= 0) {
+ System.out.println("AsyncClient.waitBlocking Exit, timeout after"
+ + /*Constants.CLIENT_MAX_SLEEP_SEC*/ max_isasleep_check +
" sec");
+
+ throw new TimeoutException(
+ "Stopped waiting for Async response after "
+ + /*Constants.CLIENT_MAX_SLEEP_SEC*/
max_isasleep_check + " sec");
+ } else {
+ System.out.println("AsyncClient.waitBlocking Exit, " + sec
+ + "sec remaining");
+ }
+ }
}