2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.dom.adapter;
10 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
11 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.path;
12 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList;
14 import com.google.common.collect.ImmutableSet;
16 import org.junit.Test;
17 import org.opendaylight.mdsal.binding.api.WriteTransaction;
18 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest;
19 import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
20 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
31 * Regression test suite for Bug 1125 - Can't detect switch disconnection
32 * https://bugs.opendaylight.org/show_bug.cgi?id=1125.
34 public class Bug1125RegressionTest extends AbstractDataTreeChangeListenerTest {
35 private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
36 private static final InstanceIdentifier<TopLevelList> TOP_FOO_PATH = TOP_PATH
37 .child(TopLevelList.class, TOP_FOO_KEY);
39 private static final InstanceIdentifier<TreeComplexUsesAugment> FOO_AUGMENT_PATH = TOP_FOO_PATH
40 .augmentation(TreeComplexUsesAugment.class);
42 private static final InstanceIdentifier<TreeComplexUsesAugment> WILDCARDED_AUGMENT_PATH = TOP_PATH
43 .child(TopLevelList.class).augmentation(
44 TreeComplexUsesAugment.class);
47 protected Set<YangModuleInfo> getModuleInfos() throws Exception {
48 return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class),
49 BindingReflections.getModuleInfo(TreeComplexUsesAugment.class));
53 public void deleteAndListenAugment() {
54 deleteAndListenAugment(TOP_PATH);
56 deleteAndListenAugment(TOP_FOO_PATH);
58 deleteAndListenAugment(FOO_AUGMENT_PATH);
61 private void deleteAndListenAugment(final InstanceIdentifier<?> path) {
62 TreeComplexUsesAugment augment = writeInitialState();
63 TestListener<TreeComplexUsesAugment> listener = createListener(LogicalDatastoreType.OPERATIONAL,
64 WILDCARDED_AUGMENT_PATH, added(FOO_AUGMENT_PATH, augment), deleted(FOO_AUGMENT_PATH, augment));
65 WriteTransaction tx = getDataBroker().newWriteOnlyTransaction();
66 tx.delete(LogicalDatastoreType.OPERATIONAL, path);
67 assertCommit(tx.commit());
71 private TreeComplexUsesAugment writeInitialState() {
72 WriteTransaction initialTx = getDataBroker().newWriteOnlyTransaction();
73 initialTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build());
74 TreeComplexUsesAugment fooAugment = new TreeComplexUsesAugmentBuilder()
75 .setContainerWithUses(new ContainerWithUsesBuilder().setLeafFromGrouping("foo").build())
77 initialTx.put(LogicalDatastoreType.OPERATIONAL, path(TOP_FOO_KEY), topLevelList(TOP_FOO_KEY, fooAugment));
78 assertCommit(initialTx.commit());