Search in sources :

Example 31 with EffectiveModelContext

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

the class SchemaContextFactoryDeviationsTest method shouldFailOnAttemptToDeviateTheSameModule2.

@Test
public void shouldFailOnAttemptToDeviateTheSameModule2() throws Exception {
    final ListenableFuture<EffectiveModelContext> lf = createSchemaContext(null, BAR_INVALID, BAZ_INVALID);
    assertTrue(lf.isDone());
    final ExecutionException ex = assertThrows(ExecutionException.class, lf::get);
    final Throwable cause = Throwables.getRootCause(ex);
    assertThat(cause, instanceOf(InferenceException.class));
    assertThat(cause.getMessage(), startsWith("Deviation must not target the same module as the one it is defined in"));
}
Also used : InferenceException(org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException) ExecutionException(java.util.concurrent.ExecutionException) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 32 with EffectiveModelContext

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

the class SchemaContextFactoryDeviationsTest method testDeviationsSupportedInAllModules.

@Test
public void testDeviationsSupportedInAllModules() throws Exception {
    final ListenableFuture<EffectiveModelContext> lf = createSchemaContext(null, FOO, BAR, BAZ, FOOBAR);
    assertTrue(lf.isDone());
    final EffectiveModelContext schemaContext = lf.get();
    assertNotNull(schemaContext);
    assertAbsent(schemaContext, MY_FOO_CONT_A);
    assertAbsent(schemaContext, MY_FOO_CONT_B);
    assertAbsent(schemaContext, MY_FOO_CONT_C);
    assertAbsent(schemaContext, MY_BAR_CONT_A);
    assertAbsent(schemaContext, MY_BAR_CONT_B);
}
Also used : EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 33 with EffectiveModelContext

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

the class SharedSchemaRepositoryWithFeaturesTest method testSharedSchemaRepositoryWithAllFeaturesSupported.

@Test
public void testSharedSchemaRepositoryWithAllFeaturesSupported() throws Exception {
    final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("shared-schema-repo-with-features-test");
    final SettableSchemaProvider<IRSchemaSource> foobar = getImmediateYangSourceProviderFromResource("/if-feature-resolution-test/shared-schema-repository/foobar.yang");
    foobar.register(sharedSchemaRepository);
    foobar.setResult();
    final EffectiveModelContextFactory fact = sharedSchemaRepository.createEffectiveModelContextFactory();
    final ListenableFuture<EffectiveModelContext> testSchemaContextFuture = fact.createEffectiveModelContext(foobar.getId());
    assertTrue(testSchemaContextFuture.isDone());
    assertSchemaContext(testSchemaContextFuture.get(), 1);
    final Module module = testSchemaContextFuture.get().findModules("foobar").iterator().next();
    assertNotNull(module);
    assertEquals(3, module.getChildNodes().size());
    final ContainerSchemaNode testContainerA = (ContainerSchemaNode) module.getDataChildByName(QName.create(module.getQNameModule(), "test-container-a"));
    final LeafSchemaNode testLeafA = (LeafSchemaNode) testContainerA.getDataChildByName(QName.create(module.getQNameModule(), "test-leaf-a"));
    final ContainerSchemaNode testContainerB = (ContainerSchemaNode) module.getDataChildByName(QName.create(module.getQNameModule(), "test-container-b"));
    final LeafSchemaNode testLeafB = (LeafSchemaNode) testContainerB.getDataChildByName(QName.create(module.getQNameModule(), "test-leaf-b"));
    final ContainerSchemaNode testContainerC = (ContainerSchemaNode) module.getDataChildByName(QName.create(module.getQNameModule(), "test-container-c"));
    final LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(QName.create(module.getQNameModule(), "test-leaf-c"));
}
Also used : IRSchemaSource(org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRSchemaSource) ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) EffectiveModelContextFactory(org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) Module(org.opendaylight.yangtools.yang.model.api.Module) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 34 with EffectiveModelContext

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

the class SharedSchemaRepositoryWithFeaturesTest method testSharedSchemaRepositoryWithNoFeaturesSupported.

@Test
public void testSharedSchemaRepositoryWithNoFeaturesSupported() throws Exception {
    final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("shared-schema-repo-with-features-test");
    final SettableSchemaProvider<IRSchemaSource> foobar = getImmediateYangSourceProviderFromResource("/if-feature-resolution-test/shared-schema-repository/foobar.yang");
    foobar.register(sharedSchemaRepository);
    foobar.setResult();
    final ListenableFuture<EffectiveModelContext> testSchemaContextFuture = sharedSchemaRepository.createEffectiveModelContextFactory(SchemaContextFactoryConfiguration.builder().setSupportedFeatures(ImmutableSet.of()).build()).createEffectiveModelContext(foobar.getId());
    assertTrue(testSchemaContextFuture.isDone());
    assertSchemaContext(testSchemaContextFuture.get(), 1);
    final Module module = testSchemaContextFuture.get().findModules("foobar").iterator().next();
    assertNotNull(module);
    assertEquals(1, module.getChildNodes().size());
    final ContainerSchemaNode testContainerC = (ContainerSchemaNode) module.getDataChildByName(QName.create(module.getQNameModule(), "test-container-c"));
    final LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(QName.create(module.getQNameModule(), "test-leaf-c"));
}
Also used : IRSchemaSource(org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRSchemaSource) ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) Module(org.opendaylight.yangtools.yang.model.api.Module) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 35 with EffectiveModelContext

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

the class SharedSchemaRepositoryTest method testDifferentCosts.

@Test
public void testDifferentCosts() throws Exception {
    final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("netconf-mounts");
    final SettableSchemaProvider<IRSchemaSource> immediateInetTypesYang = spy(getImmediateYangSourceProviderFromResource("/ietf/ietf-inet-types@2010-09-24.yang"));
    immediateInetTypesYang.register(sharedSchemaRepository);
    immediateInetTypesYang.setResult();
    final SettableSchemaProvider<IRSchemaSource> remoteInetTypesYang = spy(getRemoteYangSourceProviderFromResource("/ietf/ietf-inet-types@2010-09-24.yang"));
    remoteInetTypesYang.register(sharedSchemaRepository);
    remoteInetTypesYang.setResult();
    final EffectiveModelContextFactory fact = sharedSchemaRepository.createEffectiveModelContextFactory();
    final ListenableFuture<EffectiveModelContext> schemaContextFuture = fact.createEffectiveModelContext(remoteInetTypesYang.getId());
    assertSchemaContext(schemaContextFuture.get(), 1);
    final SourceIdentifier id = immediateInetTypesYang.getId();
    verify(remoteInetTypesYang, times(0)).getSource(id);
    verify(immediateInetTypesYang).getSource(id);
}
Also used : IRSchemaSource(org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRSchemaSource) EffectiveModelContextFactory(org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory) SourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

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