Titan Core Initial Contribution
[deliverable/titan.core.git] / titan_executor_api / TITAN_Executor_API_test / src / org / eclipse / titan / executorapi / test / JniExecutorAsyncHappySimpleTest.java
1 /******************************************************************************
2 * Copyright (c) 2000-2014 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
8 package org.eclipse.titan.executorapi.test;
9
10 import static org.junit.Assert.*;
11
12 import java.util.ArrayList;
13 import java.util.List;
14
15 import org.eclipse.titan.executor.jni.McStateEnum;
16 import org.eclipse.titan.executorapi.HostController;
17 import org.eclipse.titan.executorapi.JniExecutor;
18 import org.eclipse.titan.executorapi.exception.JniExecutorException;
19 import org.eclipse.titan.executorapi.util.Log;
20 import org.junit.Test;
21
22 /**
23 * The purpose of the existence of this class is to show in one place (not through abstract functions and several methods, like it is done in the other happy test classes)
24 * how to navigate throw the execution flow using the API functions going to each state.
25 */
26 public class JniExecutorAsyncHappySimpleTest extends JniExecutorAsyncTest {
27
28 /**
29 * async
30 * route 1
31 * testcase by name
32 * happy day
33 * @throws JniExecutorException
34 */
35 @Test
36 public void testExecutor_Async_Route1_TestByTestCaseName_Happy() throws JniExecutorException {
37 Log.fi();
38 final JniExecutor je = JniExecutor.getInstance();
39 je.init();
40 final HostController hc1 = new HostController(null, TestConstants.WORKINGDIR, TestConstants.EXECUTABLE);
41 je.addHostController(hc1);
42 je.setConfigFileName(TestConstants.CFG_FILE);
43 final String module = TestConstants.MODULE;
44 final List<String> testcases = new ArrayList<String>();
45 testcases.add(TestConstants.TESTCASE1);
46 testcases.add(TestConstants.TESTCASE2);
47 final Test1Observer o = new Test1Observer( je, module, testcases );
48 je.setObserver(o);
49 final Object lock = new Object();
50 o.setLock( lock );
51 TestUtil.assertState( McStateEnum.MC_INACTIVE );
52 je.startSession();
53 TestUtil.assertState( McStateEnum.MC_LISTENING );
54 je.startHostControllers();
55 o.waitForCompletion();
56 assertTrue(o.getVerdict());
57 Log.fo();
58 }
59
60 /**
61 * async
62 * route 2
63 * testcase by name
64 * happy day
65 * @throws JniExecutorException
66 */
67 @Test
68 public void testExecutor_Async_Route2_TestByTestCaseName_Happy() throws JniExecutorException {
69 Log.fi();
70 final JniExecutor je = JniExecutor.getInstance();
71 je.init();
72 final HostController hc1 = new HostController(null, TestConstants.WORKINGDIR, TestConstants.EXECUTABLE);
73 je.addHostController(hc1);
74 je.setConfigFileName(TestConstants.CFG_FILE);
75 final String module = TestConstants.MODULE;
76 final List<String> testcases = new ArrayList<String>();
77 testcases.add(TestConstants.TESTCASE1);
78 testcases.add(TestConstants.TESTCASE2);
79 final Test2Observer o = new Test2Observer( je, module, testcases );
80 je.setObserver(o);
81 final Object lock = new Object();
82 o.setLock( lock );
83 TestUtil.assertState( McStateEnum.MC_INACTIVE );
84 je.startSession();
85 TestUtil.assertState( McStateEnum.MC_LISTENING );
86 je.configure();
87 o.waitForCompletion();
88 assertTrue(o.getVerdict());
89 Log.fo();
90 }
91 }
This page took 0.041591 seconds and 6 git commands to generate.