Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2013-07-30 08:30:39 +0000
committerMarkus Tiede2013-07-30 08:30:39 +0000
commite4b6f0ff6b2261988b2143916a70a419300b23d6 (patch)
tree07edaa25cf641f874342c84471e0202a72f6cad0
parentf78a2da94ef5b184acd214fe75470d62f4b20de8 (diff)
downloadorg.eclipse.jubula.core-e4b6f0ff6b2261988b2143916a70a419300b23d6.tar.gz
org.eclipse.jubula.core-e4b6f0ff6b2261988b2143916a70a419300b23d6.tar.xz
org.eclipse.jubula.core-e4b6f0ff6b2261988b2143916a70a419300b23d6.zip
Non-sprint task - implementation for enhancement http://bugs.eclipse.org/413968
-rw-r--r--org.eclipse.jubula.client.core/plugin.xml49
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/Base64DecodeFunctionEvaluator.java25
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/Base64EncodeFunctionEvaluator.java25
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/RandomIntegerFunctionEvaluator.java26
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/StringReplaceAllFunctionEvaluator.java39
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/UUIDFunctionEvaluator.java23
6 files changed, 187 insertions, 0 deletions
diff --git a/org.eclipse.jubula.client.core/plugin.xml b/org.eclipse.jubula.client.core/plugin.xml
index dfe0c2aa0..02968641a 100644
--- a/org.eclipse.jubula.client.core/plugin.xml
+++ b/org.eclipse.jubula.client.core/plugin.xml
@@ -162,6 +162,55 @@
type="string">
</parameter>
</function>
+ <function
+ class="org.eclipse.jubula.client.core.functions.StringReplaceAllFunctionEvaluator"
+ evaluator="local"
+ name="replaceAll">
+ <parameter
+ name="string"
+ type="string">
+ </parameter>
+ <parameter
+ name="regex"
+ type="string">
+ </parameter>
+ <parameter
+ name="replacement"
+ type="string">
+ </parameter>
+ </function>
+ <function
+ class="org.eclipse.jubula.client.core.functions.UUIDFunctionEvaluator"
+ evaluator="local"
+ name="uuid">
+ </function>
+ <function
+ class="org.eclipse.jubula.client.core.functions.RandomIntegerFunctionEvaluator"
+ evaluator="local"
+ name="randomInt">
+ <parameter
+ name="exclusiveMaxValue"
+ type="number">
+ </parameter>
+ </function>
+ <function
+ class="org.eclipse.jubula.client.core.functions.Base64EncodeFunctionEvaluator"
+ evaluator="local"
+ name="base64Encode">
+ <parameter
+ name="string"
+ type="string">
+ </parameter>
+ </function>
+ <function
+ class="org.eclipse.jubula.client.core.functions.Base64DecodeFunctionEvaluator"
+ evaluator="local"
+ name="base64Decode">
+ <parameter
+ name="string"
+ type="string">
+ </parameter>
+ </function>
</extension>
</plugin>
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/Base64DecodeFunctionEvaluator.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/Base64DecodeFunctionEvaluator.java
new file mode 100644
index 000000000..f8e0ecb3f
--- /dev/null
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/Base64DecodeFunctionEvaluator.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2012 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.core.functions;
+
+import org.apache.commons.codec.binary.Base64;
+import org.eclipse.jubula.tools.exception.InvalidDataException;
+
+/**
+ * Function that decodes a base 64 string into a string
+ */
+public class Base64DecodeFunctionEvaluator extends AbstractFunctionEvaluator {
+ /** {@inheritDoc} */
+ public String evaluate(String[] arguments) throws InvalidDataException {
+ validateParamCount(arguments, 1);
+ return new String(Base64.decodeBase64(arguments[0].getBytes()));
+ }
+}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/Base64EncodeFunctionEvaluator.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/Base64EncodeFunctionEvaluator.java
new file mode 100644
index 000000000..50b211d34
--- /dev/null
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/Base64EncodeFunctionEvaluator.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2012 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.core.functions;
+
+import org.apache.commons.codec.binary.Base64;
+import org.eclipse.jubula.tools.exception.InvalidDataException;
+
+/**
+ * Function that encodes a given string into a base 64 string
+ */
+public class Base64EncodeFunctionEvaluator extends AbstractFunctionEvaluator {
+ /** {@inheritDoc} */
+ public String evaluate(String[] arguments) throws InvalidDataException {
+ validateParamCount(arguments, 1);
+ return new String(Base64.encodeBase64(arguments[0].getBytes()));
+ }
+}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/RandomIntegerFunctionEvaluator.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/RandomIntegerFunctionEvaluator.java
new file mode 100644
index 000000000..a593211d1
--- /dev/null
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/RandomIntegerFunctionEvaluator.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2012 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.core.functions;
+
+import org.apache.commons.lang.math.RandomUtils;
+import org.eclipse.jubula.tools.exception.InvalidDataException;
+
+/**
+ * Function that generates a random integer
+ */
+public class RandomIntegerFunctionEvaluator extends AbstractFunctionEvaluator {
+ /** {@inheritDoc} */
+ public String evaluate(String[] arguments) throws InvalidDataException {
+ validateParamCount(arguments, 1);
+ int exclusiveMaxValue = Integer.parseInt(arguments[0]);
+ return String.valueOf(RandomUtils.nextInt(exclusiveMaxValue));
+ }
+}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/StringReplaceAllFunctionEvaluator.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/StringReplaceAllFunctionEvaluator.java
new file mode 100644
index 000000000..ebb526535
--- /dev/null
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/StringReplaceAllFunctionEvaluator.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2012 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.core.functions;
+
+import java.util.regex.PatternSyntaxException;
+
+import org.eclipse.jubula.tools.exception.InvalidDataException;
+import org.eclipse.jubula.tools.messagehandling.MessageIDs;
+
+/**
+ * Function that performs a string replaceAll
+ */
+public class StringReplaceAllFunctionEvaluator
+ extends AbstractFunctionEvaluator {
+ /** {@inheritDoc} */
+ public String evaluate(String[] arguments) throws InvalidDataException {
+ validateParamCount(arguments, 3);
+ final String string = arguments[0];
+ final String regex = arguments[1];
+ final String replacement = arguments[2];
+
+ String replacedString = string;
+ try {
+ replacedString = string.replaceAll(regex, replacement);
+ } catch (PatternSyntaxException e) {
+ throw new InvalidDataException(e.getLocalizedMessage(),
+ MessageIDs.E_FUNCTION_EVAL_ERROR);
+ }
+ return replacedString;
+ }
+}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/UUIDFunctionEvaluator.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/UUIDFunctionEvaluator.java
new file mode 100644
index 000000000..691620eb3
--- /dev/null
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/functions/UUIDFunctionEvaluator.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2012 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.core.functions;
+
+import java.util.UUID;
+
+/**
+ * Function that generates a random Java UUID
+ */
+public class UUIDFunctionEvaluator implements IFunctionEvaluator {
+ /** {@inheritDoc} */
+ public String evaluate(String[] arguments) {
+ return UUID.randomUUID().toString();
+ }
+}

Back to the top