rubeus 0.0.6-java → 0.0.7-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/Rakefile +26 -0
  2. data/examples/jdbc_example.rb +5 -24
  3. data/lib/rubeus.jar +0 -0
  4. data/lib/rubeus.rb +18 -2
  5. data/lib/rubeus/component_loader.rb +25 -20
  6. data/lib/rubeus/extensions.rb +44 -4
  7. data/lib/rubeus/extensions/java/awt/dimension.rb +8 -2
  8. data/lib/rubeus/extensions/java/sql/driver_manager.rb +240 -1
  9. data/lib/rubeus/extensions/javax/swing/j_table.rb +7 -23
  10. data/lib/rubeus/extensions/javax/swing/table/default_table_model.rb +7 -0
  11. data/lib/rubeus/extensions/javax/swing/table/readonlyable_table_model.rb +10 -0
  12. data/lib/rubeus/jdbc.rb +5 -0
  13. data/lib/rubeus/swing.rb +9 -6
  14. data/lib/rubeus/verboseable.rb +41 -0
  15. data/rmaven.yml +6 -0
  16. data/test/rubeus/awt/test_attributes.rb +58 -0
  17. data/test/rubeus/awt/test_event.rb +216 -0
  18. data/test/rubeus/awt/test_nestable.rb +92 -0
  19. data/test/rubeus/awt/test_setter.rb +42 -0
  20. data/test/rubeus/extensions/java/awt/test_dimension.rb +67 -0
  21. data/test/rubeus/extensions/java/sql/test_connection.rb +50 -0
  22. data/test/rubeus/extensions/java/sql/test_driver_manager.rb +37 -0
  23. data/test/rubeus/extensions/java/sql/test_result_set.rb +67 -0
  24. data/test/rubeus/extensions/java/sql/test_result_set_meta_data.rb +121 -0
  25. data/test/rubeus/extensions/java/sql/test_statement.rb +43 -0
  26. data/test/rubeus/extensions/javax/swing/table/test_default_table_model.rb +359 -0
  27. data/test/rubeus/extensions/javax/swing/table/test_default_table_model/nhk_words.xml +15 -0
  28. data/test/rubeus/extensions/javax/swing/test_box_layout.rb +56 -0
  29. data/test/rubeus/extensions/javax/swing/test_j_component.rb +30 -0
  30. data/test/rubeus/extensions/javax/swing/test_j_frame.rb +42 -0
  31. data/test/rubeus/extensions/javax/swing/test_j_panel.rb +23 -0
  32. data/test/rubeus/extensions/javax/swing/test_j_scroll_pane.rb +24 -0
  33. data/test/rubeus/extensions/javax/swing/test_j_split_pane.rb +54 -0
  34. data/test/rubeus/extensions/javax/swing/test_j_tabbed_pane.rb +204 -0
  35. data/test/rubeus/extensions/javax/swing/test_j_table.rb +71 -0
  36. data/test/rubeus/extensions/javax/swing/test_j_text_field.rb +48 -0
  37. data/test/rubeus/extensions/javax/swing/test_timer.rb +28 -0
  38. data/test/rubeus/test_extensions.rb +44 -0
  39. data/test/test_all.rb +2 -0
  40. metadata +50 -16
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <nhk-words type = "array">
4
+ <nhk-word>
5
+ <id type = "integer">1</id>
6
+ <expression>ないわ~</expression>
7
+ <created-at type = "datetime">2008-08-13T20:35:00Z</created-at>
8
+ </nhk-word>
9
+ <nhk-word>
10
+ <id type = "integer">2</id>
11
+ <expression>格好いい</expression>
12
+ <created-at type = "datetime">2008-08-13T20:36:00Z</created-at>
13
+ </nhk-word>
14
+ </nhk-words>
15
+
@@ -0,0 +1,56 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'rubeus'
4
+
5
+ # Test for Rubeus::Extensions::Javax::Swing
6
+ class TestBoxLayout < Test::Unit::TestCase
7
+ include Rubeus::Swing
8
+
9
+ # setup method
10
+ def setup
11
+ end
12
+
13
+ # normal pattern with JFrame
14
+ def test_new_normal_jframe
15
+ assert_nothing_raised do
16
+ JFrame.new do |f|
17
+ f.layout = BoxLayout.new(:Y_AXIS)
18
+ end
19
+ end
20
+ end
21
+
22
+ # normal pattern with JPanel
23
+ def test_new_normal_jpanel
24
+ assert_nothing_raised do
25
+ JFrame.new do |f|
26
+ JPanel.new do |p|
27
+ f.layout = BoxLayout.new(:Y_AXIS)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ # new without container
34
+ def test_new_without_container
35
+ assert_raise(ArgumentError) do
36
+ BoxLayout.new(:Y_AXIS)
37
+ end
38
+ end
39
+
40
+ # new with various axis
41
+ def test_new_with_various_axis
42
+ assert_nothing_raised do
43
+ JFrame.new do |f|
44
+ f.layout = BoxLayout.new(:X_AXIS)
45
+ f.layout = BoxLayout.new(:Y_AXIS)
46
+ f.layout = BoxLayout.new(:LINE_AXIS)
47
+ f.layout = BoxLayout.new(:PAGE_AXIS)
48
+
49
+ f.layout = BoxLayout.new(javax.swing.BoxLayout::X_AXIS)
50
+ f.layout = BoxLayout.new(javax.swing.BoxLayout::Y_AXIS)
51
+ f.layout = BoxLayout.new(javax.swing.BoxLayout::LINE_AXIS)
52
+ f.layout = BoxLayout.new(javax.swing.BoxLayout::PAGE_AXIS)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,30 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'rubeus'
4
+
5
+ # Test for Rubeus::Extensions::Javax::Swing
6
+ class TestJComponent < Test::Unit::TestCase
7
+ include Rubeus::Swing
8
+
9
+ # setup method
10
+ def setup
11
+ end
12
+
13
+ # normal pattern
14
+ def test_normal
15
+ assert_nothing_raised do
16
+ JFrame.new do |f|
17
+ btn = JButton.new("Push!")
18
+ btn.set_preferred_size(200, 300)
19
+
20
+ f.set_size(500, 500)
21
+ f.pack
22
+
23
+ assert_equal(200, btn.width)
24
+ assert_equal(300, btn.height)
25
+
26
+ f.dispose
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,42 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'rubeus'
4
+
5
+ # Test for j_frame.rb
6
+ class TestJFrame < Test::Unit::TestCase
7
+ include Rubeus::Swing
8
+
9
+ # setup method
10
+ def setup
11
+ end
12
+
13
+ # normal pattern
14
+ def test_normal
15
+ JFrame.new do |f|
16
+ JPanel.new do |p|
17
+ JButton.new("Push!")
18
+ end
19
+
20
+ assert_equal(400, f.width)
21
+ assert_equal(300, f.height)
22
+ assert_equal(JFrame.const_get(:EXIT_ON_CLOSE), f.default_close_operation)
23
+ end
24
+ end
25
+
26
+ # normal pattern with set_size
27
+ if ENV_JAVA["java.specification.version"] == "1.6"
28
+ def test_normal_with_set_size
29
+ JFrame.new do |f|
30
+ JPanel.new do |p|
31
+ JButton.new("Push!")
32
+ end
33
+
34
+ f.set_size("300 x 400")
35
+
36
+ assert_equal(300, f.width)
37
+ assert_equal(400, f.height)
38
+ assert_equal(JFrame.const_get(:EXIT_ON_CLOSE), f.default_close_operation)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,23 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'rubeus'
4
+
5
+ # Test for Rubeus::Extensions::Javax::Swing
6
+ class TestJPanel < Test::Unit::TestCase
7
+ include Rubeus::Swing
8
+
9
+ # setup method
10
+ def setup
11
+ end
12
+
13
+ # normal pattern
14
+ def test_normal
15
+ assert_nothing_raised do
16
+ JFrame.new do |f|
17
+ JPanel.new do |p|
18
+ JButton.new("Push!")
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'rubeus'
4
+
5
+ # Test for j_scroll_pane.rb
6
+ class TestJScrollPane < Test::Unit::TestCase
7
+ include Rubeus::Swing
8
+
9
+ # setup method
10
+ def setup
11
+ end
12
+
13
+ # normal pattern
14
+ def test_normal
15
+ assert_nothing_raised do
16
+ JFrame.new do |f|
17
+ JScrollPane.new do |p|
18
+ JButton.new("Push!")
19
+ JLabel.new("ラベル")
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,54 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'rubeus'
4
+
5
+ # Test for j_split_pane.rb
6
+ class TestJSplitPane < Test::Unit::TestCase
7
+ include Rubeus::Swing
8
+
9
+ # setup method
10
+ def setup
11
+ end
12
+
13
+ # normal pattern with Symbol
14
+ def test_normal_with_symbol
15
+ assert_nothing_raised do
16
+ JFrame.new do |f|
17
+ JSplitPane.new(:HORIZONTAL_SPLIT) do
18
+ JButton.new("Push!")
19
+ JLabel.new("ラベル")
20
+ end
21
+ end
22
+ end
23
+
24
+ assert_nothing_raised do
25
+ JFrame.new do |f|
26
+ JSplitPane.new(:VERTICAL_SPLIT) do
27
+ JButton.new("Push!")
28
+ JLabel.new("ラベル")
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ # normal pattern with original constructor
35
+ def test_normal_with_original_constructor
36
+ assert_nothing_raised do
37
+ JFrame.new do |f|
38
+ JSplitPane.new(javax.swing.JSplitPane::HORIZONTAL_SPLIT) do
39
+ JButton.new("Push!")
40
+ JLabel.new("ラベル")
41
+ end
42
+ end
43
+ end
44
+
45
+ assert_nothing_raised do
46
+ JFrame.new do |f|
47
+ JSplitPane.new(javax.swing.JSplitPane::VERTICAL_SPLIT) do
48
+ JButton.new("Push!")
49
+ JLabel.new("ラベル")
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,204 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'rubeus'
4
+
5
+ # Test for j_tabbed_pane.rb
6
+ class TestJTabbedPane < Test::Unit::TestCase
7
+ include Rubeus::Swing
8
+
9
+ # setup method
10
+ def setup
11
+ end
12
+
13
+ # test for original constructors
14
+ def test_original_constructors
15
+ assert_nothing_raised do
16
+ JFrame.new do |f|
17
+ JTabbedPane.new do
18
+ JButton.new
19
+ JLabel.new("JTabbedPane test")
20
+ end
21
+ end
22
+ end
23
+
24
+ JFrame.new do |f|
25
+ JTabbedPane.new(javax.swing.JTabbedPane::TOP) do |tp|
26
+ JButton.new
27
+ JLabel.new("JTabbedPane test")
28
+
29
+ assert_equal(javax.swing.JTabbedPane::TOP, tp.get_tab_placement)
30
+ end
31
+ end
32
+
33
+ JFrame.new do |f|
34
+ JTabbedPane.new(javax.swing.JTabbedPane::BOTTOM) do |tp|
35
+ JButton.new
36
+ JLabel.new("JTabbedPane test")
37
+
38
+ assert_equal(javax.swing.JTabbedPane::BOTTOM, tp.get_tab_placement)
39
+ end
40
+ end
41
+
42
+ JFrame.new do |f|
43
+ JTabbedPane.new(javax.swing.JTabbedPane::LEFT) do |tp|
44
+ JButton.new
45
+ JLabel.new("JTabbedPane test")
46
+
47
+ assert_equal(javax.swing.JTabbedPane::LEFT, tp.get_tab_placement)
48
+ end
49
+ end
50
+
51
+ JFrame.new do |f|
52
+ JTabbedPane.new(javax.swing.JTabbedPane::RIGHT) do |tp|
53
+ JButton.new
54
+ JLabel.new("JTabbedPane test")
55
+
56
+ assert_equal(javax.swing.JTabbedPane::RIGHT, tp.get_tab_placement)
57
+ end
58
+ end
59
+
60
+ JFrame.new do |f|
61
+ JTabbedPane.new(javax.swing.JTabbedPane::TOP, javax.swing.JTabbedPane::WRAP_TAB_LAYOUT) do |tp|
62
+ JButton.new
63
+ JLabel.new("JTabbedPane test")
64
+
65
+ assert_equal(javax.swing.JTabbedPane::TOP, tp.get_tab_placement)
66
+ assert_equal(javax.swing.JTabbedPane::WRAP_TAB_LAYOUT, tp.get_tab_layout_policy)
67
+ end
68
+ end
69
+
70
+ JFrame.new do |f|
71
+ JTabbedPane.new(javax.swing.JTabbedPane::BOTTOM, javax.swing.JTabbedPane::SCROLL_TAB_LAYOUT) do |tp|
72
+ JButton.new
73
+ JLabel.new("JTabbedPane test")
74
+
75
+ assert_equal(javax.swing.JTabbedPane::BOTTOM, tp.get_tab_placement)
76
+ assert_equal(javax.swing.JTabbedPane::SCROLL_TAB_LAYOUT, tp.get_tab_layout_policy)
77
+ end
78
+ end
79
+
80
+ JFrame.new do |f|
81
+ JTabbedPane.new(javax.swing.JTabbedPane::LEFT, javax.swing.JTabbedPane::WRAP_TAB_LAYOUT) do |tp|
82
+ JButton.new
83
+ JLabel.new("JTabbedPane test")
84
+
85
+ assert_equal(javax.swing.JTabbedPane::LEFT, tp.get_tab_placement)
86
+ assert_equal(javax.swing.JTabbedPane::WRAP_TAB_LAYOUT, tp.get_tab_layout_policy)
87
+ end
88
+ end
89
+
90
+ JFrame.new do |f|
91
+ JTabbedPane.new(javax.swing.JTabbedPane::RIGHT, javax.swing.JTabbedPane::SCROLL_TAB_LAYOUT) do |tp|
92
+ JButton.new
93
+ JLabel.new("JTabbedPane test")
94
+
95
+ assert_equal(javax.swing.JTabbedPane::RIGHT, tp.get_tab_placement)
96
+ assert_equal(javax.swing.JTabbedPane::SCROLL_TAB_LAYOUT, tp.get_tab_layout_policy)
97
+ end
98
+ end
99
+ end
100
+
101
+ # test for constructors with symbol
102
+ def test_constructors_with_symbol
103
+ JFrame.new do |f|
104
+ JTabbedPane.new(:TOP) do |tp|
105
+ JButton.new
106
+ JLabel.new("JTabbedPane test")
107
+
108
+ assert_equal(javax.swing.JTabbedPane::TOP, tp.get_tab_placement)
109
+ end
110
+ end
111
+
112
+ JFrame.new do |f|
113
+ JTabbedPane.new(:BOTTOM) do |tp|
114
+ JButton.new
115
+ JLabel.new("JTabbedPane test")
116
+
117
+ assert_equal(javax.swing.JTabbedPane::BOTTOM, tp.get_tab_placement)
118
+ end
119
+ end
120
+
121
+ JFrame.new do |f|
122
+ JTabbedPane.new(:LEFT) do |tp|
123
+ JButton.new
124
+ JLabel.new("JTabbedPane test")
125
+
126
+ assert_equal(javax.swing.JTabbedPane::LEFT, tp.get_tab_placement)
127
+ end
128
+ end
129
+
130
+ JFrame.new do |f|
131
+ JTabbedPane.new(:RIGHT) do |tp|
132
+ JButton.new
133
+ JLabel.new("JTabbedPane test")
134
+
135
+ assert_equal(javax.swing.JTabbedPane::RIGHT, tp.get_tab_placement)
136
+ end
137
+ end
138
+
139
+ JFrame.new do |f|
140
+ JTabbedPane.new(:TOP, :WRAP_TAB_LAYOUT) do |tp|
141
+ JButton.new
142
+ JLabel.new("JTabbedPane test")
143
+
144
+ assert_equal(javax.swing.JTabbedPane::TOP, tp.get_tab_placement)
145
+ assert_equal(javax.swing.JTabbedPane::WRAP_TAB_LAYOUT, tp.get_tab_layout_policy)
146
+ end
147
+ end
148
+
149
+ JFrame.new do |f|
150
+ JTabbedPane.new(:BOTTOM, :SCROLL_TAB_LAYOUT) do |tp|
151
+ JButton.new
152
+ JLabel.new("JTabbedPane test")
153
+
154
+ assert_equal(javax.swing.JTabbedPane::BOTTOM, tp.get_tab_placement)
155
+ assert_equal(javax.swing.JTabbedPane::SCROLL_TAB_LAYOUT, tp.get_tab_layout_policy)
156
+ end
157
+ end
158
+
159
+ JFrame.new do |f|
160
+ JTabbedPane.new(:LEFT, :WRAP_TAB_LAYOUT) do |tp|
161
+ JButton.new
162
+ JLabel.new("JTabbedPane test")
163
+
164
+ assert_equal(javax.swing.JTabbedPane::LEFT, tp.get_tab_placement)
165
+ assert_equal(javax.swing.JTabbedPane::WRAP_TAB_LAYOUT, tp.get_tab_layout_policy)
166
+ end
167
+ end
168
+
169
+ JFrame.new do |f|
170
+ JTabbedPane.new(:RIGHT, :SCROLL_TAB_LAYOUT) do |tp|
171
+ JButton.new
172
+ JLabel.new("JTabbedPane test")
173
+
174
+ assert_equal(javax.swing.JTabbedPane::RIGHT, tp.get_tab_placement)
175
+ assert_equal(javax.swing.JTabbedPane::SCROLL_TAB_LAYOUT, tp.get_tab_layout_policy)
176
+ end
177
+ end
178
+ end
179
+
180
+ # test for setter utilities
181
+ def test_setter_utilities
182
+ JFrame.new do |f|
183
+ JTabbedPane.new do |tp|
184
+ JButton.new
185
+ JLabel.new("JTabbedPane test")
186
+
187
+ tp.set_titles(["Title1", "Title2"])
188
+ tp.set_icons([File.join(File.dirname(__FILE__), "..", "..", "..", "..", "..", "examples", "nyanco_viewer", "nekobean_s.png"), ""])
189
+ # tp.set_icons([File.join("..", "..", "..", "..", "..", "examples", "nyanco_viewer", "nekobean_s.png"), ""])
190
+ tp.set_tips(["Tip1", "Tip2"])
191
+
192
+ assert_equal(2, tp.tab_count)
193
+ assert_equal("Title1", tp.get_title_at(0))
194
+ assert_equal("Title2", tp.get_title_at(1))
195
+ assert_equal(32, tp.get_icon_at(0).icon_height)
196
+ assert_equal(32, tp.get_icon_at(0).icon_width)
197
+ assert_nil(tp.get_icon_at(1))
198
+ assert_equal("Tip1", tp.get_tool_tip_text_at(0))
199
+ assert_equal("Tip2", tp.get_tool_tip_text_at(1))
200
+ end
201
+ end
202
+ end
203
+ end
204
+