use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList in project controller by opendaylight.
the class RoutedServiceIT method createNodeRef.
/**
* Returns node reference from string which represents path
*
* @param string
* string with key(path)
* @return instance identifier to {@link UnorderedList}
*/
private static InstanceIdentifier<UnorderedList> createNodeRef(final String string) {
final UnorderedListKey key = new UnorderedListKey(string);
final InstanceIdentifier<UnorderedList> path = InstanceIdentifier.builder(Lists.class).child(UnorderedContainer.class).child(UnorderedList.class, key).build();
return path;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList in project controller by opendaylight.
the class DataStoreAppConfigDefaultXMLReaderTest method testConfigXML.
@Test
public void testConfigXML() throws Exception {
Lists lists = new DataStoreAppConfigDefaultXMLReader<>(getClass(), "/opendaylight-sal-test-store-config.xml", getDataBrokerTestCustomizer().getSchemaService(), getDataBrokerTestCustomizer().getBindingToNormalized(), Lists.class).createDefaultInstance();
UnorderedList element = lists.getUnorderedContainer().getUnorderedList().get(0);
assertThat(element.getName()).isEqualTo("someName");
assertThat(element.getValue()).isEqualTo("someValue");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList in project controller by opendaylight.
the class RoutedServiceIT method createSimpleRouteInput.
/**
* Creates flow AddFlowInput for which only node and cookie are set
*
* @param node
* NodeRef value
* @return simpleRouteInput instance
*/
static RoutedSimpleRouteInput createSimpleRouteInput(final InstanceIdentifier<UnorderedList> node) {
final RoutedSimpleRouteInputBuilder ret = new RoutedSimpleRouteInputBuilder();
ret.setRoute(node);
return ret.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList in project controller by opendaylight.
the class RoutedServiceIT method testServiceRegistration.
@Test
public void testServiceRegistration() {
assertNotNull(broker);
final BindingAwareProvider provider1 = new AbstractTestProvider() {
@Override
public void onSessionInitiated(final ProviderContext session) {
assertNotNull(session);
firstReg = session.addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService1);
}
};
LOG.info("Register provider 1 with first implementation of routeSimpleService - service1");
broker.registerProvider(provider1);
assertNotNull("Registration should not be null", firstReg);
assertSame(odlRoutedService1, firstReg.getInstance());
final BindingAwareProvider provider2 = new AbstractTestProvider() {
@Override
public void onSessionInitiated(final ProviderContext session) {
assertNotNull(session);
secondReg = session.addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService2);
}
};
LOG.info("Register provider 2 with second implementation of routeSimpleService - service2");
broker.registerProvider(provider2);
assertNotNull("Registration should not be null", firstReg);
assertSame(odlRoutedService2, secondReg.getInstance());
assertNotSame(secondReg, firstReg);
final BindingAwareConsumer consumer = session -> consumerService = session.getRpcService(OpendaylightTestRoutedRpcService.class);
LOG.info("Register routeService consumer");
broker.registerConsumer(consumer);
assertNotNull("MD-SAL instance of test Service should be returned", consumerService);
assertNotSame("Provider instance and consumer instance should not be same.", odlRoutedService1, consumerService);
final InstanceIdentifier<UnorderedList> nodeOnePath = createNodeRef("foo:node:1");
LOG.info("Provider 1 registers path of node 1");
firstReg.registerPath(TestContext.class, nodeOnePath);
/**
* Consumer creates addFlow message for node one and sends it to the
* MD-SAL
*/
final RoutedSimpleRouteInput simpleRouteFirstFoo = createSimpleRouteInput(nodeOnePath);
consumerService.routedSimpleRoute(simpleRouteFirstFoo);
/**
* Verifies that implementation of the first provider received the same
* message from MD-SAL.
*/
verify(odlRoutedService1).routedSimpleRoute(simpleRouteFirstFoo);
/**
* Verifies that second instance was not invoked with first message
*/
verify(odlRoutedService2, times(0)).routedSimpleRoute(simpleRouteFirstFoo);
LOG.info("Provider 2 registers path of node 2");
final InstanceIdentifier<UnorderedList> nodeTwo = createNodeRef("foo:node:2");
secondReg.registerPath(TestContext.class, nodeTwo);
/**
* Consumer sends message to nodeTwo for three times. Should be
* processed by second instance.
*/
final RoutedSimpleRouteInput simpleRouteSecondFoo = createSimpleRouteInput(nodeTwo);
consumerService.routedSimpleRoute(simpleRouteSecondFoo);
consumerService.routedSimpleRoute(simpleRouteSecondFoo);
consumerService.routedSimpleRoute(simpleRouteSecondFoo);
/**
* Verifies that second instance was invoked 3 times with second message
* and first instance wasn't invoked.
*/
verify(odlRoutedService2, times(3)).routedSimpleRoute(simpleRouteSecondFoo);
verify(odlRoutedService1, times(0)).routedSimpleRoute(simpleRouteSecondFoo);
LOG.info("Unregistration of the path for the node one in the first provider");
firstReg.unregisterPath(TestContext.class, nodeOnePath);
LOG.info("Provider 2 registers path of node 1");
secondReg.registerPath(TestContext.class, nodeOnePath);
/**
* A consumer sends third message to node 1
*/
final RoutedSimpleRouteInput simpleRouteThirdFoo = createSimpleRouteInput(nodeOnePath);
consumerService.routedSimpleRoute(simpleRouteThirdFoo);
/**
* Verifies that provider 1 wasn't invoked and provider 2 was invoked 1
* time.
* TODO: fix unregister path
*/
// verify(odlRoutedService1, times(0)).routedSimpleRoute(simpleRouteThirdFoo);
verify(odlRoutedService2).routedSimpleRoute(simpleRouteThirdFoo);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList in project controller by opendaylight.
the class DataServiceIT method test.
/**
* Ignored this, because classes here are constructed from
* very different class loader as MD-SAL is run into,
* this is code is run from different classloader.
*
* @throws Exception
*/
@Test
public void test() throws Exception {
BindingAwareConsumer consumer = session -> dataBroker = session.getSALService(DataBroker.class);
broker.registerConsumer(consumer);
assertNotNull(dataBroker);
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
assertNotNull(transaction);
InstanceIdentifier<UnorderedList> node1 = createNodeRef("0");
Optional<UnorderedList> node = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).checkedGet(5, TimeUnit.SECONDS);
assertFalse(node.isPresent());
UnorderedList nodeData1 = createNode("0");
transaction.put(LogicalDatastoreType.OPERATIONAL, node1, nodeData1);
transaction.submit().checkedGet(5, TimeUnit.SECONDS);
Optional<UnorderedList> readedData = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).checkedGet(5, TimeUnit.SECONDS);
assertTrue(readedData.isPresent());
assertEquals(nodeData1.getKey(), readedData.get().getKey());
final WriteTransaction transaction2 = dataBroker.newWriteOnlyTransaction();
assertNotNull(transaction2);
transaction2.delete(LogicalDatastoreType.OPERATIONAL, node1);
transaction2.submit().checkedGet(5, TimeUnit.SECONDS);
Optional<UnorderedList> readedData2 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).checkedGet(5, TimeUnit.SECONDS);
assertFalse(readedData2.isPresent());
}
Aggregations