1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ClParser.java,v $
10 * $Revision: 1.12.2.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 import java
.util
.Properties
;
34 import lib
.TestParameters
;
35 import util
.PropertyName
;
39 * This class parses commandline Argument and stores <br>
40 * them into TestParameter
45 * Parses the commandline argument and puts them<br>
46 * into the TestParameters
49 public void getCommandLineParameter(TestParameters param
, String
[] args
)
51 Properties mapping
= getMapping();
53 for (int i
= 0; i
< args
.length
;)
55 String pName
= getParameterFor(mapping
, args
[i
]).trim();
57 if (pName
.equals("TestJob"))
59 if (args
.length
> (i
+ 1))
61 pValue
= args
[i
].trim() + " " + args
[i
+ 1].trim();
66 pValue
= args
[i
].trim() + " unknown";
72 if ((i
+ 1) < args
.length
)
74 pValue
= args
[i
+ 1].trim();
76 if (pValue
.startsWith("-"))
81 else if (pValue
.startsWith("'"))
84 while (!pValue
.endsWith("'"))
87 pValue
= pValue
+ " " + args
[i
].trim();
90 pValue
= utils
.replaceAll13(pValue
, "'", "");
98 if (pName
.equals("TestDocumentPath"))
100 System
.setProperty("DOCPTH", pValue
);
102 else if (pName
.equals(PropertyName
.SRC_ROOT
))
104 System
.setProperty(pName
, pValue
);
115 param
.put(pName
, pValue
);
120 * This method returns the path to a Configuration file <br>
121 * if defined as command line parameter, an empty String elsewhere
123 public String
getIniPath(String
[] args
)
127 for (int i
= 0; i
< args
.length
; i
++)
129 if (args
[i
].equals("-ini"))
131 iniFile
= args
[i
+ 1];
140 * This method returns the path to a Configuration file <br>
141 * if defined as command line parameter, an empty String elsewhere
143 public String
getRunnerIniPath(String
[] args
)
147 for (int i
= 0; i
< args
.length
; i
++)
149 if (args
[i
].equals("-runnerini"))
151 iniFile
= args
[i
+ 1];
160 * This method maps commandline Parameters to TestParameters
162 protected Properties
getMapping()
164 Properties map
= new Properties();
165 map
.setProperty("-cs", "ConnectionString");
166 map
.setProperty("-tb", "TestBase");
167 map
.setProperty("-tdoc", "TestDocumentPath");
168 map
.setProperty("-objdsc", "DescriptionPath");
169 map
.setProperty("-cmd", "AppExecutionCommand");
170 map
.setProperty("-o", "TestJob");
171 map
.setProperty("-sce", "TestJob");
172 map
.setProperty("-p", "TestJob");
173 map
.setProperty("-aca", "AdditionalConnectionArguments");
174 map
.setProperty("-xcl", "ExclusionList");
175 map
.setProperty("-debug", "DebugIsActive");
176 map
.setProperty("-log", "LoggingIsActive");
177 map
.setProperty("-dbout", "DataBaseOut");
178 map
.setProperty("-nca", "NoCwsAttach");
183 protected String
getParameterFor(Properties map
, String name
)
185 String ret
= map
.getProperty(name
);
189 ret
= name
.substring(1);