Added dependency on 'yangtools' project. Removed 'yang' dependency. Updated imports.
Change-Id: I7dcc1f7f1ac36a21316b8cdd4ed7a4ad8d4baedc
Signed-off-by: Martin Vitez <mvitez@cisco.com>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
- <modelVersion>4.0.0</modelVersion>\r
- <parent>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>binding-generator</artifactId>\r
- <version>0.5.4-SNAPSHOT</version>\r
- </parent>\r
- <artifactId>binding-generator-api</artifactId>\r
- <dependencies>\r
- <dependency>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>binding-model-api</artifactId>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>yang-model-api</artifactId>\r
- </dependency>\r
- </dependencies>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>binding-generator</artifactId>\r
+ <version>0.5.5-SNAPSHOT</version>\r
+ </parent>\r
+\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <artifactId>binding-generator-api</artifactId>\r
+\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>binding-model-api</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.yangtools</groupId>\r
+ <artifactId>yang-model-api</artifactId>\r
+ </dependency>\r
+ </dependencies>\r
+\r
</project>\r
*/\r
package org.opendaylight.controller.sal.binding.generator.api;\r
\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-import org.opendaylight.controller.yang.model.api.Module;\r
-import org.opendaylight.controller.yang.model.api.SchemaContext;\r
-\r
import java.util.List;\r
import java.util.Set;\r
\r
+import org.opendaylight.controller.sal.binding.model.api.Type;\r
+import org.opendaylight.yangtools.yang.model.api.Module;\r
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
+\r
/**\r
*\r
*\r
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
- <modelVersion>4.0.0</modelVersion>\r
- <parent>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>binding-generator</artifactId>\r
- <version>0.5.4-SNAPSHOT</version>\r
- </parent>\r
- <artifactId>binding-generator-impl</artifactId>\r
- <dependencies>\r
- <dependency>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>binding-generator-util</artifactId>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>yang-model-parser-impl</artifactId>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>binding-generator-api</artifactId>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>binding-generator-spi</artifactId>\r
- </dependency>\r
- <dependency>\r
- <groupId>junit</groupId>\r
- <artifactId>junit</artifactId>\r
- </dependency>\r
- <dependency>\r
- <groupId>commons-lang</groupId>\r
- <artifactId>commons-lang</artifactId>\r
- <version>2.1</version>\r
- </dependency>\r
- </dependencies>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>binding-generator</artifactId>\r
+ <version>0.5.5-SNAPSHOT</version>\r
+ </parent>\r
+\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <artifactId>binding-generator-impl</artifactId>\r
+\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>binding-generator-util</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.yangtools</groupId>\r
+ <artifactId>yang-parser-impl</artifactId>\r
+ <version>${yangtools.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>binding-generator-api</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>binding-generator-spi</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>junit</groupId>\r
+ <artifactId>junit</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>commons-lang</groupId>\r
+ <artifactId>commons-lang</artifactId>\r
+ <version>2.1</version>\r
+ </dependency>\r
+ </dependencies>\r
+\r
</project>\r
*/
package org.opendaylight.controller.sal.binding.generator.impl;
-import static org.opendaylight.controller.binding.generator.util.BindingGeneratorUtil.moduleNamespaceToPackageName;
-import static org.opendaylight.controller.binding.generator.util.BindingGeneratorUtil.packageNameForGeneratedType;
-import static org.opendaylight.controller.binding.generator.util.BindingGeneratorUtil.parseToClassName;
-import static org.opendaylight.controller.binding.generator.util.BindingGeneratorUtil.parseToValidParamName;
-import static org.opendaylight.controller.binding.generator.util.BindingGeneratorUtil.schemaNodeToTransferObjectBuilder;
-import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.findDataSchemaNode;
-import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.findParentModule;
+import static org.opendaylight.controller.binding.generator.util.BindingGeneratorUtil.*;
+import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.Future;
+import javax.management.Notification;
+
import org.opendaylight.controller.binding.generator.util.ReferencedTypeImpl;
import org.opendaylight.controller.binding.generator.util.Types;
import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
import org.opendaylight.controller.sal.binding.model.api.type.builder.MethodSignatureBuilder;
import org.opendaylight.controller.sal.binding.yang.types.GroupingDefinitionDependencySort;
import org.opendaylight.controller.sal.binding.yang.types.TypeProviderImpl;
-import org.opendaylight.controller.yang.binding.Notification;
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.common.RpcResult;
-import org.opendaylight.controller.yang.model.api.AugmentationSchema;
-import org.opendaylight.controller.yang.model.api.ChoiceCaseNode;
-import org.opendaylight.controller.yang.model.api.ChoiceNode;
-import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.controller.yang.model.api.DataNodeContainer;
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;
-import org.opendaylight.controller.yang.model.api.IdentitySchemaNode;
-import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;
-import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
-import org.opendaylight.controller.yang.model.api.ListSchemaNode;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.NotificationDefinition;
-import org.opendaylight.controller.yang.model.api.RpcDefinition;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.api.SchemaNode;
-import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.TypeDefinition;
-import org.opendaylight.controller.yang.model.api.UsesNode;
-import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
-import org.opendaylight.controller.yang.model.util.DataNodeIterator;
-import org.opendaylight.controller.yang.model.util.ExtendedType;
-import org.opendaylight.controller.yang.model.util.SchemaContextUtil;
-import org.opendaylight.controller.yang.model.util.UnionType;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+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.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UsesNode;
+import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
+import org.opendaylight.yangtools.yang.model.util.DataNodeIterator;
+import org.opendaylight.yangtools.yang.model.util.ExtendedType;
+import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
+import org.opendaylight.yangtools.yang.model.util.UnionType;
public final class BindingGeneratorImpl implements BindingGenerator {
/**
* Method instantiates new Generated Type Builder and sets the implements
* definitions of Data Object and Augmentable.
- *
+ *
* @param packageName
* Generated Type Package Name
* @param schemaNode
}
/**
- *
+ *
* @param packageName
* @param schemaNode
* @return
* Adds the implemented types to type builder. The method passes through the
* list of elements which contains {@code dataNodeContainer} and adds them
* as <i>implements type</i> to <code>builder</code>
- *
+ *
* @param dataNodeContainer
* element which contains the list of used YANG groupings
* @param builder
import org.opendaylight.controller.binding.generator.util.Types;
import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider;
import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
public final class BaseYangTypes {
import java.util.Map;
import java.util.Set;
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;
-import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.UsesNode;
-import org.opendaylight.controller.yang.parser.util.TopologicalSort;
-import org.opendaylight.controller.yang.parser.util.TopologicalSort.Node;
-import org.opendaylight.controller.yang.parser.util.TopologicalSort.NodeImpl;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UsesNode;
+import org.opendaylight.yangtools.yang.parser.util.TopologicalSort;
+import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.Node;
+import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.NodeImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
package org.opendaylight.controller.sal.binding.yang.types;
+import static org.opendaylight.controller.binding.generator.util.BindingGeneratorUtil.*;
+import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
import org.apache.commons.lang.StringEscapeUtils;
import org.opendaylight.controller.binding.generator.util.ReferencedTypeImpl;
import org.opendaylight.controller.binding.generator.util.TypeConstants;
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder;
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.model.api.*;
-import org.opendaylight.controller.yang.model.api.type.*;
-import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition.Bit;
-import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
-import org.opendaylight.controller.yang.model.util.ExtendedType;
-
-import org.opendaylight.controller.yang.model.util.StringType;
-import org.opendaylight.controller.yang.model.util.UnionType;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import static org.opendaylight.controller.binding.generator.util.BindingGeneratorUtil.*;
-import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.*;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
+import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
+import org.opendaylight.yangtools.yang.model.util.ExtendedType;
+import org.opendaylight.yangtools.yang.model.util.StringType;
+import org.opendaylight.yangtools.yang.model.util.UnionType;
public final class TypeProviderImpl implements TypeProvider {
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.type.provider.TypeProvider#
* javaTypeForYangType(java.lang.String)
*/
* equal depth. In next step are lists from this map concatenated to one
* list in ascending order according to their depth. All type definitions
* are in the list behind all type definitions on which depends.
- *
+ *
* @param unsortedTypeDefinitions
* represents list of type definitions
* @return list of type definitions sorted according their each other
/**
* The method return how many immersion is necessary to get from type
* definition to base type.
- *
+ *
* @param typeDefinition
* is type definition for which is depth looked for.
* @return how many immersion is necessary to get from type definition to
*/
package org.opendaylight.controller.sal.binding.yang.types;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
+import org.opendaylight.yangtools.yang.model.util.ExtendedType;
+import org.opendaylight.yangtools.yang.parser.util.TopologicalSort;
+import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.Node;
+import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.NodeImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import org.opendaylight.controller.yang.model.api.TypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.UnionTypeDefinition;
-import org.opendaylight.controller.yang.model.util.ExtendedType;
-import org.opendaylight.controller.yang.parser.util.TopologicalSort;
-import org.opendaylight.controller.yang.parser.util.TopologicalSort.Node;
-import org.opendaylight.controller.yang.parser.util.TopologicalSort.NodeImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
public class UnionDependencySort {
private static final Logger logger = LoggerFactory
*/
package org.opendaylight.controller.sal.binding.generator.impl;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+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.parser.impl.YangParserImpl;
public class AugmentRleativeXPathTest {
assertNotNull("genTypes is null", genTypes);
assertFalse("genTypes is empty", genTypes.isEmpty());
-
+
GeneratedTransferObject gtInterfaceKey = null;
GeneratedType gtInterface = null;
GeneratedType gtTunnel = null;
assertTrue("gtTunnelId.getReturnType().getName() must be Uri",
gtTunnelId.getReturnType().getName().equals("Uri"));
}
-
+
}
*/
package org.opendaylight.controller.sal.binding.generator.impl;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.controller.sal.binding.model.api.*;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+import static org.junit.Assert.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import static org.junit.Assert.*;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
+import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
+import org.opendaylight.controller.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.parser.impl.YangParserImpl;
public class AugmentedTypeTest {
*/
package org.opendaylight.controller.sal.binding.generator.impl;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+import static org.junit.Assert.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.controller.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.parser.impl.YangParserImpl;
public class BinaryTypeTest {
private final static List<File> yangModels = new ArrayList<>();
*/
package org.opendaylight.controller.sal.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
import java.io.File;
import java.util.ArrayList;
import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+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.parser.impl.YangParserImpl;
public class BitAndUnionTOEnclosingTest {
*/
package org.opendaylight.controller.sal.binding.generator.impl;
+import static org.junit.Assert.*;
+
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+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.parser.impl.YangParserImpl;
public class ChoiceCaseGenTypesTest {
package org.opendaylight.controller.sal.binding.generator.impl;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+import static org.junit.Assert.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.controller.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.parser.impl.YangParserImpl;
public class ControllerTest {
package org.opendaylight.controller.sal.binding.generator.impl;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.*;
import java.io.File;
import java.util.ArrayList;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.controller.sal.binding.generator.impl.BindingGeneratorImpl;
-import org.opendaylight.controller.sal.binding.model.api.Constant;
import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;
import org.opendaylight.controller.sal.binding.model.api.Type;
import org.opendaylight.controller.sal.binding.yang.types.BaseYangTypes;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+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.parser.impl.YangParserImpl;
public class ExtendedTypedefTest {
testModels.add(listModelFile);
}
- @Test
+ @Test
public void constantGenerationTest() {
final YangModelParser parser = new YangParserImpl();
final Set<Module> modules = parser.parseYangModels(testModels);
import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+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.parser.impl.YangParserImpl;
public class GenEnumResolvingTest {
*/
package org.opendaylight.controller.sal.binding.generator.impl;
+import static org.junit.Assert.*;
+
+import java.io.File;
+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.controller.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
-
-import java.io.File;
-import java.util.*;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+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.parser.impl.YangParserImpl;
public class GenTypesSubSetTest {
import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
import org.opendaylight.controller.sal.binding.model.api.MethodSignature.Parameter;
import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+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.parser.impl.YangParserImpl;
public class GeneratedTypesBitsTest {
package org.opendaylight.controller.sal.binding.generator.impl;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.io.File;
import java.util.ArrayList;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.controller.sal.binding.generator.impl.BindingGeneratorImpl;
import org.opendaylight.controller.sal.binding.model.api.Constant;
import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;
import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+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.parser.impl.YangParserImpl;
public class GeneratedTypesStringTest {
package org.opendaylight.controller.sal.binding.generator.impl;
import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+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.parser.impl.YangParserImpl;
public class GeneratedTypesTest {
*/
package org.opendaylight.controller.sal.binding.generator.impl;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+import static org.junit.Assert.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.controller.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.parser.impl.YangParserImpl;
public class UnionTypeDefTest {
private final static List<File> yangModels = new ArrayList<>();
*/
package org.opendaylight.controller.sal.binding.generator.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.io.File;
import java.util.ArrayList;
import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;
import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+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.parser.impl.YangParserImpl;
public class UsesTest {
module bit-and-union-in-leaf {
-
+
namespace "urn:bit:union:in:leaf";
prefix "sbd";
contact "http://www.opendaylight.org/";
revision 2013-06-26 {
-
+
}
-
+
typedef union-typedef {
type union {
type string {
pattern "[a-g]";
- };
+ }
type int16;
}
}
-
+
typedef union-typedef2 {
type union {
type string;
type int16;
}
}
-
+
container parent-container {
leaf bit-leaf {
type bits {
bit third-bit;
}
}
-
+
leaf union-leaf {
type union {
type int32;
type string {
pattern "[a-z]";
- };
+ }
type string {
- pattern "[0-9]*"
- };
+ pattern "[0-9]*";
+ }
type string {
pattern "[a-d]*";
pattern "[0-5]*";
- };
+ }
type uint8;
}
}
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
- <modelVersion>4.0.0</modelVersion>\r
- <parent>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>binding-generator</artifactId>\r
- <version>0.5.4-SNAPSHOT</version>\r
- </parent>\r
- <artifactId>binding-generator-spi</artifactId>\r
- <dependencies>\r
- <dependency>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>binding-model-api</artifactId>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>yang-model-api</artifactId>\r
- </dependency>\r
- </dependencies>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>binding-generator</artifactId>\r
+ <version>0.5.5-SNAPSHOT</version>\r
+ </parent>\r
+\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <artifactId>binding-generator-spi</artifactId>\r
+\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>binding-model-api</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.yangtools</groupId>\r
+ <artifactId>yang-model-api</artifactId>\r
+ </dependency>\r
+ </dependencies>\r
+\r
</project>\r
package org.opendaylight.controller.sal.binding.generator.spi;\r
\r
import org.opendaylight.controller.sal.binding.model.api.Type;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;\r
\r
public interface TypeProvider {\r
\r
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
- <modelVersion>4.0.0</modelVersion>\r
- <parent>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>binding-generator</artifactId>\r
- <version>0.5.4-SNAPSHOT</version>\r
- </parent>\r
- <artifactId>binding-generator-util</artifactId>\r
- <dependencies>\r
- <dependency>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>binding-model-api</artifactId>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>yang-model-api</artifactId>\r
- </dependency>\r
- <dependency>\r
- <groupId>junit</groupId>\r
- <artifactId>junit</artifactId>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.opendaylight.controller</groupId>\r
- <artifactId>yang-binding</artifactId>\r
- </dependency>\r
- </dependencies>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+\r
+ <parent>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>binding-generator</artifactId>\r
+ <version>0.5.5-SNAPSHOT</version>\r
+ </parent>\r
+\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <artifactId>binding-generator-util</artifactId>\r
+\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.opendaylight.controller</groupId>\r
+ <artifactId>binding-model-api</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.yangtools</groupId>\r
+ <artifactId>yang-model-api</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>junit</groupId>\r
+ <artifactId>junit</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.opendaylight.yangtools</groupId>\r
+ <artifactId>yang-binding</artifactId>\r
+ </dependency>\r
+ </dependencies>\r
+\r
</project>\r
package org.opendaylight.controller.binding.generator.util;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder;
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaNode;
-import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
public final class BindingGeneratorUtil {
import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;
import org.opendaylight.controller.sal.binding.model.api.Type;
import org.opendaylight.controller.sal.binding.model.api.WildcardType;
-import org.opendaylight.controller.yang.binding.Augmentable;
-import org.opendaylight.controller.yang.binding.Augmentation;
-import org.opendaylight.controller.yang.binding.BaseIdentity;
-import org.opendaylight.controller.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Augmentable;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.DataObject;
public final class Types {
private static final Type SET_TYPE = typeForClass(Set.class);
/**
* Returns an instance of {@link ConcreteType} describing the class
- *
+ *
* @param cls
* Class to describe
* @return Description of class
/**
* Returns an instance of {@link ParameterizedType} describing the typed
* {@link Map}<K,V>
- *
+ *
* @param keyType
* Key Type
* @param valueType
/**
* Returns an instance of {@link ParameterizedType} describing the typed
* {@link Set}<V> with concrete type of value.
- *
+ *
* @param valueType
* Value Type
* @return Description of generic type instance of Set
/**
* Returns an instance of {@link ParameterizedType} describing the typed
* {@link List}<V> with concrete type of value.
- *
+ *
* @param valueType
* Value Type
* @return Description of type instance of List
}
/**
- *
+ *
* @param type
* @param parameters
* @return
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
- <modelVersion>4.0.0</modelVersion>\r
+\r
<parent>\r
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>binding-generator</artifactId>\r
- <version>0.5.4-SNAPSHOT</version>\r
+ <version>0.5.5-SNAPSHOT</version>\r
</parent>\r
+\r
+ <modelVersion>4.0.0</modelVersion>\r
<artifactId>binding-java-api-generator</artifactId>\r
+\r
<build>\r
<plugins>\r
<plugin>\r
<goal>compile</goal>\r
</goals>\r
<configuration>\r
- <outputDirectory>${basedir}/src/main/xtend-gen</outputDirectory>\r
+ <outputDirectory>${basedir}/src/main/xtend-gen</outputDirectory>\r
</configuration>\r
</execution>\r
</executions>\r
</plugin>\r
<plugin>\r
- <artifactId>maven-clean-plugin</artifactId>\r
- <version>2.4.1</version>\r
- <configuration>\r
- <filesets>\r
- <fileset>\r
- <directory>${basedir}/src/main/xtend-gen</directory>\r
- <includes>\r
- <include>**</include>\r
- </includes>\r
- </fileset>\r
- </filesets>\r
- </configuration>\r
+ <artifactId>maven-clean-plugin</artifactId>\r
+ <version>2.4.1</version>\r
+ <configuration>\r
+ <filesets>\r
+ <fileset>\r
+ <directory>${basedir}/src/main/xtend-gen</directory>\r
+ <includes>\r
+ <include>**</include>\r
+ </includes>\r
+ </fileset>\r
+ </filesets>\r
+ </configuration>\r
</plugin>\r
</plugins>\r
</build>\r
+\r
<dependencies>\r
<dependency>\r
<groupId>org.opendaylight.controller</groupId>\r
<groupId>junit</groupId>\r
<artifactId>junit</artifactId>\r
</dependency>\r
- <dependency>\r
- <groupId>org.eclipse.xtend</groupId>\r
- <artifactId>org.eclipse.xtend.lib</artifactId>\r
- <version>2.4.2</version>\r
- </dependency>\r
+ <dependency>\r
+ <groupId>org.eclipse.xtend</groupId>\r
+ <artifactId>org.eclipse.xtend.lib</artifactId>\r
+ <version>2.4.2</version>\r
+ </dependency>\r
</dependencies>\r
+\r
</project>\r
import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;
import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.binding.Augmentable;
+import org.opendaylight.yangtools.yang.binding.Augmentable;
public class BuilderClassDescriptor {
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder;
import org.opendaylight.controller.sal.java.api.generator.ClassCodeGenerator;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+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.parser.impl.YangParserImpl;
public class ClassCodeGeneratorTest {
import static org.junit.Assert.assertTrue;
import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.sal.java.api.generator.ClassCodeGenerator;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+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.parser.impl.YangParserImpl;
public class GenerateInnerClassForBitsAndUnionInLeavesTest {
import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
import org.opendaylight.controller.sal.java.api.generator.GeneratorJavaFile;
import org.opendaylight.controller.sal.java.api.generator.InterfaceGenerator;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
public class GeneratorJavaFileTest {
private static final String FS = File.separator;
tosToGenerate.add((GeneratedTransferObject) type);
}
if (type instanceof Enumeration) {
- enumerationToGenerate.add((Enumeration) type);
+ enumerationToGenerate.add((Enumeration) type);
}
}
type union {
type string {
pattern "[a-g]";
- };
+ }
type int16;
}
}
type int32;
type string {
pattern "[a-z]";
- };
+ }
type string {
- pattern "[0-9]*"
- };
+ pattern "[0-9]*";
+ }
type string {
pattern "[a-d]*";
pattern "[0-5]*";
- };
+ }
type uint8;
}
}
<parent>\r
<groupId>org.opendaylight.controller</groupId>\r
<artifactId>binding-generator</artifactId>\r
- <version>0.5.4-SNAPSHOT</version>\r
+ <version>0.5.5-SNAPSHOT</version>\r
</parent>\r
\r
<modelVersion>4.0.0</modelVersion>\r
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+
<parent>
<artifactId>binding-generator</artifactId>
<groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
+ <version>0.5.5-SNAPSHOT</version>
</parent>
+
+ <modelVersion>4.0.0</modelVersion>
<artifactId>maven-sal-api-gen-plugin</artifactId>
<dependencies>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>binding-generator-api</artifactId>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>binding-generator-impl</artifactId>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>binding-java-api-generator</artifactId>
</dependency>
</dependencies>
+
</project>
import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
import org.opendaylight.controller.sal.binding.model.api.Type;
import org.opendaylight.controller.sal.java.api.generator.GeneratorJavaFile;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang2sources.spi.CodeGenerator;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang2sources.spi.CodeGenerator;
public final class CodeGeneratorImpl implements CodeGenerator {
</parent>
<modelVersion>4.0.0</modelVersion>
- <version>0.5.4-SNAPSHOT</version>
+ <version>0.5.5-SNAPSHOT</version>
<artifactId>binding-generator</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <!-- version of YANG tools dependencies -->
- <yang.version>0.5.4-SNAPSHOT</yang.version>
</properties>
<modules>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common</artifactId>
- <version>${yang.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-api</artifactId>
- <version>${yang.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-util</artifactId>
- <version>${yang.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-api</artifactId>
- <version>${yang.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-util</artifactId>
- <version>${yang.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-binding</artifactId>
- <version>${yang.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-parser-api</artifactId>
- <version>${yang.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-parser-impl
</artifactId>
- <version>${yang.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${yang.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin-spi</artifactId>
- <version>${yang.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<parent>
<artifactId>binding-generator</artifactId>
<groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
+ <version>0.5.5-SNAPSHOT</version>
</parent>
<artifactId>maven-code-gen-sample</artifactId>
<build>
<plugins>
<plugin>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
+ <version>${yangtools.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
+ <version>0.5.5-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
- org.opendaylight.controller
+ org.opendaylight.yangtools
</groupId>
<artifactId>
yang-maven-plugin
</build>
<dependencies>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-binding</artifactId>
- <version>0.5.4-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
module bit-and-union-in-leaf {
-
+
namespace "urn:bit:union:in:leaf";
prefix "sbd";
revision 2013-06-26 {
}
-
+
typedef union-typedef {
type union {
type string {
pattern "[a-g]";
- };
+ }
type int16;
}
}
-
+
typedef union-typedef2 {
type union {
type string;
type int16;
}
}
-
+
container parent-container {
leaf bit-leaf {
type bits {
bit third-bit;
}
}
-
+
leaf union-leaf {
type union {
type int32;
type string {
pattern "[a-z]";
- };
+ }
type string {
pattern "[0-9]*"
- };
+ }
type string {
pattern "[a-d]*";
pattern "[0-5]*";
- };
+ }
type uint8;
}
}
}
-}
\ No newline at end of file
+}
+++ /dev/null
-module grouping_uses {
-
- namespace "urn:uses:of:grouping";
- prefix "sbd";
-
- organization "OPEN DAYLIGHT";
- contact "http://www.opendaylight.org/";
-
- revision 2013-07-18 {
- }
-
- grouping grouping-modul-test {
- leaf leaf-grouping-modul-test {
- type string;
- }
- leaf leaf-grouping-modul-test2 {
- type uint8;
- }
- }
-
-
- grouping grouping-container-test {
- leaf leaf-grouping-container-test1 {
- type string;
- }
- leaf leaf-grouping-container-test2 {
- type uint8;
- }
- }
-
- grouping grouping-case-test {
- leaf leaf-grouping-case-test1 {
- type string;
- }
- }
-
- grouping grouping-choice-test {
- choice choice-grouing-choice-test {
- case case-choice-grouping-choice-test1 {
- leaf leaf-case-choice-grouping-choice-test1 {
- type string;
- }
- }
- case case-choice-grouping-choice-test2 {
- leaf leaf-case-choice-grouping-choice-test2 {
- type uint8;
- }
- }
- }
- }
-
- grouping grouping-list-test {
- leaf leaf-grouping-list-test {
- type string;
- }
- container container-grouping-list-test {
- leaf leaf-container-grouping-list-test {
- type uint8;
- }
- }
- list list-grouping-list-test {
- leaf leaf-list-grouping-list-test {
- type int32;
- }
- }
- leaf-list leaflist-grouping-list-test {
- type string;
- }
- }
-
- grouping grouping-grouping-test {
- leaf leaf-grouping-grouping {
- type string;
- }
- }
-
- grouping grouping-rpc-input-test {
- container container-grouping-rpc-input-test {
- leaf leaf-container-grouping-rpc-input-test {
- type string;
- }
- }
- leaf-list leaflist-grouping-rpc-input-test {
- type uint8;
- }
- }
-
- grouping grouping-rpc-output-test {
- leaf leaf-grouping-rpc-output-test {
- type int8;
- }
- }
-
- grouping grouping-notification-test {
- container container-grouping-notification-test {
- leaf leaf-container-grouping-notification-test {
- type uint32;
- }
- }
- leaf-list leaffllist-grouping-notification-test {
- type string;
- }
- }
-
-//grouping in GROUPING
- grouping grouping-atest {
- leaf leaf-grouping-test {
- type int8;
- }
- uses grouping-grouping-test;
- }
-
-//grouping in MODUL
- uses grouping-modul-test;
-
-//grouping in RPC
- rpc rpc-test {
- input {
- uses grouping-rpc-input-test;
- }
- output {
- uses grouping-rpc-output-test;
- }
- }
-
-//grouping in CONTAINER
- container container-test {
- leaf container-leaf-test {
- type string;
- }
- uses grouping-container-test;
- }
-
-//grouping in CASE
- container container-with-choicetest {
- choice choice-test {
- case a {
- leaf leaf-choice-test1 {
- type string;
- }
- }
- case c {
- uses grouping-case-test;
- }
- }
- }
-
-//grouping in LIST
- list list-test {
- leaf list-leaf-test {
- type string;
- }
- uses grouping-list-test;
- }
-
-//grouping in NOTIFICATION
- notification notification-test {
- leaf leaf-notification-test {
- type string;
- }
- uses grouping-notification-test;
- }
-
- grouping grouping-augment-test1 {
- leaf leaf-grouping-augment-test {
- type string;
- }
- }
-
- container container-augment {
- leaf leaf-container-augment1 {
- type string;
- }
- leaf leaf-container-augment2 {
- type int64;
- }
- }
-
-//grouping AUGMENT
- augment "/container-augment" {
- uses grouping-augment-test1;
- uses grouping-choice-test;
- }
-}
\ No newline at end of file
<parent>
<artifactId>binding-generator</artifactId>
<groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
+ <version>0.5.5-SNAPSHOT</version>
</parent>
<artifactId>modeling-sample</artifactId>
<build>
<plugins>
<plugin>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
+ <version>${yangtools.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
+ <version>0.5.5-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
- org.opendaylight.controller
+ org.opendaylight.yangtools
</groupId>
<artifactId>
yang-maven-plugin
</build>
<dependencies>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-binding</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common</artifactId>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
<parent>
<artifactId>model-parent</artifactId>
<groupId>org.opendaylight.controller</groupId>
<version>0.5-SNAPSHOT</version>
</parent>
+
+ <modelVersion>4.0.0</modelVersion>
<artifactId>model-topology</artifactId>
<dependencies>
<version>2010.09.24-SNAPSHOT</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+
+</project>
<build>
<plugins>
<plugin>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
+ <version>${yangtools.version}</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
+ <version>0.5.5-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
<dependencies>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-binding</artifactId>
- <version>0.5.4-SNAPSHOT</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common</artifactId>
- <version>0.5.4-SNAPSHOT</version>
+ <version>${yangtools.version}</version>
</dependency>
</dependencies>
<modules>
<module>concepts-lang</module>
- <module>yang</module>
+ <!-- <module>yang</module> -->
<module>code-generator</module>
<module>model</module>
</modules>
<properties>
+ <yangtools.version>0.5.5-SNAPSHOT</yangtools.version>
<sonar.host.url>https://sonar.opendaylight.org/</sonar.host.url>
<nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
<sitedeploy>dav:http://nexus.opendaylight.org/content/sites/site</sitedeploy>
<name>central2</name>
<url>${nexusproxy}/repositories/central2/</url>
</pluginRepository>
+ <pluginRepository>
+ <id>opendaylight.snapshot</id>
+ <name>opendaylight.snapshot</name>
+ <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
+ </pluginRepository>
</pluginRepositories>
<url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
</repository>
</repositories>
+
<distributionManagement>
<!-- OpenDayLight Released artifact -->
<repository>
</properties>
</profile>
</profiles>
+
</project>
</modules>
<properties>
- <yang.version>0.5.4-SNAPSHOT</yang.version>
+ <yang.version>0.5.5-SNAPSHOT</yang.version>
</properties>
<dependencyManagement>
<version>4.10</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-binding</artifactId>
<version>${yang.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common</artifactId>
<version>${yang.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-api</artifactId>
<version>${yang.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-api</artifactId>
<version>${yang.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-util</artifactId>
<version>${yang.version}</version>
</dependency>
+++ /dev/null
-log.txt
-/target
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>yang</artifactId>
- <groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
- </parent>
- <artifactId>yang-maven-plugin-it</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-verifier</artifactId>
- <version>1.4</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-failsafe-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2013 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.controller.yang2sources.plugin.it;
-
-import static org.junit.Assert.*;
-import static org.junit.matchers.JUnitMatchers.*;
-
-import java.io.File;
-import java.net.URL;
-
-import org.apache.maven.it.VerificationException;
-import org.apache.maven.it.Verifier;
-import org.junit.Test;
-
-public class YangToSourcesPluginTestIT {
-
- // TODO Test yang files in transitive dependencies
-
- @Test
- public void testYangRootNotExist() {
- try {
- setUp("YangRootNotExist/", false);
- } catch (VerificationException e) {
- assertVerificationException(e,
- "[ERROR] yang-to-sources: Unable to parse yang files from ");
- assertVerificationException(
- e,
- "Caused by: org.apache.maven.plugin.MojoExecutionException: yang-to-sources: Unable to parse yang files from ");
- return;
- }
-
- fail("Verification exception should have been thrown");
- }
-
- @Test
- public void testCorrect() throws VerificationException {
- Verifier v = setUp("Correct/", false);
- verifyCorrectLog(v);
- }
-
- @Test
- public void testAdditionalConfiguration() throws VerificationException {
- Verifier v = setUp("AdditionalConfig/", false);
- v.verifyTextInLog("[DEBUG] yang-to-sources: Additional configuration picked up for : org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl: {nm1=abcd=a.b.c.d, nm2=abcd2=a.b.c.d.2}");
- v.verifyTextInLog("[DEBUG] yang-to-sources: Additional configuration picked up for : org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl: {c1=config}");
- v.verifyTextInLog(File.separator
- + "files marked as resources: META-INF/yang");
- v.verifyTextInLog("target"
- + File.separator
- + "generated-resources marked as resources for generator: org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl");
- }
-
- @Test
- public void testMissingYangInDep() throws VerificationException {
- try {
- setUp("MissingYangInDep/", false);
- } catch (VerificationException e) {
- assertVerificationException(
- e,
- "org.opendaylight.controller.yang.parser.util.YangValidationException: Not existing module imported:unknownDep:2013-02-27 by:private:2013-02-27");
- return;
- }
-
- fail("Verification exception should have been thrown");
- }
-
- static void verifyCorrectLog(Verifier v) throws VerificationException {
- v.verifyErrorFreeLog();
- v.verifyTextInLog("[INFO] yang-to-sources: YANG files parsed from");
- v.verifyTextInLog("[INFO] yang-to-sources: Code generator instantiated from org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl");
- v.verifyTextInLog("[INFO] yang-to-sources: Sources generated by org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl: null");
- }
-
- @Test
- public void testNoGenerators() throws VerificationException {
- Verifier v = setUp("NoGenerators/", false);
- v.verifyErrorFreeLog();
- v.verifyTextInLog("[WARNING] yang-to-sources: No code generators provided");
- }
-
- @Test
- public void testUnknownGenerator() throws VerificationException {
- Verifier v = setUp("UnknownGenerator/", true);
- v.verifyTextInLog("[ERROR] yang-to-sources: Unable to generate sources with unknown generator");
- v.verifyTextInLog("java.lang.ClassNotFoundException: unknown");
- v.verifyTextInLog("[INFO] yang-to-sources: Code generator instantiated from org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl");
- v.verifyTextInLog("[INFO] yang-to-sources: Sources generated by org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl: null");
- v.verifyTextInLog("[ERROR] yang-to-sources: One or more code generators failed, including failed list(generatorClass=exception) {unknown=java.lang.ClassNotFoundException}");
- }
-
- @Test
- public void testNoYangFiles() throws VerificationException {
- Verifier v = setUp("NoYangFiles/", false);
- v.verifyTextInLog("[INFO] yang-to-sources: YANG files parsed from []");
- v.verifyTextInLog("[INFO] yang-to-sources: Code generator instantiated from org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl");
- v.verifyTextInLog("[INFO] yang-to-sources: Sources generated by org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl: null");
- }
-
- static void assertVerificationException(VerificationException e,
- String string) {
- assertThat(e.getMessage(), containsString(string));
- }
-
- static Verifier setUp(String project, boolean ignoreF)
- throws VerificationException {
- final URL path = YangToSourcesPluginTestIT.class.getResource("/"
- + project + "pom.xml");
- File parent = new File(path.getPath());
- Verifier verifier = new Verifier(parent.getParent());
- if (ignoreF)
- verifier.addCliOption("-fn");
- verifier.setMavenDebug(true);
- verifier.executeGoal("generate-sources");
- return verifier;
- }
-
- @Test
- public void testNoOutputDir() throws VerificationException {
- Verifier v = YangToSourcesPluginTestIT.setUp("NoOutputDir/", false);
- verifyCorrectLog(v);
- }
-
- @Test
- public void testFindResourceOnCp() throws VerificationException {
- Verifier v1 = new Verifier(new File(getClass().getResource(
- "/GenerateTest1/pom.xml").getPath()).getParent());
- v1.executeGoal("clean");
- v1.executeGoal("package");
- v1.assertFilePresent("target/classes/META-INF/yang/testfile1.yang");
- v1.assertFilePresent("target/classes/META-INF/yang/testfile2.yang");
- v1.assertFilePresent("target/classes/META-INF/yang/testfile3.yang");
-
- Verifier v2 = YangToSourcesPluginTestIT.setUp("GenerateTest2/", false);
- v2.executeGoal("clean");
- v2.executeGoal("package");
- v2.assertFilePresent("target/classes/META-INF/yang/private.yang");
- v2.assertFileNotPresent("target/classes/META-INF/yang/testfile1.yang");
- v2.assertFileNotPresent("target/classes/META-INF/yang/testfile2.yang");
- v2.assertFileNotPresent("target/classes/META-INF/yang/testfile3.yang");
- }
-}
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
- <artifactId>test</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <yangFilesRootDir>../files</yangFilesRootDir>
- <inspectDependencies>false</inspectDependencies>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
- </codeGeneratorClass>
- <additionalConfiguration>
- <nm1>abcd=a.b.c.d</nm1>
- <nm2>abcd2=a.b.c.d.2</nm2>
- </additionalConfiguration>
- <resourceBaseDir>/target/resourcesGenerated</resourceBaseDir>
- </generator>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
- </codeGeneratorClass>
- <additionalConfiguration>
- <c1>config</c1>
- </additionalConfiguration>
- </generator>
- </codeGenerators>
- </configuration>
- </execution>
- </executions>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <type>test-jar</type>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
- <artifactId>test</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <yangFilesRootDir>../files</yangFilesRootDir>
- <inspectDependencies>false</inspectDependencies>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
- </codeGeneratorClass>
- </generator>
- </codeGenerators>
- </configuration>
- </execution>
- </executions>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <type>test-jar</type>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>generator-test1</artifactId>
- <version>0.5.4-SNAPSHOT</version>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <yangFilesRootDir>${basedir}/src/main/resources</yangFilesRootDir>
- <inspectDependencies>false</inspectDependencies>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
- </codeGeneratorClass>
- </generator>
- </codeGenerators>
- </configuration>
- </execution>
- </executions>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <type>test-jar</type>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-module types1 {
- yang-version 1;
- namespace "urn:simple.container.demo";
- prefix "t1";
-
- import types2 {
- prefix "data";
- revision-date 2013-02-27;
- }
-
- import types3 {
- prefix "t3";
- revision-date 2013-02-27;
- }
-
- organization "opendaylight";
- contact "http://www.opendaylight.org/";
-
- revision "2013-02-27" {
- reference " WILL BE DEFINED LATER";
- }
-
-}
+++ /dev/null
-module types2 {
- yang-version 1;
- namespace "urn:simple.types.data.demo";
- prefix "t2";
-
- organization "opendaylight";
- contact "http://www.opendaylight.org/";
-
- description "This is types-data test description";
-
- revision "2013-02-27" {
- reference " WILL BE DEFINED LATER";
- }
-
- typedef my-base-int32-type {
- type int32 {
- range "2..20";
- }
- }
-
- typedef my-type1 {
- type my-base-int32-type {
- range "11..max";
- }
- units "mile";
- default "11";
- }
-
- typedef my-custom-string {
- type string {
- pattern "[a-k]*";
- length "5..11";
- }
- }
-
- typedef my-string-type {
- type my-custom-string {
- length "5..10";
- }
- }
-
- typedef my-string-type2 {
- type my-string-type {
- pattern "[b-u]*";
- }
- }
-
- typedef my-string-type-ext {
- type my-string-type2 {
- pattern "[e-z]*";
- }
- }
-
- typedef my-int-type {
- type int32 {
- range "10..20";
- }
- }
-
- typedef my-int-type2 {
- type my-int-type {
- range "12..18";
- }
- }
-
- typedef my-int-type-ext {
- type my-int-type2 {
- range "14..16";
- }
- }
-
- typedef my-decimal-type {
- type decimal64 {
- fraction-digits 6;
- }
- }
-
- typedef my-decimal-type-ext {
- type decimal64 {
- fraction-digits 5;
- }
- }
-
- typedef my-union {
- type union {
- type int16 {
- range "1..100";
- }
- type int32;
- }
- }
-
- typedef my-union-ext {
- type my-union;
- }
-
- typedef nested-union1 {
- type nested-union2;
- }
-
- typedef nested-union2 {
- type union {
- type my-union-ext;
- type string;
- }
- }
-
- leaf if-name {
- type leafref {
- path "/interface/name";
- }
- }
-
- leaf name {
- type string;
- }
-
- leaf nested-type-leaf {
- type my-type1;
- }
-
- extension c-define {
- description
- "Takes as argument a name string.
- Makes the code generator use the given name in the
- #define.";
- argument "name" {
- yin-element "true";
- }
- }
-
- container system {
- leaf user {
- type string;
- }
- }
-
- grouping target {
- leaf address {
- type string;
- description "Target IP address";
- }
- container port {
- description "Target port container";
- }
- }
-
- container peer {
- container destination {
- uses target {
- refine address {
- default "1.2.3.4";
- }
- refine port {
- description "new port description updated by refine";
- }
- }
- }
- }
-
- container interfaces {
- list ifEntry {
- key "ifIndex";
-
- leaf ifIndex {
- type uint32;
- units minutes;
- }
-
- leaf ifMtu {
- type int32;
- }
- }
- }
-
-}
+++ /dev/null
-module types3 {
- yang-version 1;
- namespace "urn:simple.container.demo.test";
- prefix "t3";
-
- import types2 {
- prefix "data";
- revision-date 2013-02-27;
- }
-
- organization "opendaylight";
- contact "http://www.opendaylight.org/";
-
- revision "2013-02-27" {
- reference " WILL BE DEFINED LATER";
- }
-
-}
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
- <artifactId>generator-test2</artifactId>
-
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>generator-test1</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <scope>system</scope>
- <systemPath>${project.basedir}/../GenerateTest1/target/generator-test1-0.5.4-SNAPSHOT.jar</systemPath>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <yangFilesRootDir>${project.basedir}/yang</yangFilesRootDir>
- <inspectDependencies>true</inspectDependencies>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
- </codeGeneratorClass>
- <outputBaseDir>
- outDir/
- </outputBaseDir>
- </generator>
- </codeGenerators>
- </configuration>
- </execution>
- </executions>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <type>test-jar</type>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-module private {
- yang-version 1;
- namespace "urn:simple.container.demo";
- prefix "p";
-
- import types2 {
- prefix "data";
- revision-date 2013-02-27;
- }
-
- organization "opendaylight";
- contact "http://www.opendaylight.org/";
-
- revision "2013-02-27" {
- reference " WILL BE DEFINED LATER";
- }
-
-
-}
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>binding-generator</artifactId>
- <groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
- </parent>
- <artifactId>test</artifactId>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <yangFilesRootDir>../files</yangFilesRootDir>
- <inspectDependencies>false</inspectDependencies>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
- </codeGeneratorClass>
- <outputBaseDir>
- outDir/
- </outputBaseDir>
- </generator>
- </codeGenerators>
- </configuration>
- </execution>
- </executions>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <type>test-jar</type>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
- <artifactId>generator-test2</artifactId>
-
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <yangFilesRootDir>${project.basedir}/yang</yangFilesRootDir>
- <inspectDependencies>true</inspectDependencies>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
- </codeGeneratorClass>
- <outputBaseDir>
- outDir/
- </outputBaseDir>
- </generator>
- </codeGenerators>
- <resourceProviders>
- <provider>
- <resourceProviderClass>
- org.opendaylight.controller.yang2sources.spi.ResourceProviderTestImpl
- </resourceProviderClass>
- <outputBaseDir>
- outDir/
- </outputBaseDir>
- </provider>
- </resourceProviders>
- </configuration>
- </execution>
- </executions>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <type>test-jar</type>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-module private {
- yang-version 1;
- namespace "urn:simple.container.demo";
- prefix "p";
-
- import unknownDep {
- prefix "data";
- revision-date 2013-02-27;
- }
-
- organization "opendaylight";
- contact "http://www.opendaylight.org/";
-
- revision "2013-02-27" {
- reference " WILL BE DEFINED LATER";
- }
-
-
-}
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
- <artifactId>test</artifactId>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <yangFilesRootDir>../files</yangFilesRootDir>
- <inspectDependencies>false</inspectDependencies>
- <codeGenerators>
- </codeGenerators>
- <resourceProviders>
- <provider>
- <resourceProviderClass>
- org.opendaylight.controller.yang2sources.spi.ResourceProviderTestImpl
- </resourceProviderClass>
- <outputBaseDir>
- outDir/
- </outputBaseDir>
- </provider>
- </resourceProviders>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <type>test-jar</type>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
-
- <artifactId>test</artifactId>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <yangFilesRootDir>../files</yangFilesRootDir>
- <inspectDependencies>false</inspectDependencies>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
- </codeGeneratorClass>
- </generator>
- </codeGenerators>
- </configuration>
- </execution>
- </executions>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <type>test-jar</type>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
-
- <artifactId>test</artifactId>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <yangFilesRootDir>${basedir}</yangFilesRootDir>
- <inspectDependencies>false</inspectDependencies>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
- </codeGeneratorClass>
- <outputBaseDir>
- /outDir/
- </outputBaseDir>
- </generator>
- </codeGenerators>
- </configuration>
- </execution>
- </executions>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <type>test-jar</type>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
-
- <artifactId>test</artifactId>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <yangFilesRootDir>../files</yangFilesRootDir>
- <inspectDependencies>false</inspectDependencies>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
- </codeGeneratorClass>
- <outputBaseDir>
- /outDir/
- </outputBaseDir>
- </generator>
- <generator>
- <codeGeneratorClass>
- unknown
- </codeGeneratorClass>
- <outputBaseDir>
- /outDir/
- </outputBaseDir>
- </generator>
- </codeGenerators>
- </configuration>
- </execution>
- </executions>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <type>test-jar</type>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
-
- <artifactId>test</artifactId>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <version>0.5.4-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <yangFilesRootDir>unknown</yangFilesRootDir>
- <inspectDependencies>false</inspectDependencies>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>
- org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
- </codeGeneratorClass>
- <outputBaseDir>
- /outDir/
- </outputBaseDir>
- </generator>
- </codeGenerators>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-module types1 {
- yang-version 1;
- namespace "urn:simple.container.demo";
- prefix "t1";
-
- import types2 {
- prefix "data";
- revision-date 2013-02-27;
- }
-
- import types3 {
- prefix "t3";
- revision-date 2013-02-27;
- }
-
- organization "opendaylight";
- contact "http://www.opendaylight.org/";
-
- revision "2013-02-27" {
- reference " WILL BE DEFINED LATER";
- }
-
-}
+++ /dev/null
-module types2 {
- yang-version 1;
- namespace "urn:simple.types.data.demo";
- prefix "t2";
-
- organization "opendaylight";
- contact "http://www.opendaylight.org/";
-
- description "This is types-data test description";
-
- revision "2013-02-27" {
- reference " WILL BE DEFINED LATER";
- }
-
-}
+++ /dev/null
-module types3 {
- yang-version 1;
- namespace "urn:simple.container.demo.test";
- prefix "t3";
-
- import types2 {
- prefix "data";
- revision-date 2013-02-27;
- }
-
- organization "opendaylight";
- contact "http://www.opendaylight.org/";
-
- revision "2013-02-27" {
- reference " WILL BE DEFINED LATER";
- }
-
-}
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>yang</artifactId>
- <groupId>org.opendaylight.controller</groupId>
- <version>0.5.4-SNAPSHOT</version>
- </parent>
-
- <artifactId>yang-maven-plugin</artifactId>
- <packaging>maven-plugin</packaging>
- <description>
- This plugin is a wrapper for "yang to source code" generation.
- It can be configured by a set of third-party code generators and resource providers.
- For further info see available goals.
- Sample usage:
-
- TODO: add sample usage when finished
- </description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>3.0.5</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>3.0.5</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-annotations</artifactId>
- <version>3.2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>2.0</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>yang-model-parser-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>yang-maven-plugin-spi</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.8.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-plugin-plugin</artifactId>
- <version>3.2</version>
- </plugin>
- </plugins>
- </reporting>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-plugin-plugin</artifactId>
- <version>3.2</version>
- <configuration>
- <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
- </configuration>
- <executions>
- <execution>
- <id>mojo-descriptor</id>
- <goals>
- <goal>descriptor</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2013 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.controller.yang2sources.plugin;
-
-import java.io.File;
-import java.util.Map;
-
-import org.apache.maven.project.MavenProject;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
-
-/**
- * Base complex configuration arguments
- */
-public abstract class ConfigArg {
-
- private final File outputBaseDir;
-
- public ConfigArg(String outputBaseDir) {
- this.outputBaseDir = outputBaseDir == null ? null : new File(outputBaseDir);
- }
-
- public File getOutputBaseDir(MavenProject project) {
- if (outputBaseDir == null) {
- return null;
- }
- if (outputBaseDir.isAbsolute()) {
- return outputBaseDir;
- } else {
- return new File(project.getBasedir(), outputBaseDir.getPath());
- }
- }
-
- public abstract void check();
-
- /**
- * Configuration argument for code generator class and output directory.
- */
- public static final class CodeGeneratorArg extends ConfigArg {
- private static final String CODE_GEN_DEFAULT_RESOURCE_DIR = "target" + File.separator + "generated-resources";
-
- private String codeGeneratorClass;
- private File resourceBaseDir = new File(CODE_GEN_DEFAULT_RESOURCE_DIR);
-
- private Map<String, String> additionalConfiguration = Maps.newHashMap();
-
- public CodeGeneratorArg() {
- super(null);
- }
-
- public CodeGeneratorArg(String codeGeneratorClass) {
- this(codeGeneratorClass, null);
- }
-
- public CodeGeneratorArg(String codeGeneratorClass, String outputBaseDir) {
- super(outputBaseDir);
- this.codeGeneratorClass = codeGeneratorClass;
- }
-
- public CodeGeneratorArg(String codeGeneratorClass, String outputBaseDir, String resourceBaseDir) {
- super(outputBaseDir);
- this.codeGeneratorClass = codeGeneratorClass;
- this.resourceBaseDir = new File(resourceBaseDir);
- }
-
- @Override
- public void check() {
- Preconditions.checkNotNull(codeGeneratorClass, "codeGeneratorClass for CodeGenerator cannot be null");
- }
-
- public String getCodeGeneratorClass() {
- return codeGeneratorClass;
- }
-
- public File getResourceBaseDir(MavenProject project) {
- if (resourceBaseDir.isAbsolute()) {
- return resourceBaseDir;
- } else {
- return new File(project.getBasedir(), resourceBaseDir.getPath());
- }
- }
-
- public Map<String, String> getAdditionalConfiguration() {
- return additionalConfiguration;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.controller.yang2sources.plugin;
-
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-final class Util {
- static final String YANG_SUFFIX = "yang";
-
- // Cache for listed directories and found yang files. Typically yang files
- // are utilized twice. First: code is generated during generate-sources
- // phase Second: yang files are copied as resources during
- // generate-resources phase. This cache ensures that yang files are listed
- // only once.
- private static Map<File, Collection<File>> cache = Maps
- .newHashMapWithExpectedSize(10);
-
- /**
- * List files recursively and return as array of String paths. Use cache of
- * size 1.
- */
- static Collection<File> listFiles(File root) throws FileNotFoundException {
- if (cache.get(root) != null)
- return cache.get(root);
-
- if (!root.exists()) {
- throw new FileNotFoundException(root.toString());
- }
-
- Collection<File> yangFiles = FileUtils.listFiles(root,
- new String[] { YANG_SUFFIX }, true);
-
- toCache(root, yangFiles);
- return yangFiles;
- }
-
- static List<InputStream> listFilesAsStream(File rootDir)
- throws FileNotFoundException {
- List<InputStream> is = new ArrayList<InputStream>();
-
- Collection<File> files = listFiles(rootDir);
- for (File f : files) {
- is.add(new NamedFileInputStream(f));
- }
-
- return is;
- }
-
- static class NamedFileInputStream extends FileInputStream {
- private final File file;
-
- NamedFileInputStream(File file) throws FileNotFoundException {
- super(file);
- this.file = file;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + "{" + file + "}";
- }
- }
-
- private static void toCache(final File rootDir,
- final Collection<File> yangFiles) {
- cache.put(rootDir, yangFiles);
- }
-
- /**
- * Instantiate object from fully qualified class name
- */
- static <T> T getInstance(String codeGeneratorClass, Class<T> baseType)
- throws ClassNotFoundException, InstantiationException,
- IllegalAccessException {
- return baseType.cast(resolveClass(codeGeneratorClass, baseType)
- .newInstance());
- }
-
- private static Class<?> resolveClass(String codeGeneratorClass,
- Class<?> baseType) throws ClassNotFoundException {
- Class<?> clazz = Class.forName(codeGeneratorClass);
-
- if (!isImplemented(baseType, clazz))
- throw new IllegalArgumentException("Code generator " + clazz
- + " has to implement " + baseType);
- return clazz;
- }
-
- private static boolean isImplemented(Class<?> expectedIface,
- Class<?> byClazz) {
- for (Class<?> iface : byClazz.getInterfaces()) {
- if (iface.equals(expectedIface))
- return true;
- }
- return false;
- }
-
- static String message(String message, String logPrefix, Object... args) {
- String innerMessage = String.format(message, args);
- return String.format("%s %s", logPrefix, innerMessage);
- }
-
- static List<File> getClassPath(MavenProject project) {
- List<File> dependencies = Lists.newArrayList();
- for (Artifact element : project.getArtifacts()) {
- File asFile = element.getFile();
- if (isJar(asFile) || asFile.isDirectory()) {
- dependencies.add(asFile);
- }
- }
- return dependencies;
- }
-
- private static final String JAR_SUFFIX = ".jar";
-
- private static boolean isJar(File element) {
- return (element.isFile() && element.getName().endsWith(JAR_SUFFIX)) ? true
- : false;
- }
-
- static <T> T checkNotNull(T obj, String paramName) {
- return Preconditions.checkNotNull(obj, "Parameter " + paramName
- + " is null");
- }
-
- final static class YangsInZipsResult implements Closeable {
- final List<InputStream> yangStreams;
- private final List<Closeable> zipInputStreams;
-
- private YangsInZipsResult(List<InputStream> yangStreams,
- List<Closeable> zipInputStreams) {
- this.yangStreams = yangStreams;
- this.zipInputStreams = zipInputStreams;
- }
-
- @Override
- public void close() throws IOException {
- for (InputStream is : yangStreams) {
- is.close();
- }
- for (Closeable is : zipInputStreams) {
- is.close();
- }
- }
- }
-
- static YangsInZipsResult findYangFilesInDependenciesAsStream(Log log,
- MavenProject project)
- throws MojoFailureException {
- List<InputStream> yangsFromDependencies = new ArrayList<>();
- List<Closeable> zips = new ArrayList<>();
- try {
- List<File> filesOnCp = Util.getClassPath(project);
- log.info(Util.message(
- "Searching for yang files in following dependencies: %s",
- YangToSourcesProcessor.LOG_PREFIX, filesOnCp));
-
- for (File file : filesOnCp) {
- List<String> foundFilesForReporting = new ArrayList<>();
- // is it jar file or directory?
- if (file.isDirectory()) {
- File yangDir = new File(file,
- YangToSourcesProcessor.META_INF_YANG_STRING);
- if (yangDir.exists() && yangDir.isDirectory()) {
- File[] yangFiles = yangDir
- .listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".yang")
- && new File(dir, name).isFile();
- }
- });
- for (File yangFile : yangFiles) {
- yangsFromDependencies.add(new NamedFileInputStream(
- yangFile));
- }
- }
-
- } else {
- ZipFile zip = new ZipFile(file);
- zips.add(zip);
-
- Enumeration<? extends ZipEntry> entries = zip.entries();
- while (entries.hasMoreElements()) {
- ZipEntry entry = entries.nextElement();
- String entryName = entry.getName();
-
- if (entryName
- .startsWith(YangToSourcesProcessor.META_INF_YANG_STRING_JAR)) {
- if (entry.isDirectory() == false
- && entryName.endsWith(".yang")) {
- foundFilesForReporting.add(entryName);
- // This will be closed after all strams are
- // parsed.
- InputStream entryStream = zip
- .getInputStream(entry);
- yangsFromDependencies.add(entryStream);
- }
- }
- }
- }
- if (foundFilesForReporting.size() > 0) {
- log.info(Util.message("Found %d yang files in %s: %s",
- YangToSourcesProcessor.LOG_PREFIX,
- foundFilesForReporting.size(), file,
- foundFilesForReporting));
- }
-
- }
- } catch (Exception e) {
- throw new MojoFailureException(e.getMessage(), e);
- }
- return new YangsInZipsResult(yangsFromDependencies, zips);
- }
-
- final static class ContextHolder {
- private final SchemaContext context;
- private final Set<Module> yangModules;
-
- ContextHolder(SchemaContext context, Set<Module> yangModules) {
- this.context = context;
- this.yangModules = yangModules;
- }
-
- SchemaContext getContext() {
- return context;
- }
-
- Set<Module> getYangModules() {
- return yangModules;
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.controller.yang2sources.plugin;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang2sources.plugin.ConfigArg.CodeGeneratorArg;
-import org.opendaylight.controller.yang2sources.spi.CodeGenerator;
-
-import com.google.common.annotations.VisibleForTesting;
-
-/**
- * Generate sources from yang files using user provided set of
- * {@link CodeGenerator}s. Steps of this process:
- * <ol>
- * <li>List yang files from {@link #yangFilesRootDir}</li>
- * <li>Process yang files using {@link YangModelParserImpl}</li>
- * <li>For each {@link CodeGenerator} from {@link #codeGenerators}:</li>
- * <ol>
- * <li>Instantiate using default constructor</li>
- * <li>Call {@link CodeGenerator#generateSources(SchemaContext, File)}</li>
- * </ol>
- * </ol>
- */
-@Mojo(name = "generate-sources", defaultPhase = LifecyclePhase.GENERATE_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true)
-public final class YangToSourcesMojo extends AbstractMojo {
-
- /**
- * Classes implementing {@link CodeGenerator} interface. An instance will be
- * created out of every class using default constructor. Method {@link
- * CodeGenerator#generateSources(SchemaContext, File, Set<String>
- * yangModulesNames)} will be called on every instance.
- */
- @Parameter(required = false)
- private CodeGeneratorArg[] codeGenerators;
-
- /**
- * Source directory that will be recursively searched for yang files (ending
- * with .yang suffix).
- */
- @Parameter(required = false)
- private String yangFilesRootDir; // defaults to ${basedir}/src/main/yang
-
- @Parameter(property = "project", required = true, readonly = true)
- protected MavenProject project;
-
- @Parameter(property = "inspectDependencies", required = true, readonly = true)
- private boolean inspectDependencies;
-
- private YangToSourcesProcessor yangToSourcesProcessor;
-
- public YangToSourcesMojo() {
-
- }
-
- @VisibleForTesting
- YangToSourcesMojo(YangToSourcesProcessor processor) {
- this.yangToSourcesProcessor = processor;
- }
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- if (yangToSourcesProcessor == null) {
- List<CodeGeneratorArg> codeGeneratorArgs = processCodeGenerators(codeGenerators);
-
- // defaults to ${basedir}/src/main/yang
- File yangFilesRootFile = processYangFilesRootDir(yangFilesRootDir,
- project.getBasedir());
-
- yangToSourcesProcessor = new YangToSourcesProcessor(getLog(),
- yangFilesRootFile, codeGeneratorArgs, project,
- inspectDependencies);
- }
- yangToSourcesProcessor.execute();
- }
-
- private static List<CodeGeneratorArg> processCodeGenerators(
- CodeGeneratorArg[] codeGenerators) {
- List<CodeGeneratorArg> codeGeneratorArgs;
- if (codeGenerators == null) {
- codeGeneratorArgs = Collections.emptyList();
- } else {
- codeGeneratorArgs = Arrays.asList(codeGenerators);
- }
- return codeGeneratorArgs;
- }
-
- private static File processYangFilesRootDir(String yangFilesRootDir,
- File baseDir) {
- File yangFilesRootFile;
- if (yangFilesRootDir == null) {
- yangFilesRootFile = new File(baseDir, "src" + File.separator
- + "main" + File.separator + "yang");
- } else {
- File file = new File(yangFilesRootDir);
- if (file.isAbsolute()) {
- yangFilesRootFile = file;
- } else {
- yangFilesRootFile = new File(baseDir, file.getPath());
- }
- }
- return yangFilesRootFile;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.controller.yang2sources.plugin;
-
-import java.io.Closeable;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.FileUtils;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
-import org.opendaylight.controller.yang2sources.plugin.ConfigArg.CodeGeneratorArg;
-import org.opendaylight.controller.yang2sources.plugin.Util.ContextHolder;
-import org.opendaylight.controller.yang2sources.plugin.Util.YangsInZipsResult;
-import org.opendaylight.controller.yang2sources.spi.CodeGenerator;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Maps;
-
-class YangToSourcesProcessor {
- static final String LOG_PREFIX = "yang-to-sources:";
- static final String META_INF_YANG_STRING = "META-INF" + File.separator
- + "yang";
- static final String META_INF_YANG_STRING_JAR = "META-INF" + "/" + "yang";
- static final File META_INF_YANG_DIR = new File(META_INF_YANG_STRING);
-
- private final Log log;
- private final File yangFilesRootDir;
- private final List<CodeGeneratorArg> codeGenerators;
- private final MavenProject project;
- private final boolean inspectDependencies;
- private YangProvider yangProvider;
-
- @VisibleForTesting
- YangToSourcesProcessor(Log log, File yangFilesRootDir,
- List<CodeGeneratorArg> codeGenerators, MavenProject project,
- boolean inspectDependencies, YangProvider yangProvider) {
- this.log = Util.checkNotNull(log, "log");
- this.yangFilesRootDir = Util.checkNotNull(yangFilesRootDir,
- "yangFilesRootDir");
- this.codeGenerators = Collections.unmodifiableList(Util.checkNotNull(
- codeGenerators, "codeGenerators"));
- this.project = Util.checkNotNull(project, "project");
- this.inspectDependencies = inspectDependencies;
- this.yangProvider = yangProvider;
- }
-
- YangToSourcesProcessor(Log log, File yangFilesRootDir,
- List<CodeGeneratorArg> codeGenerators, MavenProject project,
- boolean inspectDependencies) {
- this(log, yangFilesRootDir, codeGenerators, project,
- inspectDependencies, new YangProvider());
- }
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- ContextHolder context = processYang();
- generateSources(context);
- yangProvider.addYangsToMETA_INF(log, project, yangFilesRootDir);
- }
-
- private ContextHolder processYang() throws MojoExecutionException {
- YangParserImpl parser = new YangParserImpl();
- List<Closeable> closeables = new ArrayList<>();
- log.info(Util.message("Inspecting %s", LOG_PREFIX, yangFilesRootDir));
- try {
- List<InputStream> yangsInProject = Util
- .listFilesAsStream(yangFilesRootDir);
- List<InputStream> all = new ArrayList<>(yangsInProject);
- closeables.addAll(yangsInProject);
- Map<InputStream, Module> allYangModules;
- Set<Module> projectYangModules;
- try {
- if (inspectDependencies) {
- YangsInZipsResult dependentYangResult = Util
- .findYangFilesInDependenciesAsStream(log, project);
- Closeable dependentYangResult1 = dependentYangResult;
- closeables.add(dependentYangResult1);
- all.addAll(dependentYangResult.yangStreams);
- }
-
- allYangModules = parser.parseYangModelsFromStreamsMapped(all);
-
- projectYangModules = new HashSet<>();
- for (InputStream inProject : yangsInProject) {
- projectYangModules.add(allYangModules.get(inProject));
- }
-
- } finally {
- for (AutoCloseable closeable : closeables) {
- closeable.close();
- }
- }
-
- Set<Module> parsedAllYangModules = new HashSet<>(
- allYangModules.values());
- SchemaContext resolveSchemaContext = parser
- .resolveSchemaContext(parsedAllYangModules);
- log.info(Util.message("%s files parsed from %s", LOG_PREFIX,
- Util.YANG_SUFFIX.toUpperCase(), yangsInProject));
- return new ContextHolder(resolveSchemaContext, projectYangModules);
-
- // MojoExecutionException is thrown since execution cannot continue
- } catch (Exception e) {
- String message = Util.message("Unable to parse %s files from %s",
- LOG_PREFIX, Util.YANG_SUFFIX, yangFilesRootDir);
- log.error(message, e);
- throw new MojoExecutionException(message, e);
- }
- }
-
- static class YangProvider {
-
- private static final String yangResourceDir = "target" + File.separator
- + "yang";
-
- void addYangsToMETA_INF(Log log, MavenProject project,
- File yangFilesRootDir) throws MojoFailureException {
- File targetYangDir = new File(project.getBasedir(), yangResourceDir);
-
- try {
- FileUtils.copyDirectory(yangFilesRootDir, targetYangDir);
- } catch (IOException e) {
- String message = "Unable to copy yang files into resource folder";
- log.warn(message, e);
- throw new MojoFailureException(message, e);
- }
-
- setResource(targetYangDir, META_IN