当前位置: 首页>>代码示例>>Java>>正文


Java SchemaFactory.getFeature方法代码示例

本文整理汇总了Java中javax.xml.validation.SchemaFactory.getFeature方法的典型用法代码示例。如果您正苦于以下问题:Java SchemaFactory.getFeature方法的具体用法?Java SchemaFactory.getFeature怎么用?Java SchemaFactory.getFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.validation.SchemaFactory的用法示例。


在下文中一共展示了SchemaFactory.getFeature方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSecureProcessingFeaturePropagationAndReset

import javax.xml.validation.SchemaFactory; //导入方法依赖的package包/类
@Test
public void testSecureProcessingFeaturePropagationAndReset() throws Exception {
    SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    boolean value;
    value = factory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
    //default is true for JDK
    //assertFalse("Default value of feature on SchemaFactory should have been false.", value);
    assertTrue("Default value of feature on SchemaFactory should have been false.", value);
    factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
    Schema schema = makeSchema(factory, null);
    Validator validator = schema.newValidator();
    value = validator.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
    assertTrue("Value of feature on Validator should have been true.", value);
    validator.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
    value = validator.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
    assertFalse("Value of feature on Validator should have been false.", value);
    validator.reset();
    value = validator.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
    assertTrue("After reset, value of feature on Validator should be true.", value);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:FeaturePropagationTest.java

示例2: testValidation_SAX_withSM

import javax.xml.validation.SchemaFactory; //导入方法依赖的package包/类
@Test
public void testValidation_SAX_withSM() {
    System.out.println("Validation using SAX Source with security manager:");
    setSystemProperty(SAX_FACTORY_ID, "MySAXFactoryImpl");

    try {
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        // should not allow
        factory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, true);
        if ((boolean) factory.getFeature(ORACLE_FEATURE_SERVICE_MECHANISM)) {
            Assert.fail("should not override in secure mode");
        }
    } catch (Exception e) {
        Assert.fail(e.getMessage());

    } finally {
        clearSystemProperty(SAX_FACTORY_ID);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:Bug7143711Test.java

示例3: testGetNullFeature

import javax.xml.validation.SchemaFactory; //导入方法依赖的package包/类
@Test(expectedExceptions = NullPointerException.class)
public void testGetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException {
    SchemaFactory sf = newSchemaFactory();
    assertNotNull(sf);
    sf.getFeature(null);

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:SchemaFactoryTest.java

示例4: testGetUnrecognizedFeature

import javax.xml.validation.SchemaFactory; //导入方法依赖的package包/类
@Test(expectedExceptions = SAXNotRecognizedException.class)
public void testGetUnrecognizedFeature() throws SAXNotRecognizedException, SAXNotSupportedException {
    SchemaFactory sf = newSchemaFactory();
    sf.getFeature(UNRECOGNIZED_NAME);

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:SchemaFactoryTest.java


注:本文中的javax.xml.validation.SchemaFactory.getFeature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。