a26ec25cc96d30ddc40ba11605582aefb1265907
[phpeclipse.git] / net.sourceforge.phpeclipse.phpunit / src / net / sourceforge / phpeclipse / phpunit / ReportListener.java
1 package net.sourceforge.phpeclipse.phpunit;
2
3 import java.io.BufferedReader;
4 import java.io.IOException;
5 import java.io.InputStreamReader;
6 import java.net.Socket; 
7
8 public class ReportListener extends Thread {
9
10         Socket serviceSocket;
11         PHPUnitView view;
12         
13         public ReportListener(Socket serviceSocket, PHPUnitView view) {
14                 this.view = view;
15                 this.serviceSocket = serviceSocket;
16
17         }
18
19         public void run() {
20
21                 InputStreamReader reader;
22
23                 try {
24                         reader = new InputStreamReader(serviceSocket.getInputStream());
25
26                         BufferedReader in = new BufferedReader(reader);
27                         String report = null;
28                         int i = 0;
29                         // keep listening until the 
30                         while ( (report = in.readLine()) != null &&
31                                         (report != "end_all_tests") ) {
32
33                                 //System.out.println("received something...");
34                                 view.handleReport(report);
35                                 //System.out.println(report);
36                         }
37
38                         //reportArea.append("Finished!");
39                         System.out.println("Finished");
40                         serviceSocket.close();
41
42                 } catch (IOException e) {
43                         // TODO Auto-generated catch block
44                         e.printStackTrace();
45                 }
46
47         }
48
49 }