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


Java YangParserTestUtils类代码示例

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


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

示例1: loadYangs

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入依赖的package包/类
private Module loadYangs(final File testedModule, final String moduleName)
        throws Exception {
    final List<InputStream> yangISs = new ArrayList<>();
    yangISs.addAll(getStreams("/ietf-inet-types.yang"));

    yangISs.add(new FileInputStream(testedModule));

    yangISs.addAll(getConfigApiYangInputStreams());

    this.context =  YangParserTestUtils.parseYangStreams(yangISs);
    // close ISs
    for (final InputStream is : yangISs) {
        is.close();
    }
    this.namesToModules = YangModelSearchUtils.mapModulesByNames(this.context
            .getModules());
    this.configModule = this.namesToModules.get(ConfigConstants.CONFIG_MODULE);
    final Module module = this.namesToModules.get(moduleName);
    Preconditions.checkNotNull(module, "Cannot get module %s from %s",
            moduleName, this.namesToModules.keySet());
    return module;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:ModuleMXBeanEntryNameConflictTest.java

示例2: testStopOnUnknownLanguageExtension

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入依赖的package包/类
@Test
public void testStopOnUnknownLanguageExtension() throws Exception {
    List<InputStream> yangISs = Lists.newArrayList(getClass()
            .getResourceAsStream("test-ifcWithUnknownExtension.yang"));
    yangISs.addAll(getConfigApiYangInputStreams());
    try {
        context = YangParserTestUtils.parseYangStreams(yangISs);
        namesToModules = YangModelSearchUtils.mapModulesByNames(context.getModules());
        configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
        threadsModule = namesToModules.get(ConfigConstants.CONFIG_THREADS_MODULE);
        try {
            super.testCreateFromIdentities();
            fail();
        } catch (IllegalStateException e) {
            assertTrue(e.getMessage(),
                    e.getMessage().startsWith("Unexpected unknown schema node."));
        }
    } finally {
        for (InputStream is : yangISs) {
            is.close();
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:UnknownExtensionTest.java

示例3: createTestContext

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入依赖的package包/类
public static SchemaContext createTestContext() {
    final List<InputStream> sources;

    try {
        sources = Collections.singletonList(
            Resources.asByteSource(TestModel.class.getResource(DATASTORE_TEST_YANG)).openStream());
    } catch (IOException e1) {
        throw new ExceptionInInitializerError(e1);
    }

    try {
        return YangParserTestUtils.parseYangStreams(sources);
    }  catch (ReactorException e) {
        throw new RuntimeException("Unable to build schema context from " + sources, e);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:TestModel.java

示例4: setUp

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入依赖的package包/类
/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
    testFactory.setExecutor(MoreExecutors.newDirectExecutorService());
    testFactory.setStartWithParsedSchema(true);
    testContext = testFactory.getTestContext();

    testContext.start();
    domMountPointService = testContext.getDomMountProviderService();
    bindingMountPointService = testContext.getBindingMountPointService();
    assertNotNull(domMountPointService);

    final InputStream moduleStream = BindingReflections.getModuleInfo(
            OpendaylightTestRpcServiceService.class)
            .getModuleSourceStream();

    assertNotNull(moduleStream);
    final List<InputStream> rpcModels = Collections.singletonList(moduleStream);
    schemaContext = YangParserTestUtils.parseYangStreams(rpcModels);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:DOMRpcServiceTestBugfix560.java

示例5: test

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入依赖的package包/类
@Test
public void test() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug7246/yang/rpc-test.yang");
    final JsonParser parser = new JsonParser();
    final JsonElement expextedJson = parser
            .parse(new FileReader(new File(getClass().getResource("/bug7246/json/expected-output.json").toURI())));

    final DataContainerChild<? extends PathArgument, ?> inputStructure = ImmutableContainerNodeBuilder.create()
            .withNodeIdentifier(new NodeIdentifier(qN("my-name")))
            .withChild(ImmutableNodes.leafNode(new NodeIdentifier(qN("my-name")), "my-value")).build();
    final SchemaPath rootPath = SchemaPath.create(true, qN("my-name"), qN("input"));
    final Writer writer = new StringWriter();
    final String jsonOutput = normalizedNodeToJsonStreamTransformation(schemaContext, rootPath, writer,
            inputStructure);
    final JsonElement serializedJson = parser.parse(jsonOutput);

    assertEquals(expextedJson, serializedJson);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:19,代码来源:Bug7246Test.java

示例6: 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

示例7: test

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

    final File outDir = new File("target/bug2444-export");
    outDir.mkdirs();

    for (final Module module : schema.getModules()) {
        exportModule(schema, module, outDir);
        final OutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(byteArrayOutputStream);
        try {
            writeModuleToOutputStream(schema, module, bufferedOutputStream, false);
            final String output = byteArrayOutputStream.toString();
            assertNotNull(output);
            assertNotEquals(0, output.length());

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

示例8: testImplicitInputAndOutputInRpc

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入依赖的package包/类
@Test
public void testImplicitInputAndOutputInRpc() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(Bug6856Test.class,
        "/bugs/bug6856/foo.yang");
    assertNotNull(schemaContext);

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

    final Module fooModule = schemaContext.findModule("foo", Revision.of("2017-02-28")).get();
    YinExportUtils.writeModuleToOutputStream(schemaContext, fooModule, bufferedOutputStream);

    final String output = byteArrayOutputStream.toString();
    assertNotNull(output);
    assertFalse(output.isEmpty());

    assertFalse(output.contains("<input>"));
    assertFalse(output.contains("<output>"));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:20,代码来源:Bug6856Test.java

示例9: testExplicitInputAndOutputInRpc

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入依赖的package包/类
@Test
public void testExplicitInputAndOutputInRpc() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(Bug6856Test.class,
        "/bugs/bug6856/bar.yang");
    assertNotNull(schemaContext);

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

    final Module barModule = schemaContext.findModule("bar", Revision.of("2017-02-28")).get();
    YinExportUtils.writeModuleToOutputStream(schemaContext, barModule, bufferedOutputStream);

    final String output = byteArrayOutputStream.toString();
    assertNotNull(output);
    assertFalse(output.isEmpty());

    assertTrue(output.contains("<input>"));
    assertTrue(output.contains("<output>"));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:20,代码来源:Bug6856Test.java

示例10: 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

示例11: 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

示例12: 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

示例13: dataTreeCanditateValidationTest

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入依赖的package包/类
@Test
public void dataTreeCanditateValidationTest() throws Exception {
    final SchemaContext context = YangParserTestUtils.parseYangResourceDirectory("/bug8713/");
    final LeafRefContext rootLeafRefContext = LeafRefContext.create(context);
    final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
        DataTreeConfiguration.DEFAULT_OPERATIONAL, context);

    final ContainerNode root = createRootContainer();
    final YangInstanceIdentifier rootPath = YangInstanceIdentifier.of(foo("root"));
    final DataTreeModification writeModification = inMemoryDataTree.takeSnapshot().newModification();
    writeModification.write(rootPath, root);
    writeModification.ready();

    final DataTreeCandidate writeContributorsCandidate = inMemoryDataTree.prepare(writeModification);

    LeafRefValidatation.validate(writeContributorsCandidate, rootLeafRefContext);
    inMemoryDataTree.commit(writeContributorsCandidate);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:19,代码来源:Bug8713Test.java

示例14: testInstanceIdentifierPathWithEmptyListKey

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入依赖的package包/类
@Test
public void testInstanceIdentifierPathWithEmptyListKey() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/baz.yang");
    final Module bazModule = schemaContext.getModules().iterator().next();
    final ContainerSchemaNode topCont = (ContainerSchemaNode) bazModule.getDataChildByName(
            QName.create(bazModule.getQNameModule(), "top-cont"));
    assertNotNull(topCont);

    final InputStream resourceAsStream = Bug8083Test.class.getResourceAsStream("/bug8083/xml/baz.xml");

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

    // deserialization
    final NormalizedNodeResult result = new NormalizedNodeResult();
    final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
    final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, topCont);
    xmlParser.parse(reader);
    final NormalizedNode<?, ?> transformedInput = result.getResult();
    assertNotNull(transformedInput);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:22,代码来源:Bug8083Test.java

示例15: testInstanceIdentifierPathWithIdentityrefListKey

import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; //导入依赖的package包/类
@Test
public void testInstanceIdentifierPathWithIdentityrefListKey() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/zab.yang");
    final Module zabModule = schemaContext.getModules().iterator().next();
    final ContainerSchemaNode topCont = (ContainerSchemaNode) zabModule.getDataChildByName(
            QName.create(zabModule.getQNameModule(), "top-cont"));
    assertNotNull(topCont);

    final InputStream resourceAsStream = Bug8083Test.class.getResourceAsStream("/bug8083/xml/zab.xml");

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

    // deserialization
    final NormalizedNodeResult result = new NormalizedNodeResult();
    final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
    final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, topCont);
    xmlParser.parse(reader);
    final NormalizedNode<?, ?> transformedInput = result.getResult();
    assertNotNull(transformedInput);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:22,代码来源:Bug8083Test.java


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