Switch to using YangParserTestUtil instead.
Change-Id: I98e0870051e42372adf7d7284b10b368e68516f6
Signed-off-by: Robert Varga <rovarga@cisco.com>
<artifactId>javassist</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-parser-impl</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-impl</artifactId>
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import com.google.common.collect.ImmutableList;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.List;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class BindingGeneratorImplTest {
- private static final YangStatementSourceImpl NETWORK_TOPOLOGY_20131021 = new YangStatementSourceImpl(
- "/isis-topology/network-topology@2013-10-21.yang", false);
-
- private static final YangStatementSourceImpl ISIS_20131021 = new YangStatementSourceImpl(
- "/isis-topology/isis-topology@2013-10-21.yang", false);
-
- private static final YangStatementSourceImpl L3_20131021 = new YangStatementSourceImpl(
- "/isis-topology/l3-unicast-igp-topology@2013-10-21.yang", false);
-
@Test
public void isisTotpologyStatementParserTest() throws IOException,
- YangSyntaxErrorException, URISyntaxException, SourceException,
- ReactorException {
- CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
- .newBuild();
-
- reactor.addSources(ISIS_20131021, L3_20131021,
- NETWORK_TOPOLOGY_20131021);
+ URISyntaxException, ReactorException {
+ final InputStream topo = getClass().getResourceAsStream("/isis-topology/network-topology@2013-10-21.yang");
+ final InputStream isis = getClass().getResourceAsStream("/isis-topology/isis-topology@2013-10-21.yang");
+ final InputStream l3 = getClass().getResourceAsStream("/isis-topology/l3-unicast-igp-topology@2013-10-21.yang");
- EffectiveSchemaContext context = reactor.buildEffective();
+ SchemaContext context = YangParserTestUtils.parseYangStreams(ImmutableList.of(isis, l3, topo));
assertNotNull(context);
List<Type> generateTypes = new BindingGeneratorImpl(false)
@Test
public void choiceNodeGenerationTest() throws IOException,
- YangSyntaxErrorException, URISyntaxException, SourceException, ReactorException {
+ URISyntaxException, ReactorException {
File resourceFile = new File(getClass().getResource(
"/binding-generator-impl-test/choice-test.yang").toURI());
}
@Test
- public void notificationGenerationTest() throws IOException,
- YangSyntaxErrorException, URISyntaxException, SourceException, ReactorException {
+ public void notificationGenerationTest() throws IOException, URISyntaxException, ReactorException {
File resourceFile = new File(getClass().getResource(
"/binding-generator-impl-test/notification-test.yang").toURI());
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import java.io.FileNotFoundException;
+import java.net.URISyntaxException;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
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;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class Bug6135Test {
@Ignore
@Test
- public void bug6135Test() throws ReactorException {
- final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- reactor.addSource(new YangStatementSourceImpl("/bug-6135/foo.yang", false));
-
- final EffectiveSchemaContext context = reactor.buildEffective();
+ public void bug6135Test() throws FileNotFoundException, ReactorException, URISyntaxException {
+ final SchemaContext context = YangParserTestUtils.parseYangSource("/bug-6135/foo.yang");
assertNotNull(context);
final List<Type> generateTypes = new BindingGeneratorImpl(false).generateTypes(context);
import static org.junit.Assert.assertNotNull;
import java.io.File;
+import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
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;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class Bug4621 {
public ExpectedException expectedEx = ExpectedException.none();
@Test
- public void bug4621test() throws ReactorException, URISyntaxException {
- final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
- .newBuild();
+ public void bug4621test() throws FileNotFoundException, ReactorException, URISyntaxException {
File file = new File(getClass().getResource("/bug-4621/foo.yang").toURI());
- reactor.addSource(new YangStatementSourceImpl(file.getPath(), true));
- final SchemaContext schemaContext = reactor.buildEffective();
+ final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(file);
final Module moduleValid = schemaContext.findModuleByNamespace(new URI("foo")).iterator().next();
final TypeProviderImpl typeProvider = new TypeProviderImpl(schemaContext);
.getDataChildByName(leafrefNode);
LeafSchemaNode leafRel = (LeafSchemaNode) leafrefRel;
TypeDefinition<?> leafTypeRel = leafRel.getType();
- Type leafrefRelResolvedType = typeProvider.javaTypeForSchemaDefinitionType(leafTypeRel, leafRel);
- assertNotNull(leafrefRelResolvedType);
+ assertNotNull(typeProvider.javaTypeForSchemaDefinitionType(leafTypeRel, leafRel));
}
}
\ No newline at end of file
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-impl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-test-util</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-binding2-generator-api</artifactId>
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.mdsal.binding2;
-
-import com.google.common.annotations.Beta;
-import java.io.File;
-import java.net.URI;
-import java.util.Set;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Beta
-public final class TestUtils {
-
- private static final Logger LOG = LoggerFactory.getLogger(TestUtils.class);
-
- private TestUtils() {
- throw new UnsupportedOperationException("Utility class");
- }
-
- public static Set<Module> loadModules(final URI resourceDirectory)
- throws SourceException, ReactorException {
- final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
- .newBuild();
- File[] files = new File(resourceDirectory).listFiles();
-
- for (File file : files) {
- if (file.getName().endsWith(".yang")) {
- addSources(reactor, new YangStatementSourceImpl(file.getPath(), true));
- } else {
- LOG.info("Ignoring non-yang file {}", file);
- }
- }
-
- EffectiveSchemaContext ctx = reactor.buildEffective();
- return ctx.getModules();
- }
-
- private static void addSources(final CrossSourceStatementReactor.BuildAction reactor,
- final YangStatementSourceImpl... sources) {
- for (YangStatementSourceImpl source : sources) {
- reactor.addSource(source);
- }
- }
-}
package org.opendaylight.mdsal.binding2;
import com.google.common.annotations.Beta;
+import java.io.FileNotFoundException;
import java.net.URISyntaxException;
import java.util.Set;
import org.junit.Before;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@Beta
public class YangTemplateTest {
private Set<Module> modules;
@Before
- public void setup() throws URISyntaxException, ReactorException {
- modules = TestUtils.loadModules(getClass().getResource("/yang-template").toURI());
+ public void setup() throws URISyntaxException, ReactorException, FileNotFoundException {
+ modules = YangParserTestUtils.parseYangSources("/yang-template").getModules();
}
@Test
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-test-util</artifactId>
</dependency>
</dependencies>
import java.io.InputStream;
import java.util.Collections;
-import java.util.List;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class TestModel {
private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
public static SchemaContext createTestContext() throws ReactorException {
- return parseYangStreams(Collections.singletonList(getInputStream()));
+ return YangParserTestUtils.parseYangStreams(Collections.singletonList(getInputStream()));
}
private static InputStream getInputStream() {
return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
}
-
- private static SchemaContext parseYangStreams(final List<InputStream> streams)
- throws SourceException, ReactorException {
-
- final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
- .newBuild();
- return reactor.buildEffective(streams);
- }
}
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-impl</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-parser-impl</artifactId>
- </dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>mockito-configuration</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- <scope>test</scope>
+ <artifactId>yang-test-util</artifactId>
</dependency>
</dependencies>
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
-import java.util.List;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class TestModel {
private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
public static SchemaContext createTestContext() throws IOException, YangSyntaxErrorException, ReactorException {
- return parseYangStreams(Collections.singletonList(getInputStream()));
+ return YangParserTestUtils.parseYangStreams(Collections.singletonList(getInputStream()));
}
private static InputStream getInputStream() {
return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
}
-
- private static SchemaContext parseYangStreams(List<InputStream> streams)
- throws SourceException, ReactorException {
-
- CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
- .newBuild();
- return reactor.buildEffective(streams);
- }
}