You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by cb...@apache.org on 2017/06/25 20:23:54 UTC
svn commit: r1799837 - in /velocity/engine/trunk/velocity-engine-core: ./
src/main/java/org/apache/velocity/runtime/resource/loader/
src/test/java/org/apache/velocity/test/sql/ src/test/resources/ds/
Author: cbrisson
Date: Sun Jun 25 20:23:54 2017
New Revision: 1799837
URL: http://svn.apache.org/viewvc?rev=1799837&view=rev
Log:
[engine] Review DataSourceResourceLoader
- use ResultSet.getCharacterStream()
- fix test case for database genericity
Added:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DBHelper.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/TestDataSource.java
- copied, changed from r1799836, velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/HsqlDataSource.java
Removed:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/HsqlDB.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/HsqlDataSource.java
Modified:
velocity/engine/trunk/velocity-engine-core/pom.xml
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/BaseSQLTest.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/resources/ds/create-db.sql
Modified: velocity/engine/trunk/velocity-engine-core/pom.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/pom.xml?rev=1799837&r1=1799836&r2=1799837&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/pom.xml (original)
+++ velocity/engine/trunk/velocity-engine-core/pom.xml Sun Jun 25 20:23:54 2017
@@ -35,6 +35,16 @@
<!-- command line switch -Dparser.nodefiles=true generates AST Node classes (new structures added to parser) -->
<parser.nodefiles>false</parser.nodefiles>
+
+ <!-- You can modify those properties locally to test
+ the DataSourceResourceLoader against other engines -->
+ <test.jdbc.driver.groupId>org.hsqldb</test.jdbc.driver.groupId>
+ <test.jdbc.driver.artifactId>hsqldb</test.jdbc.driver.artifactId>
+ <test.jdbc.driver.version>2.3.5</test.jdbc.driver.version>
+ <test.jdbc.driver.className>org.hsqldb.jdbcDriver</test.jdbc.driver.className>
+ <test.jdbc.uri>jdbc:hsqldb:.</test.jdbc.uri>
+ <test.jdbc.login>sa</test.jdbc.login>
+ <test.jdbc.password></test.jdbc.password>
</properties>
<build>
@@ -108,6 +118,22 @@
<name>org.slf4j.simpleLogger.logFile</name>
<value>${project.build.directory}/velocity.log</value>
</property>
+ <property>
+ <name>test.jdbc.driver.className</name>
+ <value>${test.jdbc.driver.className}</value>
+ </property>
+ <property>
+ <name>test.jdbc.uri</name>
+ <value>${test.jdbc.uri}</value>
+ </property>
+ <property>
+ <name>test.jdbc.login</name>
+ <value>${test.jdbc.login}</value>
+ </property>
+ <property>
+ <name>test.jdbc.password</name>
+ <value>${test.jdbc.password}</value>
+ </property>
</systemProperties>
</configuration>
<executions>
@@ -169,9 +195,9 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>2.3.4</version>
+ <groupId>${test.jdbc.driver.groupId}</groupId>
+ <artifactId>${test.jdbc.driver.artifactId}</artifactId>
+ <version>${test.jdbc.driver.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java?rev=1799837&r1=1799836&r2=1799837&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java Sun Jun 25 20:23:54 2017
@@ -226,31 +226,14 @@ public class DataSourceResourceLoader ex
if (rs.next())
{
- InputStream rawStream = rs.getAsciiStream(templateColumn);
- if (rawStream == null)
+ Reader reader = rs.getCharacterStream(templateColumn);
+ if (reader == null)
{
throw new ResourceNotFoundException("DataSourceResourceLoader: "
+ "template column for '"
+ name + "' is null");
}
- try
- {
- return buildReader(rawStream, encoding);
- }
- catch (Exception e)
- {
- if (rawStream != null)
- {
- try
- {
- rawStream.close();
- }
- catch(IOException ioe) {}
- }
- String msg = "Exception while loading Template column for " + name;
- log.error(msg, e);
- throw new VelocityException(msg, e);
- }
+ return reader;
}
else
{
Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/BaseSQLTest.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/BaseSQLTest.java?rev=1799837&r1=1799836&r2=1799837&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/BaseSQLTest.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/BaseSQLTest.java Sun Jun 25 20:23:54 2017
@@ -27,8 +27,9 @@ import java.sql.Statement;
/**
* A base class to implement tests that need a running
- * Velocity engine and an initialized Hsql Database. Yeah, I should probably
- * use Derby at some point...
+ * Velocity engine and an initialized HSQLDB Database.
+ * It can also be used to test against other database engines
+ * by means of the proper environment parameters, see velocity-engine-core pom.xml file.
*
* @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
* @version $Id$
@@ -37,23 +38,52 @@ import java.sql.Statement;
public abstract class BaseSQLTest
extends BaseTestCase
{
- private static HsqlDB hsqlDB = null;
+ private static DBHelper dbHelper = null;
+
+ protected String TEST_JDBC_DRIVER_CLASS = System.getProperty("test.jdbc.driver.className");
+ protected String TEST_JDBC_URI = System.getProperty("test.jdbc.uri");
+ protected String TEST_JDBC_LOGIN = System.getProperty("test.jdbc.login");
+ protected String TEST_JDBC_PASSWORD = System.getProperty("test.jdbc.password");
+
+ /**
+ * String (not containing any VTL) used to test unicode
+ */
+ protected String UNICODE_TEMPLATE = "\\u00a9 test \\u0410 \\u0411";
+
+ /**
+ * Name of template for testing unicode.
+ */
+ protected String UNICODE_TEMPLATE_NAME = "testUnicode";
+
public BaseSQLTest(String name, String path)
throws Exception
{
super(name);
- if (hsqlDB == null)
+ if (dbHelper == null)
{
- hsqlDB = new HsqlDB("jdbc:hsqldb:.", path + "/create-db.sql");
+ dbHelper = new DBHelper(TEST_JDBC_DRIVER_CLASS, TEST_JDBC_URI, TEST_JDBC_LOGIN, TEST_JDBC_PASSWORD,path + "/create-db.sql");
+ setUpUnicode();
}
}
+ private void setUpUnicode()
+ throws Exception
+ {
+ String insertString = "insert into velocity_template_varchar (vt_id, vt_timestamp, vt_def) VALUES " +
+ "( '" + UNICODE_TEMPLATE_NAME + "', current_timestamp, '" + UNICODE_TEMPLATE + "');";
+ executeSQL(insertString);
+ insertString = "insert into velocity_template_clob (vt_id, vt_timestamp, vt_def) VALUES " +
+ "( '" + UNICODE_TEMPLATE_NAME + "', current_timestamp, '" + UNICODE_TEMPLATE + "');";
+ executeSQL(insertString);
+ }
+
+
public void executeSQL(String sql)
- throws SQLException
+ throws SQLException
{
- Connection connection = hsqlDB.getConnection();
+ Connection connection = dbHelper.getConnection();
Statement statement = connection.createStatement();
statement.executeUpdate(sql);
}
Added: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DBHelper.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DBHelper.java?rev=1799837&view=auto
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DBHelper.java (added)
+++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DBHelper.java Sun Jun 25 20:23:54 2017
@@ -0,0 +1,103 @@
+package org.apache.velocity.test.sql;
+
+/*
+ * 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.commons.lang3.StringUtils;
+
+import java.io.FileReader;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+
+public class DBHelper
+{
+ private Connection connection = null;
+
+ public DBHelper(String driverClass, String uri, String login, String password, String loadFile) throws Exception
+ {
+ Class.forName(driverClass);
+
+ this.connection = DriverManager.getConnection(uri, login, password);
+
+ if (StringUtils.isNotEmpty(loadFile))
+ {
+ loadSqlFile(loadFile);
+ }
+ }
+
+ public Connection getConnection()
+ {
+ return connection;
+ }
+
+ public void close()
+ {
+
+ try
+ {
+ connection.close();
+ }
+ catch (Exception e)
+ {
+ System.out.println("While closing Connection" + e.getMessage());
+ }
+ }
+
+ private void loadSqlFile(String fileName) throws Exception
+ {
+ Statement statement = null;
+
+ try
+ {
+ statement = connection.createStatement();
+
+ String commands = new String(Files.readAllBytes(Paths.get(fileName)), StandardCharsets.UTF_8);
+
+ for (int targetPos = commands.indexOf(';'); targetPos > -1;
+ targetPos = commands.indexOf(';')) {
+ String cmd = commands.substring(0, targetPos + 1);
+
+ try
+ {
+ statement.execute(cmd);
+ }
+ catch (SQLException sqle)
+ {
+ System.out.println("Statement: " + cmd + ": " +
+ sqle.getMessage());
+ }
+
+ commands = commands.substring(targetPos + 2);
+ }
+ }
+ finally
+ {
+ if (statement != null)
+ {
+ statement.close();
+ }
+ }
+ }
+}
Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java?rev=1799837&r1=1799836&r2=1799837&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java Sun Jun 25 20:23:54 2017
@@ -24,9 +24,10 @@ import junit.framework.TestSuite;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
-import org.apache.velocity.runtime.RuntimeSingleton;
+import org.apache.velocity.runtime.RuntimeInstance;
import org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader;
import org.apache.velocity.test.misc.TestLogger;
+import org.apache.velocity.util.ExtProperties;
import javax.sql.DataSource;
import java.io.BufferedWriter;
@@ -65,21 +66,16 @@ public class DataSourceResourceLoaderTes
*/
private static final String COMPARE_DIR = TEST_COMPARE_DIR + "/ds/templates";
- /**
- * String (not containing any VTL) used to test unicode
- */
- private String UNICODE_TEMPLATE = "\\u00a9 test \\u0410 \\u0411";
+ /* engine with VARCHAR templates data source */
+ private RuntimeInstance varcharTemplatesEngine = null;
- /**
- * Name of template for testing unicode.
- */
- private String UNICODE_TEMPLATE_NAME = "testUnicode";
+ /* engine with CLOB templates data source */
+ private RuntimeInstance clobTemplatesEngine = null;
public DataSourceResourceLoaderTestCase(final String name)
throws Exception
{
super(name, DATA_PATH);
- setUpUnicode();
}
public static Test suite()
@@ -93,33 +89,33 @@ public class DataSourceResourceLoaderTes
assureResultsDirectoryExists(RESULTS_DIR);
- DataSource ds = new HsqlDataSource("jdbc:hsqldb:.");
-
- DataSourceResourceLoader rl = new DataSourceResourceLoader();
- rl.setDataSource(ds);
-
- // pass in an instance to Velocity
- Velocity.reset();
- Velocity.addProperty( "resource.loader", "ds" );
- Velocity.setProperty( "ds.resource.loader.instance", rl );
-
- Velocity.setProperty( "ds.resource.loader.resource.table", "velocity_template");
- Velocity.setProperty( "ds.resource.loader.resource.keycolumn", "id");
- Velocity.setProperty( "ds.resource.loader.resource.templatecolumn", "def");
- Velocity.setProperty( "ds.resource.loader.resource.timestampcolumn", "timestamp");
-
- Velocity.setProperty(
- Velocity.RUNTIME_LOG_INSTANCE, new TestLogger(false, false));
-
- Velocity.init();
- }
-
- public void setUpUnicode()
- throws Exception
- {
- String insertString = "insert into velocity_template (id, timestamp, def) VALUES " +
- "( '" + UNICODE_TEMPLATE_NAME + "', NOW(), '" + UNICODE_TEMPLATE + "');";
- executeSQL(insertString);
+ DataSource ds1 = new TestDataSource(TEST_JDBC_DRIVER_CLASS, TEST_JDBC_URI, TEST_JDBC_LOGIN, TEST_JDBC_PASSWORD);
+ DataSourceResourceLoader rl1 = new DataSourceResourceLoader();
+ rl1.setDataSource(ds1);
+
+ DataSource ds2 = new TestDataSource(TEST_JDBC_DRIVER_CLASS, TEST_JDBC_URI, TEST_JDBC_LOGIN, TEST_JDBC_PASSWORD);
+ DataSourceResourceLoader rl2 = new DataSourceResourceLoader();
+ rl2.setDataSource(ds2);
+
+ ExtProperties props = new ExtProperties();
+ props.addProperty( "resource.loader", "ds" );
+ props.setProperty( "ds.resource.loader.instance", rl1);
+ props.setProperty( "ds.resource.loader.resource.table", "velocity_template_varchar");
+ props.setProperty( "ds.resource.loader.resource.keycolumn", "vt_id");
+ props.setProperty( "ds.resource.loader.resource.templatecolumn", "vt_def");
+ props.setProperty( "ds.resource.loader.resource.timestampcolumn", "vt_timestamp");
+ props.setProperty(Velocity.RUNTIME_LOG_INSTANCE, new TestLogger(false, false));
+
+ varcharTemplatesEngine = new RuntimeInstance();
+ varcharTemplatesEngine.setConfiguration(props);
+ varcharTemplatesEngine.init();
+
+ ExtProperties props2 = (ExtProperties)props.clone();
+ props2.setProperty( "ds.resource.loader.instance", rl2);
+ props2.setProperty( "ds.resource.loader.resource.table", "velocity_template_clob");
+ clobTemplatesEngine = new RuntimeInstance();
+ clobTemplatesEngine.setConfiguration(props2);
+ clobTemplatesEngine.init();
}
/**
@@ -129,14 +125,15 @@ public class DataSourceResourceLoaderTes
public void testSimpleTemplate()
throws Exception
{
- Template t = executeTest("testTemplate1");
+ Template t = executeTest("testTemplate1", varcharTemplatesEngine);
assertFalse("Timestamp is 0", 0 == t.getLastModified());
- }
+ t = executeTest("testTemplate1", clobTemplatesEngine);
+ assertFalse("Timestamp is 0", 0 == t.getLastModified()); }
- public void testUnicode()
- throws Exception
+ public void testUnicode(RuntimeInstance engine)
+ throws Exception
{
- Template template = RuntimeSingleton.getTemplate(UNICODE_TEMPLATE_NAME);
+ Template template = engine.getTemplate(UNICODE_TEMPLATE_NAME);
Writer writer = new StringWriter();
VelocityContext context = new VelocityContext();
@@ -160,7 +157,9 @@ public class DataSourceResourceLoaderTes
public void testRenderTool()
throws Exception
{
- Template t = executeTest("testTemplate2");
+ Template t = executeTest("testTemplate2", varcharTemplatesEngine);
+ assertFalse("Timestamp is 0", 0 == t.getLastModified());
+ t = executeTest("testTemplate2", clobTemplatesEngine);
assertFalse("Timestamp is 0", 0 == t.getLastModified());
}
@@ -170,9 +169,10 @@ public class DataSourceResourceLoaderTes
public void testNullTimestamp()
throws Exception
{
- Template t = executeTest("testTemplate3");
+ Template t = executeTest("testTemplate3", varcharTemplatesEngine);
assertEquals("Timestamp is not 0", 0, t.getLastModified());
- }
+ t = executeTest("testTemplate3", clobTemplatesEngine);
+ assertEquals("Timestamp is not 0", 0, t.getLastModified()); }
/**
* Does it load the global Macros from the DB?
@@ -180,14 +180,16 @@ public class DataSourceResourceLoaderTes
public void testMacroInvocation()
throws Exception
{
- Template t = executeTest("testTemplate4");
+ Template t = executeTest("testTemplate4", varcharTemplatesEngine);
+ assertFalse("Timestamp is 0", 0 == t.getLastModified());
+ t = executeTest("testTemplate4", clobTemplatesEngine);
assertFalse("Timestamp is 0", 0 == t.getLastModified());
}
- protected Template executeTest(final String templateName)
+ protected Template executeTest(final String templateName, RuntimeInstance engine)
throws Exception
{
- Template template = RuntimeSingleton.getTemplate(templateName);
+ Template template = engine.getTemplate(templateName);
FileOutputStream fos =
new FileOutputStream (
@@ -213,12 +215,12 @@ public class DataSourceResourceLoaderTes
public static final class DSRLTCTool
{
- public int add(final int a, final int b)
+ public int add(final int a, final int b)
{
return a + b;
}
- public String getMessage()
+ public String getMessage()
{
return "And the result is:";
}
Copied: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/TestDataSource.java (from r1799836, velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/HsqlDataSource.java)
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/TestDataSource.java?p2=velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/TestDataSource.java&p1=velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/HsqlDataSource.java&r1=1799836&r2=1799837&rev=1799837&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/HsqlDataSource.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/TestDataSource.java Sun Jun 25 20:23:54 2017
@@ -19,8 +19,6 @@ package org.apache.velocity.test.sql;
* under the License.
*/
-import org.hsqldb.jdbcDriver;
-
import javax.sql.DataSource;
import java.io.PrintWriter;
import java.sql.Connection;
@@ -29,54 +27,67 @@ import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;
-public class HsqlDataSource implements DataSource {
+public class TestDataSource implements DataSource
+{
private final String url;
+ private final String user;
+ private final String password;
private PrintWriter logWriter = null;
private int loginTimeout = 0;
- public HsqlDataSource(final String url) throws Exception {
- this.url = url;
- Class.forName(jdbcDriver.class.getName());
+ public TestDataSource(final String driverClass, final String url, final String user, final String password) throws Exception
+ {
+ this.url = url;
+ this.user = user;
+ this.password = password;
+ Class.forName(driverClass);
}
- public Connection getConnection() throws SQLException {
- return DriverManager.getConnection(url, "sa", "");
+ public Connection getConnection() throws SQLException
+ {
+ return DriverManager.getConnection(url, user, password);
}
public Connection getConnection(final String username, final String password)
- throws SQLException {
- return DriverManager.getConnection(url, username, password);
+ throws SQLException
+ {
+ return DriverManager.getConnection(url, username, password);
}
- public PrintWriter getLogWriter() throws SQLException {
- return logWriter;
+ public PrintWriter getLogWriter() throws SQLException
+ {
+ return logWriter;
}
- public int getLoginTimeout() throws SQLException {
- return loginTimeout;
+ public int getLoginTimeout() throws SQLException
+ {
+ return loginTimeout;
}
- public void setLogWriter(final PrintWriter logWriter) throws SQLException {
- this.logWriter = logWriter;
+ public void setLogWriter(final PrintWriter logWriter) throws SQLException
+ {
+ this.logWriter = logWriter;
}
- public void setLoginTimeout(final int loginTimeout) throws SQLException {
- this.loginTimeout = loginTimeout;
+ public void setLoginTimeout(final int loginTimeout) throws SQLException
+ {
+ this.loginTimeout = loginTimeout;
}
- public boolean isWrapperFor(final Class iface) throws SQLException {
- return false;
+ public boolean isWrapperFor(final Class iface) throws SQLException
+ {
+ return false;
}
- public Object unwrap(final Class iface) throws SQLException {
- throw new SQLException("Not implemented");
+ public Object unwrap(final Class iface) throws SQLException
+ {
+ throw new SQLException("Not implemented");
}
- /* added to be able to compile with jdk 1.7 */
-
+ /* added to be able to compile with jdk 1.7+ */
public Logger getParentLogger() throws SQLFeatureNotSupportedException
{
throw new SQLFeatureNotSupportedException();
Modified: velocity/engine/trunk/velocity-engine-core/src/test/resources/ds/create-db.sql
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/ds/create-db.sql?rev=1799837&r1=1799836&r2=1799837&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/resources/ds/create-db.sql (original)
+++ velocity/engine/trunk/velocity-engine-core/src/test/resources/ds/create-db.sql Sun Jun 25 20:23:54 2017
@@ -15,26 +15,39 @@
-- specific language governing permissions and limitations
-- under the License.
-drop table velocity_template if exists;
+drop table if exists velocity_template_1;
+drop table if exists velocity_template_2;
-create table velocity_template (
- id VARCHAR(64) not null,
- timestamp TIMESTAMP,
- def VARCHAR(255) not null
+create table velocity_template_varchar
+(
+ vt_id VARCHAR(64) not null primary key,
+ vt_timestamp TIMESTAMP,
+ vt_def VARCHAR(255) not null
);
-insert into velocity_template (id, timestamp, def) VALUES
+create table velocity_template_clob
+(
+ vt_id VARCHAR(64) not null primary key,
+ vt_timestamp TIMESTAMP,
+ vt_def CLOB not null
+);
+
+insert into velocity_template_varchar (vt_id, vt_timestamp, vt_def) VALUES
( 'testTemplate1', NOW(), 'I am a test through the data loader');
-insert into velocity_template (id, timestamp, def) VALUES
+insert into velocity_template_varchar (vt_id, vt_timestamp, vt_def) VALUES
( 'testTemplate2', NOW(), '$tool.message $tool.add(23, 19)');
-insert into velocity_template (id, def) VALUES
+insert into velocity_template_varchar (vt_id, vt_def) VALUES
( 'testTemplate3', 'This is a template with a null timestamp');
-insert into velocity_template (id, timestamp, def) VALUES
+insert into velocity_template_varchar (vt_id, vt_timestamp, vt_def) VALUES
( 'testTemplate4', NOW(), '#testMacro("foo")');
-insert into velocity_template (id, timestamp, def) VALUES
+insert into velocity_template_varchar (vt_id, vt_timestamp, vt_def) VALUES
( 'VM_global_library.vm', NOW(), '#macro (testMacro $param) I am a macro using $param #end');
+
+-- same templates as clob
+
+insert into velocity_template_clob select * from velocity_template_varchar;