import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
import org.junit.Test;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
public class KeyTest {
- private static final YangStatementSourceImpl KEY_SIMPLE_AND_COMP = new YangStatementSourceImpl(
- "/semantic-statement-parser/key-arg-parsing/key-simple-and-comp.yang", false);
- private static final YangStatementSourceImpl KEY_COMP_DUPLICATE = new YangStatementSourceImpl(
- "/semantic-statement-parser/key-arg-parsing/key-comp-duplicate.yang", false);
+ private static final StatementStreamSource KEY_SIMPLE_AND_COMP = sourceForResource(
+ "/semantic-statement-parser/key-arg-parsing/key-simple-and-comp.yang");
+ private static final StatementStreamSource KEY_COMP_DUPLICATE = sourceForResource(
+ "/semantic-statement-parser/key-arg-parsing/key-comp-duplicate.yang");
@Test
public void keySimpleTest() throws ReactorException {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, KEY_SIMPLE_AND_COMP);
+ reactor.addSources(KEY_SIMPLE_AND_COMP);
EffectiveModelContext result = reactor.build();
assertNotNull(result);
public void keyCompositeInvalid() {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, KEY_COMP_DUPLICATE);
+ reactor.addSources(KEY_COMP_DUPLICATE);
try {
reactor.build();
assertTrue(cause.getMessage().startsWith("Key argument 'key1 key2 key2' contains duplicates"));
}
}
-
- private static void addSources(final BuildAction reactor, final YangStatementSourceImpl... sources) {
- for (YangStatementSourceImpl source : sources) {
- reactor.addSource(source);
- }
- }
-
}