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;
20 public class Bug4504Test {
22 public void test() throws Exception {
23 SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug4504");
24 assertNotNull(schema);
25 final File outDir = new File("target/bug4504-export");
27 for (final Module module : schema.getModules()) {
28 exportModule(schema, module, outDir);
32 private File exportModule(final SchemaContext schemaContext, final Module module, final File outDir)
34 final File outFile = new File(outDir, YinExportUtils.wellFormedYinName(module.getName(), module.getRevision()));
35 try (OutputStream output = new FileOutputStream(outFile)) {
36 YinExportUtils.writeModuleToOutputStream(schemaContext, module, output);