Removed use of deprecated methods from parser in binding-generator-impl tests.
Change-Id: I08ba5d2c2abc55b818e389502512f35774a90db3
Signed-off-by: Martin Vitez <mvitez@cisco.com>
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class AugmentRelativeXPathTest {
}
@Test
- public void AugmentationWithRelativeXPathTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(augmentModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void AugmentationWithRelativeXPathTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(augmentModels);
assertNotNull("context is null", context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class AugmentedTypeTest {
}
@Test
- public void augmentedAbstractTopologyTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(augmentModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void augmentedAbstractTopologyTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(augmentModels);
assertNotNull("context is null", context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
final List<MethodSignature> networkLink2Methods = gtNetworkLink2.getMethodDefinitions();
assertNotNull("networkLink2Methods is null", networkLink2Methods);
-// FIXME: in some cases getIfcMethod is null which causes test fail. fix ASAP
-// MethodSignature getIfcMethod = null;
-// for (MethodSignature method : networkLink2Methods) {
-// if (method.getName().equals("getInterface")) {
-// getIfcMethod = method;
-// break;
-// }
-// }
-//
-// assertNotNull("getIfcMethod is null", getIfcMethod);
-// assertNotNull("getIfcMethod.getReturnType() is null", getIfcMethod.getReturnType());
-// assertFalse("getIfcMethod.getReturnType() should not be Void", getIfcMethod.getReturnType().equals("java.lang.Void"));
-// assertTrue("getIfcMethod.getReturnType().getName() must be String", getIfcMethod.getReturnType().getName().equals("String"));
+ MethodSignature getIfcMethod = null;
+ for (MethodSignature method : networkLink2Methods) {
+ if (method.getName().equals("getInterface")) {
+ getIfcMethod = method;
+ break;
+ }
+ }
+
+ assertNotNull("getIfcMethod is null", getIfcMethod);
+ assertNotNull("getIfcMethod.getReturnType() is null", getIfcMethod.getReturnType());
+ assertFalse("getIfcMethod.getReturnType() should not be Void",
+ getIfcMethod.getReturnType().equals("java.lang.Void"));
+ assertTrue("getIfcMethod.getReturnType().getName() must be String", getIfcMethod.getReturnType().getName()
+ .equals("String"));
}
@Test
import static org.junit.Assert.assertNotNull;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class BinaryTypeTest {
}
@Test
- public void binaryTypeTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(yangModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void binaryTypeTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(yangModels);
assertNotNull("context is null", context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestUtil.containsMethods;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
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.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class BitAndUnionTOEnclosingTest {
private static List<Type> genTypes = null;
private static GeneratedType parentContainer = null;
- public static void parseResources() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public static void parseResources() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@BeforeClass
- public static void loadTestResources() throws URISyntaxException {
+ public static void loadTestResources() throws IOException, URISyntaxException {
final File listModelFile = new File(ExtendedTypedefTest.class.getResource("/bit_and_union.yang").toURI());
testModels.add(listModelFile);
parseResources();
import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestUtil.containsMethods;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
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.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class ChoiceCaseGenTypesTest {
}
@Test
- public void choiceCaseResolvingTypeTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(yangModels);
-
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void choiceCaseResolvingTypeTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(yangModels);
assertNotNull("context is null", context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
genType = checkGeneratedType(genTypes, "LeafAugCase", pcgPref
+ ".netconf.state.datastores.datastore.locks.lock.type"); // choice
- // FIXME
containsMethods(genType, new NameTypePattern("getLeafAugCase", "String"));
containsInterface("LockType", genType);
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class ControllerTest {
}
@Test
- public void controllerAugmentationTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(controllerModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void controllerAugmentationTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(controllerModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.sal.binding.yang.types.BaseYangTypes;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class ExtendedTypedefTest {
}
@Test
- public void constantGenerationTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void constantGenerationTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
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.MethodSignature;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class GenEnumResolvingTest {
- private SchemaContext resolveSchemaContextFromFiles(
- final URI... yangFiles) {
- final YangModelParser parser = new YangParserImpl();
+ private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) throws IOException {
+ final YangContextParser parser = new YangParserImpl();
final List<File> inputFiles = new ArrayList<File>();
for (int i = 0; i < yangFiles.length; ++i) {
inputFiles.add(new File(yangFiles[i]));
}
- final Set<Module> modules = parser.parseYangModels(inputFiles);
- return parser.resolveSchemaContext(modules);
+ return parser.parseFiles(inputFiles);
}
@Test
- public void testLeafEnumResolving() throws URISyntaxException {
- final URI ietfInterfacesPath = getClass().getResource(
- "/enum-test-models/ietf-interfaces@2012-11-15.yang").toURI();
- final URI ifTypePath = getClass().getResource(
- "/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
- final URI yangTypesPath = getClass().getResource(
- "/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
-
- final SchemaContext context = resolveSchemaContextFromFiles(
- ietfInterfacesPath, ifTypePath, yangTypesPath);
+ public void testLeafEnumResolving() throws URISyntaxException, IOException {
+ final URI ietfInterfacesPath = getClass().getResource("/enum-test-models/ietf-interfaces@2012-11-15.yang")
+ .toURI();
+ final URI ifTypePath = getClass().getResource("/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
+ final URI yangTypesPath = getClass().getResource("/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
+
+ final SchemaContext context = resolveSchemaContextFromFiles(ietfInterfacesPath, ifTypePath, yangTypesPath);
assertTrue(context != null);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
}
}
- assertNotNull("Generated Type Interface is not present in list of " +
- "Generated Types", genInterface);
+ assertNotNull("Generated Type Interface is not present in list of Generated Types", genInterface);
Enumeration linkUpDownTrapEnable = null;
Enumeration operStatus = null;
final List<Enumeration> enums = genInterface.getEnumerations();
- assertNotNull("Generated Type Interface cannot contain NULL reference" +
- " to Enumeration types!", enums);
- assertEquals("Generated Type Interface MUST contain 2 Enumeration " +
- "Types", 2, enums.size());
+ assertNotNull("Generated Type Interface cannot contain NULL reference to Enumeration types!", enums);
+ assertEquals("Generated Type Interface MUST contain 2 Enumeration Types", 2, enums.size());
for (final Enumeration e : enums) {
if (e.getName().equals("LinkUpDownTrapEnable")) {
linkUpDownTrapEnable = e;
}
}
- assertNotNull("Expected Enum LinkUpDownTrapEnable, but was NULL!",
- linkUpDownTrapEnable);
+ assertNotNull("Expected Enum LinkUpDownTrapEnable, but was NULL!", linkUpDownTrapEnable);
assertNotNull("Expected Enum OperStatus, but was NULL!", operStatus);
- assertNotNull("Enum LinkUpDownTrapEnable MUST contain Values definition " +
- "not NULL reference!", linkUpDownTrapEnable.getValues());
- assertNotNull("Enum OperStatus MUST contain Values definition not " +
- "NULL reference!", operStatus.getValues());
- assertEquals("Enum LinkUpDownTrapEnable MUST contain 2 values!", 2,
- linkUpDownTrapEnable.getValues().size());
- assertEquals("Enum OperStatus MUST contain 7 values!", 7,
- operStatus.getValues().size());
+ assertNotNull("Enum LinkUpDownTrapEnable MUST contain Values definition not NULL reference!",
+ linkUpDownTrapEnable.getValues());
+ assertNotNull("Enum OperStatus MUST contain Values definition not NULL reference!", operStatus.getValues());
+ assertEquals("Enum LinkUpDownTrapEnable MUST contain 2 values!", 2, linkUpDownTrapEnable.getValues().size());
+ assertEquals("Enum OperStatus MUST contain 7 values!", 7, operStatus.getValues().size());
- final List<MethodSignature> methods = genInterface
- .getMethodDefinitions();
+ final List<MethodSignature> methods = genInterface.getMethodDefinitions();
- assertNotNull("Generated Interface cannot contain NULL reference for " +
- "Method Signature Definitions!", methods);
+ assertNotNull("Generated Interface cannot contain NULL reference for Method Signature Definitions!", methods);
- assertEquals("Expected count of method signature definitions is 15",
- 15, methods.size());
+ assertEquals("Expected count of method signature definitions is 15", 15, methods.size());
Enumeration ianaIfType = null;
for (final MethodSignature method : methods) {
if (method.getName().equals("getType")) {
if (method.getReturnType() instanceof Enumeration) {
- ianaIfType = (Enumeration)method.getReturnType();
+ ianaIfType = (Enumeration) method.getReturnType();
}
}
}
- assertNotNull("Method getType MUST return Enumeration Type, " +
- "not NULL reference!", ianaIfType);
- assertEquals("Enumeration getType MUST contain 272 values!", 272,
- ianaIfType.getValues().size());
+ assertNotNull("Method getType MUST return Enumeration Type not NULL reference!", ianaIfType);
+ assertEquals("Enumeration getType MUST contain 272 values!", 272, ianaIfType.getValues().size());
}
@Test
- public void testTypedefEnumResolving() throws URISyntaxException {
- final URI ianaIfTypePath = getClass().getResource(
- "/leafref-test-models/iana-if-type@2012-06-05.yang").toURI();
+ public void testTypedefEnumResolving() throws URISyntaxException, IOException {
+ final URI ianaIfTypePath = getClass().getResource("/leafref-test-models/iana-if-type@2012-06-05.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(ianaIfTypePath);
assertTrue(context != null);
assertTrue(type instanceof Enumeration);
final Enumeration enumer = (Enumeration) type;
- assertEquals("Enumeration type MUST contain 272 values!", 272,
- enumer.getValues().size());
+ assertEquals("Enumeration type MUST contain 272 values!", 272, enumer.getValues().size());
}
@Test
- public void testLeafrefEnumResolving() throws URISyntaxException {
- final URI ietfInterfacesPath = getClass().getResource(
- "/enum-test-models/ietf-interfaces@2012-11-15.yang").toURI();
- final URI ifTypePath = getClass().getResource(
- "/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
- final URI yangTypesPath = getClass().getResource(
- "/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
- final URI topologyPath = getClass().getResource(
- "/enum-test-models/abstract-topology@2013-02-08.yang")
+ public void testLeafrefEnumResolving() throws URISyntaxException, IOException {
+ final URI ietfInterfacesPath = getClass().getResource("/enum-test-models/ietf-interfaces@2012-11-15.yang")
.toURI();
- final URI inetTypesPath = getClass().getResource(
- "/enum-test-models/ietf-inet-types@2010-09-24.yang")
- .toURI();
- final SchemaContext context = resolveSchemaContextFromFiles(
- ietfInterfacesPath, ifTypePath, yangTypesPath, topologyPath,
- inetTypesPath);
+ final URI ifTypePath = getClass().getResource("/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
+ final URI yangTypesPath = getClass().getResource("/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
+ final URI topologyPath = getClass().getResource("/enum-test-models/abstract-topology@2013-02-08.yang").toURI();
+ final URI inetTypesPath = getClass().getResource("/enum-test-models/ietf-inet-types@2010-09-24.yang").toURI();
+ final SchemaContext context = resolveSchemaContextFromFiles(ietfInterfacesPath, ifTypePath, yangTypesPath,
+ topologyPath, inetTypesPath);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
GeneratedType genInterface = null;
for (final Type type : genTypes) {
if (type instanceof GeneratedType) {
- if (type.getPackageName().equals("org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208.topology.interfaces")
+ if (type.getPackageName().equals(
+ "org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208.topology.interfaces")
&& type.getName().equals("Interface")) {
genInterface = (GeneratedType) type;
}
}
}
- assertNotNull("Generated Type Interface is not present in list of " +
- "Generated Types", genInterface);
+ assertNotNull("Generated Type Interface is not present in list of Generated Types", genInterface);
Type linkUpDownTrapEnable = null;
Type operStatus = null;
final List<MethodSignature> methods = genInterface.getMethodDefinitions();
- assertNotNull("Generated Type Interface cannot contain NULL reference" +
- " to Enumeration types!", methods);
- assertEquals("Generated Type Interface MUST contain 5 Methods ",
- 5, methods.size());
+ assertNotNull("Generated Type Interface cannot contain NULL reference to Enumeration types!", methods);
+ assertEquals("Generated Type Interface MUST contain 5 Methods ", 5, methods.size());
for (final MethodSignature method : methods) {
if (method.getName().equals("getLinkUpDownTrapEnable")) {
linkUpDownTrapEnable = method.getReturnType();
}
}
- assertNotNull("Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!",
- linkUpDownTrapEnable);
+ assertNotNull("Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!", linkUpDownTrapEnable);
assertTrue("Expected LinkUpDownTrapEnable of type Enumeration", linkUpDownTrapEnable instanceof Enumeration);
assertEquals(linkUpDownTrapEnable.getPackageName(),
"org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface");
- assertNotNull("Expected Referenced Enum OperStatus, but was NULL!",
- operStatus);
+ assertNotNull("Expected Referenced Enum OperStatus, but was NULL!", operStatus);
assertTrue("Expected OperStatus of type Enumeration", operStatus instanceof Enumeration);
assertEquals(operStatus.getPackageName(),
"org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface");
}
+
}
import static org.junit.Assert.assertNotNull;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class GenTypesSubSetTest {
}
@Test
- public void genTypesFromSubsetOfTwoModulesTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(yangModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void genTypesFromSubsetOfTwoModulesTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(yangModels);
+ Set<Module> modules = context.getModules();
final Set<Module> toGenModules = new HashSet<>();
for (final Module module : modules) {
}
@Test
- public void genTypesFromSubsetOfThreeModulesTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(yangModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void genTypesFromSubsetOfThreeModulesTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(yangModels);
+ final Set<Module> modules = context.getModules();
final Set<Module> toGenModules = new HashSet<>();
for (final Module module : modules) {
import static org.junit.Assert.assertTrue;
import java.net.URI;
-import java.net.URISyntaxException;
import java.util.List;
-
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
@Test
- public void testGeneretedTypesBitsTest() throws URISyntaxException {
+ public void testGeneretedTypesBitsTest() throws Exception {
final URI yangTypesPath = getClass().getResource("/simple-bits-demo.yang").toURI();
final SchemaContext context = SupportTestUtil.resolveSchemaContextFromFiles(yangTypesPath);
int hashPropertiesNum = 0;
String nameReturnParamType = "";
- String nameMethodeParamType = "";
boolean getByteLeafMethodFound = false;
boolean setByteLeafMethodFound = false;
int setByteLeafMethodParamNum = 0;
List<Parameter> parameters = methodSignature.getParameters();
setByteLeafMethodParamNum = parameters.size();
- for (Parameter parameter : parameters) {
- nameMethodeParamType = parameter.getType().getName();
- }
-
}
}
*/
package org.opendaylight.yangtools.sal.binding.generator.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class GeneratedTypesLeafrefTest {
- private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {
- final YangModelParser parser = new YangParserImpl();
+ private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) throws IOException {
+ final YangContextParser parser = new YangParserImpl();
final List<File> inputFiles = new ArrayList<File>();
for (int i = 0; i < yangFiles.length; ++i) {
inputFiles.add(new File(yangFiles[i]));
}
- final Set<Module> modules = parser.parseYangModels(inputFiles);
- return parser.resolveSchemaContext(modules);
+ return parser.parseFiles(inputFiles);
}
@Test
- public void testLeafrefResolving() throws URISyntaxException {
+ public void testLeafrefResolving() throws URISyntaxException, IOException {
final URI topologyPath = getClass().getResource("/leafref-test-models/abstract-topology@2013-02-08.yang")
.toURI();
final URI interfacesPath = getClass().getResource("/leafref-test-models/ietf-interfaces@2012-11-15.yang")
}
@Test
- public void testLeafrefInvalidPathResolving() throws URISyntaxException {
+ public void testLeafrefInvalidPathResolving() throws URISyntaxException, IOException {
final URI resource = getClass().getResource("/leafref-test-invalid-model/foo.yang").toURI();
assertNotNull(resource);
*/
package org.opendaylight.yangtools.sal.binding.generator.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
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.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class GeneratedTypesStringTest {
}
@Test
- public void constantGenerationTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void constantGenerationTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
*/
package org.opendaylight.yangtools.sal.binding.generator.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class GeneratedTypesTest {
- private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {
- final YangModelParser parser = new YangParserImpl();
+ private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) throws IOException {
+ final YangContextParser parser = new YangParserImpl();
final List<File> inputFiles = new ArrayList<File>();
for (int i = 0; i < yangFiles.length; ++i) {
inputFiles.add(new File(yangFiles[i]));
}
- final Set<Module> modules = parser.parseYangModels(inputFiles);
- return parser.resolveSchemaContext(modules);
+ return parser.parseFiles(inputFiles);
}
@Test
- public void testMultipleModulesResolving() throws URISyntaxException {
+ public void testMultipleModulesResolving() throws URISyntaxException, IOException {
final URI topologyPath = getClass().getResource("/abstract-topology.yang").toURI();
final URI typesPath = getClass().getResource("/ietf-inet-types@2010-09-24.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, typesPath);
}
@Test
- public void testContainerResolving() throws URISyntaxException {
+ public void testContainerResolving() throws URISyntaxException, IOException {
final URI filePath = getClass().getResource("/simple-container-demo.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(filePath);
assert (context != null);
}
@Test
- public void testLeafListResolving() throws URISyntaxException {
+ public void testLeafListResolving() throws URISyntaxException, IOException {
final URI filePath = getClass().getResource("/simple-leaf-list-demo.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(filePath);
assertNotNull(context);
}
@Test
- public void testListResolving() throws URISyntaxException {
+ public void testListResolving() throws URISyntaxException, IOException {
final URI filePath = getClass().getResource("/simple-list-demo.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(filePath);
assertNotNull(context);
}
@Test
- public void testListCompositeKeyResolving() throws URISyntaxException {
+ public void testListCompositeKeyResolving() throws URISyntaxException, IOException {
final URI filePath = getClass().getResource("/list-composite-key.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(filePath);
}
@Test
- public void testGeneratedTypes() throws URISyntaxException {
+ public void testGeneratedTypes() throws URISyntaxException, IOException {
final URI filePath = getClass().getResource("/demo-topology.yang").toURI();
final SchemaContext context = resolveSchemaContextFromFiles(filePath);
assertNotNull(context);
import static org.junit.Assert.assertNotNull;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class IdentityrefTypeTest {
* provideTypeForIdentityref}
*/
@Test
- public void testIdentityrefYangBuiltInType() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void testIdentityrefYangBuiltInType() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
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.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class SupportTestUtil {
- public static SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {
- final YangModelParser parser = new YangParserImpl();
+ public static SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) throws IOException {
+ final YangContextParser parser = new YangParserImpl();
final List<File> inputFiles = new ArrayList<File>();
for (int i = 0; i < yangFiles.length; ++i) {
inputFiles.add(new File(yangFiles[i]));
}
- final Set<Module> modules = parser.parseYangModels(inputFiles);
- return parser.resolveSchemaContext(modules);
+ return parser.parseFiles(inputFiles);
}
public static void containsMethods(final GeneratedType genType, final NameTypePattern... searchedSignsWhat) {
import static org.junit.Assert.assertNotNull;
import java.net.URI;
-import java.net.URISyntaxException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Set;
-
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
private Module m;
@BeforeClass
- public static void setup() throws ParseException, URISyntaxException {
+ public static void setup() throws Exception {
final URI path1 = TypeProviderIntegrationTest.class.getResource("/type-provider/test.yang").toURI();
final URI path2 = TypeProviderIntegrationTest.class.getResource(
"/type-provider/ietf-inet-types@2010-09-24.yang").toURI();
import static org.junit.Assert.assertNotNull;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class UnionTypeDefTest {
}
@Test
- public void unionTypeResolvingTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(yangModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ public void unionTypeResolvingTest() throws IOException {
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(yangModels);
assertNotNull("context is null", context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestUtil.containsMethods;
import java.io.File;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
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.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class UsesTest {
}
@Test
- public void usesInGroupingDependenciesTest() {
+ public void usesInGroupingDependenciesTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-dependencies.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInCaseTest() {
+ public void usesInCaseTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-case.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInContainerTest() {
+ public void usesInContainerTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-container.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInGroupingTest() {
+ public void usesInGroupingTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-grouping.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInListTest() {
+ public void usesInListTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-list.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInModulTest() {
+ public void usesInModulTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-modul.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInRpcTest() {
+ public void usesInRpcTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-rpc.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInAugmentTest() {
+ public void usesInAugmentTest() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-augment.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();
}
@Test
- public void usesInNotification() {
+ public void usesInNotification() throws IOException {
List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-notification.yang");
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(testModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
+ final YangContextParser parser = new YangParserImpl();
+ final SchemaContext context = parser.parseFiles(testModels);
assertNotNull(context);
final BindingGenerator bindingGen = new BindingGeneratorImpl();