Browse Source

MethodPointer: serializable
MethodPointer: equals

WebServiceInspector.WSMethod: serializable

Ranides Atterwim 11 năm trước cách đây
mục cha
commit
2a79dcd5b3

+ 460 - 428
assira1/src/main/java/net/ranides/assira/reflection/MethodFactory.java

@@ -1,428 +1,460 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.reflection;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.concurrent.Callable;
-import net.ranides.assira.asm.MethodInspectorVM;
-import net.ranides.assira.collection.ArrayUtils;
-import net.ranides.assira.generic.Function;
-import net.ranides.assira.generic.LazyRef;
-import net.ranides.assira.reflection.inspect.MethodInspector;
-import net.ranides.assira.reflection.util.ClassUtils;
-import net.ranides.assira.reflection.util.MemberUtils;
-import net.ranides.assira.reflection.util.MethodUtils;
-import net.ranides.assira.reflection.util.ReflectFormat;
-import net.ranides.assira.reflection.util.ReflectUtils;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public final class MethodFactory {
-    
-    private MethodFactory() {
-        // utility class
-    }
-    
-    public static <T> ConstructorPointer<T> wrap(Constructor<T> ctor) {
-        return new ConstructorPointer<>(ctor);
-    }
-    
-    public static MethodPointer<?> wrap(Method method) {
-        return new MethodPointer(method);
-    }
-    
-    public static <R> FunctionPointer<R> wrap(Function<R,?> function) {
-        return new FunctionPointer<>(function);
-    }
-    
-    public static abstract class ReflectivePointer<R> implements GenericMethod<R> {
-        
-        protected final LazyRef<List<GenericParam>> params = LazyRef.lockfree(new Callable<List<GenericParam>>() {
-            @Override
-            public List<GenericParam> call() throws Exception {
-                return iparams();
-            }
-        });
-        
-        protected final LazyRef<GenericClass> type = LazyRef.lockfree(new Callable<GenericClass>() {
-            @Override
-            public GenericClass call() throws Exception {
-                return itype();
-            }
-        });
-        
-        protected abstract GenericClass itype();
-        
-        protected abstract List<GenericParam> iparams();
-
-        @Override
-        public final GenericClass type() {
-            return type.get();
-        }
-
-        @Override
-        public final List<GenericParam> params() {
-            return params.get();
-        }
-        
-        @Override
-        public final void run() {
-            call();
-        }
-        
-        @Override
-        public final R call() {
-            return invoke(null);
-        }
-        
-    }
-    
-    public static class ConstructorPointer<R> extends ReflectivePointer<R> {
-        
-        protected final Constructor<R> method;
-
-        protected ConstructorPointer(ConstructorPointer<R> pointer) {
-            this.method = pointer.method;
-        }
-        
-        protected ConstructorPointer(Constructor<R> ctor) {
-            this.method = ReflectUtils.access(ctor);
-        }
-        
-        @Override
-        protected GenericClass itype() {
-            return TypeFactory.construct( method.getDeclaringClass() );
-        }
-
-        @Override
-        protected List<GenericParam> iparams() {
-            return MethodInspectorVM.params(method);
-        }
-
-        @Override
-        public int paramsize() {
-            return method.getParameterTypes().length;
-        }
-                
-        @Override
-        public String name() {
-            return method.getName();
-        }
-
-        @Override
-        public GenericMethod bind(Object that) {
-            throw new UnsupportedOperationException("Constructor can't bind this.");
-        }
-        
-        @Override
-        public R call(Object... arguments) {
-            return invoke(null, arguments);
-        }
-        
-        @Override
-        public R invoke(Object that, Object... arguments) {
-            try {
-                return method.newInstance(arguments);
-            } catch (InstantiationException | IllegalAccessException | IllegalArgumentException ex) {
-                throw new InspectException(ex);
-            } catch (InvocationTargetException ex) {
-                throw new InvokeException(ex);
-            }
-        }
-        
-        @Override
-        public String toString() {
-            return ReflectFormat.signature(method);
-        }
-
-        @Override
-        public boolean canCall(Object... object) {
-            return ClassUtils.isInstance(method.getParameterTypes(), object);
-        }
-
-        @Override
-        public boolean canInvoke(Object that, Object... arguments) {
-            return (null == that) && canCall(arguments);
-        }
-        
-        public Constructor<?> reflective() {
-            return method;
-        }
-        
-    }
-    
-    public static class MethodPointer<R> extends ReflectivePointer<R> {
-        
-        protected final Method method;
-
-        protected MethodPointer(Method method) {
-            this.method = ReflectUtils.access(method);
-        }
-        
-        protected MethodPointer(MethodPointer<R> pointer) {
-            this.method = pointer.method;
-        }
-
-        @Override
-        protected GenericClass itype() {
-            return MethodUtils.typeof(method);
-        }
-
-        @Override
-        protected List<GenericParam> iparams() {
-            return MethodUtils.params(method);
-        }
-        
-        @Override
-        public int paramsize() {
-            return method.getParameterTypes().length;
-        }
-        
-        @Override
-        public String name() {
-            return method.getName();
-        }
-
-        @Override
-        public GenericMethod bind(Object that) {
-            if( MemberUtils.isStatic(method) ) {
-                throw new UnsupportedOperationException("Static method can't bind this.");
-            }
-            return new BindPointer(this, that);
-        }
-        
-        @Override
-        public R call(Object... arguments) {
-            if( MemberUtils.isStatic(method) ) {
-                return (R)invoke(null, arguments);
-            } else {
-                return (R)invoke(arguments[0], ArrayUtils.slice(arguments, 1, arguments.length));
-            }
-        }
-        
-        @Override
-        public R invoke(Object that, Object... arguments) {
-            try {
-                return (R)method.invoke(that, arguments);
-            } catch (IllegalAccessException | IllegalArgumentException ex) {
-                throw new InspectException(ex);
-            } catch (InvocationTargetException ex) {
-                throw new InvokeException(ex);
-            }
-        }
-
-        @Override
-        public boolean canCall(Object... arguments) {
-            if( MemberUtils.isStatic(method)) {
-                return ClassUtils.isInstance(method.getParameterTypes(), arguments);
-            }
-            if( !method.getDeclaringClass().isInstance(arguments[0]) ) {
-                return false;
-            }
-            Class[] array = method.getParameterTypes();
-            if( arguments.length-1 != array.length) {
-                return false;
-            }
-            for(int i=0; i<array.length; i++) {
-                if(!ClassUtils.isInstance(array[i], arguments[i+1])) {
-                    return false;
-                }
-            }
-            return true;
-        }
-
-        @Override
-        public boolean canInvoke(Object that, Object... arguments) {
-            if( !MemberUtils.isStatic(method)) {
-                if( !method.getDeclaringClass().isInstance(that) ) {
-                    return false;
-                }
-            }
-            return ClassUtils.isInstance(method.getParameterTypes(), arguments);
-        }
-        
-        @Override
-        public String toString() {
-            return ReflectFormat.signature(method);
-        }
-        
-        public Method reflective() {
-            return method;
-        }
-        
-    }
-    
-    public static class FunctionPointer<R> implements GenericMethod<R> {
-        
-        protected final Function<R,?> function;
-        
-        protected final LazyRef<List<GenericParam>> params = LazyRef.lockfree(new Callable<List<GenericParam>>() {
-            @Override
-            public List<GenericParam> call() throws Exception {
-                return MethodInspector.inobject(function).published().name("apply").first().params();
-            }
-        });
-        
-        protected final LazyRef<GenericClass> type = LazyRef.lockfree(new Callable<GenericClass>() {
-            @Override
-            public GenericClass call() throws Exception {
-                return MethodInspector.inobject(function).published().name("apply").first().type();
-            }
-        });
-
-        protected FunctionPointer(Function<R, ?> function) {
-            this.function = function;
-        }
-        
-        @Override
-        public GenericClass type() {
-            return type.get();
-        }
-
-        @Override
-        public List<GenericParam> params() {
-            return params.get();
-        }
-        
-        @Override
-        public int paramsize() {
-            return 1;
-        }
-        
-        @Override
-        public String name() {
-            return function.getClass().getName();
-        }
-
-        @Override
-        public GenericMethod bind(Object that) {
-            if(that != null) {
-                throw new UnsupportedOperationException("Function can't use 'this' argument.");
-            }
-            return this;
-        }
-        
-        @Override
-        public void run() {
-            throw new UnsupportedOperationException("Function requires exactly one argument");
-        }
-        
-        @Override
-        public R call() {
-            throw new UnsupportedOperationException("Function requires exactly one argument");
-        }
-
-        @Override
-        public R call(Object... arguments) {
-            return invoke(null, arguments);
-        }
-        
-        @Override
-        public R invoke(Object that, Object... params) {
-            if(that != null) {
-                throw new UnsupportedOperationException("Function can't use 'this' argument.");
-            }
-            return ((Function<R,Object>)function).apply(params[0]);
-        }
-
-        @Override
-        public boolean canCall(Object... arguments) {
-            if( arguments.length != 1) {
-                return false;
-            }
-            return params().get(0).type().rawType().isInstance(arguments[0]);
-        }
-
-        @Override
-        public boolean canInvoke(Object that, Object... arguments) {
-            return (null == that) && canCall(arguments);
-        }
-        
-        @Override
-        public String toString() {
-            return function.toString();
-        }
-        
-    }
-    
-    private static final class BindPointer implements GenericMethod {
-        
-        private final GenericMethod pointer;
-        private final Object that;
-
-        private BindPointer(GenericMethod pointer, Object that) {
-            this.pointer = pointer;
-            this.that = that;
-        }
-        
-        @Override
-        public String name() {
-            return pointer.name();
-        }
-
-        @Override
-        public GenericClass type() {
-            return pointer.type();
-        }
-
-        @Override
-        public List<GenericParam> params() {
-            return pointer.params();
-        }
-        
-        @Override
-        public int paramsize() {
-            return pointer.paramsize();
-        }
-
-        @Override
-        public GenericMethod bind(Object that) {
-            return new BindPointer(pointer, that);
-        }
-        
-        @Override
-        public void run() {
-            pointer.invoke(that);
-        }
-        
-        @Override
-        public Object call() {
-            return pointer.invoke(that);
-        }
-        
-        @Override
-        public Object call(Object... arguments) {
-            return pointer.invoke(that, arguments);
-        }
-
-        @Override
-        public Object invoke(Object that, Object... arguments) {
-            throw new UnsupportedOperationException("Already bound.");
-        }
-
-        @Override
-        public boolean canCall(Object... arguments) {
-            return pointer.canInvoke(that, arguments);
-        }
-
-        @Override
-        public boolean canInvoke(Object that, Object... arguments) {
-            return false;
-        }
-        
-        @Override
-        public String toString() {
-            return pointer.toString();
-        }
-        
-    }
-}
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/assira
+ */
+package net.ranides.assira.reflection;
+
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.concurrent.Callable;
+import net.ranides.assira.asm.MethodInspectorVM;
+import net.ranides.assira.collection.ArrayUtils;
+import net.ranides.assira.generic.Function;
+import net.ranides.assira.generic.LazyRef;
+import net.ranides.assira.generic.Serializer;
+import net.ranides.assira.reflection.inspect.MethodInspector;
+import net.ranides.assira.reflection.util.ClassUtils;
+import net.ranides.assira.reflection.util.MemberUtils;
+import net.ranides.assira.reflection.util.MethodUtils;
+import net.ranides.assira.reflection.util.ReflectFormat;
+import net.ranides.assira.reflection.util.ReflectUtils;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public final class MethodFactory {
+    
+    private MethodFactory() {
+        // utility class
+    }
+    
+    public static <T> ConstructorPointer<T> wrap(Constructor<T> ctor) {
+        return new ConstructorPointer<>(ctor);
+    }
+    
+    public static MethodPointer<?> wrap(Method method) {
+        return new MethodPointer(method);
+    }
+    
+    public static <R> FunctionPointer<R> wrap(Function<R,?> function) {
+        return new FunctionPointer<>(function);
+    }
+    
+    public static abstract class ReflectivePointer<R> implements GenericMethod<R> {
+        
+        protected final LazyRef<List<GenericParam>> params = LazyRef.lockfree(new Callable<List<GenericParam>>() {
+            @Override
+            public List<GenericParam> call() throws Exception {
+                return iparams();
+            }
+        });
+        
+        protected final LazyRef<GenericClass> type = LazyRef.lockfree(new Callable<GenericClass>() {
+            @Override
+            public GenericClass call() throws Exception {
+                return itype();
+            }
+        });
+        
+        protected abstract GenericClass itype();
+        
+        protected abstract List<GenericParam> iparams();
+
+        @Override
+        public final GenericClass type() {
+            return type.get();
+        }
+
+        @Override
+        public final List<GenericParam> params() {
+            return params.get();
+        }
+        
+        @Override
+        public final void run() {
+            call();
+        }
+        
+        @Override
+        public final R call() {
+            return invoke(null);
+        }
+        
+    }
+    
+    public static class ConstructorPointer<R> extends ReflectivePointer<R> {
+        
+        protected final Constructor<R> method;
+
+        protected ConstructorPointer(ConstructorPointer<R> pointer) {
+            this.method = pointer.method;
+        }
+        
+        protected ConstructorPointer(Constructor<R> ctor) {
+            this.method = ReflectUtils.access(ctor);
+        }
+        
+        @Override
+        protected GenericClass itype() {
+            return TypeFactory.construct( method.getDeclaringClass() );
+        }
+
+        @Override
+        protected List<GenericParam> iparams() {
+            return MethodInspectorVM.params(method);
+        }
+
+        @Override
+        public int paramsize() {
+            return method.getParameterTypes().length;
+        }
+                
+        @Override
+        public String name() {
+            return method.getName();
+        }
+
+        @Override
+        public GenericMethod bind(Object that) {
+            throw new UnsupportedOperationException("Constructor can't bind this.");
+        }
+        
+        @Override
+        public R call(Object... arguments) {
+            return invoke(null, arguments);
+        }
+        
+        @Override
+        public R invoke(Object that, Object... arguments) {
+            try {
+                return method.newInstance(arguments);
+            } catch (InstantiationException | IllegalAccessException | IllegalArgumentException ex) {
+                throw new InspectException(ex);
+            } catch (InvocationTargetException ex) {
+                throw new InvokeException(ex);
+            }
+        }
+        
+        @Override
+        public String toString() {
+            return ReflectFormat.signature(method);
+        }
+
+        @Override
+        public boolean canCall(Object... object) {
+            return ClassUtils.isInstance(method.getParameterTypes(), object);
+        }
+
+        @Override
+        public boolean canInvoke(Object that, Object... arguments) {
+            return (null == that) && canCall(arguments);
+        }
+        
+        public Constructor<?> reflective() {
+            return method;
+        }
+        
+    }
+    
+    public static class MethodPointer<R> extends ReflectivePointer<R> implements Serializable {
+		
+		private static final long serialVersionUID = 1L;
+        
+        protected final Method method;
+		
+		protected MethodPointer(Class<?> clazz, String name, Class[] params) {
+			try {
+				this.method = ReflectUtils.access(clazz.getDeclaredMethod(name, params));
+			} catch (ReflectiveOperationException ex) {
+				throw new IllegalArgumentException("Method or class change after serialization: " + clazz + "." + name);
+			}
+		}
+
+        protected MethodPointer(Method method) {
+            this.method = ReflectUtils.access(method);
+        }
+        
+        protected MethodPointer(MethodPointer<R> pointer) {
+            this.method = pointer.method;
+        }
+
+        @Override
+        protected GenericClass itype() {
+            return MethodUtils.typeof(method);
+        }
+
+        @Override
+        protected List<GenericParam> iparams() {
+            return MethodUtils.params(method);
+        }
+        
+        @Override
+        public int paramsize() {
+            return method.getParameterTypes().length;
+        }
+        
+        @Override
+        public String name() {
+            return method.getName();
+        }
+
+        @Override
+        public GenericMethod bind(Object that) {
+            if( MemberUtils.isStatic(method) ) {
+                throw new UnsupportedOperationException("Static method can't bind this.");
+            }
+            return new BindPointer(this, that);
+        }
+        
+        @Override
+        public R call(Object... arguments) {
+            if( MemberUtils.isStatic(method) ) {
+                return (R)invoke(null, arguments);
+            } else {
+                return (R)invoke(arguments[0], ArrayUtils.slice(arguments, 1, arguments.length));
+            }
+        }
+        
+        @Override
+        public R invoke(Object that, Object... arguments) {
+            try {
+                return (R)method.invoke(that, arguments);
+            } catch (IllegalAccessException | IllegalArgumentException ex) {
+                throw new InspectException(ex);
+            } catch (InvocationTargetException ex) {
+                throw new InvokeException(ex);
+            }
+        }
+
+        @Override
+        public boolean canCall(Object... arguments) {
+            if( MemberUtils.isStatic(method)) {
+                return ClassUtils.isInstance(method.getParameterTypes(), arguments);
+            }
+            if( !method.getDeclaringClass().isInstance(arguments[0]) ) {
+                return false;
+            }
+            Class[] array = method.getParameterTypes();
+            if( arguments.length-1 != array.length) {
+                return false;
+            }
+            for(int i=0; i<array.length; i++) {
+                if(!ClassUtils.isInstance(array[i], arguments[i+1])) {
+                    return false;
+                }
+            }
+            return true;
+        }
+
+        @Override
+        public boolean canInvoke(Object that, Object... arguments) {
+            if( !MemberUtils.isStatic(method)) {
+                if( !method.getDeclaringClass().isInstance(that) ) {
+                    return false;
+                }
+            }
+            return ClassUtils.isInstance(method.getParameterTypes(), arguments);
+        }
+
+		@Override
+		public int hashCode() {
+			return method.hashCode();
+		}
+
+		@Override
+		public boolean equals(Object object) {
+			if (object == null) {
+				return false;
+			}
+			if (getClass() != object.getClass()) {
+				return false;
+			}
+			return method.equals(((MethodPointer<?>) object).method);
+		}
+        
+        @Override
+        public String toString() {
+            return ReflectFormat.signature(method);
+        }
+        
+        public Method reflective() {
+            return method;
+        }
+		
+		private Object writeReplace() {
+			return Serializer.proxy(this, method.getDeclaringClass(), method.getName(), method.getParameterTypes());
+		}
+        
+    }
+    
+    public static class FunctionPointer<R> implements GenericMethod<R> {
+        
+        protected final Function<R,?> function;
+        
+        protected final LazyRef<List<GenericParam>> params = LazyRef.lockfree(new Callable<List<GenericParam>>() {
+            @Override
+            public List<GenericParam> call() throws Exception {
+                return MethodInspector.inobject(function).published().name("apply").first().params();
+            }
+        });
+        
+        protected final LazyRef<GenericClass> type = LazyRef.lockfree(new Callable<GenericClass>() {
+            @Override
+            public GenericClass call() throws Exception {
+                return MethodInspector.inobject(function).published().name("apply").first().type();
+            }
+        });
+
+        protected FunctionPointer(Function<R, ?> function) {
+            this.function = function;
+        }
+        
+        @Override
+        public GenericClass type() {
+            return type.get();
+        }
+
+        @Override
+        public List<GenericParam> params() {
+            return params.get();
+        }
+        
+        @Override
+        public int paramsize() {
+            return 1;
+        }
+        
+        @Override
+        public String name() {
+            return function.getClass().getName();
+        }
+
+        @Override
+        public GenericMethod bind(Object that) {
+            if(that != null) {
+                throw new UnsupportedOperationException("Function can't use 'this' argument.");
+            }
+            return this;
+        }
+        
+        @Override
+        public void run() {
+            throw new UnsupportedOperationException("Function requires exactly one argument");
+        }
+        
+        @Override
+        public R call() {
+            throw new UnsupportedOperationException("Function requires exactly one argument");
+        }
+
+        @Override
+        public R call(Object... arguments) {
+            return invoke(null, arguments);
+        }
+        
+        @Override
+        public R invoke(Object that, Object... params) {
+            if(that != null) {
+                throw new UnsupportedOperationException("Function can't use 'this' argument.");
+            }
+            return ((Function<R,Object>)function).apply(params[0]);
+        }
+
+        @Override
+        public boolean canCall(Object... arguments) {
+            if( arguments.length != 1) {
+                return false;
+            }
+            return params().get(0).type().rawType().isInstance(arguments[0]);
+        }
+
+        @Override
+        public boolean canInvoke(Object that, Object... arguments) {
+            return (null == that) && canCall(arguments);
+        }
+        
+        @Override
+        public String toString() {
+            return function.toString();
+        }
+        
+    }
+    
+    private static final class BindPointer implements GenericMethod {
+        
+        private final GenericMethod pointer;
+        private final Object that;
+
+        private BindPointer(GenericMethod pointer, Object that) {
+            this.pointer = pointer;
+            this.that = that;
+        }
+        
+        @Override
+        public String name() {
+            return pointer.name();
+        }
+
+        @Override
+        public GenericClass type() {
+            return pointer.type();
+        }
+
+        @Override
+        public List<GenericParam> params() {
+            return pointer.params();
+        }
+        
+        @Override
+        public int paramsize() {
+            return pointer.paramsize();
+        }
+
+        @Override
+        public GenericMethod bind(Object that) {
+            return new BindPointer(pointer, that);
+        }
+        
+        @Override
+        public void run() {
+            pointer.invoke(that);
+        }
+        
+        @Override
+        public Object call() {
+            return pointer.invoke(that);
+        }
+        
+        @Override
+        public Object call(Object... arguments) {
+            return pointer.invoke(that, arguments);
+        }
+
+        @Override
+        public Object invoke(Object that, Object... arguments) {
+            throw new UnsupportedOperationException("Already bound.");
+        }
+
+        @Override
+        public boolean canCall(Object... arguments) {
+            return pointer.canInvoke(that, arguments);
+        }
+
+        @Override
+        public boolean canInvoke(Object that, Object... arguments) {
+            return false;
+        }
+        
+        @Override
+        public String toString() {
+            return pointer.toString();
+        }
+        
+    }
+}

+ 338 - 325
assira1/src/test/java/net/ranides/assira/reflection/MethodFactoryTest.java

@@ -1,325 +1,338 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.reflection;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import net.ranides.assira.collection.SetUtils;
-import net.ranides.assira.generic.TypeToken;
-import net.ranides.assira.reflection.MethodFactory.ConstructorPointer;
-import net.ranides.assira.reflection.MethodFactory.FunctionPointer;
-import net.ranides.assira.reflection.MethodFactory.MethodPointer;
-import net.ranides.assira.reflection.inspect.MethodInspector;
-import net.ranides.assira.reflection.mock.ForMethodFactory;
-import net.ranides.assira.reflection.mock.ForMethodFactory.Function1;
-import net.ranides.assira.reflection.mock.ForMethodFactory.Function2;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public class MethodFactoryTest {
-    
-    public MethodFactoryTest() {
-    }
-
-    @Test
-    public void testConstructArgs() {
-        
-        Set<String> expected = SetUtils.asHashSet(
-            "[Map<String, Q> map] @ 1 -> ForMethodFactory<?>",
-            "[List<String> list] @ 1 -> ForMethodFactory<?>",
-            "[int a, int b] @ 2 -> ForMethodFactory<?>",
-            "[] @ 0 -> ForMethodFactory<?>"
-        );
-        Set<String> found = new HashSet<>();
-        
-        for( ConstructorPointer<ForMethodFactory> ctor : MethodInspector.inclass(ForMethodFactory.class).constructors().pointers()) {
-            found.add( ctor.params().toString() + " @ " + ctor.paramsize() + " -> " + ctor.type() );
-        }
-
-        assertEquals(expected, found);
-    }
-    
-    @Test
-    public void testConstructErrors() {
-        ConstructorPointer<ForMethodFactory> ctor = 
-            MethodInspector.inclass(ForMethodFactory.class).constructors().paramsMatch(0,0).first();
-       
-        try {
-            ctor.bind(null);
-            fail("UnsupportedOperationException expected");
-        } catch(UnsupportedOperationException ex) {
-            assertTrue(true);
-        }
-        try {
-            ctor.call(-5,-5);
-            fail("InvokeException expected");
-        } catch(InvokeException ex) {
-            assertTrue(ex.getCause() instanceof ArithmeticException);
-        }
-        try {
-            ctor.call(0);
-            fail("InspectException expected");
-        } catch(InspectException ex) {
-            assertTrue(ex.getCause() instanceof IllegalArgumentException);
-        }
-    }
-    
-    @Test
-    public void testConstructCan() {
-        ConstructorPointer<ForMethodFactory> ctor = 
-            MethodInspector.inclass(ForMethodFactory.class).constructors().paramsMatch(0,0).first();
-        
-        assertTrue( ctor.canCall(1,1));
-        assertFalse( ctor.canCall(1));
-        assertFalse( ctor.canCall(1,1,1));
-        assertFalse( ctor.canCall("x"));
-        
-        assertTrue( ctor.canInvoke(null, 1,1));
-        assertFalse( ctor.canInvoke(new ForMethodFactory(), 1,1));
-        assertFalse( ctor.canInvoke(null, 1));
-        assertFalse( ctor.canInvoke(null, 1,1,1));
-        assertFalse( ctor.canInvoke(null, "x"));
-    }
-    
-    @Test
-    public void testConstructInvoke() {
-        ConstructorPointer<ForMethodFactory> c1 = MethodInspector
-            .inclass(ForMethodFactory.class).constructors().params().first();
-        
-        assertEquals(77, c1.call().value);
-        assertEquals(77, c1.invoke(null).value);
-        
-        ConstructorPointer<ForMethodFactory> c2 = MethodInspector
-            .inclass(ForMethodFactory.class).constructors().paramsMatch(0,0).first();
-        
-        assertEquals(603, c2.call(6, 3).value);
-        assertEquals(603, c2.invoke(null, 6, 3).value);
-        
-        ConstructorPointer<ForMethodFactory> c3 = MethodInspector
-            .inclass(ForMethodFactory.class).constructors().params(Map.class).first();
-        ConstructorPointer<?> c4 = MethodInspector
-            .inclass(ForMethodFactory.class).constructors().params(new TypeToken<Map>(){}).first();
-        
-        assertEquals(c3.reflective(), c4.reflective());
-        assertEquals(704, c3.call(ForMethodFactory.asmap(7, 4)).value);
-        assertEquals(704, ((ForMethodFactory)c4.call(ForMethodFactory.asmap(7, 4))).value);
-        
-        // unfortunatelly, generic params matching is unsupported now :(
-        // it doesn't matter really, because you can't overload generic params anyway
-        
-//        ConstructorPointer<?> c5 = MethodInspector
-//            .inclass(ForMethodFactory.class).constructors().params(new TypeToken<Map<Float,Float>>(){}).first();
-//        assertNull(c5);
-    }
-    
-    @Test
-    public void testMethodsArgs() {
-        MethodPointer<?> m1 = MethodInspector
-            .inclass(ForMethodFactory.class).published().name("aslist").first();
-        assertEquals("[int a, int b]", m1.params().toString());
-        assertEquals("List<String>", m1.type().toString());
-        assertEquals(2, m1.paramsize());
-        
-        MethodPointer<?> m2 = MethodInspector
-            .inclass(ForMethodFactory.class).published().name("values").first();
-        assertEquals("[int a, int b, int c]", m2.params().toString());
-        assertEquals("List<Number>", m2.type().toString());
-        assertEquals(3, m2.paramsize());
-    }
-    
-    @Test
-    public void testMethodsInvoke() {
-        ForMethodFactory that = new ForMethodFactory();
-                
-        MethodPointer<?> m1 = MethodInspector
-            .inclass(ForMethodFactory.class).published().name("aslist").first();
-        assertEquals("[4, 7]", m1.call(4,7).toString());
-        assertEquals("[4, 7]", m1.invoke(null, 4,7).toString());
-        
-        MethodPointer<?> m2 = MethodInspector
-            .inclass(ForMethodFactory.class).published().name("values").first();
-        assertEquals("[4, 7, 9]", m2.call(that, 4, 7, 9).toString());
-        assertEquals("[4, 7, 9]", m2.invoke(that, 4, 7, 9).toString());
-    }
-    
-    @Test
-    public void testMethodsErrors() {
-        ForMethodFactory that = new ForMethodFactory();
-        MethodPointer<?> mstat = MethodInspector
-            .inclass(ForMethodFactory.class).published().name("aslist").first();
-        MethodPointer<?> msome = MethodInspector
-            .inclass(ForMethodFactory.class).published().name("values").first();
-        
-        try {
-            mstat.call(-5,-5);
-            fail("InspectException:IllegalArgumentException expected");
-        } catch(InvokeException ex) {
-            assertTrue(ex.getCause() instanceof ArithmeticException);
-        }
-        assertEquals("[1, 2]", mstat.invoke(that, 1, 2).toString());
-        assertEquals("[1, 2]", mstat.invoke(null, 1, 2).toString());
-        assertEquals("[1, 2]", mstat.invoke(99, 1, 2).toString());
-        
-        try {
-            mstat.call(1);
-            fail("InspectException:IllegalArgumentException expected");
-        } catch(InspectException ex) {
-            assertTrue(ex.getCause() instanceof IllegalArgumentException);
-        }
-        try {
-            mstat.invoke(1, 1);
-            fail("InspectException:IllegalArgumentException expected");
-        } catch(InspectException ex) {
-            assertTrue(ex.getCause() instanceof IllegalArgumentException);
-        }
-        
-        try {
-            msome.call(1);
-            fail("InspectException:IllegalArgumentException expected");
-        } catch(InspectException ex) {
-            assertTrue(ex.getCause() instanceof IllegalArgumentException);
-        }
-        try {
-            msome.invoke(1, 1);
-            fail("InspectException:IllegalArgumentException expected");
-        } catch(InspectException ex) {
-            assertTrue(ex.getCause() instanceof IllegalArgumentException);
-        }
-        try {
-            msome.invoke(new Object(), 1, 1);
-            fail("InspectException:IllegalArgumentException expected");
-        } catch(InspectException ex) {
-            assertTrue(ex.getCause() instanceof IllegalArgumentException);
-        }
-        try {
-            msome.invoke(null, 1, 1);
-            fail("NullPointerException expected");
-        } catch(NullPointerException ex) {
-            assertTrue(true);
-        }
-        try {
-            msome.call(null, 1, 1);
-            fail("NullPointerException expected");
-        } catch(NullPointerException ex) {
-            assertTrue(true);
-        }
-        
-        try {
-            mstat.bind(that);
-            fail("UnsupportedOperationException expected");
-        } catch(UnsupportedOperationException ex) {
-            assertTrue(true);
-        }
-
-    }
-    
-    @Test
-    public void testMethodsCan() {
-        ForMethodFactory that = new ForMethodFactory();
-        MethodPointer<?> mstat = MethodInspector
-            .inclass(ForMethodFactory.class).published().name("aslist").first();
-        MethodPointer<?> msome = MethodInspector
-            .inclass(ForMethodFactory.class).published().name("values").first();
-        
-        assertTrue( mstat.canCall(1,2));
-        assertFalse( mstat.canCall(1,2,3));
-        assertFalse( mstat.canCall(1));
-        assertFalse( mstat.canCall("1", "2"));
-        
-        // @todo (assira # 8) issue: static MethodPointer accepts any value of "this"
-        // in #invoke & #canInvoke
-        
-        assertTrue( mstat.canInvoke(null, 1,2));
-        assertTrue( mstat.canInvoke(that, 1,2)); // feature
-        assertFalse( mstat.canInvoke(null, 1,2,3));
-        assertFalse( mstat.canInvoke(null, 1));
-        assertFalse( mstat.canInvoke(null, "1", "2"));
-        
-        assertTrue( msome.canCall(that, 1,2,3));
-        assertFalse( msome.canCall(null, 1,2,3));
-        assertFalse( msome.canCall(new Object(), 1,2,3));
-        assertFalse( msome.canCall(that, 1,2,3,4));
-        assertFalse( msome.canCall(that, 1));
-        assertFalse( msome.canCall(that, "1", "2"));
-        assertFalse( msome.canCall(that, "1", "2", "3"));
-        
-        assertTrue( msome.canInvoke(that, 1,2,3));
-        assertFalse( msome.canInvoke(null, 1,2,3));
-        assertFalse( msome.canInvoke(new Object(), 1,2,3));
-        assertFalse( msome.canInvoke(that, 1,2,3,4));
-        assertFalse( msome.canInvoke(that, 1));
-        assertFalse( msome.canInvoke(that, "1", "2"));
-        assertFalse( msome.canInvoke(that, "1", "2", "3"));
-    }
-    
-    @Test
-    public void testMethodsBind() {
-        ForMethodFactory o1 = new ForMethodFactory(1,2);
-        ForMethodFactory o2 = new ForMethodFactory(3,4);
-        MethodPointer<?> msome = MethodInspector
-            .inclass(ForMethodFactory.class).published().name("current").first();
-        
-        GenericMethod<?> bind1 = msome.bind(o1);
-        GenericMethod<?> bind2 = bind1.bind(o2);
-        
-        assertNotSame(bind1, msome);
-        
-        assertEquals(msome.name(), bind1.name());
-        assertEquals(msome.params(), bind1.params());
-        assertEquals(msome.paramsize(), bind1.paramsize());
-        assertEquals(msome.type(), bind1.type());
-        assertEquals(msome.toString(), bind1.toString());
-        
-        assertFalse(bind1.canInvoke(o1));
-        assertTrue(bind1.canCall());
-        
-        assertEquals(102, bind1.call());
-        assertEquals(304, bind2.call());
-        
-        try {
-            bind1.invoke(o1);
-            fail("UnsupportedOperationException expected");
-        } catch(UnsupportedOperationException ex)  {
-            assertTrue(true);
-        }
-    }
-    
-    @Test
-    public void testFunction() {
-        
-        FunctionPointer<Integer> pointer1 = MethodFactory.wrap(new Function1());
-        FunctionPointer<List<Integer>> pointer2 = MethodFactory.wrap(new Function2());
-        
-        assertEquals("net.ranides.assira.reflection.mock.ForMethodFactory$Function1", pointer1.name());
-        assertEquals("Integer", pointer1.type().toString());
-        assertEquals("[String source]", pointer1.params().toString());
-        assertEquals(1, pointer1.paramsize());
-        
-
-        assertEquals("net.ranides.assira.reflection.mock.ForMethodFactory$Function2", pointer2.name());
-        assertEquals("List<Integer>", pointer2.type().toString());
-        assertEquals("[List<String> input]", pointer2.params().toString());
-        assertEquals(1, pointer2.paramsize());
-        
-        assertSame(pointer1, pointer1.bind(null));
-        
-        assertEquals(Arrays.asList(1,2,3), pointer2.invoke(null, Arrays.asList("1","2","3")));
-        assertEquals(Arrays.asList(1,2,3), pointer2.call(Arrays.asList("1","2","3")));
-        
-        assertTrue( pointer1.canCall("1"));
-        assertFalse( pointer1.canCall(7));
-        assertTrue( pointer1.canInvoke(null, "1"));
-        assertFalse( pointer1.canInvoke(new Object(), "1"));
-    }
-}
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/assira
+ */
+package net.ranides.assira.reflection;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import net.ranides.assira.collection.SetUtils;
+import net.ranides.assira.generic.Serializer;
+import net.ranides.assira.generic.TypeToken;
+import net.ranides.assira.reflection.MethodFactory.ConstructorPointer;
+import net.ranides.assira.reflection.MethodFactory.FunctionPointer;
+import net.ranides.assira.reflection.MethodFactory.MethodPointer;
+import net.ranides.assira.reflection.inspect.MethodInspector;
+import net.ranides.assira.reflection.mock.ForMethodFactory;
+import net.ranides.assira.reflection.mock.ForMethodFactory.Function1;
+import net.ranides.assira.reflection.mock.ForMethodFactory.Function2;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public class MethodFactoryTest {
+    
+    public MethodFactoryTest() {
+    }
+
+    @Test
+    public void testConstructArgs() {
+        
+        Set<String> expected = SetUtils.asHashSet(
+            "[Map<String, Q> map] @ 1 -> ForMethodFactory<?>",
+            "[List<String> list] @ 1 -> ForMethodFactory<?>",
+            "[int a, int b] @ 2 -> ForMethodFactory<?>",
+            "[] @ 0 -> ForMethodFactory<?>"
+        );
+        Set<String> found = new HashSet<>();
+        
+        for( ConstructorPointer<ForMethodFactory> ctor : MethodInspector.inclass(ForMethodFactory.class).constructors().pointers()) {
+            found.add( ctor.params().toString() + " @ " + ctor.paramsize() + " -> " + ctor.type() );
+        }
+
+        assertEquals(expected, found);
+    }
+    
+    @Test
+    public void testConstructErrors() {
+        ConstructorPointer<ForMethodFactory> ctor = 
+            MethodInspector.inclass(ForMethodFactory.class).constructors().paramsMatch(0,0).first();
+       
+        try {
+            ctor.bind(null);
+            fail("UnsupportedOperationException expected");
+        } catch(UnsupportedOperationException ex) {
+            assertTrue(true);
+        }
+        try {
+            ctor.call(-5,-5);
+            fail("InvokeException expected");
+        } catch(InvokeException ex) {
+            assertTrue(ex.getCause() instanceof ArithmeticException);
+        }
+        try {
+            ctor.call(0);
+            fail("InspectException expected");
+        } catch(InspectException ex) {
+            assertTrue(ex.getCause() instanceof IllegalArgumentException);
+        }
+    }
+    
+    @Test
+    public void testConstructCan() {
+        ConstructorPointer<ForMethodFactory> ctor = 
+            MethodInspector.inclass(ForMethodFactory.class).constructors().paramsMatch(0,0).first();
+        
+        assertTrue( ctor.canCall(1,1));
+        assertFalse( ctor.canCall(1));
+        assertFalse( ctor.canCall(1,1,1));
+        assertFalse( ctor.canCall("x"));
+        
+        assertTrue( ctor.canInvoke(null, 1,1));
+        assertFalse( ctor.canInvoke(new ForMethodFactory(), 1,1));
+        assertFalse( ctor.canInvoke(null, 1));
+        assertFalse( ctor.canInvoke(null, 1,1,1));
+        assertFalse( ctor.canInvoke(null, "x"));
+    }
+    
+    @Test
+    public void testConstructInvoke() {
+        ConstructorPointer<ForMethodFactory> c1 = MethodInspector
+            .inclass(ForMethodFactory.class).constructors().params().first();
+        
+        assertEquals(77, c1.call().value);
+        assertEquals(77, c1.invoke(null).value);
+        
+        ConstructorPointer<ForMethodFactory> c2 = MethodInspector
+            .inclass(ForMethodFactory.class).constructors().paramsMatch(0,0).first();
+        
+        assertEquals(603, c2.call(6, 3).value);
+        assertEquals(603, c2.invoke(null, 6, 3).value);
+        
+        ConstructorPointer<ForMethodFactory> c3 = MethodInspector
+            .inclass(ForMethodFactory.class).constructors().params(Map.class).first();
+        ConstructorPointer<?> c4 = MethodInspector
+            .inclass(ForMethodFactory.class).constructors().params(new TypeToken<Map>(){}).first();
+        
+        assertEquals(c3.reflective(), c4.reflective());
+        assertEquals(704, c3.call(ForMethodFactory.asmap(7, 4)).value);
+        assertEquals(704, ((ForMethodFactory)c4.call(ForMethodFactory.asmap(7, 4))).value);
+        
+        // unfortunatelly, generic params matching is unsupported now :(
+        // it doesn't matter really, because you can't overload generic params anyway
+        
+//        ConstructorPointer<?> c5 = MethodInspector
+//            .inclass(ForMethodFactory.class).constructors().params(new TypeToken<Map<Float,Float>>(){}).first();
+//        assertNull(c5);
+    }
+    
+    @Test
+    public void testMethodsArgs() {
+        MethodPointer<?> m1 = MethodInspector
+            .inclass(ForMethodFactory.class).published().name("aslist").first();
+        assertEquals("[int a, int b]", m1.params().toString());
+        assertEquals("List<String>", m1.type().toString());
+        assertEquals(2, m1.paramsize());
+        
+        MethodPointer<?> m2 = MethodInspector
+            .inclass(ForMethodFactory.class).published().name("values").first();
+        assertEquals("[int a, int b, int c]", m2.params().toString());
+        assertEquals("List<Number>", m2.type().toString());
+        assertEquals(3, m2.paramsize());
+    }
+    
+    @Test
+    public void testMethodsInvoke() {
+        ForMethodFactory that = new ForMethodFactory();
+                
+        MethodPointer<?> m1 = MethodInspector
+            .inclass(ForMethodFactory.class).published().name("aslist").first();
+        assertEquals("[4, 7]", m1.call(4,7).toString());
+        assertEquals("[4, 7]", m1.invoke(null, 4,7).toString());
+        
+        MethodPointer<?> m2 = MethodInspector
+            .inclass(ForMethodFactory.class).published().name("values").first();
+        assertEquals("[4, 7, 9]", m2.call(that, 4, 7, 9).toString());
+        assertEquals("[4, 7, 9]", m2.invoke(that, 4, 7, 9).toString());
+    }
+    
+    @Test
+    public void testMethodsErrors() {
+        ForMethodFactory that = new ForMethodFactory();
+        MethodPointer<?> mstat = MethodInspector
+            .inclass(ForMethodFactory.class).published().name("aslist").first();
+        MethodPointer<?> msome = MethodInspector
+            .inclass(ForMethodFactory.class).published().name("values").first();
+        
+        try {
+            mstat.call(-5,-5);
+            fail("InspectException:IllegalArgumentException expected");
+        } catch(InvokeException ex) {
+            assertTrue(ex.getCause() instanceof ArithmeticException);
+        }
+        assertEquals("[1, 2]", mstat.invoke(that, 1, 2).toString());
+        assertEquals("[1, 2]", mstat.invoke(null, 1, 2).toString());
+        assertEquals("[1, 2]", mstat.invoke(99, 1, 2).toString());
+        
+        try {
+            mstat.call(1);
+            fail("InspectException:IllegalArgumentException expected");
+        } catch(InspectException ex) {
+            assertTrue(ex.getCause() instanceof IllegalArgumentException);
+        }
+        try {
+            mstat.invoke(1, 1);
+            fail("InspectException:IllegalArgumentException expected");
+        } catch(InspectException ex) {
+            assertTrue(ex.getCause() instanceof IllegalArgumentException);
+        }
+        
+        try {
+            msome.call(1);
+            fail("InspectException:IllegalArgumentException expected");
+        } catch(InspectException ex) {
+            assertTrue(ex.getCause() instanceof IllegalArgumentException);
+        }
+        try {
+            msome.invoke(1, 1);
+            fail("InspectException:IllegalArgumentException expected");
+        } catch(InspectException ex) {
+            assertTrue(ex.getCause() instanceof IllegalArgumentException);
+        }
+        try {
+            msome.invoke(new Object(), 1, 1);
+            fail("InspectException:IllegalArgumentException expected");
+        } catch(InspectException ex) {
+            assertTrue(ex.getCause() instanceof IllegalArgumentException);
+        }
+        try {
+            msome.invoke(null, 1, 1);
+            fail("NullPointerException expected");
+        } catch(NullPointerException ex) {
+            assertTrue(true);
+        }
+        try {
+            msome.call(null, 1, 1);
+            fail("NullPointerException expected");
+        } catch(NullPointerException ex) {
+            assertTrue(true);
+        }
+        
+        try {
+            mstat.bind(that);
+            fail("UnsupportedOperationException expected");
+        } catch(UnsupportedOperationException ex) {
+            assertTrue(true);
+        }
+
+    }
+    
+    @Test
+    public void testMethodsCan() {
+        ForMethodFactory that = new ForMethodFactory();
+        MethodPointer<?> mstat = MethodInspector
+            .inclass(ForMethodFactory.class).published().name("aslist").first();
+        MethodPointer<?> msome = MethodInspector
+            .inclass(ForMethodFactory.class).published().name("values").first();
+        
+        assertTrue( mstat.canCall(1,2));
+        assertFalse( mstat.canCall(1,2,3));
+        assertFalse( mstat.canCall(1));
+        assertFalse( mstat.canCall("1", "2"));
+        
+        // @todo (assira # 8) issue: static MethodPointer accepts any value of "this"
+        // in #invoke & #canInvoke
+        
+        assertTrue( mstat.canInvoke(null, 1,2));
+        assertTrue( mstat.canInvoke(that, 1,2)); // feature
+        assertFalse( mstat.canInvoke(null, 1,2,3));
+        assertFalse( mstat.canInvoke(null, 1));
+        assertFalse( mstat.canInvoke(null, "1", "2"));
+        
+        assertTrue( msome.canCall(that, 1,2,3));
+        assertFalse( msome.canCall(null, 1,2,3));
+        assertFalse( msome.canCall(new Object(), 1,2,3));
+        assertFalse( msome.canCall(that, 1,2,3,4));
+        assertFalse( msome.canCall(that, 1));
+        assertFalse( msome.canCall(that, "1", "2"));
+        assertFalse( msome.canCall(that, "1", "2", "3"));
+        
+        assertTrue( msome.canInvoke(that, 1,2,3));
+        assertFalse( msome.canInvoke(null, 1,2,3));
+        assertFalse( msome.canInvoke(new Object(), 1,2,3));
+        assertFalse( msome.canInvoke(that, 1,2,3,4));
+        assertFalse( msome.canInvoke(that, 1));
+        assertFalse( msome.canInvoke(that, "1", "2"));
+        assertFalse( msome.canInvoke(that, "1", "2", "3"));
+    }
+    
+    @Test
+    public void testMethodsBind() {
+        ForMethodFactory o1 = new ForMethodFactory(1,2);
+        ForMethodFactory o2 = new ForMethodFactory(3,4);
+        MethodPointer<?> msome = MethodInspector
+            .inclass(ForMethodFactory.class).published().name("current").first();
+        
+        GenericMethod<?> bind1 = msome.bind(o1);
+        GenericMethod<?> bind2 = bind1.bind(o2);
+        
+        assertNotSame(bind1, msome);
+        
+        assertEquals(msome.name(), bind1.name());
+        assertEquals(msome.params(), bind1.params());
+        assertEquals(msome.paramsize(), bind1.paramsize());
+        assertEquals(msome.type(), bind1.type());
+        assertEquals(msome.toString(), bind1.toString());
+        
+        assertFalse(bind1.canInvoke(o1));
+        assertTrue(bind1.canCall());
+        
+        assertEquals(102, bind1.call());
+        assertEquals(304, bind2.call());
+        
+        try {
+            bind1.invoke(o1);
+            fail("UnsupportedOperationException expected");
+        } catch(UnsupportedOperationException ex)  {
+            assertTrue(true);
+        }
+    }
+    
+    @Test
+    public void testFunction() {
+        
+        FunctionPointer<Integer> pointer1 = MethodFactory.wrap(new Function1());
+        FunctionPointer<List<Integer>> pointer2 = MethodFactory.wrap(new Function2());
+        
+        assertEquals("net.ranides.assira.reflection.mock.ForMethodFactory$Function1", pointer1.name());
+        assertEquals("Integer", pointer1.type().toString());
+        assertEquals("[String source]", pointer1.params().toString());
+        assertEquals(1, pointer1.paramsize());
+        
+
+        assertEquals("net.ranides.assira.reflection.mock.ForMethodFactory$Function2", pointer2.name());
+        assertEquals("List<Integer>", pointer2.type().toString());
+        assertEquals("[List<String> input]", pointer2.params().toString());
+        assertEquals(1, pointer2.paramsize());
+        
+        assertSame(pointer1, pointer1.bind(null));
+        
+        assertEquals(Arrays.asList(1,2,3), pointer2.invoke(null, Arrays.asList("1","2","3")));
+        assertEquals(Arrays.asList(1,2,3), pointer2.call(Arrays.asList("1","2","3")));
+        
+        assertTrue( pointer1.canCall("1"));
+        assertFalse( pointer1.canCall(7));
+        assertTrue( pointer1.canInvoke(null, "1"));
+        assertFalse( pointer1.canInvoke(new Object(), "1"));
+    }
+	
+	@Test
+	public void testSerialization() throws IOException {
+		MethodPointer<?> m1 = MethodInspector
+            .inclass(ForMethodFactory.class).published().name("aslist").first();
+		MethodPointer<?> m2 = Serializer.copy(m1);
+		
+		assertEquals("[int a, int b]", m2.params().toString());
+        assertEquals("List<String>", m2.type().toString());
+        assertEquals(2, m2.paramsize());
+	}
+}

+ 70 - 61
assira1/src/test/java/net/ranides/assira/reflection/inspect/WebServiceInspectorTest.java

@@ -1,61 +1,70 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.reflection.inspect;
-
-import java.util.HashSet;
-import java.util.Set;
-import net.ranides.assira.collection.SetUtils;
-import net.ranides.assira.reflection.inspect.WebServiceInspector.WSMethod;
-import net.ranides.assira.reflection.mock.ForWSInspector.Service1;
-import net.ranides.assira.text.StrBuilder;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public class WebServiceInspectorTest {
-    
-    public WebServiceInspectorTest() {
-    }
-
-    @Test
-    public void testWSInspector() {
-        WebServiceInspector wsi = new WebServiceInspector(Service1.class);
-        
-        assertEquals("name1", wsi.name());
-        assertEquals("service1", wsi.service());
-        assertEquals("ns1", wsi.namespace());
-        assertEquals("999", wsi.port());
-        assertEquals("/info.wsdl", wsi.location());
-        
-        assertEquals(2, wsi.methods().size());
-        
-        Set<String> expected = SetUtils.asHashSet(
-            "opTime time [String iuser, List<Number> inumbers] {user=String, numbers=List<Number>} ret",
-            "opHello hello [String iuser, List<Number> inumbers] {iuser=String, inumbers=List<Number>} int"
-        );
-        Set<String> found = new HashSet<>();
-        for(WSMethod method : wsi.methods()) {
-            String line = new StrBuilder()
-                .append(method.name())
-                .append(" ")
-                .append(method.action())
-                .append(" ")
-                .append(method.params())
-                .append(" ")    
-                .append(method.webparams())
-                .append(" ")    
-                .append(method.resultname())
-                .toString();
-            found.add(line);
-        }
-        assertEquals(expected, found);
-    }
-    
-}
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/assira
+ */
+package net.ranides.assira.reflection.inspect;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+import net.ranides.assira.collection.SetUtils;
+import net.ranides.assira.generic.Serializer;
+import net.ranides.assira.reflection.inspect.WebServiceInspector.WSMethod;
+import net.ranides.assira.reflection.mock.ForWSInspector.Service1;
+import net.ranides.assira.text.StrBuilder;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public class WebServiceInspectorTest {
+    
+    public WebServiceInspectorTest() {
+    }
+
+    @Test
+    public void testWSInspector() {
+        WebServiceInspector wsi = new WebServiceInspector(Service1.class);
+        
+        assertEquals("name1", wsi.name());
+        assertEquals("service1", wsi.service());
+        assertEquals("ns1", wsi.namespace());
+        assertEquals("999", wsi.port());
+        assertEquals("/info.wsdl", wsi.location());
+        
+        assertEquals(2, wsi.methods().size());
+        
+        Set<String> expected = SetUtils.asHashSet(
+            "opTime time [String iuser, List<Number> inumbers] {user=String, numbers=List<Number>} ret",
+            "opHello hello [String iuser, List<Number> inumbers] {iuser=String, inumbers=List<Number>} int"
+        );
+        Set<String> found = new HashSet<>();
+        for(WSMethod method : wsi.methods()) {
+            String line = new StrBuilder()
+                .append(method.name())
+                .append(" ")
+                .append(method.action())
+                .append(" ")
+                .append(method.params())
+                .append(" ")    
+                .append(method.webparams())
+                .append(" ")    
+                .append(method.resultname())
+                .toString();
+            found.add(line);
+        }
+        assertEquals(expected, found);
+    }
+	
+	@Test
+	public void testSerialization() throws IOException {
+		WebServiceInspector wsi = new WebServiceInspector(Service1.class);
+		WSMethod<?> m = Serializer.copy( wsi.methods().get(0) );
+		assertNotNull(m);
+	}
+    
+}