2 * Copyright (c) 2016 Cisco Systems, 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
9 package org.opendaylight.protocol.bgp.config.loader.impl;
11 import static org.junit.Assert.assertNotNull;
12 import static org.mockito.Matchers.any;
13 import static org.mockito.Mockito.doReturn;
14 import static org.mockito.Mockito.timeout;
15 import static org.mockito.Mockito.verify;
17 import com.google.common.collect.Lists;
18 import java.util.List;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
22 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.NetworkInstances;
23 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstance;
24 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.Protocols;
25 import org.opendaylight.yangtools.concepts.AbstractRegistration;
26 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
27 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
29 public class ConfigLoaderImplTest extends AbstractConfigLoader {
32 public void setUp() throws Exception {
34 final SchemaPath schemaPath = SchemaPath.create(true,
35 NetworkInstances.QNAME, NetworkInstance.QNAME, Protocols.QNAME);
36 doReturn(schemaPath).when(this.processor).getSchemaPath();
37 doReturn("processor").when(this.processor).toString();
41 protected String getResourceFolder() {
42 return ClassLoader.getSystemClassLoader().getResource("etc/opendaylight/bgpcep").getPath();
46 protected void registerModules(final ModuleInfoBackedContext moduleInfoBackedContext) throws Exception {
47 moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(NetworkInstances.class));
51 protected List<String> getYangModelsPaths() {
52 final List<String> paths = Lists.newArrayList(
53 "/META-INF/yang/ietf-interfaces.yang",
54 "/META-INF/yang/openconfig-network-instance-types.yang",
55 "/META-INF/yang/openconfig-interfaces.yang",
56 "/META-INF/yang/openconfig-network-instance.yang",
57 "/META-INF/yang/openconfig-routing-policy.yang",
58 "/META-INF/yang/openconfig-policy-types.yang",
59 "/META-INF/yang/openconfig-extensions.yang",
60 "/META-INF/yang/openconfig-local-routing.yang",
61 "/META-INF/yang/ietf-inet-types@2013-07-15.yang",
62 "/META-INF/yang/ietf-yang-types@2013-07-15.yang"
68 public void configLoaderImplTest() throws Exception {
69 assertNotNull(ClassLoader.getSystemClassLoader().getResource("etc/opendaylight/bgpcep/protocols-config.xml"));
70 final AbstractRegistration ticket = this.configLoader.registerConfigFile(this.processor);
71 verify(this.processor).loadConfiguration(any());
73 triggerEvent("protocols-config.xml");
74 verify(this.processor, timeout(20000).times(2)).loadConfiguration(any());
77 triggerEvent("protocols-config.xml");
78 verify(this.processor, timeout(20000).times(2)).loadConfiguration(any());