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 org.opendaylight.controller.sal.core.api.model.SchemaService;
11 import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
12 import org.opendaylight.yangtools.concepts.ListenerRegistration;
13 import org.opendaylight.yangtools.util.ListenerRegistry;
14 import org.opendaylight.yangtools.yang.model.api.Module;
15 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
18 @SuppressWarnings("deprecation")
19 public final class MockSchemaService implements SchemaService, SchemaContextProvider {
21 private SchemaContext schemaContext;
23 ListenerRegistry<SchemaContextListener> listeners = ListenerRegistry.create();
26 public void addModule(final Module module) {
27 throw new UnsupportedOperationException();
31 public synchronized SchemaContext getGlobalContext() {
36 public synchronized SchemaContext getSessionContext() {
41 public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
42 final SchemaContextListener listener) {
43 return listeners.register(listener);
47 public void removeModule(final Module module) {
48 throw new UnsupportedOperationException();
52 public synchronized SchemaContext getSchemaContext() {
56 public synchronized void changeSchema(final SchemaContext newContext) {
57 schemaContext = newContext;
58 for (ListenerRegistration<SchemaContextListener> listener : listeners) {
59 listener.getInstance().onGlobalContextUpdated(schemaContext);