Search in sources :

Example 6 with SharedSchemaRepository

use of org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository in project netconf by opendaylight.

the class NetconfNodeActorTest method testMissingSchemaSourceOnMissingProvider.

@Test(expected = MissingSchemaSourceException.class)
public void testMissingSchemaSourceOnMissingProvider() throws Exception {
    final SharedSchemaRepository repository = new SharedSchemaRepository("test");
    SchemaResourcesDTO schemaResourceDTO2 = mock(SchemaResourcesDTO.class);
    doReturn(repository).when(schemaResourceDTO2).getSchemaRegistry();
    doReturn(repository).when(schemaResourceDTO2).getSchemaRepository();
    final NetconfTopologySetup setup = NetconfTopologySetupBuilder.create().setActorSystem(system).setSchemaResourceDTO(schemaResourceDTO2).setIdleTimeout(Duration.apply(1, TimeUnit.SECONDS)).setBaseSchemas(BASE_SCHEMAS).build();
    final Props props = NetconfNodeActor.props(setup, remoteDeviceId, TIMEOUT, mockMountPointService);
    ActorRef actor = TestActorRef.create(system, props, "master_messages_2");
    final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("testID");
    final ProxyYangTextSourceProvider proxyYangProvider = new ProxyYangTextSourceProvider(actor, system.dispatcher(), TIMEOUT);
    final Future<YangTextSchemaSourceSerializationProxy> resolvedSchemaFuture = proxyYangProvider.getYangTextSchemaSource(sourceIdentifier);
    Await.result(resolvedSchemaFuture, TIMEOUT.duration());
}
Also used : ActorRef(akka.actor.ActorRef) TestActorRef(akka.testkit.TestActorRef) SourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier) RevisionSourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier) YangTextSchemaSourceSerializationProxy(org.opendaylight.controller.cluster.schema.provider.impl.YangTextSchemaSourceSerializationProxy) Props(akka.actor.Props) SharedSchemaRepository(org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository) SchemaResourcesDTO(org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) Test(org.junit.Test)

Example 7 with SharedSchemaRepository

use of org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository in project netconf by opendaylight.

the class NetconfNodeManagerTest method setup.

@Before
public void setup() {
    final Timeout responseTimeout = Timeout.apply(1, TimeUnit.SECONDS);
    slaveSystem = ActorSystem.create(ACTOR_SYSTEM_NAME, ConfigFactory.load().getConfig("Slave"));
    masterSystem = ActorSystem.create(ACTOR_SYSTEM_NAME, ConfigFactory.load().getConfig("Master"));
    masterAddress = Cluster.get(masterSystem).selfAddress().toString();
    SharedSchemaRepository masterSchemaRepository = new SharedSchemaRepository("master");
    masterSchemaRepository.registerSchemaSourceListener(TextToIRTransformer.create(masterSchemaRepository, masterSchemaRepository));
    String yangTemplate = "module ID {" + "  namespace \"ID\";" + "  prefix ID;" + "}";
    SOURCE_IDENTIFIERS.stream().map(sourceId -> masterSchemaRepository.registerSchemaSource(id -> Futures.immediateFuture(YangTextSchemaSource.delegateForByteSource(id, ByteSource.wrap(yangTemplate.replaceAll("ID", id.getName()).getBytes(UTF_8)))), PotentialSchemaSource.create(sourceId, YangTextSchemaSource.class, 1))).collect(Collectors.toList());
    NetconfTopologySetup masterSetup = new NetconfTopologySetup.NetconfTopologySetupBuilder().setActorSystem(masterSystem).setDataBroker(mockDataBroker).setSchemaResourceDTO(new NetconfDevice.SchemaResourcesDTO(masterSchemaRepository, masterSchemaRepository, mockSchemaContextFactory, mockSchemasResolver)).setBaseSchemas(BASE_SCHEMAS).build();
    testMasterActorRef = TestActorRef.create(masterSystem, Props.create(TestMasterActor.class, masterSetup, DEVICE_ID, responseTimeout, mockMountPointService).withDispatcher(Dispatchers.DefaultDispatcherId()), NetconfTopologyUtils.createMasterActorName(DEVICE_ID.getName(), masterAddress));
    SharedSchemaRepository slaveSchemaRepository = new SharedSchemaRepository("slave");
    slaveSchemaRepository.registerSchemaSourceListener(TextToIRTransformer.create(slaveSchemaRepository, slaveSchemaRepository));
    NetconfTopologySetup slaveSetup = new NetconfTopologySetup.NetconfTopologySetupBuilder().setActorSystem(slaveSystem).setDataBroker(mockDataBroker).setSchemaResourceDTO(new NetconfDevice.SchemaResourcesDTO(slaveSchemaRepository, slaveSchemaRepository, mockSchemaContextFactory, mockSchemasResolver)).setBaseSchemas(BASE_SCHEMAS).build();
    netconfNodeManager = new NetconfNodeManager(slaveSetup, DEVICE_ID, responseTimeout, mockMountPointService);
    setupMountPointMocks();
}
Also used : YangTextSchemaSourceRequest(org.opendaylight.netconf.topology.singleton.messages.YangTextSchemaSourceRequest) NetconfDataTreeService(org.opendaylight.netconf.dom.api.NetconfDataTreeService) NetconfDevice(org.opendaylight.netconf.sal.connect.netconf.NetconfDevice) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) EffectiveModelContextFactory(org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory) TimeoutException(java.util.concurrent.TimeoutException) ListenerRegistration(org.opendaylight.yangtools.concepts.ListenerRegistration) NetconfNode(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode) WRITE(org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.WRITE) ClusteredConnectionStatusBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.ClusteredConnectionStatusBuilder) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) Cluster(akka.cluster.Cluster) NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) ObjectRegistration(org.opendaylight.yangtools.concepts.ObjectRegistration) Map(java.util.Map) After(org.junit.After) Mockito.after(org.mockito.Mockito.after) Mockito.doReturn(org.mockito.Mockito.doReturn) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) Dispatchers(akka.dispatch.Dispatchers) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) DOMActionService(org.opendaylight.mdsal.dom.api.DOMActionService) DELETE(org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.DELETE) RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Uint16(org.opendaylight.yangtools.yang.common.Uint16) Mockito.doNothing(org.mockito.Mockito.doNothing) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) NetconfNodeConnectionStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus) List(java.util.List) DOMDataBroker(org.opendaylight.mdsal.dom.api.DOMDataBroker) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) ActorSystem(akka.actor.ActorSystem) PotentialSchemaSource(org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource) NetconfNodeActor(org.opendaylight.netconf.topology.singleton.impl.actors.NetconfNodeActor) CreateInitialMasterActorData(org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData) Props(akka.actor.Props) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) AskForMasterMountPoint(org.opendaylight.netconf.topology.singleton.messages.AskForMasterMountPoint) Iterables(com.google.common.collect.Iterables) Mock(org.mockito.Mock) SharedSchemaRepository(org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository) RunWith(org.junit.runner.RunWith) CompletableFuture(java.util.concurrent.CompletableFuture) DataTreeIdentifier(org.opendaylight.mdsal.binding.api.DataTreeIdentifier) DOMMountPointService(org.opendaylight.mdsal.dom.api.DOMMountPointService) Timeout(akka.util.Timeout) Mockito.timeout(org.mockito.Mockito.timeout) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ImmutableList(com.google.common.collect.ImmutableList) Host(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host) ConfigFactory(com.typesafe.config.ConfigFactory) DOMNotificationService(org.opendaylight.mdsal.dom.api.DOMNotificationService) ByteSource(com.google.common.io.ByteSource) DataObjectModification(org.opendaylight.mdsal.binding.api.DataObjectModification) Before(org.junit.Before) SUBTREE_MODIFIED(org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.SUBTREE_MODIFIED) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) SourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier) TextToIRTransformer(org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer) UTF_8(java.nio.charset.StandardCharsets.UTF_8) DOMRpcService(org.opendaylight.mdsal.dom.api.DOMRpcService) Test(org.junit.Test) TestKit(akka.testkit.javadsl.TestKit) TestActorRef(akka.testkit.TestActorRef) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) Futures(com.google.common.util.concurrent.Futures) NetconfDeviceSchemasResolver(org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemasResolver) NetconfTopologyUtils(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RevisionSourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) MasterActorDataInitialized(org.opendaylight.netconf.topology.singleton.messages.MasterActorDataInitialized) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) Mockito.reset(org.mockito.Mockito.reset) Collections(java.util.Collections) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) NetconfDevice(org.opendaylight.netconf.sal.connect.netconf.NetconfDevice) Timeout(akka.util.Timeout) SharedSchemaRepository(org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) Before(org.junit.Before)

Aggregations

SharedSchemaRepository (org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository)7 YangTextSchemaSource (org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource)5 Test (org.junit.Test)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 ExecutionException (java.util.concurrent.ExecutionException)3 RevisionSourceIdentifier (org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier)3 SourceIdentifier (org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier)3 PotentialSchemaSource (org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource)3 TextToIRTransformer (org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer)3 Props (akka.actor.Props)2 TestActorRef (akka.testkit.TestActorRef)2 InetSocketAddress (java.net.InetSocketAddress)2 NetconfTopologySetup (org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup)2 ActorRef (akka.actor.ActorRef)1 ActorSystem (akka.actor.ActorSystem)1 Cluster (akka.cluster.Cluster)1 Dispatchers (akka.dispatch.Dispatchers)1 TestKit (akka.testkit.javadsl.TestKit)1