Sha256: 43ba012733653489e394914d28739bc4d20554e0e1a2b07035f23b72316740d2

Contents?: true

Size: 1.69 KB

Versions: 4

Compression:

Stored size: 1.69 KB

Contents

require 'test/unit'
require 'voruby/plastic/plastic'

include VORuby::Plastic

class BasicAppTest < Test::Unit::TestCase
  def setup
    @app = Application::Base.new('test_xmlrpc_app1')
  end
  
  def test_app_registration
    puts "Hub ID is: #{@app.hub_id}"
    
    puts "Registering app..."
    @app.register()
    puts "\tID is: #{@app.app_id}"
    
    puts "Listing registered apps:"
    @app.get_registered_ids().each do |uri|
      reg_line = "\t#{uri}"
      app_name = @app.get_name(uri)
      reg_line << " [#{app_name}]" if name
      reg_line << " (hub)" if uri == @app.hub_id
      puts reg_line
      
      puts "\t\tUnderstood messages:"
      @app.get_understood_messages(uri).each do |message|
        puts "\t\t\t#{message}"
      end
    end
    
    puts "Core message inventory:"
    Messages::CORE_MESSAGES.each do |msg|
      puts "\t#{msg}"
      @app.get_message_registered_ids(msg).each do |app_id|
        puts "\t\t#{app_id}"
      end
    end
  end
  
  def test_app_requests
    puts "Asking registered apps to..."
    
    puts "\t#{Messages::TEST_ECHO}"
    @app.request(Messages::TEST_ECHO, 'Hello, world!').each do |app_id, response|
      puts "\t\t#{app_id} -> #{response}"
    end
    
    Messages::CORE_MESSAGES.delete_if{ |msg|
      msg == Messages::TEST_ECHO ||
      msg == Messages::HUB_EVENT_APPLICATION_REGISTERED ||
      msg == Messages::HUB_EVENT_APPLICATION_UNREGISTERED ||
      msg == Messages::HUB_EVENT_HUB_STOPPING
    }.each do |msg|
      puts "\t#{msg}"
      @app.request(msg).each do |app_id, response|
        puts "\t\t#{app_id} -> #{response}"
      end
    end
  end
  
  def teardown
    puts "Unregistering app #{@app.app_id}..."
    @app.unregister()
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voruby-1.0.2 test/plastic/unittest.rb
voruby-1.0.1 test/plastic/unittest.rb
voruby-1.1 test/plastic/unittest.rb
voruby-1.1.1 test/plastic/unittest.rb