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.model.testsuite;
14  
15  import com.eviware.soapui.support.SoapUIException;
16  
17  /***
18   * Exception thrown during assertion
19   * 
20   * @author Ole.Matzura
21   */
22  
23  public class AssertionException extends SoapUIException
24  {
25  	private AssertionError[] errors;
26  
27  	public AssertionException( AssertionError error )
28  	{
29  		this( new AssertionError[] { error } );
30  	}
31  
32  	public AssertionException( AssertionError[] errors )
33  	{
34  		this.errors = new AssertionError[errors.length];
35  		for( int c = 0; c < errors.length; c++ )
36  			this.errors[c] = errors[c];
37  	}
38  
39  	public int getErrorCount()
40  	{
41  		return errors.length;
42  	}
43  
44  	public AssertionError getErrorAt( int c )
45  	{
46  		return errors[c];
47  	}
48  
49  	public AssertionError[] getErrors()
50  	{
51  		return errors;
52  	}
53  
54  	public String getMessage()
55  	{
56  		StringBuffer result = new StringBuffer();
57  		for( int c = 0; c < errors.length; c++ )
58  		{
59  			if( c > 0 )
60  				result.append( '\n' );
61  			result.append( errors[c].getMessage() );
62  		}
63  
64  		return result.toString();
65  	}
66  
67  }