Mercurial > hg > Members > tatsuki > bench > jungle-core
view src/test/java/DefaultJungleTreeTest.java @ 54:650fe2a0dccc
modified tests
author | Shoshi TAMAKI |
---|---|
date | Fri, 08 Feb 2013 17:08:42 +0900 |
parents | 22d8966ab672 |
children | 26dfa90016d1 |
line wrap: on
line source
import java.nio.ByteBuffer; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Result; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; import junit.framework.Assert; import junit.framework.TestCase; public class DefaultJungleTreeTest extends TestCase { public Jungle instance() { Jungle j = new DefaultJungle(null,"hogehoge",new DefaultTreeEditor(new DefaultTraverser())); return j; } public static final String key = "KEY"; public static final ByteBuffer value = ByteBuffer.wrap(key.getBytes()); public void testSampleTest() { Jungle j = instance(); j.createNewTree("tree"); JungleTree tree = j.getTreeByName("tree"); JungleTreeEditor editor1 = tree.getTreeEditor(); JungleTreeEditor editor2 = tree.getTreeEditor(); DefaultNodePath root = new DefaultNodePath(); Either<Error,JungleTreeEditor> either = editor1.putAttribute(root,key,value); if(either.isA()){ Assert.fail(); } editor1 = either.b(); editor1.success(); // check the value ; Node node = tree.getRootNode(); ByteBuffer v = node.getAttributes().get(key); Assert.assertEquals(0,v.compareTo(value)); // editor2 must fail transction either = editor2.putAttribute(root,key,value); if(either.isA()){ Assert.fail(); } editor2 = either.b(); Either<Error,JungleTreeEditor> r = editor2.success(); Assert.assertTrue(r.isA()); } public void testIsolation() { } }