torquebox-vfs 1.0.0.CR1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. data/lib/gem_hook.rb +18 -0
  2. data/lib/jboss-common-core-2.2.17.GA.jar +0 -0
  3. data/lib/jboss-logging-3.0.0.Beta4.jar +0 -0
  4. data/lib/jboss-logging-spi-2.2.0.CR1.jar +0 -0
  5. data/lib/jboss-logmanager-1.2.0.CR9.jar +0 -0
  6. data/lib/jboss-logmanager-log4j-1.0.0.CR3.jar +0 -0
  7. data/lib/jboss-vfs-3.0.0.GA.jar +0 -0
  8. data/lib/log4j-1.2.14.jar +0 -0
  9. data/lib/org.torquebox.vfs.rb +20 -0
  10. data/lib/torquebox/vfs/debug_filter.rb +37 -0
  11. data/lib/torquebox/vfs/dir.rb +78 -0
  12. data/lib/torquebox/vfs/ext/dir.rb +188 -0
  13. data/lib/torquebox/vfs/ext/file.rb +278 -0
  14. data/lib/torquebox/vfs/ext/file_test.rb +48 -0
  15. data/lib/torquebox/vfs/ext/io.rb +158 -0
  16. data/lib/torquebox/vfs/ext/jdbc.rb +65 -0
  17. data/lib/torquebox/vfs/ext/kernel.rb +30 -0
  18. data/lib/torquebox/vfs/ext/pathname.rb +31 -0
  19. data/lib/torquebox/vfs/ext/tempfile.rb +31 -0
  20. data/lib/torquebox/vfs/ext/vfs.rb +24 -0
  21. data/lib/torquebox/vfs/ext/virtual_file.rb +72 -0
  22. data/lib/torquebox/vfs/file.rb +188 -0
  23. data/lib/torquebox/vfs/glob_filter.rb +46 -0
  24. data/lib/torquebox/vfs/glob_translator.rb +204 -0
  25. data/lib/torquebox/vfs.rb +100 -0
  26. data/lib/torquebox-vfs.jar +0 -0
  27. data/lib/torquebox-vfs.rb +20 -0
  28. data/lib/vfs.rb +20 -0
  29. data/licenses/lgpl-2.1.txt +504 -0
  30. data/spec/dir_spec.rb +259 -0
  31. data/spec/file_spec.rb +451 -0
  32. data/spec/file_test_spec.rb +34 -0
  33. data/spec/io_spec.rb +82 -0
  34. data/spec/jdbc_spec.rb +68 -0
  35. data/spec/pathname_spec.rb +20 -0
  36. data/spec/spec_helper.rb +171 -0
  37. data/spec/vfs_dir_spec.rb +23 -0
  38. data/spec/vfs_spec.rb +36 -0
  39. metadata +121 -0
data/spec/dir_spec.rb ADDED
@@ -0,0 +1,259 @@
1
+
2
+ require 'fileutils'
3
+
4
+ require File.dirname(__FILE__) + '/spec_helper.rb'
5
+
6
+ describe "Dir extensions for VFS" do
7
+
8
+ extend PathHelper
9
+ extend TestDataHelper
10
+
11
+ describe "with vfs urls" do
12
+ it "should allow globbing within archives with explicit vfs" do
13
+ pattern = "#{archive1_vfs_path}/*"
14
+ items = Dir.glob( pattern )
15
+ items.should_not be_empty
16
+ items.should include File.join( "#{archive1_vfs_path}", 'web.xml' )
17
+ items.should include File.join( "#{archive1_vfs_path}", 'lib' )
18
+ end
19
+
20
+ it "should allow globbing within nested archives with explicit vfs" do
21
+ pattern = "#{archive2_vfs_path}/*"
22
+ items = Dir.glob( pattern )
23
+ items.should_not be_empty
24
+ items.should include "#{archive2_vfs_path}/manifest.txt"
25
+ end
26
+
27
+ it "should create new Dirs" do
28
+ lambda {
29
+ Dir.new("#{archive2_vfs_path}")
30
+ }.should_not raise_error
31
+ end
32
+ end
33
+
34
+ [ :absolute, :relative, :vfs ].each do |style|
35
+ describe "with #{style} paths" do
36
+
37
+ case ( style )
38
+ when :relative
39
+ prefix = test_data_base_path( :relative )
40
+ when :absolute
41
+ prefix = test_data_base_path( :absolute )
42
+ when :vfs
43
+ prefix = test_data_base_path( :vfs )
44
+ end
45
+
46
+ it "should ignore dotfiles by default" do
47
+ glob_pattern = "#{prefix}/dotfiles/*"
48
+ items = Dir.glob( glob_pattern )
49
+ items.should_not be_empty
50
+ items.size.should eql(3)
51
+ items.should include( "#{prefix}/dotfiles/one" )
52
+ items.should include( "#{prefix}/dotfiles/three" )
53
+ items.should include( "#{prefix}/dotfiles/foo.txt" )
54
+ end
55
+
56
+ it "should match dotfiles if explicitly asked" do
57
+ items = Dir.glob( "#{prefix}/dotfiles/.*" )
58
+ items.should_not be_empty
59
+ items.size.should eql(2)
60
+ items.should include( "#{prefix}/dotfiles/.two" )
61
+ items.should include( "#{prefix}/dotfiles/.four" )
62
+ end
63
+
64
+ it "should allow globbing without any special globbing characters on normal files" do
65
+ items = Dir.glob( "#{prefix}/home/larry" )
66
+ items.should_not be_empty
67
+ items.should include( "#{prefix}/home/larry" )
68
+ end
69
+
70
+ it "should allow globbing without any special globbing characters on a single normal file" do
71
+ items = Dir.glob( "#{prefix}/home/larry/file1.txt" )
72
+ items.should_not be_empty
73
+ items.should include( "#{prefix}/home/larry/file1.txt" )
74
+ end
75
+
76
+ it "should allow globbing without any special globbing characters for archives" do
77
+ items = Dir.glob( "#{prefix}/home/larry/archive1.jar" )
78
+ items.should_not be_empty
79
+ items.should include( "#{prefix}/home/larry/archive1.jar" )
80
+ end
81
+
82
+ it "should allow globbing without any special globbing characters within archives" do
83
+ items = Dir.glob( "#{prefix}/home/larry/archive1.jar/web.xml" )
84
+ items.should_not be_empty
85
+ items.should include( "#{prefix}/home/larry/archive1.jar/web.xml" )
86
+ end
87
+
88
+ it "should allow globbing without any special globbing characters for nested archives" do
89
+ items = Dir.glob( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar" )
90
+ items.should_not be_empty
91
+ items.should include( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar" )
92
+ end
93
+
94
+ it "should allow globbing without any special globbing characters for within archives" do
95
+ items = Dir.glob( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar/manifest.txt" )
96
+ items.should_not be_empty
97
+ items.should include( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar/manifest.txt" )
98
+ end
99
+
100
+ it "should provide access to entries" do
101
+ path = "#{prefix}/home/larry"
102
+ items = Dir.entries( path )
103
+ items.should_not be_empty
104
+ items.size.should eql( 5 )
105
+ items.should include( "." )
106
+ items.should include( ".." )
107
+ items.should include( "file1.txt" )
108
+ items.should include( "file2.txt" )
109
+ items.should include( "archive1.jar" )
110
+ end
111
+
112
+ it "should provide iteration over its entries" do
113
+ items = []
114
+ Dir.foreach( "#{prefix}/home/larry" ) do |e|
115
+ items << e
116
+ end
117
+
118
+ items.should_not be_empty
119
+ items.size.should eql( 5 )
120
+ items.should include( "." )
121
+ items.should include( ".." )
122
+ items.should include( "file1.txt" )
123
+ items.should include( "file2.txt" )
124
+ items.should include( "archive1.jar" )
125
+ end
126
+
127
+ it "should allow appropriate globbing of normal files" do
128
+ items = Dir.glob( "#{prefix}/home/larry/*" )
129
+ items.should_not be_empty
130
+ items.should include( "#{prefix}/home/larry/file1.txt" )
131
+ items.should include( "#{prefix}/home/larry/file2.txt" )
132
+ items.should include( "#{prefix}/home/larry/archive1.jar" )
133
+ end
134
+
135
+ it "should determine if VFS is needed for archives" do
136
+ items = Dir.glob( "#{@archive1_path}/*" )
137
+ items.should_not be_empty
138
+ end
139
+
140
+ it "should determine if VFS is needed for nested archives" do
141
+ base = "#{prefix}/home/larry/archive1.jar/lib/archive2.jar"
142
+ items = Dir.glob( "#{base}/*" )
143
+ items.should_not be_empty
144
+ items.should include( "#{base}/manifest.txt" )
145
+ end
146
+
147
+ it "should determine if VFS is needed with relative paths" do
148
+ base = "#{prefix}/home/larry/archive1.jar/lib/archive2.jar"
149
+ items = Dir.glob( "#{base}/*" )
150
+ items.should_not be_empty
151
+ items.should include( "#{base}/manifest.txt" )
152
+ end
153
+
154
+ it "should allow character-class matching" do
155
+ items = Dir.glob( "#{prefix}/home/{larry}/file[12].{txt}" )
156
+ items.should_not be_empty
157
+ items.size.should eql 2
158
+ items.should include( "#{prefix}/home/larry/file1.txt" )
159
+ items.should include( "#{prefix}/home/larry/file2.txt" )
160
+ end
161
+
162
+ it "should allow alternation globbing on normal files" do
163
+ items = Dir.glob( "#{prefix}/home/{larry}/file{,1,2}.{txt}" )
164
+ items.should_not be_empty
165
+ items.size.should eql 2
166
+ items.should include( "#{prefix}/home/larry/file1.txt" )
167
+ items.should include( "#{prefix}/home/larry/file2.txt" )
168
+ end
169
+
170
+ it "should allow alternation globbing within archives" do
171
+ items = Dir.glob( "#{prefix}/home/larry/archive1.jar/lib/archive*{.zip,.jar,.ear}" )
172
+ items.should_not be_empty
173
+ items.size.should eql 3
174
+ items.should include( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar" )
175
+ items.should include( "#{prefix}/home/larry/archive1.jar/lib/archive3.ear" )
176
+ items.should include( "#{prefix}/home/larry/archive1.jar/lib/archive4.zip" )
177
+ items.should_not include( "#{prefix}/home/larry/archive1.jar/lib/archive4.txt" )
178
+ end
179
+
180
+ it "should allow alternation globbing with trailing comma" do
181
+ items = Dir.glob( "#{prefix}/home/todd/index{.en,}{.html,}{.erb,.haml,}" )
182
+ items.should_not be_empty
183
+ items.size.should eql 4
184
+ items.should include( "#{prefix}/home/todd/index.html.erb" )
185
+ items.should include( "#{prefix}/home/todd/index.en.html.erb" )
186
+ items.should include( "#{prefix}/home/todd/index.html.haml" )
187
+ items.should include( "#{prefix}/home/todd/index.en.html.haml" )
188
+ end
189
+
190
+ it "should allow alternation globbing with internal globs" do
191
+ items = Dir.glob( "#{prefix}/home/{todd/*,larry/*}{.haml,.txt,.jar}" )
192
+ items.should_not be_empty
193
+ items.should include( "#{prefix}/home/todd/index.html.haml" )
194
+ items.should include( "#{prefix}/home/todd/index.en.html.haml" )
195
+ items.should include( "#{prefix}/home/larry/file1.txt" )
196
+ items.should include( "#{prefix}/home/larry/file2.txt" )
197
+ items.should include( "#{prefix}/home/larry/archive1.jar" )
198
+ end
199
+
200
+ it "should allow for double-star globbing within archives" do
201
+ items = Dir.glob( "#{prefix}/home/larry/archive1.jar/**/*.jar" )
202
+ items.should_not be_empty
203
+ #items.size.should eql 1
204
+ items.should include( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar" )
205
+ items.should include( "#{prefix}/home/larry/archive1.jar/other_lib/subdir/archive6.jar" )
206
+ items.should_not include( "#{prefix}/home/larry/archive1.jar/lib/archive4.txt" )
207
+ end
208
+
209
+ it "should create new Dirs" do
210
+ lambda {
211
+ Dir.new(prefix)
212
+ }.should_not raise_error
213
+ end
214
+
215
+ end
216
+ end
217
+
218
+ describe "mkdir" do
219
+ it "should mkdir inside vfs archive when directory mounted on filesystem" do
220
+ FileUtils.rm_rf "target/mnt"
221
+ File.exists?("target/mnt").should_not be_true # catches a 1.9 issue
222
+ archive = org.jboss.vfs::VFS.child( @archive1_path )
223
+ logical = archive.getChild( "lib" )
224
+ physical = java.io::File.new( "target/mnt" )
225
+ physical.mkdirs
226
+ mount = org.jboss.vfs::VFS.mountReal( physical, logical )
227
+ begin
228
+ lambda {
229
+ Dir.mkdir("#{@archive1_path}/lib/should_mkdir_inside_vfs_archive")
230
+ File.directory?("target/mnt/should_mkdir_inside_vfs_archive").should be_true
231
+ }.should_not raise_error
232
+ ensure
233
+ mount.close
234
+ end
235
+ end
236
+ end
237
+
238
+ describe "chdir" do
239
+ it "should require a block be passed" do
240
+ lambda {
241
+ Dir.chdir("/tmp")
242
+ }.should raise_error
243
+ end
244
+ it "should work for vfs paths" do
245
+ pwd = Dir.pwd
246
+ dir = Dir.chdir( test_data_base_path(:vfs) ) { Dir.pwd }
247
+ dir.should == test_data_base_path(:absolute)
248
+ pwd.should == Dir.pwd
249
+ end
250
+
251
+ xit "should work for home dirs" do
252
+ pwd = Dir.pwd
253
+ dir = Dir.chdir { Dir.pwd }
254
+ dir.downcase.should == ENV['HOME'].downcase
255
+ pwd.should == Dir.pwd
256
+ end
257
+ end
258
+
259
+ end