Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / runner / helper / ClParser.java
blob583aea56f9770530e9bf97e6762ea253554c9363
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 package helper;
29 import java.io.File;
30 import java.util.Properties;
32 import lib.TestParameters;
33 import util.PropertyName;
34 import util.utils;
36 /**
37 * This class parses commandline Argument and stores <br>
38 * them into TestParameter
40 public class ClParser
43 * Parses the commandline argument and puts them<br>
44 * into the TestParameters
47 public void getCommandLineParameter(TestParameters param, String[] args)
49 Properties mapping = getMapping();
51 for (int i = 0; i < args.length;)
53 String pName = getParameterFor(mapping, args[i]).trim();
54 String pValue = "";
55 if (pName.equals("TestJob"))
57 if (args.length > (i + 1))
59 pValue = args[i].trim() + " " + args[i + 1].trim();
60 i += 2;
62 else
64 pValue = args[i].trim() + " unknown";
65 i += 2;
68 else
70 if ((i + 1) < args.length)
72 pValue = args[i + 1].trim();
74 if (pValue.startsWith("-"))
76 i++;
77 pValue = "yes";
79 else if (pValue.startsWith("'"))
81 i++;
82 while (!pValue.endsWith("'"))
84 i++;
85 pValue = pValue + " " + args[i].trim();
88 pValue = utils.replaceAll13(pValue, "'", "");
89 i++;
91 else
93 i += 2;
96 if (pName.equals("TestDocumentPath"))
98 System.setProperty(
99 "DOCPTH", new File(pValue).getAbsolutePath());
101 else if (pName.equals(PropertyName.SRC_ROOT))
103 System.setProperty(pName, pValue);
107 else
109 pValue = "yes";
110 i++;
114 param.put(pName, pValue);
119 * This method returns the path to a Configuration file <br>
120 * if defined as command line parameter, an empty String elsewhere
122 public String getIniPath(String[] args)
124 String iniFile = "";
126 for (int i = 0; i < args.length; i++)
128 if (args[i].equals("-ini"))
130 iniFile = args[i + 1];
131 break;
135 return iniFile;
139 * This method returns the path to a Configuration file <br>
140 * if defined as command line parameter, an empty String elsewhere
142 public String getRunnerIniPath(String[] args)
144 String iniFile = "";
146 for (int i = 0; i < args.length; i++)
148 if (args[i].equals("-runnerini"))
150 iniFile = args[i + 1];
151 break;
155 return iniFile;
159 * This method maps commandline Parameters to TestParameters
161 protected Properties getMapping()
163 Properties map = new Properties();
164 map.setProperty("-cs", "ConnectionString");
165 map.setProperty("-tb", "TestBase");
166 map.setProperty("-tdoc", "TestDocumentPath");
167 map.setProperty("-objdsc", "DescriptionPath");
168 map.setProperty("-cmd", "AppExecutionCommand");
169 map.setProperty("-o", "TestJob");
170 map.setProperty("-sce", "TestJob");
171 map.setProperty("-p", "TestJob");
172 map.setProperty("-aca", "AdditionalConnectionArguments");
173 map.setProperty("-xcl", "ExclusionList");
174 map.setProperty("-debug", "DebugIsActive");
175 map.setProperty("-log", "LoggingIsActive");
176 map.setProperty("-dbout", "DataBaseOut");
177 map.setProperty("-nca", "NoCwsAttach");
179 return map;
182 protected String getParameterFor(Properties map, String name)
184 String ret = map.getProperty(name);
186 if (ret == null)
188 ret = name.substring(1);
191 return ret;