001 package nl.cwi.sen1.visbase.rstorecontainer.datatypes; 002 003 import junit.framework.TestCase; 004 005 /** 006 * Used to test the ATermParseExceptionTest code 007 * 008 * @author Ricardo Lindooren 009 * @date 2007-02-20 010 */ 011 public class ATermParseExceptionTest extends TestCase 012 { 013 private final static String MESSAGE = "fakeMessage"; 014 015 private final static String MESSAGE2 = "fakeMessage2"; 016 017 public void testATermParseException() 018 { 019 ATermParseException rpe = new ATermParseException(); 020 021 assertNotNull(rpe); 022 } 023 024 public void testATermParseExceptionString() 025 { 026 ATermParseException rpe = new ATermParseException(MESSAGE); 027 028 assertEquals(rpe.getMessage(), MESSAGE); 029 } 030 031 public void testATermParseExceptionStringThrowable() 032 { 033 ATermParseException rpe = null; 034 Exception exp; 035 036 try 037 { 038 throw new Exception(MESSAGE); 039 } 040 catch (Exception ex) 041 { 042 exp = ex; 043 rpe = new ATermParseException(MESSAGE2, ex); 044 } 045 046 assertNotNull(rpe); 047 048 assertEquals(rpe.getMessage(), MESSAGE2); 049 050 assertEquals(rpe.getCause(), exp); 051 052 assertEquals(rpe.getCause().getMessage(), MESSAGE); 053 } 054 055 public void testATermParseExceptionThrowable() 056 { 057 ATermParseException rpe = null; 058 Exception exp; 059 060 try 061 { 062 throw new Exception(MESSAGE); 063 } 064 catch (Exception ex) 065 { 066 exp = ex; 067 rpe = new ATermParseException(ex); 068 } 069 070 assertNotNull(rpe); 071 072 assertEquals(rpe.getCause(), exp); 073 074 assertEquals(rpe.getCause().getMessage(), MESSAGE); 075 } 076 }