You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2006/07/25 02:16:31 UTC

svn commit: r425234 [2/2] - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/internal/ioc/ main/java/org/apache/tapestry/internal/test/ main/java/org/apache/tapestry/ioc/ main/java/org/apache/tapestry/ioc/annotations/ main/...

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/TooManyContributionParametersModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/TooManyContributionParametersModule.java?rev=425234&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/TooManyContributionParametersModule.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/TooManyContributionParametersModule.java Mon Jul 24 17:16:30 2006
@@ -0,0 +1,35 @@
+// 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 org.apache.tapestry.ioc.Configuration;
+import org.apache.tapestry.ioc.OrderedConfiguration;
+import org.apache.tapestry.ioc.annotations.Id;
+
+/**
+ * Used by {@link org.apache.tapestry.internal.ioc.DefaultModuleDefImpl}.
+ * 
+ * @author Howard M. Lewis Ship
+ */
+@Id("ioc.test")
+public class TooManyContributionParametersModule
+{
+
+    public void contributeTooMany(Configuration configuration1, OrderedConfiguration configuration2)
+    {
+
+    }
+
+}

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ValidatingConfigurationWrapperTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ValidatingConfigurationWrapperTest.java?rev=425234&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ValidatingConfigurationWrapperTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ValidatingConfigurationWrapperTest.java Mon Jul 24 17:16:30 2006
@@ -0,0 +1,52 @@
+// 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 org.apache.commons.logging.Log;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.Configuration;
+import org.apache.tapestry.ioc.def.ContributionDef;
+import org.testng.annotations.Test;
+
+/**
+ * @author Howard M. Lewis Ship
+ */
+public class ValidatingConfigurationWrapperTest extends InternalBaseTestCase
+{
+    @Test
+    public void valid_contribution()
+    {
+        ContributionDef def = newContributionDef();
+        Log log = newLog();
+        Configuration configuration = newConfiguration();
+        Runnable value = newRunnable();
+
+        configuration.add(value);
+
+        replay();
+
+        Configuration wrapper = new ValidatingConfigurationWrapper("foo.Bar", log, Runnable.class,
+                def, configuration);
+
+        wrapper.add(value);
+
+        verify();
+    }
+
+    private Runnable newRunnable()
+    {
+        return newMock(Runnable.class);
+    }
+}

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/FindTheParameterizedType.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/FindTheParameterizedType.java?rev=425234&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/FindTheParameterizedType.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/util/FindTheParameterizedType.java Mon Jul 24 17:16:30 2006
@@ -0,0 +1,76 @@
+// 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.util;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tapestry.internal.util.Orderer;
+
+import static java.lang.System.out;
+
+public class FindTheParameterizedType
+{
+
+    /**
+     * @param args
+     */
+    public static void main(String[] args) throws Exception
+    {
+        Method m = FindTheParameterizedType.class.getMethod("method", Map.class, List.class);
+
+        out.println(m.toString());
+        out.println(m.toGenericString());
+
+        Type[] types = m.getGenericParameterTypes();
+        ParameterizedType pt = (ParameterizedType) types[0];
+
+        Type keyType = pt.getActualTypeArguments()[0];
+        Type valueType = pt.getActualTypeArguments()[1];
+
+        out.printf("   key type: %s\n", rawType(keyType));
+        out.printf(" value type: %s\n", rawType(valueType));
+
+        Type listType = types[1];
+
+        out.printf("  list type: %s\n", rawType(listType));
+    }
+
+    private static Class rawType(Type type)
+    {
+        if (type instanceof ParameterizedType)
+        {
+            ParameterizedType pt = (ParameterizedType) type;
+
+            return rawType(pt.getRawType());
+        }
+
+        if (type instanceof Class)
+        {
+            return (Class) type;
+        }
+
+        throw new IllegalArgumentException();
+    }
+
+    public void method(Map<String, Orderer<Runnable>> configuration, List list)
+    {
+
+    }
+
+}