Bug4969692.java revision 997:540334ae53fe
146686Sbrian/*
246686Sbrian * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
346686Sbrian * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
446686Sbrian *
546686Sbrian * This code is free software; you can redistribute it and/or modify it
646686Sbrian * under the terms of the GNU General Public License version 2 only, as
746686Sbrian * published by the Free Software Foundation.
846686Sbrian *
946686Sbrian * This code is distributed in the hope that it will be useful, but WITHOUT
1046686Sbrian * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1146686Sbrian * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1246686Sbrian * version 2 for more details (a copy is included in the LICENSE file that
1346686Sbrian * accompanied this code).
1446686Sbrian *
1546686Sbrian * You should have received a copy of the GNU General Public License version
1646686Sbrian * 2 along with this work; if not, write to the Free Software Foundation,
1746686Sbrian * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1846686Sbrian *
1946686Sbrian * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2046686Sbrian * or visit www.oracle.com if you need additional information or have any
2146686Sbrian * questions.
2246686Sbrian */
2346686Sbrian
2446686Sbrianpackage validation;
2546686Sbrian
2647769Sbrianimport javax.xml.validation.SchemaFactory;
2746686Sbrianimport javax.xml.validation.Validator;
2846686Sbrian
2947061Sbrianimport org.testng.Assert;
3047061Sbrianimport org.testng.annotations.Listeners;
3147061Sbrianimport org.testng.annotations.Test;
3247061Sbrianimport org.xml.sax.SAXException;
3347061Sbrian
3447769Sbrian/*
35 * @test
36 * @bug 4969692
37 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
38 * @run testng/othervm -DrunSecMngr=true validation.Bug4969692
39 * @run testng/othervm validation.Bug4969692
40 * @summary Test Validator.get/setFeature() throw NullPointerException
41 * instead of SAXNotRecognizedException in case the "feature name" parameter is null.
42 */
43@Listeners({jaxp.library.BasePolicy.class})
44public class Bug4969692 {
45
46    SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
47
48    @Test
49    public void test01() throws SAXException {
50        Validator validator = schemaFactory.newSchema().newValidator();
51        try {
52            validator.getFeature(null);
53            Assert.fail("exception expected");
54        } catch (NullPointerException e) {
55            ;
56        }
57    }
58
59    @Test
60    public void test02() throws SAXException {
61        Validator validator = schemaFactory.newSchema().newValidator();
62        try {
63            validator.setFeature(null, false);
64            Assert.fail("exception expected");
65        } catch (NullPointerException e) {
66            ;
67        }
68    }
69}
70