Mercurial > hg > Database > jungle-network
comparison src/test/alice/jungle/PersistenJournalTest.java @ 87:f142dd4abc74
Implemented getTreeName and uuid method in some classes
author | one |
---|---|
date | Tue, 05 Nov 2013 08:41:12 +0900 |
parents | bcaf28f8244d |
children | f3f89613c7e3 |
comparison
equal
deleted
inserted
replaced
86:bcaf28f8244d | 87:f142dd4abc74 |
---|---|
6 | 6 |
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; | 7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; |
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; | 8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; |
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; | 9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; |
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; | 10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; |
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; | |
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader; | 12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader; |
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; | 13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; |
13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; | 14 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; |
14 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; | 15 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; |
15 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; | 16 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; |
41 System.out.println("Failed addNewChildAt"); | 42 System.out.println("Failed addNewChildAt"); |
42 System.exit(0); | 43 System.exit(0); |
43 } | 44 } |
44 editor = either.b(); | 45 editor = either.b(); |
45 either = editor.putAttribute(path, key, value); | 46 either = editor.putAttribute(path, key, value); |
46 | |
47 JungleTreeEditor e = either.b(); | 47 JungleTreeEditor e = either.b(); |
48 e.success(); | 48 e.success(); |
49 journal.close(); | 49 journal.close(); |
50 | 50 |
51 PersistentJournal journal2 = new PersistentJournal(); | 51 PersistentJournal journal2 = new PersistentJournal(); |
66 System.err.println("JungleUpdater Error"); | 66 System.err.println("JungleUpdater Error"); |
67 System.exit(0); | 67 System.exit(0); |
68 } | 68 } |
69 editor2 = either2.b(); | 69 editor2 = either2.b(); |
70 editor2.success(); | 70 editor2.success(); |
71 | 71 printChangeList(chList); |
72 for (TreeOperation op : chList) { | |
73 NodePath p = op.getNodePath(); | |
74 NodeOperation nodeOp = op.getNodeOperation(); | |
75 Command c = nodeOp.getCommand(); | |
76 String str = ""; | |
77 switch (c) { | |
78 case PUT_ATTRIBUTE: | |
79 String opKey = nodeOp.getKey(); | |
80 ByteBuffer opValue = nodeOp.getValue(); | |
81 if (value.limit() < 100) { | |
82 str = String.format("key:%s,value:%s", opKey, | |
83 new String(opValue.array())); | |
84 } else { | |
85 str = String.format("key:%s,value:%d", opKey, | |
86 opValue.limit()); | |
87 } | |
88 break; | |
89 case DELETE_ATTRIBUTE: | |
90 str = String.format("key:%s", nodeOp.getKey()); | |
91 break; | |
92 case APPEND_CHILD: | |
93 str = String.format("pos:%d", nodeOp.getPosition()); | |
94 break; | |
95 case DELETE_CHILD: | |
96 str = String.format("pos:%d", nodeOp.getPosition()); | |
97 break; | |
98 } | |
99 System.out.println(String.format("[%s:%s:%s]", c, p, str)); | |
100 } | |
101 System.out.println(); | 72 System.out.println(); |
102 } | 73 } |
103 JungleTree tree2 = jungle2.getTreeByName("hoge"); | 74 JungleTree tree2 = jungle2.getTreeByName("hoge"); |
104 Node node = tree2.getRootNode(); | 75 Node node = tree2.getRootNode(); |
105 System.out.println("Children size : "+node.getChildren().size()); | 76 System.out.println("Children size : "+node.getChildren().size()); |
106 | 77 |
107 journal2.close(); | 78 journal2.close(); |
108 | 79 |
109 } | 80 } |
110 | 81 |
82 public static void printChangeList(ChangeList chList) { | |
83 for (TreeOperation op : chList) { | |
84 NodePath p = op.getNodePath(); | |
85 NodeOperation nodeOp = op.getNodeOperation(); | |
86 Command c = nodeOp.getCommand(); | |
87 String str = ""; | |
88 switch (c) { | |
89 case PUT_ATTRIBUTE: | |
90 String opKey = nodeOp.getKey(); | |
91 ByteBuffer opValue = nodeOp.getValue(); | |
92 if (opValue.limit() < 100) { | |
93 str = String.format("key:%s,value:%s", opKey, | |
94 new String(opValue.array())); | |
95 } else { | |
96 str = String.format("key:%s,value:%d", opKey, | |
97 opValue.limit()); | |
98 } | |
99 break; | |
100 case DELETE_ATTRIBUTE: | |
101 str = String.format("key:%s", nodeOp.getKey()); | |
102 break; | |
103 case APPEND_CHILD: | |
104 str = String.format("pos:%d", nodeOp.getPosition()); | |
105 break; | |
106 case DELETE_CHILD: | |
107 str = String.format("pos:%d", nodeOp.getPosition()); | |
108 break; | |
109 } | |
110 System.out.println(String.format("[%s:%s:%s]", c, p, str)); | |
111 } | |
112 | |
113 } | |
114 | |
111 } | 115 } |