本文整理汇总了Java中org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier.create方法的典型用法代码示例。如果您正苦于以下问题:Java RevisionSourceIdentifier.create方法的具体用法?Java RevisionSourceIdentifier.create怎么用?Java RevisionSourceIdentifier.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier
的用法示例。
在下文中一共展示了RevisionSourceIdentifier.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSourceRegisteredWithDifferentSI
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
@Test
public void testSourceRegisteredWithDifferentSI() throws Exception {
final YangTextSchemaSource source1 = YangTextSchemaSource.forResource("/ietf/[email protected]");
final YangTextSchemaSource source2 = YangTextSchemaSource.forResource("/ietf/[email protected]");
s1 = source1.getIdentifier();
s2 = source2.getIdentifier();
final SettableSchemaProvider<ASTSchemaSource> provider =
SharedSchemaRepositoryTest.getImmediateYangSourceProviderFromResource(
"/no-revision/[email protected]");
provider.setResult();
provider.register(repository);
// 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()));
final SharedSchemaContextFactory sharedSchemaContextFactory = new SharedSchemaContextFactory(repository,
filter);
final ListenableFuture<SchemaContext> schemaContext =
sharedSchemaContextFactory.createSchemaContext(Arrays.asList(sIdWithoutRevision, provider.getId()));
assertNotNull(schemaContext.get());
}
示例2: onLinkageDeclared
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
@Override
public final void onLinkageDeclared(
final Mutable<String, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> stmt) {
final SourceIdentifier submoduleIdentifier = RevisionSourceIdentifier.create(stmt.getStatementArgument(),
StmtContextUtils.getLatestRevision(stmt.declaredSubstatements()));
final StmtContext<?, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>>
possibleDuplicateSubmodule = stmt.getFromNamespace(SubmoduleNamespace.class, submoduleIdentifier);
if (possibleDuplicateSubmodule != null && possibleDuplicateSubmodule != stmt) {
throw new SourceException(stmt.getStatementSourceReference(), "Submodule name collision: %s. At %s",
stmt.getStatementArgument(), possibleDuplicateSubmodule.getStatementSourceReference());
}
stmt.addContext(SubmoduleNamespace.class, submoduleIdentifier, stmt);
final String belongsToModuleName = firstAttributeOf(stmt.declaredSubstatements(), BelongsToStatement.class);
final StmtContext<?, ?, ?> prefixSubStmtCtx = findFirstDeclaredSubstatement(stmt, 0,
BelongsToStatement.class, PrefixStatement.class);
SourceException.throwIfNull(prefixSubStmtCtx, stmt.getStatementSourceReference(),
"Prefix of belongsTo statement is missing in submodule [%s]", stmt.getStatementArgument());
final String prefix = (String) prefixSubStmtCtx.getStatementArgument();
stmt.addToNs(BelongsToPrefixToModuleName.class, prefix, belongsToModuleName);
}
示例3: testBug6961SchemaContext
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
@Test
public void testBug6961SchemaContext() throws Exception {
final Optional<Revision> revision = Revision.ofNullable("2016-01-01");
final SourceIdentifier foo = RevisionSourceIdentifier.create("foo", revision);
final SourceIdentifier sub1Foo = RevisionSourceIdentifier.create("sub1-foo", revision);
final SourceIdentifier sub2Foo = RevisionSourceIdentifier.create("sub2-foo", revision);
final SourceIdentifier bar = RevisionSourceIdentifier.create("bar", revision);
final SourceIdentifier sub1Bar = RevisionSourceIdentifier.create("sub1-bar", revision);
final SourceIdentifier baz = RevisionSourceIdentifier.create("baz", revision);
final Set<SourceIdentifier> testSet = ImmutableSet.of(foo, sub1Foo, sub2Foo, bar, sub1Bar, baz);
final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6961/");
assertNotNull(context);
final Set<SourceIdentifier> allModuleIdentifiers = SchemaContextUtil.getConstituentModuleIdentifiers(context);
assertNotNull(allModuleIdentifiers);
assertEquals(6, allModuleIdentifiers.size());
final SchemaContext schemaContext = SimpleSchemaContext.forModules(context.getModules());
assertNotNull(schemaContext);
final Set<SourceIdentifier> allModuleIdentifiersResolved = SchemaContextUtil.getConstituentModuleIdentifiers(
schemaContext);
assertNotNull(allModuleIdentifiersResolved);
assertEquals(6, allModuleIdentifiersResolved.size());
assertEquals(allModuleIdentifiersResolved, allModuleIdentifiers);
assertEquals(allModuleIdentifiers, testSet);
assertTrue(allModuleIdentifiers.contains(foo));
}
示例4: schemaSourceTransformerGetSourceTest
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
@Test
public void schemaSourceTransformerGetSourceTest() {
final Provider p = new Provider();
final Registrator reg = new Registrator(p, SchemaSourceTransformerTest.SRC_CLASS,
PotentialSchemaSource.Costs.IMMEDIATE);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("source");
reg.register(sourceIdentifier);
this.schema = new SchemaSourceTransformer<>(p,
SchemaSourceTransformerTest.SRC_CLASS, this.consumer, SchemaSourceTransformerTest.DST_CLASS,
this.function);
final SchemaSourceProvider<YinXmlSchemaSource> prov = this.schema;
final Future<? extends YinXmlSchemaSource> source = prov.getSource(sourceIdentifier);
Assert.assertNotNull(source);
source.cancel(true);
Assert.assertTrue(source.isDone());
}
示例5: inMemorySchemaSourceCache3test
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
@Test
public void inMemorySchemaSourceCache3test() throws Exception {
final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache =
InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION);
final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache2 =
InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION, LIFETIME, UNITS);
final String content = "content";
final YangTextSchemaSource source = new TestingYangSource("test", "2012-12-12", content);
inMemorySchemaSourceCache.offer(source);
inMemorySchemaSourceCache2.offer(source);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test", Revision.of("2012-12-12"));
final ListenableFuture<? extends YangSchemaSourceRepresentation> checkedSource =
inMemorySchemaSourceCache.getSource(sourceIdentifier);
final ListenableFuture<? extends SchemaSourceRepresentation> checkedSource2 =
inMemorySchemaSourceCache2.getSource(sourceIdentifier);
Assert.assertNotNull(checkedSource);
Assert.assertNotNull(checkedSource2);
Assert.assertEquals(checkedSource.get(), checkedSource2.get());
inMemorySchemaSourceCache.close();
inMemorySchemaSourceCache2.close();
}
示例6: sourceIdToFileEmptyRevWithMoreItemsInDir
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
@Test
public void sourceIdToFileEmptyRevWithMoreItemsInDir() {
final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(this.registry,
YangTextSchemaSource.class, this.storageDir);
final String content = "content1";
final YangTextSchemaSource source = new TestingYangSource("test", "2012-12-12", content);
final YangTextSchemaSource source2 = new TestingYangSource("test", "2013-12-12", content);
cache.offer(source);
cache.offer(source2);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test");
final File sourceIdToFile = FilesystemSchemaSourceCache.sourceIdToFile(sourceIdentifier, this.storageDir);
Assert.assertNotNull(sourceIdToFile);
final List<File> storedFiles = Arrays.asList(this.storageDir.listFiles());
assertEquals(2, storedFiles.size());
}
示例7: guessSourceIdentifier
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
private static SourceIdentifier guessSourceIdentifier(final String fileName) {
try {
return YangTextSchemaSource.identifierFromFilename(fileName);
} catch (final IllegalArgumentException e) {
LOG.warn("Invalid file name format in '{}'", fileName, e);
return RevisionSourceIdentifier.create(fileName);
}
}
示例8: schemaSourceRegAndUnregSchemaSourceTest
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
@Test
public void schemaSourceRegAndUnregSchemaSourceTest() {
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("source");
final Foo<YangSchemaSourceRepresentation> foo = new Foo<>(sourceIdentifier,
SchemaSourceTransformerTest.SRC_CLASS,
PotentialSchemaSource.Costs.COMPUTATION);
final Provider p = new Provider();
final Registrator reg = new Registrator(p, SchemaSourceTransformerTest.SRC_CLASS,
PotentialSchemaSource.Costs.IMMEDIATE);
reg.register(sourceIdentifier);
final Consumer c = new Consumer();
this.schema = new SchemaSourceTransformer<>(p,
SchemaSourceTransformerTest.SRC_CLASS, c, SchemaSourceTransformerTest.DST_CLASS, this.function);
final SchemaSourceListener listener = this.schema;
p.registerSchemaSourceListener(listener);
final PotentialSchemaSource<?>[] potList = { foo.getPotentialSchemSource() };
final Iterable<PotentialSchemaSource<?>> sources = Arrays.asList(potList);
listener.schemaSourceRegistered(sources);
final ListenableFuture<YinXmlSchemaSource> source = this.schema.getSource(sourceIdentifier);
Assert.assertNotNull(source);
listener.schemaSourceUnregistered(foo.getPotentialSchemSource());
final ListenableFuture<YinXmlSchemaSource> source2 = this.schema.getSource(sourceIdentifier);
Assert.assertNotNull(source2);
}
示例9: inMemorySchemaSourceCacheNullGetSourcestest
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
@Test(expected = ExecutionException.class)
public void inMemorySchemaSourceCacheNullGetSourcestest() throws Exception {
final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache =
InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test", Revision.of("2012-12-12"));
final ListenableFuture<? extends YangSchemaSourceRepresentation> checkedSource =
inMemorySchemaSourceCache.getSource(sourceIdentifier);
Assert.assertNotNull(checkedSource);
checkedSource.get();
inMemorySchemaSourceCache.close();
}
示例10: createSourceIdentifier
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
public static SourceIdentifier createSourceIdentifier(final StmtContext<?, ?, ?> root) {
final QNameModule qNameModule = root.getFromNamespace(ModuleCtxToModuleQName.class, root);
if (qNameModule != null) {
// creates SourceIdentifier for a module
return RevisionSourceIdentifier.create((String) root.getStatementArgument(), qNameModule.getRevision());
}
// creates SourceIdentifier for a submodule
final Optional<Revision> revision = getLatestRevision(root.declaredSubstatements());
return RevisionSourceIdentifier.create((String) root.getStatementArgument(), revision);
}
示例11: sourceIdToFileEmptyRevWithOneItemInDir
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
@Test
public void sourceIdToFileEmptyRevWithOneItemInDir() {
final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(this.registry,
YangTextSchemaSource.class, this.storageDir);
final String content = "content1";
final YangTextSchemaSource source = new TestingYangSource("test", "2013-12-12", content);
cache.offer(source);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test");
final File sourceIdToFile = FilesystemSchemaSourceCache.sourceIdToFile(sourceIdentifier,
this.storageDir);
Assert.assertNotNull(sourceIdToFile);
final List<File> storedFiles = Arrays.asList(this.storageDir.listFiles());
assertEquals(1, storedFiles.size());
}
示例12: test1
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
@Test(expected = ExecutionException.class)
public void test1() throws Exception {
final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(this.registry,
YangTextSchemaSource.class, this.storageDir);
final String content = "content1";
final YangTextSchemaSource source = new TestingYangSource("test", "2013-12-12", content);
cache.offer(source);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test1", Revision.of("2012-12-12"));
final ListenableFuture<? extends YangTextSchemaSource> checked = cache.getSource(sourceIdentifier);
Assert.assertNotNull(checked);
checked.get();
}
示例13: getImportedSourceIdentifier
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
static SourceIdentifier getImportedSourceIdentifier(final StmtContext<String, ImportStatement, ?> stmt) {
final StmtContext<Revision, ?, ?> revision = findFirstDeclaredSubstatement(stmt,
RevisionDateStatement.class);
return revision == null ? RevisionSourceIdentifier.create(stmt.getStatementArgument())
: RevisionSourceIdentifier.create(stmt.getStatementArgument(), revision.getStatementArgument());
}
示例14: getSourceId
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
private static SourceIdentifier getSourceId(final YangModelDependencyInfo depInfo) {
final String name = depInfo.getName();
return depInfo.getFormattedRevision() == null ? RevisionSourceIdentifier.create(name)
: RevisionSourceIdentifier.create(name, depInfo.getRevision());
}
示例15: moduleToIdentifier
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入方法依赖的package包/类
static SourceIdentifier moduleToIdentifier(final Module module) {
return RevisionSourceIdentifier.create(module.getName(), module.getRevision());
}