From 196daf5a2aac91a150aae27d23c9228b5a1a7649 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sun, 28 Mar 2010 02:04:32 +0000 Subject: [PATCH] Convenience methods --- .../eclipse/cdt/ui/testplugin/Accessor.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/Accessor.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/Accessor.java index 38a53fb77b5..ced211fe782 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/Accessor.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/Accessor.java @@ -33,6 +33,31 @@ public class Accessor extends Assert { /** The instance to access. */ private Object fInstance; + /** + * Creates an accessor for the given instance and its + * class. Only non-inherited members that particular + * class can be accessed. + * + * @param instance the instance + */ + public Accessor(Object instance) { + assertNotNull(instance); + fInstance= instance; + fClass= instance.getClass(); + } + + /** + * Creates an accessor for the given class. + * Only static members of that particular class can be accessed. + * + * @param clazz the class + */ + public Accessor(Class clazz) { + assertNotNull(clazz); + fInstance= null; + fClass= clazz; + } + /** * Creates an accessor for the given instance and * class. Only non-inherited members that particular @@ -145,6 +170,17 @@ public class Accessor extends Assert { } } + /** + * Invokes the method with the given method name and no arguments. + *

+ * + * @param methodName the method name + * @return the method return value + */ + public Object invoke(String methodName) { + return invoke(methodName, null, new Object[0]); + } + /** * Invokes the method with the given method name and arguments. *