1 |
|
package org.qedeq.base.test; |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
import java.io.File; |
10 |
|
import java.io.IOException; |
11 |
|
import java.net.ServerSocket; |
12 |
|
|
|
|
| 65.4% |
Uncovered Elements: 9 (26) |
Complexity: 7 |
Complexity Density: 0.37 |
|
13 |
|
public class WebServer { |
14 |
|
|
15 |
|
|
16 |
|
private final File root; |
17 |
|
|
18 |
|
|
19 |
|
private final int timeout; |
20 |
|
|
21 |
|
|
22 |
|
private final int port; |
23 |
|
|
24 |
|
|
25 |
|
private boolean debug = true; |
26 |
|
|
27 |
|
|
28 |
|
private Thread thread; |
29 |
|
|
30 |
|
private ServerSocket ss; |
31 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
32 |
0
|
public static void main(String[] a) throws Exception {... |
33 |
0
|
final WebServer server = new WebServer(); |
34 |
0
|
server.start(); |
35 |
|
|
36 |
|
|
37 |
|
} |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@throws |
43 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
44 |
0
|
public WebServer() {... |
45 |
0
|
this.port = 3081; |
46 |
0
|
this.root = new File("."); |
47 |
0
|
this.debug = true; |
48 |
0
|
this.timeout = 5000; |
49 |
|
} |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
@param |
55 |
|
@param |
56 |
|
@param |
57 |
|
@param |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
59 |
1
|
public WebServer(final int port, final File root, final int timeout, final boolean debug) {... |
60 |
1
|
this.port = port; |
61 |
1
|
this.root = root; |
62 |
1
|
this.timeout = timeout; |
63 |
1
|
this.debug = debug; |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
66 |
1
|
public synchronized void start() throws IOException {... |
67 |
1
|
ss = new ServerSocket(port); |
68 |
1
|
WebServerWorker ws = new WebServerWorker(timeout, root, ss, debug); |
69 |
1
|
thread = (new Thread(ws, "additional worker")); |
70 |
|
|
71 |
1
|
thread.start(); |
72 |
|
} |
73 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
74 |
1
|
public synchronized void stop() {... |
75 |
1
|
thread.interrupt(); |
76 |
1
|
thread = null; |
77 |
1
|
if (ss != null) { |
78 |
1
|
try { |
79 |
1
|
ss.close(); |
80 |
|
} catch (Exception e) { |
81 |
|
|
82 |
|
} |
83 |
|
} |
84 |
|
} |
85 |
|
|
86 |
|
} |
87 |
|
|