View Javadoc

1   /*
2    *  soapui, copyright (C) 2005 Ole Matzura / eviware.com 
3    *
4    *  SoapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of the GNU Lesser General Public License as published by the Free Software Foundation; 
6    *  either version 2.1 of the License, or (at your option) any later version.
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;
14  
15  import org.apache.xmlbeans.XmlError;
16  
17  /***
18   * Holder for an assertion error
19   * 
20   * @author Ole.Matzura
21   */
22  
23  public class AssertionError
24  {
25  	private String message;
26  	private XmlError xmlError;
27  	
28  	public AssertionError( String message )
29  	{
30  		this.message = message;
31  	}
32  	
33  	public AssertionError( XmlError xmlError )
34  	{
35  		this.xmlError = xmlError;
36  		this.message = xmlError.getMessage();
37  	}
38  	
39  	public String getMessage()
40  	{
41  		return message;
42  	}
43  	
44  	public int getLineNumber()
45  	{
46  		return xmlError == null ? -1 : xmlError.getLine();
47  	}
48  	
49  	public XmlError getXmlError()
50  	{
51  		return xmlError;
52  	}
53  
54  	public String toString()
55  	{
56  		if( xmlError == null ) 
57  			return message;
58  		
59  		return "line " + getLineNumber() + ": " + message;
60  	}
61  
62  	public boolean equals(Object obj)
63  	{
64  		if( obj == null ) 
65  			return false;
66  		
67  		if( obj.getClass().getName().equals( this.getClass().getName() ) &&
68  		 	 obj.getClass().getClassLoader().equals( this.getClass().getClassLoader() ))
69  		{
70  			AssertionError errorObj = (AssertionError) obj;
71  			return errorObj.toString().equals( toString() );
72  		}
73  		
74  		return super.equals(obj);
75  	}
76  }