Class: TestUtils

Inherits:
Object
  • Object
show all
Defined in:
src/main/api_shim/test_utils.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (TestUtils) initialize

A new instance of TestUtils


2
3
4
# File 'src/main/api_shim/test_utils.rb', line 2

def initialize
  @j_tu = org.vertx.java.testframework.TestUtils.new( org.vertx.java.platform.impl.JRubyVerticleFactory.vertx)
end

Class Method Details

+ (Object) buffers_equal(buff1, buff2)



59
60
61
# File 'src/main/api_shim/test_utils.rb', line 59

def TestUtils.buffers_equal(buff1, buff2)
  org.vertx.java.testframework.TestUtils.buffersEqual(buff1._to_java_buffer, buff2._to_java_buffer)
end

+ (Object) gen_buffer(size)



50
51
52
53
# File 'src/main/api_shim/test_utils.rb', line 50

def TestUtils.gen_buffer(size)
  j_buff = org.vertx.java.testframework.TestUtils.generateRandomBuffer(size)
  Vertx::Buffer.new(j_buff)
end

+ (Object) random_unicode_string(size)



55
56
57
# File 'src/main/api_shim/test_utils.rb', line 55

def TestUtils.random_unicode_string(size)
  org.vertx.java.testframework.TestUtils.randomUnicodeString(size)
end

Instance Method Details

- (Object) app_ready



19
20
21
# File 'src/main/api_shim/test_utils.rb', line 19

def app_ready
  @j_tu.appReady
end

- (Object) app_stopped



23
24
25
# File 'src/main/api_shim/test_utils.rb', line 23

def app_stopped
  @j_tu.appStopped
end

- (Object) azzert(result, message = nil)



6
7
8
9
10
11
12
13
14
15
16
17
# File 'src/main/api_shim/test_utils.rb', line 6

def azzert(result, message = nil)
  begin
    if message
      @j_tu.azzert(result, message)
    else
      @j_tu.azzert(result)
    end
  rescue java.lang.RuntimeException
    # Rethrow as a ruby exception so we see nice Ruby backtrace
    raise "Assertion Failed #{message}"
  end
end

- (Object) check_thread



63
64
65
# File 'src/main/api_shim/test_utils.rb', line 63

def check_thread
  @j_tu.checkThread
end

- (Object) register(test_name, &test_handler)



31
32
33
# File 'src/main/api_shim/test_utils.rb', line 31

def register(test_name, &test_handler)
  @j_tu.register(test_name, test_handler)
end

- (Object) register_all(object)



35
36
37
38
39
40
41
42
43
44
# File 'src/main/api_shim/test_utils.rb', line 35

def register_all(object)
  methods = object.methods
  methods.each do |meth|
    if meth.to_s.start_with? 'test_'
      register(meth) {
        object.method(meth).call
      }
    end
  end
end

- (Object) test_complete



27
28
29
# File 'src/main/api_shim/test_utils.rb', line 27

def test_complete()
  @j_tu.testComplete
end

- (Object) unregister_all



46
47
48
# File 'src/main/api_shim/test_utils.rb', line 46

def unregister_all
  @j_tu.unregisterAll
end