Mercurial > hg > Database > jungle-network
changeset 11:c9ff68c4d82f
modified TestCodeSegment
author | one |
---|---|
date | Wed, 26 Jun 2013 19:02:40 +0900 |
parents | 5376ac62ac08 |
children | 80680cfcfd3b |
files | src/jungle/test/codesegment/practice/TestCodeSegment.java |
diffstat | 1 files changed, 32 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jungle/test/codesegment/practice/TestCodeSegment.java Mon Jun 24 20:40:59 2013 +0900 +++ b/src/jungle/test/codesegment/practice/TestCodeSegment.java Wed Jun 26 19:02:40 2013 +0900 @@ -3,13 +3,24 @@ import java.io.IOException; 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.Command; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; 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.store.impl.logger.TreeOperationLog; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; +import jungle.test.core.NetworkDefaultJungle; import jungle.test.datasegment.store.operations.DefaultTreeOperationLogContainer; +import jungle.test.transaction.NetworkDefaultJungleTreeEditor; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; @@ -19,9 +30,15 @@ public class TestCodeSegment extends CodeSegment { + static Jungle jungle = new NetworkDefaultJungle(null,"hoge",new DefaultTreeEditor(new DefaultTraverser())); + // create input datasegment arg1 Receiver arg1 = ids.create(CommandType.PEEK); + public TestCodeSegment() { + jungle.createNewTree("tree"); + } + @Override public void run() { System.out.println("type = " + arg1.type); @@ -38,8 +55,20 @@ } catch (IOException e) { e.printStackTrace(); } - - for (TreeOperation treeOp : convertedLog) { + printLog(convertedLog); + + JungleTree tree = jungle.getTreeByName("tree"); + NetworkDefaultJungleTreeEditor editor = (NetworkDefaultJungleTreeEditor) tree.getTreeEditor(); + JungleTreeEditor tEditor = editor.setNewLogAndGetEditor(convertedLog); + Either<Error,JungleTreeEditor> either = tEditor.success(); + if (either.isA()) { + throw new IllegalStateException(); + } + System.exit(0); + } + + public void printLog(TreeOperationLog log) { + for (TreeOperation treeOp : log) { NodePath path = treeOp.getNodePath(); NodeOperation nodeOp = treeOp.getNodeOperation(); Command c = nodeOp.getCommand(); @@ -70,20 +99,7 @@ for (int i: path ) { System.out.println(i); } - } - - - - - System.exit(0); - -/* - TestCodeSegment cs = new TestCodeSegment(); - cs.arg1.setKey("key1", arg1.index); - - // DataSegment.get("local").update - ods.update("local", "key1", "String data"); -*/ + } } }