< prev index next >

test/jaxp/javax/xml/jaxp/unittest/sax/IssueTracker56Test.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -39,15 +39,16 @@
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /*
  * @test
- * @bug 6809409
+ * @bug 6809409 6857903
  * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
  * @run testng/othervm -DrunSecMngr=true sax.IssueTracker56Test
  * @run testng/othervm sax.IssueTracker56Test
- * @summary Test SAXException has Cause.
+ * @summary Test SAXException has Cause and that Cause can be properly
+ *  initialized with initCause.
  */
 @Listeners({jaxp.library.BasePolicy.class})
 public class IssueTracker56Test {
 
     @Test

@@ -88,10 +89,22 @@
             // shouldn't happen
         }
 
     }
 
+    /*
+     * Test that SAXException::initCause call correctly initializes
+     * cause and it can be acquired with SAXException::getCause call
+     */
+    @Test
+    public void testInitCause() {
+        Exception cause = new Exception();
+        SAXException e = new SAXException("SAX exception");
+        e.initCause(cause);
+        Assert.assertSame(e.getCause(),cause,"Cause was not set by initCause:");
+    }
+
     public class MyHandler extends DefaultHandler implements ErrorHandler {
 
         public void startDocument() throws SAXException {
         }
 
< prev index next >