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