2 * Copyright (c) 2016 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
8 package org.opendaylight.yangtools.yang.stmt;
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.junit.Assert.assertThrows;
13 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
14 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
16 import org.junit.jupiter.api.Test;
17 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
21 void shouldFailOnSyntaxError() {
22 final var cause = assertThrows(IllegalArgumentException.class,
23 () -> StmtTestUtils.parseYangSources(sourceForResource("/bugs/bug7146/foo.yang"))).getCause();
24 assertInstanceOf(YangSyntaxErrorException.class, cause);
25 assertThat(cause.getMessage(), containsString("extraneous input '#'"));