blob: 169d8062e52f770927b02394ceb2a576835733a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.controller.sal.rest.impl.test.providers;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.OutputStream;
import java.util.Collection;
import javax.ws.rs.core.MediaType;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext;
import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class TestXmlBodyWriter extends AbstractBodyReaderTest {
private final NormalizedNodeXmlBodyWriter xmlBodyWriter;
private static EffectiveModelContext schemaContext;
public TestXmlBodyWriter() {
super(schemaContext, null);
this.xmlBodyWriter = new NormalizedNodeXmlBodyWriter();
}
@Override
protected MediaType getMediaType() {
return new MediaType(MediaType.APPLICATION_XML, null);
}
@BeforeClass
public static void initialization() throws Exception {
final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
}
@Test
public void rpcModuleInputTest() throws Exception {
final String uri = "invoke-rpc-module:rpc-test";
final String pathToInputFile = "/invoke-rpc/xml/rpc-output.xml";
final NormalizedNodeContext nnContext = TestRestconfUtils
.loadNormalizedContextFromXmlFile(pathToInputFile, uri, controllerContext);
final OutputStream output = new ByteArrayOutputStream();
this.xmlBodyWriter.writeTo(nnContext, null, null, null, this.mediaType, null, output);
assertTrue(output.toString().contains("lf-test"));
}
}
|