use of org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRSchemaSource in project yangtools by opendaylight.
the class MultipleRevImportBug6875Test method testYang10.
@Test
public void testYang10() throws Exception {
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("shared-schema-repo-multiple-rev-import-test");
final SettableSchemaProvider<IRSchemaSource> foo = getSourceProvider("/rfc7950/bug6875/yang1-0/foo.yang");
final SettableSchemaProvider<IRSchemaSource> bar1 = getSourceProvider("/rfc7950/bug6875/yang1-0/bar@1999-01-01.yang");
final SettableSchemaProvider<IRSchemaSource> bar2 = getSourceProvider("/rfc7950/bug6875/yang1-0/bar@2017-02-06.yang");
setAndRegister(sharedSchemaRepository, foo);
setAndRegister(sharedSchemaRepository, bar1);
setAndRegister(sharedSchemaRepository, bar2);
final ListenableFuture<EffectiveModelContext> schemaContextFuture = sharedSchemaRepository.createEffectiveModelContextFactory().createEffectiveModelContext(foo.getId(), bar1.getId(), bar2.getId());
assertTrue(schemaContextFuture.isDone());
final ExecutionException ex = assertThrows(ExecutionException.class, schemaContextFuture::get);
final Throwable cause = ex.getCause();
assertThat(cause, instanceOf(IllegalArgumentException.class));
assertThat(cause.getMessage(), startsWith("Module:bar imported twice with different revisions"));
}
use of org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRSchemaSource in project yangtools by opendaylight.
the class SchemaContextFactoryDeviationsTest method createSchemaContext.
private static ListenableFuture<EffectiveModelContext> createSchemaContext(final SetMultimap<QNameModule, QNameModule> modulesWithSupportedDeviations, final String... resources) throws Exception {
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("shared-schema-repo-with-deviations-test");
final Collection<SourceIdentifier> requiredSources = new ArrayList<>();
for (final String resource : resources) {
final SettableSchemaProvider<IRSchemaSource> yangSource = getImmediateYangSourceProviderFromResource(resource);
yangSource.register(sharedSchemaRepository);
yangSource.setResult();
requiredSources.add(yangSource.getId());
}
final SchemaContextFactoryConfiguration config = SchemaContextFactoryConfiguration.builder().setModulesDeviatedByModules(modulesWithSupportedDeviations).build();
return sharedSchemaRepository.createEffectiveModelContextFactory(config).createEffectiveModelContext(requiredSources);
}
use of org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRSchemaSource 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.parser.rfc7950.ir.IRSchemaSource 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.parser.rfc7950.ir.IRSchemaSource 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