2 * Copyright (c) 2013 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.controller.yang.parser.impl;
10 import static org.junit.Assert.*;
12 import java.io.IOException;
14 import org.junit.Test;
15 import org.opendaylight.controller.yang.parser.util.YangParseException;
16 import org.opendaylight.controller.yang.parser.util.YangValidationException;
18 public class YangParserNegativeTest {
21 public void testInvalidImport() throws IOException {
23 TestUtils.loadModule("/negative-scenario/testfile1.yang");
24 fail("ValidationException should by thrown");
25 } catch(YangValidationException e) {
26 assertTrue(e.getMessage().contains("Not existing module imported"));
31 public void testTypeNotFound() throws IOException {
33 TestUtils.loadModule("/negative-scenario/testfile2.yang");
34 fail("YangParseException should by thrown");
35 } catch(YangParseException e) {
36 assertTrue(e.getMessage().contains("Error in module 'test2' on line 24: Referenced type 'int-ext' not found."));
41 public void testInvalidAugmentTarget() throws IOException {
43 TestUtils.loadModules("/negative-scenario/testfile0.yang", "/negative-scenario/testfile3.yang");
44 fail("YangParseException should by thrown");
45 } catch(YangParseException e) {
46 assertTrue(e.getMessage().contains("Failed to resolve augments in module 'test3'."));
51 public void testInvalidRefine() throws IOException {
53 TestUtils.loadModule("/negative-scenario/testfile4.yang");
54 fail("YangParseException should by thrown");
55 } catch(YangParseException e) {
56 assertTrue(e.getMessage().contains("Can not refine 'presence' for 'node'."));