X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Frepo%2FSharedSchemaContextFactoryTest.java;h=631a76e3ad2f48a83eed5a28b1ef8f50adee7787;hb=1d4d5d61d5c50661d898b1b184f984d055486fba;hp=4f1512c4ace9c3c90bb48e2d8f6e7d0f85adbc6e;hpb=74296fa9e183b77851fc62d62f0585e26ddd7caf;p=yangtools.git diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaContextFactoryTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaContextFactoryTest.java index 4f1512c4ac..631a76e3ad 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaContextFactoryTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaContextFactoryTest.java @@ -8,29 +8,31 @@ package org.opendaylight.yangtools.yang.parser.repo; import static org.junit.Assert.assertNotNull; +import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFluentFuture; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import java.util.Arrays; +import java.util.concurrent.ExecutionException; import org.junit.Before; import org.junit.Test; -import org.mockito.Mock; +import org.junit.runner.RunWith; import org.mockito.MockitoAnnotations; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; -import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceFilter; +import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource; -import org.opendaylight.yangtools.yang.parser.util.ASTSchemaSource; -import org.opendaylight.yangtools.yang.parser.util.TextToASTTransformer; +import org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRSchemaSource; +import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer; +@RunWith(MockitoJUnitRunner.StrictStubs.class) public class SharedSchemaContextFactoryTest { private final SharedSchemaRepository repository = new SharedSchemaRepository("test"); - @Mock - private SchemaSourceFilter filter; + private final SchemaContextFactoryConfiguration config = SchemaContextFactoryConfiguration.getDefault(); private SourceIdentifier s1; private SourceIdentifier s2; @@ -40,24 +42,25 @@ public class SharedSchemaContextFactoryTest { final YangTextSchemaSource source1 = YangTextSchemaSource.forResource("/ietf/ietf-inet-types@2010-09-24.yang"); final YangTextSchemaSource source2 = YangTextSchemaSource.forResource("/ietf/iana-timezones@2012-07-09.yang"); - s1 = RevisionSourceIdentifier.create("ietf-inet-types", "2010-09-24"); - s2 = RevisionSourceIdentifier.create("iana-timezones", "2012-07-09"); + s1 = RevisionSourceIdentifier.create("ietf-inet-types", Revision.of("2010-09-24")); + s2 = RevisionSourceIdentifier.create("iana-timezones", Revision.of("2012-07-09")); - final TextToASTTransformer transformer = TextToASTTransformer.create(repository, repository); + final TextToIRTransformer transformer = TextToIRTransformer.create(repository, repository); repository.registerSchemaSourceListener(transformer); - repository.registerSchemaSource(sourceIdentifier -> Futures.immediateCheckedFuture(source1), + repository.registerSchemaSource(sourceIdentifier -> immediateFluentFuture(source1), PotentialSchemaSource.create(s1, YangTextSchemaSource.class, 1)); - repository.registerSchemaSource(sourceIdentifier -> Futures.immediateCheckedFuture(source2), + repository.registerSchemaSource(sourceIdentifier -> immediateFluentFuture(source2), PotentialSchemaSource.create(s2, YangTextSchemaSource.class, 1)); } @Test - public void testCreateSchemaContextWithDuplicateRequiredSources() throws Exception { - final SharedSchemaContextFactory sharedSchemaContextFactory = new SharedSchemaContextFactory(repository, filter); - final ListenableFuture schemaContext = - sharedSchemaContextFactory.createSchemaContext(Arrays.asList(s1, s1, s2)); + public void testCreateSchemaContextWithDuplicateRequiredSources() throws InterruptedException, ExecutionException { + final SharedSchemaContextFactory sharedSchemaContextFactory = new SharedSchemaContextFactory(repository, + config); + final ListenableFuture schemaContext = + sharedSchemaContextFactory.createEffectiveModelContext(s1, s1, s2); assertNotNull(schemaContext.get()); } @@ -68,7 +71,7 @@ public class SharedSchemaContextFactoryTest { s1 = source1.getIdentifier(); s2 = source2.getIdentifier(); - final SettableSchemaProvider provider = + final SettableSchemaProvider provider = SharedSchemaRepositoryTest.getImmediateYangSourceProviderFromResource( "/no-revision/imported@2012-12-12.yang"); provider.setResult(); @@ -77,11 +80,12 @@ public class SharedSchemaContextFactoryTest { // Register the same provider under source id without revision final SourceIdentifier sIdWithoutRevision = RevisionSourceIdentifier.create(provider.getId().getName()); repository.registerSchemaSource(provider, PotentialSchemaSource.create( - sIdWithoutRevision, ASTSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue())); + sIdWithoutRevision, IRSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue())); - final SharedSchemaContextFactory sharedSchemaContextFactory = new SharedSchemaContextFactory(repository, filter); - final ListenableFuture schemaContext = - sharedSchemaContextFactory.createSchemaContext(Arrays.asList(sIdWithoutRevision, provider.getId())); + final SharedSchemaContextFactory sharedSchemaContextFactory = new SharedSchemaContextFactory(repository, + config); + final ListenableFuture schemaContext = + sharedSchemaContextFactory.createEffectiveModelContext(sIdWithoutRevision, provider.getId()); assertNotNull(schemaContext.get()); } }