Java Code Examples for org.apache.velocity.app.Velocity#addProperty()

The following examples show how to use org.apache.velocity.app.Velocity#addProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultipleFileResourcePathTestCase.java    From velocity-engine with Apache License 2.0 6 votes vote down vote up
public void setUp()
        throws Exception
{
    assureResultsDirectoryExists(RESULTS_DIR);

    Velocity.reset();

    Velocity.addProperty(
            Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH1);

    Velocity.addProperty(
            Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH2);

    Velocity.setProperty(
            Velocity.RUNTIME_LOG_INSTANCE, new TestLogger());

    Velocity.init();
}
 
Example 2
Source File: StringResourceLoaderRepositoryTestCase.java    From velocity-engine with Apache License 2.0 6 votes vote down vote up
public void setUp() throws Exception
{
    Velocity.reset();
    Velocity.setProperty(Velocity.RESOURCE_LOADERS, "string");
    Velocity.addProperty("string.resource.loader.class", StringResourceLoader.class.getName());
    Velocity.addProperty("string.resource.loader.modificationCheckInterval", "1");
    Velocity.setProperty(Velocity.RUNTIME_LOG_INSTANCE, new TestLogger());
    Velocity.init();

    StringResourceRepository repo = getRepo(null, null);
    repo.putStringResource("foo", "This is $foo");
    repo.putStringResource("bar", "This is $bar");

    context = new VelocityContext();
    context.put("foo", "wonderful!");
    context.put("bar", "horrible!");
    context.put("woogie", "a woogie");
}
 
Example 3
Source File: StringResourceLoaderTestCase.java    From velocity-engine with Apache License 2.0 6 votes vote down vote up
public void setUp()
        throws Exception
{
    assureResultsDirectoryExists(RESULTS_DIR);

    Velocity.reset();

    Velocity.setProperty(Velocity.RESOURCE_LOADERS, "string");
    Velocity.addProperty("string.resource.loader.class", StringResourceLoader.class.getName());
    Velocity.addProperty("string.resource.loader.modificationCheckInterval", "1");

    // Silence the logger.
    Velocity.setProperty(Velocity.RUNTIME_LOG_INSTANCE, new TestLogger());

    Velocity.init();
}
 
Example 4
Source File: ClasspathResourceTestCase.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
public void setUp()
        throws Exception
{
    assureResultsDirectoryExists(RESULTS_DIR);

    Velocity.reset();
    Velocity.setProperty(Velocity.RESOURCE_LOADERS, "classpath");

    /*
     * I don't think I should have to do this, these should
     * be in the default config file.
     */

    Velocity.addProperty(
            "classpath." + Velocity.RESOURCE_LOADER + ".class",
            "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

    Velocity.setProperty(
            "classpath." + Velocity.RESOURCE_LOADER + ".cache", "false");

    Velocity.setProperty(
            "classpath." + Velocity.RESOURCE_LOADER + ".modificationCheckInterval",
            "2");

    Velocity.setProperty(
            Velocity.RUNTIME_LOG_INSTANCE, new TestLogger());

    Velocity.init();
}
 
Example 5
Source File: ChainedUberspectorsTestCase.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
public void setUp()
        throws Exception
{
    Velocity.reset();
    Velocity.setProperty(Velocity.RUNTIME_LOG_INSTANCE, new TestLogger());
    Velocity.addProperty(Velocity.UBERSPECT_CLASSNAME,"org.apache.velocity.util.introspection.UberspectImpl");
    Velocity.addProperty(Velocity.UBERSPECT_CLASSNAME,"org.apache.velocity.test.util.introspection.ChainedUberspectorsTestCase$ChainedUberspector");
    Velocity.addProperty(Velocity.UBERSPECT_CLASSNAME,"org.apache.velocity.test.util.introspection.ChainedUberspectorsTestCase$LinkedUberspector");
 Velocity.init();
}
 
Example 6
Source File: MultiLoaderTestCase.java    From velocity-engine with Apache License 2.0 4 votes vote down vote up
public void setUp()
        throws Exception
{
    assureResultsDirectoryExists(RESULTS_DIR);

    /*
     * Set up the file loader.
     */

    Velocity.reset();

    Velocity.setProperty(Velocity.RESOURCE_LOADERS, "file");

    Velocity.setProperty(
        Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);

    Velocity.addProperty(Velocity.RESOURCE_LOADERS, "classpath");

    Velocity.addProperty(Velocity.RESOURCE_LOADERS, "jar");

    /*
     *  Set up the classpath loader.
     */

    Velocity.setProperty(
        Velocity.RESOURCE_LOADER + ".classpath.class",
        "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

    Velocity.setProperty(
        Velocity.RESOURCE_LOADER + ".classpath.cache",
        "false");

    Velocity.setProperty(
        Velocity.RESOURCE_LOADER + ".classpath.modification_check_interval",
        "2");

    /*
     *  setup the Jar loader
     */

    Velocity.setProperty(
        Velocity.RESOURCE_LOADER + ".jar.class",
        "org.apache.velocity.runtime.resource.loader.JarResourceLoader");

    Velocity.setProperty(
        Velocity.RESOURCE_LOADER + ".jar.path",
        "jar:file:" + FILE_RESOURCE_LOADER_PATH + "/test2.jar" );


    Velocity.setProperty(
            Velocity.RUNTIME_LOG_INSTANCE, new TestLogger());

    Velocity.init();
}
 
Example 7
Source File: IncludeEventHandlingTestCase.java    From velocity-engine with Apache License 2.0 4 votes vote down vote up
public void setUp()
        throws Exception
{
    assureResultsDirectoryExists(RESULTS_DIR);

    Velocity.reset();
    Velocity.addProperty(
        Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);

    Velocity.setProperty(
            Velocity.RUNTIME_LOG_INSTANCE, new TestLogger());

    Velocity.init();


}
 
Example 8
Source File: Velocity580TestCase.java    From velocity-engine with Apache License 2.0 3 votes vote down vote up
public void setUp() throws Exception
{

    assureResultsDirectoryExists(RESULTS_DIR);

    Velocity.reset();

    Velocity.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, TEMPLATE_DIR);

    Velocity.setProperty(Velocity.RUNTIME_LOG_INSTANCE, new TestLogger());

    Velocity.init();
}