KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > util > ejb > RemoteAssertionFailedError


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.util.ejb;
23
24 import junit.framework.AssertionFailedError;
25
26 /**
27  * RemoteAssertionFailedError is the client-side view of an assertion
28  * failed error on the server.
29  *
30  * All throwables caught on the server are wrapped with a RemoteTestException
31  * and rethrown. On the client side the exception is caught, and if the
32  * server side exception is an instance of AssertionFailedError, it is
33  * wrapped with an instance of this class and rethrown. That makes the
34  * exception an instance of AssertionFailedError so it is reconized as
35  * a failure and not an Error.
36  *
37  * @author <a HREF="mailto:dain@daingroup.com">Dain Sundstrom</a>
38  * @version $Revision: 37406 $
39  */

40 public class RemoteAssertionFailedError extends AssertionFailedError
41 {
42    private AssertionFailedError remoteAssertionFailedError;
43    private String JavaDoc remoteStackTrace;
44
45    /**
46     * Constructs a remote assertion failed error based on the specified
47     * AssertionFailedError and remote stack trace.
48     * @param e the AssertionFailedError that was thrown on the server side
49     * @param remoteStackTrace the stack trace of the assertion failed error
50     * exactly as it appeared on the server side
51     */

52    public RemoteAssertionFailedError(
53       AssertionFailedError e,
54       String JavaDoc remoteStackTrace)
55    {
56
57       remoteAssertionFailedError = e;
58       this.remoteStackTrace = remoteStackTrace;
59    }
60
61    /**
62     * Gets the message exactly as it appeared on server side.
63     * @return the message exactly as it appeared on server side
64     */

65    public String JavaDoc getMessage()
66    {
67       return remoteAssertionFailedError.getMessage();
68    }
69
70    /**
71     * Prints the stack trace exactly as it appeared on the server side.
72     * @param ps the PrintStream on which the stack trace is printed
73     */

74    public void printStackTrace(java.io.PrintStream JavaDoc ps)
75    {
76       ps.print(remoteStackTrace);
77    }
78
79    /**
80     * Prints the stack trace exactly as it appeared on the server side.
81     */

82    public void printStackTrace()
83    {
84       printStackTrace(System.err);
85    }
86
87    /**
88     * Prints the stack trace exactly as it appeared on the server side.
89     * @param pw the PrintWriter on which the stack trace is printed
90     */

91    public void printStackTrace(java.io.PrintWriter JavaDoc pw)
92    {
93       pw.print(remoteStackTrace);
94    }
95
96    /**
97     * Gets the assertion failed error object from the server side.
98     * Note: the stack trace of this object is not available because
99     * exceptions don't seralize the stack trace. Use
100     * getRemoteStackTrace to get the stack trace as it appeared
101     * on the server.
102     * @retun the assertion failed error object from the server side.
103     */

104    public AssertionFailedError getRemoteAssertionFailedError()
105    {
106       return remoteAssertionFailedError;
107    }
108
109    /**
110     * Gets the stack trace exactly as it appeared on the server side.
111     * @return the stack trace exactly as it appeared on the server side
112     */

113    public String JavaDoc getRemoteStackTrace()
114    {
115       return remoteStackTrace;
116    }
117 }
118
Popular Tags