1   /*
2    * Copyright 2004-2005 Germinus XXI
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License")
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
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 kortsoft.kmx.bootstrap;
17  
18  import java.io.IOException;
19  import java.io.InputStream;
20  import java.net.URL;
21  import java.util.Properties;
22  
23  import junit.framework.TestCase;
24  
25  /***
26   * <a href="MockKmxMain.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author  Alvaro
29   * @version $Revision: 1.1 $
30   *
31   */
32  public class MockKmxMain implements KmxMain {
33  	public static boolean startup=false;
34  	public static boolean closed=false;	
35  	public static final String TEST_PROPERTY_FILE="test.properties";
36  	public static final String TEST_PROPERTY="test_property";
37  	public static final String TEST_PROPERTY_VALUE="test_property_value";
38  		
39  	public MockKmxMain(){
40  		super();
41  	}
42  	/* (non-Javadoc)
43  	 * @see kortsoft.kmx.bootstrap.KmxMain#startup(java.util.Properties)
44  	 */
45  	public void startup(Properties prop) {
46  		System.out.println("Startup Called");
47  		startup=true;
48  		//Trying to load properties from classpath
49  		Properties testProperties=new Properties();
50  		URL propURL=Thread.currentThread().getContextClassLoader().getResource(TEST_PROPERTY_FILE);			
51  		InputStream propIs=null;
52  		try {
53  			propIs = propURL.openStream();
54  			testProperties.load(propIs);
55  		} catch (IOException e) {
56  			TestCase.fail("Error loading test properties from classpath: "+e);		
57  		} finally {
58  			if (propIs!=null) try {propIs.close();} catch (IOException e1) {}
59  		}
60  	}
61  
62  	/* (non-Javadoc)
63  	 * @see kortsoft.kmx.bootstrap.KmxMain#closeServices()
64  	 */
65  	public void closeServices() {		
66  		closed=true;		
67  	}
68  		
69  }