Return-Path:
Delivered-To: apmail-incubator-aries-commits-archive@minotaur.apache.org
Received: (qmail 66849 invoked from network); 7 Oct 2009 03:01:14 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3)
by minotaur.apache.org with SMTP; 7 Oct 2009 03:01:14 -0000
Received: (qmail 4738 invoked by uid 500); 7 Oct 2009 03:01:14 -0000
Delivered-To: apmail-incubator-aries-commits-archive@incubator.apache.org
Received: (qmail 4677 invoked by uid 500); 7 Oct 2009 03:01:14 -0000
Mailing-List: contact aries-commits-help@incubator.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: aries-dev@incubator.apache.org
Delivered-To: mailing list aries-commits@incubator.apache.org
Received: (qmail 4667 invoked by uid 99); 7 Oct 2009 03:01:14 -0000
Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230)
by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Oct 2009 03:01:14 +0000
X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Wed, 07 Oct 2009 03:01:07 +0000
Received: by eris.apache.org (Postfix, from userid 65534)
id DBF6D23888E5; Wed, 7 Oct 2009 03:00:44 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r822565 [2/4] - in
/incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries:
mocks/ unittest/junit/ unittest/mocks/ unittest/mocks/annotations/
Date: Wed, 07 Oct 2009 03:00:44 -0000
To: aries-commits@incubator.apache.org
From: gawor@apache.org
X-Mailer: svnmailer-1.0.8
Message-Id: <20091007030044.DBF6D23888E5@eris.apache.org>
X-Virus-Checked: Checked by ClamAV on apache.org
Modified: incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/DefaultInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/DefaultInvocationHandler.java?rev=822565&r1=822564&r2=822565&view=diff
==============================================================================
--- incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/DefaultInvocationHandler.java (original)
+++ incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/DefaultInvocationHandler.java Wed Oct 7 03:00:43 2009
@@ -1,111 +1,111 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.aries.unittest.mocks;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-/**
- *
This invocation handler is used by the Skeleton when nothing else is
- * matched. If the return type is an interface it creates a dynamic proxy
- * backed by the associated skeleton for return, if it is a class with a
- * default constructor that will be returned.
- *
- */
-public class DefaultInvocationHandler implements InvocationHandler
-{
- /** The skeleton this handler is associated with */
- private Skeleton _s;
-
- /* ------------------------------------------------------------------------ */
- /* DefaultInvocationHandler constructor
- /* ------------------------------------------------------------------------ */
- /**
- * Creates an instance called by the specified skeleton.
- *
- * @param s The caller.
- */
- public DefaultInvocationHandler(Skeleton s)
- {
- this._s = s;
- }
-
- /* ------------------------------------------------------------------------ */
- /* invoke method
- /* ------------------------------------------------------------------------ */
- /**
- * Invoked when no ReturnType or MethodCall Handlers are defined.
- *
- * @param target The target object that was invoked.
- * @param method The method that was invoked.
- * @param arguments The arguments that were passed.
- * @return A proxy or null.
- * @throws Throwable
- */
- public Object invoke(Object target, Method method, Object[] arguments)
- throws Throwable
- {
- Class> returnType = method.getReturnType();
- Object obj = null;
-
- if (returnType.isInterface())
- {
- obj = createProxy(new Class[] { returnType });
- }
- else
- {
- try
- {
- obj = returnType.newInstance();
- }
- catch (Exception e)
- {
- // if this occurs then assume no default constructor was visible.
- }
- }
-
- return obj;
- }
-
- /* ------------------------------------------------------------------------ */
- /* createProxy method
- /* ------------------------------------------------------------------------ */
- /**
- * Creates and returns a proxy backed by the associated skeleton, that
- * implements the specified interfaces. Null is returned if the return
- * type array contains non interfaces.
- *
- * @param returnTypes The classes.
- * @return The proxy or null.
- */
- public Object createProxy(Class> ... returnTypes)
- {
- Object result = null;
-
- boolean allInterfaces = true;
- for(int i = 0; (allInterfaces && iThis invocation handler is used by the Skeleton when nothing else is
+ * matched. If the return type is an interface it creates a dynamic proxy
+ * backed by the associated skeleton for return, if it is a class with a
+ * default constructor that will be returned.
+ *
+ */
+public class DefaultInvocationHandler implements InvocationHandler
+{
+ /** The skeleton this handler is associated with */
+ private Skeleton _s;
+
+ /* ------------------------------------------------------------------------ */
+ /* DefaultInvocationHandler constructor
+ /* ------------------------------------------------------------------------ */
+ /**
+ * Creates an instance called by the specified skeleton.
+ *
+ * @param s The caller.
+ */
+ public DefaultInvocationHandler(Skeleton s)
+ {
+ this._s = s;
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* invoke method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * Invoked when no ReturnType or MethodCall Handlers are defined.
+ *
+ * @param target The target object that was invoked.
+ * @param method The method that was invoked.
+ * @param arguments The arguments that were passed.
+ * @return A proxy or null.
+ * @throws Throwable
+ */
+ public Object invoke(Object target, Method method, Object[] arguments)
+ throws Throwable
+ {
+ Class> returnType = method.getReturnType();
+ Object obj = null;
+
+ if (returnType.isInterface())
+ {
+ obj = createProxy(new Class[] { returnType });
+ }
+ else
+ {
+ try
+ {
+ obj = returnType.newInstance();
+ }
+ catch (Exception e)
+ {
+ // if this occurs then assume no default constructor was visible.
+ }
+ }
+
+ return obj;
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* createProxy method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * Creates and returns a proxy backed by the associated skeleton, that
+ * implements the specified interfaces. Null is returned if the return
+ * type array contains non interfaces.
+ *
+ * @param returnTypes The classes.
+ * @return The proxy or null.
+ */
+ public Object createProxy(Class> ... returnTypes)
+ {
+ Object result = null;
+
+ boolean allInterfaces = true;
+ for(int i = 0; (allInterfaces && iThis class contains method call handlers for some default method handling.
- *
- *
- *
This class provides handlers for the toString, equals and hashCode
- * methods. They reproduce the default Object implementations for dynamic
- * mock objects, these can be overridden.
- *
- */
-public class DefaultMethodCallHandlers
-{
- /** A MethodCall representing the equals method */
- private static MethodCall _equals;
- /** A MethodCall representing the toString method */
- private static MethodCall _toString;
- /** A MethodCall representing the hashCode method */
- private static MethodCall _hashCode;
-
- /* ------------------------------------------------------------------------ */
- /* static initializer
- /* ------------------------------------------------------------------------ */
- static
- {
- _equals = new MethodCall(Object.class, "equals", new Object[] {Object.class});
- _toString = new MethodCall(Object.class, "toString", new Object[0]);
- _hashCode = new MethodCall(Object.class, "hashCode", new Object[0]);
- }
-
- /**
- * The Default MethodCallHandler for the equals method, performs an == check.
- */
- public static final MethodCallHandler EQUALS_HANDLER = new MethodCallHandler()
- {
- public Object handle(MethodCall methodCall, Skeleton parent) throws Exception
- {
- Object obj = methodCall.getInvokedObject();
- Object toObj = methodCall.getArguments()[0];
-
- if (toObj == null) return false;
-
- if(parent.getTemplateObject() != null){
- try {
- if(Skeleton.isSkeleton(toObj) &&Skeleton.getSkeleton(toObj).getTemplateObject() != null){
- return parent.getTemplateObject().equals(Skeleton.getSkeleton(toObj).getTemplateObject());
- } else {
- return false;
- }
- } catch (IllegalArgumentException iae) {
- return parent.getTemplateObject().equals(toObj);
- }
- }
-
-
- return obj == toObj ? Boolean.TRUE : Boolean.FALSE;
- }
- };
-
- /**
- * The Default MethodCallHandler for the toString method, reproduces
- * @
- */
- public static final MethodCallHandler TOSTRING_HANDLER = new MethodCallHandler()
- {
- public Object handle(MethodCall methodCall, Skeleton parent) throws Exception
- {
- if(parent.getTemplateObject() != null)
- return parent.getTemplateObject().toString();
- Object obj = methodCall.getInvokedObject();
- return obj.getClass().getName() + "@" + System.identityHashCode(obj);
- }
- };
-
- /**
- * The Default MethodCallHandler for the hashCode method, returns the
- * identity hashCode.
- */
- public static final MethodCallHandler HASHCODE_HANDLER = new MethodCallHandler()
- {
- public Object handle(MethodCall methodCall, Skeleton parent) throws Exception
- {
- if(parent.getTemplateObject() != null)
- return parent.getTemplateObject().hashCode();
-
- return Integer.valueOf(System.identityHashCode(methodCall.getInvokedObject()));
- }
- };
-
- /* ------------------------------------------------------------------------ */
- /* registerDefaultHandlers method
- /* ------------------------------------------------------------------------ */
- /**
- * This method registers the DefaultMethodCall Handlers with the specified
- * skeleton.
- *
- * @param s a skeleton
- */
- public static void registerDefaultHandlers(Skeleton s)
- {
- s.registerMethodCallHandler(_equals, EQUALS_HANDLER);
- s.registerMethodCallHandler(_toString, TOSTRING_HANDLER);
- s.registerMethodCallHandler(_hashCode, HASHCODE_HANDLER);
- }
-
- /* ------------------------------------------------------------------------ */
- /* isDefaultMethodCall method
- /* ------------------------------------------------------------------------ */
- /**
- * This method returns true if and only if the specified call represents a
- * default method call.
- *
- * @param call the call
- * @return see above.
- */
- public static boolean isDefaultMethodCall(MethodCall call)
- {
- return _toString.equals(call) || _equals.equals(call) || _hashCode.equals(call);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.unittest.mocks;
+
+/**
+ *
This class contains method call handlers for some default method handling.
+ *
+ *
+ *
This class provides handlers for the toString, equals and hashCode
+ * methods. They reproduce the default Object implementations for dynamic
+ * mock objects, these can be overridden.
+ *
+ */
+public class DefaultMethodCallHandlers
+{
+ /** A MethodCall representing the equals method */
+ private static MethodCall _equals;
+ /** A MethodCall representing the toString method */
+ private static MethodCall _toString;
+ /** A MethodCall representing the hashCode method */
+ private static MethodCall _hashCode;
+
+ /* ------------------------------------------------------------------------ */
+ /* static initializer
+ /* ------------------------------------------------------------------------ */
+ static
+ {
+ _equals = new MethodCall(Object.class, "equals", new Object[] {Object.class});
+ _toString = new MethodCall(Object.class, "toString", new Object[0]);
+ _hashCode = new MethodCall(Object.class, "hashCode", new Object[0]);
+ }
+
+ /**
+ * The Default MethodCallHandler for the equals method, performs an == check.
+ */
+ public static final MethodCallHandler EQUALS_HANDLER = new MethodCallHandler()
+ {
+ public Object handle(MethodCall methodCall, Skeleton parent) throws Exception
+ {
+ Object obj = methodCall.getInvokedObject();
+ Object toObj = methodCall.getArguments()[0];
+
+ if (toObj == null) return false;
+
+ if(parent.getTemplateObject() != null){
+ try {
+ if(Skeleton.isSkeleton(toObj) &&Skeleton.getSkeleton(toObj).getTemplateObject() != null){
+ return parent.getTemplateObject().equals(Skeleton.getSkeleton(toObj).getTemplateObject());
+ } else {
+ return false;
+ }
+ } catch (IllegalArgumentException iae) {
+ return parent.getTemplateObject().equals(toObj);
+ }
+ }
+
+
+ return obj == toObj ? Boolean.TRUE : Boolean.FALSE;
+ }
+ };
+
+ /**
+ * The Default MethodCallHandler for the toString method, reproduces
+ * @
+ */
+ public static final MethodCallHandler TOSTRING_HANDLER = new MethodCallHandler()
+ {
+ public Object handle(MethodCall methodCall, Skeleton parent) throws Exception
+ {
+ if(parent.getTemplateObject() != null)
+ return parent.getTemplateObject().toString();
+ Object obj = methodCall.getInvokedObject();
+ return obj.getClass().getName() + "@" + System.identityHashCode(obj);
+ }
+ };
+
+ /**
+ * The Default MethodCallHandler for the hashCode method, returns the
+ * identity hashCode.
+ */
+ public static final MethodCallHandler HASHCODE_HANDLER = new MethodCallHandler()
+ {
+ public Object handle(MethodCall methodCall, Skeleton parent) throws Exception
+ {
+ if(parent.getTemplateObject() != null)
+ return parent.getTemplateObject().hashCode();
+
+ return Integer.valueOf(System.identityHashCode(methodCall.getInvokedObject()));
+ }
+ };
+
+ /* ------------------------------------------------------------------------ */
+ /* registerDefaultHandlers method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This method registers the DefaultMethodCall Handlers with the specified
+ * skeleton.
+ *
+ * @param s a skeleton
+ */
+ public static void registerDefaultHandlers(Skeleton s)
+ {
+ s.registerMethodCallHandler(_equals, EQUALS_HANDLER);
+ s.registerMethodCallHandler(_toString, TOSTRING_HANDLER);
+ s.registerMethodCallHandler(_hashCode, HASHCODE_HANDLER);
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* isDefaultMethodCall method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This method returns true if and only if the specified call represents a
+ * default method call.
+ *
+ * @param call the call
+ * @return see above.
+ */
+ public static boolean isDefaultMethodCall(MethodCall call)
+ {
+ return _toString.equals(call) || _equals.equals(call) || _hashCode.equals(call);
+ }
+}
Propchange: incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/DefaultMethodCallHandlers.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/DefaultReturnTypeHandlers.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/DefaultReturnTypeHandlers.java?rev=822565&r1=822564&r2=822565&view=diff
==============================================================================
--- incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/DefaultReturnTypeHandlers.java (original)
+++ incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/DefaultReturnTypeHandlers.java Wed Oct 7 03:00:43 2009
@@ -1,145 +1,145 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.aries.unittest.mocks;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- *
This class contains some return type handlers that provides some default behavior.
- */
-public class DefaultReturnTypeHandlers
-{
- /** A handler for Longs */
- public static final ReturnTypeHandler LONG_HANDLER = new ReturnTypeHandler() {
- public Object handle(Class> class1, Skeleton parent)
- {
- return Long.valueOf(0);
- }
- };
- /** A handler for Integers */
- public static final ReturnTypeHandler INT_HANDLER = new ReturnTypeHandler() {
- public Object handle(Class> class1, Skeleton parent)
- {
- return Integer.valueOf(0);
- }
- };
- /** A handler for Shorts */
- public static final ReturnTypeHandler SHORT_HANDLER = new ReturnTypeHandler() {
- public Object handle(Class> class1, Skeleton parent)
- {
- return Short.valueOf((short)0);
- }
- };
- /** A handler for Bytes */
- public static final ReturnTypeHandler BYTE_HANDLER = new ReturnTypeHandler() {
- public Object handle(Class> class1, Skeleton parent)
- {
- return Byte.valueOf((byte)0);
- }
- };
- /** A handler for Characters */
- public static final ReturnTypeHandler CHAR_HANDLER = new ReturnTypeHandler() {
- public Object handle(Class> class1, Skeleton parent)
- {
- return Character.valueOf(' ');
- }
- };
- /** A handler for Strings */
- public static final ReturnTypeHandler STRING_HANDLER = new ReturnTypeHandler() {
- public Object handle(Class> class1, Skeleton parent)
- {
- return "";
- }
- };
- /** A handler for Lists */
- public static final ReturnTypeHandler LIST_HANDLER = new ReturnTypeHandler() {
- public Object handle(Class> class1, Skeleton parent)
- {
- return new ArrayList