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.parser.stmt.rfc7950;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
15 import java.io.ByteArrayOutputStream;
16 import java.io.PrintStream;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
21 public class Bug6878Test {
24 @SuppressWarnings("checkstyle:regexpSinglelineJava")
25 public void testParsingXPathWithYang11Functions() throws Exception {
26 final PrintStream stdout = System.out;
27 final ByteArrayOutputStream output = new ByteArrayOutputStream();
30 System.setOut(new PrintStream(output, true, "UTF-8"));
32 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6878/foo.yang");
33 assertNotNull(schemaContext);
35 testLog = output.toString();
36 assertFalse(testLog.contains("Could not find function: "));
37 System.setOut(stdout);
41 @SuppressWarnings("checkstyle:regexpSinglelineJava")
42 public void shouldLogInvalidYang10XPath() throws Exception {
43 final PrintStream stdout = System.out;
44 final ByteArrayOutputStream output = new ByteArrayOutputStream();
47 System.setOut(new PrintStream(output, true, "UTF-8"));
49 StmtTestUtils.parseYangSource("/rfc7950/bug6878/foo10-invalid.yang");
51 testLog = output.toString();
52 assertTrue(testLog.contains("Could not find function: re-match"));
53 System.setOut(stdout);
57 @SuppressWarnings("checkstyle:regexpSinglelineJava")
58 public void shouldLogInvalidYang10XPath2() throws Exception {
59 final PrintStream stdout = System.out;
60 final ByteArrayOutputStream output = new ByteArrayOutputStream();
63 System.setOut(new PrintStream(output, true, "UTF-8"));
65 StmtTestUtils.parseYangSource("/rfc7950/bug6878/foo10-invalid-2.yang");
67 testLog = output.toString();
68 assertTrue(testLog.contains("Could not find function: deref"));
69 System.setOut(stdout);