Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 224:437f6e037bd4
repair persistent
author | tatsuki |
---|---|
date | Sat, 03 Oct 2015 12:05:51 +0900 |
parents | f0cc848b9af6 |
children | cf2c58463e23 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentTransactionManager.java src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/clonable/DefaultTreeNodeAttributesTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/clonable/DefaultTreeNodeChildrenTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/clonable/DefaultTreeNodeTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/DefaultNodeTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/traverse/BruteForceTraverserTest.java |
diffstat | 6 files changed, 1 insertions(+), 302 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentTransactionManager.java Tue Sep 15 17:31:19 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentTransactionManager.java Sat Oct 03 12:05:51 2015 +0900 @@ -41,6 +41,7 @@ PersistentTreeContext newContext = new PersistentTreeContext(_newRoot, tip, list, uuid, treeName, nextRevision, traverser); if (repository.compareAndSet(newContext.prev(), newContext)) { + writer.write(list); TransactionManager txManager = new PersistentTransactionManager(treeName, writer, newContext, repository, uuid); return DefaultEither.newB(txManager); }
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/clonable/DefaultTreeNodeAttributesTest.java Tue Sep 15 17:31:19 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.impl.clonable; - - -import jp.ac.u_ryukyu.ie.cr.jungle.core.Attributes; -import jp.ac.u_ryukyu.ie.cr.jungle.core.AttributesTest; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DefaultTreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Pair; -import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; -import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import java.nio.ByteBuffer; - -public class DefaultTreeNodeAttributesTest extends TestCase -{ - public static TestSuite suite() - { - TestSuite suite = new TestSuite(); - suite.addTestSuite(AttributeTestImpl.class); - //suite.addTestSuite(EditableAttributesTestImpl.class); - return suite; - } - - public static DefaultTreeNode instance() - { - List<TreeNode> rawList = new List(); - TreeMap<String,ByteBuffer> rawMap = new TreeMap(); - - for(Pair<String,ByteBuffer> entry : AttributesTest.ENTRIES){ - rawMap = rawMap.put(entry.left(),entry.right()); - } - - return new DefaultTreeNode(rawList,rawMap); - } - - public static class AttributeTestImpl extends AttributesTest - { - - @Override - public Attributes instance() - { - return DefaultTreeNodeAttributesTest.instance().getAttributes(); - } - - } - - /*public static class EditableAttributesTestImpl extends EditableAttributesTest<DefaultTreeNode> - { - - @Override - public DefaultTreeNodeAttribute instance() - { - DefaultTreeNode instance = DefaultTreeNodeAttributesTest.instance(); - return instance.getAttributes(); - } - - }*/ -}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/clonable/DefaultTreeNodeChildrenTest.java Tue Sep 15 17:31:19 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/*package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.impl.clonable; - -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.nodeeditor.EditableChildrenTest; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.treeeditor.TreeNodeChildrenTest; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.EditableNodeWrapper; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableChildren; -import DefaultTreeNode; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class DefaultTreeNodeChildrenTest extends TestCase -{ - public static TestSuite suite() - { - TestSuite suite = new TestSuite(); - suite.addTestSuite(EditableChildrenTestImpl.class); - suite.addTestSuite(TreeNodeChildrenTestImpl.class); - return suite; - } - - public static DefaultTreeNode instance() - { - return new DefaultTreeNode(); - } - - public static class TreeNodeChildrenTestImpl extends TreeNodeChildrenTest<DefaultTreeNode> - { - @Override - public DefaultTreeNode instance() - { - return DefaultTreeNodeChildrenTest.instance(); - } - } - - public static class EditableChildrenTestImpl extends EditableChildrenTest<EditableNodeWrapper<DefaultTreeNode>> - { - @Override - public EditableChildren<EditableNodeWrapper<DefaultTreeNode>> instance() - { - DefaultTreeNode wrap = DefaultTreeNodeChildrenTest.instance(); - EditableNodeWrapper<DefaultTreeNode> wrapper = new EditableNodeWrapper<DefaultTreeNode>(wrap); - return wrapper.getChildren(); - } - } -}*/
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/clonable/DefaultTreeNodeTest.java Tue Sep 15 17:31:19 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.impl.clonable; - -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DefaultTreeNode; -import junit.framework.Assert; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class DefaultTreeNodeTest extends TestCase -{ - public static TestSuite suite() - { - TestSuite suite = new TestSuite(); - //suite.addTestSuite(AttributesContaierTestImpl.class); - //suite.addTestSuite(ParentTestImpl.class); - return suite; - } - - public static DefaultTreeNode instance() - { - DefaultTreeNode node = new DefaultTreeNode(); - return node; - } - - public void testGetWrapped() - { - DefaultTreeNode instance = instance(); - } - - public void testCreateNewNode() - { - DefaultTreeNode instance = instance(); - DefaultTreeNode node = instance.createNewNode(); - - Assert.assertNotNull(node); - } - -// public static class AttributesContaierTestImpl extends AttributesContainerTest -// { -// @Override -// public AttributesContainer instance() -// { -// return DefaultTreeNodeTest.instance(); -// } -// } - - /*public static class ParentTestImpl extends ParentTest<DefaultTreeNode> - { - - @Override - public DefaultTreeNode instance() - { - return DefaultTreeNodeTest.instance(); - } - }*/ -}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/DefaultNodeTest.java Tue Sep 15 17:31:19 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.impl.node; - - -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DefaultTreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; -import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import java.nio.ByteBuffer; - -public class DefaultNodeTest extends TestCase -{ - public DefaultNodeTest(String _name) - { - super(_name); - } - - public static TestSuite suite() - { - TestSuite suite = new TestSuite(); - //suite.addTestSuite(DefaultNodeTest.AttributesContaierTestImpl.class); - //suite.addTestSuite(DefaultNodeTest.ParentTestImpl.class); - return suite; - } - - public static DefaultTreeNode instance() - { - List<TreeNode> rawList = new List(); - TreeMap<String,ByteBuffer> rawMap = new TreeMap(); - DefaultTreeNode node = new DefaultTreeNode(rawList,rawMap); - - return node; - } - -// public static class AttributesContaierTestImpl extends AttributesContainerTest -// { -// @Override -// public AttributesContainer instance() -// { -// return DefaultNodeTest.instance(); -// } -//// } - - /*public static class ParentTestImpl extends ParentTest<DefaultTreeNode> - { - - @Override - public DefaultTreeNode instance() - { - return DefaultNodeTest.instance(); - } - }*/ -}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/traverse/BruteForceTraverserTest.java Tue Sep 15 17:31:19 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -/*package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverse; - -import java.nio.ByteBuffer; -import java.util.Iterator; - -import JungleTreeEditor; -import NodePath; -import DefaultNodePath; -import TreeNode; -import DefaultTreeNode; -import InterfaceTraverser; -import Either; -import Error; -import Pair; -import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query.SearchQuery; -import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query.UpdateQuery; -import junit.framework.TestCase; - -import org.junit.Assert; -import org.junit.Test; - -public abstract class BruteForceTraverserTest extends TestCase{ - public abstract InterfaceTraverser instance(TreeNode node); - - @Test - public void testSearch() { - int maxHeight = 3; - Pair<TreeNode, NodePath> test = null; - TreeNode root = createTree(0,0,maxHeight,new DefaultNodePath()); - InterfaceTraverser traverser = instance(root); - Iterator<Pair<TreeNode, NodePath>> itNode = traverser.find(new SearchQuery("KEY","<-1,0,0>")); - for(;itNode.hasNext(); ){ - test = itNode.next(); - } - String str = new String(test.left().getAttributes().get("KEY").array()); - Assert.assertEquals(str,"<-1,0,0>"); - } - - @Test - public void testUpdate() { - int maxHeight = 3; - Pair<TreeNode, NodePath> test = null; - TreeNode root = createTree(0,0,maxHeight,new DefaultNodePath()); - InterfaceTraverser traverser = instance(root); - JungleTreeEditor editor = traverser.update(new UpdateQuery("KEY", "<-1,0,0>", "tatsuki")); - traverser.set(editor.getRoot()); - Iterator<Pair<TreeNode, NodePath>> checkNode = traverser.find(new SearchQuery("KEY","tatsuki")); - for(;checkNode.hasNext(); ){ - test = checkNode.next(); - } - String str = new String(test.left().getAttributes().get("KEY").array()); - Assert.assertEquals(str,"tatsuki"); - } - - public static String key = "KEY"; - public static ByteBuffer value = ByteBuffer.wrap(key.getBytes()); - public static DefaultTreeNode factory = new DefaultTreeNode(); - - public static TreeNode createTree(int _curX,int _curY,int _maxHeight,NodePath _address) - { - System.out.println(_address.toString()); - TreeNode parent = factory.createNewNode(); - Either<Error,TreeNode> either = parent.getAttributes().put(key,ByteBuffer.wrap(_address.toString().getBytes())); - if(either.isA()){ - Assert.fail(); - } - parent = either.b(); - - if(_curY == _maxHeight){ - return parent; - } - - for(int i = 0;i < _curY + 1;i ++){ - TreeNode ch = createTree(i,_curY + 1,_maxHeight,_address.add(i)); - either = parent.getChildren().addNewChildAt(i,ch); - if(either.isA()){ - Assert.fail(); - } - - parent = either.b(); - } - - return parent; - } - -} -*/ \ No newline at end of file