Skip to content
Browse files

Test exposing a bug in MethodInjectionPoint

A class with several dependencies injected through its constructor
fails to receive the first dependency if the second one is
constructor-injected and has at least one dependency.
  • Loading branch information...
1 parent a9344e2 commit ced32ba81e9c4557ab70a28b0098a97d8f727855 @chwthewke chwthewke committed Jan 31, 2013
View
15 test/org/swiftsuspenders/InjectorTests.as
@@ -52,6 +52,7 @@ package org.swiftsuspenders
import org.swiftsuspenders.support.injectees.TwoNamedParametersConstructorInjectee;
import org.swiftsuspenders.support.injectees.TwoNamedParametersMethodInjectee;
import org.swiftsuspenders.support.injectees.TwoParametersConstructorInjectee;
+ import org.swiftsuspenders.support.injectees.TwoParametersConstructorInjecteeWithConstructorInjectedDependencies
import org.swiftsuspenders.support.injectees.TwoParametersMethodInjectee;
import org.swiftsuspenders.support.injectees.UnknownInjectParametersListInjectee;
import org.swiftsuspenders.support.injectees.XMLInjectee;
@@ -1121,6 +1122,20 @@ package org.swiftsuspenders
Assert.assertEquals("Instance field 'property1' should be identical to Instance field 'namedProperty2'", injectee.property1, injectee.namedProperty2);
}
+ [Test]
+ public function two_parameters_constructor_injection_with_constructor_injected_dependencies_fulfilled():void
+ {
+ injector.map(Clazz);
+ injector.map(OneParameterConstructorInjectee);
+ injector.map(TwoParametersConstructorInjectee);
+ injector.map(String).toValue('stringDependency');
+
+ var injectee:TwoParametersConstructorInjecteeWithConstructorInjectedDependencies =
+ injector.instantiateUnmapped(TwoParametersConstructorInjecteeWithConstructorInjectedDependencies);
+ Assert.assertNotNull("Instance of Class should have been injected for OneParameterConstructorInjectee parameter", injectee.getDependency1() );
+ Assert.assertNotNull("Instance of Class should have been injected for TwoParametersConstructorInjectee parameter", injectee.getDependency2() );
+ }
+
// [Test]
// public function performInjectionIntoValueWithRecursiveSingletonDependency():void
// {
View
51 .../support/injectees/TwoParametersConstructorInjecteeWithConstructorInjectedDependencies.as
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2009 the original author or authors
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+package org.swiftsuspenders.support.injectees
+{
+ import org.swiftsuspenders.support.types.Clazz;
+
+ public class TwoParametersConstructorInjecteeWithConstructorInjectedDependencies
+ {
+ private var m_dependency1 : OneParameterConstructorInjectee;
+ private var m_dependency2 : TwoParametersConstructorInjectee;
+
+ public function getDependency1() : OneParameterConstructorInjectee
+ {
+ return m_dependency1;
+ }
+
+
+ public function getDependency2():TwoParametersConstructorInjectee
+ {
+ return m_dependency2;
+ }
+
+
+ public function TwoParametersConstructorInjecteeWithConstructorInjectedDependencies(dependency1:OneParameterConstructorInjectee,
+ dependency2:TwoParametersConstructorInjectee)
+ {
+ m_dependency1 = dependency1;
+ m_dependency2 = dependency2;
+ }
+ }
+}

0 comments on commit ced32ba

Please sign in to comment.
Something went wrong with that request. Please try again.