bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / runner / helper / ClParser.java
blob4ac7e87445faafbd35377828edfe1244cbd5b587
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package helper;
20 import java.io.File;
21 import java.util.Properties;
23 import lib.TestParameters;
24 import util.PropertyName;
25 import util.utils;
27 /**
28 * This class parses commandline Argument and stores <br>
29 * them into TestParameter
31 public class ClParser
34 * Parses the commandline argument and puts them<br>
35 * into the TestParameters
38 public void getCommandLineParameter(TestParameters param, String[] args)
40 Properties mapping = getMapping();
42 for (int i = 0; i < args.length;)
44 String pName = getParameterFor(mapping, args[i]).trim();
45 String pValue = "";
46 if (pName.equals("TestJob"))
48 if (args.length > (i + 1))
50 pValue = args[i].trim() + " " + args[i + 1].trim();
51 i += 2;
53 else
55 pValue = args[i].trim() + " unknown";
56 i += 2;
59 else
61 if ((i + 1) < args.length)
63 pValue = args[i + 1].trim();
65 if (pValue.startsWith("-"))
67 i++;
68 pValue = "yes";
70 else if (pValue.startsWith("'"))
72 i++;
73 while (!pValue.endsWith("'"))
75 i++;
76 pValue = pValue + " " + args[i].trim();
79 pValue = utils.replaceAll13(pValue, "'", "");
80 i++;
82 else
84 i += 2;
87 if (pName.equals("TestDocumentPath"))
89 System.setProperty(
90 "DOCPTH", new File(pValue).getAbsolutePath());
92 else if (pName.equals(PropertyName.SRC_ROOT))
94 System.setProperty(pName, pValue);
98 else
100 pValue = "yes";
101 i++;
105 param.put(pName, pValue);
110 * This method returns the path to a Configuration file <br>
111 * if defined as command line parameter, an empty String elsewhere
113 public String getIniPath(String[] args)
115 String iniFile = "";
117 for (int i = 0; i < args.length; i++)
119 if (args[i].equals("-ini"))
121 iniFile = args[i + 1];
122 break;
126 return iniFile;
130 * This method returns the path to a Configuration file <br>
131 * if defined as command line parameter, an empty String elsewhere
133 public String getRunnerIniPath(String[] args)
135 String iniFile = "";
137 for (int i = 0; i < args.length; i++)
139 if (args[i].equals("-runnerini"))
141 iniFile = args[i + 1];
142 break;
146 return iniFile;
150 * This method maps commandline Parameters to TestParameters
152 protected Properties getMapping()
154 Properties map = new Properties();
155 map.setProperty("-cs", "ConnectionString");
156 map.setProperty("-tb", "TestBase");
157 map.setProperty("-tdoc", "TestDocumentPath");
158 map.setProperty("-objdsc", "DescriptionPath");
159 map.setProperty("-cmd", "AppExecutionCommand");
160 map.setProperty("-o", "TestJob");
161 map.setProperty("-sce", "TestJob");
162 map.setProperty("-p", "TestJob");
163 map.setProperty("-aca", "AdditionalConnectionArguments");
164 map.setProperty("-xcl", "ExclusionList");
165 map.setProperty("-debug", "DebugIsActive");
166 map.setProperty("-log", "LoggingIsActive");
167 map.setProperty("-dbout", "DataBaseOut");
168 map.setProperty("-nca", "NoCwsAttach");
170 return map;
173 protected String getParameterFor(Properties map, String name)
175 String ret = map.getProperty(name);
177 if (ret == null)
179 ret = name.substring(1);
182 return ret;