incubator-composer-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r614256 - in /incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/alternatives: ImplementationHidingContainerTestCase.java issues/Issue0214TestCase.java
Date Tue, 22 Jan 2008 16:55:26 GMT
Author: mauro
Date: Tue Jan 22 08:55:24 2008
New Revision: 614256

URL: http://svn.apache.org/viewvc?rev=614256&view=rev
Log:
Renamed test.

Added:
    incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/alternatives/ImplementationHidingContainerTestCase.java
Removed:
    incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/alternatives/issues/Issue0214TestCase.java

Added: incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/alternatives/ImplementationHidingContainerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/alternatives/ImplementationHidingContainerTestCase.java?rev=614256&view=auto
==============================================================================
--- incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/alternatives/ImplementationHidingContainerTestCase.java
(added)
+++ incubator/composer/trunk/composer-core/src/test/java/org/apache/composer/core/alternatives/ImplementationHidingContainerTestCase.java
Tue Jan 22 08:55:24 2008
@@ -0,0 +1,91 @@
+/**
+ * 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.composer.core.alternatives;
+
+import org.apache.composer.core.DefaultContainer;
+import org.apache.composer.core.MutableContainer;
+import org.apache.composer.core.behaviors.ImplementationHiding;
+import org.apache.composer.core.injectors.ConstructorInjection;
+import org.apache.composer.core.visitors.VerifyingVisitor;
+import org.junit.Test;
+
+public class ImplementationHidingContainerTestCase {
+
+    @Test public void canFindNonNullCtors() {
+        final MutableContainer pico = new DefaultContainer(new ImplementationHiding().wrap(new
ConstructorInjection()));
+        pico.addComponent(A.class);
+
+        /* This is a workaround for the bug described further down. Normally
+         * this method call should only be needed if specific requirements for
+         * parameters exist, but not if Composer shall resolve the
+         * dependencies itself. However, with ImplementationHidingContainer
+         * this is currently the only way to register a class/interface such
+         * that the automatic resolution works.
+         */
+        pico.addComponent(I1.class, B.class);
+
+        /* The following addAdapter(Object, Class) of
+         * ImplementationHidingContainer is buggy, as it contains
+         * "ComponentAdapter delegate = componentFactory.createComponentAdapter(componentKey,
+         * componentImplementation, new Parameter[0]);". Instead of "new
+         * Parameter[0]" it should be "null" to have a behaviour consistent to
+         * DefaultContainer, i.e. if Apache Container shall resolve
+         * dependencies itself.
+         */
+        pico.addComponent(I2.class, C.class);
+
+        /* The following verify() throws the exception, but is expected not to
+         * throw: "org.apache.composer.core.ContainerVerificationException:
+         * [[org.apache.composer.core.PicoCompositionException: Either do the
+         * specified parameters not match any of the following constructors:
+         * [public PicoContainerBugTest$C(PicoContainerBugTest$A)] or the
+         * constructors were not accessible for 'class
+         * PicoContainerBugTest$C']]".
+         *
+         * I believe that the error comes this way: In method
+         * getGreediestSatisfiableConstructor parameters are checked against
+         * null and if parameters is not null it is assumed that specific
+         * parameters have been given so that no automatic resolution takes
+         * place. As now during registration instead of "null" falsly "new
+         * Parameter[0]" was stored, this is now interpreted as if only the
+         * nullary constructor shall be used, and if that doesn't exist, the
+         * exception is thrown.
+         */
+        new VerifyingVisitor().traverse(pico);
+    }
+
+    public static interface I1 {
+    }
+
+    public static interface I2 {
+    }
+
+    public static class A {
+        public A() {
+        }
+    }
+
+    public static class B implements I1 {
+        public B(final A a) {
+        }
+    }
+
+    public static class C implements I2 {
+        public C(final A a) {
+        }
+    }
+}



Mime
View raw message