view src/test/java/jungle/core/table/AbstractTableTestTemplate.java @ 3:9eb9fabd9f29

added Table framework
author shoshi <shoshi@cr.ie.u-ryukyu.ac.jp>
date Wed, 13 Jun 2012 01:29:02 +0900
parents
children 761d04aecfcb
line wrap: on
line source

package jungle.core.table;

import junit.framework.Assert;
import junit.framework.TestCase;

public abstract class AbstractTableTestTemplate extends TestCase
{
	public abstract Table newInstance();
	
	public Table prepare()
	{
		Table t = newInstance();
		
		t.create(ONE);
		t.create(TWO);
		t.create(THREE);
		
		return t;
	}
	
	public static final String ONE = "one";
	public static final String TWO = "two";
	public static final String THREE = "three";
	
	public void testCreateRecord()
	{
		Table t = newInstance();
		
		Record one = t.create(ONE);
		Record two = t.create(TWO);
		Record three = t.create(THREE);
		
		Assert.assertNotNull(one);
		Assert.assertNotNull(two);
		Assert.assertNotNull(three);
	}
	
	public void testFindRecord()
	{
		Table t = newInstance();
		
		Record one = t.create(ONE);
		Assert.assertNotNull(one);
		Assert.assertEquals(one,t.find(ONE));
	}
	
	public void testRemoveRecord()
	{
		Table t = newInstance();
		
		Record one = t.create(ONE);
		Record two = t.create(TWO);
		
		Assert.assertNotNull(one);
		Assert.assertNotNull(two);
		
		Assert.assertEquals(one,t.remove(ONE));
		Assert.assertEquals(two,t.remove(TWO));
		Assert.assertNull(t.remove(ONE));
		Assert.assertNull(t.remove(TWO));
	}
}