unageanu-jiji 1.1.4 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +24 -1
- data/README +0 -0
- data/base/shared_lib/moving_average.rb +34 -33
- data/base/shared_lib/system/cross.rb +76 -0
- data/base/shared_lib/system/position_manager.rb +160 -0
- data/base/shared_lib/system/signal.rb +347 -0
- data/html/css/datatable.css +4 -4
- data/html/css/default.css +57 -5
- data/html/css/treeview.css +205 -0
- data/html/img/bin_closed.png +0 -0
- data/html/img/bin_empty.png +0 -0
- data/html/img/button_add_small.gif +0 -0
- data/html/img/button_add_small_gray.gif +0 -0
- data/html/img/button_add_small_over.gif +0 -0
- data/html/img/button_mkcol.gif +0 -0
- data/html/img/button_mkcol_gray.gif +0 -0
- data/html/img/button_mkcol_over.gif +0 -0
- data/html/img/button_remove_small.gif +0 -0
- data/html/img/button_remove_small_gray.gif +0 -0
- data/html/img/button_remove_small_over.gif +0 -0
- data/html/img/button_rename.gif +0 -0
- data/html/img/button_rename_gray.gif +0 -0
- data/html/img/button_rename_over.gif +0 -0
- data/html/img/control_play.png +0 -0
- data/html/img/control_play_blue.png +0 -0
- data/html/img/folder.png +0 -0
- data/html/img/folder_brick.png +0 -0
- data/html/img/folder_user.png +0 -0
- data/html/{js/codepress/images → img}/line-numbers.png +0 -0
- data/html/img/page_white_ruby.png +0 -0
- data/html/img/sidebar_agent_edit.png +0 -0
- data/html/img/sidebar_agent_edit_over.png +0 -0
- data/html/img/sidebar_agent_edit_s.png +0 -0
- data/html/img/yui/treeview-sprite.gif +0 -0
- data/html/index.html +34 -18
- data/html/js/agent-editor/agent-editor-page.js +324 -0
- data/html/js/agent-editor/agent-editor.js +363 -0
- data/html/js/agent-editor/agent-list-tree.js +251 -0
- data/html/js/agent-selector.js +23 -28
- data/html/js/app.js +63 -91
- data/html/js/bt-create-page.js +25 -19
- data/html/js/container-min.js +1 -1
- data/html/js/container.js +944 -0
- data/html/js/edit_area/autocompletion.js +11 -13
- data/html/js/edit_area/edit_area.css +79 -40
- data/html/js/edit_area/edit_area.js +255 -226
- data/html/js/edit_area/edit_area_compressor.php +4 -4
- data/html/js/edit_area/edit_area_full.gz +0 -0
- data/html/js/edit_area/edit_area_full.js +31 -31
- data/html/js/edit_area/edit_area_full_with_plugins.gz +0 -0
- data/html/js/edit_area/edit_area_full_with_plugins.js +31 -31
- data/html/js/edit_area/edit_area_functions.js +448 -341
- data/html/js/edit_area/edit_area_loader.js +409 -397
- data/html/js/edit_area/elements_functions.js +120 -123
- data/html/js/edit_area/highlight.js +305 -197
- data/html/js/edit_area/images/goto.png +0 -0
- data/html/js/edit_area/images/help.png +0 -0
- data/html/js/edit_area/images/redo.png +0 -0
- data/html/js/edit_area/images/save.png +0 -0
- data/html/js/edit_area/images/search.png +0 -0
- data/html/js/edit_area/images/undo.png +0 -0
- data/html/js/edit_area/images/word_wrap.gif +0 -0
- data/html/js/edit_area/keyboard.js +5 -5
- data/html/js/edit_area/langs/bg.js +73 -0
- data/html/js/edit_area/langs/cs.js +2 -0
- data/html/js/edit_area/langs/de.js +2 -0
- data/html/js/edit_area/langs/dk.js +2 -0
- data/html/js/edit_area/langs/en.js +2 -0
- data/html/js/edit_area/langs/eo.js +2 -0
- data/html/js/edit_area/langs/es.js +2 -0
- data/html/js/edit_area/langs/fi.js +67 -0
- data/html/js/edit_area/langs/fr.js +2 -0
- data/html/js/edit_area/langs/hr.js +2 -0
- data/html/js/edit_area/langs/it.js +2 -0
- data/html/js/edit_area/langs/ja.js +2 -0
- data/html/js/edit_area/langs/mk.js +2 -0
- data/html/js/edit_area/langs/nl.js +2 -0
- data/html/js/edit_area/langs/pl.js +2 -0
- data/html/js/edit_area/langs/pt.js +2 -0
- data/html/js/edit_area/langs/ru.js +2 -0
- data/html/js/edit_area/langs/sk.js +2 -0
- data/html/js/edit_area/langs/zh.js +67 -0
- data/html/js/edit_area/manage_area.js +362 -205
- data/html/js/edit_area/plugins/charmap/langs/bg.js +12 -0
- data/html/js/edit_area/plugins/charmap/langs/zh.js +6 -0
- data/html/js/edit_area/plugins/test/langs/bg.js +10 -0
- data/html/js/edit_area/plugins/test/langs/zh.js +4 -0
- data/html/js/edit_area/reg_syntax/java.js +56 -0
- data/html/js/edit_area/reg_syntax/ruby.js +9 -9
- data/html/js/edit_area/reg_syntax.js +15 -13
- data/html/js/edit_area/regexp.js +36 -32
- data/html/js/edit_area/resize_area.js +43 -47
- data/html/js/edit_area/search_replace.js +29 -29
- data/html/js/edit_area/template.html +6 -4
- data/html/js/json-broker-client.js +23 -17
- data/html/js/result-page.js +107 -57
- data/html/js/rt-setting-page.js +38 -15
- data/html/js/sidebar.js +41 -27
- data/html/js/templates.js +167 -32
- data/html/js/utils.js +143 -7
- data/html/js/yui/treeview.js +3671 -0
- data/html/swf/chart.swf +0 -0
- data/html/test/agent_editor_spec.js +815 -0
- data/html/test/index.html +40 -0
- data/html/test/jsspec/JSSpec.css +224 -0
- data/html/test/jsspec/JSSpec.js +1549 -0
- data/html/test/jsspec/diff_match_patch.js +1 -0
- data/html/test/utils_spec.js +111 -0
- data/lib/jiji/agent/agent.rb +69 -12
- data/lib/jiji/agent/agent_manager.rb +18 -12
- data/lib/jiji/agent/agent_registry.rb +35 -121
- data/lib/jiji/collector.rb +16 -6
- data/lib/jiji/command.rb +46 -5
- data/lib/jiji/dao/file_system_dao.rb +158 -0
- data/lib/jiji/dao/timed_data_dao.rb +2 -0
- data/lib/jiji/dao/trade_result_dao.rb +1 -1
- data/lib/jiji/error.rb +24 -8
- data/lib/jiji/migration/migrator1_2_0.rb +67 -0
- data/lib/jiji/models.rb +82 -24
- data/lib/jiji/operator.rb +55 -51
- data/lib/jiji/output.rb +85 -29
- data/lib/jiji/output_manager.rb +84 -0
- data/lib/jiji/plugin/embedded/single_click_client.rb +2 -2
- data/lib/jiji/plugin/securities_plugin.rb +0 -1
- data/lib/jiji/process.rb +229 -208
- data/lib/jiji/process_manager.rb +190 -96
- data/lib/jiji/registry.rb +87 -19
- data/lib/jiji/server.rb +1 -0
- data/lib/jiji/service/agent_service.rb +147 -48
- data/lib/jiji/service/output_service.rb +37 -17
- data/lib/jiji/service/process_service.rb +3 -5
- data/lib/jiji/service/trade_result_service.rb +4 -5
- data/lib/jiji/util/file_lock.rb +4 -4
- data/lib/jiji/util/include_proxy.rb +17 -0
- data/lib/jiji/util/json_broker.rb +6 -4
- data/lib/jiji/util/util.rb +1 -1
- data/swf/chart/fx/chart/Chart.as +7 -0
- data/swf/chart/fx/chart/ui/graph/GraphManager.as +15 -2
- data/test/ProcessTest/agents/foo.rb +10 -0
- data/test/ProcessTest/conf/configuration.yaml +3 -0
- data/test/agent/agent_tests.rb +10 -0
- data/test/agent/test_AgentManager.rb +28 -12
- data/test/agent/test_AgentRegistry.rb +194 -99
- data/test/agent/test_PeriodicallyAgent.rb +1 -2
- data/test/agent/test_Permitter.rb +1 -2
- data/test/all_tests.rb +7 -19
- data/test/dao/dao_tests.rb +9 -0
- data/test/dao/test_FileSystemDao.rb +431 -0
- data/test/dao/test_RateDao.rb +5 -7
- data/test/dao/test_TradeResultDao.rb +1 -2
- data/test/migration/migration_tests.rb +10 -0
- data/test/migration/migrator1_2_0test_data/basic/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/basic/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/basic/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/basic/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
- data/test/migration/migrator1_2_0test_data/basic/props.yaml +85 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/props.yaml +1 -0
- data/test/migration/migrator1_2_0test_data/no_outs/props.yaml +85 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
- data/test/migration/test_Migrator.rb +1 -1
- data/test/migration/test_Migrator1_0_3.rb +1 -1
- data/test/migration/test_Migrator1_1_0.rb +1 -1
- data/test/migration/test_Migrator1_2_0.rb +94 -0
- data/test/plugin/embedded/test_SingleClickClient.rb +1 -2
- data/test/plugin/plugin_tests.rb +8 -0
- data/test/plugin/test_Loader.rb +1 -1
- data/test/shared/rate.csv +144 -0
- data/test/shared/shared_tests.rb +9 -0
- data/test/shared/test_Cross.rb +144 -0
- data/test/shared/test_PositionManager.rb +285 -0
- data/test/shared/test_Signal.rb +65 -0
- data/test/test_Output.rb +28 -21
- data/test/test_OutputManager.rb +162 -0
- data/test/test_Output_registry.rb +6 -17
- data/test/test_Process.rb +434 -222
- data/test/test_ProcessManager.rb +458 -101
- data/test/test_utils.rb +71 -8
- data/test/util/test_BlockToSession.rb +1 -2
- data/test/util/test_CSV.rb +1 -2
- data/test/util/test_SynchronizeInterceptor.rb +1 -2
- data/test/util/util_tests.rb +9 -0
- metadata +127 -47
- data/html/js/agent-editor-page.js +0 -440
- data/html/js/codepress/codepress.css +0 -21
- data/html/js/codepress/codepress.html +0 -35
- data/html/js/codepress/codepress.js +0 -138
- data/html/js/codepress/engines/gecko.js +0 -293
- data/html/js/codepress/engines/khtml.js +0 -0
- data/html/js/codepress/engines/msie.js +0 -304
- data/html/js/codepress/engines/older.js +0 -0
- data/html/js/codepress/engines/opera.js +0 -260
- data/html/js/codepress/images/line-numbers.gif +0 -0
- data/html/js/codepress/index.html +0 -443
- data/html/js/codepress/languages/asp.css +0 -71
- data/html/js/codepress/languages/asp.js +0 -117
- data/html/js/codepress/languages/autoit.css +0 -13
- data/html/js/codepress/languages/autoit.js +0 -32
- data/html/js/codepress/languages/csharp.css +0 -9
- data/html/js/codepress/languages/csharp.js +0 -25
- data/html/js/codepress/languages/css.css +0 -10
- data/html/js/codepress/languages/css.js +0 -23
- data/html/js/codepress/languages/generic.css +0 -9
- data/html/js/codepress/languages/generic.js +0 -25
- data/html/js/codepress/languages/html.css +0 -13
- data/html/js/codepress/languages/html.js +0 -59
- data/html/js/codepress/languages/java.css +0 -7
- data/html/js/codepress/languages/java.js +0 -24
- data/html/js/codepress/languages/javascript.css +0 -8
- data/html/js/codepress/languages/javascript.js +0 -30
- data/html/js/codepress/languages/perl.css +0 -11
- data/html/js/codepress/languages/perl.js +0 -27
- data/html/js/codepress/languages/php.css +0 -12
- data/html/js/codepress/languages/php.js +0 -61
- data/html/js/codepress/languages/ruby.css +0 -10
- data/html/js/codepress/languages/ruby.js +0 -26
- data/html/js/codepress/languages/sql.css +0 -10
- data/html/js/codepress/languages/sql.js +0 -30
- data/html/js/codepress/languages/text.css +0 -5
- data/html/js/codepress/languages/text.js +0 -9
- data/html/js/codepress/languages/vbscript.css +0 -71
- data/html/js/codepress/languages/vbscript.js +0 -117
- data/html/js/codepress/languages/xsl.css +0 -15
- data/html/js/codepress/languages/xsl.js +0 -103
- data/html/js/codepress/license.txt +0 -458
- data/html/js/edit_area/images/Thumbs.db +0 -0
- data/test/plugin/test_gem/a/lib/jiji_plugin_test.rb +0 -6
data/test/test_Process.rb
CHANGED
@@ -6,11 +6,7 @@ require 'rubygems'
|
|
6
6
|
require 'runit/testcase'
|
7
7
|
require 'runit/cui/testrunner'
|
8
8
|
require 'jiji/process'
|
9
|
-
require 'jiji/
|
10
|
-
require 'jiji/agent/agent_manager'
|
11
|
-
require 'jiji/agent/agent_registry'
|
12
|
-
require 'jiji/agent/permitter'
|
13
|
-
require 'jiji/agent/util'
|
9
|
+
require 'jiji/registry'
|
14
10
|
require 'logger'
|
15
11
|
require 'test_utils'
|
16
12
|
|
@@ -20,326 +16,542 @@ class ProcessTest < RUNIT::TestCase
|
|
20
16
|
include Test::Constants
|
21
17
|
|
22
18
|
def setup
|
23
|
-
@dir = File.dirname(__FILE__) + "/ProcessTest
|
19
|
+
@dir = File.dirname(__FILE__) + "/ProcessTest"
|
24
20
|
FileUtils.mkdir_p @dir
|
25
|
-
|
26
|
-
@
|
27
|
-
|
28
|
-
# レジストリ
|
29
|
-
@registry_mock = Object.new
|
30
|
-
class << @registry_mock
|
31
|
-
def output( agent_name, dir )
|
32
|
-
return ["from_registry"]
|
33
|
-
end
|
34
|
-
end
|
21
|
+
@registry = JIJI::Registry.new(@dir , nil)
|
22
|
+
@registry.plugin_loader.load
|
35
23
|
end
|
36
24
|
|
37
25
|
def teardown
|
38
|
-
|
26
|
+
begin
|
27
|
+
Test.destry( @registry, @dir )
|
28
|
+
ensure
|
29
|
+
FileUtils.rm_rf "#{@dir}/process_info_test"
|
30
|
+
end
|
39
31
|
end
|
40
32
|
|
41
|
-
#
|
42
|
-
def
|
33
|
+
# ProcessInfoの基本操作のテスト
|
34
|
+
def test_process_info
|
43
35
|
|
44
|
-
#
|
45
|
-
agent_mng = new_agent_mang
|
36
|
+
dir = "#{@dir}/process_info_test"
|
46
37
|
|
47
|
-
p1 = JIJI::
|
48
|
-
assert_equals p1.
|
49
|
-
assert_equals p1.props, {
|
38
|
+
p1 = JIJI::ProcessInfo.new( "1", dir )
|
39
|
+
assert_equals p1.process_id, "1"
|
40
|
+
assert_equals p1.props, {}
|
50
41
|
assert_equals p1["x"], nil
|
51
|
-
assert_equals p1.
|
52
|
-
assert_equals p1.
|
42
|
+
assert_equals p1.progress, 0
|
43
|
+
assert_equals p1.data_exist?, false
|
53
44
|
|
54
|
-
|
45
|
+
#プロパティを設定。データがファイルに保存される。
|
46
|
+
p1.props = {"x"=>"xxx", "y"=>"yyy"}
|
47
|
+
assert_equals p1.process_id, "1"
|
48
|
+
assert_equals p1.props, {"x"=>"xxx", "y"=>"yyy"}
|
55
49
|
assert_equals p1["x"], "xxx"
|
50
|
+
assert_equals p1["y"], "yyy"
|
51
|
+
assert_equals p1.progress, 0
|
52
|
+
assert_equals p1.data_exist?, true
|
53
|
+
|
54
|
+
|
55
|
+
#再作成
|
56
|
+
p1 = JIJI::ProcessInfo.new( "1", dir )
|
57
|
+
assert_equals p1.process_id, "1"
|
58
|
+
assert_equals p1.props, {}
|
59
|
+
assert_equals p1["x"], nil
|
60
|
+
assert_equals p1.progress, 0
|
61
|
+
assert_equals p1.data_exist?, true
|
62
|
+
|
63
|
+
#保存されたデータを読み込み
|
64
|
+
p1.load
|
65
|
+
assert_equals p1.process_id, "1"
|
66
|
+
assert_equals p1.props, {"x"=>"xxx", "y"=>"yyy"}
|
67
|
+
assert_equals p1["x"], "xxx"
|
68
|
+
assert_equals p1["y"], "yyy"
|
69
|
+
assert_equals p1.progress, 0
|
70
|
+
|
71
|
+
#プロパティを変更
|
72
|
+
p1["x"] = "aaa"
|
73
|
+
p1["a"] = "aaa"
|
74
|
+
p1.progress = 20
|
75
|
+
assert_equals p1.process_id, "1"
|
76
|
+
assert_equals p1.props, {"x"=>"aaa", "y"=>"yyy", "a"=>"aaa"}
|
77
|
+
assert_equals p1["x"], "aaa"
|
78
|
+
assert_equals p1["y"], "yyy"
|
79
|
+
assert_equals p1["a"], "aaa"
|
80
|
+
assert_equals p1.progress, 20
|
81
|
+
|
82
|
+
#再作成
|
83
|
+
p1 = JIJI::ProcessInfo.new( "1", dir )
|
84
|
+
assert_equals p1.process_id, "1"
|
85
|
+
assert_equals p1.props, {}
|
86
|
+
assert_equals p1["x"], nil
|
87
|
+
assert_equals p1.progress, 0
|
88
|
+
assert_equals p1.data_exist?, true
|
89
|
+
|
90
|
+
#保存されたデータを読み込み
|
91
|
+
p1.load
|
92
|
+
assert_equals p1.process_id, "1"
|
93
|
+
assert_equals p1.props, {"x"=>"aaa", "y"=>"yyy", "a"=>"aaa"}
|
94
|
+
assert_equals p1["x"], "aaa"
|
95
|
+
assert_equals p1["y"], "yyy"
|
96
|
+
assert_equals p1["a"], "aaa"
|
97
|
+
assert_equals p1.progress, 0 #進捗は記録されない。
|
98
|
+
|
99
|
+
|
100
|
+
#別のProcessInfo
|
101
|
+
p1 = JIJI::ProcessInfo.new( "2", dir )
|
102
|
+
assert_equals p1.process_id, "2"
|
103
|
+
assert_equals p1.props, {}
|
104
|
+
assert_equals p1["x"], nil
|
105
|
+
assert_equals p1.progress, 0
|
106
|
+
assert_equals p1.data_exist?, false
|
107
|
+
end
|
108
|
+
|
109
|
+
# Processの基本動作のテスト
|
110
|
+
def test_backtest_process
|
111
|
+
|
112
|
+
# エージェント設定なし
|
113
|
+
pi1 = @registry.process_info( "1" )
|
114
|
+
pi1.props = {
|
115
|
+
"id"=>"pid1",
|
116
|
+
"name"=>"エージェントなし",
|
117
|
+
"start_date"=>0,
|
118
|
+
"end_date"=>100
|
119
|
+
}
|
120
|
+
p1 = @registry.backtest_process(pi1)
|
121
|
+
agent_mng = p1.agent_manager
|
122
|
+
|
123
|
+
#エージェントを読み込み → 何もロードされない
|
124
|
+
p1.load_agents( false )
|
125
|
+
assert_equals agent_mng.map, []
|
126
|
+
|
127
|
+
assert_equals agent_mng.operator.trade_enable, false
|
56
128
|
|
57
129
|
# トレードのon/offを設定
|
58
|
-
p1
|
59
|
-
|
60
|
-
assert_equals
|
61
|
-
p1
|
62
|
-
|
63
|
-
assert_equals
|
64
|
-
p1
|
65
|
-
|
66
|
-
assert_equals
|
67
|
-
|
68
|
-
|
130
|
+
p1.trade_enable = true
|
131
|
+
pi1["trade_enable"] = true
|
132
|
+
assert_equals agent_mng.operator.trade_enable, true
|
133
|
+
p1.trade_enable = false
|
134
|
+
pi1["trade_enable"] = false
|
135
|
+
assert_equals agent_mng.operator.trade_enable, false
|
136
|
+
p1.trade_enable = true
|
137
|
+
pi1["trade_enable"] = true
|
138
|
+
assert_equals agent_mng.operator.trade_enable, true
|
139
|
+
|
140
|
+
#エージェントを追加
|
69
141
|
agents = [
|
70
142
|
{"id"=>"aaa",
|
71
143
|
"name"=>"テストエージェント1",
|
72
|
-
"class"=>"
|
73
|
-
"class_name" => "
|
144
|
+
"class"=>"TestAgent@foo.rb",
|
145
|
+
"class_name" => "TestAgent",
|
74
146
|
"file_name" => "foo.rb",
|
75
147
|
"description" => "説明",
|
76
148
|
"property_def" => {"id"=>"x", "default"=>85 },
|
77
149
|
"properties" => {"x"=>30, "y"=>40 }},
|
78
150
|
{"id"=>"bbb",
|
79
151
|
"name"=>"テストエージェント2",
|
80
|
-
"class"=>"
|
81
|
-
"class_name" => "
|
152
|
+
"class"=>"TestAgent2@foo.rb",
|
153
|
+
"class_name" => "TestAgent",
|
82
154
|
"file_name" => "foo.rb",
|
83
155
|
"description" => "説明2",
|
84
156
|
"property_def" => {"id"=>"x", "default"=>85 },
|
85
157
|
"properties" => {"x"=>30, "y"=>41 }}
|
86
158
|
]
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
assert_equals p1["agents"], agents
|
91
|
-
assert_equals agent_mng.get("aaa").agent.cl, "testclass@foo.rb"
|
159
|
+
pi1["agents"] = agents
|
160
|
+
p1.set_agents( agents )
|
161
|
+
assert_equals pi1["agents"], agents
|
92
162
|
assert_equals agent_mng.get("aaa").agent.properties, {"x"=>30, "y"=>40 }
|
93
|
-
assert_equals agent_mng.get("bbb").agent.cl, "testclass2@foo.rb"
|
94
163
|
assert_equals agent_mng.get("bbb").agent.properties, {"x"=>30, "y"=>41 }
|
95
|
-
|
164
|
+
|
165
|
+
assert_equals agent_mng.get("aaa").operator.agent_name, "テストエージェント1"
|
166
|
+
assert_equals agent_mng.get("bbb").operator.agent_name, "テストエージェント2"
|
167
|
+
|
168
|
+
out1 = agent_mng.output_manager.get( "1", "aaa" )
|
169
|
+
assert_equals out1.agent_id, "aaa"
|
170
|
+
assert_equals out1.agent_name, "テストエージェント1"
|
171
|
+
out2 = agent_mng.output_manager.get( "1", "bbb" )
|
172
|
+
assert_equals out2.agent_id, "bbb"
|
173
|
+
assert_equals out2.agent_name, "テストエージェント2"
|
174
|
+
|
96
175
|
|
97
176
|
# 変更
|
98
177
|
agents = [
|
99
178
|
{"id"=>"aaa",
|
100
179
|
"name"=>"テストエージェント1",
|
101
|
-
"class"=>"
|
102
|
-
"class_name" => "
|
180
|
+
"class"=>"TestAgent@foo.rb",
|
181
|
+
"class_name" => "TestAgent",
|
103
182
|
"file_name" => "foo.rb",
|
104
183
|
"description" => "説明",
|
105
184
|
"property_def" => {"id"=>"x", "default"=>85 },
|
106
185
|
"properties" => {"x"=>50, "y"=>40 }},
|
107
186
|
{"id"=>"bbb",
|
108
187
|
"name"=>"テストエージェント4",
|
109
|
-
"class"=>"
|
110
|
-
"class_name" => "
|
188
|
+
"class"=>"TestAgent2@foo.rb",
|
189
|
+
"class_name" => "TestAgent",
|
111
190
|
"file_name" => "foo.rb",
|
112
191
|
"description" => "説明2aaaaaa",
|
113
192
|
"property_def" => {"id"=>"x", "default"=>85 },
|
114
193
|
"properties" => {"x"=>60, "y"=>41 }}
|
115
194
|
]
|
116
|
-
|
117
|
-
|
118
|
-
assert_equals
|
195
|
+
pi1["agents"] = agents
|
196
|
+
p1.set_agents( agents )
|
197
|
+
assert_equals pi1["agents"], agents
|
119
198
|
assert_equals agent_mng.get("aaa").agent.properties, {"x"=>50, "y"=>40 }
|
120
|
-
assert_equals agent_mng.get("bbb").agent.cl, "testclass2@foo.rb"
|
121
199
|
assert_equals agent_mng.get("bbb").agent.properties, {"x"=>60, "y"=>41 }
|
122
|
-
|
200
|
+
|
201
|
+
assert_equals agent_mng.get("aaa").operator.agent_name, "テストエージェント1"
|
202
|
+
assert_equals agent_mng.get("bbb").operator.agent_name, "テストエージェント4"
|
203
|
+
|
204
|
+
out1 = agent_mng.output_manager.get( "1", "aaa" )
|
205
|
+
assert_equals out1.agent_id, "aaa"
|
206
|
+
assert_equals out1.agent_name, "テストエージェント1"
|
207
|
+
out2 = agent_mng.output_manager.get( "1", "bbb" )
|
208
|
+
assert_equals out2.agent_id, "bbb"
|
209
|
+
assert_equals out2.agent_name, "テストエージェント4"
|
123
210
|
|
124
211
|
# 削除
|
125
212
|
agents = [
|
126
213
|
{"id"=>"aaa",
|
127
|
-
"name"=>"テストエージェント
|
128
|
-
"class"=>"
|
129
|
-
"class_name" => "
|
214
|
+
"name"=>"テストエージェント11",
|
215
|
+
"class"=>"TestAgent@foo.rb",
|
216
|
+
"class_name" => "TestAgent",
|
130
217
|
"file_name" => "foo.rb",
|
131
218
|
"description" => "説明",
|
132
219
|
"property_def" => {"id"=>"x", "default"=>85 },
|
133
220
|
"properties" => {"x"=>50, "y"=>41 }}
|
134
221
|
]
|
135
|
-
p1
|
136
|
-
|
137
|
-
assert_equals
|
222
|
+
p1.set_agents( agents )
|
223
|
+
pi1["agents"] = agents
|
224
|
+
assert_equals pi1["agents"], agents
|
138
225
|
assert_equals agent_mng.get("aaa").agent.properties, {"x"=>50, "y"=>41 }
|
139
226
|
assert_equals agent_mng.get("bbb"), nil
|
140
|
-
assert_equals p1.outputs, { "aaa"=>["out1","out2"] }
|
141
227
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
assert_equals
|
228
|
+
assert_equals agent_mng.get("aaa").operator.agent_name, "テストエージェント11"
|
229
|
+
|
230
|
+
out1 = agent_mng.output_manager.get( "1", "aaa" )
|
231
|
+
assert_equals out1.agent_id, "aaa"
|
232
|
+
assert_equals out1.agent_name, "テストエージェント11"
|
233
|
+
out2 = agent_mng.output_manager.get( "1", "bbb" ) # outputは削除されない。
|
234
|
+
assert_equals out2.agent_id, "bbb"
|
235
|
+
assert_equals out2.agent_name, "テストエージェント4"
|
236
|
+
|
237
|
+
|
238
|
+
# 保存されたデータから再構築
|
239
|
+
pi1 = @registry.process_info( "1" )
|
240
|
+
pi1.load
|
241
|
+
p1 = @registry.backtest_process(pi1)
|
242
|
+
agent_mng = p1.agent_manager
|
243
|
+
|
244
|
+
p1.load_agents( false )
|
147
245
|
assert_equals p1.agent_manager, agent_mng
|
148
|
-
assert_equals
|
149
|
-
assert_equals
|
150
|
-
|
246
|
+
assert_equals pi1["agents"], agents
|
247
|
+
assert_equals pi1["trade_enable"], false #バックテストは必ずfalseになる
|
248
|
+
|
249
|
+
assert_equals agent_mng.operator.trade_enable, false #バックテストは必ずfalseになる
|
250
|
+
|
151
251
|
assert_equals agent_mng.get("aaa").agent.properties, {"x"=>50, "y"=>41 }
|
152
252
|
assert_equals agent_mng.get("bbb"), nil
|
153
|
-
|
154
|
-
assert_equals
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
assert_equals
|
162
|
-
|
163
|
-
|
164
|
-
assert_equals p1["agents"], agents
|
165
|
-
assert_equals agent_mng.get("aaa"), nil
|
166
|
-
assert_equals agent_mng.get("bbb"), nil
|
167
|
-
assert_equals p1["trade_enable"], false
|
168
|
-
assert_equals p1.agent_manager.operator.trade_enable, false
|
169
|
-
assert_equals p1.outputs, { "aaa"=> ["from_registry"] }
|
170
|
-
|
171
|
-
# 別のプロセスを作成 / 設定値は別途保持される。
|
172
|
-
agent_mng = new_agent_mang
|
173
|
-
p2 = JIJI::Process.new( "2", @dir, agent_mng, @logger, {}, @registry_mock )
|
174
|
-
assert_equals p2.id, "2"
|
175
|
-
assert_equals p2.agent_manager, agent_mng
|
176
|
-
assert_equals p2["x"], nil
|
177
|
-
assert_equals p2["agents"], []
|
178
|
-
assert_equals p2.outputs, { }
|
253
|
+
|
254
|
+
assert_equals agent_mng.get("aaa").operator.agent_name, "テストエージェント11"
|
255
|
+
|
256
|
+
out1 = agent_mng.output_manager.get( "1", "aaa" )
|
257
|
+
assert_equals out1.agent_id, "aaa"
|
258
|
+
assert_equals out1.agent_name, "テストエージェント11"
|
259
|
+
out2 = agent_mng.output_manager.get( "1", "bbb" )
|
260
|
+
assert_equals out2.agent_id, "bbb"
|
261
|
+
assert_equals out2.agent_name, "テストエージェント4"
|
262
|
+
|
263
|
+
p1.stop
|
179
264
|
|
180
265
|
# 作成の段階でエージェントを指定する
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
266
|
+
pi2 = @registry.process_info( "2" )
|
267
|
+
pi2.props = {
|
268
|
+
"id"=>"2",
|
269
|
+
"name"=>"エージェントあり",
|
270
|
+
"start_date"=>0,
|
271
|
+
"end_date"=>100,
|
272
|
+
"agents"=>agents
|
273
|
+
}
|
274
|
+
p2 = @registry.backtest_process(pi2)
|
275
|
+
agent_mng = p2.agent_manager
|
276
|
+
|
277
|
+
p2.load_agents( false )
|
278
|
+
assert_equals p2.agent_manager, agent_mng
|
279
|
+
assert_equals p2.info, pi2
|
280
|
+
assert_equals agent_mng.operator.trade_enable, false
|
281
|
+
|
188
282
|
assert_equals agent_mng.get("aaa").agent.properties, {"x"=>50, "y"=>41 }
|
189
283
|
assert_equals agent_mng.get("bbb"), nil
|
190
|
-
assert_equals p3.outputs, { "aaa"=>["out1","out2"] }
|
191
284
|
|
285
|
+
out1 = agent_mng.output_manager.get( "2", "aaa" )
|
286
|
+
assert_equals out1.agent_id, "aaa"
|
287
|
+
assert_equals out1.agent_name, "テストエージェント11"
|
288
|
+
|
289
|
+
p2.stop
|
192
290
|
end
|
193
291
|
|
194
|
-
#
|
195
|
-
def
|
292
|
+
# Processの基本動作のテスト
|
293
|
+
def test_rmt_process
|
294
|
+
|
295
|
+
p1 = @registry.rmt_process
|
296
|
+
agent_mng = p1.agent_manager
|
297
|
+
|
298
|
+
#エージェントを読み込み → 何もロードされない
|
299
|
+
p1.load_agents( false )
|
300
|
+
assert_equals agent_mng.map, []
|
301
|
+
|
302
|
+
assert_equals agent_mng.operator.trade_enable, false
|
303
|
+
|
304
|
+
# トレードのon/offを設定
|
305
|
+
p1.trade_enable = true
|
306
|
+
p1.info["trade_enable"] = true
|
307
|
+
assert_equals agent_mng.operator.trade_enable, true
|
308
|
+
p1.trade_enable = false
|
309
|
+
p1.info["trade_enable"] = false
|
310
|
+
assert_equals agent_mng.operator.trade_enable, false
|
311
|
+
p1.trade_enable = true
|
312
|
+
p1.info["trade_enable"] = true
|
313
|
+
assert_equals agent_mng.operator.trade_enable, true
|
314
|
+
|
315
|
+
#エージェントを追加
|
196
316
|
agents = [
|
197
317
|
{"id"=>"aaa",
|
198
318
|
"name"=>"テストエージェント1",
|
199
|
-
"class"=>"
|
200
|
-
"class_name" => "
|
319
|
+
"class"=>"TestAgent@foo.rb",
|
320
|
+
"class_name" => "TestAgent",
|
201
321
|
"file_name" => "foo.rb",
|
202
322
|
"description" => "説明",
|
203
323
|
"property_def" => {"id"=>"x", "default"=>85 },
|
204
|
-
"properties" => {"x"=>
|
324
|
+
"properties" => {"x"=>30, "y"=>40 }},
|
325
|
+
{"id"=>"bbb",
|
326
|
+
"name"=>"テストエージェント2",
|
327
|
+
"class"=>"TestAgent2@foo.rb",
|
328
|
+
"class_name" => "TestAgent",
|
329
|
+
"file_name" => "foo.rb",
|
330
|
+
"description" => "説明2",
|
331
|
+
"property_def" => {"id"=>"x", "default"=>85 },
|
332
|
+
"properties" => {"x"=>30, "y"=>41 }}
|
205
333
|
]
|
334
|
+
p1.set_agents( agents )
|
335
|
+
p1.info["agents"] = agents
|
336
|
+
assert_equals p1.info["agents"], agents
|
337
|
+
assert_equals agent_mng.get("aaa").agent.properties, {"x"=>30, "y"=>40 }
|
338
|
+
assert_equals agent_mng.get("bbb").agent.properties, {"x"=>30, "y"=>41 }
|
206
339
|
|
207
|
-
|
208
|
-
|
209
|
-
agent_mng = new_agent_mang
|
210
|
-
p1 = JIJI::Process.new( "1", @dir, agent_mng, @logger, {"agents"=>agents}, @registry_mock, true )
|
340
|
+
assert_equals agent_mng.get("aaa").operator.agent_name, "テストエージェント1"
|
341
|
+
assert_equals agent_mng.get("bbb").operator.agent_name, "テストエージェント2"
|
211
342
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
343
|
+
out1 = agent_mng.output_manager.get( "rmt", "aaa" )
|
344
|
+
assert_equals out1.agent_id, "aaa"
|
345
|
+
assert_equals out1.agent_name, "テストエージェント1"
|
346
|
+
out2 = agent_mng.output_manager.get( "rmt", "bbb" )
|
347
|
+
assert_equals out2.agent_id, "bbb"
|
348
|
+
assert_equals out2.agent_name, "テストエージェント2"
|
349
|
+
|
350
|
+
p1.stop
|
351
|
+
Test.destry( @registry)
|
352
|
+
@registry = JIJI::Registry.new(@dir , nil)
|
353
|
+
@registry.plugin_loader.load
|
354
|
+
|
355
|
+
# 保存されたデータから再構築
|
356
|
+
p1 = @registry.rmt_process
|
357
|
+
agent_mng = p1.agent_manager
|
358
|
+
|
359
|
+
p1.load_agents( false )
|
220
360
|
assert_equals p1.agent_manager, agent_mng
|
221
|
-
assert_equals p1["agents"], agents
|
222
|
-
assert_equals
|
223
|
-
assert_equals agent_mng.get("bbb"), nil
|
224
|
-
assert_equals p1["trade_enable"], nil
|
225
|
-
assert_equals p1.agent_manager.operator.trade_enable, false
|
226
|
-
assert_equals p1.outputs, { "aaa"=>["from_registry"] }
|
361
|
+
assert_equals p1.info["agents"], agents
|
362
|
+
assert_equals p1.info["trade_enable"], true
|
227
363
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
"property_def" => {"id"=>"x", "default"=>85 },
|
236
|
-
"properties" => {"x"=>60, "y"=>41 }}
|
237
|
-
begin
|
238
|
-
p1["agents"] = agents
|
239
|
-
fail
|
240
|
-
rescue
|
241
|
-
end
|
364
|
+
assert_equals agent_mng.operator.trade_enable, true
|
365
|
+
|
366
|
+
assert_equals agent_mng.get("aaa").agent.properties, {"x"=>30, "y"=>40 }
|
367
|
+
assert_equals agent_mng.get("bbb").agent.properties, {"x"=>30, "y"=>41 }
|
368
|
+
|
369
|
+
assert_equals agent_mng.get("aaa").operator.agent_name, "テストエージェント1"
|
370
|
+
assert_equals agent_mng.get("bbb").operator.agent_name, "テストエージェント2"
|
242
371
|
|
243
|
-
|
244
|
-
|
372
|
+
out1 = agent_mng.output_manager.get( "rmt", "aaa" )
|
373
|
+
assert_equals out1.agent_id, "aaa"
|
374
|
+
assert_equals out1.agent_name, "テストエージェント1"
|
375
|
+
out2 = agent_mng.output_manager.get( "rmt", "bbb" )
|
376
|
+
assert_equals out2.agent_id, "bbb"
|
377
|
+
assert_equals out2.agent_name, "テストエージェント2"
|
378
|
+
|
379
|
+
|
380
|
+
# 削除
|
381
|
+
agents = [
|
245
382
|
{"id"=>"aaa",
|
246
|
-
"name"=>"テストエージェント
|
247
|
-
"class"=>"
|
248
|
-
"class_name" => "
|
383
|
+
"name"=>"テストエージェント11",
|
384
|
+
"class"=>"TestAgent@foo.rb",
|
385
|
+
"class_name" => "TestAgent",
|
249
386
|
"file_name" => "foo.rb",
|
250
387
|
"description" => "説明",
|
251
388
|
"property_def" => {"id"=>"x", "default"=>85 },
|
252
389
|
"properties" => {"x"=>50, "y"=>41 }}
|
253
390
|
]
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
a = Agent.new( cl, property )
|
258
|
-
class << a
|
259
|
-
def properties=(props)
|
260
|
-
raise "test"
|
261
|
-
end
|
262
|
-
end
|
263
|
-
return a
|
264
|
-
end
|
265
|
-
end
|
266
|
-
agent_mng = new_agent_mang(error_registry)
|
267
|
-
p1 = JIJI::Process.new( "2", @dir, agent_mng, @logger, {"agents"=>agents2}, @registry_mock, true )
|
268
|
-
assert_equals p1["agents"], agents2
|
269
|
-
assert_equals agent_mng.get("aaa").agent.cl, "testclass@foo.rb"
|
391
|
+
p1.set_agents( agents )
|
392
|
+
p1.info["agents"] = agents
|
393
|
+
assert_equals p1.info["agents"], agents
|
270
394
|
assert_equals agent_mng.get("aaa").agent.properties, {"x"=>50, "y"=>41 }
|
271
395
|
assert_equals agent_mng.get("bbb"), nil
|
272
|
-
assert_equals p1.outputs, { "aaa"=>["out1","out2"] }
|
273
396
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
397
|
+
assert_equals agent_mng.get("aaa").operator.agent_name, "テストエージェント11"
|
398
|
+
|
399
|
+
out1 = agent_mng.output_manager.get( "rmt", "aaa" )
|
400
|
+
assert_equals out1.agent_id, "aaa"
|
401
|
+
assert_equals out1.agent_name, "テストエージェント11"
|
402
|
+
out2 = agent_mng.output_manager.get( "rmt", "bbb" )
|
403
|
+
assert_equals out2.agent_id, "bbb"
|
404
|
+
assert_equals out2.agent_name, "テストエージェント2"
|
405
|
+
|
406
|
+
|
407
|
+
p1.info["trade_enable"] = false
|
408
|
+
p1.trade_enable = false
|
409
|
+
p1.stop
|
410
|
+
Test.destry( @registry)
|
411
|
+
@registry = JIJI::Registry.new(@dir , nil)
|
412
|
+
@registry.plugin_loader.load
|
413
|
+
|
414
|
+
# 保存されたデータから再構築
|
415
|
+
p1 = @registry.rmt_process
|
416
|
+
agent_mng = p1.agent_manager
|
417
|
+
|
418
|
+
p1.load_agents( false )
|
419
|
+
assert_equals p1.agent_manager, agent_mng
|
420
|
+
assert_equals p1.info["agents"], agents
|
421
|
+
assert_equals p1.info["trade_enable"], false
|
422
|
+
|
423
|
+
assert_equals agent_mng.operator.trade_enable, false
|
424
|
+
assert_equals p1.info["agents"], agents
|
290
425
|
assert_equals agent_mng.get("aaa").agent.properties, {"x"=>50, "y"=>41 }
|
291
426
|
assert_equals agent_mng.get("bbb"), nil
|
292
|
-
assert_equals p1.outputs, { "aaa"=>["out1","out2"] }
|
293
427
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
428
|
+
assert_equals agent_mng.get("aaa").operator.agent_name, "テストエージェント11"
|
429
|
+
|
430
|
+
out1 = agent_mng.output_manager.get( "rmt", "aaa" )
|
431
|
+
assert_equals out1.agent_id, "aaa"
|
432
|
+
assert_equals out1.agent_name, "テストエージェント11"
|
433
|
+
out2 = agent_mng.output_manager.get( "rmt", "bbb" )
|
434
|
+
assert_equals out2.agent_id, "bbb"
|
435
|
+
assert_equals out2.agent_name, "テストエージェント2"
|
436
|
+
end
|
437
|
+
|
438
|
+
|
439
|
+
# エージェントの作成でエラーになった場合のテスト
|
440
|
+
def test_error
|
441
|
+
|
442
|
+
agents = [
|
443
|
+
{"id"=>"aaa",
|
444
|
+
"name"=>"テストエージェント1",
|
445
|
+
"class"=>"TestAgent@foo.rb",
|
446
|
+
"class_name" => "TestAgent",
|
447
|
+
"file_name" => "foo.rb",
|
448
|
+
"description" => "説明",
|
449
|
+
"property_def" => {"id"=>"x", "default"=>85 },
|
450
|
+
"properties" => {"x"=>50, "y"=>41 }}
|
451
|
+
]
|
452
|
+
|
453
|
+
pi1 = @registry.process_info( "1" )
|
454
|
+
pi1.props = {
|
455
|
+
"id"=>"pid1",
|
456
|
+
"name"=>"エージェントなし",
|
457
|
+
"start_date"=>0,
|
458
|
+
"end_date"=>100,
|
459
|
+
"agents"=>agents
|
460
|
+
}
|
461
|
+
p1 = @registry.backtest_process(pi1)
|
462
|
+
agent_mng = p1.agent_manager
|
463
|
+
error_registry = Test::RegistryMock.new # エージェントレジストリをモックに差し替え。
|
464
|
+
agent_mng.agent_registry = error_registry
|
465
|
+
|
466
|
+
# 生成時にエラー
|
467
|
+
Test::RegistryMock.set_fail_create {|cl,p| true }
|
300
468
|
begin
|
301
|
-
|
469
|
+
# エラーを無視しないモードで生成 / 例外が発生する
|
470
|
+
p1.load_agents( false )
|
302
471
|
fail
|
303
|
-
rescue
|
472
|
+
rescue RuntimeError
|
304
473
|
end
|
305
|
-
|
474
|
+
assert_equals agent_mng.get("aaa"), nil
|
306
475
|
|
307
|
-
|
308
|
-
|
309
|
-
agent_mng
|
310
|
-
agent_mng.operator = Struct.new(:trade_enable).new(true)
|
311
|
-
agent_mng.conf = CONF
|
312
|
-
agent_mng.conf.set( [:agent,:safe_level], 0)
|
313
|
-
agent_mng.registry = @registry_mock
|
314
|
-
return agent_mng
|
315
|
-
end
|
476
|
+
# エラーを無視するモードで生成 / 例外は発生しない
|
477
|
+
p1.load_agents( true )
|
478
|
+
assert_equals agent_mng.get("aaa"), nil
|
316
479
|
|
317
|
-
class Agent
|
318
|
-
include JIJI::Agent
|
319
480
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
481
|
+
# エージェントの追加時にエラー
|
482
|
+
agents << {"id"=>"bbb",
|
483
|
+
"name"=>"テストエージェント4",
|
484
|
+
"class"=>"TestAgent2@foo.rb",
|
485
|
+
"class_name" => "TestAgent",
|
486
|
+
"file_name" => "foo.rb",
|
487
|
+
"description" => "説明2aaaaaa",
|
488
|
+
"property_def" => {"id"=>"x", "default"=>85 },
|
489
|
+
"properties" => {"x"=>60, "y"=>41 }}
|
490
|
+
result = p1.set_agents(agents)
|
491
|
+
assert_not_nil result["aaa"][:cause]
|
492
|
+
assert_equals result["aaa"][:info], agents[0]
|
493
|
+
assert_equals result["aaa"][:operation], :add
|
494
|
+
assert_not_nil result["bbb"][:cause]
|
495
|
+
assert_equals result["bbb"][:info], agents[1]
|
496
|
+
assert_equals result["bbb"][:operation], :add
|
497
|
+
assert_equals agent_mng.get("aaa"), nil
|
498
|
+
assert_equals agent_mng.get("bbb"), nil
|
324
499
|
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
#
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
500
|
+
Test::RegistryMock.set_fail_create {|cl,p| false }
|
501
|
+
|
502
|
+
# エージェントのプロパティ更新時にエラー
|
503
|
+
Test::Agent.set_fail_propset {|a| a.cl == "TestAgent@foo.rb" }
|
504
|
+
p1.load_agents( false ) # ロードできるようになる。
|
505
|
+
assert_equals agent_mng.get("aaa").agent.cl, "TestAgent@foo.rb"
|
506
|
+
assert_equals agent_mng.get("aaa").agent.properties, {"x"=>50, "y"=>41 }
|
507
|
+
assert_equals agent_mng.get("bbb").agent.cl, "TestAgent2@foo.rb"
|
508
|
+
assert_equals agent_mng.get("bbb").agent.properties, {"x"=>60, "y"=>41 }
|
509
|
+
|
510
|
+
agents[0]["properties"] = {"x"=>80, "y"=>81 }
|
511
|
+
agents[1]["properties"] = {"x"=>80, "y"=>81 }
|
512
|
+
result = p1.set_agents(agents)
|
513
|
+
assert_not_nil result["aaa"][:cause]
|
514
|
+
assert_equals result["aaa"][:info], agents[0]
|
515
|
+
assert_equals result["aaa"][:operation], :update
|
516
|
+
assert_nil result["bbb"]
|
517
|
+
|
518
|
+
#"aaa"のプロパティは更新されていない
|
519
|
+
assert_equals agent_mng.get("aaa").agent.cl, "TestAgent@foo.rb"
|
520
|
+
assert_equals agent_mng.get("aaa").agent.properties, {"x"=>50, "y"=>41 }
|
521
|
+
assert_equals agent_mng.get("bbb").agent.cl, "TestAgent2@foo.rb"
|
522
|
+
assert_equals agent_mng.get("bbb").agent.properties, {"x"=>80, "y"=>81 }
|
523
|
+
Test::Agent.set_fail_propset {|a| false }
|
524
|
+
|
525
|
+
# エージェントの削除時にエラー
|
526
|
+
class << agent_mng
|
527
|
+
def remove( agent_id )
|
528
|
+
raise "test" if agent_id == "aaa"
|
529
|
+
super
|
530
|
+
end
|
335
531
|
end
|
336
|
-
|
532
|
+
|
533
|
+
result = p1.set_agents([])
|
534
|
+
assert_not_nil result["aaa"][:cause]
|
535
|
+
assert_equals result["aaa"][:info], agents[0]
|
536
|
+
assert_equals result["aaa"][:operation], :remove
|
537
|
+
assert_nil result["bbb"]
|
538
|
+
|
539
|
+
#エージェント"aaa"は健在
|
540
|
+
assert_equals agent_mng.get("aaa").agent.cl, "TestAgent@foo.rb"
|
541
|
+
assert_equals agent_mng.get("aaa").agent.properties, {"x"=>50, "y"=>41 }
|
542
|
+
assert_equals agent_mng.get("bbb"), nil
|
543
|
+
|
544
|
+
p1.stop
|
337
545
|
end
|
338
546
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
547
|
+
# エージェントマネージャを再作成する
|
548
|
+
def new_agent_mang( process_id, agent_registory=RegistryMock.new )
|
549
|
+
agent_mng = JIJI::AgentManager.new( process_id, agent_registory, Logger.new(STDOUT))
|
550
|
+
agent_mng.operator = Struct.new(:trade_enable, :agent_name).new(true)
|
551
|
+
agent_mng.conf = CONF
|
552
|
+
agent_mng.conf.set( [:agent,:safe_level], 0)
|
553
|
+
agent_mng.output_manager = JIJI::OutputManager.new( @registry_mock )
|
554
|
+
return agent_mng
|
343
555
|
end
|
344
556
|
|
345
557
|
end
|