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.yangtools.concepts.ListenerRegistration;
12 import org.opendaylight.yangtools.util.ListenerRegistry;
13 import org.opendaylight.yangtools.yang.model.api.Module;
14 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
15 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
18 public final class MockSchemaService implements SchemaService, SchemaContextProvider {
20 private SchemaContext schemaContext;
22 ListenerRegistry<SchemaContextListener> listeners = ListenerRegistry.create();
25 public void addModule(final Module module) {
26 throw new UnsupportedOperationException();
30 public synchronized SchemaContext getGlobalContext() {
35 public synchronized SchemaContext getSessionContext() {
40 public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
41 final SchemaContextListener listener) {
42 return listeners.register(listener);
46 public void removeModule(final Module module) {
47 throw new UnsupportedOperationException();
51 public synchronized SchemaContext getSchemaContext() {
55 public synchronized void changeSchema(final SchemaContext newContext) {
56 schemaContext = newContext;
57 for (ListenerRegistration<SchemaContextListener> listener : listeners) {
58 listener.getInstance().onGlobalContextUpdated(schemaContext);