KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > ruby > rubyproject > execution > RegexpOutputRecognizerTest


1 /*
2  * RegexpOutputRecognizerTest.java
3  * JUnit based test
4  *
5  * Created on March 5, 2007, 3:53 PM
6  */

7 package org.netbeans.modules.ruby.rubyproject.execution;
8
9
10
11 import junit.framework.TestCase;
12 import org.netbeans.modules.ruby.rubyproject.api.RubyExecution;
13 import org.netbeans.modules.ruby.rubyproject.execution.OutputRecognizer.FileLocation;
14
15 /**
16  *
17  * @author Tor Norbye
18  */

19 public class RegexpOutputRecognizerTest extends TestCase {
20     
21     public RegexpOutputRecognizerTest(String JavaDoc testName) {
22         super(testName);
23     }
24     
25     protected void setUp() throws Exception JavaDoc {
26         super.setUp();
27     }
28
29     protected void tearDown() throws Exception JavaDoc {
30         super.tearDown();
31     }
32
33     public void testStackUnix() {
34         RegexpOutputRecognizer recognizer = RubyExecution.RUBY_COMPILER;
35         FileLocation location;
36         
37         location = recognizer.processLine(":[-1,-1]:[0,0]: main.rb:7: unterminated string meets end of file (SyntaxError)");
38         assertNotNull(location);
39         assertEquals("main.rb", location.file);
40         assertEquals(7, location.line);
41         location = recognizer.processLine("main.rb:6 warning: parenthesize argument(s) for future version");
42         assertNotNull(location);
43         assertEquals("main.rb", location.file);
44         assertEquals(6, location.line);
45         location = recognizer.processLine("/Users/tor/codehaus/jruby/trunk/trunk/jruby/src/builtin/socket.rb:240:in `initialize': Errno::EADDRINUSE (Errno::EADDRINUSE)");
46         assertNotNull(location);
47         assertEquals("/Users/tor/codehaus/jruby/trunk/trunk/jruby/src/builtin/socket.rb", location.file);
48         assertEquals(240, location.line);
49         location = recognizer.processLine(" from /Users/tor/semplice/modules/scripting/build/cluster/jruby-0.9.1/lib/ruby/1.8/webrick/utils.rb:73:in `new'");
50         assertNotNull(location);
51         assertEquals("/Users/tor/semplice/modules/scripting/build/cluster/jruby-0.9.1/lib/ruby/1.8/webrick/utils.rb", location.file);
52         assertEquals(73, location.line);
53         location = recognizer.processLine(" from /Users/tor/semplice/modules/scripting/build/cluster/jruby-0.9.1/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59");
54         assertNotNull(location);
55         assertEquals("/Users/tor/semplice/modules/scripting/build/cluster/jruby-0.9.1/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb", location.file);
56         assertEquals(59, location.line);
57     }
58
59     public void testNotOutput() {
60         RegexpOutputRecognizer recognizer = RubyExecution.RUBY_COMPILER;
61         FileLocation location;
62
63         location = recognizer.processLine(" Hello World");
64         assertNull(location);
65         location = recognizer.processLine(" Hello:World");
66         assertNull(location);
67         location = recognizer.processLine(" ");
68         assertNull(location);
69     }
70     
71     public void testStackWindows() {
72         RegexpOutputRecognizer recognizer = RubyExecution.RUBY_COMPILER;
73         FileLocation location;
74
75         // No spaces
76
location = recognizer.processLine(" from C:\\DocumentsAndSettings\\pb97924\\MyDocuments\\NetBeansProjects\\RubyApplication2\\lib\\main.rb:10:in `say_hi'");
77         assertNotNull(location);
78         assertEquals("C:\\DocumentsAndSettings\\pb97924\\MyDocuments\\NetBeansProjects\\RubyApplication2\\lib\\main.rb", location.file);
79         assertEquals(10, location.line);
80         
81         // Spaces
82
location = recognizer.processLine(" from C:\\Documents and Settings\\pb97924\\My Documents\\NetBeansProjects\\RubyApplication2\\lib\\main.rb:10:in `say_hi'");
83         assertNotNull(location);
84         assertEquals("C:\\Documents and Settings\\pb97924\\My Documents\\NetBeansProjects\\RubyApplication2\\lib\\main.rb", location.file);
85         assertEquals(10, location.line);
86     }
87     
88     
89 }
90
Popular Tags