1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.teststeps.assertions;
14
15 import com.eviware.soapui.config.RequestAssertionConfig;
16 import com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange;
17 import com.eviware.soapui.impl.wsdl.support.soap.SoapUtils;
18 import com.eviware.soapui.impl.wsdl.support.soap.SoapVersion;
19 import com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageAssertion;
20 import com.eviware.soapui.model.iface.SubmitContext;
21 import com.eviware.soapui.model.testsuite.Assertable;
22 import com.eviware.soapui.model.testsuite.AssertionError;
23 import com.eviware.soapui.model.testsuite.AssertionException;
24 import com.eviware.soapui.model.testsuite.ResponseAssertion;
25
26 /***
27 * Assertion that checks that the associated WsdlTestRequests response is not a SOAP Fault
28 *
29 * @author Ole.Matzura
30 */
31
32 public class NotSoapFaultAssertion extends WsdlMessageAssertion implements ResponseAssertion
33 {
34 public static final String ID = "SOAP Fault Assertion";
35
36 public static final String LABEL = "Not SOAP Fault";
37
38 public NotSoapFaultAssertion(RequestAssertionConfig assertionConfig, Assertable assertable )
39 {
40 super(assertionConfig, assertable, false, false, false, true);
41 }
42
43 public String internalAssertResponse(WsdlMessageExchange messageExchange, SubmitContext context ) throws AssertionException
44 {
45 String responseContent = messageExchange.getResponseContent();
46 try
47 {
48
49 SoapVersion soapVersion = messageExchange.getOperation().getInterface().getSoapVersion();
50 if( SoapUtils.isSoapFault( responseContent, soapVersion ))
51 throw new AssertionException( new AssertionError("Response is a SOAP Fault") );
52 }
53 catch (Exception e)
54 {
55 throw new AssertionException( new AssertionError(e.getMessage()) );
56 }
57
58 return "Response is not a SOAP Fault";
59 }
60
61 @Override
62 protected String internalAssertRequest( WsdlMessageExchange messageExchange, SubmitContext context ) throws AssertionException
63 {
64 return null;
65 }
66 }