Created
March 22, 2010 04:19
-
-
Save BanzaiMan/339793 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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