added tests for VariablePlaceholderConfigurer

This commit is contained in:
eeichinger
2009-02-21 11:41:31 +00:00
parent f84fdfa443
commit fe3bc0b39b

View File

@@ -166,5 +166,27 @@ namespace Spring.Objects.Factory.Config
Assert.IsTrue( ex.Message.IndexOf("nickname") > -1 );
}
}
[Test]
public void IgnoresUnresolvableVariable()
{
StaticApplicationContext ac = new StaticApplicationContext();
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.Add("name", "${name}");
pvs.Add("nickname", "${nickname}");
ac.RegisterSingleton("tb1", typeof(TestObject), pvs);
VariablePlaceholderConfigurer vpc = new VariablePlaceholderConfigurer();
vpc.IgnoreUnresolvablePlaceholders = true;
vpc.VariableSource = new DictionaryVariableSource(new string[] {"name", "Erich"});
ac.AddObjectFactoryPostProcessor(vpc);
ac.Refresh();
TestObject tb1 = (TestObject) ac.GetObject("tb1");
Assert.AreEqual("Erich", tb1.Name);
Assert.AreEqual("${nickname}", tb1.Nickname);
}
}
}