devdaily home | apple | java | perl | unix | directory | blog

What this is

This file 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.

Other links

The source code

package tests;

import java.io.File;
import java.util.*;
import junit.framework.*;

import com.efsol.friki.*;

public class PolicyTest extends TestCase
{
	private Map map;
	private File tmp;
	private File base;
	private Policy p1;

	public PolicyTest(String name)
	{
		super(name);
	}

	public void setUp()
	{
		map = new HashMap();
		tmp = new File("tmp");
		base = new File("base");
		p1 = new Policy(map, tmp, base);
	}

	public void testMissing()
	{
		assertEquals("PolicyTest.missing 1", null, p1.getObject("hoopla"));
	}

	public void testPresent()
	{
		map.put("hoopla", "dunno");
		assertEquals("PolicyTest.present 1", "dunno", p1.getObject("hoopla"));
	}

	public void testConstructor()
	{
		Policy p2 = new Policy(PolicyHelper.makeMap(new String[] {
			"true=false",
			"black=white"
		}), tmp, base);
		assertEquals("PolicyTest.constructor 1", null, p2.getObject("hoopla"));
		assertEquals("PolicyTest.constructor 2", "false", p2.getObject("true"));
		assertEquals("PolicyTest.constructor 3", "white", p2.getObject("black"));
	}
}




Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
 
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com