Bug4969689.java revision 779:2b61bfcaa586
178189Sbrian/*
278189Sbrian * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
378189Sbrian * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
478189Sbrian *
578189Sbrian * This code is free software; you can redistribute it and/or modify it
66059Samurai * under the terms of the GNU General Public License version 2 only, as
778189Sbrian * published by the Free Software Foundation.
878189Sbrian *
978189Sbrian * This code is distributed in the hope that it will be useful, but WITHOUT
1078189Sbrian * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1178189Sbrian * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1278189Sbrian * version 2 for more details (a copy is included in the LICENSE file that
1378189Sbrian * accompanied this code).
1478189Sbrian *
156059Samurai * You should have received a copy of the GNU General Public License version
1678189Sbrian * 2 along with this work; if not, write to the Free Software Foundation,
1778189Sbrian * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1878189Sbrian *
1978189Sbrian * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2078189Sbrian * or visit www.oracle.com if you need additional information or have any
2178189Sbrian * questions.
2278189Sbrian */
2378189Sbrian
2478189Sbrianpackage validation;
2578189Sbrian
2678189Sbrianimport javax.xml.validation.SchemaFactory;
276059Samurai
2850479Speterimport org.testng.Assert;
296059Samuraiimport org.testng.annotations.Test;
3036285Sbrianimport org.xml.sax.SAXNotRecognizedException;
3143313Sbrianimport org.xml.sax.SAXNotSupportedException;
3230715Sbrian
3330715Sbrian
3430715Sbrian/*
3536285Sbrian * @bug 4969689
3658032Sbrian * @summary Test SchemaFactory.get/setFeature() throw NullPointerException
3758032Sbrian * instead of SAXNotRecognizedException in case the "feature name" parameter is null.
3830715Sbrian */
3930715Sbrianpublic class Bug4969689 {
406059Samurai
4111336Samurai    SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
4230715Sbrian
43102500Sbrian    @Test
4430715Sbrian    public void test01() throws SAXNotRecognizedException, SAXNotSupportedException {
4552396Sbrian        try {
4630715Sbrian            schemaFactory.getFeature(null);
4797140Sbrian            Assert.fail("exception expected");
486059Samurai        } catch (NullPointerException e) {
4918786Sjkh            ; // expected
5049581Sbrian        }
5130715Sbrian    }
5250059Sbrian
5358037Sbrian    @Test
5458037Sbrian    public void test() throws SAXNotRecognizedException, SAXNotSupportedException {
5558037Sbrian        try {
5646086Sbrian            schemaFactory.setFeature(null, false);
5739395Sbrian            Assert.fail("exception expected");
5839395Sbrian        } catch (NullPointerException e) {
5958037Sbrian            ; // as expected
6046686Sbrian        }
6137141Sbrian    }
6230715Sbrian}
6330715Sbrian