Bug 6244: Add context to exceptions thrown by yang statement parser
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / ListKeysTest.java
index d772e493c183ebcdf56b43702081b0b8b97134fd..e1fab4e0995f4c4f58b2df58f230b99796dfb9fc 100644 (file)
@@ -7,15 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+
 import java.io.IOException;
 import java.net.URISyntaxException;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
@@ -50,8 +49,8 @@ public class ListKeysTest {
             reactor.buildEffective();
             fail("effective build should fail due to list instead of leaf referenced in list key");
         } catch (Exception e) {
-            assertEquals(InferenceException.class, e.getClass());
-            assertTrue(e.getMessage().startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"));
+            assertTrue(e instanceof ReactorException);
+            assertTrue(e.getCause().getMessage().startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"));
         }
     }
 
@@ -68,8 +67,8 @@ public class ListKeysTest {
             reactor.buildEffective();
             fail("effective build should fail due to missing leaf referenced in list key");
         } catch (Exception e) {
-            assertEquals(InferenceException.class, e.getClass());
-            assertTrue(e.getMessage().startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"));
+            assertTrue(e instanceof ReactorException);
+            assertTrue(e.getCause().getMessage().startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"));
         }
     }
 
@@ -86,8 +85,8 @@ public class ListKeysTest {
             reactor.buildEffective();
             fail("effective build should fail due to list instead of leaf in grouping referenced in list key");
         } catch (Exception e) {
-            assertEquals(InferenceException.class, e.getClass());
-            assertTrue(e.getMessage().startsWith("Key 'grp_list' misses node 'grp_list'"));
+            assertTrue(e instanceof ReactorException);
+            assertTrue(e.getCause().getMessage().startsWith("Key 'grp_list' misses node 'grp_list'"));
         }
     }
 
@@ -105,8 +104,8 @@ public class ListKeysTest {
             fail("effective build should fail due to list instead of leaf in grouping augmented to list referenced " +
                     "in list key");
         } catch (Exception e) {
-            assertEquals(InferenceException.class, e.getClass());
-            assertTrue(e.getMessage().startsWith("Key 'grp_leaf' misses node 'grp_leaf'"));
+            assertTrue(e instanceof ReactorException);
+            assertTrue(e.getCause().getMessage().startsWith("Key 'grp_leaf' misses node 'grp_leaf'"));
         }
     }