unageanu-jiji 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +3 -0
- data/bin/jiji +1 -1
- data/html/swf/chart.swf +0 -0
- data/lib/jiji/agent/agent.rb +0 -1
- data/lib/jiji/agent/agent_manager.rb +0 -1
- data/lib/jiji/collector.rb +14 -17
- data/lib/jiji/command.rb +40 -12
- data/lib/jiji/configuration.rb +8 -2
- data/lib/jiji/dao/trade_result_dao.rb +1 -1
- data/lib/jiji/migration/migrator1_1_0.rb +46 -0
- data/lib/jiji/models.rb +1 -5
- data/lib/jiji/operator.rb +12 -30
- data/lib/jiji/plugin/embedded/click_securities_demo_plugin.rb +140 -0
- data/lib/jiji/plugin/embedded/single_click_client.rb +107 -0
- data/lib/jiji/plugin/plugin_loader.rb +53 -0
- data/lib/jiji/plugin/securities_plugin.rb +135 -0
- data/lib/jiji/registry.rb +24 -19
- data/lib/jiji/server.rb +3 -1
- data/lib/jiji/service/rate_service.rb +7 -2
- data/lib/jiji/util/block_to_session.rb +4 -4
- data/lib/jiji/util/util.rb +0 -67
- data/lib/jiji_plugin.rb +6 -0
- data/swf/build.xml +1 -1
- data/swf/chart/fx/chart/Chart.as +6 -4
- data/swf/chart/fx/chart/ctrl/Controller.as +12 -0
- data/swf/chart/fx/chart/model/Model.as +3 -1
- data/swf/chart/fx/chart/ui/RangeInfoWindow.as +1 -1
- data/swf/chart/fx/chart/ui/ScaleSelector.as +6 -17
- data/test/OutputregistryTest/conf/configuration.yaml +3 -0
- data/test/ProcessManagerTest/conf/configuration.yaml +4 -17
- data/test/{test_AgentManager.rb → agent/test_AgentManager.rb} +37 -39
- data/test/{test_AgentRegistry.rb → agent/test_AgentRegistry.rb} +3 -2
- data/test/{test_PeriodicallyAgent.rb → agent/test_PeriodicallyAgent.rb} +7 -6
- data/test/{test_Permitter.rb → agent/test_Permitter.rb} +10 -9
- data/test/all_tests.rb +31 -24
- data/test/{test_RateDao.rb → dao/test_RateDao.rb} +5 -5
- data/test/{test_TradeResultDao.rb → dao/test_TradeResultDao.rb} +12 -11
- data/test/jiji_plugin.rb +7 -0
- data/test/migration/migrator1_1_0test_data/configuration.yaml +11 -0
- data/test/migration/test_Migrator1_1_0.rb +56 -0
- data/test/{test_SingleClickClient.rb → plugin/embedded/test_SingleClickClient.rb} +44 -14
- data/test/plugin/error_test/jiji_plugin.rb +2 -0
- data/test/plugin/test/foo_plugin.rb +1 -0
- data/test/plugin/test/jiji_plugin.rb +2 -0
- data/test/plugin/test_Loader.rb +33 -0
- data/test/plugin/test_gem/a/jiji_plugin_test_gem_a-1.0.0.gem +0 -0
- data/test/plugin/test_gem/a/jiji_plugin_test_gem_a.gemspec +10 -0
- data/test/plugin/test_gem/a/lib/jiji_plugin.rb +2 -0
- data/test/plugin/test_gem/a/lib/jiji_plugin_test.rb +6 -0
- data/test/plugin/test_gem/b/jiji_plugin_test_gem_b-1.0.0.gem +0 -0
- data/test/plugin/test_gem/b/jiji_plugin_test_gem_b.gemspec +9 -0
- data/test/plugin/test_gem/b/lib/jiji_plugin.rb +2 -0
- data/test/test_BackTestCollector.rb +12 -20
- data/test/test_Collector.rb +16 -32
- data/test/test_Configuration.rb +3 -3
- data/test/test_Operator.rb +9 -9
- data/test/test_Output.rb +2 -3
- data/test/test_Output_registry.rb +9 -9
- data/test/test_Process.rb +6 -6
- data/test/test_ProcessManager.rb +11 -9
- data/test/test_utils.rb +49 -0
- data/test/{test_BlockToSession.rb → util/test_BlockToSession.rb} +57 -9
- data/test/{test_CSV.rb → util/test_CSV.rb} +5 -5
- data/test/{test_SynchronizeInterceptor.rb → util/test_SynchronizeInterceptor.rb} +5 -3
- metadata +59 -26
- data/lib/jiji/single_click_client.rb +0 -95
- data/test/test_configuration.yaml +0 -16
- data/test/testutils.rb +0 -37
@@ -1,21 +1,22 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
$: << "
|
3
|
+
$: << "../../lib"
|
4
|
+
$: << "../"
|
4
5
|
|
5
|
-
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require 'rubygems'
|
7
|
+
require 'runit/testcase'
|
8
|
+
require 'runit/cui/testrunner'
|
8
9
|
require 'jiji/agent/agent'
|
9
10
|
require 'jiji/agent/agent_manager'
|
10
11
|
require 'jiji/agent/agent_registry'
|
11
12
|
require 'jiji/agent/permitter'
|
12
13
|
require 'jiji/agent/util'
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
14
|
+
require 'jiji/configuration'
|
15
|
+
require 'jiji/collector'
|
16
|
+
require 'jiji/dao/trade_result_dao'
|
17
|
+
require 'fileutils'
|
18
|
+
require 'test_utils'
|
19
|
+
require 'logger'
|
19
20
|
|
20
21
|
# AgentManager のテスト
|
21
22
|
class AgentManagerTest < RUNIT::TestCase
|
@@ -33,12 +34,11 @@ class AgentManagerTest < RUNIT::TestCase
|
|
33
34
|
@permitter = JIJI::Permitter.new( 5, 0 )
|
34
35
|
logger = Logger.new STDOUT
|
35
36
|
logger = @permitter.proxy( logger, [/^(info|debug|warn|error|fatal)$/] )
|
36
|
-
|
37
|
-
|
37
|
+
|
38
38
|
@registry_mock = Object.new
|
39
39
|
class << @registry_mock
|
40
40
|
def output( agent_name, dir )
|
41
|
-
output = JIJI::Output.new( agent_name, "#{dir}/out" )
|
41
|
+
output = JIJI::Output.new( agent_name, "#{@dir}/#{dir}/out" )
|
42
42
|
output = @permitter.proxy( output, [/^(get|each|put|<<)$/], [/^get$/] )
|
43
43
|
return output
|
44
44
|
end
|
@@ -48,21 +48,19 @@ class AgentManagerTest < RUNIT::TestCase
|
|
48
48
|
end
|
49
49
|
@registry_mock.permitter = @permitter
|
50
50
|
|
51
|
-
|
51
|
+
trade_result_dao = JIJI::Dao::TradeResultDao.new( "#{@dir}/trade_result" )
|
52
|
+
operator = JIJI::Operator.new( trade_result_dao )
|
52
53
|
operator.conf = CONF
|
53
54
|
operator = @permitter.proxy( operator, [/^(sell|buy|commit)$/],[/^(sell|buy)$/])
|
54
|
-
|
55
|
-
|
55
|
+
|
56
56
|
@m = JIJI::AgentManager.new( "test_agentManager", @registry, logger)
|
57
57
|
@m.operator = operator
|
58
58
|
@m.conf = CONF
|
59
59
|
@m.trade_result_dao = trade_result_dao
|
60
|
-
@m.client = @client
|
61
60
|
@m.registry = @registry_mock
|
62
61
|
end
|
63
62
|
|
64
63
|
def teardown
|
65
|
-
@client.close
|
66
64
|
@permitter.close
|
67
65
|
FileUtils.rm_rf @dir
|
68
66
|
end
|
@@ -86,15 +84,15 @@ class AgentManagerTest < RUNIT::TestCase
|
|
86
84
|
agent1 = @registry.create( "Foo@foo.rb" )
|
87
85
|
agent2 = @registry.create( "Foo@foo.rb" )
|
88
86
|
|
89
|
-
@m.add( "
|
90
|
-
@m.add( "
|
87
|
+
@m.add( "test", agent1 )
|
88
|
+
@m.add( "test2", agent2 )
|
91
89
|
|
92
90
|
# 追加直後はactive
|
93
|
-
assert_equals @m.on?( "
|
94
|
-
assert_equals @m.on?( "
|
91
|
+
assert_equals @m.on?( "test" ), true
|
92
|
+
assert_equals @m.on?( "test2" ), true
|
95
93
|
|
96
94
|
pair_infos = {
|
97
|
-
|
95
|
+
:EURJPY => Info.new( 10000 )
|
98
96
|
}
|
99
97
|
@m.next_rates( JIJI::Rates.new( pair_infos, {
|
100
98
|
:EURJPY => Rate.new( 100.0,100.05,-200,200,100 )
|
@@ -110,9 +108,9 @@ class AgentManagerTest < RUNIT::TestCase
|
|
110
108
|
}
|
111
109
|
|
112
110
|
# agent1をoff
|
113
|
-
@m.off( "
|
114
|
-
assert_equals @m.on?( "
|
115
|
-
assert_equals @m.on?( "
|
111
|
+
@m.off( "test" )
|
112
|
+
assert_equals @m.on?( "test" ), false
|
113
|
+
assert_equals @m.on?( "test2" ), true
|
116
114
|
@m.next_rates( JIJI::Rates.new( pair_infos, {
|
117
115
|
:EURJPY => Rate.new( 100.0,100.05,-200,200,100 )
|
118
116
|
}))
|
@@ -124,9 +122,9 @@ class AgentManagerTest < RUNIT::TestCase
|
|
124
122
|
}
|
125
123
|
|
126
124
|
# agent1を再度onにする
|
127
|
-
@m.on( "
|
128
|
-
assert_equals @m.on?( "
|
129
|
-
assert_equals @m.on?( "
|
125
|
+
@m.on( "test" )
|
126
|
+
assert_equals @m.on?( "test" ), true
|
127
|
+
assert_equals @m.on?( "test2" ), true
|
130
128
|
@m.next_rates( JIJI::Rates.new( pair_infos, {
|
131
129
|
:EURJPY => Rate.new( 100.0,100.05,-200,200,100 )
|
132
130
|
}))
|
@@ -138,8 +136,8 @@ class AgentManagerTest < RUNIT::TestCase
|
|
138
136
|
}
|
139
137
|
|
140
138
|
# agent1を削除
|
141
|
-
@m.remove( "
|
142
|
-
assert_equals @m.on?( "
|
139
|
+
@m.remove( "test" )
|
140
|
+
assert_equals @m.on?( "test2" ), true
|
143
141
|
@m.next_rates( JIJI::Rates.new( pair_infos, {
|
144
142
|
:EURJPY => Rate.new( 100.0,100.05,-200,200,100 )
|
145
143
|
}))
|
@@ -180,9 +178,9 @@ class AgentManagerTest < RUNIT::TestCase
|
|
180
178
|
end
|
181
179
|
|
182
180
|
# エージェントの2重登録
|
183
|
-
@m.add( "
|
181
|
+
@m.add( "test", TestAgent.new.taint )
|
184
182
|
begin
|
185
|
-
@m.add( "
|
183
|
+
@m.add( "test", TestAgent.new.taint )
|
186
184
|
fail
|
187
185
|
rescue JIJI::UserError
|
188
186
|
assert_equals JIJI::ERROR_ALREADY_EXIST, $!.code
|
@@ -216,10 +214,10 @@ class AgentManagerTest < RUNIT::TestCase
|
|
216
214
|
logger.error IOError.new
|
217
215
|
logger.debug "test"
|
218
216
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
217
|
+
p1 = operator.sell(1)
|
218
|
+
p1.commit
|
219
|
+
p2 = operator.buy(1)
|
220
|
+
p2.commit
|
223
221
|
end
|
224
222
|
attr :log, true
|
225
223
|
end
|
@@ -227,10 +225,10 @@ class AgentManagerTest < RUNIT::TestCase
|
|
227
225
|
@registry.add_file( "foo.rb", str )
|
228
226
|
|
229
227
|
agent = @registry.create( "Foo@foo.rb" )
|
230
|
-
@m.add( "
|
228
|
+
@m.add( "test", agent )
|
231
229
|
|
232
230
|
pair_infos = {
|
233
|
-
|
231
|
+
:EURJPY => Info.new( 10000 )
|
234
232
|
}
|
235
233
|
2.times {
|
236
234
|
@m.next_rates( JIJI::Rates.new( pair_infos, {
|
@@ -1,16 +1,17 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
$: << "
|
3
|
+
$: << "../../lib"
|
4
|
+
$: << "../"
|
4
5
|
|
5
|
-
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require 'rubygems'
|
7
|
+
require 'runit/testcase'
|
8
|
+
require 'runit/cui/testrunner'
|
8
9
|
require 'jiji/agent/agent'
|
9
10
|
require 'jiji/agent/agent_manager'
|
10
11
|
require 'jiji/agent/agent_registry'
|
11
12
|
require 'jiji/agent/permitter'
|
12
13
|
require 'jiji/agent/util'
|
13
|
-
require
|
14
|
+
require 'jiji/collector'
|
14
15
|
|
15
16
|
# PeriodicallyAgent のテスト
|
16
17
|
class PeriodicallyAgentTest < RUNIT::TestCase
|
@@ -27,7 +28,7 @@ class PeriodicallyAgentTest < RUNIT::TestCase
|
|
27
28
|
agent = TestAgent.new( 2 )
|
28
29
|
assert_equals agent.log, []
|
29
30
|
|
30
|
-
pair_infos = {
|
31
|
+
pair_infos = {:USDJPY=>"info"}
|
31
32
|
|
32
33
|
agent.next_rates( JIJI::Rates.new( pair_infos, {
|
33
34
|
:USDJPY => R.new( 100.0, 100.05, -200, 222 ),
|
@@ -1,20 +1,21 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
$: << "
|
3
|
+
$: << "../../lib"
|
4
|
+
$: << "../"
|
4
5
|
|
5
|
-
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require 'rubygems'
|
7
|
+
require 'runit/testcase'
|
8
|
+
require 'runit/cui/testrunner'
|
8
9
|
require 'jiji/agent/agent'
|
9
10
|
require 'jiji/agent/agent_manager'
|
10
11
|
require 'jiji/agent/agent_registry'
|
11
12
|
require 'jiji/agent/permitter'
|
12
13
|
require 'jiji/agent/util'
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
14
|
+
require 'jiji/configuration'
|
15
|
+
require 'jiji/collector'
|
16
|
+
require 'fileutils'
|
17
|
+
require 'test_utils'
|
18
|
+
require 'logger'
|
18
19
|
|
19
20
|
# Permitter のテスト
|
20
21
|
class PermitterTest < RUNIT::TestCase
|
data/test/all_tests.rb
CHANGED
@@ -2,28 +2,35 @@
|
|
2
2
|
|
3
3
|
$: << "../lib"
|
4
4
|
|
5
|
+
require 'rubygems'
|
6
|
+
require 'runit/testcase'
|
7
|
+
require 'runit/cui/testrunner'
|
8
|
+
|
9
|
+
require 'test_ProcessManager'
|
10
|
+
require 'test_BackTestCollector'
|
11
|
+
require 'test_Collector'
|
12
|
+
require 'test_Configuration'
|
13
|
+
require 'test_Operator'
|
14
|
+
require 'test_Output'
|
15
|
+
require 'test_Output_registry'
|
16
|
+
require 'test_Process'
|
17
|
+
|
18
|
+
require 'util/test_BlockToSession'
|
19
|
+
require 'util/test_CSV'
|
20
|
+
require 'util/test_SynchronizeInterceptor'
|
21
|
+
|
22
|
+
require 'dao/test_RateDao'
|
23
|
+
require 'dao/test_TradeResultDao'
|
24
|
+
|
25
|
+
require 'agent/test_AgentManager'
|
26
|
+
require 'agent/test_AgentRegistry'
|
27
|
+
require 'agent/test_PeriodicallyAgent'
|
28
|
+
require 'agent/test_Permitter'
|
29
|
+
|
30
|
+
require 'migration/test_Migrator'
|
31
|
+
require 'migration/test_Migrator1_0_3'
|
32
|
+
require 'migration/test_Migrator1_1_0'
|
33
|
+
|
34
|
+
require 'plugin/test_Loader'
|
35
|
+
require 'plugin/embedded/test_SingleClickClient'
|
5
36
|
|
6
|
-
require "runit/testcase"
|
7
|
-
require "runit/cui/testrunner"
|
8
|
-
|
9
|
-
require "test_BackTestCollector"
|
10
|
-
require "test_Collector"
|
11
|
-
require "test_SingleClickClient"
|
12
|
-
require "test_BlockToSession"
|
13
|
-
require "test_AgentManager"
|
14
|
-
|
15
|
-
require "test_AgentRegistry"
|
16
|
-
require "test_Configuration"
|
17
|
-
require "test_CSV"
|
18
|
-
require "test_Operator"
|
19
|
-
require "test_Output"
|
20
|
-
require "test_Output_registry"
|
21
|
-
require "test_PeriodicallyAgent"
|
22
|
-
require "test_Process"
|
23
|
-
require "test_ProcessManager"
|
24
|
-
require "test_RateDao"
|
25
|
-
require "test_Permitter"
|
26
|
-
require "test_TradeResultDao"
|
27
|
-
|
28
|
-
require "migration/test_Migrator"
|
29
|
-
require "migration/test_Migrator1_0_3"
|
@@ -1,15 +1,15 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
$: << "
|
3
|
+
$: << "../../lib"
|
4
|
+
$: << "../"
|
4
5
|
|
5
|
-
|
6
|
-
require
|
7
|
-
require "runit/cui/testrunner"
|
6
|
+
require 'runit/testcase'
|
7
|
+
require 'runit/cui/testrunner'
|
8
8
|
require 'jiji/dao/rate_dao'
|
9
9
|
require 'fileutils'
|
10
10
|
require 'rubygems'
|
11
11
|
require 'clickclient'
|
12
|
-
require
|
12
|
+
require 'test_utils'
|
13
13
|
|
14
14
|
class RateDaoTest < RUNIT::TestCase
|
15
15
|
|
@@ -1,15 +1,16 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
$: << "
|
3
|
+
$: << "../../lib"
|
4
|
+
$: << "../"
|
4
5
|
|
5
|
-
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require 'rubygems'
|
7
|
+
require 'runit/testcase'
|
8
|
+
require 'runit/cui/testrunner'
|
8
9
|
require 'jiji/dao/trade_result_dao'
|
9
10
|
require 'jiji/operator'
|
10
11
|
require 'fileutils'
|
11
12
|
require 'rubygems'
|
12
|
-
require
|
13
|
+
require 'test_utils'
|
13
14
|
|
14
15
|
class TradeResultDaoTest < RUNIT::TestCase
|
15
16
|
|
@@ -29,8 +30,8 @@ class TradeResultDaoTest < RUNIT::TestCase
|
|
29
30
|
def test_basic
|
30
31
|
|
31
32
|
pair_infos = {
|
32
|
-
|
33
|
-
|
33
|
+
:USDJPY => Info.new( 10000 ),
|
34
|
+
:AUDUSD => Info.new( 10000 )
|
34
35
|
}
|
35
36
|
|
36
37
|
op = JIJI::Operator.new @dao
|
@@ -68,7 +69,6 @@ class TradeResultDaoTest < RUNIT::TestCase
|
|
68
69
|
}, Time.local(2008,8,7,0,1,1) ))
|
69
70
|
|
70
71
|
p1_props = {
|
71
|
-
:open_interest_no=>"",
|
72
72
|
:count=>1,
|
73
73
|
:rate=>101.08,
|
74
74
|
:state=>1,
|
@@ -80,6 +80,7 @@ class TradeResultDaoTest < RUNIT::TestCase
|
|
80
80
|
:price=>1010800.0,
|
81
81
|
:trader=>"a",
|
82
82
|
:position_id=>p1.position_id,
|
83
|
+
:raw_position_id=>nil,
|
83
84
|
:profit_or_loss=>-500.0,
|
84
85
|
:swap=>0
|
85
86
|
}
|
@@ -390,8 +391,8 @@ class TradeResultDaoTest < RUNIT::TestCase
|
|
390
391
|
# flush のテスト。
|
391
392
|
def test_flush()
|
392
393
|
pair_infos = {
|
393
|
-
|
394
|
-
|
394
|
+
:USDJPY => Info.new( 10000 ),
|
395
|
+
:AUDUSD => Info.new( 10000 )
|
395
396
|
}
|
396
397
|
|
397
398
|
op = JIJI::Operator.new @dao
|
@@ -428,7 +429,6 @@ class TradeResultDaoTest < RUNIT::TestCase
|
|
428
429
|
|
429
430
|
# 1mは経過していないので、バッファ内のデータは保存されていない。
|
430
431
|
p1_props = {
|
431
|
-
:open_interest_no=>"",
|
432
432
|
:count=>1,
|
433
433
|
:rate=>101.08,
|
434
434
|
:state=>1,
|
@@ -440,6 +440,7 @@ class TradeResultDaoTest < RUNIT::TestCase
|
|
440
440
|
:price=>1010800.0,
|
441
441
|
:trader=>"a",
|
442
442
|
:position_id=>p1.position_id,
|
443
|
+
:raw_position_id=>nil,
|
443
444
|
:profit_or_loss=>-500.0,
|
444
445
|
:swap=>0
|
445
446
|
}
|
data/test/jiji_plugin.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$: << "../../lib"
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'runit/testcase'
|
7
|
+
require 'runit/cui/testrunner'
|
8
|
+
require 'fileutils'
|
9
|
+
require 'jiji/configuration'
|
10
|
+
require 'jiji/migration/migrator1_1_0'
|
11
|
+
|
12
|
+
# Migrator1_1_0 のテスト
|
13
|
+
class Migrator1_1_0Test < RUNIT::TestCase
|
14
|
+
|
15
|
+
def setup
|
16
|
+
@dir = File.dirname(__FILE__) + "/migrator1_1_0_test"
|
17
|
+
FileUtils.rm_rf @dir
|
18
|
+
FileUtils.mkdir_p "#{@dir}/conf"
|
19
|
+
|
20
|
+
@registry = {}
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
FileUtils.rm_rf @dir
|
25
|
+
end
|
26
|
+
|
27
|
+
# 実際のデータを変更するテスト
|
28
|
+
def test_real_data
|
29
|
+
FileUtils.cp_r File.dirname(__FILE__) + "/migrator1_1_0test_data/configuration.yaml", "#{@dir}/conf"
|
30
|
+
|
31
|
+
assert_equals( YAML.load_file("#{@dir}/conf/configuration.yaml"), {
|
32
|
+
"server"=>{ "port"=>8080 },
|
33
|
+
"securities"=>{ "account"=>{
|
34
|
+
"user"=>"foo",
|
35
|
+
"password"=>"xxxx"
|
36
|
+
}},
|
37
|
+
"foo"=>{"var"=>"aaa"}
|
38
|
+
})
|
39
|
+
|
40
|
+
# データ移行
|
41
|
+
m = JIJI::Migration::Migrator1_1_0.new
|
42
|
+
m.migrate( Struct.new( :base_dir, :conf ).new( @dir, JIJI::Configuration.new ) )
|
43
|
+
|
44
|
+
assert_equals( YAML.load_file("#{@dir}/conf/configuration.yaml"), {
|
45
|
+
:server=>{ :port=>8080 },
|
46
|
+
:securities=>{
|
47
|
+
:type=>:click_securities_demo,
|
48
|
+
:user=>"foo",
|
49
|
+
:password=>"xxxx"
|
50
|
+
},
|
51
|
+
:foo=>{:var=>"aaa"}
|
52
|
+
})
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
@@ -1,13 +1,13 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
$: << "
|
4
|
-
|
3
|
+
$: << "../../"
|
4
|
+
$: << "../../../lib"
|
5
5
|
|
6
6
|
require "runit/testcase"
|
7
7
|
require "runit/cui/testrunner"
|
8
8
|
require "jiji/configuration"
|
9
|
-
require
|
10
|
-
require "
|
9
|
+
require 'jiji/plugin/embedded/single_click_client'
|
10
|
+
require "test_utils"
|
11
11
|
require 'logger'
|
12
12
|
require 'csv'
|
13
13
|
|
@@ -19,7 +19,10 @@ class SingleClickClientTest < RUNIT::TestCase
|
|
19
19
|
|
20
20
|
def setup
|
21
21
|
l = Logger.new STDOUT
|
22
|
-
@c = JIJI::SingleClickClient.new(
|
22
|
+
@c = JIJI::Plugin::SingleClickClient.new( {
|
23
|
+
:user=>Test::Constants::USER,
|
24
|
+
:password=>Test::Constants::PASSWORD
|
25
|
+
}, l )
|
23
26
|
end
|
24
27
|
|
25
28
|
def teardown
|
@@ -40,7 +43,7 @@ class SingleClickClientTest < RUNIT::TestCase
|
|
40
43
|
def test_request_error
|
41
44
|
begin
|
42
45
|
@c.request {|fx|
|
43
|
-
fx.list_orders( 1000 ) #
|
46
|
+
fx.list_orders( 1000 ) # 通貨ペアコードが不正。
|
44
47
|
}
|
45
48
|
fail
|
46
49
|
rescue RuntimeError
|
@@ -81,9 +84,12 @@ class SingleClickClientTest < RUNIT::TestCase
|
|
81
84
|
l = Logger.new STDOUT
|
82
85
|
|
83
86
|
# 接続先が不正
|
84
|
-
conf =
|
85
|
-
|
86
|
-
|
87
|
+
conf = {
|
88
|
+
:user=>Test::Constants::USER,
|
89
|
+
:password=>Test::Constants::PASSWORD,
|
90
|
+
:host=>"notfound.com"
|
91
|
+
}
|
92
|
+
c = JIJI::Plugin::SingleClickClient.new( conf, l ) # エラーは発生しない。
|
87
93
|
|
88
94
|
# 接続失敗状態でリクエストを送付すると、常に接続失敗の例外が返される。
|
89
95
|
3.times {
|
@@ -94,12 +100,19 @@ class SingleClickClientTest < RUNIT::TestCase
|
|
94
100
|
assert_equals JIJI::ERROR_NOT_CONNECTED, $!.code
|
95
101
|
end
|
96
102
|
}
|
103
|
+
# 接続できるようになると復帰する。
|
104
|
+
conf[:host] = nil
|
105
|
+
3.times {
|
106
|
+
c.request {|fx| fx.list_currency_pairs }
|
107
|
+
}
|
97
108
|
c.close
|
98
|
-
|
109
|
+
|
99
110
|
# アカウントが不正
|
100
|
-
|
101
|
-
|
102
|
-
|
111
|
+
c = JIJI::Plugin::SingleClickClient.new( {
|
112
|
+
:user=>"illegal",
|
113
|
+
:password=>Test::Constants::PASSWORD
|
114
|
+
}, l )
|
115
|
+
|
103
116
|
# 接続失敗状態でリクエストを送付すると、常に接続失敗の例外が返される。
|
104
117
|
3.times {
|
105
118
|
begin
|
@@ -110,6 +123,23 @@ class SingleClickClientTest < RUNIT::TestCase
|
|
110
123
|
end
|
111
124
|
}
|
112
125
|
c.close
|
113
|
-
|
126
|
+
|
127
|
+
# パスワードが不正
|
128
|
+
c = JIJI::Plugin::SingleClickClient.new( {
|
129
|
+
:user=>Test::Constants::USER,
|
130
|
+
:password=>"illegal"
|
131
|
+
}, l )
|
132
|
+
|
133
|
+
# 接続失敗状態でリクエストを送付すると、常に接続失敗の例外が返される。
|
134
|
+
3.times {
|
135
|
+
begin
|
136
|
+
c.request {|fx| fx.list_currency_pairs }
|
137
|
+
fail
|
138
|
+
rescue JIJI::FatalError
|
139
|
+
assert_equals JIJI::ERROR_NOT_CONNECTED, $!.code
|
140
|
+
end
|
141
|
+
}
|
142
|
+
c.close
|
143
|
+
|
114
144
|
end
|
115
145
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
JIJI::Plugin.register( :test, "foo" )
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$: << "../../lib"
|
4
|
+
$: << File.dirname(__FILE__) + "/test"
|
5
|
+
$: << File.dirname(__FILE__) + "/error_test"
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'runit/testcase'
|
9
|
+
require 'runit/cui/testrunner'
|
10
|
+
require 'logger'
|
11
|
+
require 'jiji/plugin/plugin_loader'
|
12
|
+
|
13
|
+
# Loader のテスト
|
14
|
+
class LoaderTest < RUNIT::TestCase
|
15
|
+
|
16
|
+
# 基本動作のテスト
|
17
|
+
def test_basic
|
18
|
+
# ロード前は空
|
19
|
+
assert_equals [], JIJI::Plugin.get(:test)
|
20
|
+
|
21
|
+
# ロード
|
22
|
+
loader = JIJI::Plugin::Loader.new
|
23
|
+
loader.server_logger = Logger.new STDOUT
|
24
|
+
loader.load
|
25
|
+
|
26
|
+
# ./test以下の"jiji_plugin.rb"がロードされる。
|
27
|
+
assert_equals ["test"], JIJI::Plugin.get(:test)
|
28
|
+
|
29
|
+
# テスト用のplugin gemがインストールされていれば aaa,bbb が表示される。
|
30
|
+
puts JIJI::Plugin.get(:test_gem)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
Binary file
|
Binary file
|