Remove deprecated Yin/YangStatementSourceImpl
[yangtools.git] / yang / yang-model-export / src / test / java / org / opendaylight / yangtools / yang / model / export / test / Bug5531Test.java
1 /*
2  * Copyright (c) 2016 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.assertEquals;
11 import static org.junit.Assert.assertNotEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
14
15 import java.io.BufferedOutputStream;
16 import java.io.ByteArrayOutputStream;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.model.api.Module;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20 import org.opendaylight.yangtools.yang.model.export.YinExportUtils;
21 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
22
23 public class Bug5531Test {
24     @Test
25     public void test() throws Exception {
26         SchemaContext schema = YangParserTestUtils.parseYangResourceDirectory("/bugs/bug5531");
27
28         assertNotNull(schema);
29         assertNotNull(schema.getModules());
30         assertEquals(1, schema.getModules().size());
31
32         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
33         BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(byteArrayOutputStream);
34
35         // write small module of size less than 8kB
36        for (Module module : schema.getModules()) {
37            YinExportUtils.writeModuleToOutputStream(schema, module, bufferedOutputStream);
38        }
39
40         String output = byteArrayOutputStream.toString();
41
42         // if all changes were flushed then following conditions are satisfied
43         assertNotEquals("Output should not be empty", 0, output.length());
44         assertTrue("Output should contains start of the module", output.contains("<module"));
45         assertTrue("Output should contains end of the module", output.contains("</module>"));
46     }
47 }