blob: 747c79094f8c8748f7d8976d2c7a7d809c582b58 [file] [log] [blame]
Sean Condon06613e92017-06-09 15:14:01 +01001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Sean Condon06613e92017-06-09 15:14:01 +01003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.yang.serializers.xml;
17
Sean Condond911af92017-07-19 18:05:27 +010018import org.onosproject.yang.MockMicrosemiRegistrator;
Sean Condon06613e92017-06-09 15:14:01 +010019import org.onosproject.yang.model.SchemaContext;
20import org.onosproject.yang.runtime.Annotation;
21import org.onosproject.yang.runtime.DefaultAnnotation;
22import org.onosproject.yang.runtime.YangSerializerContext;
23import org.onosproject.yang.runtime.impl.DefaultYangModelRegistry;
24
25import java.util.LinkedList;
26import java.util.List;
27
28public class MockYangSerializerContext implements YangSerializerContext {
29
Sean Condond911af92017-07-19 18:05:27 +010030 private static MockMicrosemiRegistrator schemaProvider =
31 new MockMicrosemiRegistrator();
Sean Condon06613e92017-06-09 15:14:01 +010032 private static final String NETCONF_NS =
33 "urn:ietf:params:xml:ns:netconf:base:1.0";
34 private static final String XMNLS_NC = "xmlns:xc";
35
Sean Condond911af92017-07-19 18:05:27 +010036 public MockYangSerializerContext() {
37 schemaProvider.activate();
38 }
Sean Condon06613e92017-06-09 15:14:01 +010039
40 @Override
41 public SchemaContext getContext() {
Sean Condond911af92017-07-19 18:05:27 +010042 DefaultYangModelRegistry registry = (DefaultYangModelRegistry) schemaProvider.registry();
Sean Condon06613e92017-06-09 15:14:01 +010043 return registry;
44 }
45
46 @Override
47 public List<Annotation> getProtocolAnnotations() {
48 Annotation annotation = new DefaultAnnotation(XMNLS_NC, NETCONF_NS);
49 List<Annotation> protocolAnnotation = new LinkedList<>();
50 protocolAnnotation.add(annotation);
51 return protocolAnnotation;
52 }
53}