1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
require File.dirname(__FILE__) + "/../spec_helper"
require 'jruby/core_ext'
describe "JRuby annotation processing:" do
context "method annotations using #add_method_annotation" do
class ClassWithAnnotatedMethods
add_method_annotation 'foo', {Java::java_integration.fixtures.MethodAnnotations::Annotated => {}}
def foo; end
add_method_annotation 'bar', {Java::java_integration.fixtures.MethodAnnotations::Annotated => {}}
def bar; end
def baz; end
become_java!
end
it "has two annotated methods" do
Java::java_integration.fixtures.MethodAnnotations.countAnnotated(ClassWithAnnotatedMethods).size.should == 2
end
end
context "parameter annotations using #add_parameter_annotation" do
class ClassWithAnnotatedParams
add_parameter_annotation 'foo', [{Java::java_integration.fixtures.ParameterAnnotations::Annotated => {}}]
def foo(x); end
become_java!
end
it "has an annotated parameter" do
Java::java_integration.fixtures.ParameterAnnotations.countAnnotated(ClassWithAnnotatedParams).size.should == 1
end
end
context "method annotations using #java_signature" do
class ClassWithAnnotatedMethods2
java_signature("@java_integration.fixtures.MethodAnnotations.Annotated void foo()")
def foo; end
java_signature("@java_integration.fixtures.MethodAnnotations.Annotated void bar()")
def bar; end
def baz; end
become_java!
end
it "has two annotated methods" do
Java::java_integration.fixtures.MethodAnnotations.countAnnotated(ClassWithAnnotatedMethods2).size.should == 2
end
end
context "field annotations using #add_field_annotation" do
let(:cls) do
Class.new do
java_field "java.lang.String foo"
add_field_annotation(:foo, Java::java_integration.fixtures.FieldAnnotations::Annotated => {})
java_field "java.lang.String bar"
add_field_annotation(:bar, Java::java_integration.fixtures.FieldAnnotations::Annotated => {})
java_field "java.lang.String baz"
become_java!
end
end
it "has two annotated fields" do
Java::java_integration.fixtures.FieldAnnotations.countAnnotated(cls).size.should == 2
end
end
end
|