diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/HostControllerErrorIllegalArgTest.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/HostControllerErrorIllegalArgTest.java index f16d62c9ed92d201e40195e1e1a9bff5ee51da9c..8f8dca1928190bc794b1e68ebb6593211b30f4eb 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/HostControllerErrorIllegalArgTest.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/HostControllerErrorIllegalArgTest.java @@ -24,10 +24,10 @@ import org.junit.Test; * JniExecutorIllegalArgException is expected. */ public class HostControllerErrorIllegalArgTest { - + @Test public void testHostControllerConstructor() { - + // working dir null try { new HostController(null, null, TestConstants.EXECUTABLE); @@ -35,7 +35,7 @@ public class HostControllerErrorIllegalArgTest { } catch (JniExecutorIllegalArgumentException e) { //expected } - + // executable null try { new HostController(null, TestConstants.WORKINGDIR, null); @@ -43,7 +43,7 @@ public class HostControllerErrorIllegalArgTest { } catch (JniExecutorIllegalArgumentException e) { //expected } - + // working dir does NOT exist try { new HostController(null, TestConstants.WORKINGDIR + TestConstants.NONEXISTENTFILENAMEEXT, TestConstants.EXECUTABLE); @@ -51,7 +51,7 @@ public class HostControllerErrorIllegalArgTest { } catch (JniExecutorIllegalArgumentException e) { //expected } - + // working dir exists, but not a directory try { new HostController(null, TestConstants.EXISTS_BUT_NOT_DIR_WORKINGDIR, TestConstants.EXECUTABLE); @@ -59,7 +59,7 @@ public class HostControllerErrorIllegalArgTest { } catch (JniExecutorIllegalArgumentException e) { //expected } - + // executable does NOT exist try { new HostController(null, TestConstants.WORKINGDIR, TestConstants.EXECUTABLE + TestConstants.NONEXISTENTFILENAMEEXT); @@ -67,7 +67,7 @@ public class HostControllerErrorIllegalArgTest { } catch (JniExecutorIllegalArgumentException e) { //expected } - + // executable exists, but not a file (it's a directory) try { new HostController(null, TestConstants.EXISTS_BUT_NOT_FILE_WORKINGDIR, TestConstants.EXISTS_BUT_NOT_FILE_EXECUTABLE); diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncErrorIllegalArgTest.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncErrorIllegalArgTest.java index ba21c91c8d915beb4431d08445c17203eac8a46b..b2914f79b21f008ad95dd4590b6f9ce169e0adf1 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncErrorIllegalArgTest.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncErrorIllegalArgTest.java @@ -25,7 +25,7 @@ import org.junit.Test; * JniExecutorIllegalArgException is expected. */ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTest { - + private void testIllegalArgAddHostController( final JniExecutor je ) { try { je.addHostController( null ); @@ -36,7 +36,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe fail(); } } - + private void testIllegalArgSetConfigFileName( final JniExecutor je ) { try { je.setConfigFileName( null ); @@ -46,7 +46,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe } catch (JniExecutorWrongStateException e) { fail(); } - + try { je.setConfigFileName( "" ); fail("JniExecutorIllegalArgumentException expected"); @@ -56,7 +56,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe fail(); } } - + private void testIllegalArgSetObserver( final JniExecutor je, final TestData td ) { try { je.setObserver(td.mObserver); @@ -66,7 +66,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe fail(); } } - + private void testIllegalArgExecuteControl( final JniExecutor je ) { try { je.executeControl(null); @@ -76,7 +76,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe } catch (JniExecutorWrongStateException e) { fail(); } - + try { je.executeControl(""); fail("JniExecutorIllegalArgumentException expected"); @@ -86,7 +86,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe fail(); } } - + private void testIllegalArgExecuteTestcase( final JniExecutor je, final TestData td ) { try { je.executeTestcase( null, td.mTestcases.get(0)); @@ -121,7 +121,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe fail(); } } - + private void testIllegalArgExecuteCfg( final JniExecutor je ) { try { je.executeCfg( -1 ); @@ -131,7 +131,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe } catch (JniExecutorWrongStateException e) { fail(); } - + try { final int executeCfgLen = je.getExecuteCfgLen(); je.executeCfg( executeCfgLen ); @@ -142,7 +142,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe fail(); } } - + /** * disconnected (before init()) */ @@ -150,7 +150,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe public void testExecutorIllegalArgDisconnected() { //nothing to test in disconnected state } - + /** * connected MC_INACTIVE state (after init()) */ @@ -165,12 +165,12 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe testIllegalArgAddHostController(je); testIllegalArgSetConfigFileName(je); testIllegalArgSetObserver(je, td); - + // -------------- je.shutdownSession(); je.waitForCompletion(); } - + /** * MC_LISTENING state (after startSession()) */ @@ -178,9 +178,9 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe public void testExecutorIllegalArgListening() { final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + gotoListening(je, td); - + // we are now in MC_LISTENING, test all the functions, which has argument testIllegalArgAddHostController(je); testIllegalArgSetObserver(je, td); @@ -189,7 +189,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe je.shutdownSession(); je.waitForCompletion(); } - + /** * MC_HC_CONNECTED after startHostControllers() */ @@ -197,9 +197,9 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe public void testExecutorIllegalArgHcConnected() { final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + gotoHcConnected(je, td); - + // we are now in MC_HC_CONNECTED, test all the functions, which has argument testIllegalArgSetObserver(je, td); @@ -207,7 +207,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe je.shutdownSession(); je.waitForCompletion(); } - + /** * MC_LISTENING_CONFIGURED state (after configure()) */ @@ -217,7 +217,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe final JniExecutor je = JniExecutor.getInstance(); gotoListeningConfigured(je, td); - + // we are now in MC_LISTENING_CONFIGURED, test all the functions, which has argument testIllegalArgAddHostController(je); testIllegalArgSetObserver(je, td); @@ -226,7 +226,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe je.shutdownSession(); je.waitForCompletion(); } - + /** * MC_ACTIVE after configure() */ @@ -236,7 +236,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe final JniExecutor je = JniExecutor.getInstance(); gotoActive(je, td); - + // we are now in MC_ACTIVE, test all the functions, which has argument testIllegalArgSetObserver(je, td); @@ -244,7 +244,7 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe je.shutdownSession(); je.waitForCompletion(); } - + /** * MC_READY after createMTC() */ @@ -252,15 +252,15 @@ public class JniExecutorAsyncErrorIllegalArgTest extends JniExecutorAsyncErrorTe public void testExecutorIllegalArgReady() { final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + gotoReady(je, td); - + // we are now in MC_READY, test all the functions, which has argument testIllegalArgSetObserver(je, td); testIllegalArgExecuteControl(je); testIllegalArgExecuteTestcase(je, td); testIllegalArgExecuteCfg(je); - + // -------------- je.shutdownSession(); je.waitForCompletion(); diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncErrorTest.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncErrorTest.java index bb07e27d562be2ec3eda4bd6ea10ee03da901ad5..73ae88ad6b6f87d79b7e5a4a1b8abe6bcf106ef4 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncErrorTest.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncErrorTest.java @@ -34,7 +34,7 @@ import org.eclipse.titan.executorapi.util.Log; * Base class of asynchronous JniExecutor error tests. */ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { - + /** * structure to hold all the needed data to run tests * @@ -46,7 +46,7 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { public List<String> mTestcases = null; public IJniExecutorObserver mObserver = null; } - + protected TestData createTestData1() { HostController hc1 = null; try { @@ -59,10 +59,10 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { final List<String> testcases = new ArrayList<String>(); testcases.add(TestConstants.TESTCASE1); testcases.add(TestConstants.TESTCASE2); - + final JniExecutor je = JniExecutor.getInstance(); IJniExecutorObserver o1 = new Test1Observer(je, module, testcases); - + TestData td = new TestData(); td.mHc = hc1; td.mCfgFileName = cfgFileName; @@ -71,9 +71,9 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { td.mObserver = o1; return td; } - + // functions to get to different states - + protected void gotoInactive( final JniExecutor je, final TestData td ) { Log.fi(); // get to connected MC_INACTIVE @@ -85,24 +85,24 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { } Log.fo(); } - + protected void gotoListening( final JniExecutor je, final TestData td ) { Log.fi(); // get to MC_LISTENING gotoInactive(je, td); - + try { TestUtil.assertState( McStateEnum.MC_INACTIVE ); - + je.addHostController( td.mHc ); TestUtil.assertState( McStateEnum.MC_INACTIVE ); - + je.setConfigFileName( td.mCfgFileName ); TestUtil.assertState( McStateEnum.MC_INACTIVE ); - + je.setObserver(null); TestUtil.assertState( McStateEnum.MC_INACTIVE ); - + je.startSession(); TestUtil.assertState( McStateEnum.MC_LISTENING ); } catch (JniExecutorIllegalArgumentException | JniExecutorWrongStateException | JniExecutorStartSessionException e) { @@ -110,12 +110,12 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { } Log.fo(); } - + protected void gotoListeningConfigured( final JniExecutor je, final TestData td ) { Log.fi(); // get to MC_LISTENING_CONFIGURED gotoListening(je, td); - + try { TestUtil.assertState( McStateEnum.MC_LISTENING ); final Object lock = new Object(); @@ -130,21 +130,21 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { } Log.fo(); } - + protected void gotoListeningWithoutAddHostController( final JniExecutor je, final TestData td ) { Log.fi(); // get to MC_LISTENING gotoInactive(je, td); - + try { TestUtil.assertState( McStateEnum.MC_INACTIVE ); - + je.setConfigFileName( td.mCfgFileName ); TestUtil.assertState( McStateEnum.MC_INACTIVE ); - + je.setObserver(null); TestUtil.assertState( McStateEnum.MC_INACTIVE ); - + je.startSession(); TestUtil.assertState( McStateEnum.MC_LISTENING ); } catch (JniExecutorIllegalArgumentException | JniExecutorWrongStateException | JniExecutorStartSessionException e) { @@ -152,12 +152,12 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { } Log.fo(); } - + protected void gotoListeningConfiguredWithoutAddHostController( final JniExecutor je, final TestData td ) { Log.fi(); // get to MC_LISTENING_CONFIGURED without addHostController() gotoListeningWithoutAddHostController(je, td); - + try { TestUtil.assertState( McStateEnum.MC_LISTENING ); final Object lock = new Object(); @@ -172,12 +172,12 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { } Log.fo(); } - + protected void gotoHcConnected( final JniExecutor je, final TestData td ) { Log.fi(); // get to MC_HC_CONNECTED gotoListening(je, td); - + try { TestUtil.assertState( McStateEnum.MC_LISTENING ); final Object lock = new Object(); @@ -192,12 +192,12 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { } Log.fo(); } - + protected void gotoActive( final JniExecutor je, final TestData td ) { Log.fi(); // get to MC_ACTIVE gotoHcConnected(je, td); - + try { TestUtil.assertState( McStateEnum.MC_HC_CONNECTED ); final Object lock = new Object(); @@ -212,12 +212,12 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { } Log.fo(); } - + protected void gotoReady( final JniExecutor je, final TestData td ) { Log.fi(); // get to MC_READY gotoActive(je, td); - + try { TestUtil.assertState( McStateEnum.MC_ACTIVE ); final Object lock = new Object(); @@ -232,12 +232,12 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { } Log.fo(); } - + protected void gotoPaused( final JniExecutor je, final TestData td ) { Log.fi(); // get to MC_PAUSED gotoReady(je, td); - + try { TestUtil.assertState( McStateEnum.MC_READY ); je.pauseExecution(true); @@ -253,7 +253,7 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { } Log.fo(); } - + /** * First part of waiting until asynchronous function gets to the expected state. * <p> @@ -287,7 +287,7 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { } Log.fo(); } - + @Override public void error(int aSeverity, String aMsg) { Log.fi(aSeverity, aMsg); @@ -300,7 +300,7 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { @Override public void notify(Timeval aTime, String aSource, int aSeverity, String aMsg) { } - + @Override public void verdict(String aTestcase, VerdictTypeEnum aVerdictType) { } @@ -319,7 +319,7 @@ public abstract class JniExecutorAsyncErrorTest extends JniExecutorAsyncTest { } Log.fo(); } - + /** * Pair of {@link #waitBefore(Object, McStateEnum)} * @param aLock lock for synchronization diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncErrorWrongStateTest.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncErrorWrongStateTest.java index debc4e5776c6a204e2dd9a038a7e815e1c987089..99dcb7542eab718182a68f4a820b33be0fe8cf68 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncErrorWrongStateTest.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncErrorWrongStateTest.java @@ -31,18 +31,18 @@ import org.junit.Test; * If method is not callable in the given state, JniExecutorWrongStateException is expected. */ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTest { - + // Method testers. Each method is tested in 2 ways: // 1. true: If it's callable in the given state, we expect NOT to throw JniExecutorWrongStateException and to get to the next state (if any). // in this case it is recommended to check the state before and after this function using assertState // 2. false: If it's NOT callable in the given state, we expect to throw JniExecutorWrongStateException // final boolean aCallable determines the expected behaviour for each testWrongState...() method - + // there is no separate method tester for the following methods, as they are called many times in the other method testers in all of the states: // shutdownSession // getState // isConnected - + private void testWrongStateInit( final boolean aCallable, final JniExecutor je ) { if ( aCallable ) { try { @@ -61,7 +61,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + private void testWrongStateAddHostControllers( final boolean aCallable, final JniExecutor je, final TestData td ) { if ( aCallable ) { try { @@ -80,7 +80,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + private void testWrongStateSetConfigFileName( final boolean aCallable, final JniExecutor je, final TestData td ) { if ( aCallable ) { try { @@ -99,7 +99,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + private void testWrongStateSetObserver( final boolean aCallable, final JniExecutor je, final TestData td ) { if ( aCallable ) { try { @@ -135,7 +135,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + private void testWrongStateStartHostControllers( final boolean aCallable, final JniExecutor je ) { if ( aCallable ) { try { @@ -152,7 +152,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + private void testWrongStateConfigure( final boolean aCallable, final JniExecutor je ) { if ( aCallable ) { try { @@ -186,7 +186,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + private void testWrongStateExecuteControl( final boolean aCallable, final JniExecutor je, final TestData td ) { if ( aCallable ) { try { @@ -205,7 +205,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + private void testWrongStateExecuteTextcase( final boolean aCallable, final JniExecutor je, final TestData td ) { if ( aCallable ) { try { @@ -241,7 +241,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + private void testWrongStateExecuteCfg( final boolean aCallable, final JniExecutor je ) { if ( aCallable ) { try { @@ -260,7 +260,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + private void testWrongStatePauseExecutionAndIsPaused( final boolean aCallable, final JniExecutor je ) { if ( aCallable ) { try { @@ -278,7 +278,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } catch (JniExecutorWrongStateException e) { //expected } - + try { je.isPaused(); fail("JniExecutorWrongStateException expected"); @@ -304,7 +304,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + private void testWrongStateStopExecution( final boolean aCallable, final JniExecutor je ) { if ( aCallable ) { try { @@ -321,7 +321,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + private void testWrongStateExitMTC( final boolean aCallable, final JniExecutor je ) { if ( aCallable ) { try { @@ -338,7 +338,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + /** * Method tester for getNumberOfHosts(), getHostData() and getComponentData() * @param aCallable true, if getNumberOfHosts() and getHostData() are callable @@ -384,14 +384,14 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } catch ( JniExecutorWrongStateException e ) { //expected } - + try { je.getHostData(0); fail("JniExecutorWrongStateException expected"); } catch ( JniExecutorWrongStateException e ) { //expected } - + try { je.getComponentData(0); fail("JniExecutorWrongStateException expected"); @@ -400,7 +400,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe } } } - + /** * disconnected (before init()) */ @@ -409,9 +409,9 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe Log.fi(); final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + testWrongStateHostAndComponentData(false, false, je); - + testWrongStateAddHostControllers(false, je, td); testWrongStateSetConfigFileName(false, je, td); testWrongStateSetObserver(false, je, td); @@ -427,27 +427,27 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe testWrongStateContinueExecution(false, je); testWrongStateStopExecution(false, je); testWrongStateExitMTC(false, je); - + assertTrue( !je.isConnected() ); assertTrue( je.getState() == McStateEnum.MC_INACTIVE ); - + // it can be called in any state, it has no effect if we are in disconnected state je.shutdownSession(); - + assertTrue( !je.isConnected() ); assertTrue( je.getState() == McStateEnum.MC_INACTIVE ); - + testWrongStateInit(true, je); - + TestUtil.assertState( McStateEnum.MC_INACTIVE ); - + // in this case shutdownSession() is synchronous je.shutdownSession(); assertTrue( !je.isConnected() ); assertTrue( je.getState() == McStateEnum.MC_INACTIVE ); Log.fo(); } - + /** * connected MC_INACTIVE state (after init()) */ @@ -461,7 +461,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe // we are now in connected MC_INACTIVE, test all the functions, first the ones, that throw exception testWrongStateHostAndComponentData(false, false, je); - + testWrongStateInit(false, je); testWrongStateStartHostControllers(false, je); testWrongStateConfigure(false, je); @@ -484,13 +484,13 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe TestUtil.assertState( McStateEnum.MC_INACTIVE ); testWrongStateStartSession(true, je); TestUtil.assertState( McStateEnum.MC_LISTENING ); - + // -------------- je.shutdownSession(); je.waitForCompletion(); Log.fo(); } - + /** * MC_LISTENING state (after startSession()) */ @@ -499,13 +499,13 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe Log.fi(); final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + gotoListening(je, td); - + // we are now in MC_LISTENING, test all the functions, first the ones, that throw exception - + testWrongStateHostAndComponentData(false, false, je); - + testWrongStateInit(false, je); testWrongStateSetConfigFileName(false, je, td); testWrongStateSetObserver(true, je, td); @@ -519,7 +519,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe testWrongStateContinueExecution(false, je); testWrongStateStopExecution(false, je); testWrongStateExitMTC(false, je); - + TestUtil.assertState( McStateEnum.MC_LISTENING ); final Object lock = new Object(); synchronized (lock) { @@ -534,7 +534,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe je.waitForCompletion(); Log.fo(); } - + /** * MC_HC_CONNECTED after startHostControllers() */ @@ -543,13 +543,13 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe Log.fi(); final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + gotoHcConnected(je, td); - + // we are now in MC_HC_CONNECTED, test all the functions, first the ones, that throw exception - + testWrongStateHostAndComponentData(true, false, je); - + testWrongStateInit(false, je); testWrongStateAddHostControllers(false, je, td); testWrongStateSetConfigFileName(false, je, td); @@ -565,7 +565,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe testWrongStateContinueExecution(false, je); testWrongStateStopExecution(false, je); testWrongStateExitMTC(false, je); - + TestUtil.assertState( McStateEnum.MC_HC_CONNECTED ); final Object lock = new Object(); synchronized (lock) { @@ -574,13 +574,13 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe waitAfter(lock); } TestUtil.assertState( McStateEnum.MC_ACTIVE ); - + // -------------- je.shutdownSession(); je.waitForCompletion(); Log.fo(); } - + /** * MC_LISTENING state (after startSession()), addHostController() is called */ @@ -589,22 +589,22 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe Log.fi(); final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + // get to MC_LISTENING without calling addHostController() gotoListeningWithoutAddHostController(je, td); - + testWrongStateHostAndComponentData(false, false, je); - + TestUtil.assertState( McStateEnum.MC_LISTENING ); testWrongStateAddHostControllers(true, je, td); TestUtil.assertState( McStateEnum.MC_LISTENING ); - + // -------------- je.shutdownSession(); je.waitForCompletion(); Log.fo(); } - + /** * MC_LISTENING_CONFIGURED state (after configure()) */ @@ -615,11 +615,11 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe final JniExecutor je = JniExecutor.getInstance(); gotoListeningConfigured(je, td); - + // we are now in MC_LISTENING_CONFIGURED, test all the functions, first the ones, that throw exception - + testWrongStateHostAndComponentData(false, false, je); - + testWrongStateInit(false, je); testWrongStateSetConfigFileName(false, je, td); testWrongStateSetObserver(true, je, td); @@ -633,7 +633,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe testWrongStateContinueExecution(false, je); testWrongStateStopExecution(false, je); testWrongStateExitMTC(false, je); - + TestUtil.assertState( McStateEnum.MC_LISTENING_CONFIGURED ); final Object lock = new Object(); synchronized (lock) { @@ -648,7 +648,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe je.waitForCompletion(); Log.fo(); } - + /** * MC_LISTENING_CONFIGURED state (after configure()) to call addHostController() */ @@ -659,11 +659,11 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe final JniExecutor je = JniExecutor.getInstance(); gotoListeningConfiguredWithoutAddHostController(je, td); - + // we are now in MC_LISTENING_CONFIGURED, test all the functions, first the ones, that throw exception - + testWrongStateHostAndComponentData(false, false, je); - + testWrongStateInit(false, je); testWrongStateAddHostControllers(true, je, td); testWrongStateSetConfigFileName(false, je, td); @@ -678,7 +678,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe testWrongStateContinueExecution(false, je); testWrongStateStopExecution(false, je); testWrongStateExitMTC(false, je); - + TestUtil.assertState( McStateEnum.MC_LISTENING_CONFIGURED ); final Object lock = new Object(); synchronized (lock) { @@ -693,7 +693,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe je.waitForCompletion(); Log.fo(); } - + /** * MC_ACTIVE after configure() */ @@ -704,11 +704,11 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe final JniExecutor je = JniExecutor.getInstance(); gotoActive(je, td); - + // we are now in MC_ACTIVE, test all the functions, first the ones, that throw exception - + testWrongStateHostAndComponentData(true, false, je); - + testWrongStateInit(false, je); testWrongStateAddHostControllers(false, je, td); testWrongStateSetConfigFileName(false, je, td); @@ -724,7 +724,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe testWrongStateContinueExecution(false, je); testWrongStateStopExecution(false, je); testWrongStateExitMTC(false, je); - + TestUtil.assertState( McStateEnum.MC_ACTIVE ); final Object lock = new Object(); synchronized (lock) { @@ -733,13 +733,13 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe waitAfter(lock); } TestUtil.assertState( McStateEnum.MC_READY ); - + // -------------- je.shutdownSession(); je.waitForCompletion(); Log.fo(); } - + /** * MC_READY after createMTC() */ @@ -748,11 +748,11 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe Log.fi(); final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + gotoReady(je, td); - + // we are now in MC_READY, test all the functions, first the ones, that throw exception - + testWrongStateHostAndComponentData(true, true, je); testWrongStateInit(false, je); @@ -766,7 +766,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe testWrongStatePauseExecutionAndIsPaused(true, je); testWrongStateContinueExecution(false, je); testWrongStateStopExecution(true, je); // do nothing - + TestUtil.assertState( McStateEnum.MC_READY ); final Object lock1 = new Object(); synchronized (lock1) { @@ -775,7 +775,7 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe waitAfter(lock1); } TestUtil.assertState( McStateEnum.MC_READY ); - + final Object lock2 = new Object(); synchronized (lock2) { waitBefore(lock2, McStateEnum.MC_READY ); @@ -783,10 +783,10 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe waitAfter(lock2); } TestUtil.assertState( McStateEnum.MC_READY ); - + testWrongStateGetExecuteCfglen(true, je); TestUtil.assertState( McStateEnum.MC_READY ); - + final Object lock3 = new Object(); synchronized (lock3) { waitBefore(lock3, McStateEnum.MC_READY ); @@ -794,15 +794,15 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe waitAfter(lock3); } TestUtil.assertState( McStateEnum.MC_READY ); - + testWrongStateHostAndComponentData( true, true, je ); - + // -------------- je.shutdownSession(); je.waitForCompletion(); Log.fo(); } - + /** * MC_READY after createMTC() to call exitMTC() */ @@ -811,9 +811,9 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe Log.fi(); final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + gotoReady(je, td); - + TestUtil.assertState( McStateEnum.MC_READY ); final Object lock = new Object(); synchronized (lock) { @@ -822,13 +822,13 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe waitAfter(lock); } TestUtil.assertState( McStateEnum.MC_ACTIVE ); - + // -------------- je.shutdownSession(); je.waitForCompletion(); Log.fo(); } - + /** * MC_READY after createMTC() to call stopExecution() */ @@ -837,9 +837,9 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe Log.fi(); final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + gotoReady(je, td); - + TestUtil.assertState( McStateEnum.MC_READY ); final Object lock = new Object(); synchronized (lock) { @@ -854,16 +854,16 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe // the testcase faster, than we get here or java side MC lock is blocked (JniExecutor.getState() is synchronized), // we are already in MC_READY, so the testcase fails. // It really happened sometimes during the automatic tests, so assert was removed. - + // If executeTestcase() is called and then stopExecution() is also called without any delay, // the behaviour of MainController is unpredictable: // Sometimes "Dynamic test case error" sent by MainController to the JniExecutor through the pipe. try { - Thread.sleep(100); // in milliseconds + Thread.sleep(100); // in milliseconds } catch(InterruptedException ex) { - Thread.currentThread().interrupt(); + Thread.currentThread().interrupt(); } - + je.stopExecution(); } catch (JniExecutorWrongStateException | JniExecutorIllegalArgumentException e ) { fail(); @@ -871,13 +871,13 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe waitAfter(lock); } TestUtil.assertState( McStateEnum.MC_READY ); - + // -------------- je.shutdownSession(); je.waitForCompletion(); Log.fo(); } - + /** * MC_PAUSED, call continueExecution */ @@ -886,11 +886,11 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe Log.fi(); final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + gotoPaused(je, td); - + // we are now in MC_PAUSED, test all the functions, first the ones, that throw exception - + testWrongStateHostAndComponentData(false, false, je); testWrongStateInit(false, je); @@ -905,9 +905,9 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe testWrongStateExecuteTextcase(false, je, td); testWrongStateGetExecuteCfglen(false, je); testWrongStateExecuteCfg(false, je); - + TestUtil.assertState( McStateEnum.MC_PAUSED ); - + final Object lock = new Object(); synchronized (lock) { waitBefore(lock, McStateEnum.MC_PAUSED ); @@ -915,13 +915,13 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe waitAfter(lock); } TestUtil.assertState( McStateEnum.MC_PAUSED ); - + // -------------- je.shutdownSession(); je.waitForCompletion(); Log.fo(); } - + /** * MC_PAUSED, call stopExecution */ @@ -930,11 +930,11 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe Log.fi(); final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + gotoPaused(je, td); - + TestUtil.assertState( McStateEnum.MC_PAUSED ); - + final Object lock = new Object(); synchronized (lock) { waitBefore(lock, McStateEnum.MC_READY ); @@ -942,13 +942,13 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe waitAfter(lock); } TestUtil.assertState( McStateEnum.MC_READY ); - + // -------------- je.shutdownSession(); je.waitForCompletion(); Log.fo(); } - + /** * MC_PAUSED switch paused state to false -> test control continues */ @@ -957,9 +957,9 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe Log.fi(); final TestData td = createTestData1(); final JniExecutor je = JniExecutor.getInstance(); - + gotoPaused(je, td); - + TestUtil.assertState( McStateEnum.MC_PAUSED ); final Object lock = new Object(); synchronized (lock) { @@ -974,11 +974,11 @@ public class JniExecutorAsyncErrorWrongStateTest extends JniExecutorAsyncErrorTe waitAfter(lock); } TestUtil.assertState( McStateEnum.MC_READY ); - + // -------------- je.shutdownSession(); je.waitForCompletion(); Log.fo(); } - + } diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncHappyTest.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncHappyTest.java index 1c3b02f9546b6af9923f771e612df73593d00284..e5e573424e6269a132d5bd32edb3a83251181648 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncHappyTest.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncHappyTest.java @@ -33,44 +33,44 @@ import org.junit.Test; */ public class JniExecutorAsyncHappyTest extends JniExecutorAsyncTest { - /** - * Route alternative in the MC state flow, - * or in other words: the order of startHostControllers() and configure() operations - */ + /** + * Route alternative in the MC state flow, + * or in other words: the order of startHostControllers() and configure() operations + */ public enum McRoute { - + /** * MC_LISTENING -> startHostControllers() -> MC_HC_CONNECTED -> configure() -> (MC_CONFIGURING) -> MC_ACTIVE */ ROUTE_1, - + /** * MC_LISTENING -> configure() -> MC_LISTENING_CONFIGURED -> startHostControllers() -> (MC_CONFIGURING) -> MC_ACTIVE */ ROUTE_2 }; - + /** * Determines how the tests are executed in when we get to MC_READY state */ public enum ExecutionMethod { - + /** * Test is executed by test control name */ TEST_CONTROL, - + /** * Test is executed by test case name, a module name and list of testcase name must be added */ TEST_CASE, - + /** * Execution list of the cfg file is used for test execution */ CFG_FILE } - + /** * Runs test of 1 module. * Sets up MC, executes tests, shuts down session. @@ -119,7 +119,7 @@ public class JniExecutorAsyncHappyTest extends JniExecutorAsyncTest { assertTrue(!je.isConnected()); Log.fo(); } - + /** * Runs test of 1 module. (It has less parameters, calls the other testHappy) * Sets up MC, executes tests, shuts down session. @@ -137,36 +137,36 @@ public class JniExecutorAsyncHappyTest extends JniExecutorAsyncTest { final List<String> testcases = new ArrayList<String>(); testcases.add(TestConstants.TESTCASE1); testcases.add(TestConstants.TESTCASE2); - + testHappy( hc1, cfgFileName, module, testcases, aRoute, aExecMethod ); Log.fo(); } - + @Test public void testExecutorAsyncHappyRoute1TestControl() throws JniExecutorException { testHappy(McRoute.ROUTE_1, ExecutionMethod.TEST_CONTROL); } - + @Test public void testExecutorAsyncHappyRoute1TestCasel() throws JniExecutorException { testHappy(McRoute.ROUTE_1, ExecutionMethod.TEST_CASE); } - + @Test public void testExecutorAsyncHappyRoute1CfgFilel() throws JniExecutorException { testHappy(McRoute.ROUTE_1, ExecutionMethod.CFG_FILE); } - + @Test public void testExecutorAsyncHappyRoute2TestControl() throws JniExecutorException { testHappy(McRoute.ROUTE_2, ExecutionMethod.TEST_CONTROL); } - + @Test public void testExecutorAsyncHappyRoute2TestCase() throws JniExecutorException { testHappy(McRoute.ROUTE_2, ExecutionMethod.TEST_CASE); } - + @Test public void testExecutorAsyncHappyRoute2CfgFile() throws JniExecutorException { testHappy(McRoute.ROUTE_2, ExecutionMethod.CFG_FILE); diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncTest.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncTest.java index 57a4a071d171bcef36717ab5c094eddbb27487ff..fdbd9e7479a167fe674d30e8464e7b522ac78dce 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncTest.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorAsyncTest.java @@ -31,34 +31,34 @@ public abstract class JniExecutorAsyncTest extends JniExecutorTest { * Common one-time initialization code for asynchronous JniExecutor tests. * It runs only once for a test class. */ - @BeforeClass - public static void oneTimeSetUp() { - // one-time initialization code + @BeforeClass + public static void oneTimeSetUp() { + // one-time initialization code Log.fi(); // make sure, that session is shut down final JniExecutor je = JniExecutor.getInstance(); je.shutdownSession(); je.waitForCompletion(); Log.fo(); - } - + } + /** * Common one-time cleanup code for asynchronous JniExecutor tests. * It runs only once for a test class. */ - @AfterClass - public static void oneTimeTearDown() { - // one-time cleanup code + @AfterClass + public static void oneTimeTearDown() { + // one-time cleanup code Log.fi(); Log.fo(); - } - + } + /** * Common initialization code for asynchronous JniExecutor tests. * It runs before each test method. */ - @Before - public void setUp() { + @Before + public void setUp() { Log.fi(); // check if session is not started final JniExecutor je = JniExecutor.getInstance(); @@ -66,19 +66,19 @@ public abstract class JniExecutorAsyncTest extends JniExecutorTest { final McStateEnum state = je.getState(); assertTrue( state == McStateEnum.MC_INACTIVE ); Log.fo(); - } - + } + /** * Common cleanup code for asynchronous JniExecutor tests. * It runs before each test method. */ - @After - public void tearDown() { + @After + public void tearDown() { Log.fi(); // make sure, that session is shut down final JniExecutor je = JniExecutor.getInstance(); je.shutdownSession(); je.waitForCompletion(); Log.fo(); - } + } } diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorSync.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorSync.java index 353a99e15bb07e8a45a2ee7bbcd9b0c7239671bf..00436c874751b8ca22ad2cc363c182f76d506a0f 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorSync.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorSync.java @@ -30,30 +30,30 @@ import org.eclipse.titan.executorapi.util.Log; * Wrapper class for synchronous usage of JniExecutor. SINGLETON */ public final class JniExecutorSync implements IJniExecutorObserver { - + /** Default timeout of synchronous functions of the asynchronous requests in ms */ private static final int DEFAULT_TIMEOUT = 0; - + /** * lock for synchronous access of mRequestOngoing */ private final Object mLockObject = new Object(); - + /** * Flag for signaling the asynchronous requests, used for the synchronous versions of the functions */ private volatile boolean mRequestOngoing = false; - + /** * true, if setObserver() was called */ private boolean mObserverSet = false; - + /** * Timeout of synchronous functions of the asynchronous requests in ms */ private long mTimeout = DEFAULT_TIMEOUT; - + /** * Private constructor, because it is a singleton. */ @@ -68,7 +68,7 @@ public final class JniExecutorSync implements IJniExecutorObserver { private static class SingletonHolder { private static final JniExecutorSync mInstance = new JniExecutorSync(); } - + /** * @return the singleton instance */ @@ -81,16 +81,16 @@ public final class JniExecutorSync implements IJniExecutorObserver { Log.fi( aNewState ); // in case of final states // synchronous function is signaled that function can be ended - if ( !isIntermediateState( aNewState ) ) { - signalEndSync(); - } + if ( !isIntermediateState( aNewState ) ) { + signalEndSync(); + } Log.fo(); } @Override public void error( final int aSeverity, final String aMsg ) { Log.fi( aSeverity, aMsg ); - signalEndSync(); + signalEndSync(); Log.fo(); } @@ -105,7 +105,7 @@ public final class JniExecutorSync implements IJniExecutorObserver { @Override public void verdictStats(Map<VerdictTypeEnum, Integer> aVerdictStats) { } - + public void init() throws JniExecutorWrongStateException, JniExecutorJniLoadException { JniExecutor.getInstance().init(); mRequestOngoing = false; @@ -119,15 +119,15 @@ public final class JniExecutorSync implements IJniExecutorObserver { public void setConfigFileName( final String aConfigFileName ) throws JniExecutorWrongStateException, JniExecutorIllegalArgumentException { JniExecutor.getInstance().setConfigFileName( aConfigFileName ); } - + public void startSession() throws JniExecutorWrongStateException, JniExecutorStartSessionException { JniExecutor.getInstance().startSession(); } - + public int getExecuteCfgLen() throws JniExecutorWrongStateException { return JniExecutor.getInstance().getExecuteCfgLen(); } - + /** * Sets new timeout * @param aTimeout the new timeout value in ms, @@ -136,7 +136,7 @@ public final class JniExecutorSync implements IJniExecutorObserver { public void setTimeout( final long aTimeout ) { mTimeout = aTimeout; } - + /** * Sets observer if it's not set yet. * It must be called before the 1st asynchronous function call. @@ -148,10 +148,10 @@ public final class JniExecutorSync implements IJniExecutorObserver { mObserverSet = true; } } - + // ------------ SYNCHRONOUS VERSION OF ASYNCHRONOUS FUNCTIONS -------------------- - - + + public void startHostControllersSync() throws JniExecutorWrongStateException { // observer is set before the 1st async request setObserver(); @@ -159,7 +159,7 @@ public final class JniExecutorSync implements IJniExecutorObserver { JniExecutor.getInstance().startHostControllers(); endSync(); } - + public void configureSync() throws JniExecutorWrongStateException { // observer is set before the 1st async request setObserver(); @@ -167,43 +167,43 @@ public final class JniExecutorSync implements IJniExecutorObserver { JniExecutor.getInstance().configure(); endSync(); } - + public void createMTCSync() throws JniExecutorWrongStateException { startSync(); JniExecutor.getInstance().createMTC(); endSync(); } - + public void executeControlSync( final String aModule ) throws JniExecutorWrongStateException, JniExecutorIllegalArgumentException { startSync(); JniExecutor.getInstance().executeControl( aModule ); endSync(); } - + public void executeTestcaseSync( final String aModule, final String aTestcase ) throws JniExecutorWrongStateException, JniExecutorIllegalArgumentException { startSync(); JniExecutor.getInstance().executeTestcase( aModule, aTestcase ); endSync(); } - + public void executeCfgSync( final int aIndex ) throws JniExecutorWrongStateException, JniExecutorIllegalArgumentException { startSync(); JniExecutor.getInstance().executeCfg( aIndex ); endSync(); } - + public void continueExecutionSync() throws JniExecutorWrongStateException { startSync(); JniExecutor.getInstance().continueExecution(); endSync(); } - + public void exitMTCSync() throws JniExecutorWrongStateException { startSync(); JniExecutor.getInstance().exitMTC(); endSync(); } - + public void shutdownSessionSync() { startSync(); JniExecutor.getInstance().shutdownSession(); @@ -223,7 +223,7 @@ public final class JniExecutorSync implements IJniExecutorObserver { } Log.fo(); } - + private void endSync() { Log.fi(); synchronized (mLockObject) { @@ -247,7 +247,7 @@ public final class JniExecutorSync implements IJniExecutorObserver { } Log.fo(); } - + private void signalEndSync() { Log.fi(); synchronized (mLockObject) { diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorSyncTest.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorSyncTest.java index 15a32383e71103a96aec16f9e6f447ef7642c083..a0bb330efe42559e8d10698f892cc456953b7488 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorSyncTest.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorSyncTest.java @@ -33,26 +33,26 @@ import org.junit.Test; */ public class JniExecutorSyncTest extends JniExecutorTest { - @BeforeClass - public static void oneTimeSetUp() { - // one-time initialization code + @BeforeClass + public static void oneTimeSetUp() { + // one-time initialization code Log.fi(); // make sure, that session is shut down final JniExecutor je = JniExecutor.getInstance(); je.shutdownSession(); je.waitForCompletion(); Log.fo(); - } - - @AfterClass - public static void oneTimeTearDown() { - // one-time cleanup code + } + + @AfterClass + public static void oneTimeTearDown() { + // one-time cleanup code Log.fi(); Log.fo(); - } - - @Before - public void setUp() { + } + + @Before + public void setUp() { Log.fi(); // check if session is not started final JniExecutor je = JniExecutor.getInstance(); @@ -60,17 +60,17 @@ public class JniExecutorSyncTest extends JniExecutorTest { final McStateEnum state = je.getState(); assertTrue( state == McStateEnum.MC_INACTIVE ); Log.fo(); - } - - @After - public void tearDown() { + } + + @After + public void tearDown() { Log.fi(); // make sure, that session is shut down final JniExecutor je = JniExecutor.getInstance(); je.shutdownSession(); je.waitForCompletion(); Log.fo(); - } + } /** * sync @@ -88,7 +88,7 @@ public class JniExecutorSyncTest extends JniExecutorTest { je.addHostController(hc1); je.setConfigFileName(TestConstants.CFG_FILE); TestUtil.assertState( McStateEnum.MC_INACTIVE ); - + Log.i("startSession()"); je.startSession(); TestUtil.assertState( McStateEnum.MC_LISTENING ); @@ -96,15 +96,15 @@ public class JniExecutorSyncTest extends JniExecutorTest { Log.i("startHostControllersSync()"); je.startHostControllersSync(); TestUtil.assertState( McStateEnum.MC_HC_CONNECTED ); - + Log.i("configureSync()"); je.configureSync(); TestUtil.assertState( McStateEnum.MC_ACTIVE ); - + Log.i("createMTCSync()"); je.createMTCSync(); TestUtil.assertState( McStateEnum.MC_READY ); - + final String module = TestConstants.MODULE; final List<String> testcases = new ArrayList<String>(); testcases.add(TestConstants.TESTCASE1); @@ -118,12 +118,12 @@ public class JniExecutorSyncTest extends JniExecutorTest { Log.i("exitMTCSync()"); je.exitMTCSync(); TestUtil.assertState( McStateEnum.MC_ACTIVE ); - + Log.i("shutdownSessionSync()"); je.shutdownSessionSync(); Log.fo(); } - + /** * sync * route 2 @@ -140,7 +140,7 @@ public class JniExecutorSyncTest extends JniExecutorTest { je.addHostController(hc1); je.setConfigFileName(TestConstants.CFG_FILE); TestUtil.assertState( McStateEnum.MC_INACTIVE ); - + Log.i("startSession()"); je.startSession(); TestUtil.assertState( McStateEnum.MC_LISTENING ); @@ -148,15 +148,15 @@ public class JniExecutorSyncTest extends JniExecutorTest { Log.iu("configureSync()"); je.configureSync(); TestUtil.assertState( McStateEnum.MC_LISTENING_CONFIGURED ); - + Log.iu("startHostControllersSync()"); je.startHostControllersSync(); TestUtil.assertState( McStateEnum.MC_ACTIVE ); - + Log.i("createMTCSync()"); je.createMTCSync(); TestUtil.assertState( McStateEnum.MC_READY ); - + final String module = TestConstants.MODULE; final List<String> testcases = new ArrayList<String>(); testcases.add(TestConstants.TESTCASE1); @@ -170,12 +170,12 @@ public class JniExecutorSyncTest extends JniExecutorTest { Log.i("exitMTCSync()"); je.exitMTCSync(); TestUtil.assertState( McStateEnum.MC_ACTIVE ); - + Log.i("shutdownSessionSync()"); je.shutdownSessionSync(); Log.fo(); } - + /** * sync * route 1 @@ -192,7 +192,7 @@ public class JniExecutorSyncTest extends JniExecutorTest { je.addHostController( hc1 ); je.setConfigFileName(TestConstants.CFG_FILE); TestUtil.assertState( McStateEnum.MC_INACTIVE ); - + Log.i("startSession()"); je.startSession(); TestUtil.assertState( McStateEnum.MC_LISTENING ); @@ -200,11 +200,11 @@ public class JniExecutorSyncTest extends JniExecutorTest { Log.i("startHostControllersSync()"); je.startHostControllersSync(); TestUtil.assertState( McStateEnum.MC_HC_CONNECTED ); - + Log.i("configureSync()"); je.configureSync(); TestUtil.assertState( McStateEnum.MC_ACTIVE ); - + Log.i("createMTCSync()"); je.createMTCSync(); TestUtil.assertState( McStateEnum.MC_READY ); @@ -220,7 +220,7 @@ public class JniExecutorSyncTest extends JniExecutorTest { Log.i("exitMTCSync()"); je.exitMTCSync(); TestUtil.assertState( McStateEnum.MC_ACTIVE ); - + Log.i("shutdownSessionSync()"); je.shutdownSessionSync(); Log.fo(); diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorTest.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorTest.java index fc7e898eb67f02b69ca277d0926a0aeae0c07447..e24e5df17dc5831dfc126c7d51764efc271e4620 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorTest.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/JniExecutorTest.java @@ -20,7 +20,7 @@ import org.junit.rules.Timeout; * @see org.eclipse.titan.executorapi.JniExecutor */ public abstract class JniExecutorTest { - + /** The time in milliseconds max per method tested */ @Rule public Timeout globalTimeout = new Timeout(60000); diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/NormalTestObserver.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/NormalTestObserver.java index 47e3f30b04fb52e376afcbe68a52c2302649e082..abbb150d524731f7540616b767d751b02ba4f678 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/NormalTestObserver.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/NormalTestObserver.java @@ -34,13 +34,13 @@ class NormalTestObserver extends TestObserverBase { * or -1 if it's not known yet. It is read in MC_READY state */ private int mExecuteCfgLen = -1; - + /** * The index of the current item, which is currently executed * Used for CFG_FILE and TEST_CONTROL */ private int mExecuteIndex = -1; - + protected NormalTestObserver(JniExecutor aJe, McRoute aRoute, ExecutionMethod aExecMethod) { super(aJe, aRoute, aExecMethod); } @@ -77,7 +77,7 @@ class NormalTestObserver extends TestObserverBase { } Log.fo(); } - + private boolean executionReady() { switch ( mExecMethod ) { case TEST_CONTROL: @@ -90,7 +90,7 @@ class NormalTestObserver extends TestObserverBase { return true; } } - + private void executeNext() throws JniExecutorWrongStateException, JniExecutorIllegalArgumentException { switch ( mExecMethod ) { case TEST_CONTROL: diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/Test1Observer.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/Test1Observer.java index d2774cc3021d46eb42fa743d12f258d343d9ad8b..63eeef58dcefc823cf16f6a1276a0b3f491852d8 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/Test1Observer.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/Test1Observer.java @@ -28,13 +28,13 @@ import org.eclipse.titan.executorapi.util.Log; * testcase by name */ class Test1Observer extends TestObserverBase { - + public Test1Observer( final JniExecutor aJe, final String aModule, final List<String> aTestcases ) { super( aJe, McRoute.ROUTE_1, ExecutionMethod.TEST_CASE ); setModule(aModule); setTestcases(aTestcases); } - + @Override public void statusChanged2( final McStateEnum aNewState ) throws JniExecutorException { Log.fi(aNewState); diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/Test2Observer.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/Test2Observer.java index 724aa0941911a83ed1662fdbcd1959dc34b11e77..50b68022ca88cd5abb4a2f0e02cb97116de9e8ed 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/Test2Observer.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/Test2Observer.java @@ -28,13 +28,13 @@ import org.eclipse.titan.executorapi.util.Log; * testcase by name */ class Test2Observer extends TestObserverBase { - + public Test2Observer( final JniExecutor aJe, final String aModule, final List<String> aTestcases ) { super( aJe, McRoute.ROUTE_2, ExecutionMethod.TEST_CASE ); setModule(aModule); setTestcases(aTestcases); } - + @Override public void statusChanged2(McStateEnum aNewState) throws JniExecutorException { Log.fi(aNewState); diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/TestConstants.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/TestConstants.java index a2c925a32dcf9d37de02cfbcd83d02c8135d12ea..8dfde152a4a2c3776cfa637302c4a2cc6710c5dd 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/TestConstants.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/TestConstants.java @@ -20,41 +20,41 @@ public class TestConstants { //public static final String WORKINGDIR = WORKSPACE + "hw/bin"; //public static final String EXECUTABLE = "hw"; //public static final String CFG_FILE = WORKSPACE + "hw/src/MyExample.cfg"; - + private static final String WORKSPACE = "../../titan/Install/"; public static final String WORKINGDIR = getWorkspace() + "demo"; public static final String EXECUTABLE = "MyExample"; public static final String CFG_FILE = getWorkspace() + "demo/MyExample.cfg"; - + public static final String MODULE = EXECUTABLE; public static final String TESTCASE1 = "HelloW"; public static final String TESTCASE2 = "HelloW2"; - + // constants for error situations - + //public static final String EXISTS_BUT_NOT_DIR_WORKINGDIR = WORKSPACE + "hw/bin/hw"; //public static final String EXISTS_BUT_NOT_FILE_WORKINGDIR = WORKSPACE + "hw"; //public static final String EXISTS_BUT_NOT_FILE_EXECUTABLE = "bin"; - + /** extension for a filename to make sure, that it will invalid */ public static final String NONEXISTENTFILENAMEEXT = "72634753271645721854657214521"; - + /** Working dir for this case: exists, but not a dir */ public static final String EXISTS_BUT_NOT_DIR_WORKINGDIR = WORKSPACE + "demo/MyExample"; - + /** Working dir for this case: executable exists, but not a file (it's a directory) */ public static final String EXISTS_BUT_NOT_FILE_WORKINGDIR = WORKSPACE; - + /** Executable for this case: executable exists, but not a file (it's a directory) */ public static final String EXISTS_BUT_NOT_FILE_EXECUTABLE = "demo"; - + private static final String getWorkspace() { String ttcn3_dir = System.getenv().get("TTCN3_DIR"); String workspace = WORKSPACE; - if (ttcn3_dir != null && ttcn3_dir.length() > 0) { - workspace = ttcn3_dir; - } - workspace += ( workspace.endsWith( File.separator ) ? "" : File.separator ); - return workspace; + if (ttcn3_dir != null && ttcn3_dir.length() > 0) { + workspace = ttcn3_dir; + } + workspace += ( workspace.endsWith( File.separator ) ? "" : File.separator ); + return workspace; } } diff --git a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/TestObserverBase.java b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/TestObserverBase.java index 7dfa1a0de5cb5d1071cbc4941b37ac9b76c8122a..1dce88a2020ef2ca43ca03b5169dd8c97d719b87 100644 --- a/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/TestObserverBase.java +++ b/titan_executor_api/TITAN_Executor_API_test/src/org/eclipse/titan/executorapi/test/TestObserverBase.java @@ -26,19 +26,19 @@ import org.eclipse.titan.executorapi.test.JniExecutorAsyncHappyTest.McRoute; import org.eclipse.titan.executorapi.util.Log; abstract class TestObserverBase implements IJniExecutorObserver { - + /** Executor instance, NOT OWNED */ protected final JniExecutor mJe; - + /** TTCN-3 module name of the test control or test case(s), it can be null (it means execution list from cfg file is used) */ protected String mModule = null; - + /** List of test cases, it can be null (it means test control is executed) */ protected List<String> mTestcases = null; - + protected final McRoute mRoute; protected final ExecutionMethod mExecMethod; - + /** * Lock object for waiting completion. NOT OWNED */ @@ -51,29 +51,29 @@ abstract class TestObserverBase implements IJniExecutorObserver { * false: FAIL */ private volatile boolean mVerdict = true; - + public void setLock( final Object aLockObject ) { mLockCompletion = aLockObject; } - + public boolean getVerdict() { return mVerdict; } - + public void setModule( final String aModule ) { mModule = aModule; } - + public void setTestcases( final List<String> aTestcases ) { mTestcases = aTestcases; } - + protected TestObserverBase( final JniExecutor aJe, final McRoute aRoute, final ExecutionMethod aExecMethod ) { mJe = aJe; mRoute = aRoute; mExecMethod = aExecMethod; } - + @Override public void statusChanged(McStateEnum aNewState) { Log.fi(aNewState); @@ -91,7 +91,7 @@ abstract class TestObserverBase implements IJniExecutorObserver { } Log.fo(); } - + @Override public void error(int aSeverity, String aMsg) { Log.fi( aSeverity, aMsg ); @@ -104,7 +104,7 @@ abstract class TestObserverBase implements IJniExecutorObserver { Log.fi( aTime, aSource, aSeverity, aMsg ); Log.fo(); } - + @Override public void verdict(String aTestcase, VerdictTypeEnum aVerdictType) { Log.fi( aTestcase, aVerdictType ); @@ -116,7 +116,7 @@ abstract class TestObserverBase implements IJniExecutorObserver { Log.fi( aVerdictStats ); Log.fo(); } - + /** * Exception proof function instead of statusChanged(), exception is handled in statusChanged() * @param aNewState @@ -124,7 +124,7 @@ abstract class TestObserverBase implements IJniExecutorObserver { * @see #statusChanged(McStateEnum) */ abstract protected void statusChanged2( final McStateEnum aNewState ) throws JniExecutorException; - + /** * releases the lock of the test client */ @@ -137,7 +137,7 @@ abstract class TestObserverBase implements IJniExecutorObserver { } } } - + /** * Set verdict to FAIL on the observer, so to can be read by the test method */ @@ -145,7 +145,7 @@ abstract class TestObserverBase implements IJniExecutorObserver { mVerdict = false; releaseLock(); } - + /** * sets lock, waits until lock is released */