You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2006/07/18 05:07:00 UTC
svn commit: r422949 [2/2] - in /tapestry/tapestry5/tapestry-core/trunk/src:
main/java/org/apache/tapestry/internal/ioc/
main/java/org/apache/tapestry/internal/pageload/
main/java/org/apache/tapestry/internal/parser/
main/java/org/apache/tapestry/intern...
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java?rev=422949&r1=422948&r2=422949&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java Mon Jul 17 20:06:58 2006
@@ -16,15 +16,19 @@
import static org.apache.tapestry.internal.ioc.IOCMessages.buildMethodConflict;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.Set;
+import org.apache.tapestry.internal.util.InternalUtils;
import org.apache.tapestry.ioc.ErrorLog;
import org.apache.tapestry.ioc.IOCConstants;
+import org.apache.tapestry.ioc.def.DecoratorDef;
import org.apache.tapestry.ioc.def.ModuleDef;
+import org.apache.tapestry.ioc.def.ServiceDef;
import org.apache.tapestry.test.TestBase;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -43,9 +47,9 @@
// BigDecimal is arbitrary, any class would do.
- ModuleDef g = new DefaultModuleDefImpl(BigDecimal.class, log);
+ ModuleDef md = new DefaultModuleDefImpl(BigDecimal.class, log);
- Assert.assertEquals("java.math", g.getModuleId());
+ Assert.assertEquals("java.math", md.getModuleId());
verify();
}
@@ -59,9 +63,9 @@
// BigDecimal is arbitrary, any class would do.
- ModuleDef g = new DefaultModuleDefImpl(ModuleBuilderWithId.class, log);
+ ModuleDef md = new DefaultModuleDefImpl(ModuleBuilderWithId.class, log);
- Assert.assertEquals("tapestry.ioc", g.getModuleId());
+ Assert.assertEquals("tapestry.ioc", md.getModuleId());
verify();
}
@@ -69,41 +73,57 @@
@Test
public void simple_module() throws Exception
{
+ String className = SimpleModuleBuilder.class.getName();
+
ErrorLog log = newErrorLog();
replay();
// BigDecimal is arbitrary, any class would do.
- ModuleDef g = new DefaultModuleDefImpl(SimpleModuleBuilder.class, log);
+ ModuleDef md = new DefaultModuleDefImpl(SimpleModuleBuilder.class, log);
- Set<String> ids = g.getServiceIds();
+ Set<String> ids = md.getServiceIds();
assertEquals(ids.size(), 2);
assertTrue(ids.contains("ioc.Fred"));
assertTrue(ids.contains("ioc.Barney"));
- ServiceDefImpl sd = (ServiceDefImpl) g.getServiceDef("ioc.Fred");
+ ServiceDef sd = md.getServiceDef("ioc.Fred");
assertEquals(sd.getServiceId(), "ioc.Fred");
assertEquals(sd.getServiceInterface(), FieService.class);
- assertEquals(sd.getBuilderMethod(), SimpleModuleBuilder.class.getMethod("buildFred"));
+ assertEquals(sd.toString(), className + ".buildFred()");
assertEquals(sd.getServiceLifeycle(), IOCConstants.DEFAULT_LIFECYCLE);
assertEquals(sd.isPrivate(), false);
- sd = (ServiceDefImpl) g.getServiceDef("ioc.Barney");
+ sd = md.getServiceDef("ioc.Barney");
assertEquals(sd.getServiceId(), "ioc.Barney");
assertEquals(sd.getServiceInterface(), FoeService.class);
- assertEquals(sd.getBuilderMethod(), SimpleModuleBuilder.class.getMethod("buildBarney"));
+ assertEquals(sd.toString(), className + ".buildBarney()");
assertEquals(sd.getServiceLifeycle(), "threaded");
assertEquals(sd.isPrivate(), true);
+ // Now the decorator method.
+
+ Set<DecoratorDef> defs = md.getDecoratorDefs();
+
+ assertEquals(defs.size(), 1);
+
+ DecoratorDef dd = defs.iterator().next();
+
+ assertEquals(dd.getDecoratorId(), "ioc.Logging");
+ assertNull(dd.getAfter());
+ assertNull(dd.getBefore());
+ assertEquals(dd.toString(), className + ".decorateLogging(Class, Object)");
+
verify();
+
}
/** Two different methods both claim to build the same service. */
@@ -111,9 +131,8 @@
public void service_id_conflict() throws Exception
{
Method conflictMethod = ServiceIdConflictMethodBuilder.class.getMethod("buildFred");
- String expectedMethod = ServiceIdConflictMethodBuilder.class.getMethod(
- "buildFred",
- Object.class).toString();
+ String expectedMethod = InternalUtils.asString(ServiceIdConflictMethodBuilder.class
+ .getMethod("buildFred", Object.class));
ErrorLog log = newErrorLog();
@@ -123,14 +142,14 @@
// BigDecimal is arbitrary, any class would do.
- ModuleDef g = new DefaultModuleDefImpl(ServiceIdConflictMethodBuilder.class, log);
+ ModuleDef md = new DefaultModuleDefImpl(ServiceIdConflictMethodBuilder.class, log);
- Set<String> ids = g.getServiceIds();
+ Set<String> ids = md.getServiceIds();
- Assert.assertEquals(ids.size(), 1);
- Assert.assertTrue(ids.contains("ioc.Fred"));
+ assertEquals(ids.size(), 1);
+ assertTrue(ids.contains("ioc.Fred"));
- ServiceDefImpl sd = (ServiceDefImpl) g.getServiceDef("ioc.Fred");
+ ServiceDef sd = md.getServiceDef("ioc.Fred");
assertEquals(sd.getServiceId(), "ioc.Fred");
@@ -145,4 +164,76 @@
verify();
}
+ @Test
+ public void builder_method_returns_void() throws Exception
+ {
+ Method m = VoidBuilderMethodModule.class.getMethod("buildNull");
+
+ ErrorLog log = newErrorLog();
+
+ log.warn(IOCMessages.buildMethodWrongReturnType(m), null);
+
+ replay();
+
+ ModuleDef md = new DefaultModuleDefImpl(VoidBuilderMethodModule.class, log);
+
+ assertTrue(md.getServiceIds().isEmpty());
+
+ verify();
+ }
+
+ @Test
+ public void decorator_method_returns_void() throws Exception
+ {
+ invalidDecoratorMethod(VoidDecoratorMethodModule.class, "decorateVoid");
+ }
+
+ private void invalidDecoratorMethod(Class moduleClass, String methodName)
+ throws NoSuchMethodException
+ {
+ Method m = moduleClass.getMethod(methodName, Object.class);
+
+ ErrorLog log = newErrorLog();
+
+ log.warn(IOCMessages.decoratorMethodWrongReturnType(m), null);
+
+ replay();
+
+ ModuleDef md = new DefaultModuleDefImpl(moduleClass, log);
+
+ assertTrue(md.getDecoratorDefs().isEmpty());
+
+ verify();
+ }
+
+ @Test
+ public void decorator_method_returns_primitive() throws Exception
+ {
+ invalidDecoratorMethod(PrimitiveDecoratorMethodModule.class, "decoratePrimitive");
+ }
+
+ @Test
+ public void decorator_method_returns_array() throws Exception
+ {
+ invalidDecoratorMethod(ArrayDecoratorMethodModule.class, "decorateArray");
+ }
+
+ @Test
+ public void decorator_method_does_not_include_delegate_parameter() throws Exception
+ {
+ Class moduleClass = NoDelegateDecoratorMethodModule.class;
+ Method m = moduleClass.getMethod("decorateNoDelegate");
+
+ ErrorLog log = newErrorLog();
+
+ log.warn(IOCMessages.decoratorMethodNeedsDelegateParameter(m), null);
+
+ replay();
+
+ ModuleDef md = new DefaultModuleDefImpl(moduleClass, log);
+
+ assertTrue(md.getDecoratorDefs().isEmpty());
+
+ verify();
+ }
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java?rev=422949&r1=422948&r2=422949&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java Mon Jul 17 20:06:58 2006
@@ -23,6 +23,9 @@
import org.apache.tapestry.ioc.Registry;
import org.apache.tapestry.ioc.RegistryBuilder;
import org.apache.tapestry.ioc.def.ModuleDef;
+import org.apache.tapestry.ioc.def.ServiceDef;
+import org.apache.tapestry.util.CollectionFactory;
+import org.easymock.EasyMock;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
@@ -53,6 +56,8 @@
module,
new ClassFactoryImpl());
+ trainFindDecoratorsForService(registry);
+
replay();
UpcaseService service = module.getService("ioc.test.Upcase", UpcaseService.class, module);
@@ -62,6 +67,12 @@
verify();
}
+ private void trainFindDecoratorsForService(InternalRegistry registry)
+ {
+ registry.findDecoratorsForService(EasyMock.isA(ServiceDef.class));
+ setReturnValue(CollectionFactory.newList());
+ }
+
@Test
public void get_service_by_id_private()
{
@@ -80,6 +91,8 @@
ClassFactory.class,
module,
new ClassFactoryImpl());
+
+ trainFindDecoratorsForService(registry);
replay();
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/NoDelegateDecoratorMethodModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/NoDelegateDecoratorMethodModule.java?rev=422949&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/NoDelegateDecoratorMethodModule.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/NoDelegateDecoratorMethodModule.java Mon Jul 17 20:06:58 2006
@@ -0,0 +1,32 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed 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.tapestry.internal.ioc;
+
+/**
+ * Used by {@link org.apache.tapestry.internal.ioc.DefaultModuleDefImplTest}.
+ *
+ * @author Howard M. Lewis Ship
+ */
+public class NoDelegateDecoratorMethodModule
+{
+ /**
+ * Decorator methods need to define a parameter of type Object which is the delegate object.
+ * Typically, it is a parameterized type, but it has to be there.
+ */
+ public Object decorateNoDelegate()
+ {
+ return null;
+ }
+}
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/PrimitiveDecoratorMethodModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/PrimitiveDecoratorMethodModule.java?rev=422949&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/PrimitiveDecoratorMethodModule.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/PrimitiveDecoratorMethodModule.java Mon Jul 17 20:06:58 2006
@@ -0,0 +1,28 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed 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.tapestry.internal.ioc;
+
+/**
+ * Used by {@link org.apache.tapestry.internal.ioc.DefaultModuleDefImplTest}.
+ *
+ * @author Howard M. Lewis Ship
+ */
+public class PrimitiveDecoratorMethodModule
+{
+ public int decoratePrimitive(Object delegate)
+ {
+ return 0;
+ }
+}
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java?rev=422949&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java Mon Jul 17 20:06:58 2006
@@ -0,0 +1,193 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed 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.tapestry.internal.ioc;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertSame;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.ErrorLog;
+import org.apache.tapestry.ioc.ServiceResources;
+import org.testng.annotations.Test;
+
+/**
+ * @author Howard M. Lewis Ship
+ */
+public class ServiceDecoratorImplTest extends InternalBaseTestCase
+{
+ private static final String SERVICE_ID = "ioc.Fie";
+
+ private Object _expectedDelegate;
+
+ private Object _interceptorToReturn;
+
+ private RuntimeException _exception;
+
+ @Test
+ public void decorator_returns_interceptor() throws Exception
+ {
+ ServiceResources resources = newServiceResources();
+ ErrorLog errorLog = newErrorLog();
+ Log log = newLog();
+ _expectedDelegate = newFieService();
+ _interceptorToReturn = newFieService();
+
+ trainForConstructor(resources, errorLog, log);
+
+ replay();
+
+ // Check that the delegate gets passed in; check that the return value of the
+ // decorator method is the return value of the ServiceDecorator.
+
+ Method m = getClass().getMethod("decoratorReturnsInterceptor", Object.class);
+
+ ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, this, resources);
+
+ Object interceptor = decorator.createInterceptor(_expectedDelegate);
+
+ assertSame(interceptor, _interceptorToReturn);
+
+ verify();
+ }
+
+ public Object decoratorReturnsInterceptor(Object delegate)
+ {
+ assertSame(delegate, _expectedDelegate);
+
+ return _interceptorToReturn;
+ }
+
+ @Test
+ public void decorator_returns_null_interceptor() throws Exception
+ {
+ ServiceResources resources = newServiceResources();
+ ErrorLog errorLog = newErrorLog();
+ Log log = newLog();
+ Object delegate = newFieService();
+
+ trainForConstructor(resources, errorLog, log);
+
+ replay();
+
+ Method m = getClass().getMethod("decorateReturnNull", Object.class);
+
+ ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, this, resources);
+
+ Object interceptor = decorator.createInterceptor(delegate);
+
+ assertNull(interceptor);
+
+ verify();
+ }
+
+ @Test
+ public void decorator_returns_incorrect_type() throws Exception
+ {
+ ServiceResources resources = newServiceResources();
+ ErrorLog errorLog = newErrorLog();
+ Log log = newLog();
+ _expectedDelegate = newFieService();
+ _interceptorToReturn = newMock(FoeService.class);
+
+ Method m = getClass().getMethod("decoratorReturnsInterceptor", Object.class);
+
+ trainForConstructor(resources, errorLog, log);
+
+ errorLog.warn(IOCMessages.decoratorReturnedWrongType(
+ m,
+ SERVICE_ID,
+ _interceptorToReturn,
+ FieService.class), null);
+
+ replay();
+
+ ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, this, resources);
+
+ Object interceptor = decorator.createInterceptor(_expectedDelegate);
+
+ assertNull(interceptor);
+
+ verify();
+ }
+
+ @Test
+ public void decorator_method_throws_exception() throws Exception
+ {
+ ServiceResources resources = newServiceResources();
+ ErrorLog errorLog = newErrorLog();
+ Log log = newLog();
+ Object delegate = newFieService();
+ _exception = new RuntimeException("Ouch!");
+
+ trainForConstructor(resources, errorLog, log);
+
+ replay();
+
+ Method m = getClass().getMethod("decoratorThrowsException", Object.class);
+
+ ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, this, resources);
+
+ try
+ {
+ decorator.createInterceptor(delegate);
+ unreachable();
+ }
+ catch (RuntimeException ex)
+ {
+ assertEquals(ex.getMessage(), IOCMessages.decoratorMethodError(m, SERVICE_ID, ex
+ .getCause()));
+
+ InvocationTargetException te = (InvocationTargetException) ex.getCause();
+ RuntimeException inner = (RuntimeException) te.getCause();
+
+ assertSame(inner, _exception);
+ }
+
+ verify();
+
+ }
+
+ public Object decoratorThrowsException(Object delegate)
+ {
+ throw _exception;
+ }
+
+ private FieService newFieService()
+ {
+ return newMock(FieService.class);
+ }
+
+ public Object decorateReturnNull(Object delegate)
+ {
+ return null;
+ }
+
+ private void trainForConstructor(ServiceResources resources, ErrorLog errorLog, Log log)
+ {
+ trainGetServiceId(resources, SERVICE_ID);
+
+ trainGetErrorLog(resources, errorLog);
+
+ trainGetServiceInterface(resources, FieService.class);
+
+ trainGetServiceLog(resources, log);
+ }
+
+}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/SimpleModuleBuilder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/SimpleModuleBuilder.java?rev=422949&r1=422948&r2=422949&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/SimpleModuleBuilder.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/SimpleModuleBuilder.java Mon Jul 17 20:06:58 2006
@@ -40,6 +40,14 @@
public void ignoredMethod()
{
+ }
+ /**
+ * Minimal decorator method that uses generics to qualify the delegate passed in and the object
+ * returned.
+ */
+ public <T> T decorateLogging(Class<T> serviceInterace, T delegate)
+ {
+ return null;
}
}
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/VoidBuilderMethodModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/VoidBuilderMethodModule.java?rev=422949&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/VoidBuilderMethodModule.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/VoidBuilderMethodModule.java Mon Jul 17 20:06:58 2006
@@ -0,0 +1,28 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed 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.tapestry.internal.ioc;
+
+/**
+ * Used by {@link org.apache.tapestry.internal.ioc.DefaultModuleDefImplTest}.
+ *
+ * @author Howard M. Lewis Ship
+ */
+public class VoidBuilderMethodModule
+{
+ /** Builder methods should not return void. */
+ public void buildNull()
+ {
+ }
+}
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/VoidDecoratorMethodModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/VoidDecoratorMethodModule.java?rev=422949&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/VoidDecoratorMethodModule.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/VoidDecoratorMethodModule.java Mon Jul 17 20:06:58 2006
@@ -0,0 +1,33 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed 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.tapestry.internal.ioc;
+
+/**
+ * Used by {@link org.apache.tapestry.internal.ioc.DefaultModuleDefImplTest}.
+ *
+ * @author Howard M. Lewis Ship
+ */
+public class VoidDecoratorMethodModule
+{
+ /**
+ * Decorator methods are not supposed to return void. They can return null.
+ *
+ * @param delegate
+ */
+ public void decorateVoid(Object delegate)
+ {
+
+ }
+}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java?rev=422949&r1=422948&r2=422949&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java Mon Jul 17 20:06:58 2006
@@ -14,6 +14,14 @@
package org.apache.tapestry.internal.transform;
+import static java.lang.Thread.currentThread;
+import static java.util.Arrays.asList;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
import java.lang.annotation.Documented;
import java.lang.annotation.Target;
import java.lang.reflect.Modifier;
@@ -43,15 +51,6 @@
import org.apache.tapestry.transform.ClassTransformation;
import org.testng.annotations.Configuration;
import org.testng.annotations.Test;
-
-import static java.lang.Thread.currentThread;
-import static java.util.Arrays.asList;
-import static org.apache.tapestry.util.CollectionFactory.newList;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertSame;
-import static org.testng.Assert.assertTrue;
/**
* @author Howard M. Lewis Ship
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/InternalUtilsTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/InternalUtilsTest.java?rev=422949&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/InternalUtilsTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/InternalUtilsTest.java Mon Jul 17 20:06:58 2006
@@ -0,0 +1,72 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed 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.tapestry.internal.util;
+
+import static org.testng.Assert.assertEquals;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author Howard M. Lewis Ship
+ */
+public class InternalUtilsTest
+{
+ @Test
+ public void method_as_string_no_args() throws Exception
+ {
+
+ Method m = Object.class.getMethod("toString");
+
+ assertEquals(InternalUtils.asString(m), "java.lang.Object.toString()");
+ }
+
+ @Test
+ public void method_as_string_with_args() throws Exception
+ {
+ Method m = Collections.class.getMethod("sort", List.class, Comparator.class);
+
+ assertEquals(InternalUtils.asString(m), "java.util.Collections.sort(List, Comparator)");
+ }
+
+ @Test
+ public void method_as_string_primitive_arg() throws Exception
+ {
+ Method m = Object.class.getMethod("wait", long.class);
+
+ assertEquals(InternalUtils.asString(m), "java.lang.Object.wait(long)");
+ }
+
+ @Test
+ public void method_as_string_primitive_array_arg() throws Exception
+ {
+ Method m = Arrays.class.getMethod("sort", int[].class);
+
+ assertEquals(InternalUtils.asString(m), "java.util.Arrays.sort(int[])");
+ }
+
+ @Test
+ public void method_as_string_array_arg() throws Exception
+ {
+ Method m = Arrays.class.getMethod("sort", Object[].class);
+
+ assertEquals(InternalUtils.asString(m), "java.util.Arrays.sort(Object[])");
+ }
+}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/CollectionFactoryTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/CollectionFactoryTest.java?rev=422949&r1=422948&r2=422949&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/CollectionFactoryTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/CollectionFactoryTest.java Mon Jul 17 20:06:58 2006
@@ -14,6 +14,7 @@
package org.apache.tapestry.util;
+import static java.util.Arrays.asList;
import static org.apache.tapestry.util.CollectionFactory.newList;
import static org.apache.tapestry.util.CollectionFactory.newMap;
import static org.apache.tapestry.util.CollectionFactory.newSet;
@@ -68,6 +69,18 @@
Set<String> set = newSet();
assertTrue(set instanceof HashSet);
+ }
+
+ @Test
+ public void copy_set()
+ {
+ List<String> start = asList("fred", "barney");
+
+ Set<String> set = newSet(start);
+
+ assertEquals(set.size(), 2);
+ assertTrue(set.contains("fred"));
+ assertTrue(set.contains("barney"));
}
@Test