File tree 3 files changed +44
-1
lines changed
main/java/org/browsermob/proxy
test/java/org/browsermob/proxy 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 257
257
<artifactId >selenium-api</artifactId >
258
258
<version >2.0b3</version >
259
259
</dependency >
260
+
261
+ <dependency >
262
+ <groupId >junit</groupId >
263
+ <artifactId >junit</artifactId >
264
+ <version >4.9</version >
265
+ <scope >test</scope >
266
+ </dependency >
267
+
260
268
</dependencies >
261
269
262
270
<reporting >
Original file line number Diff line number Diff line change 8
8
import org .browsermob .core .har .HarPage ;
9
9
import org .browsermob .proxy .http .BrowserMobHttpClient ;
10
10
import org .browsermob .proxy .jetty .http .HttpContext ;
11
+ import org .browsermob .proxy .jetty .http .HttpListener ;
11
12
import org .browsermob .proxy .jetty .http .SocketListener ;
12
13
import org .browsermob .proxy .jetty .jetty .Server ;
13
14
import org .browsermob .proxy .jetty .util .InetAddrPort ;
@@ -40,7 +41,8 @@ public void start() throws Exception {
40
41
}
41
42
42
43
server = new Server ();
43
- server .addListener (new SocketListener (new InetAddrPort (getPort ()))); // todo: arg?
44
+ HttpListener listener = new SocketListener (new InetAddrPort (getPort ()));
45
+ server .addListener (listener );
44
46
HttpContext context = new HttpContext ();
45
47
context .setContextPath ("/" );
46
48
server .addContext (context );
@@ -56,6 +58,8 @@ public void start() throws Exception {
56
58
context .addHandler (handler );
57
59
58
60
server .start ();
61
+
62
+ setPort (listener .getPort ());
59
63
}
60
64
61
65
public org .openqa .selenium .Proxy seleniumProxy () {
Original file line number Diff line number Diff line change
1
+ package org .browsermob .proxy ;
2
+
3
+ import org .junit .After ;
4
+ import org .junit .Before ;
5
+ import org .junit .Rule ;
6
+ import org .junit .Test ;
7
+ import org .junit .rules .ExternalResource ;
8
+
9
+ import static org .hamcrest .CoreMatchers .equalTo ;
10
+ import static org .hamcrest .CoreMatchers .not ;
11
+ import static org .junit .Assert .assertThat ;
12
+
13
+ public class ProxyServerTest {
14
+
15
+ private ProxyServer server = new ProxyServer (0 );
16
+
17
+ @ Before
18
+ public void startServer () throws Exception {
19
+ server .start ();
20
+ }
21
+
22
+ @ After
23
+ public void stopServer () throws Exception {
24
+ server .stop ();
25
+ }
26
+
27
+ @ Test
28
+ public void portAllocation () throws Exception {
29
+ assertThat (server .getPort (), not (equalTo (0 )));
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments