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.MatcherAssert.assertThat;
11 import static org.hamcrest.Matchers.isA;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertTrue;
15 import static org.junit.Assert.fail;
17 import java.util.Collection;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.model.api.Deviation;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
23 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
25 public class Bug4933Test {
28 public void test() throws Exception {
29 SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug4933/correct");
30 assertNotNull(context);
32 final Module foo = context.findModules("foo").iterator().next();
33 Collection<? extends Deviation> deviations = foo.getDeviations();
34 assertEquals(4, deviations.size());
38 public void incorrectKeywordTest() throws Exception {
40 StmtTestUtils.parseYangSources("/bugs/bug4933/incorrect");
41 fail("ReactorException should be thrown.");
42 } catch (ReactorException e) {
43 final Throwable cause = e.getCause();
44 assertThat(cause, isA(SourceException.class));
45 assertTrue(cause.getMessage().startsWith("String 'not_supported' is not valid deviate argument"));