Bump version to 24.04.3.4
[LibreOffice.git] / qadevOOo / runner / helper / ClParser.java
blob1dd70dbb9c1bc93bfc73c84d609f2d365631f69c
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.HashMap;
23 import lib.TestParameters;
24 import util.PropertyName;
26 /**
27 * This class parses commandline Argument and stores <br>
28 * them into TestParameter
30 public class ClParser
33 * Parses the commandline argument and puts them<br>
34 * into the TestParameters
37 public void getCommandLineParameter(TestParameters param, String[] args)
39 for (int i = 0; i < args.length;)
41 String pName = getParameterFor(args[i]).trim();
42 String pValue = "";
43 if (pName.equals("TestJob"))
45 if (args.length > (i + 1))
47 pValue = args[i].trim() + " " + args[i + 1].trim();
48 i += 2;
50 else
52 pValue = args[i].trim() + " unknown";
53 i += 2;
56 else
58 if ((i + 1) < args.length)
60 pValue = args[i + 1].trim();
62 if (pValue.startsWith("-"))
64 i++;
65 pValue = "yes";
67 else if (pValue.startsWith("'"))
69 i++;
70 while (!pValue.endsWith("'"))
72 i++;
73 pValue = pValue + " " + args[i].trim();
76 pValue = pValue.replace("'", "");
77 i++;
79 else
81 i += 2;
84 if (pName.equals("TestDocumentPath"))
86 System.setProperty(
87 "DOCPTH", new File(pValue).getAbsolutePath());
89 else if (pName.equals(PropertyName.SRC_ROOT))
91 System.setProperty(pName, pValue);
95 else
97 pValue = "yes";
98 i++;
102 param.put(pName, pValue);
107 * Map command-line Parameters to TestParameters
109 private static final java.util.Map<String,String> COMMAND_LINE_OPTION_TO_TEST_PARAMETER = new HashMap<String,String>();
110 static {
111 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-cs", "ConnectionString");
112 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-tb", "TestBase");
113 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-tdoc", "TestDocumentPath");
114 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-objdsc", "DescriptionPath");
115 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-cmd", "AppExecutionCommand");
116 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-o", "TestJob");
117 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-sce", "TestJob");
118 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-p", "TestJob");
119 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-aca", "AdditionalConnectionArguments");
120 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-xcl", "ExclusionList");
121 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-debug", "DebugIsActive");
122 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-log", "LoggingIsActive");
123 COMMAND_LINE_OPTION_TO_TEST_PARAMETER.put("-dbout", "DataBaseOut");
126 private String getParameterFor(String name)
128 String ret = COMMAND_LINE_OPTION_TO_TEST_PARAMETER.get(name);
130 if (ret == null)
132 ret = name.substring(1);
135 return ret;