Bug 2563 - Parser should fail when key statement does not reference leaf.
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / impl / ListKeysTest.java
1 /**
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.impl;
9
10 import java.io.File;
11 import java.io.IOException;
12 import java.net.URISyntaxException;
13
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
16 import org.opendaylight.yangtools.yang.parser.util.YangParseException;
17
18 public class ListKeysTest {
19
20     @Test
21     public void correctListKeysTest() throws IOException, YangSyntaxErrorException, URISyntaxException {
22         File yangFile = new File(getClass().getResource("/list-keys-test/correct-list-keys-test.yang").toURI());
23
24         YangParserImpl parser = YangParserImpl.getInstance();
25         parser.parseFile(yangFile, yangFile.getParentFile());
26     }
27
28     @Test(expected = YangParseException.class)
29     public void incorrectListKeysTest1() throws IOException, YangSyntaxErrorException, URISyntaxException {
30         File yangFile = new File(getClass().getResource("/list-keys-test/incorrect-list-keys-test.yang").toURI());
31
32         YangParserImpl parser = YangParserImpl.getInstance();
33         parser.parseFile(yangFile, yangFile.getParentFile());
34     }
35
36     @Test(expected = YangParseException.class)
37     public void incorrectListKeysTest2() throws IOException, YangSyntaxErrorException, URISyntaxException {
38         File yangFile = new File(getClass().getResource("/list-keys-test/incorrect-list-keys-test2.yang").toURI());
39
40         YangParserImpl parser = YangParserImpl.getInstance();
41         parser.parseFile(yangFile, yangFile.getParentFile());
42     }
43
44     @Test(expected = YangParseException.class)
45     public void incorrectListKeysTest3() throws IOException, YangSyntaxErrorException, URISyntaxException {
46         File yangFile = new File(getClass().getResource("/list-keys-test/incorrect-list-keys-test3.yang").toURI());
47
48         YangParserImpl parser = YangParserImpl.getInstance();
49         parser.parseFile(yangFile, yangFile.getParentFile());
50     }
51
52     @Test(expected = YangParseException.class)
53     public void incorrectListKeysTest4() throws IOException, YangSyntaxErrorException, URISyntaxException {
54         File yangFile = new File(getClass().getResource("/list-keys-test/incorrect-list-keys-test4.yang").toURI());
55
56         YangParserImpl parser = YangParserImpl.getInstance();
57         parser.parseFile(yangFile, yangFile.getParentFile());
58     }
59
60 }