import org.custommonkey.xmlunit.ElementNameAndAttributeQualifier;
import org.custommonkey.xmlunit.XMLAssert;
import org.custommonkey.xmlunit.XMLUnit;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.Submodule;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.w3c.dom.Document;
abstract class AbstractYinExportTest {
final void exportYinModules(final String yangDir, final String yinDir) throws IOException, SAXException,
XMLStreamException {
- final SchemaContext schemaContext = YangParserTestUtils.parseYangResourceDirectory(yangDir);
+ final EffectiveModelContext schemaContext = YangParserTestUtils.parseYangResourceDirectory(yangDir);
final Collection<? extends Module> modules = schemaContext.getModules();
assertNotEquals(0, modules.size());
}
}
- private void readAndValidateModule(final SchemaContext schemaContext, final Module module, final String yinDir)
- throws XMLStreamException, IOException, SAXException {
+ private void readAndValidateModule(final EffectiveModelContext schemaContext, final Module module,
+ final String yinDir) throws XMLStreamException, IOException, SAXException {
final String fileName = YinExportUtils.wellFormedYinName(module.getName(), module.getRevision());
validateOutput(yinDir, fileName, export(module));
}
- private void readAndValidateSubmodule(final SchemaContext schemaContext, final Module module,
+ private void readAndValidateSubmodule(final EffectiveModelContext schemaContext, final Module module,
final Submodule submodule, final String yinDir) throws XMLStreamException, IOException, SAXException {
final String fileName = YinExportUtils.wellFormedYinName(submodule.getName(), submodule.getRevision());
validateOutput(yinDir, fileName, export(module, submodule));
private static String export(final Module module) throws XMLStreamException {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- YinExportUtils.writeModuleAsYinText(module, bos);
- return new String(bos.toByteArray(), StandardCharsets.UTF_8);
+ YinExportUtils.writeModuleAsYinText(module.asEffectiveStatement(), bos);
+ return bos.toString(StandardCharsets.UTF_8);
}
private static String export(final Module module, final Submodule submodule) throws XMLStreamException {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- YinExportUtils.writeSubmoduleAsYinText(module, submodule, bos);
- return new String(bos.toByteArray(), StandardCharsets.UTF_8);
+ YinExportUtils.writeSubmoduleAsYinText(module.asEffectiveStatement(), submodule.asEffectiveStatement(), bos);
+ return bos.toString(StandardCharsets.UTF_8);
}
private static void assertXMLEquals(final String fileName, final Document expectedXMLDoc, final String output)
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.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class Bug5531Test {
@Test
public void test() throws Exception {
- SchemaContext schema = YangParserTestUtils.parseYangResourceDirectory("/bugs/bug5531");
+ EffectiveModelContext schema = YangParserTestUtils.parseYangResourceDirectory("/bugs/bug5531");
assertNotNull(schema);
assertNotNull(schema.getModules());
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(byteArrayOutputStream);
// write small module of size less than 8kB
- for (Module module : schema.getModules()) {
+ for (ModuleEffectiveStatement module : schema.getModuleStatements().values()) {
YinExportUtils.writeModuleAsYinText(module, bufferedOutputStream);
}
import java.io.OutputStream;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@Test
public void testImplicitInputAndOutputInRpc() throws Exception {
- final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(Bug6856Test.class,
+ final EffectiveModelContext schemaContext = YangParserTestUtils.parseYangResources(Bug6856Test.class,
"/bugs/bug-6856/foo.yang");
assertNotNull(schemaContext);
final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(byteArrayOutputStream);
final Module fooModule = schemaContext.findModule("foo", Revision.of("2017-02-28")).get();
- YinExportUtils.writeModuleAsYinText(fooModule, bufferedOutputStream);
+ YinExportUtils.writeModuleAsYinText(fooModule.asEffectiveStatement(), bufferedOutputStream);
final String output = byteArrayOutputStream.toString();
assertNotNull(output);
final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(byteArrayOutputStream);
final Module barModule = schemaContext.findModule("bar", Revision.of("2017-02-28")).get();
- YinExportUtils.writeModuleAsYinText(barModule, bufferedOutputStream);
+ YinExportUtils.writeModuleAsYinText(barModule.asEffectiveStatement(), bufferedOutputStream);
final String output = byteArrayOutputStream.toString();
assertNotNull(output);