diff src/test/java/alice/jungle/log/example/StartCodeSegment.java @ 82:60d28fedcbf2

Remove unnecessary files and move some files
author one
date Wed, 16 Oct 2013 20:53:44 +0900
parents src/jungle/test/codesegment/log/practice/StartCodeSegment.java@87ec5dd0dc27
children f9e29a52efd3
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/alice/jungle/log/example/StartCodeSegment.java	Wed Oct 16 20:53:44 2013 +0900
@@ -0,0 +1,60 @@
+package test.java.alice.jungle.log.example;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.LinkedList;
+import java.util.List;
+
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.AppendChildAtOperation;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DefaultTreeOperation;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteAttributeOperation;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteChildAtOperation;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation;
+import alice.codesegment.CodeSegment;
+import alice.jungle.datasegment.store.container.DefaultTreeOperationLogContainer;
+
+public class StartCodeSegment extends CodeSegment {
+
+	@Override
+	public void run() {
+		System.out.println("run StartCodeSegment");
+		
+		TestCodeSegment cs = new TestCodeSegment();
+		cs.arg1.setKey("log"); 
+		System.out.println("create TestCodeSegment");
+
+		DefaultTreeOperationLog log = getSampleOperationLog();
+		DefaultTreeOperationLogContainer logContainer = new DefaultTreeOperationLogContainer();
+		try {
+			logContainer.unconvert(log);
+			ods.update("local", "log", logContainer);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+ 	}
+	
+	public DefaultTreeOperationLog getSampleOperationLog() {
+		String key = "hoge";
+		ByteBuffer b = ByteBuffer.wrap("messagepack value".getBytes());
+		DefaultNodePath nodePath1 = new DefaultNodePath();
+		nodePath1 = nodePath1.add(1);
+		DefaultNodePath nodePath2 = nodePath1.add(2);
+		AppendChildAtOperation appendChildOp1 = new AppendChildAtOperation(1);
+		AppendChildAtOperation appendChildOp2 = new AppendChildAtOperation(2);
+		PutAttributeOperation putOp = new PutAttributeOperation(key, b);
+		DeleteAttributeOperation deleteOp = new DeleteAttributeOperation("hoge");
+		DeleteChildAtOperation deleteChild = new DeleteChildAtOperation(2);
+		List<TreeOperation> list = new LinkedList<TreeOperation>();
+		list.add(new DefaultTreeOperation(new DefaultNodePath(), appendChildOp1));
+		list.add(new DefaultTreeOperation(nodePath1, appendChildOp2));
+		list.add(new DefaultTreeOperation(nodePath2, putOp));
+		list.add(new DefaultTreeOperation(nodePath2, deleteOp));
+		list.add(new DefaultTreeOperation(nodePath1, deleteChild));
+		DefaultTreeOperationLog log = new DefaultTreeOperationLog(list, list.size());
+		return log;
+	}
+
+}