View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.impl.wsdl.teststeps;
14  
15  import java.beans.PropertyChangeEvent;
16  import java.beans.PropertyChangeListener;
17  import java.util.ArrayList;
18  import java.util.Collection;
19  import java.util.Collections;
20  import java.util.List;
21  import java.util.Map;
22  
23  import javax.swing.ImageIcon;
24  
25  import org.apache.log4j.Logger;
26  
27  import com.eviware.soapui.config.RequestStepConfig;
28  import com.eviware.soapui.config.TestStepConfig;
29  import com.eviware.soapui.impl.support.http.HttpRequestTestStep;
30  import com.eviware.soapui.impl.wsdl.AbstractWsdlModelItem;
31  import com.eviware.soapui.impl.wsdl.WsdlInterface;
32  import com.eviware.soapui.impl.wsdl.WsdlOperation;
33  import com.eviware.soapui.impl.wsdl.WsdlProject;
34  import com.eviware.soapui.impl.wsdl.WsdlRequest;
35  import com.eviware.soapui.impl.wsdl.WsdlSubmit;
36  import com.eviware.soapui.impl.wsdl.submit.transports.http.WsdlResponse;
37  import com.eviware.soapui.impl.wsdl.support.assertions.AssertedXPathsContainer;
38  import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
39  import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext;
40  import com.eviware.soapui.impl.wsdl.teststeps.assertions.TestAssertionRegistry.AssertableType;
41  import com.eviware.soapui.model.ModelItem;
42  import com.eviware.soapui.model.iface.Interface;
43  import com.eviware.soapui.model.iface.Operation;
44  import com.eviware.soapui.model.iface.Submit;
45  import com.eviware.soapui.model.iface.Request.SubmitException;
46  import com.eviware.soapui.model.project.Project;
47  import com.eviware.soapui.model.propertyexpansion.PropertyExpander;
48  import com.eviware.soapui.model.propertyexpansion.PropertyExpansion;
49  import com.eviware.soapui.model.propertyexpansion.PropertyExpansionContainer;
50  import com.eviware.soapui.model.propertyexpansion.PropertyExpansionsResult;
51  import com.eviware.soapui.model.support.InterfaceListenerAdapter;
52  import com.eviware.soapui.model.support.ModelSupport;
53  import com.eviware.soapui.model.support.ProjectListenerAdapter;
54  import com.eviware.soapui.model.support.TestStepBeanProperty;
55  import com.eviware.soapui.model.testsuite.Assertable;
56  import com.eviware.soapui.model.testsuite.AssertionError;
57  import com.eviware.soapui.model.testsuite.AssertionsListener;
58  import com.eviware.soapui.model.testsuite.OperationTestStep;
59  import com.eviware.soapui.model.testsuite.TestAssertion;
60  import com.eviware.soapui.model.testsuite.TestCaseRunContext;
61  import com.eviware.soapui.model.testsuite.TestCaseRunner;
62  import com.eviware.soapui.model.testsuite.TestStep;
63  import com.eviware.soapui.model.testsuite.TestStepResult;
64  import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus;
65  import com.eviware.soapui.support.resolver.ChangeOperationResolver;
66  import com.eviware.soapui.support.resolver.ImportInterfaceResolver;
67  import com.eviware.soapui.support.resolver.RemoveTestStepResolver;
68  import com.eviware.soapui.support.resolver.ResolveContext;
69  import com.eviware.soapui.support.resolver.ResolveContext.PathToResolve;
70  import com.eviware.soapui.support.types.StringToStringMap;
71  
72  /***
73   * WsdlTestStep that executes a WsdlTestRequest
74   * 
75   * @author Ole.Matzura
76   */
77  
78  public class WsdlTestRequestStep extends WsdlTestStepWithProperties implements OperationTestStep,
79  		PropertyChangeListener, PropertyExpansionContainer, Assertable, HttpRequestTestStep
80  {
81  	private final static Logger log = Logger.getLogger( WsdlTestRequestStep.class );
82  	private RequestStepConfig requestStepConfig;
83  	private WsdlTestRequest testRequest;
84  	private WsdlOperation wsdlOperation;
85  	private final InternalProjectListener projectListener = new InternalProjectListener();
86  	private final InternalInterfaceListener interfaceListener = new InternalInterfaceListener();
87  	private WsdlSubmit<WsdlRequest> submit;
88  
89  	public WsdlTestRequestStep( WsdlTestCase testCase, TestStepConfig config, boolean forLoadTest )
90  	{
91  		super( testCase, config, true, forLoadTest );
92  
93  		if( getConfig().getConfig() != null )
94  		{
95  			requestStepConfig = ( RequestStepConfig )getConfig().getConfig().changeType( RequestStepConfig.type );
96  
97  			wsdlOperation = findWsdlOperation();
98  			if( wsdlOperation == null )
99  			{
100 				log.error( "Could not find operation [" + requestStepConfig.getOperation() + "] in interface ["
101 						+ requestStepConfig.getInterface() + "] for test request [" + getName() + "] in TestCase ["
102 						+ getTestCase().getTestSuite().getName() + "/" + getTestCase().getName() + "]" );
103 				// requestStepConfig.setRequest(null);
104 				setDisabled( true );
105 			}
106 			else
107 			{
108 				initTestRequest( config, forLoadTest );
109 			}
110 		}
111 		else
112 		{
113 			requestStepConfig = ( RequestStepConfig )getConfig().addNewConfig().changeType( RequestStepConfig.type );
114 		}
115 
116 		// init properties
117 		if( testRequest != null )
118 		{
119 			initRequestProperties();
120 		}
121 	}
122 
123 	private void initRequestProperties()
124 	{
125 		addProperty( new TestStepBeanProperty( "Endpoint", false, testRequest, "endpoint", this ) );
126 		addProperty( new TestStepBeanProperty( "Username", false, testRequest, "username", this ) );
127 		addProperty( new TestStepBeanProperty( "Password", false, testRequest, "password", this ) );
128 		addProperty( new TestStepBeanProperty( "Domain", false, testRequest, "domain", this ) );
129 		addProperty( new TestStepBeanProperty( "Request", false, testRequest, "requestContent", this )
130 		{
131 			@Override
132 			public String getDefaultValue()
133 			{
134 				return getOperation().createRequest( true );
135 			}
136 		} );
137 		addProperty( new TestStepBeanProperty( "Response", true, testRequest, "responseContent", this )
138 		{
139 			@Override
140 			public String getDefaultValue()
141 			{
142 				return getOperation().createResponse( true );
143 			}
144 		} );
145 	}
146 
147 	private void initTestRequest( TestStepConfig config, boolean forLoadTest )
148 	{
149 		if( !forLoadTest )
150 		{
151 			wsdlOperation.getInterface().getProject().addProjectListener( projectListener );
152 			wsdlOperation.getInterface().addInterfaceListener( interfaceListener );
153 
154 			// we need to listen for name changes which happen when
155 			// interfaces are updated..
156 			wsdlOperation.getInterface().addPropertyChangeListener( this );
157 			wsdlOperation.addPropertyChangeListener( this );
158 		}
159 
160 		testRequest = new WsdlTestRequest( wsdlOperation, requestStepConfig.getRequest(), this, forLoadTest );
161 		testRequest.addPropertyChangeListener( this );
162 
163 		if( config.isSetName() )
164 			testRequest.setName( config.getName() );
165 		else
166 			config.setName( testRequest.getName() );
167 	}
168 
169 	@Override
170 	public WsdlTestStep clone( WsdlTestCase targetTestCase, String name )
171 	{
172 		beforeSave();
173 
174 		TestStepConfig config = ( TestStepConfig )getConfig().copy();
175 		RequestStepConfig stepConfig = ( RequestStepConfig )config.getConfig().changeType( RequestStepConfig.type );
176 
177 		while( stepConfig.getRequest().sizeOfAttachmentArray() > 0 )
178 			stepConfig.getRequest().removeAttachment( 0 );
179 
180 		config.setName( name );
181 		stepConfig.getRequest().setName( name );
182 
183 		WsdlTestRequestStep result = ( WsdlTestRequestStep )targetTestCase.addTestStep( config );
184 		testRequest.copyAttachmentsTo( result.getTestRequest() );
185 
186 		return result;
187 	}
188 
189 	private WsdlOperation findWsdlOperation()
190 	{
191 		WsdlTestCase testCase = getTestCase();
192 		if( testCase == null || testCase.getTestSuite() == null )
193 			return null;
194 
195 		Project project = testCase.getTestSuite().getProject();
196 		WsdlOperation operation = null;
197 		for( int c = 0; c < project.getInterfaceCount(); c++ )
198 		{
199 			if( project.getInterfaceAt( c ).getName().equals( requestStepConfig.getInterface() ) )
200 			{
201 				WsdlInterface iface = ( WsdlInterface )project.getInterfaceAt( c );
202 				for( int i = 0; i < iface.getOperationCount(); i++ )
203 				{
204 					if( iface.getOperationAt( i ).getName().equals( requestStepConfig.getOperation() ) )
205 					{
206 						operation = iface.getOperationAt( i );
207 						break;
208 					}
209 				}
210 
211 				if( operation != null )
212 					break;
213 			}
214 		}
215 		return operation;
216 	}
217 
218 	public String getInterfaceName()
219 	{
220 		return requestStepConfig.getInterface();
221 	}
222 
223 	public String getOperationName()
224 	{
225 		return requestStepConfig.getOperation();
226 	}
227 
228 	@Override
229 	public void release()
230 	{
231 		super.release();
232 
233 		if( wsdlOperation == null )
234 			wsdlOperation = findWsdlOperation();
235 
236 		if( wsdlOperation != null )
237 		{
238 			wsdlOperation.removePropertyChangeListener( this );
239 			wsdlOperation.getInterface().getProject().removeProjectListener( projectListener );
240 			wsdlOperation.getInterface().removeInterfaceListener( interfaceListener );
241 			wsdlOperation.getInterface().removePropertyChangeListener( this );
242 		}
243 
244 		// could be null if initialization failed..
245 		if( testRequest != null )
246 		{
247 			testRequest.removePropertyChangeListener( this );
248 			testRequest.release();
249 		}
250 	}
251 
252 	@Override
253 	public void resetConfigOnMove( TestStepConfig config )
254 	{
255 		super.resetConfigOnMove( config );
256 
257 		requestStepConfig = ( RequestStepConfig )config.getConfig().changeType( RequestStepConfig.type );
258 		testRequest.updateConfig( requestStepConfig.getRequest() );
259 	}
260 
261 	@Override
262 	public ImageIcon getIcon()
263 	{
264 		return testRequest == null ? null : testRequest.getIcon();
265 	}
266 
267 	public WsdlTestRequest getTestRequest()
268 	{
269 		return testRequest;
270 	}
271 
272 	@Override
273 	public void setName( String name )
274 	{
275 		super.setName( name );
276 		testRequest.setName( name );
277 	}
278 
279 	public void propertyChange( PropertyChangeEvent arg0 )
280 	{
281 		if( arg0.getSource() == wsdlOperation )
282 		{
283 			if( arg0.getPropertyName().equals( Operation.NAME_PROPERTY ) )
284 			{
285 				requestStepConfig.setOperation( ( String )arg0.getNewValue() );
286 			}
287 		}
288 		else if( arg0.getSource() == wsdlOperation.getInterface() )
289 		{
290 			if( arg0.getPropertyName().equals( Interface.NAME_PROPERTY ) )
291 			{
292 				requestStepConfig.setInterface( ( String )arg0.getNewValue() );
293 			}
294 		}
295 		else if( arg0.getPropertyName().equals( TestAssertion.CONFIGURATION_PROPERTY )
296 				|| arg0.getPropertyName().equals( TestAssertion.DISABLED_PROPERTY ) )
297 		{
298 			if( getTestRequest().getResponse() != null )
299 			{
300 				getTestRequest().assertResponse( new WsdlTestRunContext( this ) );
301 			}
302 		}
303 		else
304 		{
305 			if( arg0.getSource() == testRequest && arg0.getPropertyName().equals( WsdlTestRequest.NAME_PROPERTY ) )
306 			{
307 				if( !super.getName().equals( ( String )arg0.getNewValue() ) )
308 					super.setName( ( String )arg0.getNewValue() );
309 			}
310 
311 			notifyPropertyChanged( arg0.getPropertyName(), arg0.getOldValue(), arg0.getNewValue() );
312 		}
313 	}
314 
315 	public TestStepResult run( TestCaseRunner runner, TestCaseRunContext runContext )
316 	{
317 		WsdlTestRequestStepResult testStepResult = new WsdlTestRequestStepResult( this );
318 		testStepResult.startTimer();
319 		runContext.setProperty( AssertedXPathsContainer.ASSERTEDXPATHSCONTAINER_PROPERTY, testStepResult );
320 
321 		try
322 		{
323 			submit = testRequest.submit( runContext, false );
324 			WsdlResponse response = ( WsdlResponse )submit.getResponse();
325 
326 			if( submit.getStatus() != Submit.Status.CANCELED )
327 			{
328 				if( submit.getStatus() == Submit.Status.ERROR )
329 				{
330 					testStepResult.setStatus( TestStepStatus.FAILED );
331 					testStepResult.addMessage( submit.getError().toString() );
332 					
333 
334 					testRequest.setResponse( null, runContext );
335 				}
336 				else if( response == null )
337 				{
338 					testStepResult.setStatus( TestStepStatus.FAILED );
339 					testStepResult.addMessage( "Request is missing response" );
340 
341 					testRequest.setResponse( null, runContext );
342 				}
343 				else
344 				{
345 					runContext.setProperty( AssertedXPathsContainer.ASSERTEDXPATHSCONTAINER_PROPERTY, testStepResult );
346 					testRequest.setResponse( response, runContext );
347 
348 					testStepResult.setTimeTaken( response.getTimeTaken() );
349 					testStepResult.setSize( response.getContentLength() );
350 
351 					switch( testRequest.getAssertionStatus() )
352 					{
353 					case FAILED :
354 						testStepResult.setStatus( TestStepStatus.FAILED );
355 						break;
356 					case VALID :
357 						testStepResult.setStatus( TestStepStatus.OK );
358 						break;
359 					case UNKNOWN :
360 						testStepResult.setStatus( TestStepStatus.UNKNOWN );
361 						break;
362 					}
363 
364 					testStepResult.setResponse( response, testStepResult.getStatus() != TestStepStatus.FAILED );
365 				}
366 			}
367 			else
368 			{
369 				testStepResult.setStatus( TestStepStatus.CANCELED );
370 				testStepResult.addMessage( "Request was canceled" );
371 			}
372 
373 			if( response != null )
374 				testStepResult.setRequestContent( response.getRequestContent(), testStepResult.getStatus() != TestStepStatus.FAILED );
375 			else
376 				testStepResult.setRequestContent( testRequest.getRequestContent(), testStepResult.getStatus() != TestStepStatus.FAILED );
377 			testStepResult.stopTimer();
378 		}
379 		catch( SubmitException e )
380 		{
381 			testStepResult.setStatus( TestStepStatus.FAILED );
382 			testStepResult.addMessage( "SubmitException: " + e );
383 			testStepResult.stopTimer();
384 		}
385 		finally
386 		{
387 			submit = null;
388 		}
389 
390 		testStepResult.setDomain( PropertyExpander.expandProperties( runContext, testRequest.getDomain() ) );
391 		testStepResult.setUsername( PropertyExpander.expandProperties( runContext, testRequest.getUsername() ) );
392 		testStepResult.setPassword( PropertyExpander.expandProperties( runContext, testRequest.getPassword() ) );
393 		testStepResult.setEndpoint( PropertyExpander.expandProperties( runContext, testRequest.getEndpoint() ) );
394 		testStepResult.setEncoding( PropertyExpander.expandProperties( runContext, testRequest.getEncoding() ) );
395 
396 		if( testStepResult.getStatus() != TestStepStatus.CANCELED )
397 		{
398 			AssertionStatus assertionStatus = testRequest.getAssertionStatus();
399 			switch( assertionStatus )
400 			{
401 			case FAILED :
402 			{
403 				testStepResult.setStatus( TestStepStatus.FAILED );
404 				if( getAssertionCount() == 0 )
405 				{
406 					testStepResult.addMessage( "Invalid/empty response" );
407 				}
408 				else
409 					for( int c = 0; c < getAssertionCount(); c++ )
410 					{
411 						WsdlMessageAssertion assertion = getAssertionAt( c );
412 						AssertionError[] errors = assertion.getErrors();
413 						if( errors != null )
414 						{
415 							for( AssertionError error : errors )
416 							{
417 								testStepResult.addMessage( "[" + assertion.getName() + "] " + error.getMessage() );
418 							}
419 						}
420 					}
421 
422 				break;
423 			}
424 				// default : testStepResult.setStatus( TestStepStatus.OK ); break;
425 			}
426 		}
427 
428 //		if( !runContext.hasProperty( TestRunContext.INTERACTIVE ) )
429 //			testRequest.setResponse( null, runContext );
430 
431 		return testStepResult;
432 	}
433 
434 	public WsdlMessageAssertion getAssertionAt( int index )
435 	{
436 		return testRequest.getAssertionAt( index );
437 	}
438 
439 	public int getAssertionCount()
440 	{
441 		return testRequest == null ? 0 : testRequest.getAssertionCount();
442 	}
443 
444 	public WsdlTestRequest getHttpRequest()
445 	{
446 		return testRequest;
447 	}
448 
449 	public class InternalProjectListener extends ProjectListenerAdapter
450 	{
451 		@Override
452 		public void interfaceRemoved( Interface iface )
453 		{
454 			if( wsdlOperation != null && wsdlOperation.getInterface().equals( iface ) )
455 			{
456 				log.debug( "Removing test step due to removed interface" );
457 				( getTestCase() ).removeTestStep( WsdlTestRequestStep.this );
458 			}
459 		}
460 	}
461 
462 	public class InternalInterfaceListener extends InterfaceListenerAdapter
463 	{
464 		@Override
465 		public void operationRemoved( Operation operation )
466 		{
467 			if( operation == wsdlOperation )
468 			{
469 				log.debug( "Removing test step due to removed operation" );
470 				( getTestCase() ).removeTestStep( WsdlTestRequestStep.this );
471 			}
472 		}
473 
474 		@Override
475 		public void operationUpdated( Operation operation )
476 		{
477 			if( operation == wsdlOperation )
478 			{
479 				requestStepConfig.setOperation( operation.getName() );
480 			}
481 		}
482 	}
483 
484 	@Override
485 	public boolean cancel()
486 	{
487 		if( submit == null )
488 			return false;
489 
490 		submit.cancel();
491 
492 		return true;
493 	}
494 
495 	@Override
496 	public Collection<Interface> getRequiredInterfaces()
497 	{
498 		ArrayList<Interface> result = new ArrayList<Interface>();
499 		result.add( findWsdlOperation().getInterface() );
500 		return result;
501 	}
502 
503 	public String getDefaultSourcePropertyName()
504 	{
505 		return "Response";
506 	}
507 
508 	public String getDefaultTargetPropertyName()
509 	{
510 		return "Request";
511 	}
512 
513 	@Override
514 	public boolean dependsOn( AbstractWsdlModelItem<?> modelItem )
515 	{
516 		if( modelItem instanceof Interface && testRequest.getOperation().getInterface() == modelItem )
517 		{
518 			return true;
519 		}
520 		else if( modelItem instanceof Operation && testRequest.getOperation() == modelItem )
521 		{
522 			return true;
523 		}
524 
525 		return false;
526 	}
527 
528 	@Override
529 	public void beforeSave()
530 	{
531 		super.beforeSave();
532 
533 		if( testRequest != null )
534 			testRequest.beforeSave();
535 	}
536 
537 	@Override
538 	public String getDescription()
539 	{
540 		return testRequest == null ? "<missing>" : testRequest.getDescription();
541 	}
542 
543 	@Override
544 	public void setDescription( String description )
545 	{
546 		if( testRequest != null )
547 			testRequest.setDescription( description );
548 	}
549 
550 	public void setOperation( WsdlOperation operation )
551 	{
552 		if( wsdlOperation == operation )
553 			return;
554 
555 		WsdlOperation oldOperation = wsdlOperation;
556 		wsdlOperation = operation;
557 		requestStepConfig.setInterface( operation.getInterface().getName() );
558 		requestStepConfig.setOperation( operation.getName() );
559 
560 		if( oldOperation != null )
561 			oldOperation.removePropertyChangeListener( this );
562 
563 		wsdlOperation.addPropertyChangeListener( this );
564 
565 		initTestRequest( this.getConfig(), false );
566 		testRequest.setOperation( wsdlOperation );
567 	}
568 
569 	@SuppressWarnings( "unchecked" )
570 	@Override
571 	public List<? extends ModelItem> getChildren()
572 	{
573 		return testRequest == null ? Collections.EMPTY_LIST : testRequest.getAssertionList();
574 	}
575 
576 	public PropertyExpansion[] getPropertyExpansions()
577 	{
578 		if( testRequest == null )
579 			return new PropertyExpansion[0];
580 
581 		PropertyExpansionsResult result = new PropertyExpansionsResult( this, testRequest );
582 
583 		result.extractAndAddAll( "requestContent" );
584 		result.extractAndAddAll( "endpoint" );
585 		result.extractAndAddAll( "username" );
586 		result.extractAndAddAll( "password" );
587 		result.extractAndAddAll( "domain" );
588 
589 		StringToStringMap requestHeaders = testRequest.getRequestHeaders();
590 		for( String key : requestHeaders.keySet() )
591 		{
592 			result.extractAndAddAll( new RequestHeaderHolder( requestHeaders, key ), "value" );
593 		}
594 
595 		testRequest.addWsaPropertyExpansions( result, testRequest.getWsaConfig(), this );
596 		testRequest.addJMSHeaderExpansions(result, testRequest.getJMSHeaderConfig(), this);
597 		return result.toArray( new PropertyExpansion[result.size()] );
598 	}
599 
600 	public class RequestHeaderHolder
601 	{
602 		private final StringToStringMap valueMap;
603 		private final String key;
604 
605 		public RequestHeaderHolder( StringToStringMap valueMap, String key )
606 		{
607 			this.valueMap = valueMap;
608 			this.key = key;
609 		}
610 
611 		public String getValue()
612 		{
613 			return valueMap.get( key );
614 		}
615 
616 		public void setValue( String value )
617 		{
618 			valueMap.put( key, value );
619 			testRequest.setRequestHeaders( valueMap );
620 		}
621 	}
622 
623 	public TestAssertion addAssertion( String type )
624 	{
625 		WsdlMessageAssertion result = testRequest.addAssertion( type );
626 		return result;
627 	}
628 
629 	public void addAssertionsListener( AssertionsListener listener )
630 	{
631 		testRequest.addAssertionsListener( listener );
632 	}
633 
634 	public TestAssertion cloneAssertion( TestAssertion source, String name )
635 	{
636 		return testRequest.cloneAssertion( source, name );
637 	}
638 
639 	public String getAssertableContent()
640 	{
641 		return testRequest.getAssertableContent();
642 	}
643 
644 	public AssertableType getAssertableType()
645 	{
646 		return testRequest.getAssertableType();
647 	}
648 
649 	public TestAssertion getAssertionByName( String name )
650 	{
651 		return testRequest.getAssertionByName( name );
652 	}
653 
654 	public List<TestAssertion> getAssertionList()
655 	{
656 		return testRequest.getAssertionList();
657 	}
658 
659 	public AssertionStatus getAssertionStatus()
660 	{
661 		return testRequest.getAssertionStatus();
662 	}
663 
664 	public Interface getInterface()
665 	{
666 		return getOperation().getInterface();
667 	}
668 
669 	public WsdlOperation getOperation()
670 	{
671 		return wsdlOperation;
672 	}
673 
674 	public TestStep getTestStep()
675 	{
676 		return this;
677 	}
678 
679 	public void removeAssertion( TestAssertion assertion )
680 	{
681 		testRequest.removeAssertion( assertion );
682 	}
683 
684 	public TestAssertion moveAssertion( int ix, int whereTo )
685 	{
686 		return testRequest.moveAssertion( ix, whereTo );
687 	}
688 
689 	public void removeAssertionsListener( AssertionsListener listener )
690 	{
691 		testRequest.removeAssertionsListener( listener );
692 	}
693 
694 	public Map<String, TestAssertion> getAssertions()
695 	{
696 		return testRequest.getAssertions();
697 	}
698 
699 	@Override
700 	public void prepare( TestCaseRunner testRunner, TestCaseRunContext testRunContext ) throws Exception
701 	{
702 		super.prepare( testRunner, testRunContext );
703 
704 		testRequest.setResponse( null, testRunContext );
705 
706 		for( TestAssertion assertion : testRequest.getAssertionList() )
707 		{
708 			assertion.prepare( testRunner, testRunContext );
709 		}
710 	}
711 
712 	public String getDefaultAssertableContent()
713 	{
714 		return testRequest.getDefaultAssertableContent();
715 	}
716 
717 	@SuppressWarnings( "unchecked" )
718 	public void resolve( ResolveContext<?> context )
719 	{
720 		super.resolve( context );
721 
722 		if( wsdlOperation == null )
723 		{
724 			// not solved and we have it in list do not add it.
725 			if( context.hasThisModelItem( this, "Missing SOAP Operation in Project", requestStepConfig.getInterface()
726 					+ "/" + requestStepConfig.getOperation() ) )
727 				return;
728 
729 			context.addPathToResolve( this, "Missing SOAP Operation in Project",
730 					requestStepConfig.getInterface() + "/" + requestStepConfig.getOperation() ).addResolvers(
731 					new RemoveTestStepResolver( this ), new ImportInterfaceResolver( this )
732 					{
733 
734 						@Override
735 						protected boolean update()
736 						{
737 							wsdlOperation = findWsdlOperation();
738 							if( wsdlOperation == null )
739 								return false;
740 
741 							initTestRequest( getConfig(), false );
742 							initRequestProperties();
743 							setDisabled( false );
744 							return true;
745 						}
746 					}, new ChangeOperationResolver( this, "Operation" )
747 					{
748 
749 						@Override
750 						public boolean update()
751 						{
752 							WsdlOperation wsdlOperation = ( WsdlOperation )getSelectedOperation();
753 							if( wsdlOperation == null )
754 								return false;
755 
756 							setOperation( wsdlOperation );
757 							initTestRequest( getConfig(), false );
758 							initRequestProperties();
759 							setDisabled( false );
760 							return true;
761 						}
762 
763 						protected Interface[] getInterfaces( WsdlProject project )
764 						{
765 							List<WsdlInterface> interfaces = ModelSupport.getChildren( project, WsdlInterface.class );
766 							return interfaces.toArray( new Interface[interfaces.size()] );
767 
768 						}
769 
770 					} );
771 		}
772 		else
773 		{
774 			testRequest.resolve( context );
775 			if( context.hasThisModelItem( this, "Missing SOAP Operation in Project", requestStepConfig.getInterface()
776 					+ "/" + requestStepConfig.getOperation() ) )
777 			{
778 				PathToResolve path = context.getPath( this, "Missing SOAP Operation in Project", requestStepConfig
779 						.getInterface()
780 						+ "/" + requestStepConfig.getOperation() );
781 				path.setSolved( true );
782 			}
783 		}
784 	}
785 
786 }