use of org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException in project controller by opendaylight.
the class RemoteSchemaProviderTest method getNonExistingSchemaSource.
@Test(expected = SchemaSourceException.class)
public void getNonExistingSchemaSource() throws Exception {
Futures.failed(new Exception("halo"));
Mockito.when(mockedRemoteSchemaRepository.getYangTextSchemaSource(ID)).thenReturn(Futures.failed(new SchemaSourceException("Source not provided")));
CheckedFuture<?, ?> sourceFuture = remoteSchemaProvider.getSource(ID);
assertTrue(sourceFuture.isDone());
sourceFuture.checkedGet();
}
use of org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException in project mdsal by opendaylight.
the class ModuleInfoSnapshotResolver method registerModuleInfo.
/*
* Perform registration of a YangModuleInfo.
*/
@Holding("this")
private RegisteredModuleInfo registerModuleInfo(@NonNull final YangModuleInfo info) {
// First search for an existing explicit registration
final SourceIdentifier sourceId = sourceIdentifierFrom(info);
for (RegisteredModuleInfo reg : sourceToInfoReg.get(sourceId)) {
if (info.equals(reg.info)) {
reg.incRef();
LOG.debug("Reusing registration {}", reg);
return reg;
}
}
// Create an explicit registration
final Registration reg;
try {
reg = ctxResolver.registerSource(toYangTextSource(sourceId, info));
} catch (YangSyntaxErrorException | SchemaSourceException | IOException e) {
throw new IllegalStateException("Failed to register info " + info, e);
}
final RegisteredModuleInfo regInfo = new RegisteredModuleInfo(info, reg, info.getClass().getClassLoader());
LOG.debug("Created new registration {}", regInfo);
sourceToInfoReg.put(sourceId, regInfo);
return regInfo;
}
use of org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException in project netconf by opendaylight.
the class YangLibrarySchemaYangSourceProvider method getSource.
@Override
public ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
final URL url = availableSources.get(requireNonNull(sourceIdentifier));
checkArgument(url != null);
try (InputStream in = url.openStream()) {
final byte[] schemaContent = in.readAllBytes();
final NetconfYangTextSchemaSource yangSource = new NetconfYangTextSchemaSource(id, sourceIdentifier, url.toString(), schemaContent);
LOG.debug("Source {} downloaded from a yang library's url {}", sourceIdentifier, url);
return Futures.immediateFuture(yangSource);
} catch (IOException e) {
LOG.warn("Unable to download source {} from a yang library's url {}", sourceIdentifier, url, e);
return Futures.immediateFailedFuture(new SchemaSourceException("Unable to download remote schema for " + sourceIdentifier + " from " + url, e));
}
}
Aggregations