1 /*
   2  * @test
   3  * @bug 8009579
   4  * @summary The initCause() incorrectly initialise the cause in
   5  * XPathException class when used with XPathException(String)
   6  * constructor.
   7  * @run main XPathExceptionInitCause
   8  * @author aleksej.efimov@oracle.com
   9  */
  10 
  11 import javax.xml.xpath.XPathException;
  12 
  13 public class XPathExceptionInitCause {
  14 
  15     public static void main(String[] args) throws Exception {
  16         Throwable cause = new Throwable("message 1");
  17         XPathException xpathexcep = new XPathException("message 2");
  18         xpathexcep.initCause(cause);
  19         System.out.println("getCause() result: '" + xpathexcep.getCause()
  20                 + "' Cause itself: '" + cause + "'");
  21         if (!xpathexcep.getCause().toString().equals(cause.toString())) {
  22             throw new Exception("Incorrect cause is set by initCause()");
  23         }
  24     }
  25 }