當前位置: 首頁>>代碼示例>>Java>>正文


Java Validator.getFeature方法代碼示例

本文整理匯總了Java中javax.xml.validation.Validator.getFeature方法的典型用法代碼示例。如果您正苦於以下問題:Java Validator.getFeature方法的具體用法?Java Validator.getFeature怎麽用?Java Validator.getFeature使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.validation.Validator的用法示例。


在下文中一共展示了Validator.getFeature方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testSecureProcessingFeaturePropagationAndReset

import javax.xml.validation.Validator; //導入方法依賴的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: testFeatureReset

import javax.xml.validation.Validator; //導入方法依賴的package包/類
@Test
public void testFeatureReset() throws Exception {
    SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schema = makeSchema(factory, null);
    Validator validator = schema.newValidator();
    validator.setFeature(FEATURE_STRING_DEFAULT_TRUE, false);
    validator.setFeature(FEATURE_STRING_DEFAULT_FALSE, true);
    validator.reset();
    boolean value = validator.getFeature(FEATURE_STRING_DEFAULT_TRUE);
    assertTrue("After reset, value of feature on Validator should be true.", value);
    value = validator.getFeature(FEATURE_STRING_DEFAULT_FALSE);
    assertFalse("After reset, value of feature on Validator should be false.", value);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:FeaturePropagationTest.java

示例3: test01

import javax.xml.validation.Validator; //導入方法依賴的package包/類
@Test
public void test01() throws SAXException {
    Validator validator = schemaFactory.newSchema().newValidator();
    try {
        validator.getFeature(null);
        Assert.fail("exception expected");
    } catch (NullPointerException e) {
        ;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:Bug4969692.java

示例4: testGetNullFeature

import javax.xml.validation.Validator; //導入方法依賴的package包/類
@Test(expectedExceptions = NullPointerException.class)
public void testGetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException {
    Validator validator = getValidator();
    assertNotNull(validator);
    validator.getFeature(null);

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:ValidatorTest.java

示例5: testGetUnrecognizedFeature

import javax.xml.validation.Validator; //導入方法依賴的package包/類
@Test(expectedExceptions = SAXNotRecognizedException.class)
public void testGetUnrecognizedFeature() throws SAXNotRecognizedException, SAXNotSupportedException {
    Validator validator = getValidator();
    validator.getFeature(UNRECOGNIZED_NAME);

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:ValidatorTest.java


注:本文中的javax.xml.validation.Validator.getFeature方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。