1 package org.apache.turbine;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertNotNull;
24
25 import org.apache.turbine.test.BaseTestCase;
26 import org.apache.turbine.test.EnhancedMockHttpServletResponse;
27 import org.apache.turbine.util.TurbineConfig;
28 import org.junit.Test;
29
30 import com.mockobjects.servlet.MockHttpServletRequest;
31
32
33
34
35
36
37
38
39
40 public class TurbineTest extends BaseTestCase
41 {
42
43 @Test
44 public void testTurbineAndFirstGet() throws Exception
45 {
46 TurbineConfig tc = new TurbineConfig(".",
47 "/conf/test/CompleteTurbineResources.properties");
48 tc.initialize();
49
50 assertNotNull(Turbine.getDefaultServerData());
51 assertEquals("", Turbine.getServerName());
52 assertEquals("80", Turbine.getServerPort());
53 assertEquals("", Turbine.getScriptName());
54 Turbine t = tc.getTurbine();
55
56 MockHttpServletRequest request = getMockRequest();
57 EnhancedMockHttpServletResponse resp = new EnhancedMockHttpServletResponse();
58
59 t.doGet(request, resp);
60
61 assertEquals("8080", Turbine.getServerPort());
62 t.destroy();
63 tc.dispose();
64 }
65 @Test
66 public void testDefaultInputEncoding() throws Exception
67 {
68 TurbineConfig tc = new TurbineConfig(".",
69 "/conf/test/CompleteTurbineResources.properties");
70 tc.initialize();
71 Turbine t = tc.getTurbine();
72 assertNotNull(t.getDefaultInputEncoding());
73 assertEquals(TurbineConstants.PARAMETER_ENCODING_DEFAULT, t.getDefaultInputEncoding());
74 t.destroy();
75 tc.dispose();
76 }
77 @Test
78 public void testNonDefaultEncoding()
79 {
80 TurbineConfig tc = new TurbineConfig(".",
81 "/conf/test/CompleteTurbineResourcesWithEncoding.properties");
82 tc.initialize();
83 Turbine t = tc.getTurbine();
84 assertNotNull(t.getDefaultInputEncoding());
85 assertEquals("UTF-8", t.getDefaultInputEncoding());
86 tc.dispose();
87 }
88 }