Mercurial > hg > Members > shoshi > jungle > jungle-core
annotate src/test/java/DefaultJungleTreeTest.java @ 175:e26462a38ce0
add push pop
author | tatsuki |
---|---|
date | Fri, 06 Mar 2015 10:44:50 +0900 |
parents | 6615db346bf5 |
children | e5275a599048 |
rev | line source |
---|---|
47 | 1 import java.nio.ByteBuffer; |
75
26dfa90016d1
error delete but 2 test program commentout and not action BulletinBoard
one
parents:
54
diff
changeset
|
2 |
47 | 3 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; |
4 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; | |
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; | |
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; | |
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; | |
54 | 8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; |
75
26dfa90016d1
error delete but 2 test program commentout and not action BulletinBoard
one
parents:
54
diff
changeset
|
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; |
54 | 10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; |
47 | 11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; |
54 | 12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; |
47 | 13 import junit.framework.Assert; |
14 import junit.framework.TestCase; | |
15 | |
166 | 16 public class DefaultJungleTreeTest extends TestCase { |
17 public Jungle instance() { | |
18 Jungle j = new DefaultJungle(null, "hogehoge", new DefaultTreeEditor(new DefaultTraverser())); | |
19 return j; | |
20 } | |
47 | 21 |
166 | 22 public static final String key = "KEY"; |
23 public static final ByteBuffer value = ByteBuffer.wrap(key.getBytes()); | |
24 | |
25 public void testSampleTest() { | |
26 Jungle j = instance(); | |
27 j.createNewTree("tree"); | |
28 JungleTree tree = j.getTreeByName("tree"); | |
29 Assert.assertEquals(0, tree.revision()); | |
30 JungleTreeEditor editor1 = tree.getTreeEditor(); | |
31 JungleTreeEditor editor2 = tree.getTreeEditor(); | |
32 | |
33 DefaultNodePath root = new DefaultNodePath(); | |
34 | |
35 Either<Error, JungleTreeEditor> either = editor1.putAttribute(root, key, value); | |
36 if (either.isA()) { | |
37 Assert.fail(); | |
38 } | |
39 editor1 = either.b(); | |
40 editor1.success(); | |
41 | |
42 // check the value ; | |
43 TreeNode node = tree.getRootNode(); | |
44 ByteBuffer v = node.getAttributes().get(key); | |
45 Assert.assertEquals(0, v.compareTo(value)); | |
46 Assert.assertEquals(1, tree.revision()); | |
47 // editor2 must fail transction | |
48 either = editor2.putAttribute(root, key, value); | |
49 if (either.isA()) { | |
50 Assert.fail(); | |
51 } | |
52 editor2 = either.b(); | |
53 Either<Error, JungleTreeEditor> r = editor2.success(); | |
54 Assert.assertTrue(r.isA()); | |
55 } | |
56 | |
57 public void testIsolation() { | |
58 | |
59 } | |
47 | 60 } |