alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

jforum example source code file (VariableExpanderTest.java)

This example jforum source code file (VariableExpanderTest.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - jforum tags/keywords

exception, hashmap, map, map, mystore, mystore, string, string, testcase, util, variableexpander, variableexpander, variableexpandertest, variablestore

The jforum VariableExpanderTest.java source code

/*
 * Created on 28/08/2005 22:23:41
 */
package net.jforum.util.preferences;

import java.util.HashMap;
import java.util.Map;

import junit.framework.TestCase;

/**
 * @author Rafael Steil
 * @version $Id: VariableExpanderTest.java,v 1.1 2005/08/29 02:13:23 rafaelsteil Exp $
 */
public class VariableExpanderTest extends TestCase
{
	private static class MyStore implements VariableStore
	{
		private Map data = new HashMap();
		
		public MyStore()
		{
			this.fill();
		}
		
		private void fill()
		{
			this.data.put("config.dir", "/config");
			this.data.put("database.driver.name", "mysql");
		}
		
		public String getVariableValue(String variableName)
		{
			return (String)this.data.get(variableName);
		}
	}
	
	private VariableExpander extapnder;
	
	private String test = "${config.dir}/database/${database.driver.name}/${database.driver.name}.properties";
	
	/**
	 * @see junit.framework.TestCase#setUp()
	 */
	protected void setUp() throws Exception
	{
		this.extapnder = new VariableExpander(new MyStore(), "${", "}");
	}
	
	public void testExpand()
	{
		String result = this.extapnder.expandVariables(this.test);
		assertEquals("/config/database/mysql/mysql.properties", result);
	}
}

Other jforum examples (source code examples)

Here is a short list of links related to this jforum VariableExpanderTest.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.