Title: [1328] trunk/qdox/src/test/java/com/thoughtworks/qdox/parser: Add ParseExceptionTest
Revision
1328
Author
rfscholte
Date
2011-09-10 17:18:06 -0500 (Sat, 10 Sep 2011)

Log Message

Add ParseExceptionTest

Modified Paths


Added Paths

Diff

Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/parser/ParseException.java (1327 => 1328)

--- trunk/qdox/src/main/java/com/thoughtworks/qdox/parser/ParseException.java	2011-09-10 22:01:32 UTC (rev 1327)
+++ trunk/qdox/src/main/java/com/thoughtworks/qdox/parser/ParseException.java	2011-09-10 22:18:06 UTC (rev 1328)
@@ -67,7 +67,7 @@
 
     public void setSourceInfo( String sourceInfo )
     {
-        sourceInfo += sourceInfo;
+        this.sourceInfo = sourceInfo;
     }
 
     
@@ -80,7 +80,7 @@
             if( column >=0 ) {
                buffer.append( ',' ).append( column );  
             }
-            buffer.append( "]" );
+            buffer.append( ']' );
         }
         if ( sourceInfo != null ) {
             buffer.append( " in " ).append( sourceInfo );

Added: trunk/qdox/src/test/java/com/thoughtworks/qdox/parser/ParseExceptionTest.java (0 => 1328)

--- trunk/qdox/src/test/java/com/thoughtworks/qdox/parser/ParseExceptionTest.java	                        (rev 0)
+++ trunk/qdox/src/test/java/com/thoughtworks/qdox/parser/ParseExceptionTest.java	2011-09-10 22:18:06 UTC (rev 1328)
@@ -0,0 +1,52 @@
+package com.thoughtworks.qdox.parser;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ParseExceptionTest
+{
+
+    @Test
+    public void testNullParseException() 
+    {
+       ParseException pe = new ParseException( null, -1, -1 );
+       try {
+           pe.getMessage();
+           fail( "Message should never be null" );
+       }
+       catch( NullPointerException npe )
+       {
+       }
+    }
+    
+    @Test
+    public void testEmptyParseException() 
+    {
+       ParseException pe = new ParseException( "", -1, -1 );
+       assertEquals("", pe.getMessage());
+    }
+
+    @Test
+    public void testNegativeColumnParseException() 
+    {
+       ParseException pe = new ParseException( "Failed to parse:", 5, -50 );
+       assertEquals("Failed to parse: @[5]", pe.getMessage());
+    }
+
+    @Test
+    public void testPositiveColumnParseException() 
+    {
+       ParseException pe = new ParseException( "Failed to parse:", 5, 50 );
+       assertEquals("Failed to parse: @[5,50]", pe.getMessage());
+    }
+
+    @Test
+    public void testSurceInfoParseException() 
+    {
+       ParseException pe = new ParseException( "Failed to parse:", 5, 50 );
+       pe.setSourceInfo( "com/foo/Bar.java" );
+       assertEquals("Failed to parse: @[5,50] in com/foo/Bar.java", pe.getMessage());
+    }
+
+}


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to