You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2014/03/26 21:20:03 UTC
svn commit: r1582033 [3/5] - in /commons/proper/proxy/trunk: ./ asm4/
asm4/src/main/java/org/apache/commons/proxy2/asm4/
asm4/src/test/java/org/apache/commons/proxy2/asm4/
build-tools/src/main/resources/org/apache/commons/proxy2/ cglib/
cglib/src/main/...
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/CloningProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/CloningProvider.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/CloningProvider.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/CloningProvider.java Wed Mar 26 20:20:01 2014
@@ -17,17 +17,17 @@
package org.apache.commons.proxy2.provider;
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.reflect.MethodUtils;
import org.apache.commons.proxy2.ObjectProvider;
import org.apache.commons.proxy2.exception.ObjectProviderException;
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-
/**
* Merely calls <code>clone()</code> (reflectively) on the given {@link Cloneable} object.
- *
+ *
* @author James Carman
* @since 1.0
*/
@@ -38,35 +38,33 @@ public class CloningProvider<T extends C
*/
private static final long serialVersionUID = 1L;
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Fields
+ //******************************************************************************************************************
private final T cloneable;
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Constructors
+ //******************************************************************************************************************
/**
- * Constructs a provider which returns clone copies of the specified {@link Cloneable}
- * object.
- *
- * @param cloneable the object to clone
+ * Constructs a provider which returns clone copies of the specified {@link Cloneable} object.
+ *
+ * @param cloneable
+ * the object to clone
*/
public CloningProvider(T cloneable)
{
Validate.notNull(cloneable, "Cloneable object cannot be null.");
- Validate.isTrue(
- MethodUtils.getAccessibleMethod(cloneable.getClass(), "clone") != null,
- String.format("Class %s does not override clone() method as public.",
- cloneable.getClass().getName()));
+ Validate.isTrue(MethodUtils.getAccessibleMethod(cloneable.getClass(), "clone") != null,
+ String.format("Class %s does not override clone() method as public.", cloneable.getClass().getName()));
this.cloneable = cloneable;
}
- //**********************************************************************************************************************
+ //******************************************************************************************************************
// ObjectProvider Implementation
- //**********************************************************************************************************************
+ //******************************************************************************************************************
/**
* {@inheritDoc}
@@ -80,24 +78,20 @@ public class CloningProvider<T extends C
}
catch (IllegalAccessException e)
{
- throw new ObjectProviderException(
- "Class " + cloneable.getClass().getName() + " does not have a public clone() method.", e);
+ throw new ObjectProviderException("Class " + cloneable.getClass().getName()
+ + " does not have a public clone() method.", e);
}
catch (InvocationTargetException e)
{
- throw new ObjectProviderException(
- "Attempt to clone object of type " + cloneable.getClass().getName() + " threw an exception.", e);
+ throw new ObjectProviderException("Attempt to clone object of type " + cloneable.getClass().getName()
+ + " threw an exception.", e);
}
catch (NoSuchMethodException e)
{
- throw new ObjectProviderException(
- String.format("Class %s does not have a clone() method (should never happen).", cloneable.getClass().getName()), e);
+ throw new ObjectProviderException(String.format(
+ "Class %s does not have a clone() method (should never happen).", cloneable.getClass().getName()),
+ e);
}
}
-//**********************************************************************************************************************
-// Getter/Setter Methods
-//**********************************************************************************************************************
-
-
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ConstantProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ConstantProvider.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ConstantProvider.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ConstantProvider.java Wed Mar 26 20:20:01 2014
@@ -17,13 +17,13 @@
package org.apache.commons.proxy2.provider;
-import org.apache.commons.proxy2.ObjectProvider;
-
import java.io.Serializable;
+import org.apache.commons.proxy2.ObjectProvider;
+
/**
* Always returns the same object.
- *
+ *
* @author James Carman
* @since 1.0
*/
@@ -32,28 +32,29 @@ public class ConstantProvider<T> impleme
/** Serialization version */
private static final long serialVersionUID = 1L;
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Fields
+ //******************************************************************************************************************
private final T constant;
- //**********************************************************************************************************************
- // Constructors
- //**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Constructors
+ //******************************************************************************************************************
/**
* Create a new ConstantProvider instance.
+ *
* @param constant
*/
- public ConstantProvider( T constant )
+ public ConstantProvider(T constant)
{
this.constant = constant;
}
- //**********************************************************************************************************************
- // ObjectProvider Implementation
- //**********************************************************************************************************************
+ //******************************************************************************************************************
+ // ObjectProvider Implementation
+ //******************************************************************************************************************
/**
* {@inheritDoc}
@@ -62,4 +63,4 @@ public class ConstantProvider<T> impleme
{
return constant;
}
-}
+}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/NullProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/NullProvider.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/NullProvider.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/NullProvider.java Wed Mar 26 20:20:01 2014
@@ -19,7 +19,7 @@ package org.apache.commons.proxy2.provid
/**
* Always returns null.
- *
+ *
* @author James Carman
* @since 1.0
*/
@@ -28,9 +28,9 @@ public class NullProvider<T> extends Con
/** Serialization version */
private static final long serialVersionUID = 1L;
- //**********************************************************************************************************************
- // Constructors
- //**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Constructors
+ //******************************************************************************************************************
/**
* Create a new NullProvider instance.
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ObjectProviderUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ObjectProviderUtils.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ObjectProviderUtils.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ObjectProviderUtils.java Wed Mar 26 20:20:01 2014
@@ -21,9 +21,9 @@ import org.apache.commons.proxy2.ObjectP
public final class ObjectProviderUtils
{
-//----------------------------------------------------------------------------------------------------------------------
-// Static Methods
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Static Methods
+ //******************************************************************************************************************
public static <T> ObjectProvider<T> bean(Class<T> beanClass)
{
@@ -50,12 +50,11 @@ public final class ObjectProviderUtils
return new SingletonProvider<T>(inner);
}
-//----------------------------------------------------------------------------------------------------------------------
-// Constructors
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Constructors
+ //******************************************************************************************************************
private ObjectProviderUtils()
{
-
}
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ProviderDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ProviderDecorator.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ProviderDecorator.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ProviderDecorator.java Wed Mar 26 20:20:01 2014
@@ -20,31 +20,31 @@ package org.apache.commons.proxy2.provid
import org.apache.commons.proxy2.ObjectProvider;
/**
- * Returns the result of the inner {@link ObjectProvider provider}. Subclasses can override the {@link #getObject()}
+ * Returns the result of the inner {@link ObjectProvider provider}. Subclasses can override the {@link #getObject()}
* method and decorate what comes back from the inner provider in some way (by {@link SingletonProvider caching it} for
* example).
- *
+ *
* @author James Carman
* @since 1.0
*/
public class ProviderDecorator<T> implements ObjectProvider<T>
{
-//----------------------------------------------------------------------------------------------------------------------
-// Fields
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Fields
+ //******************************************************************************************************************
/**
* The wrapped {@link ObjectProvider}.
*/
private ObjectProvider<? extends T> inner;
-//----------------------------------------------------------------------------------------------------------------------
-// Constructors
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Constructors
+ //******************************************************************************************************************
/**
* Create a new ProviderDecorator instance.
- *
+ *
* @param inner
*/
public ProviderDecorator(ObjectProvider<? extends T> inner)
@@ -52,9 +52,9 @@ public class ProviderDecorator<T> implem
this.inner = inner;
}
-//----------------------------------------------------------------------------------------------------------------------
-// ObjectProvider Implementation
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // ObjectProvider Implementation
+ //******************************************************************************************************************
/**
* {@inheritDoc}
@@ -64,9 +64,9 @@ public class ProviderDecorator<T> implem
return inner.getObject();
}
-//----------------------------------------------------------------------------------------------------------------------
-// Getter/Setter Methods
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Getter/Setter Methods
+ //******************************************************************************************************************
protected ObjectProvider<? extends T> getInner()
{
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/SingletonProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/SingletonProvider.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/SingletonProvider.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/SingletonProvider.java Wed Mar 26 20:20:01 2014
@@ -22,25 +22,25 @@ import org.apache.commons.proxy2.ObjectP
/**
* Wraps another object provider, making sure to only call it once, returning the value returned from the wrapped
* provider on all subsequent invocations.
- *
+ *
* @author James Carman
* @since 1.0
*/
public class SingletonProvider<T> extends ProviderDecorator<T>
{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Fields
+ //******************************************************************************************************************
private T instance;
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Constructors
+ //******************************************************************************************************************
/**
* Create a new SingletonProvider instance.
- *
+ *
* @param inner
*/
public SingletonProvider(ObjectProvider<? extends T> inner)
@@ -48,9 +48,9 @@ public class SingletonProvider<T> extend
super(inner);
}
-//**********************************************************************************************************************
-// ObjectProvider Implementation
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // ObjectProvider Implementation
+ //******************************************************************************************************************
/**
* {@inheritDoc}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/ReadResolve.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/ReadResolve.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/ReadResolve.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/ReadResolve.java Wed Mar 26 20:20:01 2014
@@ -27,6 +27,7 @@ public interface ReadResolve extends Ser
{
/**
* Get the deserialized version of this {@link Serializable}.
+ *
* @return Object
*/
Object readResolve();
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/WriteReplace.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/WriteReplace.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/WriteReplace.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/WriteReplace.java Wed Mar 26 20:20:01 2014
@@ -27,6 +27,7 @@ public interface WriteReplace extends Se
{
/**
* Get the serialized version of this object.
+ *
* @return Object
*/
Object writeReplace();
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/package-info.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/package-info.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/package-info.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/package-info.java Wed Mar 26 20:20:01 2014
@@ -34,4 +34,5 @@
* equivalent proxy object, which probably implies some form of {@code static} access.
*/
package org.apache.commons.proxy2.serialization;
-import java.io.Serializable;
+
+
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationBuilder.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationBuilder.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationBuilder.java Wed Mar 26 20:20:01 2014
@@ -25,6 +25,8 @@ import java.lang.reflect.Proxy;
import java.util.Map;
import org.apache.commons.lang3.AnnotationUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.reflect.TypeUtils;
import org.apache.commons.proxy2.Interceptor;
@@ -79,11 +81,8 @@ public class AnnotationBuilder<A extends
}
- private static class ReflectionInvocation implements Invocation, Serializable
+ private static class ReflectionInvocation implements Invocation
{
- /** Serialization version */
- private static final long serialVersionUID = 1L;
-
private final Method method;
private final Object[] arguments;
private final Object target;
@@ -91,7 +90,7 @@ public class AnnotationBuilder<A extends
public ReflectionInvocation(Object target, Method method, Object[] arguments)
{
this.method = method;
- this.arguments = (arguments == null ? ProxyUtils.EMPTY_ARGUMENTS : arguments);
+ this.arguments = ObjectUtils.defaultIfNull(ArrayUtils.clone(arguments), ProxyUtils.EMPTY_ARGUMENTS);
this.target = target;
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationInvoker.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationInvoker.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationInvoker.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationInvoker.java Wed Mar 26 20:20:01 2014
@@ -29,10 +29,11 @@ public final class AnnotationInvoker imp
public static final AnnotationInvoker INSTANCE = new AnnotationInvoker();
@Override
- public Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable {
+ public Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable
+ {
final Object result = method.getDefaultValue();
- return result == null && method.getReturnType().isPrimitive() ? ProxyUtils
- .nullValue(method.getReturnType()) : result;
+ return result == null && method.getReturnType().isPrimitive() ? ProxyUtils.nullValue(method.getReturnType())
+ : result;
}
-
+
}
\ No newline at end of file
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationTrainer.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationTrainer.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationTrainer.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationTrainer.java Wed Mar 26 20:20:01 2014
@@ -21,11 +21,13 @@ import java.lang.annotation.Annotation;
public abstract class AnnotationTrainer<A extends Annotation> extends BaseAnnotationTrainer<AnnotationTrainer<A>, A>
{
- protected AnnotationTrainer() {
+ protected AnnotationTrainer()
+ {
super();
}
- protected AnnotationTrainer(Class<A> traineeType) {
+ protected AnnotationTrainer(Class<A> traineeType)
+ {
super(traineeType);
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/BaseTrainer.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/BaseTrainer.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/BaseTrainer.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/BaseTrainer.java Wed Mar 26 20:20:01 2014
@@ -32,19 +32,18 @@ import org.apache.commons.proxy2.interce
public abstract class BaseTrainer<S extends BaseTrainer<S, T>, T>
{
- // ----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
// Fields
- // ----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
public final Class<T> traineeType;
- // ----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
// Constructors
- // ----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
/**
- * Create a new {@link BaseTrainer} instance. This constructor should only
- * be called by classes that explicitly assign the T parameter in the class
- * definition. This should include basically any runtime-usable class.
+ * Create a new {@link BaseTrainer} instance. This constructor should only be called by classes that explicitly
+ * assign the T parameter in the class definition. This should include basically any runtime-usable class.
*/
protected BaseTrainer()
{
@@ -67,15 +66,15 @@ public abstract class BaseTrainer<S exte
this.traineeType = resolvedVariable;
}
- // ----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
// Abstract Methods
- // ----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
protected abstract void train(T trainee);
- // ----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
// Other Methods
- // ----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
protected <R> R any(Class<R> type)
{
@@ -176,9 +175,9 @@ public abstract class BaseTrainer<S exte
return (S) this;
}
- // ----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
// Inner Classes
- // ----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
protected abstract class BaseWhen<R>
{
@@ -285,9 +284,8 @@ public abstract class BaseTrainer<S exte
}
/**
- * Intermediate result of a when(Class) call. Provided because it is such a
- * common case to have a mismatch between a declared Class<?> return type
- * and the bound parameter of a class literal.
+ * Intermediate result of a when(Class) call. Provided because it is such a common case to have a mismatch between a
+ * declared Class<?> return type and the bound parameter of a class literal.
*/
protected class WhenClass extends BaseWhen<Class<?>>
{
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/StubBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/StubBuilder.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/StubBuilder.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/StubBuilder.java Wed Mar 26 20:20:01 2014
@@ -33,18 +33,18 @@ import org.apache.commons.proxy2.provide
public class StubBuilder<T> implements Builder<T>
{
-//----------------------------------------------------------------------------------------------------------------------
-// Fields
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Fields
+ //******************************************************************************************************************
private final ProxyFactory proxyFactory;
private final T target;
private final SwitchInterceptor switchInterceptor = new SwitchInterceptor();
private final Set<Class<?>> proxyTypes = new HashSet<Class<?>>();
-//----------------------------------------------------------------------------------------------------------------------
-// Constructors
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Constructors
+ //******************************************************************************************************************
public StubBuilder(ProxyFactory proxyFactory, Class<T> type)
{
@@ -57,7 +57,7 @@ public class StubBuilder<T> implements B
this.target = proxyFactory.createInvokerProxy(invoker, type);
this.proxyTypes.add(Validate.notNull(type));
}
-
+
public StubBuilder(ProxyFactory proxyFactory, Class<T> type, ObjectProvider<? extends T> provider)
{
this.proxyFactory = proxyFactory;
@@ -72,9 +72,9 @@ public class StubBuilder<T> implements B
this.proxyTypes.add(Validate.notNull(type));
}
-//----------------------------------------------------------------------------------------------------------------------
-// Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Other Methods
+ //******************************************************************************************************************
public T build()
{
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/StubInterceptorBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/StubInterceptorBuilder.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/StubInterceptorBuilder.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/StubInterceptorBuilder.java Wed Mar 26 20:20:01 2014
@@ -23,25 +23,25 @@ import org.apache.commons.proxy2.interce
public class StubInterceptorBuilder
{
-//----------------------------------------------------------------------------------------------------------------------
-// Fields
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Fields
+ //******************************************************************************************************************
private final ProxyFactory proxyFactory;
private final SwitchInterceptor interceptor = new SwitchInterceptor();
-//----------------------------------------------------------------------------------------------------------------------
-// Constructors
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Constructors
+ //******************************************************************************************************************
public StubInterceptorBuilder(ProxyFactory proxyFactory)
{
this.proxyFactory = proxyFactory;
}
-//----------------------------------------------------------------------------------------------------------------------
-// Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Other Methods
+ //******************************************************************************************************************
public Interceptor build()
{
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/Trainer.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/Trainer.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/Trainer.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/Trainer.java Wed Mar 26 20:20:01 2014
@@ -17,13 +17,16 @@
package org.apache.commons.proxy2.stub;
-public abstract class Trainer<T> extends BaseTrainer<Trainer<T>, T> {
+public abstract class Trainer<T> extends BaseTrainer<Trainer<T>, T>
+{
- protected Trainer() {
+ protected Trainer()
+ {
super();
}
- protected Trainer(Class<T> traineeType) {
+ protected Trainer(Class<T> traineeType)
+ {
super(traineeType);
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/TrainingContext.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/TrainingContext.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/TrainingContext.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/TrainingContext.java Wed Mar 26 20:20:01 2014
@@ -16,23 +16,31 @@
*/
package org.apache.commons.proxy2.stub;
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Deque;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
+
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.proxy2.*;
+import org.apache.commons.proxy2.Interceptor;
+import org.apache.commons.proxy2.Invocation;
+import org.apache.commons.proxy2.Invoker;
+import org.apache.commons.proxy2.ProxyFactory;
+import org.apache.commons.proxy2.ProxyUtils;
import org.apache.commons.proxy2.interceptor.SwitchInterceptor;
import org.apache.commons.proxy2.interceptor.matcher.ArgumentMatcher;
import org.apache.commons.proxy2.interceptor.matcher.InvocationMatcher;
import org.apache.commons.proxy2.invoker.NullInvoker;
import org.apache.commons.proxy2.invoker.RecordedInvocation;
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.util.*;
-
class TrainingContext
{
-//----------------------------------------------------------------------------------------------------------------------
-// Fields
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Fields
+ //******************************************************************************************************************
private static final ThreadLocal<TrainingContext> TRAINING_CONTEXT = new ThreadLocal<TrainingContext>();
@@ -42,9 +50,9 @@ class TrainingContext
private final TrainingContext resume;
-//----------------------------------------------------------------------------------------------------------------------
-// Static Methods
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Static Methods
+ //******************************************************************************************************************
static TrainingContext current()
{
@@ -58,9 +66,9 @@ class TrainingContext
return context;
}
-//----------------------------------------------------------------------------------------------------------------------
-// Constructors
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Constructors
+ //******************************************************************************************************************
private TrainingContext(ProxyFactory proxyFactory)
{
@@ -68,9 +76,9 @@ class TrainingContext
this.resume = current();
}
-//----------------------------------------------------------------------------------------------------------------------
-// Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Other Methods
+ //******************************************************************************************************************
void part()
{
@@ -100,12 +108,10 @@ class TrainingContext
<T> T pop(Invoker invoker)
{
final TrainingContextFrame<?> frame = frameDeque.pop();
- return proxyFactory.createInterceptorProxy(
- proxyFactory.createInvokerProxy(invoker, frame.type),
- frame.stubInterceptor,
- frame.type);
+ return proxyFactory.createInterceptorProxy(proxyFactory.createInvokerProxy(invoker, frame.type),
+ frame.stubInterceptor, frame.type);
}
-
+
<T> T push(Class<T> type)
{
return push(type, new SwitchInterceptor());
@@ -129,9 +135,9 @@ class TrainingContext
peek().then(interceptor);
}
-//----------------------------------------------------------------------------------------------------------------------
-// Inner Classes
-//----------------------------------------------------------------------------------------------------------------------
+ //******************************************************************************************************************
+ // Inner Classes
+ //******************************************************************************************************************
private static final class ExactArgumentsMatcher implements InvocationMatcher
{
@@ -145,8 +151,8 @@ class TrainingContext
@Override
public boolean matches(Invocation invocation)
{
- return invocation.getMethod().equals(recordedInvocation.getInvokedMethod()) &&
- Arrays.deepEquals(invocation.getArguments(), recordedInvocation.getArguments());
+ return invocation.getMethod().equals(recordedInvocation.getInvokedMethod())
+ && Arrays.deepEquals(invocation.getArguments(), recordedInvocation.getArguments());
}
}
@@ -164,8 +170,8 @@ class TrainingContext
@Override
public boolean matches(Invocation invocation)
{
- return invocation.getMethod().equals(recordedInvocation.getInvokedMethod()) &&
- allArgumentsMatch(invocation.getArguments());
+ return invocation.getMethod().equals(recordedInvocation.getInvokedMethod())
+ && allArgumentsMatch(invocation.getArguments());
}
private boolean allArgumentsMatch(Object[] arguments)
@@ -219,7 +225,8 @@ class TrainingContext
void methodInvoked(Method method, Object[] arguments)
{
- final ArgumentMatcher<?>[] matchersArray = argumentMatchers.toArray(new ArgumentMatcher[argumentMatchers.size()]);
+ final ArgumentMatcher<?>[] matchersArray = argumentMatchers.toArray(new ArgumentMatcher[argumentMatchers
+ .size()]);
argumentMatchers.clear();
final RecordedInvocation invocation = new RecordedInvocation(method, arguments);
if (ArrayUtils.isEmpty(matchersArray))
Modified: commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/AbstractProxyFactoryTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/AbstractProxyFactoryTestCase.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/AbstractProxyFactoryTestCase.java (original)
+++ commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/AbstractProxyFactoryTestCase.java Wed Mar 26 20:20:01 2014
@@ -17,18 +17,34 @@
package org.apache.commons.proxy2;
-import org.apache.commons.proxy2.provider.BeanProvider;
-import org.apache.commons.proxy2.provider.ConstantProvider;
-import org.apache.commons.proxy2.provider.SingletonProvider;
-import org.apache.commons.proxy2.util.*;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Method;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ServiceLoader;
+import java.util.SortedSet;
+import java.util.TreeSet;
-import static org.junit.Assert.*;
+import org.apache.commons.proxy2.provider.BeanProvider;
+import org.apache.commons.proxy2.provider.ConstantProvider;
+import org.apache.commons.proxy2.provider.SingletonProvider;
+import org.apache.commons.proxy2.util.AbstractTestCase;
+import org.apache.commons.proxy2.util.DuplicateEcho;
+import org.apache.commons.proxy2.util.Echo;
+import org.apache.commons.proxy2.util.EchoImpl;
+import org.apache.commons.proxy2.util.SuffixInterceptor;
+import org.junit.Test;
/**
* @author James Carman
@@ -37,17 +53,17 @@ import static org.junit.Assert.*;
@SuppressWarnings("serial")
public abstract class AbstractProxyFactoryTestCase extends AbstractTestCase
{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Fields
+ //**********************************************************************************************************************
- private static final Class<?>[] ECHO_ONLY = new Class[]{Echo.class};
+ private static final Class<?>[] ECHO_ONLY = new Class[] { Echo.class };
protected final ProxyFactory factory;
- private static final Class<?>[] COMPARABLE_ONLY = new Class[]{Comparable.class};
+ private static final Class<?>[] COMPARABLE_ONLY = new Class[] { Comparable.class };
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Constructors
+ //**********************************************************************************************************************
protected AbstractProxyFactoryTestCase()
{
@@ -64,9 +80,9 @@ public abstract class AbstractProxyFacto
}
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Other Methods
+ //**********************************************************************************************************************
private ObjectProvider<Echo> createSingletonEcho()
{
@@ -98,10 +114,8 @@ public abstract class AbstractProxyFacto
public void testInterceptorEquals()
{
final Date date = new Date();
- final Comparable<?> proxy1 = factory.createInterceptorProxy(date,
- new NoOpMethodInterceptor(), COMPARABLE_ONLY);
- final Comparable<?> proxy2 = factory.createInterceptorProxy(date,
- new NoOpMethodInterceptor(), COMPARABLE_ONLY);
+ final Comparable<?> proxy1 = factory.createInterceptorProxy(date, new NoOpMethodInterceptor(), COMPARABLE_ONLY);
+ final Comparable<?> proxy2 = factory.createInterceptorProxy(date, new NoOpMethodInterceptor(), COMPARABLE_ONLY);
assertEquals(proxy1, proxy1);
assertFalse(proxy1.equals(proxy2));
assertFalse(proxy2.equals(proxy1));
@@ -121,10 +135,8 @@ public abstract class AbstractProxyFacto
public void testDelegatorEquals() throws Exception
{
final Date date = new Date();
- final Comparable<?> proxy1 = factory.createDelegatorProxy(new ConstantProvider<Date>(date),
- COMPARABLE_ONLY);
- final Comparable<?> proxy2 = factory.createDelegatorProxy(new ConstantProvider<Date>(date),
- COMPARABLE_ONLY);
+ final Comparable<?> proxy1 = factory.createDelegatorProxy(new ConstantProvider<Date>(date), COMPARABLE_ONLY);
+ final Comparable<?> proxy2 = factory.createDelegatorProxy(new ConstantProvider<Date>(date), COMPARABLE_ONLY);
assertEquals(proxy1, proxy1);
assertFalse(proxy1.equals(proxy2));
assertFalse(proxy2.equals(proxy1));
@@ -183,9 +195,10 @@ public abstract class AbstractProxyFacto
public void testDelegatingProxyInterfaceOrder()
{
final Echo echo = factory.createDelegatorProxy(createSingletonEcho(), Echo.class, DuplicateEcho.class);
- final List<Class<?>> expected = new LinkedList<Class<?>>(Arrays.<Class<?>>asList(Echo.class, DuplicateEcho.class));
+ final List<Class<?>> expected = new LinkedList<Class<?>>(Arrays.<Class<?>> asList(Echo.class,
+ DuplicateEcho.class));
final List<Class<?>> actual = new LinkedList<Class<?>>(Arrays.asList(echo.getClass().getInterfaces()));
- actual.retainAll(expected); // Doesn't alter order!
+ actual.retainAll(expected); // Doesn't alter order!
assertEquals(expected, actual);
}
@@ -229,7 +242,8 @@ public abstract class AbstractProxyFacto
@Test
public void testInterfaceHierarchies()
{
- final SortedSet<String> set = factory.createDelegatorProxy(new ConstantProvider<SortedSet<String>>(new TreeSet<String>()), SortedSet.class);
+ final SortedSet<String> set = factory.createDelegatorProxy(new ConstantProvider<SortedSet<String>>(
+ new TreeSet<String>()), SortedSet.class);
set.add("Hello");
}
@@ -337,9 +351,9 @@ public abstract class AbstractProxyFacto
proxy.echo();
}
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Inner Classes
+ //**********************************************************************************************************************
private static class ChangeArgumentInterceptor implements Interceptor
{
Modified: commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/AbstractSubclassingProxyFactoryTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/AbstractSubclassingProxyFactoryTestCase.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/AbstractSubclassingProxyFactoryTestCase.java (original)
+++ commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/AbstractSubclassingProxyFactoryTestCase.java Wed Mar 26 20:20:01 2014
@@ -17,6 +17,12 @@
package org.apache.commons.proxy2;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+
import org.apache.commons.proxy2.exception.ProxyFactoryException;
import org.apache.commons.proxy2.invoker.NullInvoker;
import org.apache.commons.proxy2.provider.ConstantProvider;
@@ -25,10 +31,6 @@ import org.apache.commons.proxy2.util.Ec
import org.apache.commons.proxy2.util.EchoImpl;
import org.junit.Test;
-import java.util.Date;
-
-import static org.junit.Assert.*;
-
/**
* @author James Carman
* @since 1.0
@@ -36,27 +38,27 @@ import static org.junit.Assert.*;
@SuppressWarnings("serial")
public abstract class AbstractSubclassingProxyFactoryTestCase extends AbstractProxyFactoryTestCase
{
-//----------------------------------------------------------------------------------------------------------------------
-// Fields
-//----------------------------------------------------------------------------------------------------------------------
-
- private static final Class<?>[] DATE_ONLY = new Class[]{Date.class};
-
-//----------------------------------------------------------------------------------------------------------------------
-// Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------------------------------------------------
+ // Fields
+ //----------------------------------------------------------------------------------------------------------------------
+
+ private static final Class<?>[] DATE_ONLY = new Class[] { Date.class };
+
+ //----------------------------------------------------------------------------------------------------------------------
+ // Other Methods
+ //----------------------------------------------------------------------------------------------------------------------
@Test
public void testCanProxy()
{
- assertTrue(factory.canProxy(new Class[]{Echo.class}));
- assertTrue(factory.canProxy(new Class[]{EchoImpl.class}));
- assertFalse(factory.canProxy(new Class[]{FinalEcho.class}));
- assertTrue(factory.canProxy(new Class[]{FinalMethodEcho.class, Echo.class}));
- assertFalse(factory.canProxy(new Class[]{NoDefaultConstructorEcho.class}));
- assertTrue(factory.canProxy(new Class[]{ProtectedConstructorEcho.class}));
- assertFalse(factory.canProxy(new Class[]{InvisibleEcho.class}));
- assertFalse(factory.canProxy(new Class[]{Echo.class, EchoImpl.class, String.class}));
+ assertTrue(factory.canProxy(new Class[] { Echo.class }));
+ assertTrue(factory.canProxy(new Class[] { EchoImpl.class }));
+ assertFalse(factory.canProxy(new Class[] { FinalEcho.class }));
+ assertTrue(factory.canProxy(new Class[] { FinalMethodEcho.class, Echo.class }));
+ assertFalse(factory.canProxy(new Class[] { NoDefaultConstructorEcho.class }));
+ assertTrue(factory.canProxy(new Class[] { ProtectedConstructorEcho.class }));
+ assertFalse(factory.canProxy(new Class[] { InvisibleEcho.class }));
+ assertFalse(factory.canProxy(new Class[] { Echo.class, EchoImpl.class, String.class }));
}
@Test
@@ -64,9 +66,9 @@ public abstract class AbstractSubclassin
{
final EqualsEcho echo = new EqualsEcho("text");
final Echo proxy1 = factory.createDelegatorProxy(new ConstantProvider<Echo>(echo),
- new Class[]{EqualsEcho.class});
+ new Class[] { EqualsEcho.class });
final Echo proxy2 = factory.createDelegatorProxy(new ConstantProvider<Echo>(echo),
- new Class[]{EqualsEcho.class});
+ new Class[] { EqualsEcho.class });
assertEquals(proxy1, proxy1);
assertFalse(proxy1.equals(proxy2));
assertFalse(proxy2.equals(proxy1));
@@ -75,15 +77,15 @@ public abstract class AbstractSubclassin
@Test(expected = ProxyFactoryException.class)
public void testDelegatorWithMultipleSuperclasses()
{
- factory.createDelegatorProxy(new ConstantProvider<EchoImpl>(new EchoImpl()),
- new Class[]{EchoImpl.class, String.class});
+ factory.createDelegatorProxy(new ConstantProvider<EchoImpl>(new EchoImpl()), new Class[] { EchoImpl.class,
+ String.class });
}
@Test
public void testDelegatorWithSuperclass()
{
- final Echo echo = factory
- .createDelegatorProxy(new ConstantProvider<EchoImpl>(new EchoImpl()), new Class[]{Echo.class, EchoImpl.class});
+ final Echo echo = factory.createDelegatorProxy(new ConstantProvider<EchoImpl>(new EchoImpl()), new Class[] {
+ Echo.class, EchoImpl.class });
assertTrue(echo instanceof EchoImpl);
}
@@ -91,10 +93,10 @@ public abstract class AbstractSubclassin
public void testInterceptorEquals()
{
final EqualsEcho echo = new EqualsEcho("text");
- final Echo proxy1 = factory.createInterceptorProxy(echo,
- new NoOpMethodInterceptor(), new Class[]{EqualsEcho.class});
- final Echo proxy2 = factory.createInterceptorProxy(echo,
- new NoOpMethodInterceptor(), new Class[]{EqualsEcho.class});
+ final Echo proxy1 = factory.createInterceptorProxy(echo, new NoOpMethodInterceptor(),
+ new Class[] { EqualsEcho.class });
+ final Echo proxy2 = factory.createInterceptorProxy(echo, new NoOpMethodInterceptor(),
+ new Class[] { EqualsEcho.class });
assertEquals(proxy1, proxy1);
assertFalse(proxy1.equals(proxy2));
assertFalse(proxy2.equals(proxy1));
@@ -103,23 +105,22 @@ public abstract class AbstractSubclassin
@Test(expected = ProxyFactoryException.class)
public void testInterceptorWithMultipleSuperclasses()
{
- factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(),
- new Class[]{EchoImpl.class, String.class});
+ factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), new Class[] { EchoImpl.class,
+ String.class });
}
@Test
public void testInterceptorWithSuperclass()
{
- final Echo echo = factory
- .createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), new Class[]{Echo.class, EchoImpl.class});
+ final Echo echo = factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), new Class[] {
+ Echo.class, EchoImpl.class });
assertTrue(echo instanceof EchoImpl);
}
@Test(expected = ProxyFactoryException.class)
public void testInvocationHandlerWithMultipleSuperclasses()
{
- factory.createInvokerProxy(new NullInvoker(),
- new Class[]{EchoImpl.class, String.class});
+ factory.createInvokerProxy(new NullInvoker(), new Class[] { EchoImpl.class, String.class });
}
@Test
@@ -135,15 +136,14 @@ public abstract class AbstractSubclassin
@Test
public void testInvokerWithSuperclass()
{
- final Echo echo = factory
- .createInvokerProxy(new NullInvoker(), new Class[]{Echo.class, EchoImpl.class});
+ final Echo echo = factory.createInvokerProxy(new NullInvoker(), new Class[] { Echo.class, EchoImpl.class });
assertTrue(echo instanceof EchoImpl);
}
@Test
public void testProxiesWithClashingFinalMethodInSuperclass()
{
- final Class<?>[] proxyClasses = new Class[]{Echo.class, FinalMethodEcho.class};
+ final Class<?>[] proxyClasses = new Class[] { Echo.class, FinalMethodEcho.class };
Echo proxy = factory.createDelegatorProxy(new ConstantProvider<EchoImpl>(new EchoImpl()), proxyClasses);
assertEquals("final", proxy.echoBack("echo"));
@@ -157,14 +157,15 @@ public abstract class AbstractSubclassin
@Test
public void testWithAbstractSuperclass()
{
- final Echo echo = factory.createDelegatorProxy(new ConstantProvider<EchoImpl>(new EchoImpl()), new Class[]{AbstractEcho.class});
+ final Echo echo = factory.createDelegatorProxy(new ConstantProvider<EchoImpl>(new EchoImpl()),
+ new Class[] { AbstractEcho.class });
assertEquals("hello", echo.echoBack("hello"));
assertEquals("helloworld", echo.echoBack("hello", "world"));
}
-//----------------------------------------------------------------------------------------------------------------------
-// Inner Classes
-//----------------------------------------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------------------------------------------------
+ // Inner Classes
+ //----------------------------------------------------------------------------------------------------------------------
public static class EqualsEcho extends EchoImpl
{
Modified: commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/ProxyUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/ProxyUtilsTest.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/ProxyUtilsTest.java (original)
+++ commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/ProxyUtilsTest.java Wed Mar 26 20:20:01 2014
@@ -17,6 +17,13 @@
package org.apache.commons.proxy2;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Properties;
+
import org.apache.commons.proxy2.util.AbstractTestCase;
import org.apache.commons.proxy2.util.DuplicateEcho;
import org.apache.commons.proxy2.util.Echo;
@@ -25,24 +32,17 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.Properties;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
public class ProxyUtilsTest extends AbstractTestCase
{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Fields
+ //**********************************************************************************************************************
private Properties prevProperties;
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Other Methods
+ //**********************************************************************************************************************
@Before
public void setUp() throws Exception
@@ -61,17 +61,17 @@ public class ProxyUtilsTest extends Abst
public void testNullValue()
{
assertNullValue(null, String.class);
- assertNullValue(( char ) 0, Character.TYPE);
+ assertNullValue((char) 0, Character.TYPE);
assertNullValue(0, Integer.TYPE);
- assertNullValue(( long ) 0, Long.TYPE);
- assertNullValue(( short ) 0, Short.TYPE);
- assertNullValue(( double ) 0, Double.TYPE);
- assertNullValue(( float ) 0, Float.TYPE);
+ assertNullValue((long) 0, Long.TYPE);
+ assertNullValue((short) 0, Short.TYPE);
+ assertNullValue((double) 0, Double.TYPE);
+ assertNullValue((float) 0, Float.TYPE);
assertNullValue(false, Boolean.TYPE);
- assertNullValue(( byte ) 0, Byte.TYPE);
+ assertNullValue((byte) 0, Byte.TYPE);
}
- private void assertNullValue( Object expected, Class<?> type )
+ private void assertNullValue(Object expected, Class<?> type)
{
assertEquals(expected, ProxyUtils.nullValue(type));
}
@@ -80,8 +80,8 @@ public class ProxyUtilsTest extends Abst
public void testGetAllInterfaces()
{
assertNull(ProxyUtils.getAllInterfaces(null));
- assertEquals(Arrays.asList(new Class[] {DuplicateEcho.class, Serializable.class, Echo.class}),
- Arrays.asList(ProxyUtils.getAllInterfaces(EchoImpl.class)));
+ assertEquals(Arrays.asList(new Class[] { DuplicateEcho.class, Serializable.class, Echo.class }),
+ Arrays.asList(ProxyUtils.getAllInterfaces(EchoImpl.class)));
}
@Test
Modified: commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/AbstractExceptionClassTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/AbstractExceptionClassTestCase.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/AbstractExceptionClassTestCase.java (original)
+++ commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/AbstractExceptionClassTestCase.java Wed Mar 26 20:20:01 2014
@@ -17,9 +17,11 @@
package org.apache.commons.proxy2.exception;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import org.apache.commons.proxy2.util.AbstractTestCase;
import org.junit.Test;
-import static org.junit.Assert.*;
/**
* @author James Carman
@@ -27,30 +29,31 @@ import static org.junit.Assert.*;
*/
public abstract class AbstractExceptionClassTestCase extends AbstractTestCase
{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Fields
+ //**********************************************************************************************************************
private final Class<?> exceptionClass;
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Constructors
+ //**********************************************************************************************************************
- public AbstractExceptionClassTestCase( Class<?> exceptionClass )
+ public AbstractExceptionClassTestCase(Class<?> exceptionClass)
{
this.exceptionClass = exceptionClass;
}
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Other Methods
+ //**********************************************************************************************************************
@Test
public void testCauseOnlyConstructor() throws Exception
{
final Exception cause = new Exception();
- Exception e = ( Exception ) exceptionClass.getConstructor(new Class[] {Throwable.class}).newInstance(new Object[] {cause});
+ Exception e = (Exception) exceptionClass.getConstructor(new Class[] { Throwable.class }).newInstance(
+ new Object[] { cause });
assertEquals(cause.toString(), e.getMessage());
assertEquals(cause, e.getCause());
}
@@ -60,7 +63,8 @@ public abstract class AbstractExceptionC
{
final Exception cause = new Exception();
final String message = "message";
- Exception e = ( Exception ) exceptionClass.getConstructor(new Class[] {String.class, Throwable.class}).newInstance(new Object[] {message, cause});
+ Exception e = (Exception) exceptionClass.getConstructor(new Class[] { String.class, Throwable.class })
+ .newInstance(new Object[] { message, cause });
assertEquals(message, e.getMessage());
assertEquals(cause, e.getCause());
}
@@ -69,7 +73,8 @@ public abstract class AbstractExceptionC
public void testMessageOnlyConstructor() throws Exception
{
final String message = "message";
- Exception e = ( Exception ) exceptionClass.getConstructor(new Class[] {String.class}).newInstance(new Object[] {message});
+ Exception e = (Exception) exceptionClass.getConstructor(new Class[] { String.class }).newInstance(
+ new Object[] { message });
assertEquals(message, e.getMessage());
assertNull(e.getCause());
}
@@ -77,7 +82,7 @@ public abstract class AbstractExceptionC
@Test
public void testNoArgConstructor() throws Exception
{
- Exception e = ( Exception ) exceptionClass.getConstructor(new Class[] {}).newInstance(new Object[] {});
+ Exception e = (Exception) exceptionClass.getConstructor(new Class[] {}).newInstance(new Object[] {});
assertNull(e.getMessage());
assertNull(e.getCause());
}
Modified: commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/DelegateProviderExceptionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/DelegateProviderExceptionTest.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/DelegateProviderExceptionTest.java (original)
+++ commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/DelegateProviderExceptionTest.java Wed Mar 26 20:20:01 2014
@@ -19,9 +19,9 @@ package org.apache.commons.proxy2.except
public class DelegateProviderExceptionTest extends AbstractExceptionClassTestCase
{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Constructors
+ //**********************************************************************************************************************
public DelegateProviderExceptionTest()
{
Modified: commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/InvocationHandlerExceptionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/InvocationHandlerExceptionTest.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/InvocationHandlerExceptionTest.java (original)
+++ commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/InvocationHandlerExceptionTest.java Wed Mar 26 20:20:01 2014
@@ -19,9 +19,9 @@ package org.apache.commons.proxy2.except
public class InvocationHandlerExceptionTest extends AbstractExceptionClassTestCase
{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Constructors
+ //**********************************************************************************************************************
public InvocationHandlerExceptionTest()
{
Modified: commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/ProxyFactoryExceptionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/ProxyFactoryExceptionTest.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/ProxyFactoryExceptionTest.java (original)
+++ commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/ProxyFactoryExceptionTest.java Wed Mar 26 20:20:01 2014
@@ -23,9 +23,9 @@ package org.apache.commons.proxy2.except
*/
public class ProxyFactoryExceptionTest extends AbstractExceptionClassTestCase
{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Constructors
+ //**********************************************************************************************************************
public ProxyFactoryExceptionTest()
{
Modified: commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/impl/MethodSignatureTest.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/impl/MethodSignatureTest.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/impl/MethodSignatureTest.java (original)
+++ commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/impl/MethodSignatureTest.java Wed Mar 26 20:20:01 2014
@@ -17,6 +17,11 @@
package org.apache.commons.proxy2.impl;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.lang.reflect.Method;
import org.apache.commons.lang3.SerializationUtils;
@@ -27,13 +32,11 @@ import org.apache.commons.proxy2.util.Ec
import org.apache.commons.proxy2.util.EchoImpl;
import org.junit.Test;
-import static org.junit.Assert.*;
-
public class MethodSignatureTest extends AbstractTestCase
{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Other Methods
+ //**********************************************************************************************************************
@Test
public void testEquals() throws Exception
@@ -58,13 +61,18 @@ public class MethodSignatureTest extends
public void testToString() throws Exception
{
assertEquals("echo()", new MethodSignature(Echo.class.getMethod("echo")).toString());
- assertEquals("echoBack(Ljava/lang/String;)", new MethodSignature(Echo.class.getMethod("echoBack", String.class)).toString());
- assertEquals("echoBack([Ljava/lang/String;)", new MethodSignature(Echo.class.getMethod("echoBack", String[].class)).toString());
- assertEquals("echoBack([[Ljava/lang/String;)", new MethodSignature(Echo.class.getMethod("echoBack", String[][].class)).toString());
- assertEquals("echoBack([[[Ljava/lang/String;)", new MethodSignature(Echo.class.getMethod("echoBack", String[][][].class)).toString());
+ assertEquals("echoBack(Ljava/lang/String;)",
+ new MethodSignature(Echo.class.getMethod("echoBack", String.class)).toString());
+ assertEquals("echoBack([Ljava/lang/String;)",
+ new MethodSignature(Echo.class.getMethod("echoBack", String[].class)).toString());
+ assertEquals("echoBack([[Ljava/lang/String;)",
+ new MethodSignature(Echo.class.getMethod("echoBack", String[][].class)).toString());
+ assertEquals("echoBack([[[Ljava/lang/String;)",
+ new MethodSignature(Echo.class.getMethod("echoBack", String[][][].class)).toString());
assertEquals("echoBack(I)", new MethodSignature(Echo.class.getMethod("echoBack", int.class)).toString());
assertEquals("echoBack(Z)", new MethodSignature(Echo.class.getMethod("echoBack", boolean.class)).toString());
- assertEquals("echoBack(Ljava/lang/String;Ljava/lang/String;)", new MethodSignature(Echo.class.getMethod("echoBack", String.class, String.class)).toString());
+ assertEquals("echoBack(Ljava/lang/String;Ljava/lang/String;)",
+ new MethodSignature(Echo.class.getMethod("echoBack", String.class, String.class)).toString());
assertEquals("illegalArgument()", new MethodSignature(Echo.class.getMethod("illegalArgument")).toString());
assertEquals("ioException()", new MethodSignature(Echo.class.getMethod("ioException")).toString());
}
Modified: commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/InterceptorUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/InterceptorUtilsTest.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/InterceptorUtilsTest.java (original)
+++ commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/InterceptorUtilsTest.java Wed Mar 26 20:20:01 2014
@@ -17,6 +17,8 @@
package org.apache.commons.proxy2.interceptor;
+import static org.junit.Assert.assertEquals;
+
import org.apache.commons.proxy2.Interceptor;
import org.apache.commons.proxy2.Invocation;
import org.apache.commons.proxy2.provider.ObjectProviderUtils;
@@ -24,8 +26,6 @@ import org.apache.commons.proxy2.util.Ab
import org.apache.commons.proxy2.util.Echo;
import org.junit.Test;
-import static org.junit.Assert.*;
-
public class InterceptorUtilsTest extends AbstractTestCase
{
@Test
@@ -55,7 +55,8 @@ public class InterceptorUtilsTest extend
@Test(expected = RuntimeException.class)
public void testThrowingProvidedException() throws Throwable
{
- Interceptor interceptor = InterceptorUtils.throwing(ObjectProviderUtils.constant(new RuntimeException("Oops!")));
+ Interceptor interceptor = InterceptorUtils
+ .throwing(ObjectProviderUtils.constant(new RuntimeException("Oops!")));
Invocation invocation = mockInvocation(Echo.class, "echoBack", String.class).withArguments("World!").build();
interceptor.intercept(invocation);
}
Modified: commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/ObjectProviderInterceptorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/ObjectProviderInterceptorTest.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/ObjectProviderInterceptorTest.java (original)
+++ commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/ObjectProviderInterceptorTest.java Wed Mar 26 20:20:01 2014
@@ -17,17 +17,17 @@
package org.apache.commons.proxy2.interceptor;
+import static org.junit.Assert.assertEquals;
+
import org.apache.commons.proxy2.provider.ObjectProviderUtils;
import org.apache.commons.proxy2.util.AbstractTestCase;
import org.junit.Test;
-import static org.junit.Assert.*;
-
public class ObjectProviderInterceptorTest extends AbstractTestCase
{
-//----------------------------------------------------------------------------------------------------------------------
-// Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------------------------------------------------
+ // Other Methods
+ //----------------------------------------------------------------------------------------------------------------------
@Test
public void testIntercept() throws Throwable
Modified: commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/SwitchInterceptorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/SwitchInterceptorTest.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/SwitchInterceptorTest.java (original)
+++ commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/SwitchInterceptorTest.java Wed Mar 26 20:20:01 2014
@@ -31,9 +31,9 @@ import org.junit.Test;
public class SwitchInterceptorTest extends AbstractTestCase
{
-//----------------------------------------------------------------------------------------------------------------------
-// Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------------------------------------------------
+ // Other Methods
+ //----------------------------------------------------------------------------------------------------------------------
@Test
public void testWithMultipleAdvices() throws Throwable
@@ -58,7 +58,8 @@ public class SwitchInterceptorTest exten
@Test
public void testWithSingleAdviceWhichDoesNotMatch() throws Throwable
{
- SwitchInterceptor interceptor = new SwitchInterceptor().when(new MethodNameMatcher("echoBackZZZZ")).then(constant("bar"));
+ SwitchInterceptor interceptor = new SwitchInterceptor().when(new MethodNameMatcher("echoBackZZZZ")).then(
+ constant("bar"));
Method method = Echo.class.getMethod("echoBack", String.class);
Invocation invocation = new MockInvocation(method, "foo", "foo");
assertEquals("foo", interceptor.intercept(invocation));
@@ -67,7 +68,8 @@ public class SwitchInterceptorTest exten
@Test
public void testWithSingleAdviceWhichMatches() throws Throwable
{
- SwitchInterceptor interceptor = new SwitchInterceptor().when(new MethodNameMatcher("echoBack")).then(constant("bar"));
+ SwitchInterceptor interceptor = new SwitchInterceptor().when(new MethodNameMatcher("echoBack")).then(
+ constant("bar"));
Method method = Echo.class.getMethod("echoBack", String.class);
Invocation invocation = new MockInvocation(method, "foo", "foo");
assertEquals("bar", interceptor.intercept(invocation));
Modified: commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/matcher/DeclaredByMatcherTest.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/matcher/DeclaredByMatcherTest.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/matcher/DeclaredByMatcherTest.java (original)
+++ commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/matcher/DeclaredByMatcherTest.java Wed Mar 26 20:20:01 2014
@@ -32,9 +32,9 @@ import org.junit.Test;
public class DeclaredByMatcherTest extends AbstractTestCase
{
-//----------------------------------------------------------------------------------------------------------------------
-// Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------------------------------------------------
+ // Other Methods
+ //----------------------------------------------------------------------------------------------------------------------
@Test
public void testExactMatchNonMatching() throws Throwable