/*
 * Copyright (c) 2014 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.data.impl.schema.tree;

import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;

import java.io.InputStream;
import java.util.Collections;
import java.util.Set;

public class TestModel {

    public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13",
        "test");
    public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
    public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
    public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
    public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
    public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
    public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
    private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";

    public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
    public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
    public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
    public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");


    public static final InputStream getDatastoreTestInputStream() {
        return getInputStream(DATASTORE_TEST_YANG);
    }

    private static InputStream getInputStream(final String resourceName) {
        return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
    }

    public static SchemaContext createTestContext() {
        YangParserImpl parser = new YangParserImpl();
        Set<Module> modules = parser.parseYangModelsFromStreams(Collections.singletonList(getDatastoreTestInputStream()));
        return parser.resolveSchemaContext(modules);
    }
}

@@ -365,16 +365,141 @@
 .tree;%0A%0A
+import com.google.common.io.Resources;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.util.Collections;%0A
 import o
@@ -664,22 +664,29 @@
 del.api.
-Module
+SchemaContext
 ;%0Aimport
@@ -724,33 +724,51 @@
 g.model.
-api.SchemaContext
+parser.api.YangSyntaxErrorException
 ;%0Aimport
@@ -833,89 +833,8 @@
 l;%0A%0A
-import java.io.InputStream;%0Aimport java.util.Collections;%0Aimport java.util.Set;%0A%0A
 publ
@@ -2062,142 +2062,8 @@
 ) %7B%0A
-        return getInputStream(DATASTORE_TEST_YANG);%0A    %7D%0A%0A    private static InputStream getInputStream(final String resourceName) %7B%0A
     
@@ -2258,175 +2258,297 @@
     
-Set%3CModule%3E modules = parser.parseYangModelsFromStreams(Collections.singletonList(getDatastoreTestInputStream()));%0A        return parser.resolveSchemaContext(modules);
+try %7B%0A            return parser.parseSources(Collections.singleton(Resources.asByteSource(TestModel.class.getResource(DATASTORE_TEST_YANG))));%0A        %7D catch (IOException %7C YangSyntaxErrorException e) %7B%0A            throw new IllegalStateException(%22Failed to create context%22, e);%0A        %7D
 %0A   

Remove use of deprecated parser method