[Exmmt-commit] SF.net SVN: exmmt: [72] net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/b
Status: Inactive
Brought to you by:
lgrammel
|
From: <lgr...@us...> - 2006-06-05 23:44:12
|
Revision: 72 Author: lgrammel Date: 2006-06-05 04:06:10 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=72&view=rev Log Message: ----------- #1500774 scenario "shopping list" Added Paths: ----------- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/builder/ControllerTreeBuilderTest.java Removed Paths: ------------- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/builder/TreeBuilderTest.java Copied: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/builder/ControllerTreeBuilderTest.java (from rev 70, net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/builder/TreeBuilderTest.java) =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/builder/ControllerTreeBuilderTest.java (rev 0) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/builder/ControllerTreeBuilderTest.java 2006-06-05 11:06:10 UTC (rev 72) @@ -0,0 +1,97 @@ +/* $HeadURL$ + * ----------------------------------------------------------------------------- + * + * Copyright (C) Lars Grammel and others. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies + * this distribution, and is available at + * + * http://www.eclipse.org/legal/cpl-v10.html + * + */ +package net.sourceforge.exmmt.builder; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import junit.framework.JUnit4TestAdapter; + +import org.jdom.Element; +import org.junit.Test; + +public class ControllerTreeBuilderTest { + + @Test public void buildOneElement() { + ControllerTreeBuilder builder = new ControllerTreeBuilder(); + + Element element = new Element("entry"); + + Controller composite = builder.build(element); + + assertEquals(element, composite.getModel()); + assertNotNull(composite.getChildren()); + assertEquals(0, composite.getChildren().size()); + assertNull(composite.getParent()); + } + + @Test public void buildOneElementWithAttributes() { + String nameOfAttribute1 = "item"; + String nameOfAttribute2 = "count"; + + ControllerTreeBuilder builder = new ControllerTreeBuilder(); + + Element element = new Element("entry"); + element.setAttribute(nameOfAttribute1, "testItem"); + element.setAttribute(nameOfAttribute2, "2"); + + Controller composite = builder.build(element); + + assertEquals(element, composite.getModel()); + assertNotNull(composite.getChildren()); + assertEquals(2, composite.getChildren().size()); + assertNull(composite.getParent()); + + Controller childComposite1 = composite.getChildren().get(0); + + assertEquals(element.getAttribute(nameOfAttribute1), childComposite1.getModel()); + assertNotNull(childComposite1.getChildren()); + assertEquals(0, childComposite1.getChildren().size()); + assertEquals(composite, childComposite1.getParent()); + + Controller childComposite2 = composite.getChildren().get(1); + + assertEquals(element.getAttribute(nameOfAttribute2), childComposite2.getModel()); + assertNotNull(childComposite2.getChildren()); + assertEquals(0, childComposite2.getChildren().size()); + assertEquals(composite, childComposite2.getParent()); + } + + @Test public void buildElementWithChildElement() { + ControllerTreeBuilder builder = new ControllerTreeBuilder(); + + Element listElement = new Element("list"); + Element entryElement = new Element("entry"); + listElement.addContent(entryElement); + + Controller composite = builder.build(listElement); + + assertEquals(listElement, composite.getModel()); + assertNotNull(composite.getChildren()); + assertEquals(1, composite.getChildren().size()); + assertNull(composite.getParent()); + + Controller childComposite = composite.getChildren().get(0); + + assertEquals(entryElement, childComposite.getModel()); + assertNotNull(childComposite.getChildren()); + assertEquals(0, childComposite.getChildren().size()); + assertEquals(composite, childComposite.getParent()); + } + + // Junit 3.8.1 backward compability + public static junit.framework.Test suite() { + return new JUnit4TestAdapter(ControllerTreeBuilderTest.class); + } + +} Deleted: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/builder/TreeBuilderTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/builder/TreeBuilderTest.java 2006-06-05 11:04:09 UTC (rev 71) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/builder/TreeBuilderTest.java 2006-06-05 11:06:10 UTC (rev 72) @@ -1,97 +0,0 @@ -/* $HeadURL$ - * ----------------------------------------------------------------------------- - * - * Copyright (C) Lars Grammel and others. - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Common Public License v1.0 which accompanies - * this distribution, and is available at - * - * http://www.eclipse.org/legal/cpl-v10.html - * - */ -package net.sourceforge.exmmt.builder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import junit.framework.JUnit4TestAdapter; - -import org.jdom.Element; -import org.junit.Test; - -public class TreeBuilderTest { - - @Test public void buildOneElement() { - TreeBuilder builder = new TreeBuilder(); - - Element element = new Element("entry"); - - Controller composite = builder.build(element); - - assertEquals(element, composite.getModel()); - assertNotNull(composite.getChildren()); - assertEquals(0, composite.getChildren().size()); - assertNull(composite.getParent()); - } - - @Test public void buildOneElementWithAttributes() { - String nameOfAttribute1 = "item"; - String nameOfAttribute2 = "count"; - - TreeBuilder builder = new TreeBuilder(); - - Element element = new Element("entry"); - element.setAttribute(nameOfAttribute1, "testItem"); - element.setAttribute(nameOfAttribute2, "2"); - - Controller composite = builder.build(element); - - assertEquals(element, composite.getModel()); - assertNotNull(composite.getChildren()); - assertEquals(2, composite.getChildren().size()); - assertNull(composite.getParent()); - - Controller childComposite1 = composite.getChildren().get(0); - - assertEquals(element.getAttribute(nameOfAttribute1), childComposite1.getModel()); - assertNotNull(childComposite1.getChildren()); - assertEquals(0, childComposite1.getChildren().size()); - assertEquals(composite, childComposite1.getParent()); - - Controller childComposite2 = composite.getChildren().get(1); - - assertEquals(element.getAttribute(nameOfAttribute2), childComposite2.getModel()); - assertNotNull(childComposite2.getChildren()); - assertEquals(0, childComposite2.getChildren().size()); - assertEquals(composite, childComposite2.getParent()); - } - - @Test public void buildElementWithChildElement() { - TreeBuilder builder = new TreeBuilder(); - - Element listElement = new Element("list"); - Element entryElement = new Element("entry"); - listElement.addContent(entryElement); - - Controller composite = builder.build(listElement); - - assertEquals(listElement, composite.getModel()); - assertNotNull(composite.getChildren()); - assertEquals(1, composite.getChildren().size()); - assertNull(composite.getParent()); - - Controller childComposite = composite.getChildren().get(0); - - assertEquals(entryElement, childComposite.getModel()); - assertNotNull(childComposite.getChildren()); - assertEquals(0, childComposite.getChildren().size()); - assertEquals(composite, childComposite.getParent()); - } - - // Junit 3.8.1 backward compability - public static junit.framework.Test suite() { - return new JUnit4TestAdapter(TreeBuilderTest.class); - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |