4
4
import org .eclipse .jetty .util .thread .QueuedThreadPool ;
5
5
import org .junit .After ;
6
6
import org .junit .Test ;
7
+
7
8
import spark .embeddedserver .EmbeddedServer ;
8
9
import spark .route .Routes ;
9
10
import spark .staticfiles .StaticFilesConfiguration ;
10
11
11
- import static org .mockito .Mockito .*;
12
+ import static org .mockito .Mockito .mock ;
13
+ import static org .mockito .Mockito .times ;
14
+ import static org .mockito .Mockito .verify ;
15
+ import static org .mockito .Mockito .verifyNoMoreInteractions ;
16
+ import static org .mockito .Mockito .when ;
12
17
13
18
public class EmbeddedJettyFactoryTest {
19
+
14
20
private EmbeddedServer embeddedServer ;
15
21
16
22
@ Test
@@ -19,14 +25,14 @@ public void create() throws Exception {
19
25
final StaticFilesConfiguration staticFilesConfiguration = mock (StaticFilesConfiguration .class );
20
26
final Routes routes = mock (Routes .class );
21
27
22
- when (jettyServerFactory .create (100 ,10 ,10000 )).thenReturn (new Server ());
28
+ when (jettyServerFactory .create (100 , 10 , 10000 )).thenReturn (new Server ());
23
29
24
30
final EmbeddedJettyFactory embeddedJettyFactory = new EmbeddedJettyFactory (jettyServerFactory );
25
31
embeddedServer = embeddedJettyFactory .create (routes , staticFilesConfiguration , false );
26
32
27
- embeddedServer .ignite ("localhost" , 8080 , null , 100 ,10 ,10000 );
33
+ embeddedServer .ignite ("localhost" , 6757 , null , 100 , 10 , 10000 );
28
34
29
- verify (jettyServerFactory , times (1 )).create (100 ,10 ,10000 );
35
+ verify (jettyServerFactory , times (1 )).create (100 , 10 , 10000 );
30
36
verifyNoMoreInteractions (jettyServerFactory );
31
37
}
32
38
@@ -42,7 +48,7 @@ public void create_withThreadPool() throws Exception {
42
48
final EmbeddedJettyFactory embeddedJettyFactory = new EmbeddedJettyFactory (jettyServerFactory ).withThreadPool (threadPool );
43
49
embeddedServer = embeddedJettyFactory .create (routes , staticFilesConfiguration , false );
44
50
45
- embeddedServer .ignite ("localhost" , 8080 , null , 0 ,0 , 0 );
51
+ embeddedServer .ignite ("localhost" , 6758 , null , 0 , 0 , 0 );
46
52
47
53
verify (jettyServerFactory , times (1 )).create (threadPool );
48
54
verifyNoMoreInteractions (jettyServerFactory );
@@ -54,19 +60,21 @@ public void create_withNullThreadPool() throws Exception {
54
60
final StaticFilesConfiguration staticFilesConfiguration = mock (StaticFilesConfiguration .class );
55
61
final Routes routes = mock (Routes .class );
56
62
57
- when (jettyServerFactory .create (100 ,10 ,10000 )).thenReturn (new Server ());
63
+ when (jettyServerFactory .create (100 , 10 , 10000 )).thenReturn (new Server ());
58
64
59
65
final EmbeddedJettyFactory embeddedJettyFactory = new EmbeddedJettyFactory (jettyServerFactory ).withThreadPool (null );
60
66
embeddedServer = embeddedJettyFactory .create (routes , staticFilesConfiguration , false );
61
67
62
- embeddedServer .ignite ("localhost" , 8080 , null , 100 ,10 ,10000 );
68
+ embeddedServer .ignite ("localhost" , 6759 , null , 100 , 10 , 10000 );
63
69
64
- verify (jettyServerFactory , times (1 )).create (100 ,10 ,10000 );
70
+ verify (jettyServerFactory , times (1 )).create (100 , 10 , 10000 );
65
71
verifyNoMoreInteractions (jettyServerFactory );
66
72
}
67
73
68
74
@ After
69
75
public void tearDown () throws Exception {
70
- if (embeddedServer != null ) embeddedServer .extinguish ();
76
+ if (embeddedServer != null ) {
77
+ embeddedServer .extinguish ();
78
+ }
71
79
}
72
80
}
0 commit comments