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"));
}
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);
}
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"));
}
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"));
}
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);
}
Aggregations