X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-dom-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Ftest%2Fbugfix%2FDeleteNestedAugmentationListenParentTest.java;h=213f62e8b3a011b455a42f43f2775ca17e49f337;hp=40d4591001212c05e716f9fd6b2898d37cc47267;hb=4f82c49691f091f0ba6b09a07525edb246f17321;hpb=614324d63a339ef4acbc9e2c3bbaaef469f97868 diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java index 40d4591001..213f62e8b3 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java @@ -1,13 +1,25 @@ +/* + * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.controller.sal.binding.test.bugfix; import static org.junit.Assert.assertFalse; +import com.google.common.util.concurrent.SettableFuture; import java.util.concurrent.ExecutionException; - +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; -import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; -import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugment; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugmentBuilder; @@ -23,9 +35,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import com.google.common.util.concurrent.SettableFuture; - -@SuppressWarnings("deprecation") public class DeleteNestedAugmentationListenParentTest extends AbstractDataServiceTest { private static final TopLevelListKey FOO_KEY = new TopLevelListKey("foo"); @@ -46,28 +55,23 @@ public class DeleteNestedAugmentationListenParentTest extends AbstractDataServic @Test - public void deleteChildListenParent() throws InterruptedException, ExecutionException { - DataModificationTransaction initTx = baDataService.beginTransaction(); - - initTx.putOperationalData(LIST11_PATH, createList11()); - initTx.commit().get(); - - final SettableFuture, DataObject>> event = SettableFuture.create(); + public void deleteChildListenParent() throws InterruptedException, ExecutionException, TimeoutException { + DataBroker dataBroker = testContext.getDataBroker(); + final WriteTransaction initTx = dataBroker.newWriteOnlyTransaction(); - baDataService.registerDataChangeListener(LIST11_PATH, new DataChangeListener() { + initTx.put(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, createList11(), true); + initTx.submit().get(5, TimeUnit.SECONDS); - @Override - public void onDataChanged(final DataChangeEvent, DataObject> change) { - event.set(change); - } - }); + final SettableFuture, DataObject>> event = SettableFuture.create(); + dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, + change -> event.set(change), DataChangeScope.SUBTREE); - DataModificationTransaction deleteTx = baDataService.beginTransaction(); - deleteTx.removeOperationalData(LIST11_PATH.augmentation(List11SimpleAugment.class)); - deleteTx.commit().get(); + final WriteTransaction deleteTx = dataBroker.newWriteOnlyTransaction(); + deleteTx.delete(LogicalDatastoreType.OPERATIONAL, LIST11_PATH.augmentation(List11SimpleAugment.class)); + deleteTx.submit().get(5, TimeUnit.SECONDS); - DataChangeEvent, DataObject> receivedEvent = event.get(); - assertFalse(receivedEvent.getRemovedOperationalData().contains(TLL_COMPLEX_AUGMENT_PATH)); + AsyncDataChangeEvent, DataObject> receivedEvent = event.get(); + assertFalse(receivedEvent.getRemovedPaths().contains(TLL_COMPLEX_AUGMENT_PATH)); } private List11 createList11() { @@ -79,4 +83,4 @@ public class DeleteNestedAugmentationListenParentTest extends AbstractDataServic return builder.build(); } -} \ No newline at end of file +}