Search in sources :

Example 1 with UnorderedList

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;
}
Also used : Lists(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists) UnorderedList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList) UnorderedListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey)

Example 2 with UnorderedList

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");
}
Also used : Lists(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists) UnorderedList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList) AbstractConcurrentDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 3 with UnorderedList

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();
}
Also used : RoutedSimpleRouteInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder)

Example 4 with UnorderedList

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);
}
Also used : OpendaylightTestRoutedRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.OpendaylightTestRoutedRpcService) UnorderedListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Assert.assertNotSame(org.junit.Assert.assertNotSame) LoggerFactory(org.slf4j.LoggerFactory) ProviderContext(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext) Lists(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists) Assert.assertSame(org.junit.Assert.assertSame) Before(org.junit.Before) UnorderedList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList) Logger(org.slf4j.Logger) Assert.assertNotNull(org.junit.Assert.assertNotNull) OpendaylightTestRoutedRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.OpendaylightTestRoutedRpcService) RoutedSimpleRouteInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder) RoutedRpcRegistration(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) UnorderedContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.UnorderedContainer) Mockito.verify(org.mockito.Mockito.verify) BindingAwareConsumer(org.opendaylight.controller.sal.binding.api.BindingAwareConsumer) Mockito(org.mockito.Mockito) Futures(com.google.common.util.concurrent.Futures) BindingAwareProvider(org.opendaylight.controller.sal.binding.api.BindingAwareProvider) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TestContext(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.TestContext) RoutedSimpleRouteInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput) Mockito.mock(org.mockito.Mockito.mock) ProviderContext(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext) BindingAwareProvider(org.opendaylight.controller.sal.binding.api.BindingAwareProvider) UnorderedList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList) RoutedSimpleRouteInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput) BindingAwareConsumer(org.opendaylight.controller.sal.binding.api.BindingAwareConsumer) Test(org.junit.Test)

Example 5 with UnorderedList

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());
}
Also used : UnorderedListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey) UnorderedList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList) Assert.assertNotNull(org.junit.Assert.assertNotNull) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UnorderedContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.UnorderedContainer) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Lists(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists) TimeUnit(java.util.concurrent.TimeUnit) BindingAwareConsumer(org.opendaylight.controller.sal.binding.api.BindingAwareConsumer) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(com.google.common.base.Optional) UnorderedListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListBuilder) Assert.assertEquals(org.junit.Assert.assertEquals) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) UnorderedList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList) BindingAwareConsumer(org.opendaylight.controller.sal.binding.api.BindingAwareConsumer) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Test(org.junit.Test)

Aggregations

Lists (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists)4 UnorderedList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList)4 UnorderedListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey)4 Test (org.junit.Test)3 Assert.assertNotNull (org.junit.Assert.assertNotNull)2 BindingAwareConsumer (org.opendaylight.controller.sal.binding.api.BindingAwareConsumer)2 RoutedSimpleRouteInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder)2 UnorderedContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.UnorderedContainer)2 UnorderedListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListBuilder)2 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)2 Optional (com.google.common.base.Optional)1 Futures (com.google.common.util.concurrent.Futures)1 TimeUnit (java.util.concurrent.TimeUnit)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertNotSame (org.junit.Assert.assertNotSame)1 Assert.assertSame (org.junit.Assert.assertSame)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Before (org.junit.Before)1 Mockito (org.mockito.Mockito)1