@Beta
public class SchemaResolutionException extends SchemaSourceException {
- private static final String MESSAGE_BLUEPRINT = "%s, resolved sources: %s, unsatisfied imports: %s";
-
private static final long serialVersionUID = 1L;
+ private final SourceIdentifier failedSource;
private final Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports;
private final Collection<SourceIdentifier> resolvedSources;
}
public SchemaResolutionException(@Nonnull final String message, final Throwable cause) {
- this(message, cause, Collections.emptySet(), ImmutableMultimap.of());
+ this(message, null, cause, Collections.emptySet(), ImmutableMultimap.of());
+ }
+
+ public SchemaResolutionException(@Nonnull final String message, final SourceIdentifier failedSource,
+ final Throwable cause) {
+ this(message, failedSource, cause, Collections.emptySet(), ImmutableMultimap.of());
}
public SchemaResolutionException(@Nonnull final String message, final Collection<SourceIdentifier> resolvedSources,
final @Nonnull Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports) {
- this(message, null, resolvedSources, unsatisfiedImports);
+ this(message, null, null, resolvedSources, unsatisfiedImports);
}
- public SchemaResolutionException(@Nonnull final String message, final Throwable cause,
- @Nonnull final Collection<SourceIdentifier> resolvedSources,
+ public SchemaResolutionException(@Nonnull final String message, final SourceIdentifier failedSource,
+ final Throwable cause, @Nonnull final Collection<SourceIdentifier> resolvedSources,
@Nonnull final Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports) {
- super(formatMessage(message, resolvedSources, unsatisfiedImports), cause);
+ super(formatMessage(message, failedSource, resolvedSources, unsatisfiedImports), cause);
+ this.failedSource = failedSource;
this.unsatisfiedImports = ImmutableMultimap.copyOf(unsatisfiedImports);
this.resolvedSources = ImmutableList.copyOf(resolvedSources);
}
- private static String formatMessage(final String message, final Collection<SourceIdentifier> resolvedSources, final Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports) {
- return String.format(MESSAGE_BLUEPRINT, message, resolvedSources, unsatisfiedImports);
+ private static String formatMessage(final String message, final SourceIdentifier failedSource,
+ final Collection<SourceIdentifier> resolvedSources,
+ final Multimap<SourceIdentifier, ModuleImport> unsatisfiedImports) {
+ return String.format("%s, failed source: %s, resolved sources: %s, unsatisfied imports: %s", message,
+ failedSource, resolvedSources, unsatisfiedImports);
+ }
+
+ /**
+ * Return YANG schema source identifier consisting of name and revision of the module which caused this exception
+ *
+ * @return YANG schema source identifier
+ */
+ public final SourceIdentifier getFailedSource() {
+ return this.failedSource;
}
/**
reactor.addSource(new YangStatementSourceImpl(e.getKey(), (StatementContext) parserRuleCtx));
}
- final SchemaContext schemaContext = reactor.buildEffective();
+ final SchemaContext schemaContext;
+ try {
+ schemaContext = reactor.buildEffective();
+ } catch (ReactorException ex) {
+ throw new SchemaResolutionException("Failed to resolve required models", ex.getSourceIdentifier(), ex);
+ }
return Futures.immediateCheckedFuture(schemaContext);
}
package org.opendaylight.yangtools.yang.parser.spi.meta;
import com.google.common.base.Preconditions;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
public class ReactorException extends Exception {
private static final long serialVersionUID = 1L;
private final ModelProcessingPhase phase;
+ private final SourceIdentifier sourceIdentifier;
- public ReactorException(ModelProcessingPhase phase, String message, Throwable cause) {
+ public ReactorException(ModelProcessingPhase phase, String message, SourceIdentifier sourceId, Throwable cause) {
super(message, cause);
this.phase = Preconditions.checkNotNull(phase);
+ this.sourceIdentifier = sourceId;
}
- public ReactorException(ModelProcessingPhase phase, String message) {
+ public ReactorException(ModelProcessingPhase phase, String message, SourceIdentifier sourceId) {
super(message);
this.phase = Preconditions.checkNotNull(phase);
+ this.sourceIdentifier = sourceId;
}
public final ModelProcessingPhase getPhase() {
return phase;
}
+ public final SourceIdentifier getSourceIdentifier() {
+ return sourceIdentifier;
+ }
}
*/
package org.opendaylight.yangtools.yang.parser.spi.meta;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+
public class SomeModifiersUnresolvedException extends ReactorException {
private static final long serialVersionUID = 1L;
- public SomeModifiersUnresolvedException(ModelProcessingPhase phase) {
- super(phase,"Some of " + phase + " modifiers for statements were not resolved.");
+ public SomeModifiersUnresolvedException(ModelProcessingPhase phase, SourceIdentifier sourceId, Throwable cause) {
+ super(phase, "Some of " + phase + " modifiers for statements were not resolved.", sourceId, cause);
}
}
package org.opendaylight.yangtools.yang.parser.stmt.reactor;
import com.google.common.base.Preconditions;
-import com.google.common.base.Throwables;
import com.google.common.base.Verify;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
import org.opendaylight.yangtools.yang.parser.spi.meta.DerivedNamespaceBehaviour;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace;
import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.SourceSpecificContext.PhaseCompletionProgress;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return new EffectiveModelContext(rootStatements);
}
- public EffectiveSchemaContext buildEffective() throws SourceException, ReactorException {
+ public EffectiveSchemaContext buildEffective() throws ReactorException {
for (ModelProcessingPhase phase : PHASE_EXECUTION_ORDER) {
startPhase(phase);
loadPhaseStatements();
return transformEffective();
}
- private EffectiveSchemaContext transformEffective() {
+ private EffectiveSchemaContext transformEffective() throws ReactorException {
Preconditions.checkState(finishedPhase == ModelProcessingPhase.EFFECTIVE_MODEL);
List<DeclaredStatement<?>> rootStatements = new ArrayList<>(sources.size());
List<EffectiveStatement<?, ?>> rootEffectiveStatements = new ArrayList<>(sources.size());
+ SourceIdentifier sourceId = null;
- for (SourceSpecificContext source : sources) {
- final RootStatementContext<?, ?, ?> root = source.getRoot();
- rootStatements.add(root.buildDeclared());
- rootEffectiveStatements.add(root.buildEffective());
+ try {
+ for (SourceSpecificContext source : sources) {
+ final RootStatementContext<?, ?, ?> root = source.getRoot();
+ sourceId = Utils.createSourceIdentifier(root);
+ rootStatements.add(root.buildDeclared());
+ rootEffectiveStatements.add(root.buildEffective());
+ }
+ } catch (SourceException ex) {
+ throw new SomeModifiersUnresolvedException(currentPhase, sourceId, ex);
}
return new EffectiveSchemaContext(rootStatements, rootEffectiveStatements);
currentPhase = phase;
}
- private void loadPhaseStatements() throws SourceException {
+ private void loadPhaseStatements() throws ReactorException {
Preconditions.checkState(currentPhase != null);
for (SourceSpecificContext source : sources) {
- source.loadStatements();
+ try {
+ source.loadStatements();
+ } catch (SourceException ex) {
+ final SourceIdentifier sourceId = Utils.createSourceIdentifier(source.getRoot());
+ throw new SomeModifiersUnresolvedException(currentPhase, sourceId, ex);
+ }
}
}
- private SomeModifiersUnresolvedException addSourceExceptions(final SomeModifiersUnresolvedException buildFailure,
- final List<SourceSpecificContext> sourcesToProgress) {
+ private SomeModifiersUnresolvedException addSourceExceptions(final List<SourceSpecificContext> sourcesToProgress) {
boolean addedCause = false;
+ SomeModifiersUnresolvedException buildFailure = null;
for (SourceSpecificContext failedSource : sourcesToProgress) {
final SourceException sourceEx = failedSource.failModifiers(currentPhase);
if (!addedCause) {
addedCause = true;
- buildFailure.initCause(sourceEx);
+ final SourceIdentifier sourceId = Utils.createSourceIdentifier(failedSource.getRoot());
+ buildFailure = new SomeModifiersUnresolvedException(currentPhase, sourceId, sourceEx);
} else {
buildFailure.addSuppressed(sourceEx);
}
private void completePhaseActions() throws ReactorException {
Preconditions.checkState(currentPhase != null);
List<SourceSpecificContext> sourcesToProgress = Lists.newArrayList(sources);
+ SourceIdentifier sourceId = null;
try {
boolean progressing = true;
while (progressing) {
Iterator<SourceSpecificContext> currentSource = sourcesToProgress.iterator();
while (currentSource.hasNext()) {
SourceSpecificContext nextSourceCtx = currentSource.next();
+ sourceId = Utils.createSourceIdentifier(nextSourceCtx.getRoot());
PhaseCompletionProgress sourceProgress = nextSourceCtx.tryToCompletePhase(currentPhase);
switch (sourceProgress) {
case FINISHED:
}
}
} catch (SourceException e) {
- throw Throwables.propagate(e);
+ throw new SomeModifiersUnresolvedException(currentPhase, sourceId, e);
}
if (!sourcesToProgress.isEmpty()) {
- SomeModifiersUnresolvedException buildFailure = new SomeModifiersUnresolvedException(currentPhase);
- buildFailure = addSourceExceptions(buildFailure, sourcesToProgress);
+ final SomeModifiersUnresolvedException buildFailure = addSourceExceptions(sourcesToProgress);
throw buildFailure;
}
}
stmt.addToNs(ImpPrefixToNamespace.class, modulePrefix, moduleNs);
stmt.addContext(PreLinkageModuleNamespace.class, moduleName, stmt);
+
+ Optional<Date> revisionDate = Optional.fromNullable(Utils.getLatestRevision(stmt.declaredSubstatements
+ ()));
+ if (!revisionDate.isPresent()) {
+ revisionDate = Optional.of(SimpleDateFormatUtil.DEFAULT_DATE_REV);
+ }
+
+ QNameModule qNameModule = QNameModule.create(moduleNs, revisionDate.orNull()).intern();
+
+ stmt.addToNs(ModuleCtxToModuleQName.class, stmt, qNameModule);
};
@Override
stmt.addToNs(PrefixToModule.class, modulePrefix, qNameModule);
stmt.addToNs(ModuleNameToModuleQName.class, stmt.getStatementArgument(), qNameModule);
- stmt.addToNs(ModuleCtxToModuleQName.class, stmt, qNameModule);
+ stmt.addToNs(ModuleCtxToModuleQName.class, stmt, qNameModule); // tu
stmt.addToNs(ModuleCtxToModuleIdentifier.class, stmt, moduleIdentifier);
stmt.addToNs(ModuleQNameToModuleName.class, qNameModule, stmt.getStatementArgument());
stmt.addToNs(ModuleIdentifierToModuleQName.class, moduleIdentifier, qNameModule);
import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
import com.google.common.base.CharMatcher;
+import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Relative;
import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.util.RevisionAwareXPathImpl;
import org.opendaylight.yangtools.yang.parser.spi.meta.QNameCacheNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.RootStatementContext;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return false;
}
+
+ public static SourceIdentifier createSourceIdentifier(RootStatementContext<?, ?, ?> root) {
+ final QNameModule qNameModule = root.getFromNamespace(ModuleCtxToModuleQName.class, root);
+ if (qNameModule != null) {
+ // creates SourceIdentifier for a module
+ return RevisionSourceIdentifier.create((String) root.getStatementArgument(),
+ qNameModule.getFormattedRevision());
+ } else {
+ // creates SourceIdentifier for a submodule
+ final Date revision = Optional.fromNullable(Utils.getLatestRevision(root.declaredSubstatements()))
+ .or(SimpleDateFormatUtil.DEFAULT_DATE_REV);
+ final String formattedRevision = SimpleDateFormatUtil.getRevisionFormat().format(revision);
+ return RevisionSourceIdentifier.create((String) root.getStatementArgument(),
+ formattedRevision);
+ }
+ }
}
.addSupport(new IncludeStatementImpl.Definition())
.addSupport(new PrefixStatementImpl.Definition())
.addSupport(new YangVersionStatementImpl.Definition())
+ .addSupport(new RevisionStatementImpl.Definition())
.addSupport(global(ModuleNameToNamespace.class))
.addSupport(global(PreLinkageModuleNamespace.class))
.addSupport(sourceLocal(ImpPrefixToNamespace.class))
+ .addSupport(global(ModuleCtxToModuleQName.class))
.build();
public static final StatementSupportBundle LINKAGE_BUNDLE = StatementSupportBundle
.derivedFrom(PRE_LINKAGE_BUNDLE)
.addSupport(new DescriptionStatementImpl.Definition())
- .addSupport(new RevisionStatementImpl.Definition())
.addSupport(new RevisionDateStatementImpl.Definition())
.addSupport(new ReferenceStatementImpl.Definition())
.addSupport(new ContactStatementImpl.Definition())
.addSupport(global(SubmoduleNamespace.class))
.addSupport(global(NamespaceToModule.class))
.addSupport(global(ModuleNameToModuleQName.class))
- .addSupport(global(ModuleCtxToModuleQName.class))
.addSupport(global(ModuleCtxToModuleIdentifier.class))
.addSupport(global(ModuleQNameToModuleName.class))
.addSupport(global(PrefixToModule.class))
try {
StmtTestUtils.parseYangSources(new File(getClass().getResource("/bugs/bug5946/foo-invalid.yang").toURI()));
fail("Should fail due to invalid argument of unique constraint");
- } catch (SourceException e) {
- assertTrue(e.getMessage().startsWith(
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage().startsWith(
"Unique statement argument '/simple-unique/l1' contains schema node identifier '/simple-unique/l1'"
+ " which is not in the descendant node identifier form."));
}
package org.opendaylight.yangtools.yang.stmt;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.FileNotFoundException;
import java.net.URISyntaxException;
public void test() throws ReactorException, SourceException, FileNotFoundException, URISyntaxException {
try {
StmtTestUtils.parseYangSources("/bugs/bug6131");
+ fail("A NullPointerException should have been thrown.");
} catch (final Exception e) {
- assertEquals("Malformed source. Valid root element is missing.", e.getMessage());
+ assertTrue(e instanceof NullPointerException);
}
}
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ChoiceEffectiveStatementImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ContainerEffectiveStatementImpl;
@Test
public void InferenceExceptionChoiceTest() throws ReactorException, FileNotFoundException, URISyntaxException {
- expectedEx.expect(InferenceException.class);
+ expectedEx.expect(ReactorException.class);
schema = StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/choice");
}
@Test
public void InferenceExceptionCaseTest() throws ReactorException, FileNotFoundException, URISyntaxException {
- expectedEx.expect(InferenceException.class);
+ expectedEx.expect(ReactorException.class);
schema = StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/case");
}
}
\ No newline at end of file
*/
package org.opendaylight.yangtools.yang.stmt;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+
import java.io.IOException;
import java.net.URISyntaxException;
import org.junit.Test;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
reactor.buildEffective();
fail("effective build should fail due to list instead of leaf referenced in list key");
} catch (Exception e) {
- assertEquals(InferenceException.class, e.getClass());
- assertTrue(e.getMessage().startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"));
+ assertTrue(e instanceof ReactorException);
+ assertTrue(e.getCause().getMessage().startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"));
}
}
reactor.buildEffective();
fail("effective build should fail due to missing leaf referenced in list key");
} catch (Exception e) {
- assertEquals(InferenceException.class, e.getClass());
- assertTrue(e.getMessage().startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"));
+ assertTrue(e instanceof ReactorException);
+ assertTrue(e.getCause().getMessage().startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"));
}
}
reactor.buildEffective();
fail("effective build should fail due to list instead of leaf in grouping referenced in list key");
} catch (Exception e) {
- assertEquals(InferenceException.class, e.getClass());
- assertTrue(e.getMessage().startsWith("Key 'grp_list' misses node 'grp_list'"));
+ assertTrue(e instanceof ReactorException);
+ assertTrue(e.getCause().getMessage().startsWith("Key 'grp_list' misses node 'grp_list'"));
}
}
fail("effective build should fail due to list instead of leaf in grouping augmented to list referenced " +
"in list key");
} catch (Exception e) {
- assertEquals(InferenceException.class, e.getClass());
- assertTrue(e.getMessage().startsWith("Key 'grp_leaf' misses node 'grp_leaf'"));
+ assertTrue(e instanceof ReactorException);
+ assertTrue(e.getCause().getMessage().startsWith("Key 'grp_leaf' misses node 'grp_leaf'"));
}
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+
import com.google.common.base.Throwables;
import java.io.ByteArrayOutputStream;
import java.io.File;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
public class YangParserNegativeTest {
TestUtils.loadModule(stream);
fail("SourceException should be thrown");
}
- } catch (SourceException e) {
- assertTrue(e.getMessage().contains("Error in module 'test4' in the refine of uses 'Relative{path=[" +
- "(urn:simple.container.demo?revision=1970-01-01)node]}': can not perform refine of 'PRESENCE' for" +
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage().contains("Error in module 'test4' in the refine of uses " +
+ "'Relative{path=[(urn:simple.container.demo?revision=1970-01-01)node]}': can not perform refine of 'PRESENCE' for" +
" the target 'LEAF_LIST'."));
}
}
TestUtils.loadModule(stream);
fail("YangParseException should be thrown");
}
- } catch (SourceException e) {
- assertTrue(e.getMessage().contains("Invalid length constraint: <4, 10>"));
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage().contains("Invalid length constraint: <4, 10>"));
}
}
TestUtils.loadModule(stream);
fail("Exception should be thrown");
}
- } catch (SourceException e) {
- assertTrue(e.getMessage().contains("Invalid range constraint: <5, 20>"));
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage().contains("Invalid range constraint: <5, 20>"));
}
}
TestUtils.loadModule(stream);
fail("SourceException should be thrown");
}
- } catch (SourceException e) {
+ } catch (ReactorException e) {
String expected = "Error in module 'container': cannot add '(urn:simple.container" +
".demo?revision=1970-01-01)foo'. Node name collision: '(urn:simple.container" +
".demo?revision=1970-01-01)foo' already declared.";
- assertTrue(e.getMessage().contains(expected));
+ assertTrue(e.getCause().getMessage().contains(expected));
}
}
TestUtils.loadModule(stream);
fail("SourceException should be thrown");
}
- } catch (SourceException e) {
+ } catch (ReactorException e) {
String expected = "Error in module 'container-list': cannot add '(urn:simple.container" +
".demo?revision=1970-01-01)foo'. Node name collision: '(urn:simple.container" +
".demo?revision=1970-01-01)foo' already declared.";
- assertTrue(e.getMessage().contains(expected));
+ assertTrue(e.getCause().getMessage().contains(expected));
}
}
TestUtils.loadModule(stream);
fail("SourceException should be thrown");
}
- } catch (SourceException e) {
+ } catch (ReactorException e) {
String expected = "Error in module 'container-leaf': cannot add '(urn:simple.container" +
".demo?revision=1970-01-01)foo'. Node name collision: '(urn:simple.container" +
".demo?revision=1970-01-01)foo' already declared.";
- assertTrue(e.getMessage().contains(expected));
+ assertTrue(e.getCause().getMessage().contains(expected));
}
}
TestUtils.loadModule(stream);
fail("SourceException should be thrown");
}
- } catch (SourceException e) {
+ } catch (ReactorException e) {
String expected = "Error in module 'typedef': cannot add '(urn:simple.container" +
".demo?revision=1970-01-01)int-ext'. Node name collision: '(urn:simple.container" +
".demo?revision=1970-01-01)int-ext' already declared.";
- assertTrue(e.getMessage().startsWith(expected));
+ assertTrue(e.getCause().getMessage().startsWith(expected));
}
}
TestUtils.loadModule(stream1);
fail("InferenceException should be thrown");
}
- } catch (InferenceException e) {
+ } catch (ReactorException e) {
String expected = "Key 'rib-id' misses node 'rib-id' in list '(invalid:list:key:def?revision=1970-01-01)" +
"application-map'";
- assertTrue(e.getMessage().startsWith(expected));
+ assertTrue(e.getCause().getMessage().startsWith(expected));
}
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
-
import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
import org.opendaylight.yangtools.concepts.SemVer;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
StmtTestUtils.parseYangSources("/semantic-version/border-case/border-case-invalid-major",
StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid semantic version");
- } catch (InferenceException e) {
- assertTrue(e.getMessage()
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage()
.startsWith("Unable to find module compatible with requested import [bar(5.5.5)]."));
}
}
StmtTestUtils.parseYangSources("/semantic-version/border-case/border-case-invalid-minor",
StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid semantic version");
- } catch (InferenceException e) {
- assertTrue(e.getMessage()
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage()
.startsWith("Unable to find module compatible with requested import [bar(5.5.5)]."));
}
}
StmtTestUtils.parseYangSources("/semantic-version/border-case/border-case-invalid-patch",
StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid semantic version");
- } catch (InferenceException e) {
- assertTrue(e.getMessage()
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage()
.startsWith("Unable to find module compatible with requested import [bar(5.5.5)]."));
}
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
-
import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
import org.opendaylight.yangtools.concepts.SemVer;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
try {
StmtTestUtils.parseYangSources("/semantic-version/defaults/default-major-invalid", StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid semantic version");
- } catch (InferenceException e) {
- assertTrue(e.getMessage()
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage()
.startsWith("Unable to find module compatible with requested import [bar(0.0.0)]."));
}
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
-
import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
import org.opendaylight.yangtools.concepts.SemVer;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
StmtTestUtils.parseYangSources("/semantic-version/import/import-invalid-deprecated-1",
StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid import of semantic-version module");
- } catch (InferenceException e) {
- assertTrue(e.getMessage().startsWith(
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage().startsWith(
"Unable to find module compatible with requested import " + "[semantic-version(1.0.0)]."));
}
}
StmtTestUtils.parseYangSources("/semantic-version/import/import-invalid-deprecated-2",
StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid import of semantic-version module");
- } catch (InferenceException e) {
- assertTrue(e.getMessage().startsWith(
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage().startsWith(
"Unable to find module compatible with requested import " + "[semantic-version(0.9.9)]."));
}
}
StmtTestUtils.parseYangSources("/semantic-version/import/import-invalid-notsufficient-1",
StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid import of semantic-version module");
- } catch (InferenceException e) {
- assertTrue(e.getMessage().startsWith(
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage().startsWith(
"Unable to find module compatible with requested import " + "[semantic-version(2.0.0)]."));
}
}
StmtTestUtils.parseYangSources("/semantic-version/import/import-invalid-notsufficient-2",
StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid import of semantic-version module");
- } catch (InferenceException e) {
- assertTrue(e.getMessage().startsWith(
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage().startsWith(
"Unable to find module compatible with requested import " + "[semantic-version(2.0.5)]."));
}
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
-
import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
StmtTestUtils.parseYangSources("/semantic-version/multiple/multiple-invalid-deprecated",
StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid semantic version");
- } catch (InferenceException e) {
- assertTrue(e.getMessage()
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage()
.startsWith("Unable to find module compatible with requested import [bar(1.0.0)]."));
}
}
StmtTestUtils.parseYangSources("/semantic-version/multiple/multiple-invalid-nosufficient",
StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid semantic version");
- } catch (InferenceException e) {
- assertTrue(e.getMessage()
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage()
.startsWith("Unable to find module compatible with requested import [bar(2.5.5)]."));
}
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
-
import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
try {
StmtTestUtils.parseYangSources("/semantic-version/basic-import-invalid-1", StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid semantic version");
- } catch (InferenceException e) {
- assertTrue(e.getMessage()
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage()
.startsWith("Unable to find module compatible with requested import [bar(0.1.2)]."));
}
}
try {
StmtTestUtils.parseYangSources("/semantic-version/basic-import-invalid-2", StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid semantic version");
- } catch (InferenceException e) {
- assertTrue(e.getMessage()
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage()
.startsWith("Unable to find module compatible with requested import [bar(0.1.2)]."));
}
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
-
import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
import org.opendaylight.yangtools.concepts.SemVer;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
try {
StmtTestUtils.parseYinSources("/semantic-version/yin-input/basic-import-invalid", StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid semantic version");
- } catch (InferenceException e) {
- assertTrue(e.getMessage()
+ } catch (ReactorException e) {
+ assertTrue(e.getCause().getMessage()
.startsWith("Unable to find module compatible with requested import [bar(0.1.2)]."));
}
}