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.panels.support.assertions.Assertable;
17 import com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange;
18 import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext;
19 import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlValidator;
20 import com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageAssertion;
21 import com.eviware.soapui.model.iface.SubmitContext;
22
23 public class SoapResponseAssertion extends WsdlMessageAssertion implements ResponseAssertion, RequestAssertion
24 {
25 public static final String ID = "SOAP Response";
26
27 public SoapResponseAssertion( RequestAssertionConfig assertionConfig, Assertable assertable )
28 {
29 super( assertionConfig, assertable );
30 }
31
32 @Override
33 protected String internalAssertResponse( WsdlMessageExchange messageExchange, SubmitContext context )
34 throws AssertionException
35 {
36 WsdlContext wsdlContext = messageExchange.getOperation().getInterface().getWsdlContext();
37 WsdlValidator validator = new WsdlValidator( wsdlContext );
38
39 try
40 {
41 AssertionError[] errors = validator.assertResponse( messageExchange, true );
42 if (errors.length > 0)
43 throw new AssertionException(errors);
44 }
45 catch( AssertionException e )
46 {
47 throw e;
48 }
49 catch (Exception e)
50 {
51 throw new AssertionException( new AssertionError( e.getMessage() ));
52 }
53
54 return "Response Envelope OK";
55 }
56
57 @Override
58 protected String internalAssertRequest( WsdlMessageExchange messageExchange, SubmitContext context ) throws AssertionException
59 {
60 WsdlContext wsdlContext = messageExchange.getOperation().getInterface().getWsdlContext();
61 WsdlValidator validator = new WsdlValidator( wsdlContext );
62
63 try
64 {
65 AssertionError[] errors = validator.assertRequest( messageExchange, true );
66 if (errors.length > 0)
67 throw new AssertionException(errors);
68 }
69 catch( AssertionException e )
70 {
71 throw e;
72 }
73 catch (Exception e)
74 {
75 throw new AssertionException( new AssertionError( e.getMessage() ));
76 }
77
78 return "Request Envelope OK";
79 }
80 }