1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.teststeps.assertions.soap;
14
15 import com.eviware.soapui.config.TestAssertionConfig;
16 import com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange;
17 import com.eviware.soapui.impl.wsdl.support.wsa.WsaValidator;
18 import com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageAssertion;
19 import com.eviware.soapui.impl.wsdl.teststeps.assertions.AbstractTestAssertionFactory;
20 import com.eviware.soapui.model.iface.MessageExchange;
21 import com.eviware.soapui.model.iface.SubmitContext;
22 import com.eviware.soapui.model.testsuite.*;
23 import com.eviware.soapui.model.testsuite.AssertionError;
24
25 /***
26 * Assertion for verifying that WS-Addressing processing was ok
27 *
28 * @author dragica.soldo
29 */
30
31 public class WSAAssertion extends WsdlMessageAssertion implements ResponseAssertion, RequestAssertion
32 {
33 public static final String ID = "WS Addressing Assertion";
34 public static final String LABEL = "WS-Addressing";
35 /***
36 * Constructor for our assertion.
37 *
38 * @param assertionConfig
39 * @param modelItem
40 */
41 public WSAAssertion( TestAssertionConfig assertionConfig, Assertable modelItem )
42 {
43 super( assertionConfig, modelItem, false, false, false, true );
44 }
45
46 public static class Factory extends AbstractTestAssertionFactory
47 {
48 public Factory()
49 {
50 super(WSAAssertion.ID, WSAAssertion.LABEL, WSAAssertion.class);
51 }
52 }
53 @Override
54 protected String internalAssertRequest(MessageExchange messageExchange, SubmitContext context)
55 throws AssertionException
56 {
57 try
58 {
59 new WsaValidator( (WsdlMessageExchange) messageExchange ).validateWsAddressingRequest();
60 }
61 catch (Exception e)
62 {
63 throw new AssertionException( new AssertionError(e.getMessage()) );
64 }
65
66 return "Request WS-Addressing is valid";
67 }
68
69 @Override
70 protected String internalAssertResponse(MessageExchange messageExchange, SubmitContext context)
71 throws AssertionException
72 {
73 try
74 {
75 new WsaValidator( (WsdlMessageExchange) messageExchange ).validateWsAddressingResponse();
76 }
77 catch (Exception e)
78 {
79 throw new AssertionException( new AssertionError(e.getMessage()) );
80 }
81
82 return "Response WS-Addressing is valid";
83 }
84
85 }