SchemaContext is well-known invariant, make sure we reuse it.
Change-Id: Id26988be0bd36a21bc4b0f227f5199d217a06300
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.opendaylight.yangtools.yang.test.util.YangParserTestUtils.parseYangResources;
import com.google.common.io.ByteSource;
import com.google.common.util.concurrent.Futures;
import com.google.common.io.ByteSource;
import com.google.common.util.concurrent.Futures;
import org.custommonkey.xmlunit.DetailedDiff;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
import org.custommonkey.xmlunit.DetailedDiff;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.mockito.MockitoAnnotations;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.mockito.MockitoAnnotations;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
private static final String DATA_ELEMENT = "data";
protected static final Document RPC_REPLY_OK = getReplyOk();
private static final String DATA_ELEMENT = "data";
protected static final Document RPC_REPLY_OK = getReplyOk();
+ private static SchemaContext SCHEMA_CONTEXT;
+
private CurrentSchemaContext currentSchemaContext;
private TransactionProvider transactionProvider;
private CurrentSchemaContext currentSchemaContext;
private TransactionProvider transactionProvider;
+ @BeforeClass
+ public static void beforeClass() {
+ SCHEMA_CONTEXT = parseYangResources(AbstractNetconfOperationTest.class,
+ "/yang/mdsal-netconf-mapping-test.yang");
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ SCHEMA_CONTEXT = null;
+ }
+
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);
- final SchemaContext schemaContext = getSchemaContext();
- final DOMSchemaService schemaService = new SchemaServiceStub(schemaContext);
+ final DOMSchemaService schemaService = new SchemaServiceStub(SCHEMA_CONTEXT);
final DOMStore operStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", schemaService);
final DOMStore configStore = InMemoryDOMDataStoreFactory.create("DOM-CFG", schemaService);
final DOMStore operStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", schemaService);
final DOMStore configStore = InMemoryDOMDataStoreFactory.create("DOM-CFG", schemaService);
this.transactionProvider = new TransactionProvider(sdb, SESSION_ID_FOR_REPORTING);
}
this.transactionProvider = new TransactionProvider(sdb, SESSION_ID_FOR_REPORTING);
}
- protected abstract SchemaContext getSchemaContext();
-
protected CurrentSchemaContext getCurrentSchemaContext() {
return currentSchemaContext;
}
protected CurrentSchemaContext getCurrentSchemaContext() {
return currentSchemaContext;
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.netconf.mdsal.connector.ops;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
package org.opendaylight.netconf.mdsal.connector.ops;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.opendaylight.yangtools.yang.test.util.YangParserTestUtils.parseYangResources;
import java.io.File;
import java.io.FileInputStream;
import java.io.File;
import java.io.FileInputStream;
import org.opendaylight.netconf.api.DocumentedException.ErrorType;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.netconf.util.test.XmlFileLoader;
import org.opendaylight.netconf.api.DocumentedException.ErrorType;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.netconf.util.test.XmlFileLoader;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@Rule
public TemporaryFolder tmpDir = new TemporaryFolder();
@Rule
public TemporaryFolder tmpDir = new TemporaryFolder();
- @Override
- protected SchemaContext getSchemaContext() {
- return parseYangResources(CopyConfigTest.class,
- "/yang/mdsal-netconf-mapping-test.yang");
- }
-
-
@Test
public void testTargetMissing() throws Exception {
try {
@Test
public void testTargetMissing() throws Exception {
try {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.netconf.mdsal.connector.ops;
import static org.junit.Assert.assertEquals;
package org.opendaylight.netconf.mdsal.connector.ops;
import static org.junit.Assert.assertEquals;
import org.opendaylight.netconf.util.test.XmlFileLoader;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.netconf.util.test.XmlFileLoader;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
private static final YangInstanceIdentifier AUGMENTED_CONTAINER_IN_MODULES =
YangInstanceIdentifier.builder().node(TOP).node(MODULES).build();
private static final YangInstanceIdentifier AUGMENTED_CONTAINER_IN_MODULES =
YangInstanceIdentifier.builder().node(TOP).node(MODULES).build();
- @Override
- protected SchemaContext getSchemaContext() {
- return YangParserTestUtils.parseYangResources(NetconfMDSalMappingTest.class,
- "/yang/mdsal-netconf-mapping-test.yang");
- }
-
@Test
public void testEmptyDatastore() throws Exception {
assertEmptyDatastore(get());
@Test
public void testEmptyDatastore() throws Exception {
assertEmptyDatastore(get());