2 * Copyright (c) 2017 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.yangtools.yang.data.codec.xml;
11 import static org.junit.Assert.assertNotNull;
13 import java.io.InputStream;
14 import javax.xml.stream.XMLInputFactory;
15 import javax.xml.stream.XMLStreamReader;
16 import org.junit.Ignore;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
19 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
20 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
21 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
22 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
23 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
25 public class Bug8083Test {
27 @Ignore("XMLEmptyCodec needs to be fixed first.")
29 public void testInstanceIdentifierPathWithEmptyListKey() throws Exception {
30 final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bug8083/yang/baz.yang");
31 final InputStream resourceAsStream = Bug8083Test.class.getResourceAsStream("/bug8083/xml/baz.xml");
33 final XMLInputFactory factory = XMLInputFactory.newInstance();
34 final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream);
37 final NormalizedNodeResult result = new NormalizedNodeResult();
38 final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
39 final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext);
40 xmlParser.parse(reader);
41 final NormalizedNode<?, ?> transformedInput = result.getResult();
42 assertNotNull(transformedInput);
46 public void testInstanceIdentifierPathWithIdentityrefListKey() throws Exception {
47 final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bug8083/yang/zab.yang");
48 final InputStream resourceAsStream = Bug8083Test.class.getResourceAsStream("/bug8083/xml/zab.xml");
50 final XMLInputFactory factory = XMLInputFactory.newInstance();
51 final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream);
54 final NormalizedNodeResult result = new NormalizedNodeResult();
55 final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
56 final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext);
57 xmlParser.parse(reader);
58 final NormalizedNode<?, ?> transformedInput = result.getResult();
59 assertNotNull(transformedInput);
63 public void testInstanceIdentifierPathWithInstanceIdentifierListKey() throws Exception {
64 final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bug8083/yang/foobar.yang");
65 final InputStream resourceAsStream = Bug8083Test.class.getResourceAsStream("/bug8083/xml/foobar.xml");
67 final XMLInputFactory factory = XMLInputFactory.newInstance();
68 final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream);
71 final NormalizedNodeResult result = new NormalizedNodeResult();
72 final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
73 final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext);
74 xmlParser.parse(reader);
75 final NormalizedNode<?, ?> transformedInput = result.getResult();
76 assertNotNull(transformedInput);