Mercurial > hg > Members > shoshi > TreeCMS > TreeCMSPrototype1
view src/treecms/proto/test/SimpleLinkTest2.java @ 31:ff4d4704e5d7
modified Node API
delete setLinkedNode,getLinkedNode
added Link API
setNode,getNode
added SimpleLink and deleted SimpleLinkedNode
Test code is SimpleLinkTest2
added document/figure/linkednode1.graffle
author | shoshi |
---|---|
date | Wed, 17 Nov 2010 18:28:21 +0900 |
parents | |
children |
line wrap: on
line source
package treecms.proto.test; import static org.hamcrest.core.IsNot.not; import org.junit.Test; import org.junit.Assert; import org.junit.runner.JUnitCore; import treecms.proto.api.*; import treecms.proto.simple.*; public class SimpleLinkTest2 { public static void main(String _arg[]) { JUnitCore.main(SimpleLinkTest2.class.getName()); } private Node m_root1; private Node m_root2; public SimpleLinkTest2() { m_root1 = new SimpleNode(); m_root1.addChild(new SimpleNode()); m_root1.addChild(new SimpleNode()); m_root1.addChild(new SimpleNode()); m_root2 = new SimpleNode(); m_root2.addChild(new SimpleNode()); m_root2.addChild(new SimpleNode()); } @Test public void testCreateLink() { Link link = (Link)m_root1.addChild(new SimpleLink(m_root2)); m_root2.setTitle("title"); m_root2.setClassName("class"); Assert.assertEquals(link.getTitle(),m_root2.getTitle()); Assert.assertEquals(link.getClassName(),m_root2.getClassName()); Assert.assertThat(link.getID(),not(m_root2.getID())); } @Test public void testEditFromLink() { Link link = new SimpleLink(m_root2); link.setClassName("class"); link.setTitle("title"); Assert.assertEquals(link.getTitle(),m_root2.getTitle()); Assert.assertEquals(link.getClassName(),m_root2.getClassName()); Assert.assertThat(link.getID(),not(m_root2.getID())); } @Test public void testClone() { Link link = (Link)m_root1.addChild(new SimpleLink(m_root2)); m_root2.setTitle("title"); m_root2.setClassName("class"); Link clone = (Link)link.cloneNode(); Assert.assertThat(clone.getID(),not(link.getID())); Assert.assertEquals(m_root2.getClassName(),clone.getClassName()); Assert.assertEquals(m_root2.getTitle(),clone.getTitle()); } }