TestServer.java
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.dianping.cat;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.webapp.WebAppContext;
import org.mortbay.servlet.GzipFilter;
import org.unidal.test.jetty.JettyServer;
@RunWith(JUnit4.class)
public class TestServer extends JettyServer {
public static void main(String[] args) throws Exception {
TestServer server = new TestServer();
System.setProperty("devMode", "true");
server.startServer();
server.startWebApp();
server.stopServer();
}
@Before
public void before() throws Exception {
System.setProperty("devMode", "true");
super.startServer();
}
@Override
protected String getContextPath() {
return "/cat";
}
@Override
protected int getServerPort() {
return 2281;
}
@Override
protected void postConfigure(WebAppContext context) {
context.addFilter(GzipFilter.class, "/*", Handler.ALL);
}
@Test
public void startWebApp() throws Exception {
// open the page in the default browser
display("/cat/r");
waitForAnyKey();
}
}