From: Ivan Hrasko Date: Thu, 31 Mar 2016 10:46:23 +0000 (+0200) Subject: Bug5531: Can't get complete YIN schema on Windows X-Git-Tag: release/boron~176 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F44%2F36944%2F1;p=yangtools.git Bug5531: Can't get complete YIN schema on Windows Added unit test trying to write small module to YIN. If result is not empty and module is complete then test is sucessfull. Change-Id: I8b0b0c0c0f787c9a6402dd8b4c74173b89a1b8c5 Signed-off-by: Ivan Hrasko --- diff --git a/yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/Bug5531Test.java b/yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/Bug5531Test.java new file mode 100644 index 0000000000..0d0d9d1bb4 --- /dev/null +++ b/yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/Bug5531Test.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.yangtools.yang.model.export.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; +import org.junit.Test; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.export.YinExportUtils; + +public class Bug5531Test { + @Test + public void test() throws Exception { + SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug5531"); + + assertNotNull(schema); + assertNotNull(schema.getModules()); + assertEquals(1, schema.getModules().size()); + + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(byteArrayOutputStream); + + // write small module of size less than 8kB + for (Module module : schema.getModules()) { + YinExportUtils.writeModuleToOutputStream(schema, module, bufferedOutputStream); + } + + String output = byteArrayOutputStream.toString(); + + // if all changes were flushed then following conditions are satisfied + assertNotEquals("Output should not be empty", 0, output.length()); + assertTrue("Output should contains start of the module", output.contains("")); + } +} diff --git a/yang/yang-model-export/src/test/resources/bugs/bug5531/foo.yang b/yang/yang-model-export/src/test/resources/bugs/bug5531/foo.yang new file mode 100644 index 0000000000..2c6c2e3593 --- /dev/null +++ b/yang/yang-model-export/src/test/resources/bugs/bug5531/foo.yang @@ -0,0 +1,8 @@ +module foo { + namespace "foo"; + prefix foo; + + revision 2015-01-01 { + description "test"; + } +}