Search in sources :

Example 1 with EffectiveModelContextListener

use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener in project netconf by opendaylight.

the class RuntimeRpcTest method setUp.

@Before
public void setUp() throws Exception {
    doNothing().when(registration).close();
    doAnswer(invocationOnMock -> {
        ((EffectiveModelContextListener) invocationOnMock.getArguments()[0]).onModelContextUpdated(SCHEMA_CONTEXT);
        return registration;
    }).when(schemaService).registerSchemaContextListener(any(EffectiveModelContextListener.class));
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    doAnswer(invocationOnMock -> {
        final SourceIdentifier sId = (SourceIdentifier) invocationOnMock.getArguments()[0];
        final YangTextSchemaSource yangTextSchemaSource = YangTextSchemaSource.delegateForByteSource(sId, ByteSource.wrap("module test".getBytes()));
        return immediateFluentFuture(yangTextSchemaSource);
    }).when(sourceProvider).getSource(any(SourceIdentifier.class));
    this.currentSchemaContext = new CurrentSchemaContext(schemaService, sourceProvider);
}
Also used : YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) SourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier) CurrentSchemaContext(org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext) EffectiveModelContextListener(org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener) Before(org.junit.Before)

Example 2 with EffectiveModelContextListener

use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener in project mdsal by opendaylight.

the class DOMRpcRouterTest method testClose.

@Test
public void testClose() {
    final ListenerRegistration<EffectiveModelContextListener> reg = mock(ListenerRegistration.class);
    doNothing().when(reg).close();
    final DOMSchemaService schema = mock(DOMSchemaService.class);
    doReturn(reg).when(schema).registerSchemaContextListener(any());
    final DOMRpcRouter rpcRouter = new DOMRpcRouter(schema);
    rpcRouter.close();
    final DOMRpcProviderService svc = rpcRouter.getRpcProviderService();
    assertThrows(RejectedExecutionException.class, () -> svc.registerRpcImplementation(getTestRpcImplementation(), DOMRpcIdentifier.create(Rpcs.FOO, null)));
}
Also used : DOMRpcProviderService(org.opendaylight.mdsal.dom.api.DOMRpcProviderService) EffectiveModelContextListener(org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener) DOMSchemaService(org.opendaylight.mdsal.dom.api.DOMSchemaService) Test(org.junit.Test)

Aggregations

EffectiveModelContextListener (org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener)2 Before (org.junit.Before)1 Test (org.junit.Test)1 DOMRpcProviderService (org.opendaylight.mdsal.dom.api.DOMRpcProviderService)1 DOMSchemaService (org.opendaylight.mdsal.dom.api.DOMSchemaService)1 CurrentSchemaContext (org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext)1 SourceIdentifier (org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier)1 YangTextSchemaSource (org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource)1