Merge "BUG-1770: emit proper namespaces"
[yangtools.git] / code-generator / binding-generator-impl / src / test / java / org / opendaylight / yangtools / sal / binding / generator / impl / GeneratedTypesBitsTest.java
index f79d3a430ed43ae09c6a0ab87c8912614b28b256..16abfd7b1c9fcc47f434ce84bc4bb6158245a999 100644 (file)
@@ -1,11 +1,19 @@
+/*
+ * Copyright (c) 2014 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.yangtools.sal.binding.generator.impl;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
-import java.io.File;
-import java.util.ArrayList;
+import java.net.URI;
 import java.util.List;
-import java.util.Set;
 
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
@@ -15,33 +23,19 @@ import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
 import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature.Parameter;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class GeneratedTypesBitsTest {
 
-    private SchemaContext resolveSchemaContextFromFiles(final String... yangFiles) {
-        final YangModelParser parser = new YangParserImpl();
-
-        final List<File> inputFiles = new ArrayList<File>();
-        for (int i = 0; i < yangFiles.length; ++i) {
-            inputFiles.add(new File(yangFiles[i]));
-        }
-
-        final Set<Module> modules = parser.parseYangModels(inputFiles);
-        return parser.resolveSchemaContext(modules);
-    }
 
     @Test
-    public void testGeneretedTypesBitsTest() {
-        final String yangTypesPath = getClass().getResource("/simple-bits-demo.yang").getPath();
+    public void testGeneretedTypesBitsTest() throws Exception {
+        final URI yangTypesPath = getClass().getResource("/simple-bits-demo.yang").toURI();
 
-        final SchemaContext context = resolveSchemaContextFromFiles(yangTypesPath);
+        final SchemaContext context = SupportTestUtil.resolveSchemaContextFromFiles(yangTypesPath);
         assertTrue(context != null);
 
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
         final List<Type> genTypes = bindingGen.generateTypes(context);
         assertTrue(genTypes != null);
 
@@ -56,7 +50,6 @@ public class GeneratedTypesBitsTest {
         int hashPropertiesNum = 0;
 
         String nameReturnParamType = "";
-        String nameMethodeParamType = "";
         boolean getByteLeafMethodFound = false;
         boolean setByteLeafMethodFound = false;
         int setByteLeafMethodParamNum = 0;
@@ -105,10 +98,6 @@ public class GeneratedTypesBitsTest {
 
                                 List<Parameter> parameters = methodSignature.getParameters();
                                 setByteLeafMethodParamNum = parameters.size();
-                                for (Parameter parameter : parameters) {
-                                    nameMethodeParamType = parameter.getType().getName();
-                                }
-
                             }
 
                         }
@@ -136,4 +125,4 @@ public class GeneratedTypesBitsTest {
         assertEquals(0, setByteLeafMethodParamNum);
     }
 
-}
\ No newline at end of file
+}