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;
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;
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
* <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",
@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();
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;
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
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;
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;
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);
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;
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();
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;
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
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;
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;
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
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;
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;
@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
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();
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);
}
@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 =
@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 =
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;
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
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;
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);
* 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;
* 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");
}
/**
@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);
@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);
*/
@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);
}
*/
@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());
}
*/
@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));
}
}
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;
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;
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
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;
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