01: /*
02: * Copyright 2005 jWic Group (http://www.jwic.de)
03: * $Id: TestJWicRuntimeProvider.java,v 1.1 2006/01/16 08:31:12 lordsam Exp $
04: */
05: package de.jwic.test;
06:
07: import java.io.FileInputStream;
08:
09: import de.jwic.base.ConfigurationTool;
10: import de.jwic.base.JWicRuntime;
11:
12: /**
13: * Returns the JWicRuntime. Initializes the Runtime on first access.
14: * To initialize the runtime, you must specify the path to the jwic-setup.xml
15: * file in the testenv file.
16: *
17: * @version $Revision: 1.1 $
18: * @author Florian Lippisch
19: */
20: public class TestJWicRuntimeProvider {
21:
22: private static boolean initDone = false;
23:
24: /**
25: * Returns the ApplicationContext.
26: * @return
27: */
28: public static JWicRuntime getJWicRuntime() {
29: TestEnvironment env = TestEnvironment.getTestEnvironment();
30: JWicRuntime rt = JWicRuntime.getJWicRuntime();
31:
32: if (!initDone) {
33: String rootPath = env.getProperty("rootpath");
34: ConfigurationTool.setRootPath(rootPath != null ? rootPath
35: : ".");
36:
37: String jwfile = env.getProperty("jwic-setup.xml");
38: if (jwfile == null) {
39: throw new RuntimeException(
40: "property jwic-setup.xml not specified in testenv.properties.");
41: }
42: try {
43: rt.setupRuntime(new FileInputStream(jwfile));
44: } catch (Exception e) {
45: throw new RuntimeException(
46: "Error initializing JWicRuntime:" + e);
47: }
48: initDone = true;
49: }
50:
51: return rt;
52: }
53:
54: }
|