Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 43 lines (33 sloc) 0.96 kb
5e87f87 @mperham Add simple eventmachine test
mperham authored
1 require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
98bc8b0 Disable eventmachine_test on 0.6.
Robert Jackson authored
3 if RUBY_VERSION < '1.9' || CASSANDRA_VERSION == '0.6'
5e87f87 @mperham Add simple eventmachine test
mperham authored
4 puts "Skipping EventMachine test"
5 else
6
98bc8b0 Disable eventmachine_test on 0.6.
Robert Jackson authored
7 require 'thrift_client/event_machine'
5e87f87 @mperham Add simple eventmachine test
mperham authored
8
98bc8b0 Disable eventmachine_test on 0.6.
Robert Jackson authored
9 class EventmachineTest < Test::Unit::TestCase
5e87f87 @mperham Add simple eventmachine test
mperham authored
10
98bc8b0 Disable eventmachine_test on 0.6.
Robert Jackson authored
11 def test_twitter
12 @twitter = Cassandra.new('Twitter', "127.0.0.1:9160", :retries => 2, :exception_classes => [], :transport => Thrift::EventMachineTransport, :transport_wrapper => nil)
13 @twitter.clear_keyspace!
5e87f87 @mperham Add simple eventmachine test
mperham authored
14 end
98bc8b0 Disable eventmachine_test on 0.6.
Robert Jackson authored
15
16 private
17
18 def em_test(name)
19 EM.run do
20 Fiber.new do
21 begin
22 send("raw_#{name}".to_sym)
23 ensure
24 EM.stop
25 end
26 end.resume
5e87f87 @mperham Add simple eventmachine test
mperham authored
27 end
28 end
98bc8b0 Disable eventmachine_test on 0.6.
Robert Jackson authored
29
30 def self.wrap_tests
31 self.public_instance_methods.select { |m| m =~ /^test_/ }.each do |meth|
32 alias_method :"raw_#{meth}", meth
33 define_method(meth) do
34 em_test(meth)
35 end
36 end
37 end
38
39 wrap_tests
40
5e87f87 @mperham Add simple eventmachine test
mperham authored
41 end
42 end
Something went wrong with that request. Please try again.