mirror of
https://github.com/EsotericSoftware/reflectasm.git
synced 2025-02-08 18:20:29 +08:00
Added test for MethodAccess to an interface type
This commit is contained in:
parent
a8e2c96928
commit
af9620b361
@ -1,7 +1,12 @@
|
||||
|
||||
package com.esotericsoftware.reflectasm;
|
||||
|
||||
import com.esotericsoftware.reflectasm.FieldAccessTest.EmptyClass;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@ -71,6 +76,21 @@ public class MethodAccessTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testInvokeInterface () {
|
||||
MethodAccess access = MethodAccess.get(ConcurrentMap.class);
|
||||
ConcurrentHashMap<String, String> someMap = new ConcurrentHashMap<String, String>();
|
||||
someMap.put("first", "one");
|
||||
someMap.put("second", "two");
|
||||
Object value;
|
||||
|
||||
// invoke a method declared directly in the ConcurrentMap interface
|
||||
value = access.invoke(someMap, "replace", "first", "foo");
|
||||
assertEquals("one", value);
|
||||
// invoke a method declared in the Map superinterface
|
||||
value = access.invoke(someMap, "size");
|
||||
assertEquals(someMap.size(), value);
|
||||
}
|
||||
|
||||
static public class EmptyClass {
|
||||
}
|
||||
|
||||
@ -98,4 +118,5 @@ public class MethodAccessTest extends TestCase {
|
||||
return "test";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user