2 * Copyright (c) 2014 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
8 package org.opendaylight.controller.sal.binding.test.util;
10 import com.google.common.collect.ClassToInstanceMap;
11 import com.google.common.collect.ImmutableClassToInstanceMap;
13 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
14 import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension;
15 import org.opendaylight.yangtools.concepts.ListenerRegistration;
16 import org.opendaylight.yangtools.util.ListenerRegistry;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
21 public final class MockSchemaService implements DOMSchemaService, SchemaContextProvider {
23 private SchemaContext schemaContext;
25 ListenerRegistry<SchemaContextListener> listeners = ListenerRegistry.create();
28 public synchronized SchemaContext getGlobalContext() {
33 public synchronized SchemaContext getSessionContext() {
38 public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
39 final SchemaContextListener listener) {
40 return listeners.register(listener);
44 public synchronized SchemaContext getSchemaContext() {
50 public Map<Class<? extends DOMSchemaServiceExtension>, DOMSchemaServiceExtension> getSupportedExtensions() {
51 return ImmutableClassToInstanceMap.of();
55 public ClassToInstanceMap<DOMSchemaServiceExtension> getExtensions() {
56 return ImmutableClassToInstanceMap.of();
59 public synchronized void changeSchema(final SchemaContext newContext) {
60 schemaContext = newContext;
61 for (ListenerRegistration<SchemaContextListener> listener : listeners) {
62 listener.getInstance().onGlobalContextUpdated(schemaContext);