Author: bdaw
Date: 2007-10-13 08:38:42 -0400 (Sat, 13 Oct 2007)
New Revision: 8629
Added:
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ToolingConstants.java
Modified:
modules/test/trunk/test/src/main/org/jboss/portal/test/framework/embedded/DataSourceSupport.java
modules/test/trunk/tooling/build.xml
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/JBossUnitTask.java
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsType.java
modules/test/trunk/tooling/src/resources/test/bobo-tests.xml
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/Main.java
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainBuilder.java
Log:
- add properties support for tooling
- remove tooling dependency on unit module
Modified:
modules/test/trunk/test/src/main/org/jboss/portal/test/framework/embedded/DataSourceSupport.java
===================================================================
---
modules/test/trunk/test/src/main/org/jboss/portal/test/framework/embedded/DataSourceSupport.java 2007-10-13
12:27:59 UTC (rev 8628)
+++
modules/test/trunk/test/src/main/org/jboss/portal/test/framework/embedded/DataSourceSupport.java 2007-10-13
12:38:42 UTC (rev 8629)
@@ -304,6 +304,27 @@
{
IOTools.safeClose(in);
}
+ }
+
+ public static Config obtainConfig(String datasources, String dataSourceName) throws
Exception
+ {
+ URL url =
Thread.currentThread().getContextClassLoader().getResource(datasources);
+
+ Config[] configs = fromXML(url);
+
+ for (Config config : configs)
+ {
+ if (config.getName().equals(dataSourceName))
+ {
+ return config;
+ }
+ }
+
+ throw new IllegalStateException("Could not obtain Config for
{datasourceName:datasources} - {" + dataSourceName + ":" + datasources +
"}" );
+
}
}
+
+
+
}
Modified: modules/test/trunk/tooling/build.xml
===================================================================
--- modules/test/trunk/tooling/build.xml 2007-10-13 12:27:59 UTC (rev 8628)
+++ modules/test/trunk/tooling/build.xml 2007-10-13 12:38:42 UTC (rev 8629)
@@ -216,17 +216,15 @@
<jboss-unit>
- <tests
config="/home/bdaw/Workshop/JBoss/portal/modules/test/trunk/tooling/output/resources/test/bobo-tests.xml">
- <include ids="testOne,otherTestOne"/>
- </tests>
-
+
<tests config="./output/resources/test/bobo-tests.xml"
suiteName="one">
<!-- no include tag means invoke all -->
<!-- but you can still exclude some tests -->
+ <property name="propName" value="propValue"/>
<exclude id="otherTestTwo"/>
</tests>
- <tests config="./output/resources/test/bobo-tests.xml">
+ <!--<tests config="./output/resources/test/bobo-tests.xml">
<include id="testOne"/>
<include id="otherTestOne"/>
<exclude ids="testOne,testTwo"/>
@@ -240,13 +238,13 @@
<tests config="output/resources/test/bobo-tests.xml"
suiteName="four">
<include keywords="simpleTag"/>
- </tests>
+ </tests>-->
- <tests config="output/resources/test/bobo-tests.xml">
+ <!--<tests
config="output/resources/test/bobo-tests.xml">-->
<!-- this one should fail as attribute 'id' is exclusive -->
<!--<include id="otherTestOne"
ids="testOne,testTwo" keywords="lola,lolo,loli"/>-->
- </tests>
+ <!--</tests>-->
<!-- provide noConsole="true" to disable console output -->
<reports>
Modified:
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/JBossUnitTask.java
===================================================================
---
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/JBossUnitTask.java 2007-10-13
12:27:59 UTC (rev 8628)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/JBossUnitTask.java 2007-10-13
12:38:42 UTC (rev 8629)
@@ -28,8 +28,6 @@
import org.apache.tools.ant.taskdefs.optional.junit.AggregateTransformer;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.FileSet;
-import org.jboss.unit.tooling.MainBuilder;
-import org.jboss.unit.report.impl.junit.JUnitTestReport;
import java.util.List;
import java.util.LinkedList;
Modified: modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsType.java
===================================================================
---
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsType.java 2007-10-13
12:27:59 UTC (rev 8628)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsType.java 2007-10-13
12:38:42 UTC (rev 8629)
@@ -28,14 +28,18 @@
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Environment;
import org.apache.tools.ant.taskdefs.Java;
-import org.jboss.unit.tooling.filter.IncludeTestFilter;
-import org.jboss.unit.tooling.filter.ExcludeTestFilter;
-import org.jboss.unit.tooling.Main;
+import static org.jboss.unit.tooling.ant.ToolingConstants.*;
+
import java.util.List;
import java.util.LinkedList;
import java.util.Set;
import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.HashSet;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
@@ -71,8 +75,6 @@
public void execute() throws BuildException
{
- //System.out.println("Executing Task. Includes: " + includes.size() +
" excludes: " + excludes.size() + " config: " + config);
-
//Evaluate all the include filters
Java javaTask = createJava();
@@ -153,26 +155,32 @@
private void addArguments(Java javaTask)
{
- javaTask.createArg().setValue(Main.OPT_CONFIG + "=" + config);
+ javaTask.createArg().setValue(OPT_CONFIG + "=" + config);
if (getSuiteName() != null)
{
- javaTask.createArg().setValue(Main.OPT_SUITE_NAME + "=" +
getSuiteName());
+ javaTask.createArg().setValue(OPT_SUITE_NAME + "=" + getSuiteName());
}
if (getReports() != null && getReports().getXmlReports() != null)
{
- javaTask.createArg().setValue(Main.OPT_XML_REPORT_DIR + "=" +
getReports().getXmlReports().getToDir());
+ javaTask.createArg().setValue(OPT_XML_REPORT_DIR + "=" +
getReports().getXmlReports().getToDir());
}
- // Filters to aggregate all the values
- IncludeTestFilter includeFilter = new IncludeTestFilter();
+ Set<String> includeIds = new HashSet<String>();
- ExcludeTestFilter excludeFilter = new ExcludeTestFilter();
+ Set<String> includeKeywords = new HashSet<String>();
+ Set<String> excludeIds = new HashSet<String>();
+
+ Set<String> excludeKeywords = new HashSet<String>();
+
+
+
+
for (IncludeType include : includes)
{
//Check attributes consistency
@@ -185,38 +193,29 @@
if (include.getIds() != null)
{
- includeFilter.addUnparsedNames(include.getIds());
+ addUnparsedString(includeIds, include.getIds());
}
if (include.getKeywords() != null)
{
- includeFilter.addUnparsedKeywords(include.getKeywords());
+ addUnparsedString(includeKeywords, include.getKeywords());
}
- if (include.getIdPatterns() != null)
- {
- includeFilter.addUnparsedNamePatterns(include.getIdPatterns());
- }
if (include.getId() != null)
{
- includeFilter.addUnparsedNames(include.getId());
+ addUnparsedString(includeIds, include.getId());
}
}
- if (includeFilter.getNames().size() != 0)
+ if (includeIds.size() != 0)
{
- javaTask.createArg().setValue(generateArgument(includeFilter.getNames(),
Main.OPT_NAMES));
+ javaTask.createArg().setValue(generateArgument(includeIds, OPT_IDS));
}
- if (includeFilter.getNamePatterns().size() != 0)
+ if (includeKeywords.size() != 0)
{
- javaTask.createArg().setValue(generateArgument(includeFilter.getNamePatterns(),
Main.OPT_PATTERNS));
+ javaTask.createArg().setValue(generateArgument(includeKeywords, OPT_KEYWORDS));
}
- if (includeFilter.getKeywords().size() != 0)
- {
- javaTask.createArg().setValue(generateArgument(includeFilter.getKeywords(),
Main.OPT_KEYWORDS));
- }
-
// List<TestFilter> excludeFilters = new LinkedList<TestFilter>();
for (ExcludeType exclude : excludes)
@@ -229,41 +228,78 @@
if (exclude.getIds() != null)
{
- excludeFilter.addUnparsedNames(exclude.getIds());
+ addUnparsedString(excludeIds, exclude.getIds());
}
if (exclude.getKeywords() != null)
{
- excludeFilter.addUnparsedKeywords(exclude.getKeywords());
+ addUnparsedString(excludeKeywords, exclude.getKeywords());
}
- if (exclude.getIdPatterns() != null)
- {
- excludeFilter.addUnparsedNamePatterns(exclude.getIdPatterns());
- }
if (exclude.getId() != null)
{
- excludeFilter.addUnparsedNames(exclude.getId());
+ addUnparsedString(excludeIds, exclude.getId());
}
}
- if (excludeFilter.getNames().size() != 0)
+ if (excludeIds.size() != 0)
{
- javaTask.createArg().setValue(generateArgument(excludeFilter.getNames(),
Main.OPT_EX_NAMES));
+ javaTask.createArg().setValue(generateArgument(excludeIds, OPT_EX_IDS));
}
- if (excludeFilter.getNamePatterns().size() != 0)
+ if (excludeKeywords.size() != 0)
{
- javaTask.createArg().setValue(generateArgument(excludeFilter.getNamePatterns(),
Main.OPT_EX_PATTERNS));
+ javaTask.createArg().setValue(generateArgument(excludeKeywords,
OPT_EX_KEYWORDS));
}
-
- if (excludeFilter.getKeywords().size() != 0)
+
+
+ if (properties.size() > 0)
{
- javaTask.createArg().setValue(generateArgument(excludeFilter.getKeywords(),
Main.OPT_EX_KEYWORDS));
+
+ Map<String,String> taskProperties = new HashMap<String,String>();
+
+ for (PropertyType property : properties)
+ {
+ taskProperties.put(property.getName(),property.getValue());
+ }
+
+ updateProperties(taskProperties);
+
+
+ StringBuilder props = new StringBuilder("[");
+
+ for (Iterator<String> iterator = taskProperties.keySet().iterator();
iterator.hasNext();)
+ {
+ String propertyKey = iterator.next();
+
+ String propertyValue = taskProperties.get(propertyKey);
+
+ props.append(propertyKey + "=" + propertyValue);
+
+ if (iterator.hasNext())
+ {
+ props.append(",");
+ }
+ else
+ {
+ props.append("]");
+ }
+ }
+
+ javaTask.createArg().setValue(OPT_PROPERTIES + "=" + props);
+
}
+ }
- for (PropertyType property : properties)
+ private void addUnparsedString(Set<String> set, String valueString)
+ {
+ if (valueString == null)
{
- javaTask.createArg().setValue(Main.OPT_PROPERTY + "=" +
property.getName() + "=" + property.getValue());
+ throw new IllegalArgumentException("valueString cannot be null");
}
+ String[] parsedValues = valueString.split(",");
+ for (String keyword : parsedValues)
+ {
+ set.add(keyword.trim());
+ }
}
private String generateArgument(Set<String> values, String argumentName)
@@ -280,8 +316,82 @@
}
+ private void updateProperties(Map<String,String> propMap)
+ {
+ Hashtable<String, String> sysProps =
(Hashtable<String,String>)getProject().getProperties();
+
+
+
+ String sysProperties = (String)sysProps.get(JBOSS_UNIT_PROPERTIES);
+
+ if (sysProperties != null && sysProperties.length() > 0)
+ {
+ Map<String,String> parsedProps = parseProperties(sysProperties);
+ propMap.putAll(parsedProps);
+ }
+
+ for (String sysPropKey : sysProps.keySet())
+ {
+
+ if (sysPropKey.startsWith(JBOSS_UNIT_PROPERTY))
+ {
+ String propertyString = sysPropKey + "=" +
sysProps.get(sysPropKey);
+
+ propertyString = propertyString.replaceFirst(JBOSS_UNIT_PROPERTY +
"\\.", "");
+
+ //
+ String[] patternValues = propertyString.split("=");
+
+ //
+ if (patternValues.length != 2)
+ {
+ throw new IllegalArgumentException("Property not accepted, it should
match a=b and it is " + propertyString);
+ }
+
+ propMap.put(patternValues[0],patternValues[1]);
+
+ }
+
+
+ }
+
+ }
+
+ public static Map<String,String> parseProperties(String propertiesString)
+ {
+ if (!propertiesString.matches("\\[.+=.+(,.+=.+)*\\]"))
+ {
+ throw new IllegalArgumentException("Parameters don't follow proper
format: [a=b,c=d,e=f]");
+ }
+
+ Map<String,String> parsedProps = new HashMap<String,String>();
+
+ propertiesString =
propertiesString.replaceAll("\\[","").replaceAll("\\]","");
+
+ String propertyGroups[] = propertiesString.split(",");
+
+ for (String propertyGroup : propertyGroups)
+ {
+
+ String property[] = propertyGroup.split("=");
+
+ //
+ if (property.length != 2)
+ {
+ throw new IllegalArgumentException("Property not accepted, it should
match a=b and it is " + property);
+ }
+
+ parsedProps.put(property[0],property[1]);
+ }
+ return parsedProps;
+ }
+
+
+
+
+
public void addConfiguredInclude(IncludeType include)
{
this.includes.add(include);
@@ -302,11 +412,6 @@
this.properties.add(property);
}
- public void addTask(Task task)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
public String getConfig()
{
return config;
Added:
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ToolingConstants.java
===================================================================
--- modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ToolingConstants.java
(rev 0)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ToolingConstants.java 2007-10-13
12:38:42 UTC (rev 8629)
@@ -0,0 +1,63 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling.ant;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public final class ToolingConstants
+{
+
+ public static final String JBOSS_UNIT_PROPERTIES = "jboss.unit.properties";
+
+ public static final String JBOSS_UNIT_PROPERTY = "jboss.unit.property";
+
+ public static final String OPT_ID = "--id";
+
+ public static final String OPT_IDS = "--ids";
+
+ public static final String OPT_KEYWORDS = "--keywords";
+
+ public static final String OPT_EX_ID = "--ex_id";
+
+ public static final String OPT_EX_IDS = "--ex_ids";
+
+ public static final String OPT_EX_KEYWORDS = "--ex_keywords";
+
+ public static final String OPT_CONFIG = "--config";
+
+ public static final String OPT_SUITE_NAME = "--suite_name";
+
+ public static final String OPT_NO_CONSOLE = "--no_console";
+
+ public static final String OPT_XML_REPORT_DIR = "--xml_report_dir";
+
+ public static final String OPT_HTML_REPORT_DIR = "--html_report_dir";
+
+ public static final String OPT_PROPERTY = "--property";
+
+ public static final String OPT_PROPERTIES = "--properties";
+
+
+}
Modified: modules/test/trunk/tooling/src/resources/test/bobo-tests.xml
===================================================================
--- modules/test/trunk/tooling/src/resources/test/bobo-tests.xml 2007-10-13 12:27:59 UTC
(rev 8628)
+++ modules/test/trunk/tooling/src/resources/test/bobo-tests.xml 2007-10-13 12:38:42 UTC
(rev 8629)
@@ -4,10 +4,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
<pojo>
- <test-def id="bobo">
+ <test>
<class name="org.jboss.test.unit.tooling.bobo.BoboTest1"/>
- </test-def>
- <test refid="bobo">
</test>
</pojo>
</jboss-unit>
\ No newline at end of file
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/tooling/Main.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/tooling/Main.java 2007-10-13 12:27:59
UTC (rev 8628)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/tooling/Main.java 2007-10-13 12:38:42
UTC (rev 8629)
@@ -52,32 +52,22 @@
private final TestRunnerEventBroadcaster broadcaster;
-// public static final String JBOSS_UNIT_NAMES = "jboss.unit.names";
-//
-// public static final String JBOSS_UNIT_KEYWORDS = "jboss.unit.keywords";
-//
-// public static final String JBOSS_UNIT_PATTERNS = "jboss.unit.patterns";
-//
-// public static final String JBOSS_UNIT_CONFIG = "jboss.unit.config";
-//
-// public static final String JBOSS_UNIT_SUITE_NAME =
"jboss.unit.suite_name";
+ public static final String JBOSS_UNIT_PROPERTIES = "jboss.unit.properties";
+ public static final String JBOSS_UNIT_PROPERTY = "jboss.unit.property";
+
public static final String OPT_ID = "--id";
- public static final String OPT_NAMES = "--names";
+ public static final String OPT_IDS = "--ids";
public static final String OPT_KEYWORDS = "--keywords";
- public static final String OPT_PATTERNS = "--patterns";
-
public static final String OPT_EX_ID = "--ex_id";
- public static final String OPT_EX_NAMES = "--ex_names";
+ public static final String OPT_EX_IDS = "--ex_ids";
public static final String OPT_EX_KEYWORDS = "--ex_keywords";
- public static final String OPT_EX_PATTERNS = "--ex_patterns";
-
public static final String OPT_CONFIG = "--config";
public static final String OPT_SUITE_NAME = "--suite_name";
@@ -95,6 +85,8 @@
*/
public static final String OPT_PROPERTY = "--property";
+ public static final String OPT_PROPERTIES = "--properties";
+
public static final Set options;
public static final Set options_no_arg;
@@ -102,13 +94,11 @@
static {
Set<String> opts = new HashSet<String>();
opts.add(OPT_ID);
- opts.add(OPT_NAMES);
+ opts.add(OPT_IDS);
opts.add(OPT_KEYWORDS);
- opts.add(OPT_PATTERNS);
opts.add(OPT_EX_ID);
- opts.add(OPT_EX_NAMES);
+ opts.add(OPT_EX_IDS);
opts.add(OPT_EX_KEYWORDS);
- opts.add(OPT_EX_PATTERNS);
opts.add(OPT_CONFIG);
opts.add(OPT_SUITE_NAME);
opts.add(OPT_NO_CONSOLE);
@@ -159,6 +149,11 @@
public void execute()
{
+ // For now lets just be verbose. Later we need some real logging + 'debug'
switch
+ System.out.println("TestRunnerContext contains: ");
+ System.out.println("Properties: " + properties.toString());
+
+
TestRunnerContextSupport runnerContext = new TestRunnerContextSupport(properties,
new ParametrizationSet(), mainFilter, broadcaster);
runner.run(runnerContext);
}
@@ -186,8 +181,6 @@
MainBuilder builder = null;
-
-
if (arguments.keySet().contains(OPT_SUITE_NAME))
{
builder = new MainBuilder(arguments.get(OPT_CONFIG),
arguments.get(OPT_SUITE_NAME));
@@ -200,67 +193,72 @@
}
-
- if (arguments.keySet().contains(OPT_NAMES))
+ for (String argument : arguments.keySet())
{
- builder.addUnparsedNames(arguments.get(OPT_NAMES));
- }
- if (arguments.keySet().contains(OPT_ID))
- {
- builder.addName(arguments.get(OPT_ID));
- }
+ if (argument.equals(OPT_IDS))
+ {
+ builder.addUnparsedNames(arguments.get(OPT_IDS));
+ }
- if (arguments.keySet().contains(OPT_KEYWORDS))
- {
- builder.addUnparsedKeywords(arguments.get(OPT_KEYWORDS));
- }
+ if (argument.equals(OPT_ID))
+ {
+ builder.addName(arguments.get(OPT_ID));
+ }
- if (arguments.keySet().contains(OPT_PATTERNS))
- {
- builder.addUnparsedNamePatterns(arguments.get(OPT_PATTERNS));
- }
+ if (argument.equals(OPT_KEYWORDS))
+ {
+ builder.addUnparsedKeywords(arguments.get(OPT_KEYWORDS));
+ }
- if (arguments.keySet().contains(OPT_EX_NAMES))
- {
- builder.addUnparsedExcludeNames(arguments.get(OPT_EX_NAMES));
- }
+ if (argument.equals(OPT_EX_IDS))
+ {
+ builder.addUnparsedExcludeNames(arguments.get(OPT_EX_IDS));
+ }
- if (arguments.keySet().contains(OPT_EX_ID))
- {
- builder.addExcludeName(arguments.get(OPT_EX_ID));
- }
+ if (argument.equals(OPT_EX_ID))
+ {
+ builder.addExcludeName(arguments.get(OPT_EX_ID));
+ }
- if (arguments.keySet().contains(OPT_EX_KEYWORDS))
- {
- builder.addUnparsedExcludeKeywords(arguments.get(OPT_EX_KEYWORDS));
- }
+ if (argument.equals(OPT_EX_KEYWORDS))
+ {
+ builder.addUnparsedExcludeKeywords(arguments.get(OPT_EX_KEYWORDS));
+ }
- if (arguments.keySet().contains(OPT_EX_PATTERNS))
- {
- builder.addUnparsedExcludeNamePatterns(arguments.get(OPT_EX_PATTERNS));
- }
+ if (argument.equals(OPT_NO_CONSOLE))
+ {
+ builder.setNoConsole(true);
+ }
- if (arguments.keySet().contains(OPT_NO_CONSOLE))
- {
- builder.setNoConsole(true);
- }
+ if (argument.equals(OPT_XML_REPORT_DIR))
+ {
+ builder.setXMLReportDir(arguments.get(OPT_XML_REPORT_DIR));
+ }
- if (arguments.keySet().contains(OPT_XML_REPORT_DIR))
- {
- builder.setXMLReportDir(arguments.get(OPT_XML_REPORT_DIR));
- }
+ if (argument.equals(OPT_HTML_REPORT_DIR))
+ {
+ builder.setHTMLReportDir(arguments.get(OPT_HTML_REPORT_DIR));
+ }
- if (arguments.keySet().contains(OPT_HTML_REPORT_DIR))
- {
- builder.setHTMLReportDir(arguments.get(OPT_HTML_REPORT_DIR));
- }
+ if (argument.startsWith(OPT_PROPERTY))
+ {
- if (arguments.keySet().contains(OPT_PROPERTY))
- {
- builder.addUnparsedProperty(arguments.get(OPT_PROPERTY));
+ //pass whole --properties.name=value to be parsed
+ builder.addUnparsedProperty(argument + arguments.get(OPT_PROPERTY));
+ }
+
+ if (argument.equals(OPT_PROPERTIES))
+ {
+ builder.addUnparsedProperties(arguments.get(OPT_PROPERTIES));
+ }
+
}
+
+
+
+
Main main = builder.build();
main.execute();
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainBuilder.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainBuilder.java 2007-10-13
12:27:59 UTC (rev 8628)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainBuilder.java 2007-10-13
12:38:42 UTC (rev 8629)
@@ -275,6 +275,8 @@
throw new IllegalArgumentException("No null property name accepted");
}
+ propertyString = propertyString.replaceFirst(Main.OPT_PROPERTY + "\\.",
"");
+
//
String[] patternValues = propertyString.split("=");
@@ -305,7 +307,53 @@
return this;
}
+ public void addUnparsedProperties(String propertiesString)
+ {
+ if (propertiesString == null)
+ {
+ throw new IllegalArgumentException("Properties cannot be null");
+ }
+ Map<String, String> props = parseProperties(propertiesString);
+
+ for (String key : props.keySet())
+ {
+ addProperty(key, props.get(key));
+ }
+
+
+ }
+
+ public static Map<String,String> parseProperties(String propertiesString)
+ {
+ if (!propertiesString.matches("\\[.+=.+(,.+=.+)*\\]"))
+ {
+ throw new IllegalArgumentException("Parameters don't follow proper
format: [a=b,c=d,e=f]");
+ }
+
+ Map<String,String> parsedProps = new HashMap<String,String>();
+
+ propertiesString =
propertiesString.replaceAll("\\[","").replaceAll("\\]","");
+
+ String propertyGroups[] = propertiesString.split(",");
+
+ for (String propertyGroup : propertyGroups)
+ {
+ String property[] = propertyGroup.split("=");
+
+ //
+ if (property.length != 2)
+ {
+ throw new IllegalArgumentException("Property not accepted, it should
match a=b and it is " + property);
+ }
+
+ parsedProps.put(property[0],property[1]);
+ }
+ return parsedProps;
+ }
+
+
+
public String getSuiteName()
{
return suiteName;
@@ -432,5 +480,6 @@
}
+
}