1 /*******************************************************************************
2 
3     Test for ocean.util.app.ext.TaskExt for CliApp
4 
5     Copyright:
6         Copyright (c) 2018 dunnhumby Germany GmbH.
7         All rights reserved.
8 
9     License:
10         Boost Software License Version 1.0. See LICENSE_BOOST.txt for details.
11         Alternatively, this file may be distributed under the terms of the Tango
12         3-Clause BSD License (see LICENSE_BSD.txt for details).
13 
14 *******************************************************************************/
15 
16 module integrationtest.taskext_cli.main;
17 
18 import ocean.meta.types.Qualifiers;
19 import ocean.util.app.CliApp;
20 import ocean.text.Arguments;
21 import ocean.task.Task;
22 import ocean.task.Scheduler;
23 import ocean.core.Test;
24 import Version;
25 
26 class HarmlessException : Exception
27 {
28     this ( )
29     {
30         super("");
31     }
32 }
33 
34 class TestApp : CliApp
35 {
36     this ( )
37     {
38         istring name = "test app";
39         istring desc = name;
40         CliApp.OptionalSettings settings;
41         settings.use_task_ext = true;
42         settings.scheduler_config.worker_fiber_limit = 5;
43         super(name, desc, VersionInfo.init, settings);
44     }
45 
46     override int run ( Arguments args )
47     {
48         theScheduler.exception_handler = (Task, Exception e)
49         {
50             throw e;
51         };
52 
53         test(Task.getThis() !is null);
54         test(isSchedulerUsed());
55         auto stats = theScheduler.getStats();
56         test!("==")(stats.worker_fiber_total, 5);
57         throw new HarmlessException;
58     }
59 }
60 
61 
62 version (unittest) {} else
63 int main ( istring[] cl_args )
64 {
65     auto app = new TestApp;
66     testThrown!(HarmlessException)(app.main(cl_args));
67     return 0;
68 }