2 * Copyright (c) 2016 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.assertEquals;
11 import static org.junit.Assert.assertNotEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
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;
22 public class Bug5531Test {
24 public void test() throws Exception {
25 SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug5531");
27 assertNotNull(schema);
28 assertNotNull(schema.getModules());
29 assertEquals(1, schema.getModules().size());
31 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
32 BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(byteArrayOutputStream);
34 // write small module of size less than 8kB
35 for (Module module : schema.getModules()) {
36 YinExportUtils.writeModuleToOutputStream(schema, module, bufferedOutputStream);
39 String output = byteArrayOutputStream.toString();
41 // if all changes were flushed then following conditions are satisfied
42 assertNotEquals("Output should not be empty", 0, output.length());
43 assertTrue("Output should contains start of the module", output.contains("<module"));
44 assertTrue("Output should contains end of the module", output.contains("</module>"));