view src/test/java/jungle/core/table/AbstractPropertySequenceTestTemplate.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 AbstractPropertySequenceTestTemplate extends TestCase
{
	public abstract PropertySequence newInstance();
	
	public void testInitialSizeIsZero()
	{
		PropertySequence seq = newInstance();
		Assert.assertEquals(0,seq.size());
	}
	
	public static final String ONE = "one";
	public static final String TWO = "two";
	public static final String THREE = "three";
	
	public PropertySequence prepare()
	{
		PropertySequence seq = newInstance();
		seq.add(ONE);
		seq.add(TWO);
		seq.add(THREE);
		
		return seq;
	}
	
	public void testAdd()
	{
		PropertySequence seq = prepare();
		
		int size = seq.size();
		Assert.assertEquals(3,size);
		
		String one = seq.get(0);
		String two = seq.get(1);
		String three = seq.get(2);
		
		Assert.assertEquals(ONE,one);
		Assert.assertEquals(TWO,two);
		Assert.assertEquals(THREE,three);
	}
	
	public void testGet()
	{
		PropertySequence seq = prepare();
		Assert.assertEquals(ONE,seq.get(0));
	}
	
	public void testSize()
	{
		PropertySequence seq = prepare();
		Assert.assertEquals(3,seq.size());
	}
	
	public void testRemove()
	{
		PropertySequence seq = prepare();
		
		String removed = seq.remove(1);
		Assert.assertEquals(removed,TWO);
		
		Assert.assertEquals(ONE,seq.get(0));
		Assert.assertEquals(THREE,seq.get(1));
	}
	
	public void testThreadSafety()
	{
		Assert.assertTrue(true);
	}
}