1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
35
import java.io.FileInputStream;
36
import java.io.IOException;
37
import java.util.Iterator;
38
import java.util.Properties;
43
public class TestConfiguration {
46
private File calocaltop;
47
private File cascript;
48
private String adminUser;
49
private Properties props = new Properties();
51
private static TestConfiguration theInstance;
52
public synchronized static TestConfiguration getInstance() throws IOException {
53
if(theInstance == null) {
54
theInstance = new TestConfiguration();
59
protected TestConfiguration() throws IOException {
61
File file = new File("test/TestConfiguration.properties".replace('/', File.separatorChar));
62
props.load(new FileInputStream(file));
64
File privFile = new File("test/TestConfiguration_private.properties".replace('/', File.separatorChar));
66
if(privFile.exists()) {
68
Properties privProps = new Properties();
69
privProps.load(new FileInputStream(privFile));
71
Iterator iter = privProps.keySet().iterator();
72
while(iter.hasNext()) {
73
Object prop = iter.next();
74
props.put(prop, privProps.get(prop));
78
String fileProp = System.getProperty(getClass().getName() + ".file");
79
if(fileProp != null) {
80
Properties fileProps = new Properties();
81
fileProps.load(new FileInputStream(fileProp));
83
Iterator iter = fileProps.keySet().iterator();
84
while(iter.hasNext()) {
85
Object prop = iter.next();
86
props.put(prop, fileProps.get(prop));
92
private File getFileFromConfig(String key) {
93
String str = props.getProperty(key);
95
throw new IllegalArgumentException(key + " is not defined in test configuration");
100
public File getCatop() {
102
String str = getCell() + "common/sgeCA";
103
catop = new File(getSgeRoot(), str.replace('/', File.separatorChar) );
108
public File getCaLocalTop() {
109
if(calocaltop == null) {
110
String str = "/var/sgeCA/port" + getQMasterPort() + "/" + getCell();
111
calocaltop = new File(str.replace('/', File.pathSeparatorChar));
116
public File getCaScript() {
117
if(cascript == null) {
118
cascript = new File(getSgeRoot(), "util/sgeCA/sge_ca".replace('/', File.separatorChar));
124
private int qmasterPort = -1;
125
public int getQMasterPort() {
126
if(qmasterPort < 0) {
127
qmasterPort = Integer.parseInt(props.getProperty("sge_qmaster_port"));
132
public String getAdminUser() {
133
if(adminUser == null) {
134
adminUser = props.getProperty("adminuser");
139
public String getTestUser() {
140
return props.getProperty("testuser");
143
public char [] getTestUserPassword() {
144
String pw = props.getProperty("testuser_pw");
146
return pw.toCharArray();
151
public String getUserVerifier() {
152
return props.getProperty("userverifier");
155
public String getPamService() {
156
return props.getProperty("pam_service");
159
private File sgeRoot;
161
public File getSgeRoot() {
162
if(sgeRoot == null) {
163
sgeRoot = new File(props.getProperty("sge_root"));
170
public String getCell() {
172
cell = props.getProperty("sge_cell");