You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bsf-dev@jakarta.apache.org by Sanka Samaranayake <sa...@opensource.lk> on 2004/06/21 05:11:46 UTC

A testcase for ObjectRegistry

Hi,

can anyone commit this testcase for ObjectRegistry class

cheers !!

Sanka

*********************************************************
*********************************************************


package org.apache.bsf.test.utilTests;

import org.apache.bsf.util.ObjectRegistry;

import junit.framework.TestCase;

/**
 * This is a testcase for ObjectRegistry class
 *
 * @author Sanka Samaranayake <sa...@opensource.lk>
 * @author Nilupa Bandara	  <ni...@opensource.lk>
 *
 */
public class ObjectRegistryTest extends TestCase {

	ObjectRegistry parent = null;
	ObjectRegistry child  = null;

	protected void setUp() throws Exception {
		createObjectRegistry();
		createObjectRegistryObjectRegistry();
	}

	/*
	 * Class under test for void ObjectRegistry()
	 */
	void createObjectRegistry() {
		parent = new ObjectRegistry();
		assertNotNull(parent);
	}

	/*
	 * Class under test for void ObjectRegistry(ObjectRegistry)
	 */
	void createObjectRegistryObjectRegistry() {
		child = new ObjectRegistry(parent);
		assertNotNull(child);
	}

	public void testRegister() {
		Integer foo = new Integer(0);

		try{
			child.register("foo", foo);
			assertEquals(child.lookup("foo"), foo);
		}catch(Exception ex){
			fail(ex.getMessage());
		}
	}

	public void testLookup() {

		Integer foo = new Integer(0);

		try{
			parent.register("foo", foo);
			Integer bar = (Integer)child.lookup("foo");
			assertEquals(bar, foo);
		}catch(Exception ex){
			fail(ex.getMessage());
		}
	}

	public void testUnregister() {

		try{
			child.register("foo", new Integer(0));
			child.unregister("foo");
			child.lookup("foo");
			fail("should throw an IllegalArgumentException ..");
		}catch(Exception ex) {
		}
	}


}


---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-dev-help@jakarta.apache.org