BUG-7052: extract SimpleSchemaContext
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug5712Test.java
index bdfdc05297560080e0d8962d6ca46fa6fbf4e56a..9df7aa9dc6812b64ade71d8540017ea10d0627c4 100644 (file)
@@ -11,29 +11,16 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
 public class Bug5712Test {
 
     @Test
-    public void testTypedefWithNewStatementParser() throws ReactorException, SourceException, FileNotFoundException,
-            URISyntaxException {
+    public void testTypedefWithNewStatementParser() throws Exception {
         SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug5712");
         assertNotNull(schemaContext);
 
@@ -43,7 +30,7 @@ public class Bug5712Test {
         checkThing2TypeDef(badModule);
     }
 
-    private void checkThing2TypeDef(Module badModule) {
+    private static void checkThing2TypeDef(final Module badModule) {
         TypeDefinition<?> thing2 = null;
         for (TypeDefinition<?> typeDef : badModule.getTypeDefinitions()) {
             if (typeDef.getQName().getLocalName().equals("thing2")) {
@@ -56,32 +43,4 @@ public class Bug5712Test {
         TypeDefinition<?> baseType = thing2.getBaseType();
         assertEquals(QName.create("urn:opendaylight:bad", "2016-04-11", "thing"), baseType.getQName());
     }
-
-    @Test
-    public void testTypedefWithOldParser() throws URISyntaxException, IOException {
-        Set<Module> modules = loadModules(getClass().getResource("/bugs/bug5712").toURI());
-        assertNotNull(modules);
-        assertEquals(1, modules.size());
-
-        checkThing2TypeDef(modules.iterator().next());
-    }
-
-    public static Set<Module> loadModules(final URI resourceDirectory) throws IOException {
-        return loadSchemaContext(resourceDirectory).getModules();
-    }
-
-    public static SchemaContext loadSchemaContext(final URI resourceDirectory) throws IOException {
-        final YangContextParser parser = new YangParserImpl();
-        final File testDir = new File(resourceDirectory);
-        final String[] fileList = testDir.list();
-        final List<File> testFiles = new ArrayList<>();
-        if (fileList == null) {
-            throw new FileNotFoundException(resourceDirectory.toString());
-        }
-        for (String fileName : fileList) {
-            testFiles.add(new File(testDir, fileName));
-        }
-        return parser.parseFiles(testFiles);
-    }
-
 }