2 * Copyright (c) 2017 Red Hat, 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.controller.blueprint.tests;
10 import static com.google.common.truth.Truth.assertThat;
12 import org.junit.Test;
13 import org.opendaylight.controller.blueprint.ext.DataStoreAppConfigDefaultXMLReader;
14 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList;
19 * Example unit test using the {@link DataStoreAppConfigDefaultXMLReader}.
21 * @author Michael Vorburger.ch
23 public class DataStoreAppConfigDefaultXMLReaderTest extends AbstractConcurrentDataBrokerTest {
26 public void testConfigXML() throws Exception {
27 Lists lists = new DataStoreAppConfigDefaultXMLReader<>(
28 getClass(), "/opendaylight-sal-test-store-config.xml",
29 getDataBrokerTestCustomizer().getSchemaService(),
30 getDataBrokerTestCustomizer().getBindingToNormalized(),
31 Lists.class).createDefaultInstance();
33 UnorderedList element = lists.getUnorderedContainer().getUnorderedList().get(0);
34 assertThat(element.getName()).isEqualTo("someName");
35 assertThat(element.getValue()).isEqualTo("someValue");
38 @Test(expected = IllegalArgumentException.class)
39 public void testBadXMLName() throws Exception {
40 new DataStoreAppConfigDefaultXMLReader<>(
41 getClass(), "/badname.xml",
42 getDataBrokerTestCustomizer().getSchemaService(),
43 getDataBrokerTestCustomizer().getBindingToNormalized(),
44 Lists.class).createDefaultInstance();