Convert blueprint ext classes to MDSAL APIs
[controller.git] / opendaylight / blueprint / src / test / java / org / opendaylight / controller / blueprint / tests / DataStoreAppConfigDefaultXMLReaderTest.java
1 /*
2  * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.blueprint.tests;
9
10 import static com.google.common.truth.Truth.assertThat;
11
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;
17
18 /**
19  * Example unit test using the {@link DataStoreAppConfigDefaultXMLReader}.
20  *
21  * @author Michael Vorburger.ch
22  */
23 public class DataStoreAppConfigDefaultXMLReaderTest extends AbstractConcurrentDataBrokerTest {
24
25     @Test
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();
32
33         UnorderedList element = lists.getUnorderedContainer().getUnorderedList().get(0);
34         assertThat(element.getName()).isEqualTo("someName");
35         assertThat(element.getValue()).isEqualTo("someValue");
36     }
37
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();
45     }
46 }