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


Java YangParserTestUtils.parseYangResourceDirectory方法代码示例

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


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

示例1: setUp

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@Before
public void setUp() {
    barModuleQName = QNameModule.create(URI.create("bar"));
    myContainer1 = QName.create(barModuleQName, "my-container-1");
    myLeaf1 = QName.create(barModuleQName, "my-leaf-1");
    myAnyXMLDataBar = QName.create(barModuleQName, "my-anyxml-data");

    fooModuleQName = QNameModule.create(URI.create("foo"));
    myContainer2 = QName.create(fooModuleQName, "my-container-2");
    innerContainer = QName.create(fooModuleQName, "inner-container");
    myLeaf3 = QName.create(fooModuleQName, "my-leaf-3");
    myLeaf2 = QName.create(fooModuleQName, "my-leaf-2");
    myAnyXMLDataFoo = QName.create(fooModuleQName, "my-anyxml-data");

    schemaContext = YangParserTestUtils.parseYangResourceDirectory("/anyxml-support/yang");
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:17,代码来源:YangModeledAnyXMLDeserializationTest.java

示例2: init

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@BeforeClass
public static void init() throws XMLStreamException, URISyntaxException, IOException, ParserConfigurationException,
        SAXException {
    schemaContext = YangParserTestUtils.parseYangResourceDirectory("/yang-modeled-anyxml/yang");
    final Module bazModule = schemaContext.findModules("baz").iterator().next();
    final ContainerSchemaNode bazCont = (ContainerSchemaNode) bazModule.getDataChildByName(
            QName.create(bazModule.getQNameModule(), "baz"));
    assertNotNull(bazCont);

    final InputStream resourceAsStream = YangModeledAnyXmlSupportTest.class.getResourceAsStream(
            "/yang-modeled-anyxml/xml/baz.xml");

    final XMLInputFactory factory = XMLInputFactory.newInstance();
    final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream);

    final NormalizedNodeResult result = new NormalizedNodeResult();

    final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);

    final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, bazCont);
    xmlParser.parse(reader);

    assertNotNull(result.getResult());
    assertTrue(result.getResult() instanceof ContainerNode);
    data = (ContainerNode) result.getResult();
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:27,代码来源:YangModeledAnyXmlSupportTest.java

示例3: test

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    final SchemaContext schema = YangParserTestUtils.parseYangResourceDirectory("/bugs/bug2444/yang");
    assertNotNull(schema);

    final ImmutableSet<Module> modulesAndSubmodules = getAllModulesAndSubmodules(schema);
    for (final Module module : modulesAndSubmodules) {
        final OutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(byteArrayOutputStream);
        try {
            YinExportUtils.writeModuleToOutputStream(schema, module, bufferedOutputStream);
            final String output = byteArrayOutputStream.toString();
            assertNotNull(output);
            assertNotEquals(0, output.length());

            final Document doc = YinExportTestUtils.loadDocument("/bugs/bug2444/yin", module);
            assertXMLEquals(module.getName(), doc, output);
        } finally {
            byteArrayOutputStream.close();
            bufferedOutputStream.close();
        }
    }
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:24,代码来源:Bug2444Test.java

示例4: test

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    SchemaContext schema = YangParserTestUtils.parseYangResourceDirectory("/bugs/bug5531");

    assertNotNull(schema);
    assertNotNull(schema.getModules());
    assertEquals(1, schema.getModules().size());

    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(byteArrayOutputStream);

    // write small module of size less than 8kB
   for (Module module : schema.getModules()) {
       YinExportUtils.writeModuleToOutputStream(schema, module, bufferedOutputStream);
   }

    String output = byteArrayOutputStream.toString();

    // if all changes were flushed then following conditions are satisfied
    assertNotEquals("Output should not be empty", 0, output.length());
    assertTrue("Output should contains start of the module", output.contains("<module"));
    assertTrue("Output should contains end of the module", output.contains("</module>"));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:24,代码来源:Bug5531Test.java

示例5: init

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@BeforeClass
public static void init() {
    context = YangParserTestUtils.parseYangResourceDirectory("/leafref-context-test/correct-modules");

    final Set<Module> modules = context.getModules();
    for (final Module module : modules) {
        if (module.getName().equals("import-mod")) {
            impMod = module;
        }
        if (module.getName().equals("leafref-test")) {
            tstMod = module;
        }
    }

    imp = impMod.getQNameModule();
    tst = tstMod.getQNameModule();

    rootLeafRefContext = LeafRefContext.create(context);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:20,代码来源:LeafRefContextTreeBuilderTest.java

示例6: setup

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@Before
public void setup() throws XPathExpressionException {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResourceDirectory("/test/documentTest");
    assertNotNull(schemaContext);

    initQNames();
    xpathSchemaContext = new JaxenSchemaContextFactory().createContext(schemaContext);
    assertNotNull(xpathSchemaContext);

    xpathExpression = xpathSchemaContext.compileExpression(createSchemaPath(), createPrefixes(), createXPath(
                false));
    assertNotNull(xpathExpression);

    xpathDocument = xpathSchemaContext.createDocument(TestUtils.createNormalizedNodes());
    assertNotNull(xpathDocument);
    String rootNodeName = xpathDocument.getRootNode().getNodeType().getLocalName();
    assertNotNull(rootNodeName);
    assertEquals("root", rootNodeName);

    Optional<? extends XPathResult<?>> resultExpressionEvaluate = xpathExpression
            .evaluate(xpathDocument, createYangInstanceIdentifier(false));
    assertNotNull(resultExpressionEvaluate);
    assertTrue(resultExpressionEvaluate.isPresent());
    XPathResult<?> xpathResult = resultExpressionEvaluate.get();
    assertTrue(xpathResult instanceof XPathNodesetResult);
    XPathNodesetResult nodeset = (XPathNodesetResult) xpathResult;

    Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = nodeset.getValue().iterator().next();
    assertNotNull(entry);
    assertEquals("three", entry.getValue().getValue());

    convertNctx = new ConverterNamespaceContext(createPrefixes());
    navigator = new NormalizedNodeNavigator(convertNctx, (JaxenDocument) xpathDocument);
    assertNotNull(navigator);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:36,代码来源:JaxenTest.java

示例7: test

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResourceDirectory("/dom-reader-test");
    final ContainerSchemaNode outerContainerSchema = (ContainerSchemaNode) SchemaContextUtil
            .findNodeInSchemaContext(schemaContext, ImmutableList.of(QName.create("foo-ns", "top-cont")));
    assertNotNull(outerContainerSchema);

    // deserialization
    final Document doc = loadDocument("/dom-reader-test/foo.xml");
    final DOMSource inputXml = new DOMSource(doc.getDocumentElement());
    XMLStreamReader domXMLReader = new DOMSourceXMLStreamReader(inputXml);

    final NormalizedNodeResult result = new NormalizedNodeResult();
    final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
    final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, outerContainerSchema);
    xmlParser.parse(domXMLReader);
    final NormalizedNode<?, ?> transformedInput = result.getResult();
    assertNotNull(transformedInput);

    // serialization
    //final StringWriter writer = new StringWriter();
    final DOMResult domResult = new DOMResult(UntrustedXML.newDocumentBuilder().newDocument());
    final XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
    outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
    final XMLStreamWriter xmlStreamWriter = outputFactory.createXMLStreamWriter(domResult);

    final NormalizedNodeStreamWriter xmlNormalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(
            xmlStreamWriter, schemaContext);

    final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(
            xmlNormalizedNodeStreamWriter);
    normalizedNodeWriter.write(transformedInput);

    //final String serializedXml = writer.toString();
    final String serializedXml = toString(domResult.getNode());
    assertFalse(serializedXml.isEmpty());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:38,代码来源:DOMSourceXMLStreamReaderTest.java

示例8: newParserLeafRefTest2

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@Test
public void newParserLeafRefTest2() throws URISyntaxException, IOException {
    SchemaContext context = YangParserTestUtils.parseYangResourceDirectory("/leafref/yang");
    assertNotNull(context);

    parseJsonToNormalizedNodes(context);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:8,代码来源:Bug4969Test.java

示例9: test

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    SchemaContext schema = YangParserTestUtils.parseYangResourceDirectory("/bugs/bug4504");
    assertNotNull(schema);
    final File outDir = new File("target/bug4504-export");
    outDir.mkdirs();
    for (final Module module : schema.getModules()) {
        exportModule(schema, module, outDir);
    }
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:11,代码来源:Bug4504Test.java

示例10: setup

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@BeforeClass
public static void setup() {
    fooModule = QNameModule.create(URI.create("foo-namespace"));
    parentContainer = QName.create(fooModule, "parent-container");

    bazModule = QNameModule.create(URI.create("baz-namespace"));
    outerContainer = QName.create(bazModule, "outer-container");

    myContainer1 = QName.create(bazModule, "my-container-1");
    myKeyedList = QName.create(bazModule, "my-keyed-list");
    myKeyLeaf = QName.create(bazModule, "my-key-leaf");
    myLeafInList1 = QName.create(bazModule, "my-leaf-in-list-1");
    myLeafInList2 = QName.create(bazModule, "my-leaf-in-list-2");
    myLeaf1 = QName.create(bazModule, "my-leaf-1");
    myLeafList = QName.create(bazModule, "my-leaf-list");

    myContainer2 = QName.create(bazModule, "my-container-2");
    innerContainer = QName.create(bazModule, "inner-container");
    myLeaf2 = QName.create(bazModule, "my-leaf-2");
    myLeaf3 = QName.create(bazModule, "my-leaf-3");
    myChoice = QName.create(bazModule, "my-choice");
    myLeafInCase2 = QName.create(bazModule, "my-leaf-in-case-2");

    myContainer3 = QName.create(bazModule, "my-container-3");
    myDoublyKeyedList = QName.create(bazModule, "my-doubly-keyed-list");
    myFirstKeyLeaf = QName.create(bazModule, "my-first-key-leaf");
    mySecondKeyLeaf = QName.create(bazModule, "my-second-key-leaf");
    myLeafInList3 = QName.create(bazModule, "my-leaf-in-list-3");

    schemaContext = YangParserTestUtils.parseYangResourceDirectory("/");
    parentContainerSchema = (ContainerSchemaNode) SchemaContextUtil.findNodeInSchemaContext(schemaContext,
            ImmutableList.of(parentContainer));
    outerContainerSchema = (ContainerSchemaNode) SchemaContextUtil.findNodeInSchemaContext(schemaContext,
            ImmutableList.of(outerContainer));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:36,代码来源:XmlToNormalizedNodesTest.java

示例11: initSchemaContext

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
private static void initSchemaContext() {
    context = YangParserTestUtils.parseYangResourceDirectory("/leafref-validation");

    final Set<Module> modules = context.getModules();
    for (final Module module : modules) {
        if (module.getName().equals("leafref-validation")) {
            valModule = module;
        }
    }

    valModuleQname = valModule.getQNameModule();
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:13,代码来源:DataTreeCandidateValidatorTest.java

示例12: initSchemaContext

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
private static void initSchemaContext() {
    context = YangParserTestUtils.parseYangResourceDirectory("/leafref-validation");

    final Set<Module> modules = context.getModules();
    for (final Module module : modules) {
        if (module.getName().equals("leafref-validation3")) {
            mainModule = module;
        }
    }

    rootModuleQname = mainModule.getQNameModule();
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:13,代码来源:DataTreeCandidateValidatorTest3.java

示例13: init

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@BeforeClass
public static void init() {
    context = YangParserTestUtils.parseYangResourceDirectory("/leafref-context-test/correct-modules");

    final Set<Module> modules = context.getModules();
    for (final Module module : modules) {
        if (module.getName().equals("leafref-test2")) {
            rootMod = module;
        }
    }

    root = rootMod.getQNameModule();
    rootLeafRefContext = LeafRefContext.create(context);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:15,代码来源:LeafRefContextTest.java

示例14: init

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@BeforeClass
public static void init() {
    FULL_SCHEMA_CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/bug8083/yang/");
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:5,代码来源:Bug8083Test.java

示例15: setup

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入方法依赖的package包/类
@BeforeClass
public static void setup() {
    schemaContext = YangParserTestUtils.parseYangResourceDirectory("/complexjson/yang");
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:5,代码来源:AnyXmlSupportTest.java


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