Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 38:cb9fabaedfd4
added tests and changed testing provider to junit47
line wrap: on
line diff
--- a/pom.xml Sat Jan 26 22:52:32 2013 +0900 +++ b/pom.xml Mon Jan 28 18:52:52 2013 +0900 @@ -18,7 +18,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>3.8.1</version> + <version>4.7</version> <scope>test</scope> </dependency> <dependency> @@ -32,11 +32,6 @@ <version>3.2.1</version> </dependency> <dependency> - <groupId>net.sf.jpf</groupId> - <artifactId>jpf</artifactId> - <version>1.5</version> - </dependency> - <dependency> <groupId>org.functionaljava</groupId> <artifactId>functionaljava</artifactId> <version>3.1</version> @@ -52,6 +47,21 @@ <target>1.6</target> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugin</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.13</version> + <configuration> + <exclude>**/*TestBase.java</exclude> + </configuration> + <dependencies> + <dependency> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>surefire-junit47</artifactId> + <version>2.13</version> + </dependency> + </dependencies> + </plugin> </plugins> </build> </project>
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/JungleTreeEditor.java Sat Jan 26 22:52:32 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/JungleTreeEditor.java Mon Jan 28 18:52:52 2013 +0900 @@ -3,7 +3,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Transaction; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; -public interface JungleTreeEditor extends TreeEditor , Transaction<JungleTree> +public interface JungleTreeEditor<T extends JungleTreeEditor<T>> extends TreeEditor<T> , Transaction<JungleTree> { }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/Attributes.java Sat Jan 26 22:52:32 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/Attributes.java Mon Jan 28 18:52:52 2013 +0900 @@ -1,6 +1,8 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core; -public interface Attributes<K,V> +import java.nio.ByteBuffer; + +public interface Attributes { - public V get(K _key); + public ByteBuffer get(String _key); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/AttributesContainer.java Sat Jan 26 22:52:32 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/AttributesContainer.java Mon Jan 28 18:52:52 2013 +0900 @@ -1,6 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core; -public interface AttributesContainer<K,V> +public interface AttributesContainer { - public Attributes<K,V> getAttributes(); + public Attributes getAttributes(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/Node.java Sat Jan 26 22:52:32 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/Node.java Mon Jan 28 18:52:52 2013 +0900 @@ -1,7 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core; -import java.nio.ByteBuffer; -public interface Node extends AttributesContainer<String,ByteBuffer> , Parent<Node> +public interface Node extends AttributesContainer , Parent<Node> { } \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultAttributes.java Sat Jan 26 22:52:32 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultAttributes.java Mon Jan 28 18:52:52 2013 +0900 @@ -13,7 +13,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -public class DefaultAttributes implements Attributes<String,ByteBuffer> +public class DefaultAttributes implements Attributes { private final TreeMap<String,ByteBuffer> attrs;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Sat Jan 26 22:52:32 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Mon Jan 28 18:52:52 2013 +0900 @@ -18,7 +18,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; public class DefaultTreeEditor<T extends ClonableNode<T>> - implements TreeEditor + implements TreeEditor<DefaultTreeEditor<T>> { private final T root; private final Traverser traverser; @@ -35,31 +35,31 @@ } @Override - public Either<Error,TreeEditor> appendChild(NodePath _path,int _pos) + public Either<Error,DefaultTreeEditor<T>> appendChild(NodePath _path,int _pos) { return edit(_path,new AppendChildAt(_pos)); } @Override - public Either<Error,TreeEditor> deleteChild(NodePath _path,int _pos) + public Either<Error, DefaultTreeEditor<T>> deleteChild(NodePath _path,int _pos) { return edit(_path,new DeleteChildAt(_pos)); } @Override - public Either<Error,TreeEditor> putAttribute(NodePath _path, String _key,ByteBuffer _value) + public Either<Error, DefaultTreeEditor<T>> putAttribute(NodePath _path, String _key,ByteBuffer _value) { return edit(_path,new PutAttribute(_key,_value)); } @Override - public Either<Error,TreeEditor> deleteAttribute(NodePath _path, String _key) + public Either<Error, DefaultTreeEditor<T>> deleteAttribute(NodePath _path, String _key) { return edit(_path,new DeleteAttribute(_key)); } @Override - public Either<Error,TreeEditor> edit(NodePath _path,NodeEditor _editor) + public Either<Error,DefaultTreeEditor<T>> edit(NodePath _path,NodeEditor _editor) { DefaultEvaluator e = new DefaultEvaluator(_path); TraversableNodeWrapper<T> wrap = new TraversableNodeWrapper<T>(root); @@ -70,12 +70,12 @@ } Traversal<TraversableNodeWrapper<T>> t = either.b(); - Either<Error,TreeEditor> ret = clone(t,_editor); + Either<Error,DefaultTreeEditor<T>> ret = clone(t,_editor); return ret; } - private Either<Error,TreeEditor> clone(Traversal<TraversableNodeWrapper<T>> _t,NodeEditor _editor) + private Either<Error,DefaultTreeEditor<T>> clone(Traversal<TraversableNodeWrapper<T>> _t,NodeEditor _editor) { // copying nodes from bottom to root @@ -112,7 +112,7 @@ } T newRoot = child; - TreeEditor newEditor = new DefaultTreeEditor<T>(newRoot,traverser); + DefaultTreeEditor<T> newEditor = new DefaultTreeEditor<T>(newRoot,traverser); return DefaultEither.newB(newEditor); } } \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/EditableAttributes.java Sat Jan 26 22:52:32 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/EditableAttributes.java Mon Jan 28 18:52:52 2013 +0900 @@ -7,8 +7,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -public interface EditableAttributes<T extends Parent<T>> - extends Attributes<String,ByteBuffer> +public interface EditableAttributes<T extends Parent<T>> extends Attributes { public Either<Error,T> delete(String _key); public Either<Error,T> put(String _key,ByteBuffer _value);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/EditableNode.java Sat Jan 26 22:52:32 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/EditableNode.java Mon Jan 28 18:52:52 2013 +0900 @@ -1,12 +1,9 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer; -import java.nio.ByteBuffer; - import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.AttributesContainer; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Parent; -public interface EditableNode<T extends Parent<T>> - extends AttributesContainer<String,ByteBuffer> , Parent<T> +public interface EditableNode<T extends Parent<T>> extends AttributesContainer , Parent<T> { public EditableAttributes<T> getAttributes(); public EditableChildren<T> getChildren();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/ClonableDefaultNode.java Sat Jan 26 22:52:32 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/ClonableDefaultNode.java Mon Jan 28 18:52:52 2013 +0900 @@ -25,4 +25,9 @@ { return new ClonableDefaultAttributes(wrap); } + + public DefaultNode getWrapped() + { + return wrap; + } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultJungleTreeEditor.java Sat Jan 26 22:52:32 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultJungleTreeEditor.java Mon Jan 28 18:52:52 2013 +0900 @@ -5,62 +5,116 @@ 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.store.NodePath; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.Logger; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.NodeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Traverser; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -public class DefaultJungleTreeEditor implements JungleTreeEditor +public class DefaultJungleTreeEditor implements JungleTreeEditor<DefaultJungleTreeEditor> { private final TransactionManager txManager; private final DefaultNode root; private final DefaultTreeEditor<LoggingNode<ClonableDefaultNode>> editor; + private final Traverser traverser; - public DefaultJungleTreeEditor(DefaultNode _root,TransactionManager _txManager) + public DefaultJungleTreeEditor(DefaultNode _root,TransactionManager _txManager,Traverser _traverser) { root = _root; txManager = _txManager; + ClonableDefaultNode node = new ClonableDefaultNode(root); + LoggingNode<ClonableDefaultNode> loggingNode = new LoggingNode<ClonableDefaultNode>(node); + editor = new DefaultTreeEditor<LoggingNode<ClonableDefaultNode>>(loggingNode,_traverser); + traverser = _traverser; } @Override - public Either<Error,JungleTreeEditor> appendChild(NodePath _path, int _pos) + public Either<Error,DefaultJungleTreeEditor> appendChild(NodePath _path, int _pos) { + Either<Error,DefaultTreeEditor<LoggingNode<ClonableDefaultNode>>> either = editor.appendChild(_path,_pos); + if(either.isA()){ + return DefaultEither.newA(either.a()); + } + DefaultTreeEditor<LoggingNode<ClonableDefaultNode>> newTreeEditor = either.b(); + DefaultNode newRoot = newTreeEditor.getRootNode().getWrapper().getWrapped(); - return null; + return DefaultEither.newB(new DefaultJungleTreeEditor(newRoot,txManager,traverser)); } @Override - public Either<Error,TreeEditor> deleteChild(NodePath _path, int _pos) + public Either<Error,DefaultJungleTreeEditor> deleteChild(NodePath _path, int _pos) { - return null; + Either<Error,DefaultTreeEditor<LoggingNode<ClonableDefaultNode>>> either = editor.deleteChild(_path,_pos); + if(either.isA()){ + return DefaultEither.newA(either.a()); + } + + DefaultTreeEditor<LoggingNode<ClonableDefaultNode>> newTreeEditor = either.b(); + DefaultNode newRoot = newTreeEditor.getRootNode().getWrapper().getWrapped(); + + return DefaultEither.newB(new DefaultJungleTreeEditor(newRoot,txManager,traverser)); } @Override - public Either<Error,TreeEditor> putAttribute(NodePath _path,String _key,ByteBuffer _value) + public Either<Error,DefaultJungleTreeEditor> putAttribute(NodePath _path,String _key,ByteBuffer _value) { - return null; + Either<Error,DefaultTreeEditor<LoggingNode<ClonableDefaultNode>>> either = editor.putAttribute(_path,_key,_value); + if(either.isA()){ + return DefaultEither.newA(either.a()); + } + + DefaultTreeEditor<LoggingNode<ClonableDefaultNode>> newTreeEditor = either.b(); + DefaultNode newRoot = newTreeEditor.getRootNode().getWrapper().getWrapped(); + + return DefaultEither.newB(new DefaultJungleTreeEditor(newRoot,txManager,traverser)); } @Override - public Either<Error, TreeEditor> deleteAttribute(NodePath _path, String _key) + public Either<Error,DefaultJungleTreeEditor> deleteAttribute(NodePath _path, String _key) { - return null; + Either<Error,DefaultTreeEditor<LoggingNode<ClonableDefaultNode>>> either = editor.deleteAttribute(_path,_key); + if(either.isA()){ + return DefaultEither.newA(either.a()); + } + + DefaultTreeEditor<LoggingNode<ClonableDefaultNode>> newTreeEditor = either.b(); + DefaultNode newRoot = newTreeEditor.getRootNode().getWrapper().getWrapped(); + + return DefaultEither.newB(new DefaultJungleTreeEditor(newRoot,txManager,traverser)); } @Override - public Either<Error,TreeEditor> edit(NodePath _path,NodeEditor _transformer) + public Either<Error,DefaultJungleTreeEditor> edit(NodePath _path,NodeEditor _transformer) { - return null; + Either<Error,DefaultTreeEditor<LoggingNode<ClonableDefaultNode>>> either = editor.edit(_path,_transformer); + if(either.isA()){ + return DefaultEither.newA(either.a()); + } + + DefaultTreeEditor<LoggingNode<ClonableDefaultNode>> newTreeEditor = either.b(); + DefaultNode newRoot = newTreeEditor.getRootNode().getWrapper().getWrapped(); + + return DefaultEither.newB(new DefaultJungleTreeEditor(newRoot,txManager,traverser)); } @Override public Either<Error,JungleTree> success() { - return null; + LoggingNode<ClonableDefaultNode> loggingNode = editor.getRootNode(); + Logger log = loggingNode.getLogger(); + DefaultNode newRoot = loggingNode.getWrapper().getWrapped(); + + Either<Error,JungleTree> either = txManager.commit(newRoot,log); + if(either.isA()){ + return DefaultEither.newA(either.a()); + } + + return DefaultEither.newB(either.b()); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java Mon Jan 28 18:52:52 2013 +0900 @@ -0,0 +1,17 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNode; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.Logger; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; + +public class DefaultTransactionManager implements TransactionManager +{ + @Override + public Either<Error, JungleTree> commit(DefaultNode _newRoot, Logger _log) + { + return null; + } + +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/TransactionManager.java Sat Jan 26 22:52:32 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/TransactionManager.java Mon Jan 28 18:52:52 2013 +0900 @@ -1,8 +1,12 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNode; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.Logger; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; public interface TransactionManager { - public boolean commit(ChangeSet _ch); + public Either<Error,JungleTree> commit(DefaultNode _newRoot,Logger _log); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/AttributesContainerTest.java Mon Jan 28 18:52:52 2013 +0900 @@ -0,0 +1,22 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core; + +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +import junit.framework.TestCase; + +@Ignore +public abstract class AttributesContainerTest extends TestCase +{ + public abstract AttributesContainer instance(); + + @Test + public void testGetAttributes() + { + AttributesContainer instance = instance(); + Attributes attrs = instance.getAttributes(); + + Assert.assertNotNull(attrs); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/AttributesTest.java Mon Jan 28 18:52:52 2013 +0900 @@ -0,0 +1,34 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core; + +import org.junit.Ignore; +import java.nio.ByteBuffer; +import fj.P2; +import fj.P; +import fj.data.List; +import junit.framework.Assert; +import junit.framework.TestCase; + +@Ignore +public abstract class AttributesTest extends TestCase +{ + @SuppressWarnings("unchecked") + public static List<P2<String,ByteBuffer>> ENTRIES = List.list( + P.p("KEY1",ByteBuffer.wrap("VALUE1".getBytes())), + P.p("KEY2",ByteBuffer.wrap("VALUE2".getBytes())), + P.p("KEY3",ByteBuffer.wrap("VALUE3".getBytes())) + ); + + public abstract Attributes instance(); + + public void testGet() + { + Attributes attrs = instance(); + + for(P2<String,ByteBuffer> entry : ENTRIES){ + String key = entry._1(); + ByteBuffer expect = entry._2(); + ByteBuffer actual = attrs.get(key); + Assert.assertEquals(0,actual.compareTo(expect)); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/ChildrenTest.java Mon Jan 28 18:52:52 2013 +0900 @@ -0,0 +1,18 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core; + +import junit.framework.Assert; +import junit.framework.TestCase; + +public abstract class ChildrenTest<T> extends TestCase +{ + public abstract int expectSize(); + public abstract Children<T> instance(); + + public void testSize() + { + int expect = expectSize(); + Children<T> children = instance(); + + Assert.assertEquals(expect,children.size()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/ParentTest.java Mon Jan 28 18:52:52 2013 +0900 @@ -0,0 +1,21 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core; + +import org.junit.Ignore; +import org.junit.Test; + +import junit.framework.Assert; +import junit.framework.TestCase; + +@Ignore +public abstract class ParentTest<T extends Parent<?>> extends TestCase +{ + public abstract T instance(); + + @Test + public void testGetChildren() + { + T instance = instance(); + Children<?> children = instance.getChildren(); + Assert.assertNotNull(children); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultAttributesTest.java Mon Jan 28 18:52:52 2013 +0900 @@ -0,0 +1,29 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.impl.node; + +import java.nio.ByteBuffer; + +import fj.Ord; +import fj.P2; +import fj.data.List; +import fj.data.TreeMap; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.AttributesTest; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultAttributes; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNode; + +public class DefaultAttributesTest extends AttributesTest +{ + public DefaultAttributes instance() + { + List<DefaultNode> rawList = List.nil(); + TreeMap<String,ByteBuffer> rawMap = TreeMap.empty(Ord.stringOrd); + + // add attributes + + for(P2<String, ByteBuffer> entry : ENTRIES){ + rawMap = rawMap.set(entry._1(),entry._2()); + } + + DefaultNode node = new DefaultNode(rawList,rawMap); + return node.getAttributes(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultChildrenTest.java Mon Jan 28 18:52:52 2013 +0900 @@ -0,0 +1,34 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.impl.node; + +import java.nio.ByteBuffer; + +import fj.Ord; +import fj.data.List; +import fj.data.TreeMap; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.ChildrenTest; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultChildren; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNode; + +public class DefaultChildrenTest extends ChildrenTest<Node> +{ + + @Override + public DefaultChildren instance() + { + List<DefaultNode> rawList = List.nil(); + for(int i = 0;i < expectSize();i ++){ + rawList = rawList.cons(new DefaultNode()); + } + + TreeMap<String,ByteBuffer> rawMap = TreeMap.empty(Ord.stringOrd); + + return new DefaultNode(rawList,rawMap).getChildren(); + } + + @Override + public int expectSize() + { + return 3; + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultNodeTest.java Mon Jan 28 18:52:52 2013 +0900 @@ -0,0 +1,58 @@ +package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.impl.node; + +import java.nio.ByteBuffer; + +import fj.Ord; +import fj.data.List; +import fj.data.TreeMap; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.AttributesContainer; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.AttributesContainerTest; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.ParentTest; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNode; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +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 DefaultNode instance() + { + List<DefaultNode> rawList = List.nil(); + TreeMap<String,ByteBuffer> rawMap = TreeMap.empty(Ord.stringOrd); + DefaultNode node = new DefaultNode(rawList,rawMap); + + return node; + } + + public static class AttributesContaierTestImpl extends AttributesContainerTest + { + @Override + public AttributesContainer instance() + { + return DefaultNodeTest.instance(); + } + } + + public static class ParentTestImpl extends ParentTest<DefaultNode> + { + + @Override + public DefaultNode instance() + { + return DefaultNodeTest.instance(); + } + + } +}
--- a/src/test/java/jungle/core/AppTest.java Sat Jan 26 22:52:32 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -package jungle.core; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -}
--- a/src/test/java/jungle/misc/fj/ImmutableListExample.java Sat Jan 26 22:52:32 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -package jungle.misc.fj; - -import fj.data.List; - -public class ImmutableListExample -{ - public static void main(String[] _args) - { - List<String> first = List.list("1","3","2","3"); - System.out.println(first.take(3+1).last()); - System.out.println(first.splitAt(2)._1()); - } -}
--- a/src/test/java/jungle/misc/fj/ImmutableSetExample.java Sat Jan 26 22:52:32 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -package jungle.misc.fj; - -import fj.F; -import fj.Ord; -import fj.P2; -import fj.Show; -import fj.data.List; -import fj.data.TreeMap; - - -public class ImmutableSetExample -{ - public static void main(String _args[]) - { - TreeMap<String,String> map = TreeMap.empty(Ord.stringOrd); - Show<List<P2<String,String>>> s = Show.listShow(Show.p2Show(Show.stringShow,Show.stringShow)); - - TreeMap<String,String> second = map.set("hoge","fuga"); - TreeMap<String,String> third = second.set("fuga","fuga"); - s.println(List.iterableList(second)); - s.println(List.iterableList(third)); - System.out.println(second.get("hoge").some()); - - F<String,String> predicate = new F<String,String>(){ - @Override - public String f(String str){ - return null; - } - }; - - P2<Boolean,TreeMap<String,String>> transformResult = third.update("hoge",predicate); - if(transformResult._1()){ - s.println(List.iterableList(transformResult._2())); - } - } -}
--- a/src/test/java/jungle/misc/fj/XMLNodeTest.java Sat Jan 26 22:52:32 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -package jungle.misc.fj; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -public class XMLNodeTest -{ - public static void main(String _args[]) throws Exception - { - DocumentBuilder b = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document g = b.newDocument(); - - Element e = g.createElement("hoge"); - g.appendChild(e); - e.appendChild(g.createElement("hoge")); - NodeList l1 = e.getElementsByTagName("hoge"); - System.out.println(l1.getLength()); - e.appendChild(g.createElement("hoge")); - e.appendChild(g.createElement("hoge")); - NodeList l2 = e.getElementsByTagName("hoge"); - - System.out.println(l1.getLength()); - System.out.println(l2.getLength()); - } -}
--- a/src/test/java/jungle/util/PairTest.java Sat Jan 26 22:52:32 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -package jungle.util; - -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair; -import junit.framework.Assert; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class PairTest extends TestCase -{ - public PairTest(String _testName) - { - super(_testName); - } - - public static Test suite() - { - return new TestSuite(PairTest.class); - } - - public void testPair() - { - Object left = new Object(); - Object right = new Object(); - - Pair<Object,Object> p = new Pair<Object,Object>(left,right); - - Assert.assertEquals(left,p.left()); - Assert.assertEquals(right,p.right()); - } -}