From: <chr...@us...> - 2007-01-05 12:19:19
|
Revision: 1443 http://svn.sourceforge.net/gridarta/?rev=1443&view=rev Author: christianhujer Date: 2007-01-05 04:19:20 -0800 (Fri, 05 Jan 2007) Log Message: ----------- Adding test for MapArchObject. Modified Paths: -------------- trunk/gridarta.ipr trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java Added Paths: ----------- trunk/daimonin/src/test/daieditor/map/MapArchObjectTest.java trunk/daimonin/src/test/daieditor/map/noAttributes.testdata trunk/daimonin/src/test/daieditor/map/package.html Added: trunk/daimonin/src/test/daieditor/map/MapArchObjectTest.java =================================================================== --- trunk/daimonin/src/test/daieditor/map/MapArchObjectTest.java (rev 0) +++ trunk/daimonin/src/test/daieditor/map/MapArchObjectTest.java 2007-01-05 12:19:20 UTC (rev 1443) @@ -0,0 +1,46 @@ +package test.daieditor.map; + +import daieditor.map.MapArchObject; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import net.sf.gridarta.Size2D; +import net.sf.gridarta.map.AbstractMapArchObject; +import org.junit.Assert; +import org.junit.Test; + +/** + * Test for {@link MapArchObject}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class MapArchObjectTest { + + /** + * Test for {@link MapArchObject#parseMapArch(java.io.BufferedReader, String)}. + * @throws IOException (unexpected) + */ + @Test public void testParseMapArchNoAttributes() throws IOException { + final MapArchObject mao = new MapArchObject(); + final BufferedReader in = openTestDataReader("noAttributes.testdata"); + try { + mao.parseMapArch(in, "noAttributes.testdata"); + } finally { + in.close(); + } + Assert.assertEquals(mao.getMapName(), AbstractMapArchObject.MAP_NAME_UNNAMED); + Assert.assertEquals(mao.getMapSize(), Size2D.ONE); + } + + /** + * Reads test data. + * @param testDataName Name of the test data to open + * @return BufferedReader for reading from testDataName. + */ + private BufferedReader openTestDataReader(final String testDataName) { + final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + final InputStream in = contextClassLoader.getResourceAsStream(getClass().getPackage().getName().replace('.', '/') + "/" + testDataName); + return new BufferedReader(new InputStreamReader(in)); + } + +} // class MapArchObjectTest Property changes on: trunk/daimonin/src/test/daieditor/map/MapArchObjectTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/daimonin/src/test/daieditor/map/noAttributes.testdata =================================================================== --- trunk/daimonin/src/test/daieditor/map/noAttributes.testdata (rev 0) +++ trunk/daimonin/src/test/daieditor/map/noAttributes.testdata 2007-01-05 12:19:20 UTC (rev 1443) @@ -0,0 +1,2 @@ +arch map +end \ No newline at end of file Property changes on: trunk/daimonin/src/test/daieditor/map/noAttributes.testdata ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/daimonin/src/test/daieditor/map/package.html =================================================================== --- trunk/daimonin/src/test/daieditor/map/package.html (rev 0) +++ trunk/daimonin/src/test/daieditor/map/package.html 2007-01-05 12:19:20 UTC (rev 1443) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <title></title> + </head> + <body> + <p> + Tests for package {@link daieditor.map}. + </p> + </body> +</html> Property changes on: trunk/daimonin/src/test/daieditor/map/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2007-01-05 07:41:03 UTC (rev 1442) +++ trunk/gridarta.ipr 2007-01-05 12:19:20 UTC (rev 1443) @@ -70,6 +70,7 @@ <entry name="?*.html" /> <entry name="?*.dtd" /> <entry name="?*.tld" /> + <entry name="?*.testdata" /> </wildcardResourcePatterns> </component> <component name="DataSourceManagerImpl" /> Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java 2007-01-05 07:41:03 UTC (rev 1442) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java 2007-01-05 12:19:20 UTC (rev 1443) @@ -9,11 +9,14 @@ */ public abstract class AbstractMapArchObject implements MapArchObject { + /** Name of an unnamed map. */ + @NotNull public static final String MAP_NAME_UNNAMED = "<unnamed>"; + /** The size of the map reflected by this MapArchObject. */ @NotNull private Size2D mapSize = Size2D.ONE; /** The name of this map. */ - @NotNull private String mapName = "<unnamed>"; + @NotNull private String mapName = MAP_NAME_UNNAMED; /** The filename of this map. */ // TODO: Rename because the filename is a URI now. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |