update dev300-m58
[ooovba.git] / qadevOOo / runner / helper / ClParser.java
blob8cf0f808816e870c72c879ed66cefa76abdbeeb2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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 ************************************************************************/
30 package helper;
32 import java.util.Properties;
34 import lib.TestParameters;
35 import util.PropertyName;
36 import util.utils;
38 /**
39 * This class parses commandline Argument and stores <br>
40 * them into TestParameter
42 public class ClParser
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();
56 String pValue = "";
57 if (pName.equals("TestJob"))
59 if (args.length > (i + 1))
61 pValue = args[i].trim() + " " + args[i + 1].trim();
62 i += 2;
64 else
66 pValue = args[i].trim() + " unknown";
67 i += 2;
70 else
72 if ((i + 1) < args.length)
74 pValue = args[i + 1].trim();
76 if (pValue.startsWith("-"))
78 i++;
79 pValue = "yes";
81 else if (pValue.startsWith("'"))
83 i++;
84 while (!pValue.endsWith("'"))
86 i++;
87 pValue = pValue + " " + args[i].trim();
90 pValue = utils.replaceAll13(pValue, "'", "");
91 i++;
93 else
95 i += 2;
98 if (pName.equals("TestDocumentPath"))
100 System.setProperty("DOCPTH", pValue);
102 else if (pName.equals(PropertyName.SRC_ROOT))
104 System.setProperty(pName, pValue);
108 else
110 pValue = "yes";
111 i++;
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)
125 String iniFile = "";
127 for (int i = 0; i < args.length; i++)
129 if (args[i].equals("-ini"))
131 iniFile = args[i + 1];
132 break;
136 return iniFile;
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)
145 String iniFile = "";
147 for (int i = 0; i < args.length; i++)
149 if (args[i].equals("-runnerini"))
151 iniFile = args[i + 1];
152 break;
156 return iniFile;
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");
180 return map;
183 protected String getParameterFor(Properties map, String name)
185 String ret = map.getProperty(name);
187 if (ret == null)
189 ret = name.substring(1);
192 return ret;