Remove deprecated Yin/YangStatementSourceImpl
[yangtools.git] / yang / yang-model-export / src / test / java / org / opendaylight / yangtools / yang / model / export / test / Bug4504Test.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.model.export.test;
9
10 import static org.junit.Assert.assertNotNull;
11
12 import java.io.File;
13 import java.io.FileOutputStream;
14 import java.io.OutputStream;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.model.export.YinExportUtils;
19 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
20
21 public class Bug4504Test {
22     @Test
23     public void test() throws Exception {
24         SchemaContext schema = YangParserTestUtils.parseYangResourceDirectory("/bugs/bug4504");
25         assertNotNull(schema);
26         final File outDir = new File("target/bug4504-export");
27         outDir.mkdirs();
28         for (final Module module : schema.getModules()) {
29             exportModule(schema, module, outDir);
30         }
31     }
32
33     private static File exportModule(final SchemaContext schemaContext, final Module module, final File outDir)
34             throws Exception {
35         final File outFile = new File(outDir, YinExportUtils.wellFormedYinName(module.getName(), module.getRevision()));
36         try (OutputStream output = new FileOutputStream(outFile)) {
37             YinExportUtils.writeModuleToOutputStream(schemaContext, module, output);
38         }
39         return outFile;
40     }
41 }