Permalink
Browse files

fixing jruby tests for gridfs

  • Loading branch information...
brandonblack committed Nov 21, 2012
1 parent 7eac82b commit eedcf8ee8ce0ac4b0492a2fb0900001af5ec9cd4
Showing with 5 additions and 56 deletions.
  1. +0 −3 lib/mongo.rb
  2. +0 −38 lib/mongo/gridfs/grid_io_fix.rb
  3. +1 −5 tasks/testing.rake
  4. +4 −10 test/functional/write_concern_test.rb
View
@@ -77,7 +77,4 @@ module Constants
require 'mongo/gridfs/grid_ext'
require 'mongo/gridfs/grid'
require 'mongo/gridfs/grid_io'
-if RUBY_PLATFORM =~ /java/
- require 'mongo/gridfs/grid_io_fix'
-end
require 'mongo/gridfs/grid_file_system'
@@ -1,38 +0,0 @@
-# encoding: UTF-8
-
-# --
-# Copyright (C) 2008-2012 10gen Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ++
-
-module Mongo
- class GridIO
-
- # This fixes a comparison issue in JRuby 1.9
- def get_md5
- md5_command = BSON::OrderedHash.new
- md5_command['filemd5'] = @files_id
- md5_command['root'] = @fs_name
- @server_md5 = @files.db.command(md5_command)['md5']
- if @safe
- @client_md5 = @local_md5.hexdigest
- if @local_md5.to_s != @server_md5.to_s
- raise GridMD5Failure, "File on server failed MD5 check"
- end
- else
- @server_md5
- end
- end
- end
-end
View
@@ -28,11 +28,7 @@ namespace :test do
end
end
- if ENV['TEST']
- Rake::Task['test:functional'].invoke
- else
- DEFAULT_TESTS.each { |t| Rake::Task["test:#{t}"].invoke }
- end
+ DEFAULT_TESTS.each { |t| Rake::Task["test:#{t}"].invoke }
Rake::Task['test:cleanup'].invoke
end
@@ -66,43 +66,37 @@ class WriteConcernTest < Test::Unit::TestCase
assert_equal 3, response['n']
end
end
-
+
context "Write concern in gridfs" do
setup do
@db = standard_connection.db(MONGO_TEST_DB)
@grid = Mongo::GridFileSystem.new(@db)
@filename = 'sample'
end
-
+
teardown do
@grid.delete(@filename)
end
should "should acknowledge writes by default using md5" do
-
file = @grid.open(@filename, 'w')
file.write "Hello world!"
file.close
assert_equal file.client_md5, file.server_md5
-
end
-
- should "should allow for unacknowledged writes" do
+ should "should allow for unacknowledged writes" do
file = @grid.open(@filename, 'w', {:w => 0} )
file.write "Hello world!"
file.close
assert_nil file.client_md5, file.server_md5
-
end
-
- should "should support legacy write concern api" do
+ should "should support legacy write concern api" do
file = @grid.open(@filename, 'w', {:safe => false} )
file.write "Hello world!"
file.close
assert_nil file.client_md5, file.server_md5
-
end
end

0 comments on commit eedcf8e

Please sign in to comment.