X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=apps%2Fyanglib-mdsal-writer%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fyanglib%2Fwriter%2FYangLibraryWriterSingletonIntegrationTest.java;fp=apps%2Fyanglib-mdsal-writer%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fyanglib%2Fwriter%2FYangLibraryWriterSingletonIntegrationTest.java;h=67ca8cd5a5d0dd6ffb995f12348a183e8e5dd20d;hb=868c2eca15f8345ddabdb6da5fa4e299a3660e66;hp=0000000000000000000000000000000000000000;hpb=d22a35d360f5f059ffdcbb4bdd700a42518d1044;p=netconf.git diff --git a/apps/yanglib-mdsal-writer/src/test/java/org/opendaylight/netconf/yanglib/writer/YangLibraryWriterSingletonIntegrationTest.java b/apps/yanglib-mdsal-writer/src/test/java/org/opendaylight/netconf/yanglib/writer/YangLibraryWriterSingletonIntegrationTest.java new file mode 100644 index 0000000000..67ca8cd5a5 --- /dev/null +++ b/apps/yanglib-mdsal-writer/src/test/java/org/opendaylight/netconf/yanglib/writer/YangLibraryWriterSingletonIntegrationTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 PANTHEON.tech, s.r.o. 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.netconf.yanglib.writer; + +import static org.awaitility.Awaitility.await; + +import java.time.Duration; +import org.junit.Test; +import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; +import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService; +import org.opendaylight.mdsal.eos.dom.simple.SimpleDOMEntityOwnershipService; +import org.opendaylight.mdsal.singleton.impl.EOSClusterSingletonServiceProvider; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.YangLibrary; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class YangLibraryWriterSingletonIntegrationTest extends AbstractConcurrentDataBrokerTest { + private final DOMEntityOwnershipService eos = new SimpleDOMEntityOwnershipService(); + + @Test + public void testIntegrationNoLegacy() throws Exception { + testIntegration(false); + } + + @Test + public void testIntegrationLegacy() throws Exception { + testIntegration(true); + } + + private void testIntegration(final boolean writeLegacy) throws Exception { + try (var cssProvider = new EOSClusterSingletonServiceProvider(eos)) { + try (var singleton = new YangLibraryWriterSingleton(cssProvider, new FixedDOMSchemaService(modelContext()), + getDataBroker(), writeLegacy)) { + await().atMost(Duration.ofSeconds(5)).until(this::yangLibraryExists); + } + await().atMost(Duration.ofSeconds(5)).until(() -> !yangLibraryExists()); + } + } + + private boolean yangLibraryExists() throws Exception { + try (var tx = getDataBroker().newReadOnlyTransaction()) { + return tx.exists(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(YangLibrary.class)).get(); + } + } +}