Mercurial > hg > Members > nobuyasu > jungle-network
changeset 13:f3c0a65c3f12
TestCodeSegment use asClass
author | one |
---|---|
date | Thu, 27 Jun 2013 21:02:58 +0900 |
parents | 80680cfcfd3b |
children | 6dc6b25021a3 |
files | src/jungle/test/codesegment/practice/StartCodeSegment.java src/jungle/test/codesegment/practice/TestCodeSegment.java |
diffstat | 2 files changed, 18 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jungle/test/codesegment/practice/StartCodeSegment.java Wed Jun 26 19:03:19 2013 +0900 +++ b/src/jungle/test/codesegment/practice/StartCodeSegment.java Thu Jun 27 21:02:58 2013 +0900 @@ -26,6 +26,17 @@ 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(); @@ -43,14 +54,7 @@ list.add(new DefaultTreeOperation(nodePath2, deleteOp)); list.add(new DefaultTreeOperation(nodePath1, deleteChild)); DefaultTreeOperationLog log = new DefaultTreeOperationLog(list, list.size()); - - DefaultTreeOperationLogContainer logContainer = new DefaultTreeOperationLogContainer(); - try { - logContainer.unconvert(log); - ods.update("local", "log", logContainer); - } catch (IOException e) { - e.printStackTrace(); - } - } + return log; + } }
--- a/src/jungle/test/codesegment/practice/TestCodeSegment.java Wed Jun 26 19:03:19 2013 +0900 +++ b/src/jungle/test/codesegment/practice/TestCodeSegment.java Thu Jun 27 21:02:58 2013 +0900 @@ -12,6 +12,7 @@ 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.DefaultTreeOperationLog; 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; @@ -24,6 +25,7 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; +import alice.test.topology.aquarium.FishPoint; import org.msgpack.MessagePack; import org.msgpack.type.Value; @@ -36,6 +38,7 @@ Receiver arg1 = ids.create(CommandType.PEEK); public TestCodeSegment() { + arg1.setKey("log"); jungle.createNewTree("tree"); } @@ -44,13 +47,11 @@ System.out.println("type = " + arg1.type); System.out.println("index = " + arg1.index); System.out.println("data = " + arg1.getVal()); - System.out.println(((Value)arg1.getVal()).getType()); + System.out.println(arg1.getVal().getType()); - MessagePack msgpack = new MessagePack(); - Value logContainerValue = (Value) arg1.getVal(); + DefaultTreeOperationLogContainer convertedLogContainer = arg1.asClass(DefaultTreeOperationLogContainer.class); TreeOperationLog convertedLog = null; try { - DefaultTreeOperationLogContainer convertedLogContainer = msgpack.convert(logContainerValue, DefaultTreeOperationLogContainer.class); convertedLog = convertedLogContainer.convert(); } catch (IOException e) { e.printStackTrace();