Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 07D26CA9F for ; Thu, 7 Jun 2012 15:22:53 +0000 (UTC) Received: (qmail 97638 invoked by uid 500); 7 Jun 2012 15:22:52 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 97552 invoked by uid 500); 7 Jun 2012 15:22:52 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 97542 invoked by uid 99); 7 Jun 2012 15:22:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2012 15:22:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2012 15:22:46 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 039D723889E0 for ; Thu, 7 Jun 2012 15:22:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1347673 - in /commons/proper/proxy/branches/version-2.0-work/stub/src: main/java/org/apache/commons/proxy2/stub/ test/java/org/apache/commons/proxy2/stub/ Date: Thu, 07 Jun 2012 15:22:23 -0000 To: commits@commons.apache.org From: mbenson@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120607152224.039D723889E0@eris.apache.org> Author: mbenson Date: Thu Jun 7 15:22:23 2012 New Revision: 1347673 URL: http://svn.apache.org/viewvc?rev=1347673&view=rev Log: revert too-big commit Modified: commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/AnnotationFactory.java commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/StubConfiguration.java commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/StubConfigurer.java commons/proper/proxy/branches/version-2.0-work/stub/src/test/java/org/apache/commons/proxy2/stub/AnnotationFactoryTest.java Modified: commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/AnnotationFactory.java URL: http://svn.apache.org/viewvc/commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/AnnotationFactory.java?rev=1347673&r1=1347672&r2=1347673&view=diff ============================================================================== --- commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/AnnotationFactory.java (original) +++ commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/AnnotationFactory.java Thu Jun 7 15:22:23 2012 @@ -26,7 +26,6 @@ import java.lang.reflect.Proxy; import java.util.Map; import org.apache.commons.lang3.AnnotationUtils; -import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.proxy2.Interceptor; import org.apache.commons.proxy2.Invocation; @@ -35,7 +34,6 @@ import org.apache.commons.proxy2.ObjectP import org.apache.commons.proxy2.ProxyFactory; import org.apache.commons.proxy2.ProxyUtils; import org.apache.commons.proxy2.impl.AbstractProxyFactory; -import org.apache.commons.proxy2.provider.ConstantProvider; /** * {@link AnnotationFactory} provides a simplified API over {@link StubProxyFactory} @@ -166,9 +164,6 @@ public class AnnotationFactory { @Override protected void configure(A stub) { - if (attributes == null) { - return; - } When bud; StubConfiguration dy = this; for (Map.Entry attr : attributes.entrySet()) { @@ -256,100 +251,61 @@ public class AnnotationFactory { * @return stubbed annotation proxy */ public A create(StubConfigurer configurer) { - return create(Thread.currentThread().getContextClassLoader(), Validate.notNull(configurer, "null configurer")); - } - - /** - * Create a delegating annotation of the type supported by configurer. - * @param - * @param target not {@code null} - * @param configurer not {@code null} - * @return stubbed annotation proxy - */ - public A createDelegator(A target, StubConfigurer configurer) { - return createInternal(Thread.currentThread().getContextClassLoader(), - Validate.notNull(target, "null target"), Validate.notNull(configurer, "null configurer")); + @SuppressWarnings("unchecked") + final A result = (A) createInternal(Thread.currentThread().getContextClassLoader(), configurer); + return result; } /** * Create an annotation of the type supported by configurer in the specified classpath. * @param - * @param classLoader not {@code null} - * @param configurer not {@code null} + * @param classLoader + * @param configurer * @return stubbed annotation proxy */ public A create(ClassLoader classLoader, StubConfigurer configurer) { - return createInternal(Validate.notNull(classLoader, "null classLoader"), - null, Validate.notNull(configurer, "null configurer")); - } - - /** - * Create a delegating annotation of the type supported by configurer in the specified classpath. - * @param - * @param classLoader not {@code null} - * @param target not {@code null} - * @param configurer not {@code null} - * @return stubbed annotation proxy - */ - public A createDelegator(ClassLoader classLoader, A target, StubConfigurer configurer) { - return createInternal(Validate.notNull(classLoader, "null classLoader"), - Validate.notNull(target, "null target"), Validate.notNull(configurer, "null configurer")); + @SuppressWarnings("unchecked") + final A result = (A) createInternal(classLoader, configurer); + return result; } /** * Create an annotation of annotationType with fully default behavior. * @param - * @param annotationType not {@code null} + * @param classLoader + * @param annotationType * @return stubbed annotation proxy */ public A create(Class annotationType) { @SuppressWarnings("unchecked") - final A result = - (A) createInternal(Thread.currentThread().getContextClassLoader(), - Validate.notNull(annotationType, "null annotationType")); + final A result = (A) createInternal(Thread.currentThread().getContextClassLoader(), annotationType); return result; } /** * Create an annotation of annotationType with fully default behavior. * @param - * @param classLoader not {@code null} - * @param annotationType not {@code null} + * @param classLoader + * @param annotationType * @return stubbed annotation proxy */ public A create(ClassLoader classLoader, Class annotationType) { @SuppressWarnings("unchecked") - final A result = - (A) createInternal(Validate.notNull(classLoader, "null classLoader"), - Validate.notNull(annotationType, "null annotationType")); + final A result = (A) createInternal(classLoader, annotationType); return result; } /** * Create an annotation of annotationType with behavior specified by a {@link String}-keyed {@link Map}. * @param - * @param annotationType not {@code null} + * @param classLoader + * @param annotationType * @param attributes * @return stubbed annotation proxy */ public A create(Class annotationType, Map attributes) { - if (attributes == null || attributes.isEmpty()) { - return create(annotationType); - } - return create(new MapBasedAnnotationConfigurer(annotationType, attributes)); - } - - /** - * Create a delegating annotation of annotationType with behavior specified by a {@link String}-keyed {@link Map}. - * @param - * @param target not {@code null} - * @param attributes - * @return stubbed annotation proxy - */ - public A createDelegator(A target, Map attributes) { - @SuppressWarnings("unchecked") - final Class annotationType = (Class) Validate.notNull(target, "null target").annotationType(); - return createDelegator(target, new MapBasedAnnotationConfigurer(annotationType, attributes)); + return attributes == null || attributes.isEmpty() ? create(annotationType) + : create(new MapBasedAnnotationConfigurer(annotationType, attributes)); } /** @@ -362,28 +318,11 @@ public class AnnotationFactory { */ public A create(ClassLoader classLoader, Class annotationType, Map attributes) { - return create(classLoader, new MapBasedAnnotationConfigurer(annotationType, attributes)); - } - - /** - * Create a delegating annotation of annotationType with behavior specified by a {@link String}-keyed {@link Map}. - * @param - * @param classLoader - * @param target - * @param attributes - * @return stubbed annotation proxy - */ - public A createDelegator(ClassLoader classLoader, A target, Map attributes) { - @SuppressWarnings("unchecked") - final Class annotationType = (Class) Validate.notNull(target, "null target").annotationType(); - return createDelegator(classLoader, target, new MapBasedAnnotationConfigurer(annotationType, attributes)); + return attributes == null || attributes.isEmpty() ? create(classLoader, annotationType) : create(classLoader, + new MapBasedAnnotationConfigurer(annotationType, attributes)); } private A createInternal(ClassLoader classLoader, Object configurer) { - return createInternal(classLoader, null, configurer); - } - - private A createInternal(ClassLoader classLoader, A target, Object configurer) { final Object existingConfigurer = CONFIGURER.get(); final boolean outerContext = CONTEXT.get() == null; try { @@ -391,17 +330,8 @@ public class AnnotationFactory { if (outerContext) { CONTEXT.set(ImmutablePair.of(this, classLoader)); } - final A result; - if (target == null) { - @SuppressWarnings("unchecked") - A invoker = (A) proxyFactory.createInvokerProxy(classLoader, ANNOTATION_INVOKER, getStubType()); - result = invoker; - } else { - @SuppressWarnings("unchecked") - A delegator = - (A) proxyFactory.createDelegatorProxy(classLoader, new ConstantProvider(target), getStubType()); - result = delegator; - } + @SuppressWarnings("unchecked") + final A result = (A) proxyFactory.createInvokerProxy(classLoader, ANNOTATION_INVOKER, getStubType()); return validate(result); } finally { if (existingConfigurer == null) { Modified: commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/StubConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/StubConfiguration.java?rev=1347673&r1=1347672&r2=1347673&view=diff ============================================================================== --- commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/StubConfiguration.java (original) +++ commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/StubConfiguration.java Thu Jun 7 15:22:23 2012 @@ -17,16 +17,12 @@ package org.apache.commons.proxy2.stub; -import org.apache.commons.functor.UnaryPredicate; import org.apache.commons.proxy2.ObjectProvider; /** * Fluent stub configuration interface inspired by Mockito stubbing mechanisms. - * This interface declares all the methods necessary to: - *
    - *
  • allow varargs to be used to specify return values for any array type
  • - *
  • make interactive stub calls describe nonspecific argument matching situations
  • - *
+ * This interface declares all the methods necessary to, in particular, allow + * varargs to be used to specify return values for any array type. */ public interface StubConfiguration { @@ -348,67 +344,4 @@ public interface StubConfiguration { */ WhenClass when(Class call); - /** - * Match any boolean. - * @return mock argument - */ - boolean anyBoolean(); - - /** - * Match any byte. - * @return mock argument - */ - byte anyByte(); - - /** - * Match any short. - * @return mock argument - */ - short anyShort(); - - /** - * Match any int. - * @return mock argument - */ - int anyInt(); - - /** - * Match any char. - * @return mock argument - */ - char anyChar(); - - /** - * Match any long. - * @return mock argument - */ - long anyLong(); - - /** - * Match any float. - * @return mock argument - */ - float anyFloat(); - - /** - * Match any double. - * @return mock argument - */ - double anyDouble(); - - /** - * Match any object. - * @param - * @return mock argument - */ - T any(); - - /** - * Match an argument with a test. - * @param - * @param test - * @return mock argument - */ - T argThat(UnaryPredicate test); - } Modified: commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/StubConfigurer.java URL: http://svn.apache.org/viewvc/commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/StubConfigurer.java?rev=1347673&r1=1347672&r2=1347673&view=diff ============================================================================== --- commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/StubConfigurer.java (original) +++ commons/proper/proxy/branches/version-2.0-work/stub/src/main/java/org/apache/commons/proxy2/stub/StubConfigurer.java Thu Jun 7 15:22:23 2012 @@ -17,13 +17,11 @@ package org.apache.commons.proxy2.stub; -import org.apache.commons.functor.UnaryPredicate; import org.apache.commons.lang3.reflect.TypeUtils; import org.apache.commons.proxy2.ObjectProvider; import org.apache.commons.proxy2.provider.ConstantProvider; /** - *

* Configuration mechanism for a stub. Implements {@link StubConfiguration} for maximum fluency. * A {@link StubConfigurer} needs to know the type of stub object to which it applies. * Any useful runtime subclass should have the type variable non-generically @@ -36,11 +34,7 @@ import org.apache.commons.proxy2.provide * } * } * - *

* - *

Note that when argument matching is used, all method parameters must be specified using matchers. - * TODO add matching example - *

* @param * @author Matt Benson */ @@ -71,11 +65,12 @@ public abstract class StubConfigurer return; } @SuppressWarnings("unchecked") - final Class resolvedVariable = - (Class) TypeUtils.getRawType(StubConfigurer.class.getTypeParameters()[0], getClass()); + final Class resolvedVariable = (Class) TypeUtils.getRawType( + StubConfigurer.class.getTypeParameters()[0], getClass()); if (resolvedVariable == null) { - throw new IllegalArgumentException("stubType was not specified and could not be calculated for " - + getClass()); + throw new IllegalArgumentException( + "stubType was not specified and could not be calculated for " + + getClass()); } this.stubType = resolvedVariable; } @@ -91,7 +86,8 @@ public abstract class StubConfigurer /** * {@inheritDoc} */ - public org.apache.commons.proxy2.stub.StubConfiguration.When when(RT call) { + public org.apache.commons.proxy2.stub.StubConfiguration.When when( + RT call) { return new When() { public StubConfiguration thenReturn(RT result) { @@ -99,7 +95,8 @@ public abstract class StubConfigurer return StubConfigurer.this; } - public StubConfiguration thenAnswer(ObjectProvider objectProvider) { + public StubConfiguration thenAnswer( + ObjectProvider objectProvider) { requireStubInterceptor().addAnswer(objectProvider); return StubConfigurer.this; } @@ -108,7 +105,8 @@ public abstract class StubConfigurer return thenThrow(new ConstantProvider(t)); } - public StubConfiguration thenThrow(ObjectProvider throwableProvider) { + public StubConfiguration thenThrow( + ObjectProvider throwableProvider) { requireStubInterceptor().addThrow(throwableProvider); return StubConfigurer.this; } @@ -118,7 +116,8 @@ public abstract class StubConfigurer /** * {@inheritDoc} */ - public org.apache.commons.proxy2.stub.StubConfiguration.WhenBooleanArray when(boolean[] call) { + public org.apache.commons.proxy2.stub.StubConfiguration.WhenBooleanArray when( + boolean[] call) { return new WhenBooleanArray() { public StubConfiguration thenReturn(boolean... b) { @@ -126,7 +125,8 @@ public abstract class StubConfigurer return StubConfigurer.this; } - public StubConfiguration thenAnswer(ObjectProvider objectProvider) { + public StubConfiguration thenAnswer( + ObjectProvider objectProvider) { requireStubInterceptor().addAnswer(objectProvider); return StubConfigurer.this; } @@ -135,7 +135,8 @@ public abstract class StubConfigurer return thenThrow(new ConstantProvider(t)); } - public StubConfiguration thenThrow(ObjectProvider throwableProvider) { + public StubConfiguration thenThrow( + ObjectProvider throwableProvider) { requireStubInterceptor().addThrow(throwableProvider); return StubConfigurer.this; } @@ -145,7 +146,8 @@ public abstract class StubConfigurer /** * {@inheritDoc} */ - public org.apache.commons.proxy2.stub.StubConfiguration.WhenByteArray when(byte[] call) { + public org.apache.commons.proxy2.stub.StubConfiguration.WhenByteArray when( + byte[] call) { return new WhenByteArray() { public StubConfiguration thenReturn(byte... b) { @@ -153,7 +155,8 @@ public abstract class StubConfigurer return StubConfigurer.this; } - public StubConfiguration thenAnswer(ObjectProvider objectProvider) { + public StubConfiguration thenAnswer( + ObjectProvider objectProvider) { requireStubInterceptor().addAnswer(objectProvider); return StubConfigurer.this; } @@ -162,7 +165,8 @@ public abstract class StubConfigurer return thenThrow(new ConstantProvider(t)); } - public StubConfiguration thenThrow(ObjectProvider throwableProvider) { + public StubConfiguration thenThrow( + ObjectProvider throwableProvider) { requireStubInterceptor().addThrow(throwableProvider); return StubConfigurer.this; } @@ -172,7 +176,8 @@ public abstract class StubConfigurer /** * {@inheritDoc} */ - public org.apache.commons.proxy2.stub.StubConfiguration.WhenShortArray when(short[] call) { + public org.apache.commons.proxy2.stub.StubConfiguration.WhenShortArray when( + short[] call) { return new WhenShortArray() { public StubConfiguration thenReturn(short... s) { @@ -180,7 +185,8 @@ public abstract class StubConfigurer return StubConfigurer.this; } - public StubConfiguration thenAnswer(ObjectProvider objectProvider) { + public StubConfiguration thenAnswer( + ObjectProvider objectProvider) { requireStubInterceptor().addAnswer(objectProvider); return StubConfigurer.this; } @@ -189,7 +195,8 @@ public abstract class StubConfigurer return thenThrow(new ConstantProvider(t)); } - public StubConfiguration thenThrow(ObjectProvider throwableProvider) { + public StubConfiguration thenThrow( + ObjectProvider throwableProvider) { requireStubInterceptor().addThrow(throwableProvider); return StubConfigurer.this; } @@ -199,7 +206,8 @@ public abstract class StubConfigurer /** * {@inheritDoc} */ - public org.apache.commons.proxy2.stub.StubConfiguration.WhenIntArray when(int[] call) { + public org.apache.commons.proxy2.stub.StubConfiguration.WhenIntArray when( + int[] call) { return new WhenIntArray() { public StubConfiguration thenReturn(int... i) { @@ -207,7 +215,8 @@ public abstract class StubConfigurer return StubConfigurer.this; } - public StubConfiguration thenAnswer(ObjectProvider objectProvider) { + public StubConfiguration thenAnswer( + ObjectProvider objectProvider) { requireStubInterceptor().addAnswer(objectProvider); return StubConfigurer.this; } @@ -216,7 +225,8 @@ public abstract class StubConfigurer return thenThrow(new ConstantProvider(t)); } - public StubConfiguration thenThrow(ObjectProvider throwableProvider) { + public StubConfiguration thenThrow( + ObjectProvider throwableProvider) { requireStubInterceptor().addThrow(throwableProvider); return StubConfigurer.this; } @@ -226,7 +236,8 @@ public abstract class StubConfigurer /** * {@inheritDoc} */ - public org.apache.commons.proxy2.stub.StubConfiguration.WhenCharArray when(char[] call) { + public org.apache.commons.proxy2.stub.StubConfiguration.WhenCharArray when( + char[] call) { return new WhenCharArray() { public StubConfiguration thenReturn(char... c) { @@ -234,7 +245,8 @@ public abstract class StubConfigurer return StubConfigurer.this; } - public StubConfiguration thenAnswer(ObjectProvider objectProvider) { + public StubConfiguration thenAnswer( + ObjectProvider objectProvider) { requireStubInterceptor().addAnswer(objectProvider); return StubConfigurer.this; } @@ -243,7 +255,8 @@ public abstract class StubConfigurer return thenThrow(new ConstantProvider(t)); } - public StubConfiguration thenThrow(ObjectProvider throwableProvider) { + public StubConfiguration thenThrow( + ObjectProvider throwableProvider) { requireStubInterceptor().addThrow(throwableProvider); return StubConfigurer.this; } @@ -253,7 +266,8 @@ public abstract class StubConfigurer /** * {@inheritDoc} */ - public org.apache.commons.proxy2.stub.StubConfiguration.WhenLongArray when(long[] call) { + public org.apache.commons.proxy2.stub.StubConfiguration.WhenLongArray when( + long[] call) { return new WhenLongArray() { public StubConfiguration thenReturn(long... l) { @@ -261,7 +275,8 @@ public abstract class StubConfigurer return StubConfigurer.this; } - public StubConfiguration thenAnswer(ObjectProvider objectProvider) { + public StubConfiguration thenAnswer( + ObjectProvider objectProvider) { requireStubInterceptor().addAnswer(objectProvider); return StubConfigurer.this; } @@ -270,7 +285,8 @@ public abstract class StubConfigurer return thenThrow(new ConstantProvider(t)); } - public StubConfiguration thenThrow(ObjectProvider throwableProvider) { + public StubConfiguration thenThrow( + ObjectProvider throwableProvider) { requireStubInterceptor().addThrow(throwableProvider); return StubConfigurer.this; } @@ -280,7 +296,8 @@ public abstract class StubConfigurer /** * {@inheritDoc} */ - public org.apache.commons.proxy2.stub.StubConfiguration.WhenFloatArray when(float[] call) { + public org.apache.commons.proxy2.stub.StubConfiguration.WhenFloatArray when( + float[] call) { return new WhenFloatArray() { public StubConfiguration thenReturn(float... f) { @@ -288,7 +305,8 @@ public abstract class StubConfigurer return StubConfigurer.this; } - public StubConfiguration thenAnswer(ObjectProvider objectProvider) { + public StubConfiguration thenAnswer( + ObjectProvider objectProvider) { requireStubInterceptor().addAnswer(objectProvider); return StubConfigurer.this; } @@ -297,7 +315,8 @@ public abstract class StubConfigurer return thenThrow(new ConstantProvider(t)); } - public StubConfiguration thenThrow(ObjectProvider throwableProvider) { + public StubConfiguration thenThrow( + ObjectProvider throwableProvider) { requireStubInterceptor().addThrow(throwableProvider); return StubConfigurer.this; } @@ -307,7 +326,8 @@ public abstract class StubConfigurer /** * {@inheritDoc} */ - public org.apache.commons.proxy2.stub.StubConfiguration.WhenDoubleArray when(double[] call) { + public org.apache.commons.proxy2.stub.StubConfiguration.WhenDoubleArray when( + double[] call) { return new WhenDoubleArray() { public StubConfiguration thenReturn(double... d) { @@ -315,7 +335,8 @@ public abstract class StubConfigurer return StubConfigurer.this; } - public StubConfiguration thenAnswer(ObjectProvider objectProvider) { + public StubConfiguration thenAnswer( + ObjectProvider objectProvider) { requireStubInterceptor().addAnswer(objectProvider); return StubConfigurer.this; } @@ -324,7 +345,8 @@ public abstract class StubConfigurer return thenThrow(new ConstantProvider(t)); } - public StubConfiguration thenThrow(ObjectProvider throwableProvider) { + public StubConfiguration thenThrow( + ObjectProvider throwableProvider) { requireStubInterceptor().addThrow(throwableProvider); return StubConfigurer.this; } @@ -334,7 +356,8 @@ public abstract class StubConfigurer /** * {@inheritDoc} */ - public org.apache.commons.proxy2.stub.StubConfiguration.WhenObjectArray when(C[] call) { + public org.apache.commons.proxy2.stub.StubConfiguration.WhenObjectArray when( + C[] call) { return new WhenObjectArray() { public StubConfiguration thenReturn(C... c) { @@ -342,7 +365,8 @@ public abstract class StubConfigurer return StubConfigurer.this; } - public StubConfiguration thenAnswer(ObjectProvider objectProvider) { + public StubConfiguration thenAnswer( + ObjectProvider objectProvider) { requireStubInterceptor().addAnswer(objectProvider); return StubConfigurer.this; } @@ -351,7 +375,8 @@ public abstract class StubConfigurer return thenThrow(new ConstantProvider(t)); } - public StubConfiguration thenThrow(ObjectProvider throwableProvider) { + public StubConfiguration thenThrow( + ObjectProvider throwableProvider) { requireStubInterceptor().addThrow(throwableProvider); return StubConfigurer.this; } @@ -361,7 +386,8 @@ public abstract class StubConfigurer /** * {@inheritDoc} */ - public org.apache.commons.proxy2.stub.StubConfiguration.WhenClass when(Class call) { + public org.apache.commons.proxy2.stub.StubConfiguration.WhenClass when( + Class call) { return new WhenClass() { public StubConfiguration thenReturn(Class c) { @@ -369,7 +395,8 @@ public abstract class StubConfigurer return StubConfigurer.this; } - public StubConfiguration thenAnswer(ObjectProvider> objectProvider) { + public StubConfiguration thenAnswer( + ObjectProvider> objectProvider) { requireStubInterceptor().addAnswer(objectProvider); return StubConfigurer.this; } @@ -378,7 +405,8 @@ public abstract class StubConfigurer return thenThrow(new ConstantProvider(t)); } - public StubConfiguration thenThrow(ObjectProvider throwableProvider) { + public StubConfiguration thenThrow( + ObjectProvider throwableProvider) { requireStubInterceptor().addThrow(throwableProvider); return StubConfigurer.this; } @@ -386,102 +414,13 @@ public abstract class StubConfigurer } /** - * {@inheritDoc} - */ - @Override - public boolean anyBoolean() { - // TODO Auto-generated method stub - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public byte anyByte() { - // TODO Auto-generated method stub - return 0; - } - - /** - * {@inheritDoc} - */ - @Override - public short anyShort() { - // TODO Auto-generated method stub - return 0; - } - - /** - * {@inheritDoc} - */ - @Override - public int anyInt() { - // TODO Auto-generated method stub - return 0; - } - - /** - * {@inheritDoc} - */ - @Override - public char anyChar() { - // TODO Auto-generated method stub - return 0; - } - - /** - * {@inheritDoc} - */ - @Override - public long anyLong() { - // TODO Auto-generated method stub - return 0; - } - - /** - * {@inheritDoc} - */ - @Override - public float anyFloat() { - // TODO Auto-generated method stub - return 0; - } - - /** - * {@inheritDoc} - */ - @Override - public double anyDouble() { - // TODO Auto-generated method stub - return 0; - } - - /** - * {@inheritDoc} - */ - @Override - public U any() { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public U argThat(UnaryPredicate test) { - // TODO Auto-generated method stub - return null; - } - - /** * Apply thyself against the specified stub interceptor. * @param stubInterceptor */ final void configure(StubInterceptor stubInterceptor, T stub) { if (stubInterceptor == null) { - throw new IllegalArgumentException("Cannot configure null StubInterceptor"); + throw new IllegalArgumentException( + "Cannot configure null StubInterceptor"); } synchronized (this) { this.stubInterceptor = stubInterceptor; Modified: commons/proper/proxy/branches/version-2.0-work/stub/src/test/java/org/apache/commons/proxy2/stub/AnnotationFactoryTest.java URL: http://svn.apache.org/viewvc/commons/proper/proxy/branches/version-2.0-work/stub/src/test/java/org/apache/commons/proxy2/stub/AnnotationFactoryTest.java?rev=1347673&r1=1347672&r2=1347673&view=diff ============================================================================== --- commons/proper/proxy/branches/version-2.0-work/stub/src/test/java/org/apache/commons/proxy2/stub/AnnotationFactoryTest.java (original) +++ commons/proper/proxy/branches/version-2.0-work/stub/src/test/java/org/apache/commons/proxy2/stub/AnnotationFactoryTest.java Thu Jun 7 15:22:23 2012 @@ -22,13 +22,9 @@ import static org.junit.Assert.assertEqu import static org.junit.Assert.assertNotNull; import java.lang.annotation.Annotation; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.apache.commons.lang3.reflect.FieldUtils; import org.junit.Before; import org.junit.Test; @@ -36,7 +32,6 @@ import org.junit.Test; * Test {@link AnnotationFactory}. */ public class AnnotationFactoryTest { - @CustomAnnotation(annString = "FOO", finiteValues = { FiniteValues.ONE, FiniteValues.TWO, FiniteValues.THREE }, someType = Object.class) private AnnotationFactory annotationFactory; @Before @@ -172,65 +167,12 @@ public class AnnotationFactoryTest { annotationFactory.create(CustomAnnotation.class, attributes); } - @Test - public void testDelegator() { - final boolean forceAccess = true; - final CustomAnnotation sourceAnnotation = - FieldUtils.getDeclaredField(AnnotationFactoryTest.class, "annotationFactory", forceAccess).getAnnotation( - CustomAnnotation.class); - assertNotNull(sourceAnnotation); - CustomAnnotation stub = - annotationFactory.createDelegator(sourceAnnotation, new AnnotationConfigurer() { - - @Override - protected void configure(CustomAnnotation stub) { - when(stub.finiteValues()).thenReturn(FiniteValues.ONE); - } - }); - assertEquals(CustomAnnotation.class, stub.annotationType()); - assertEquals(Object.class, stub.someType()); - assertEquals("FOO", stub.annString()); - assertArrayEquals(new FiniteValues[] { FiniteValues.ONE }, stub.finiteValues()); - } - - @Test(expected = NullPointerException.class) - public void testDelegatorMissingTarget() { - annotationFactory.createDelegator(null, new StubConfigurer() { - - @Override - protected void configure(CustomAnnotation stub) { - } - }); - } - - @Test - public void testDelegatorWithAttributes() { - final boolean forceAccess = true; - final CustomAnnotation sourceAnnotation = - FieldUtils.getDeclaredField(AnnotationFactoryTest.class, "annotationFactory", forceAccess).getAnnotation( - CustomAnnotation.class); - assertNotNull(sourceAnnotation); - Map attributes = - Collections. singletonMap("finiteValues", new FiniteValues[] { FiniteValues.ONE }); - CustomAnnotation stub = annotationFactory.createDelegator(sourceAnnotation, attributes); - assertEquals(CustomAnnotation.class, stub.annotationType()); - assertEquals(Object.class, stub.someType()); - assertEquals("FOO", stub.annString()); - assertArrayEquals(new FiniteValues[] { FiniteValues.ONE }, stub.finiteValues()); - } - - @Test(expected = NullPointerException.class) - public void testDelegatorWithAttributesMissingTarget() { - annotationFactory.createDelegator(null, Collections. emptyMap()); - } - public @interface NestingAnnotation { CustomAnnotation child(); String somethingElse(); } - @Retention(RetentionPolicy.RUNTIME) public @interface CustomAnnotation { String annString() default "";