X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fblueprint%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fblueprint%2Ftests%2FDataStoreAppConfigDefaultXMLReaderTest.java;fp=opendaylight%2Fblueprint%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fblueprint%2Ftests%2FDataStoreAppConfigDefaultXMLReaderTest.java;h=46bd69966892b80fabd13372996fac0eadc5a4f9;hp=0000000000000000000000000000000000000000;hb=821944277049bbb3949021626844ef7a80101f70;hpb=3488960e844918404db473ee684661f98dab3563 diff --git a/opendaylight/blueprint/src/test/java/org/opendaylight/controller/blueprint/tests/DataStoreAppConfigDefaultXMLReaderTest.java b/opendaylight/blueprint/src/test/java/org/opendaylight/controller/blueprint/tests/DataStoreAppConfigDefaultXMLReaderTest.java new file mode 100644 index 0000000000..46bd699668 --- /dev/null +++ b/opendaylight/blueprint/src/test/java/org/opendaylight/controller/blueprint/tests/DataStoreAppConfigDefaultXMLReaderTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017 Red Hat, 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.blueprint.tests; + +import static com.google.common.truth.Truth.assertThat; + +import org.junit.Test; +import org.opendaylight.controller.blueprint.ext.DataStoreAppConfigDefaultXMLReader; +import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList; + +/** + * Example unit test using the {@link DataStoreAppConfigDefaultXMLReader}. + * + * @author Michael Vorburger.ch + */ +public class DataStoreAppConfigDefaultXMLReaderTest extends AbstractConcurrentDataBrokerTest { + + @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"); + } + + @Test(expected = IllegalArgumentException.class) + public void testBadXMLName() throws Exception { + new DataStoreAppConfigDefaultXMLReader<>( + getClass(), "/badname.xml", + getDataBrokerTestCustomizer().getSchemaService(), + getDataBrokerTestCustomizer().getBindingToNormalized(), + Lists.class).createDefaultInstance(); + } +}