Search in sources :

Example 51 with EffectiveModelContext

use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.

the class MoreRevisionsTest method multipleRevisionsSimpleTest.

@Test
public void multipleRevisionsSimpleTest() throws Exception {
    for (int i = 0; i < 1000; i++) {
        EffectiveModelContext context = StmtTestUtils.parseYangSources("/semantic-statement-parser/multiple-revisions/simple");
        assertEquals(5, context.getModules().size());
        checkContentSimpleTest(context);
    }
}
Also used : EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 52 with EffectiveModelContext

use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.

the class MoreRevisionsTest method readAndParseYangFileTest.

@Test
public void readAndParseYangFileTest() throws ReactorException {
    EffectiveModelContext result = RFC7950Reactors.defaultReactor().newBuild().addSource(REVFILE).buildEffective();
    final Module moduleByName = result.getModules().iterator().next();
    assertEquals("2015-06-07", moduleByName.getQNameModule().getRevision().get().toString());
}
Also used : Module(org.opendaylight.yangtools.yang.model.api.Module) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 53 with EffectiveModelContext

use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.

the class YT1133Test method testAugmentKeys.

@Test
@SuppressWarnings("checkstyle:regexpSinglelineJava")
public void testAugmentKeys() throws Exception {
    final PrintStream stdout = System.out;
    final ByteArrayOutputStream output = new ByteArrayOutputStream();
    final EffectiveModelContext ctx;
    try (PrintStream out = new PrintStream(output, true, StandardCharsets.UTF_8)) {
        System.setOut(out);
        ctx = StmtTestUtils.parseYangSources("/bugs/YT1133");
    } finally {
        System.setOut(stdout);
    }
    assertEquals(2, ctx.getModules().size());
    final String log = output.toString();
    assertThat(log, not(containsString("Configuration list (bar)values")));
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 54 with EffectiveModelContext

use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.

the class Main method runSystemTest.

@SuppressFBWarnings({ "DM_EXIT", "DM_GC" })
@SuppressWarnings("checkstyle:illegalCatch")
private static void runSystemTest(final List<String> yangLibDirs, final List<String> yangFiles, final Set<QName> supportedFeatures, final boolean recursiveSearch) {
    LOG.info("Yang model dirs: {} ", yangLibDirs);
    LOG.info("Yang model files: {} ", yangFiles);
    LOG.info("Supported features: {} ", supportedFeatures);
    EffectiveModelContext context = null;
    printMemoryInfo("start");
    final Stopwatch stopWatch = Stopwatch.createStarted();
    try {
        context = SystemTestUtils.parseYangSources(yangLibDirs, yangFiles, supportedFeatures, recursiveSearch);
    } catch (final Exception e) {
        LOG.error("Failed to create SchemaContext.", e);
        System.exit(1);
    }
    stopWatch.stop();
    LOG.info("Elapsed time: {}", stopWatch);
    printMemoryInfo("end");
    LOG.info("SchemaContext resolved Successfully. {}", context);
    Runtime.getRuntime().gc();
    printMemoryInfo("after gc");
}
Also used : Stopwatch(com.google.common.base.Stopwatch) ParseException(org.apache.commons.cli.ParseException) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 55 with EffectiveModelContext

use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project lighty-netconf-simulator by PANTHEONtech.

the class RpcOutputRequestProcessor method init.

@Override
public void init(NetconfDeviceServices netconfDeviceServices) {
    super.init(netconfDeviceServices);
    EffectiveModelContext schemaContext = getNetconfDeviceServices().getAdapterContext().currentSerializer().getRuntimeContext().getEffectiveModelContext();
    Optional<? extends RpcDefinition> rpcDefinitionOptional = ConverterUtils.loadRpc(schemaContext, getIdentifier());
    if (rpcDefinitionOptional.isPresent()) {
        this.rpcDefinition = rpcDefinitionOptional.get();
    } else {
        throw new IllegalStateException("RpcDefinition for " + getIdentifier() + " was not found!");
    }
}
Also used : EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)

Aggregations

EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)182 Test (org.junit.Test)99 Module (org.opendaylight.yangtools.yang.model.api.Module)37 QName (org.opendaylight.yangtools.yang.common.QName)29 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)28 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)26 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)24 LeafSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafSchemaNode)24 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)21 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)18 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)16 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)16 NormalizedNodeStreamWriter (org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter)16 IRSchemaSource (org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRSchemaSource)14 DOMMountPoint (org.opendaylight.mdsal.dom.api.DOMMountPoint)13 RestconfDocumentedException (org.opendaylight.restconf.common.errors.RestconfDocumentedException)13 RpcDefinition (org.opendaylight.yangtools.yang.model.api.RpcDefinition)13 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)11 IOException (java.io.IOException)9 Collection (java.util.Collection)9