c9b71a07cbce388755116da0370977b9da4a6b07
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / test / Bug4933Test.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.stmt.test;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.fail;
13
14 import java.io.FileNotFoundException;
15 import java.net.URISyntaxException;
16 import java.util.Set;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.model.api.Deviation;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
21 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
22
23 public class Bug4933Test {
24
25     @Test
26     public void test() throws SourceException, ReactorException, FileNotFoundException, URISyntaxException {
27         SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug4933/correct");
28         assertNotNull(context);
29
30         Set<Deviation> deviations = context.getModules().iterator().next().getDeviations();
31         assertEquals(4, deviations.size());
32     }
33
34     @Test
35     public void incorrectKeywordTest() throws SourceException, ReactorException, FileNotFoundException,
36             URISyntaxException {
37         try {
38             StmtTestUtils.parseYangSources("/bugs/bug4933/incorrect");
39             fail("NullPointerException should be thrown.");
40         } catch (NullPointerException e) {
41             assertEquals("String 'not_supported' is not valid deviate argument", e.getMessage());
42         }
43     }
44 }