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 public void testParsingXPathWithYang11Functions() throws Exception {
25 final PrintStream stdout = System.out;
26 final ByteArrayOutputStream output = new ByteArrayOutputStream();
29 System.setOut(new PrintStream(output, true, "UTF-8"));
31 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6878/foo.yang");
32 assertNotNull(schemaContext);
34 testLog = output.toString();
35 assertFalse(testLog.contains("Could not find function: "));
36 System.setOut(stdout);
40 public void shouldLogInvalidYang10XPath() throws Exception {
41 final PrintStream stdout = System.out;
42 final ByteArrayOutputStream output = new ByteArrayOutputStream();
45 System.setOut(new PrintStream(output, true, "UTF-8"));
47 StmtTestUtils.parseYangSource("/rfc7950/bug6878/foo10-invalid.yang");
49 testLog = output.toString();
50 assertTrue(testLog.contains("Could not find function: re-match"));
51 System.setOut(stdout);
55 public void shouldLogInvalidYang10XPath2() throws Exception {
56 final PrintStream stdout = System.out;
57 final ByteArrayOutputStream output = new ByteArrayOutputStream();
60 System.setOut(new PrintStream(output, true, "UTF-8"));
62 StmtTestUtils.parseYangSource("/rfc7950/bug6878/foo10-invalid-2.yang");
64 testLog = output.toString();
65 assertTrue(testLog.contains("Could not find function: deref"));
66 System.setOut(stdout);