summaryrefslogtreecommitdiff
path: root/qadevOOo/runner/complexlib
diff options
context:
space:
mode:
authorLars Langhans <lla@openoffice.org>2010-02-09 10:55:27 +0100
committerLars Langhans <lla@openoffice.org>2010-02-09 10:55:27 +0100
commitea6b5703509211c4f8339534cee3ab75d9d54079 (patch)
tree673d9f56a07913d6334baf433bf9db4dc492b90a /qadevOOo/runner/complexlib
parent9886d1e152ccab5eb64af4a5c742d7791efe99a4 (diff)
qadev40: #161119# refactoring
Diffstat (limited to 'qadevOOo/runner/complexlib')
-rw-r--r--qadevOOo/runner/complexlib/ComplexTestCase.java100
1 files changed, 67 insertions, 33 deletions
diff --git a/qadevOOo/runner/complexlib/ComplexTestCase.java b/qadevOOo/runner/complexlib/ComplexTestCase.java
index 18f89681c96e..5e5a95982027 100644
--- a/qadevOOo/runner/complexlib/ComplexTestCase.java
+++ b/qadevOOo/runner/complexlib/ComplexTestCase.java
@@ -47,8 +47,6 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
protected static TestParameters param = null;
/** Log writer **/
protected static LogWriter log = null;
- /** Description entry **/
- protected DescEntry subEntry = null;
/**
* The method name which will be written into f.e. the data base
**/
@@ -56,42 +54,33 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
/** Maximal time one method is allowed to execute
* Can be set with parameter 'ThreadTimeOut'
**/
- protected int mThreadTimeOut = 0;
+ protected int m_nThreadTimeOut = 0;
/** Continue a test even if it did fail **/
// public static final boolean CONTINUE = true;
/** End a test if it did fail **/
public static final boolean BREAK = true;
+ private boolean m_bBeforeCalled;
+
/**
- * Call test. It is expected, that an environment is
- * given to this test.
- *
- * @param entry The name of the test method that should be called.
- * @param environment The environment for the test.
+ * is called before the real test starts
*/
- public void executeMethods(DescEntry entry, TestParameters environment)
+ private void before()
{
-
- // get the environment
- param = environment;
- log = entry.Logger;
-
- mThreadTimeOut = param.getInt("ThreadTimeOut");
- if (mThreadTimeOut == 0)
- {
- mThreadTimeOut = 300000;
- }
- // start with the before() method
- boolean beforeWorked = true;
try
{
Method before = this.getClass().getMethod("before", new Class[] {} );
before.invoke(this, new Object[] {} );
+
+ // beforeWorked = false;
+ m_bBeforeCalled = true;
}
catch (java.lang.NoSuchMethodException e)
{
// simply ignore
+ int dummy = 0;
+ m_bBeforeCalled = true;
}
catch (java.lang.IllegalAccessException e)
{
@@ -99,7 +88,6 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
}
catch (java.lang.reflect.InvocationTargetException e)
{
- beforeWorked = false;
Throwable t = e.getTargetException();
if (!(t instanceof RuntimeException) || state)
{
@@ -113,12 +101,25 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
}
}
+ }
- //executeMethodTests
- for (int i = 0; i < entry.SubEntries.length; i++)
+ /** Description entry **/
+ // protected DescEntry subEntry = null;
+
+ private void test_method(DescEntry _entry)
+ {
+
+ m_nThreadTimeOut = param.getInt("ThreadTimeOut");
+ if (m_nThreadTimeOut == 0)
{
- subEntry = entry.SubEntries[i];
- if (beforeWorked)
+ m_nThreadTimeOut = 300000;
+ }
+
+ for (int i = 0; i < _entry.SubEntries.length; i++)
+ {
+
+ DescEntry subEntry = _entry.SubEntries[i];
+ if (m_bBeforeCalled)
{
state = true;
message = "";
@@ -141,10 +142,7 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
{
String sParameter = (entryName.substring(entryName.indexOf("(") + 1, entryName.indexOf(")")));
mTestMethodName = entryName;
- parameter = new String[]
- {
- sParameter
- };
+ parameter = new String[] { sParameter };
entryName = entryName.substring(0, entryName.indexOf("("));
testMethod = this.getClass().getMethod(entryName, new Class[] { String.class });
}
@@ -173,7 +171,7 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
int sleepingStep = 1000;
int factor = 0;
- while (th.isAlive() && (lastPing != newPing || factor * sleepingStep < mThreadTimeOut))
+ while (th.isAlive() && (lastPing != newPing || factor * sleepingStep < m_nThreadTimeOut))
{
Thread.sleep(sleepingStep);
factor++;
@@ -196,7 +194,7 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
{
log.println("Destroy " + mTestMethodName);
th.destroy();
- subEntry.State = "Test did sleep for " + (mThreadTimeOut / 1000) + " seconds and has been killed!";
+ subEntry.State = "Test did sleep for " + (m_nThreadTimeOut / 1000) + " seconds and has been killed!";
subEntry.hasErrorMsg = true;
subEntry.ErrorMsg = subEntry.State;
continue;
@@ -228,8 +226,14 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
subEntry.hasErrorMsg = !state;
subEntry.ErrorMsg = message;
}
+ }
- if (beforeWorked)
+ /**
+ * after() is called after the test is done
+ */
+ private void after()
+ {
+ if (m_bBeforeCalled)
{
// the after() method
try
@@ -264,8 +268,38 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
}
}
}
+
+ }
+
+
+
+ /**
+ * Call test. It is expected, that an environment is
+ * given to this test.
+ *
+ * @param entry The name of the test method that should be called.
+ * @param environment The environment for the test.
+ */
+ public void executeMethods(DescEntry entry, TestParameters environment)
+ {
+ m_bBeforeCalled = false;
+
+ // get the environment
+ param = environment;
+ log = entry.Logger;
+
+
+ // start with the before() method
+ before();
+
+ //executeMethodTests
+ test_method(entry);
+
+ // cleanup
+ after();
}
+
/**
* Implement this method in the Complex test.
* @return All test method names.