Java Code Examples for javax.xml.validation.Validator#getProperty()

The following examples show how to use javax.xml.validation.Validator#getProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FeaturePropagationTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testPropertyReset() throws Exception {
    SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schema = makeSchema(factory, null);
    Validator validator = schema.newValidator();
    Object beforeReset = validator.getProperty(SECURITY_MANAGER);
    validator.setProperty(SECURITY_MANAGER, null);
    Object changed = validator.getProperty(SECURITY_MANAGER);
    //for JDK, this is changed since by default the security manager is set
    assertTrue("Property value should have changed after calling setProperty().", beforeReset != changed);
    validator.reset();
    Object afterReset = validator.getProperty(SECURITY_MANAGER);
    assertTrue("Property value should be the same after calling reset()", beforeReset == afterReset);
}
 
Example 2
Source File: Bug4969693.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test01() throws SAXException {
    Validator validator = schemaFactory.newSchema().newValidator();
    try {
        validator.getProperty(null);
        Assert.fail("exception expected");
    } catch (NullPointerException e) {
        ;
    }
}
 
Example 3
Source File: ValidatorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test(expectedExceptions = NullPointerException.class)
public void testGetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException {
    Validator validator = getValidator();
    assertNotNull(validator);
    validator.getProperty(null);

}
 
Example 4
Source File: ValidatorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = SAXNotRecognizedException.class)
public void testGetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException {
    Validator validator = getValidator();
    validator.getProperty(UNRECOGNIZED_NAME);

}