public void TestGlobalConfig() { VelocityEngine velocityEngine = appContext.GetObject("cnVelocityEngineConfig") as VelocityEngine; Assert.IsNotNull(velocityEngine, "velocity engine is null"); string classProp = TemplateNamespaceParser.getResourceLoaderProperty(VelocityConstants.Assembly, VelocityConstants.Class); string descProp = TemplateNamespaceParser.getResourceLoaderProperty(VelocityConstants.Assembly, VelocityConstants.Description); Assert.AreEqual(VelocityConstants.Assembly, getSingleProperty(velocityEngine, RuntimeConstants.RESOURCE_LOADER), "incorrect resource loader"); Assert.AreEqual("NVelocity.Runtime.Resource.Loader.AssemblyResourceLoader", getSingleProperty(velocityEngine, classProp), "incorrect resource loader type"); Assert.AreEqual("TestDescription", getSingleProperty(velocityEngine, descProp), "incorrect description"); }
public void TestAssemblyBasedConfig() { VelocityEngine velocityEngine = appContext.GetObject("cnAssemblyVelocityEngine") as VelocityEngine; Assert.IsNotNull(velocityEngine, "velocity engine is null"); Assert.AreEqual(VelocityConstants.Assembly, getSingleProperty(velocityEngine, RuntimeConstants.RESOURCE_LOADER), "incorrect resource loader"); Assert.AreEqual(TemplateDefinitionConstants.AssemblyResourceLoaderClass, getSingleProperty(velocityEngine, TemplateNamespaceParser.getResourceLoaderProperty(VelocityConstants.Assembly, VelocityConstants.Class)), "incorrect resource loader type"); Assert.AreEqual("Spring.Template.Velocity.Tests", getSingleProperty(velocityEngine, TemplateNamespaceParser.getResourceLoaderProperty(VelocityConstants.Assembly, VelocityConstants.Assembly)), "incorrect resource loader path"); Assert.AreEqual(DEFAULT_CACHE_SIZE, velocityEngine.GetProperty(RuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZE), "incorrect default cache size"); Assert.AreEqual(DEFAULT_CACHE_FLAG, velocityEngine.GetProperty(VelocityConstants.Assembly + VelocityConstants.Separator + PropertyResourceLoaderCachce), "incorrect caching flag"); AssertMergedValue(velocityEngine, "Spring.Template.Velocity.SimpleTemplate.vm"); }
public void TestFileBasedConfig() { VelocityEngine velocityEngine = appContext.GetObject("cnFileVelocityEngine") as VelocityEngine; Assert.IsNotNull(velocityEngine, "velocity engine is null"); Assert.AreEqual(VelocityConstants.File, getSingleProperty(velocityEngine, RuntimeConstants.RESOURCE_LOADER), "incorrect resource loader"); Assert.AreEqual(TemplateDefinitionConstants.FileResourceLoaderClass, getSingleProperty(velocityEngine, TemplateNamespaceParser.getResourceLoaderProperty(VelocityConstants.File, VelocityConstants.Class)), "incorrect resource loader type"); Assert.AreEqual(new string[] { "Template/Velocity/", "Template/" }, velocityEngine.GetProperty( TemplateNamespaceParser.getResourceLoaderProperty(VelocityConstants.File, VelocityConstants.Path)), "incorrect resource loader path"); Assert.AreEqual(DEFAULT_CACHE_SIZE, velocityEngine.GetProperty(RuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZE), "incorrect default cache size"); Assert.AreEqual(DEFAULT_MOD_CHECK, velocityEngine.GetProperty( VelocityConstants.File + VelocityConstants.Separator + PropertyModificationCheck), "incorrect mod check interval"); Assert.AreEqual(DEFAULT_CACHE_FLAG, velocityEngine.GetProperty(VelocityConstants.File + VelocityConstants.Separator + PropertyResourceLoaderCachce), "incorrect caching flag"); AssertMergedValue(velocityEngine, "SimpleTemplate.vm"); }
public void TestCustomResourceLoader() { VelocityEngine velocityEngine = appContext.GetObject("cnVelocityEngingCustomResourceLoader") as VelocityEngine; Assert.IsNotNull(velocityEngine, "velocity engine is null"); const string PropertyMyResourceLoader = "myResourceLoader"; string classProp = TemplateNamespaceParser.getResourceLoaderProperty(PropertyMyResourceLoader, VelocityConstants.Class); string descProp = TemplateNamespaceParser.getResourceLoaderProperty(PropertyMyResourceLoader, VelocityConstants.Description); Assert.AreEqual(PropertyMyResourceLoader, getSingleProperty(velocityEngine, RuntimeConstants.RESOURCE_LOADER), "incorrect resource loader"); Assert.AreEqual("Spring.Template.Velocity.Config.TestCustomResourceLoader; Spring.Template.Velocity.Castle.Tests", getSingleProperty(velocityEngine, classProp), "incorrect resource loader type"); Assert.AreEqual(PropertyMyResourceLoader, getSingleProperty(velocityEngine, RuntimeConstants.RESOURCE_LOADER), "incorrect resource loader"); Assert.AreEqual("A custom resource loader", getSingleProperty(velocityEngine, descProp), "incorrect resource loader description"); Assert.AreEqual("Template/Velocity/", getSingleProperty(velocityEngine, TemplateNamespaceParser.getResourceLoaderProperty(PropertyMyResourceLoader, VelocityConstants.Path)), "incorrect resource loader path"); AssertMergedValue(velocityEngine, "Template/Velocity/SimpleTemplate.vm"); }
public void TestSpringBasedConfig() { VelocityEngine velocityEngine = appContext.GetObject("cnSpringVelocityEngine") as VelocityEngine; Assert.IsNotNull(velocityEngine, "velocity engine is null"); const string PropertySpring = TemplateDefinitionConstants.Spring; Assert.AreEqual(PropertySpring, getSingleProperty(velocityEngine, RuntimeConstants.RESOURCE_LOADER), "incorrect resource loader"); Assert.AreEqual(TemplateDefinitionConstants.SpringResourceLoaderClass, getSingleProperty(velocityEngine, TemplateNamespaceParser.getResourceLoaderProperty(PropertySpring, VelocityConstants.Class)), "incorrect resource loader type"); // no way to test the path property other than trying to actually perform a merge (it is set in velocity engine as an application attribute which is not exposed) Assert.AreEqual(DEFAULT_CACHE_SIZE, velocityEngine.GetProperty(RuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZE), "incorrect default cache size"); Assert.AreEqual(DEFAULT_CACHE_FLAG, velocityEngine.GetProperty(PropertySpring + VelocityConstants.Separator + PropertyResourceLoaderCachce), "incorrect caching flag"); AssertMergedValue(velocityEngine, "SimpleTemplate.vm"); AssertMergedValue(velocityEngine, "EmbeddedTemplate.vm"); }