Author: nbubna
Date: Wed Aug 20 14:12:31 2008
New Revision: 687467
URL: http://svn.apache.org/viewvc?rev=687467&view=rev
Log:
VELOCITY-439 add test case for Velocity[Engine].resourceExists(String)
Added:
velocity/engine/trunk/src/test/org/apache/velocity/test/ResourceExistsTestCase.java
(with props)
velocity/engine/trunk/test/resourceexists/
velocity/engine/trunk/test/resourceexists/testfile.vm (with props)
Added:
velocity/engine/trunk/src/test/org/apache/velocity/test/ResourceExistsTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/ResourceExistsTestCase.java?rev=687467&view=auto
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/ResourceExistsTestCase.java
(added)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/ResourceExistsTestCase.java
Wed Aug 20 14:12:31 2008
@@ -0,0 +1,64 @@
+package org.apache.velocity.test;
+
+/*
+ * 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.
+ */
+
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.log.NullLogChute;
+import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
+import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
+
+/**
+ * Test the resource exists method
+ *
+ * @version $Id: ResourceExistsTestCase.java 687191 2008-08-19 23:02:41Z
nbubna $
+ */
+public class ResourceExistsTestCase extends BaseTestCase
+{
+ private VelocityEngine velocity;
+
+ public ResourceExistsTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ velocity = new VelocityEngine();
+ // pass in an instance to Velocity
+ velocity.addProperty("resource.loader", "myfile,string");
+ velocity.setProperty("myfile.resource.loader.instance", new
FileResourceLoader());
+ velocity.setProperty("myfile.resource.loader.path", TEST_COMPARE_DIR +
"/resourceexists");
+ velocity.setProperty("string.resource.loader.class",
StringResourceLoader.class.getName());
+ velocity.setProperty(velocity.RUNTIME_LOG_LOGSYSTEM_CLASS,
NullLogChute.class.getName());
+ }
+
+ public void testFileResourceExists() throws Exception
+ {
+ assertTrue(velocity.resourceExists("testfile.vm"));
+ assertFalse(velocity.resourceExists("nosuchfile.vm"));
+ }
+
+ public void testStringResourceExists() throws Exception
+ {
+ assertFalse(velocity.resourceExists("foo.vm"));
+ StringResourceLoader.getRepository().putStringResource("foo.vm", "Make
it so!");
+ assertTrue(velocity.resourceExists("foo.vm"));
+ }
+}
Propchange:
velocity/engine/trunk/src/test/org/apache/velocity/test/ResourceExistsTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
velocity/engine/trunk/src/test/org/apache/velocity/test/ResourceExistsTestCase.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
velocity/engine/trunk/src/test/org/apache/velocity/test/ResourceExistsTestCase.java
------------------------------------------------------------------------------
svn:keywords = Revision
Propchange:
velocity/engine/trunk/src/test/org/apache/velocity/test/ResourceExistsTestCase.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: velocity/engine/trunk/test/resourceexists/testfile.vm
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/test/resourceexists/testfile.vm?rev=687467&view=auto
==============================================================================
--- velocity/engine/trunk/test/resourceexists/testfile.vm (added)
+++ velocity/engine/trunk/test/resourceexists/testfile.vm Wed Aug 20 14:12:31
2008
@@ -0,0 +1 @@
+we're just testing that this exists.
Propchange: velocity/engine/trunk/test/resourceexists/testfile.vm
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: velocity/engine/trunk/test/resourceexists/testfile.vm
------------------------------------------------------------------------------
svn:executable = *
Propchange: velocity/engine/trunk/test/resourceexists/testfile.vm
------------------------------------------------------------------------------
svn:mime-type = text/plain