2 * Copyright (c) 2015 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.controller.sal.rest.impl.test.providers;
11 import java.io.InputStream;
12 import javax.ws.rs.core.MediaType;
13 import org.junit.BeforeClass;
14 import org.junit.Test;
15 import org.opendaylight.netconf.sal.rest.impl.XmlToPATCHBodyReader;
16 import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 public class TestXmlPATCHBodyReader extends AbstractBodyReaderTest {
21 private final XmlToPATCHBodyReader xmlPATCHBodyReader;
22 private static SchemaContext schemaContext;
24 public TestXmlPATCHBodyReader() throws NoSuchFieldException, SecurityException {
26 xmlPATCHBodyReader = new XmlToPATCHBodyReader();
30 protected MediaType getMediaType() {
31 return new MediaType(MediaType.APPLICATION_XML, null);
35 public static void initialization() throws NoSuchFieldException, SecurityException {
36 schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
37 controllerContext.setSchemas(schemaContext);
41 public void moduleDataTest() throws Exception {
42 final String uri = "instance-identifier-patch-module:patch-cont/my-list1/leaf1";
43 mockBodyReader(uri, xmlPATCHBodyReader, false);
44 final InputStream inputStream = TestXmlBodyReader.class
45 .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdata.xml");
46 final PATCHContext returnValue = xmlPATCHBodyReader
47 .readFrom(null, null, null, mediaType, null, inputStream);
48 checkPATCHContext(returnValue);