Skip to content

Instantly share code, notes, and snippets.

@BanzaiMan
Created March 22, 2010 04:19
Show Gist options
  • Select an option

  • Save BanzaiMan/339793 to your computer and use it in GitHub Desktop.

Select an option

Save BanzaiMan/339793 to your computer and use it in GitHub Desktop.
require File.dirname(__FILE__) + "/../spec_helper"
TEST_VALUE = 101
class MyCallableTask
include java.util.concurrent.Callable
def call
sleep 2
TEST_VALUE
end
end
describe "java.util.concurrent.Executors" do
before do
@executor = java.util.concurrent.Executors.newSingleThreadExecutor
@future_callable = @executor.submit(MyCallableTask.new)
end
it "expects a class that implements Callable interface" do
@future.get.should == TEST_VALUE
end
after do
@executor.shutdown
end
end
require 'test/unit'
require 'java'
TEST_VALUE = 101
class MyTask
include java.util.concurrent.Callable
def call
sleep 2
TEST_VALUE
end
end
class TestJavaCallable < Test::Unit::TestCase
def setup
@executor = java.util.concurrent.Executors.newSingleThreadExecutor
@future = @executor.submit(MyTask.new)
end
def test_call
assert @future.get == TEST_VALUE
end
def teardown
@executor.shutdown
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment