diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2010-03-03 14:01:18 +0100 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2010-03-03 14:01:18 +0100 |
commit | b67973f21ad24df3c39f828a5b44a5863764a40b (patch) | |
tree | 470f673b2cd5a955ba7e188f58a23492085a9ab0 /qadevOOo/runner/complexlib/ComplexTestCase.java | |
parent | 6ee33e01b1fbd367ce01dc5650eb9e3c089672ab (diff) | |
parent | 46feaa99faff38763a172beddba10f94fed6070e (diff) |
CWS-TOOLING: integrate CWS qadev40
Diffstat (limited to 'qadevOOo/runner/complexlib/ComplexTestCase.java')
-rw-r--r-- | qadevOOo/runner/complexlib/ComplexTestCase.java | 100 |
1 files changed, 67 insertions, 33 deletions
diff --git a/qadevOOo/runner/complexlib/ComplexTestCase.java b/qadevOOo/runner/complexlib/ComplexTestCase.java index 8f67cd959f28..b15224bc503f 100644 --- a/qadevOOo/runner/complexlib/ComplexTestCase.java +++ b/qadevOOo/runner/complexlib/ComplexTestCase.java @@ -44,8 +44,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 **/ @@ -53,42 +51,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) { @@ -96,7 +85,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) { @@ -110,12 +98,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 = ""; @@ -138,10 +139,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 }); } @@ -170,7 +168,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++; @@ -193,7 +191,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; @@ -225,8 +223,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 @@ -261,8 +265,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. |