Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZeb Ford-Reitz2012-01-24 14:12:35 +0000
committerZeb Ford-Reitz2012-01-24 14:12:35 +0000
commit9de7169a3baaac7fb28c9b24d44db5559b8c174d (patch)
tree0e72fa60270b71f2da9210c6740520f909750521 /org.eclipse.jubula.client.core.tests
parentad05b96cee74af078ad8ea2eb3fe2330c472dfba (diff)
downloadorg.eclipse.jubula.core-9de7169a3baaac7fb28c9b24d44db5559b8c174d.tar.gz
org.eclipse.jubula.core-9de7169a3baaac7fb28c9b24d44db5559b8c174d.tar.xz
org.eclipse.jubula.core-9de7169a3baaac7fb28c9b24d44db5559b8c174d.zip
Adds automated tests for Parameter parsing.
Diffstat (limited to 'org.eclipse.jubula.client.core.tests')
-rw-r--r--org.eclipse.jubula.client.core.tests/.classpath7
-rw-r--r--org.eclipse.jubula.client.core.tests/.gitignore2
-rw-r--r--org.eclipse.jubula.client.core.tests/.project28
-rw-r--r--org.eclipse.jubula.client.core.tests/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--org.eclipse.jubula.client.core.tests/META-INF/MANIFEST.MF9
-rw-r--r--org.eclipse.jubula.client.core.tests/build.properties11
-rw-r--r--org.eclipse.jubula.client.core.tests/src/org/eclipse/jubula/client/core/tests/parameter/TestParameterInput.java100
7 files changed, 165 insertions, 0 deletions
diff --git a/org.eclipse.jubula.client.core.tests/.classpath b/org.eclipse.jubula.client.core.tests/.classpath
new file mode 100644
index 000000000..64c5e31b7
--- /dev/null
+++ b/org.eclipse.jubula.client.core.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.jubula.client.core.tests/.gitignore b/org.eclipse.jubula.client.core.tests/.gitignore
new file mode 100644
index 000000000..934e0e06f
--- /dev/null
+++ b/org.eclipse.jubula.client.core.tests/.gitignore
@@ -0,0 +1,2 @@
+/bin
+/target
diff --git a/org.eclipse.jubula.client.core.tests/.project b/org.eclipse.jubula.client.core.tests/.project
new file mode 100644
index 000000000..bdb1538cb
--- /dev/null
+++ b/org.eclipse.jubula.client.core.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jubula.client.core.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.jubula.client.core.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jubula.client.core.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..f0de5c635
--- /dev/null
+++ b/org.eclipse.jubula.client.core.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Tue Jan 24 12:12:31 CET 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/org.eclipse.jubula.client.core.tests/META-INF/MANIFEST.MF b/org.eclipse.jubula.client.core.tests/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..233ecc6b4
--- /dev/null
+++ b/org.eclipse.jubula.client.core.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tests for Jubula Core
+Bundle-SymbolicName: org.eclipse.jubula.client.core.tests
+Bundle-Version: 1.2.0.qualifier
+Bundle-Vendor: BREDEX GmbH
+Fragment-Host: org.eclipse.jubula.client.core;bundle-version="[1.2.0,1.3.0)"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.junit;bundle-version="[4.8.2,5.0.0)"
diff --git a/org.eclipse.jubula.client.core.tests/build.properties b/org.eclipse.jubula.client.core.tests/build.properties
new file mode 100644
index 000000000..63c299c3f
--- /dev/null
+++ b/org.eclipse.jubula.client.core.tests/build.properties
@@ -0,0 +1,11 @@
+###############################################################################
+# 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
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/org.eclipse.jubula.client.core.tests/src/org/eclipse/jubula/client/core/tests/parameter/TestParameterInput.java b/org.eclipse.jubula.client.core.tests/src/org/eclipse/jubula/client/core/tests/parameter/TestParameterInput.java
new file mode 100644
index 000000000..27b090ab3
--- /dev/null
+++ b/org.eclipse.jubula.client.core.tests/src/org/eclipse/jubula/client/core/tests/parameter/TestParameterInput.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.tests.parameter;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.PushbackReader;
+import java.io.StringReader;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.eclipse.jubula.client.core.gen.parser.parameter.lexer.Lexer;
+import org.eclipse.jubula.client.core.gen.parser.parameter.lexer.LexerException;
+import org.eclipse.jubula.client.core.gen.parser.parameter.node.Start;
+import org.eclipse.jubula.client.core.gen.parser.parameter.parser.Parser;
+import org.eclipse.jubula.client.core.gen.parser.parameter.parser.ParserException;
+import org.eclipse.jubula.client.core.utils.ParsedParameter;
+import org.eclipse.jubula.client.core.utils.SemanticParsingException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class TestParameterInput {
+
+ private String m_inputString;
+
+ private boolean m_inputIsValid;
+
+ public TestParameterInput(String inputString, boolean inputIsValid) {
+ m_inputString = inputString;
+ m_inputIsValid = inputIsValid;
+ }
+
+ @SuppressWarnings("nls")
+ @Test
+ public void testParameterInput() throws IOException {
+ Parser parser = new Parser(new Lexer(new PushbackReader(
+ new StringReader(m_inputString))));
+ try {
+ Start ast = parser.parse();
+ ParsedParameter param =
+ new ParsedParameter(true, null, null);
+ ast.apply(param);
+ assertTrue(m_inputString + " succeeded unexpectedly.", m_inputIsValid);
+ } catch (ParserException e) {
+ assertFalse(m_inputString + " failed unexpectedly.", m_inputIsValid);
+ } catch (LexerException e) {
+ assertFalse(m_inputString + " failed unexpectedly.", m_inputIsValid);
+ } catch (SemanticParsingException spe) {
+ assertFalse(m_inputString + " failed unexpectedly.", m_inputIsValid);
+ }
+ }
+
+ /**
+ *
+ * @return the parameters for the tests, in the format:
+ * <table border="1"><tr><td>String: input</td>
+ * <td>boolean: inputIsValid</td></tr></table>
+ *
+ */
+ @SuppressWarnings("nls")
+ @Parameters
+ public static Collection<Object[]> createInputStrings() {
+ return Arrays.asList(new Object[][] {
+ {"", true},
+ {"abc123", true},
+ {"=PARAMETER", true},
+ {"={PARAMETER}", true},
+ {"=1", true},
+ {"={1}", true},
+ {"?()", true},
+
+ {"=", false}, // missing parameter name
+ {"={}", false}, // missing parameter name
+ {"$", false}, // missing variable name
+ {"${}", false}, // missing variable name
+ {"'", false}, // missing closing single quote
+ {"?", false}, // missing function body
+ {"?(", false}, // missing closing parentheses
+ {"?)", false}, // missing opening parentheses
+ {"?a", false}, // invalid (literal) after function symbol
+ {"?=", false}, // invalid (parameter symbol) after function symbol
+ {"??", false}, // invalid (function symbol) after function symbol
+ {"?$", false}, // invalid (variable symbol) after function symbol
+ {"?''", false}, // invalid (single quote) after function symbol
+ });
+ }
+}

Back to the top