Use YangParserTestUtils.parseYangResourceDirectory() 99/107099/2
authorRobert Varga <[email protected]>
Wed, 26 Jul 2023 20:07:56 +0000 (22:07 +0200)
committerRobert Varga <[email protected]>
Wed, 26 Jul 2023 21:16:19 +0000 (23:16 +0200)
We have a build-in utility which does the right thing for
single-directory schema assembly. Use that instead of home-grown
utilities.

Change-Id: I55c956d74d2d142726d39f85655118fbea22018d
Signed-off-by: Robert Varga <[email protected]>
13 files changed:
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/legacy/SchemaContextHandlerTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/monitoring/RestconfStateStreamsTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtilTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/Netconf799Test.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfImplTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImplTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfSchemaServiceTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfStreamsSubscriptionServiceImplTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtilTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/AbstractFieldsTranslatorTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/IdentifierCodecTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializerTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializerTest.java

index ac6ecc56577ce7fd1b88edfb05db27061aeff68c..48f12d9379e41702272458cbbb5c23d18b1f5de7 100644 (file)
@@ -13,7 +13,6 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
 
-import java.io.FileNotFoundException;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -23,7 +22,6 @@ import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -46,8 +44,8 @@ public class SchemaContextHandlerTest {
     private ListenerRegistration<?> mockListenerReg;
 
     @BeforeClass
-    public static void beforeClass() throws FileNotFoundException {
-        SCHEMA_CONTEXT = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules"));
+    public static void beforeClass() {
+        SCHEMA_CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/modules");
     }
 
     @AfterClass
@@ -95,10 +93,10 @@ public class SchemaContextHandlerTest {
      * <code>SchemaContextHandler</code> reference to new <code>SchemaContext</code> instead of old one.
      */
     @Test
-    public void onGlobalContextUpdateTest() throws Exception {
+    public void onGlobalContextUpdateTest() {
         // create new SchemaContext and update SchemaContextHandler
         final EffectiveModelContext newSchemaContext =
-                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules/modules-behind-mount-point"));
+                YangParserTestUtils.parseYangResourceDirectory("/modules/modules-behind-mount-point");
         schemaContextHandler.onModelContextUpdated(newSchemaContext);
 
         assertNotEquals("SchemaContextHandler should not has reference to old SchemaContext",
index f26f40e853be9a0d34f013c0b72294345ad76be2..863c477920c2423dfcd18065231024a1214c846f 100644 (file)
@@ -53,9 +53,8 @@ public class RestconfStateStreamsTest {
     @BeforeClass
     public static void loadTestSchemaContextAndModules() throws Exception {
         // FIXME: assemble these from dependencies
-        schemaContext =
-                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules/restconf-module-testing"));
-        schemaContextMonitoring = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules"));
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/modules/restconf-module-testing");
+        schemaContextMonitoring = YangParserTestUtils.parseYangResourceDirectory("/modules");
         modules = schemaContextMonitoring.getModules();
         modulesRest = YangParserTestUtils
                 .parseYangFiles(TestRestconfUtils.loadFiles("/modules/restconf-module-testing")).getModules();
index 27648761a291393bda883b54dd0c0d56abbd8df6..c7df03d5849a828b37f108eff743de6e17dcd364 100644 (file)
@@ -21,7 +21,6 @@ import org.junit.runner.RunWith;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
 import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -43,8 +42,8 @@ public class CreateStreamUtilTest {
     private static EffectiveModelContext SCHEMA_CTX;
 
     @BeforeClass
-    public static void setUp() throws Exception {
-        SCHEMA_CTX = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/streams"));
+    public static void setUp() {
+        SCHEMA_CTX = YangParserTestUtils.parseYangResourceDirectory("/streams");
     }
 
     @Test
index 948e2475f27a5e9a580086da66eef819784eecf7..e1176984642c3a94ae87f51f909f567705385c41 100644 (file)
@@ -17,7 +17,6 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
 import com.google.common.util.concurrent.Futures;
-import java.io.FileNotFoundException;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.junit.MockitoJUnitRunner;
@@ -26,7 +25,6 @@ import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
 import org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult;
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.databind.DatabindContext;
 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfStreamsSubscriptionService;
@@ -55,9 +53,9 @@ public class Netconf799Test {
     private static final YangInstanceIdentifier ACTION_YII = YangInstanceIdentifier.of(CONT_QNAME).node(CONT1_QNAME);
 
     @Test
-    public void testInvokeAction() throws FileNotFoundException {
-        final EffectiveModelContext contextRef = YangParserTestUtils.parseYangFiles(
-            TestRestconfUtils.loadFiles("/instanceidentifier/yang"));
+    public void testInvokeAction() {
+        final EffectiveModelContext contextRef =
+            YangParserTestUtils.parseYangResourceDirectory("/instanceidentifier/yang");
 
         final DOMDataBroker mockDataBroker = mock(DOMDataBroker.class);
 
index d980ce819e4689c770ef24629c5aae233a561a53..e21c3299dc1e7f9a4891f03ac8f368833b2f548e 100644 (file)
@@ -11,7 +11,6 @@ import static org.junit.Assert.assertEquals;
 
 import org.junit.Test;
 import org.opendaylight.restconf.nb.rfc8040.Rfc8040.IetfYangLibrary;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.databind.DatabindContext;
 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
@@ -19,8 +18,8 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class RestconfImplTest {
     @Test
-    public void restImplTest() throws Exception {
-        final var context = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/impl"));
+    public void restImplTest() {
+        final var context = YangParserTestUtils.parseYangResourceDirectory("/restconf/impl");
         final RestconfImpl restconfImpl = new RestconfImpl(() -> DatabindContext.ofModel(context));
         final NormalizedNodePayload libraryVersion = restconfImpl.getLibraryVersion();
         final LeafNode<?> value = (LeafNode<?>) libraryVersion.getData();
index 35249dfbb904593839006e522b3ac72ad41381ec..f458e599866e3dd7de9bb2918fbd650e174cc031 100644 (file)
@@ -44,7 +44,6 @@ import org.opendaylight.mdsal.dom.api.DOMRpcService;
 import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
 import org.opendaylight.restconf.nb.rfc8040.streams.StreamsConfiguration;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
@@ -82,8 +81,8 @@ public class RestconfInvokeOperationsServiceImplTest {
     private RestconfInvokeOperationsServiceImpl invokeOperationsService;
 
     @BeforeClass
-    public static void beforeClass() throws Exception {
-        CONTEXT = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/invoke-rpc"));
+    public static void beforeClass() {
+        CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/invoke-rpc");
     }
 
     @Before
index 1c8e5bc6312c9db82f94f2d878f250133e8c1902..a5e256ec7be443798982062a563214e2cd67eddd 100644 (file)
@@ -14,7 +14,6 @@ import static org.junit.Assert.assertThrows;
 import static org.mockito.Mockito.when;
 
 import com.google.common.collect.ImmutableClassToInstanceMap;
-import java.io.FileNotFoundException;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -27,7 +26,6 @@ import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
 import org.opendaylight.mdsal.dom.broker.DOMMountPointServiceImpl;
 import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfSchemaService;
 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.SchemaExportContext;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
@@ -69,12 +67,11 @@ public class RestconfSchemaServiceTest {
     private DOMYangTextSourceProvider mockSourceProvider;
 
     @BeforeClass
-    public static void beforeClass() throws FileNotFoundException {
-        SCHEMA_CONTEXT = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules"));
-        SCHEMA_CONTEXT_BEHIND_MOUNT_POINT = YangParserTestUtils.parseYangFiles(
-            TestRestconfUtils.loadFiles("/modules/modules-behind-mount-point"));
-        SCHEMA_CONTEXT_WITH_MOUNT_POINTS = YangParserTestUtils.parseYangFiles(
-            TestRestconfUtils.loadFiles("/modules/mount-points"));
+    public static void beforeClass() {
+        SCHEMA_CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/modules");
+        SCHEMA_CONTEXT_BEHIND_MOUNT_POINT =
+            YangParserTestUtils.parseYangResourceDirectory("/modules/modules-behind-mount-point");
+        SCHEMA_CONTEXT_WITH_MOUNT_POINTS = YangParserTestUtils.parseYangResourceDirectory("/modules/mount-points");
     }
 
     @AfterClass
index fc06fbef815016458a415e00f897e65630701533..6a6aae3dcabf654563fa31a2b7df4a094312238a 100644 (file)
@@ -14,7 +14,6 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
 import com.google.common.collect.ImmutableClassToInstanceMap;
-import java.io.FileNotFoundException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Map;
@@ -34,7 +33,6 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
 import org.opendaylight.mdsal.dom.api.DOMNotificationService;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.databind.DatabindContext;
 import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
@@ -54,10 +52,11 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 @RunWith(MockitoJUnitRunner.StrictStubs.class)
 public class RestconfStreamsSubscriptionServiceImplTest {
-
     private static final String URI = "/rests/data/ietf-restconf-monitoring:restconf-state/streams/stream/"
             + "toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE";
 
+    private static EffectiveModelContext MODEL_CONTEXT;
+
     @Mock
     private DOMDataBroker dataBroker;
     @Mock
@@ -68,11 +67,15 @@ public class RestconfStreamsSubscriptionServiceImplTest {
     private StreamsConfiguration configurationWs;
     private StreamsConfiguration configurationSse;
 
-    private EffectiveModelContext modelContext;
     private DatabindProvider databindProvider;
 
+    @BeforeClass
+    public static void beforeClass() {
+        MODEL_CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/notifications");
+    }
+
     @Before
-    public void setUp() throws FileNotFoundException, URISyntaxException {
+    public void setUp() throws URISyntaxException {
         final DOMDataTreeWriteTransaction wTx = mock(DOMDataTreeWriteTransaction.class);
         doReturn(wTx).when(dataBroker).newWriteOnlyTransaction();
         doReturn(CommitInfo.emptyFluentFuture()).when(wTx).commit();
@@ -88,8 +91,7 @@ public class RestconfStreamsSubscriptionServiceImplTest {
         doReturn(UriBuilder.fromUri("http://localhost:8181")).when(uriInfo).getBaseUriBuilder();
         doReturn(new URI("http://127.0.0.1/" + URI)).when(uriInfo).getAbsolutePath();
 
-        modelContext = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/notifications"));
-        databindProvider = () -> DatabindContext.ofModel(modelContext);
+        databindProvider = () -> DatabindContext.ofModel(MODEL_CONTEXT);
         configurationWs = new StreamsConfiguration(0, 100, 10, false);
         configurationSse = new StreamsConfiguration(0, 100, 10, true);
     }
@@ -112,7 +114,7 @@ public class RestconfStreamsSubscriptionServiceImplTest {
     @Test
     public void testSubscribeToStreamSSE() {
         ListenersBroker.getInstance().registerDataChangeListener(
-                IdentifierCodec.deserialize("toaster:toaster/toasterStatus", modelContext),
+                IdentifierCodec.deserialize("toaster:toaster/toasterStatus", MODEL_CONTEXT),
                 "data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
                 NotificationOutputType.XML);
         final RestconfStreamsSubscriptionServiceImpl streamsSubscriptionService =
@@ -129,7 +131,7 @@ public class RestconfStreamsSubscriptionServiceImplTest {
     @Test
     public void testSubscribeToStreamWS() {
         ListenersBroker.getInstance().registerDataChangeListener(
-                IdentifierCodec.deserialize("toaster:toaster/toasterStatus", modelContext),
+                IdentifierCodec.deserialize("toaster:toaster/toasterStatus", MODEL_CONTEXT),
                 "data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
                 NotificationOutputType.XML);
         final RestconfStreamsSubscriptionServiceImpl streamsSubscriptionService =
index b9d54cd174ad2f853a2fb73b83dfbf8e954c62aa..5c9e2e524fd8ce19a8a378ba8f60420614ebc5f7 100644 (file)
@@ -27,7 +27,6 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
 import org.opendaylight.netconf.dom.api.NetconfDataTreeService;
 import org.opendaylight.restconf.api.query.ContentParam;
 import org.opendaylight.restconf.api.query.WithDefaultsParam;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy;
@@ -184,14 +183,13 @@ public class ReadDataTransactionUtilTest {
     private EffectiveModelContext schemaContext;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         // FIXME: these tests need to be parameterized somehow. The trouble is we need mocking before we invoke
         //        the strategy. This needs some more thought.
         doReturn(read).when(mockDataBroker).newReadOnlyTransaction();
         mdsalStrategy = new MdsalRestconfStrategy(mockDataBroker);
         netconfStrategy = new NetconfRestconfStrategy(netconfService);
-        schemaContext = YangParserTestUtils.parseYangFiles(
-                TestRestconfUtils.loadFiles("/modules"));
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/modules");
     }
 
     @Test
index 7b0c210cc3e88325d942f8ef99fb28bb1d1abc48..a5493940be5605b53af1529e7b7a6b4b7faabfd2 100644 (file)
@@ -20,14 +20,12 @@ import org.opendaylight.restconf.api.query.FieldsParam;
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.nb.rfc8040.AbstractJukeboxTest;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
 import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
@@ -124,19 +122,16 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
     protected static final QName EPSILON_Q_NAME = QName.create(Q_NAME_MODULE_FOO, "epsilon");
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         identifierJukebox = InstanceIdentifierContext.ofStack(
             SchemaInferenceStack.ofDataTreePath(JUKEBOX_SCHEMA, JUKEBOX_Q_NAME));
 
-        final EffectiveModelContext schemaContextTestServices =
-                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/test-services"));
         identifierTestServices = InstanceIdentifierContext.ofStack(
-            SchemaInferenceStack.ofDataTreePath(schemaContextTestServices, TEST_DATA_Q_NAME));
+            SchemaInferenceStack.ofDataTreePath(YangParserTestUtils.parseYangResourceDirectory("/test-services"),
+                TEST_DATA_Q_NAME));
 
-        final EffectiveModelContext schemaContextFoo =
-            YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/same-qname-nodes"));
-        identifierFoo = InstanceIdentifierContext.ofStack(
-            SchemaInferenceStack.ofDataTreePath(schemaContextFoo, FOO_Q_NAME));
+        identifierFoo = InstanceIdentifierContext.ofStack(SchemaInferenceStack.ofDataTreePath(
+            YangParserTestUtils.parseYangResourceDirectory("/same-qname-nodes"), FOO_Q_NAME));
     }
 
     protected abstract List<T> translateFields(InstanceIdentifierContext context, FieldsParam fields);
index 8d259b45ffe143361fdfced6b3c54850bd785b48..8dc4ebb9d9e7f02498e0461d30876fc36a0b1e4b 100644 (file)
@@ -5,16 +5,13 @@
  * 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.restconf.nb.rfc8040.utils.parser;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import java.io.FileNotFoundException;
-import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -23,16 +20,15 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
  * Unit tests for {@link IdentifierCodec} mostly according to examples from draft-ietf-netconf-restconf-13.
  */
 public class IdentifierCodecTest {
-
     private static final String URI_WITH_LIST_AND_LEAF =
             "list-test:top/list1=%2C%27" + '"' + "%3A" + '"' + "%20%2F,,foo/list2=a,b/result";
     private static final String URI_WITH_INT_VAL_LEAF_LIST = "list-test:top/Y=4";
 
-    private EffectiveModelContext schemaContext;
+    private static EffectiveModelContext SCHEMA_CONTEXT;
 
-    @Before
-    public void init() throws FileNotFoundException {
-        this.schemaContext = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/parser"));
+    @BeforeClass
+    public static void beforeClass() {
+        SCHEMA_CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/restconf/parser");
     }
 
     /**
@@ -43,8 +39,8 @@ public class IdentifierCodecTest {
     @Test
     public void codecListAndLeafTest() {
         final YangInstanceIdentifier dataYangII = IdentifierCodec.deserialize(
-                IdentifierCodecTest.URI_WITH_LIST_AND_LEAF, this.schemaContext);
-        final String serializedDataYangII = IdentifierCodec.serialize(dataYangII, this.schemaContext);
+                IdentifierCodecTest.URI_WITH_LIST_AND_LEAF, SCHEMA_CONTEXT);
+        final String serializedDataYangII = IdentifierCodec.serialize(dataYangII, SCHEMA_CONTEXT);
 
         assertEquals("Failed codec deserialization and serialization test",
                 IdentifierCodecTest.URI_WITH_LIST_AND_LEAF, serializedDataYangII);
@@ -58,8 +54,8 @@ public class IdentifierCodecTest {
     @Test
     public void codecLeafListTest() {
         final YangInstanceIdentifier dataYangII = IdentifierCodec.deserialize(
-                IdentifierCodecTest.URI_WITH_INT_VAL_LEAF_LIST, this.schemaContext);
-        final String serializedDataYangII = IdentifierCodec.serialize(dataYangII, this.schemaContext);
+                IdentifierCodecTest.URI_WITH_INT_VAL_LEAF_LIST, SCHEMA_CONTEXT);
+        final String serializedDataYangII = IdentifierCodec.serialize(dataYangII, SCHEMA_CONTEXT);
 
         assertEquals("Failed codec deserialization and serialization test",
                 IdentifierCodecTest.URI_WITH_INT_VAL_LEAF_LIST, serializedDataYangII);
@@ -72,7 +68,7 @@ public class IdentifierCodecTest {
      */
     @Test
     public void codecDeserializeNullTest() {
-        final YangInstanceIdentifier dataYangII = IdentifierCodec.deserialize(null, this.schemaContext);
+        final YangInstanceIdentifier dataYangII = IdentifierCodec.deserialize(null, SCHEMA_CONTEXT);
         assertEquals("Failed codec deserialization test", YangInstanceIdentifier.of(), dataYangII);
     }
 
@@ -82,7 +78,7 @@ public class IdentifierCodecTest {
      */
     @Test
     public void codecSerializeEmptyTest() {
-        final String serialized = IdentifierCodec.serialize(YangInstanceIdentifier.of(), this.schemaContext);
+        final String serialized = IdentifierCodec.serialize(YangInstanceIdentifier.of(), SCHEMA_CONTEXT);
         assertTrue("Failed codec serialization test", serialized.isEmpty());
     }
 
@@ -92,8 +88,8 @@ public class IdentifierCodecTest {
      */
     @Test
     public void codecDeserializeAndSerializeEmptyTest() {
-        final String serialized = IdentifierCodec.serialize(YangInstanceIdentifier.of(), this.schemaContext);
+        final String serialized = IdentifierCodec.serialize(YangInstanceIdentifier.of(), SCHEMA_CONTEXT);
         assertEquals("Failed codec serialization and deserialization test",
-                YangInstanceIdentifier.of(), IdentifierCodec.deserialize(serialized, this.schemaContext));
+                YangInstanceIdentifier.of(), IdentifierCodec.deserialize(serialized, SCHEMA_CONTEXT));
     }
 }
index 815f01b4ac7bc8b38d0fca89507ebf2ad2ec7cb4..0736598a4a3233fb97d27b6299b4a96cafac1268 100644 (file)
@@ -14,7 +14,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThrows;
 
 import com.google.common.collect.ImmutableMap;
-import java.io.FileNotFoundException;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -24,7 +23,6 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
 import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -50,9 +48,8 @@ public class YangInstanceIdentifierDeserializerTest {
     private static EffectiveModelContext SCHEMA_CONTEXT;
 
     @BeforeClass
-    public static void beforeClass() throws FileNotFoundException {
-        SCHEMA_CONTEXT =
-                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/parser/deserializer"));
+    public static void beforeClass() {
+        SCHEMA_CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/restconf/parser/deserializer");
     }
 
     @AfterClass
index 6687b5f0816ea83c6cc0d33044561ad7c8b2a627..10b9a564efbf309e615326283194ea72a4e4cfbc 100644 (file)
@@ -17,7 +17,6 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -33,8 +32,8 @@ public class YangInstanceIdentifierSerializerTest {
     private static EffectiveModelContext SCHEMA_CONTEXT;
 
     @BeforeClass
-    public static void beforeClass() throws Exception {
-        SCHEMA_CONTEXT = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/parser/serializer"));
+    public static void beforeClass() {
+        SCHEMA_CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/restconf/parser/serializer");
     }
 
     @AfterClass