|
@@ -7,12 +7,9 @@
|
|
|
package net.ranides.assira.junit;
|
|
package net.ranides.assira.junit;
|
|
|
|
|
|
|
|
import java.io.PrintStream;
|
|
import java.io.PrintStream;
|
|
|
-import java.lang.reflect.Field;
|
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Method;
|
|
|
import java.lang.reflect.Modifier;
|
|
import java.lang.reflect.Modifier;
|
|
|
-import java.lang.reflect.ParameterizedType;
|
|
|
|
|
-import java.lang.reflect.Type;
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -20,10 +17,13 @@ import java.util.Map;
|
|
|
import java.util.Map.Entry;
|
|
import java.util.Map.Entry;
|
|
|
import java.util.SortedSet;
|
|
import java.util.SortedSet;
|
|
|
import java.util.TreeSet;
|
|
import java.util.TreeSet;
|
|
|
|
|
+import java.util.function.Consumer;
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
import java.util.function.Supplier;
|
|
import java.util.function.Supplier;
|
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
|
-import javax.annotation.Resource;
|
|
|
|
|
|
|
+import net.ranides.assira.junit.TestUtils.ICounter;
|
|
|
|
|
+import net.ranides.assira.junit.TestUtils.IField;
|
|
|
|
|
+import net.ranides.assira.junit.TestUtils.IPatterns;
|
|
|
import org.junit.Assert;
|
|
import org.junit.Assert;
|
|
|
import org.junit.Ignore;
|
|
import org.junit.Ignore;
|
|
|
|
|
|
|
@@ -37,13 +37,27 @@ import org.junit.Ignore;
|
|
|
*/
|
|
*/
|
|
|
public final class TestContractRunner {
|
|
public final class TestContractRunner {
|
|
|
|
|
|
|
|
|
|
+ // @todo (assira.junit #3) obsługa wielu funkcji i supplierów
|
|
|
|
|
+ // możemy pobierać typy argumentów i returnów funkcji za pomocą TestUtils#typeof(Function)
|
|
|
|
|
+ // jeśli tę funkcję rozszerzyć, żeby zwracała Tuple<Param,Result> to mamy wszystko
|
|
|
|
|
+ // potem to można trzymać w jakiejś mapie
|
|
|
|
|
+ // a potem można matchować przy uruchamianiu metod
|
|
|
|
|
+ //
|
|
|
|
|
+ // w sumie przydatne, jeśli nasza klasa chce ruszyć na kilku testerach, które
|
|
|
|
|
+ // pobierają różne inputy:
|
|
|
|
|
+ // Function<int[], MyInterface>
|
|
|
|
|
+ // Function<char[], MyInterface>
|
|
|
|
|
+ // Function<byte[], MyInterface>
|
|
|
|
|
+ // Function<String, MyInterface>
|
|
|
|
|
+ // Supplier<MyInterface>
|
|
|
|
|
+
|
|
|
private static final boolean DEBUG = "true".equals(System.getProperty("assira.junit.debug"));
|
|
private static final boolean DEBUG = "true".equals(System.getProperty("assira.junit.debug"));
|
|
|
|
|
|
|
|
private final SortedSet<MethodRunner> methods = new TreeSet<>();
|
|
private final SortedSet<MethodRunner> methods = new TreeSet<>();
|
|
|
|
|
|
|
|
private final List<TesterWrapper> testers = new ArrayList<>();
|
|
private final List<TesterWrapper> testers = new ArrayList<>();
|
|
|
|
|
|
|
|
- private final List<Pattern> ignored = new ArrayList<>();
|
|
|
|
|
|
|
+ private final IPatterns ignored = new IPatterns();
|
|
|
|
|
|
|
|
private final PrintStream output;
|
|
private final PrintStream output;
|
|
|
|
|
|
|
@@ -62,15 +76,11 @@ public final class TestContractRunner {
|
|
|
|
|
|
|
|
public TestContractRunner(TestContractRunner runner) {
|
|
public TestContractRunner(TestContractRunner runner) {
|
|
|
this(runner.output);
|
|
this(runner.output);
|
|
|
- try {
|
|
|
|
|
- for(TesterWrapper w : runner.testers) {
|
|
|
|
|
- this.appendCopy(w);
|
|
|
|
|
- }
|
|
|
|
|
- this.ignored.addAll(runner.ignored);
|
|
|
|
|
- this.debug = runner.debug;
|
|
|
|
|
- } catch(ReflectiveOperationException cause) {
|
|
|
|
|
- throw NewAssert.rethrow(cause);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ for(TesterWrapper w : runner.testers) {
|
|
|
|
|
+ appendWrapper(TestUtils.copy(w.object)).setParams(w);
|
|
|
|
|
+ }
|
|
|
|
|
+ this.ignored.add(runner.ignored);
|
|
|
|
|
+ this.debug = runner.debug;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public TestContractRunner debug(boolean value) {
|
|
public TestContractRunner debug(boolean value) {
|
|
@@ -83,7 +93,7 @@ public final class TestContractRunner {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public TestContractRunner ignore(String method) {
|
|
public TestContractRunner ignore(String method) {
|
|
|
- this.ignored.add(Pattern.compile(Pattern.quote(method)));
|
|
|
|
|
|
|
+ this.ignored.add(method);
|
|
|
return this;
|
|
return this;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -96,16 +106,6 @@ public final class TestContractRunner {
|
|
|
appendWrapper(tester);
|
|
appendWrapper(tester);
|
|
|
return this;
|
|
return this;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- private void appendCopy(TesterWrapper source) throws ReflectiveOperationException {
|
|
|
|
|
- Object tester = source.object.getClass().newInstance();
|
|
|
|
|
- TesterWrapper target = appendWrapper(tester);
|
|
|
|
|
- for(Entry<String, IParam> entry : source.resources.entrySet()) {
|
|
|
|
|
- String key = entry.getKey();
|
|
|
|
|
- target.resources.get(key).set(entry.getValue().get());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
public TesterWrapper appendWrapper(Object tester) {
|
|
public TesterWrapper appendWrapper(Object tester) {
|
|
|
TesterWrapper wrapper = new TesterWrapper(tester);
|
|
TesterWrapper wrapper = new TesterWrapper(tester);
|
|
@@ -126,18 +126,13 @@ public final class TestContractRunner {
|
|
|
if(!m.getReturnType().equals(void.class)) {
|
|
if(!m.getReturnType().equals(void.class)) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- MethodRunner mr = runner(tester, m);
|
|
|
|
|
- if(null != mr) {
|
|
|
|
|
- methods.add(mr);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ methods.add(runner(tester, m));
|
|
|
}
|
|
}
|
|
|
return wrapper;
|
|
return wrapper;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public TestContractRunner param(String name, Object value) {
|
|
public TestContractRunner param(String name, Object value) {
|
|
|
- testers.stream().forEach((t) -> {
|
|
|
|
|
- t.param(name, value);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ testers.stream().forEach(t -> t.param(name, value));
|
|
|
return this;
|
|
return this;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -148,8 +143,13 @@ public final class TestContractRunner {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
|
- public <P> TestContractRunner function(P ident, Function<P, ?> function) {
|
|
|
|
|
|
|
+ public <T,R> TestContractRunner function(Function<T, R> function) {
|
|
|
this.function = (Function)function;
|
|
this.function = (Function)function;
|
|
|
|
|
+ return this;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public <T,R> TestContractRunner function(T ident, Function<T, R> function) {
|
|
|
|
|
+ function(function);
|
|
|
this.supplier = () -> this.function.apply(ident);
|
|
this.supplier = () -> this.function.apply(ident);
|
|
|
return this;
|
|
return this;
|
|
|
}
|
|
}
|
|
@@ -158,19 +158,22 @@ public final class TestContractRunner {
|
|
|
for(TesterWrapper tester : testers) {
|
|
for(TesterWrapper tester : testers) {
|
|
|
tester.bind(this);
|
|
tester.bind(this);
|
|
|
}
|
|
}
|
|
|
- if(null == supplier) {
|
|
|
|
|
- throw new AssertionError("Supplier is not set.");
|
|
|
|
|
|
|
+ if(null == supplier && null == function) {
|
|
|
|
|
+ throw new AssertionError("You have to set Supplier or Function.");
|
|
|
}
|
|
}
|
|
|
- Class<?> type = supplier.get().getClass();
|
|
|
|
|
- Counter counter = new Counter();
|
|
|
|
|
|
|
+ Class<?> type;
|
|
|
|
|
+ if(null != supplier) {
|
|
|
|
|
+ type = supplier.get().getClass();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ type = TestUtils.typeof(function);
|
|
|
|
|
+ }
|
|
|
|
|
+ ICounter counter = new ICounter();
|
|
|
List<String> failed = new ArrayList<>();
|
|
List<String> failed = new ArrayList<>();
|
|
|
- methods.stream().filter((m)->m.accept(type)).forEach((m)->{
|
|
|
|
|
- try {
|
|
|
|
|
- m.run(counter);
|
|
|
|
|
- } catch(Throwable cause) {
|
|
|
|
|
- failed.add(m.label);
|
|
|
|
|
- cause.printStackTrace(output);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ methods.stream().filter(m -> m.accept(type)).forEach(m -> {
|
|
|
|
|
+ m.run(counter, cause -> {
|
|
|
|
|
+ failed.add(m.label);
|
|
|
|
|
+ cause.printStackTrace(output);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
ireset();
|
|
ireset();
|
|
|
if(!failed.isEmpty()) {
|
|
if(!failed.isEmpty()) {
|
|
@@ -180,7 +183,7 @@ public final class TestContractRunner {
|
|
|
output.print(f);
|
|
output.print(f);
|
|
|
}
|
|
}
|
|
|
output.println();
|
|
output.println();
|
|
|
- Assert.fail("Failed interface tests: " + failed.size() + "/"+counter.value);
|
|
|
|
|
|
|
+ Assert.fail("Failed interface tests: " + failed.size() + "/"+counter.value());
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -196,10 +199,10 @@ public final class TestContractRunner {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private MethodRunner runner(Object that, Method method) {
|
|
private MethodRunner runner(Object that, Method method) {
|
|
|
- if( method.getParameterTypes()[0].equals(Supplier.class) ) {
|
|
|
|
|
|
|
+ if( TestUtils.acceptsSupplier(method) ) {
|
|
|
return new SMethodRunner(that, method);
|
|
return new SMethodRunner(that, method);
|
|
|
}
|
|
}
|
|
|
- if( method.getParameterTypes()[0].equals(Function.class) ) {
|
|
|
|
|
|
|
+ if( TestUtils.acceptsFunction(method) ) {
|
|
|
return new SMethodRunner(that, method);
|
|
return new SMethodRunner(that, method);
|
|
|
}
|
|
}
|
|
|
return new CMethodRunner(that, method);
|
|
return new CMethodRunner(that, method);
|
|
@@ -213,6 +216,9 @@ public final class TestContractRunner {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void invoke() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
protected void invoke() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
|
|
|
+ if(null == supplier) {
|
|
|
|
|
+ throw new AssertionError("Supplier is required by method: " + nid, TestUtils.cause4method(method, "Supplier required."));
|
|
|
|
|
+ }
|
|
|
method.invoke(that, supplier.get());
|
|
method.invoke(that, supplier.get());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -246,11 +252,11 @@ public final class TestContractRunner {
|
|
|
protected String label;
|
|
protected String label;
|
|
|
|
|
|
|
|
public MethodRunner(Object that, Method method) {
|
|
public MethodRunner(Object that, Method method) {
|
|
|
- this.type = typeof(method);
|
|
|
|
|
|
|
+ this.type = TestUtils.typeof(method);
|
|
|
this.that = that;
|
|
this.that = that;
|
|
|
this.method = method;
|
|
this.method = method;
|
|
|
- this.uid = type.getName()+"#"+method.getDeclaringClass().getName() +"#" + method.getName();
|
|
|
|
|
- this.nid = method.getDeclaringClass().getSimpleName() + "." + method.getName();
|
|
|
|
|
|
|
+ this.uid = TestUtils.uid(method);
|
|
|
|
|
+ this.nid = TestUtils.nid(method);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -264,14 +270,12 @@ public final class TestContractRunner {
|
|
|
|
|
|
|
|
protected abstract void invoke() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException;
|
|
protected abstract void invoke() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException;
|
|
|
|
|
|
|
|
- public void run(Counter counter) throws RuntimeException {
|
|
|
|
|
- for(Pattern p : ignored) {
|
|
|
|
|
- if(p.matcher(nid).matches()) {
|
|
|
|
|
- if(debug) {
|
|
|
|
|
- printf(type, counter.next(), method, "IGNORED");
|
|
|
|
|
- }
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ public void run(ICounter counter, Consumer<Throwable> handler) {
|
|
|
|
|
+ if(ignored.matches(nid)) {
|
|
|
|
|
+ if(debug) {
|
|
|
|
|
+ printf(type, counter.next(), method, "IGNORED");
|
|
|
}
|
|
}
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
int index = counter.next();
|
|
int index = counter.next();
|
|
|
try {
|
|
try {
|
|
@@ -280,10 +284,10 @@ public final class TestContractRunner {
|
|
|
printf(type, index, method, "");
|
|
printf(type, index, method, "");
|
|
|
}
|
|
}
|
|
|
} catch (IllegalAccessException | IllegalArgumentException ex) {
|
|
} catch (IllegalAccessException | IllegalArgumentException ex) {
|
|
|
- throw NewAssert.rethrow(ex);
|
|
|
|
|
|
|
+ handler.accept(ex);
|
|
|
} catch (InvocationTargetException ex) {
|
|
} catch (InvocationTargetException ex) {
|
|
|
printf(type, index, method, "FAILED");
|
|
printf(type, index, method, "FAILED");
|
|
|
- throw NewAssert.rethrow(ex.getTargetException());
|
|
|
|
|
|
|
+ handler.accept(ex.getTargetException());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -305,93 +309,27 @@ public final class TestContractRunner {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- static Class<?> typeof(Method method) {
|
|
|
|
|
- Class<?> cparam = method.getParameterTypes()[0];
|
|
|
|
|
- if(Supplier.class.isAssignableFrom(cparam)) {
|
|
|
|
|
- return typeofSupplier(method);
|
|
|
|
|
- }
|
|
|
|
|
- if(Function.class.isAssignableFrom(cparam)) {
|
|
|
|
|
- return typeofFunction(method);
|
|
|
|
|
- }
|
|
|
|
|
- return cparam;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static Class<?> typeofSupplier(Method method) throws AssertionError {
|
|
|
|
|
- ParameterizedType gparam = (ParameterizedType)method.getGenericParameterTypes()[0];
|
|
|
|
|
- Type tparam = gparam.getActualTypeArguments()[0];
|
|
|
|
|
- if(tparam instanceof Class<?>) {
|
|
|
|
|
- return (Class<?>)tparam;
|
|
|
|
|
- }
|
|
|
|
|
- if(tparam instanceof ParameterizedType) {
|
|
|
|
|
- return (Class<?>)(((ParameterizedType)tparam).getRawType());
|
|
|
|
|
- }
|
|
|
|
|
- throw new AssertionError("You can't use wildcard generic types in method: " + method, causeForMethod(method));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static Class<?> typeofFunction(Method method) throws AssertionError {
|
|
|
|
|
- ParameterizedType gparam = (ParameterizedType)method.getGenericParameterTypes()[0];
|
|
|
|
|
-// if(!gparam.getActualTypeArguments()[0].equals(int[].class)) {
|
|
|
|
|
-// throw new AssertionError("Function must accept int[] in method: " + method, causeForMethod(method));
|
|
|
|
|
-// }
|
|
|
|
|
- Type tparam = gparam.getActualTypeArguments()[1];
|
|
|
|
|
- if(tparam instanceof Class<?>) {
|
|
|
|
|
- return (Class<?>)tparam;
|
|
|
|
|
- }
|
|
|
|
|
- if(tparam instanceof ParameterizedType) {
|
|
|
|
|
- return (Class<?>)(((ParameterizedType)tparam).getRawType());
|
|
|
|
|
- }
|
|
|
|
|
- throw new AssertionError("You can't use wildcard generic types in method: " + method, causeForMethod(method));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static Exception causeForMethod(Method method) {
|
|
|
|
|
- Exception e = new Exception("Invalid declaration");
|
|
|
|
|
- e.setStackTrace(new StackTraceElement[]{
|
|
|
|
|
- new StackTraceElement(
|
|
|
|
|
- method.getDeclaringClass().getName(),
|
|
|
|
|
- method.getName(), "?", -1)
|
|
|
|
|
- });
|
|
|
|
|
- return e;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static final class Counter {
|
|
|
|
|
- private int value = 0;
|
|
|
|
|
-
|
|
|
|
|
- public int next() {
|
|
|
|
|
- return ++value;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private static final class TesterWrapper {
|
|
private static final class TesterWrapper {
|
|
|
|
|
|
|
|
private final Object object;
|
|
private final Object object;
|
|
|
|
|
|
|
|
- private final Map<String, IParam> resources = new HashMap<>();
|
|
|
|
|
|
|
+ private final Map<String, IField> resources = new HashMap<>();
|
|
|
|
|
|
|
|
- private final List<IParam> bindings = new ArrayList<>();
|
|
|
|
|
|
|
+ private final List<IField> bindings = new ArrayList<>();
|
|
|
|
|
|
|
|
public TesterWrapper(Object object) {
|
|
public TesterWrapper(Object object) {
|
|
|
this.object = object;
|
|
this.object = object;
|
|
|
- for(Class<?> c=object.getClass(); c!=null; c=c.getSuperclass()) {
|
|
|
|
|
- for(Field f : c.getDeclaredFields()) {
|
|
|
|
|
- Resource info = f.getAnnotation(Resource.class);
|
|
|
|
|
- if(null != info) {
|
|
|
|
|
- String name = info.name();
|
|
|
|
|
- if("".equals(name)) {
|
|
|
|
|
- name = f.getName();
|
|
|
|
|
- }
|
|
|
|
|
- f.setAccessible(true);
|
|
|
|
|
- if( f.getType().equals(TestContractRunner.class) ) {
|
|
|
|
|
- bindings.add(new IParam(object, f));
|
|
|
|
|
- } else {
|
|
|
|
|
- resources.put(name, new IParam(object, f));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ for(IField f : TestUtils.getFields(object)) {
|
|
|
|
|
+ if( TestContractRunner.class.equals(f.type()) ) {
|
|
|
|
|
+ bindings.add(f);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ resources.put(f.name(), f);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void bind(TestContractRunner runner) {
|
|
public void bind(TestContractRunner runner) {
|
|
|
- for(IParam p : bindings) {
|
|
|
|
|
|
|
+ for(IField p : bindings) {
|
|
|
p.set(runner);
|
|
p.set(runner);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -401,9 +339,17 @@ public final class TestContractRunner {
|
|
|
resources.get(name).set(value);
|
|
resources.get(name).set(value);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public void setParams(TesterWrapper source) {
|
|
|
|
|
+ for(Entry<String, IField> entry : source.resources.entrySet()) {
|
|
|
|
|
+ String key = entry.getKey();
|
|
|
|
|
+ Object val = entry.getValue().get();
|
|
|
|
|
+ resources.get(key).set(val);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public void resetParams() {
|
|
public void resetParams() {
|
|
|
- for(IParam param : resources.values()) {
|
|
|
|
|
|
|
+ for(IField param : resources.values()) {
|
|
|
param.reset();
|
|
param.reset();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -429,46 +375,5 @@ public final class TestContractRunner {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- private static final class IParam {
|
|
|
|
|
- private final Object object;
|
|
|
|
|
- private final Field field;
|
|
|
|
|
- private final Object value;
|
|
|
|
|
-
|
|
|
|
|
- public IParam(Object object, Field field) {
|
|
|
|
|
- try {
|
|
|
|
|
- this.object = object;
|
|
|
|
|
- this.field = field;
|
|
|
|
|
- this.value = field.get(object);
|
|
|
|
|
- } catch(ReflectiveOperationException cause) {
|
|
|
|
|
- throw NewAssert.rethrow(cause);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void set(Object value) {
|
|
|
|
|
- try {
|
|
|
|
|
- field.set(object, value);
|
|
|
|
|
- } catch(ReflectiveOperationException cause) {
|
|
|
|
|
- throw NewAssert.rethrow(cause);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public Object get() {
|
|
|
|
|
- try {
|
|
|
|
|
- return field.get(object);
|
|
|
|
|
- } catch(ReflectiveOperationException cause) {
|
|
|
|
|
- throw NewAssert.rethrow(cause);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void reset() {
|
|
|
|
|
- try {
|
|
|
|
|
- field.set(object, value);
|
|
|
|
|
- } catch(ReflectiveOperationException cause) {
|
|
|
|
|
- throw NewAssert.rethrow(cause);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|