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());
}
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();
}
Aggregations