01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.rice.test;
17:
18: import org.apache.commons.lang.StringUtils;
19: import org.kuali.rice.config.Config;
20: import org.kuali.rice.core.Core;
21: import org.kuali.rice.web.jetty.JettyServer;
22: import org.mortbay.jetty.Server;
23: import org.mortbay.jetty.webapp.WebAppContext;
24:
25: public class TestHarnessWebApp extends JettyServer {
26:
27: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
28: .getLogger(TestHarnessWebApp.class);
29:
30: private int port;
31: private String webAppRoot;
32: private String contextName;
33:
34: public TestHarnessWebApp() {
35: this (9912, null);
36: }
37:
38: public TestHarnessWebApp(int port, String contextName) {
39: super (port, contextName);
40: }
41:
42: protected Server createServer() {
43: Config config = Core.getCurrentContextConfig();
44: this .webAppRoot = config.getProperty("test.web.app.root");
45: this .contextName = config.getProperty("test.context.name");
46: if (StringUtils.isBlank(this .webAppRoot)
47: || StringUtils.isBlank(this .contextName)) {
48: LOG
49: .warn("Could not locate both the 'test.web.app.root' and 'test.context.name' configuration parameters. Not starting embedded Jetty server.");
50: return null;
51: }
52: Server server = new Server(getPort());
53: WebAppContext context = new WebAppContext(getWebAppRoot(),
54: getContextName());
55: server.addHandler(context);
56: return server;
57: }
58:
59: public String getWebAppRoot() {
60: return this .webAppRoot;
61: }
62:
63: public String getContextName() {
64: return this .contextName;
65: }
66:
67: public void setContextName(String contextName) {
68: this .contextName = contextName;
69: }
70:
71: public int getPort() {
72: if (this .port == 0) {
73: return 9912;
74: }
75: return this .port;
76: }
77:
78: public void setPort(int port) {
79: this.port = port;
80: }
81:
82: }
|