File tree Expand file tree Collapse file tree 1 file changed +20
-9
lines changed
mockserver-netty/src/test/java/org/mockserver/lifecycle Expand file tree Collapse file tree 1 file changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -32,14 +32,25 @@ public class PortBindingIntegrationTest {
32
32
33
33
@ Test
34
34
public void throwsExpectionOnPortAlreadyBound () {
35
- // then
36
- exception .expect (RuntimeException .class );
37
- exception .expectMessage (Matchers .containsString ("Exception while binding MockServer to port" ));
38
-
39
- // when - server started
40
- new MockServer (MOCK_SERVER_PORT );
41
-
42
- // and - server started again on same port
43
- new MockServer (MOCK_SERVER_PORT );
35
+ MockServer mockServerOne = null , mockServerTwo = null ;
36
+ try {
37
+ // then
38
+ exception .expect (RuntimeException .class );
39
+ exception .expectMessage (Matchers .containsString ("Exception while binding MockServer to port" ));
40
+
41
+ // when - server started
42
+ mockServerOne = new MockServer (MOCK_SERVER_PORT );
43
+
44
+ // and - server started again on same port
45
+ mockServerTwo = new MockServer (MOCK_SERVER_PORT );
46
+
47
+ } finally {
48
+ if (mockServerOne != null ) {
49
+ mockServerOne .stop ();
50
+ }
51
+ if (mockServerTwo != null ) {
52
+ mockServerTwo .stop ();
53
+ }
54
+ }
44
55
}
45
56
}
You can’t perform that action at this time.
0 commit comments