2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.model.export.test;
10 import static org.junit.Assert.assertNotNull;
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;
21 public class Bug4504Test {
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");
28 for (final Module module : schema.getModules()) {
29 exportModule(schema, module, outDir);
33 private static File exportModule(final SchemaContext schemaContext, final Module module, final File outDir)
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);