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.assertions.jms;
14  
15  import com.eviware.soapui.config.TestAssertionConfig;
16  import com.eviware.soapui.impl.wsdl.WsdlRequest;
17  import com.eviware.soapui.impl.wsdl.submit.transports.jms.HermesJmsRequestTransport;
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.Assertable;
23  import com.eviware.soapui.model.testsuite.AssertionError;
24  import com.eviware.soapui.model.testsuite.AssertionException;
25  import com.eviware.soapui.model.testsuite.RequestAssertion;
26  import com.eviware.soapui.model.testsuite.ResponseAssertion;
27  
28  /***
29   * Asserts JMS connection
30   * 
31   * @author nebojsa.tasic
32   */
33  
34  public class JMSStatusAssertion extends WsdlMessageAssertion implements ResponseAssertion, RequestAssertion
35  {
36  	public static final String ID = "JMS Status";
37  	public static final String LABEL = "JMS Status";
38  
39  	public JMSStatusAssertion( TestAssertionConfig assertionConfig, Assertable assertable )
40  	{
41  		super( assertionConfig, assertable, false, false, false, true );
42  	}
43  
44  	@Override
45  	protected String internalAssertResponse( MessageExchange messageExchange, SubmitContext context )
46  			throws AssertionException
47  	{
48  
49  		Exception exception = ( Exception )context.getProperty( HermesJmsRequestTransport.JMS_ERROR );
50  		if( exception != null )
51  		{
52  			throw new AssertionException( new AssertionError( exception.getMessage() ) );
53  		}
54  
55  		return "JMS Status OK";
56  	}
57  
58  	@Override
59  	protected String internalAssertRequest( MessageExchange messageExchange, SubmitContext context )
60  			throws AssertionException
61  	{
62  		return "JMS Status OK";
63  	}
64  
65  	public static class Factory extends AbstractTestAssertionFactory
66  	{
67  		public Factory()
68  		{
69  			super( JMSStatusAssertion.ID, JMSStatusAssertion.LABEL, JMSStatusAssertion.class, WsdlRequest.class );
70  		}
71  
72  		@Override
73  		public Class<? extends WsdlMessageAssertion> getAssertionClassType()
74  		{
75  			return JMSStatusAssertion.class;
76  		}
77  	}
78  }