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 org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertThrows;
13 import org.junit.Test;
14 import org.opendaylight.controller.blueprint.ext.DataStoreAppConfigDefaultXMLReader;
15 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList;
20 * Example unit test using the {@link DataStoreAppConfigDefaultXMLReader}.
22 * @author Michael Vorburger.ch
24 public class DataStoreAppConfigDefaultXMLReaderTest extends AbstractConcurrentDataBrokerTest {
26 public void testConfigXML() throws Exception {
27 Lists lists = new DataStoreAppConfigDefaultXMLReader<>(getClass(), "/opendaylight-sal-test-store-config.xml",
28 getDataBrokerTestCustomizer().getSchemaService(),
29 getDataBrokerTestCustomizer().getAdapterContext().currentSerializer(), Lists.class)
30 .createDefaultInstance();
32 UnorderedList element = lists.getUnorderedContainer().getUnorderedList().values().iterator().next();
33 assertEquals("someName", element.getName());
34 assertEquals("someValue", element.getValue());
38 public void testBadXMLName() throws Exception {
39 final var reader = new DataStoreAppConfigDefaultXMLReader<>(getClass(), "/badname.xml",
40 getDataBrokerTestCustomizer().getSchemaService(),
41 getDataBrokerTestCustomizer().getAdapterContext().currentSerializer(), Lists.class);
43 final String message = assertThrows(IllegalArgumentException.class, reader::createDefaultInstance).getMessage();
44 assertEquals("resource /badname.xml relative to " + DataStoreAppConfigDefaultXMLReaderTest.class.getName()
45 + " not found.", message);