From: <aki...@us...> - 2010-06-02 07:20:47
|
Revision: 8060 http://gridarta.svn.sourceforge.net/gridarta/?rev=8060&view=rev Author: akirschbaum Date: 2010-06-02 07:20:40 +0000 (Wed, 02 Jun 2010) Log Message: ----------- Fix archetype collection: do not drop mpart_id attributes for tail parts. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java trunk/build.xml trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java trunk/daimonin/ChangeLog trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java Added Paths: ----------- trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java trunk/src/test/net/sf/gridarta/var/ trunk/src/test/net/sf/gridarta/var/atrinik/ trunk/src/test/net/sf/gridarta/var/atrinik/model/ trunk/src/test/net/sf/gridarta/var/atrinik/model/archetype/ Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/atrinik/ChangeLog 2010-06-02 07:20:40 UTC (rev 8060) @@ -1,3 +1,8 @@ +2010-06-02 Andreas Kirschbaum + + * Fix archetype collection: do not drop mpart_id attributes for + tail parts. + 2010-05-30 Alex Tokar * Update map header flags in map properties dialog to be in-sync Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -130,11 +130,10 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetypePart(@NotNull final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { - // set or check mpart_nr - if (firstArch.getMultiRefCount() == 2) { - firstArch.setMultiShapeID(multiShapeID); - } else if (multiShapeID != firstArch.getMultiShapeID()) { + protected void finishParseArchetypePart(@Nullable final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { + // set or check mpart_id + archetype.setMultiShapeID(multiShapeID); + if (firstArch != null && multiShapeID != firstArch.getMultiShapeID()) { errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDefArchWithInvalidMpartNr", archetype.getArchetypeName(), firstArch.getArchetypeName(), Integer.toString(multiShapeID), Integer.toString(firstArch.getMultiShapeID()))); } } Added: trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java =================================================================== --- trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java (rev 0) +++ trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -0,0 +1,131 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.var.atrinik.model.archetype; + +import java.io.IOException; +import java.util.regex.Pattern; +import net.sf.gridarta.model.anim.AnimationObjects; +import net.sf.gridarta.model.anim.DefaultAnimationObjects; +import net.sf.gridarta.model.archetype.AbstractArchetypeBuilder; +import net.sf.gridarta.model.archetype.AbstractArchetypeParser; +import net.sf.gridarta.model.archetype.AbstractArchetypeParserTest; +import net.sf.gridarta.model.archetype.UndefinedArchetypeException; +import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; +import net.sf.gridarta.model.face.ArchFaceProvider; +import net.sf.gridarta.model.face.DefaultFaceObjects; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.gameobject.IsoMapSquareInfo; +import net.sf.gridarta.model.gameobject.MultiPositionData; +import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.var.atrinik.model.gameobject.DefaultGameObjectFactory; +import net.sf.gridarta.var.atrinik.model.gameobject.GameObject; +import net.sf.gridarta.var.atrinik.model.maparchobject.MapArchObject; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Regression tests for {@link ArchetypeParser}. + * @author Andreas Kirschbaum + */ +public class ArchetypeParserTest extends AbstractArchetypeParserTest<GameObject, MapArchObject, Archetype> { + + /** + * The loaded archetypes. + */ + @Nullable + private ArchetypeSet archetypeSet = null; + + /** + * Checks that mpart_id fields are parsed correctly. + * @throws IOException if the test fails + * @throws UndefinedArchetypeException if the test fails + */ + @Test + public void testMpartIdOk() throws IOException, UndefinedArchetypeException { + check("Object head\nmpart_id 1\nend\nMore\nObject tail\nmpart_id 1\nend\n", false, false, 2); + Assert.assertEquals(1, getArchetypeSet().getArchetype("head").getMultiShapeID()); + Assert.assertEquals(1, getArchetypeSet().getArchetype("tail").getMultiShapeID()); + } + + /** + * Checks that mpart_id fields are parsed correctly. + * @throws IOException if the test fails + * @throws UndefinedArchetypeException if the test fails + */ + @Test + public void testMpartIdInconsistent() throws IOException, UndefinedArchetypeException { + check("Object head\nmpart_id 1\nend\nMore\nObject tail\nmpart_id 2\nend\n", false, true, 2); + Assert.assertEquals(1, getArchetypeSet().getArchetype("head").getMultiShapeID()); + Assert.assertEquals(2, getArchetypeSet().getArchetype("tail").getMultiShapeID()); + } + + /** + * Initializes the test. + */ + @BeforeClass + public static void setUp() { + final ActionBuilder actionBuilder = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + actionBuilder.addParent(ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta.var.atrinik")); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ? extends AbstractArchetypeBuilder<GameObject, MapArchObject, Archetype>> newArchetypeParser() { + final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); + final FaceObjects faceObjects = new DefaultFaceObjects("png", "facetree", Pattern.compile(".*"), "facetree.output", archFaceProvider); + final GUIUtils guiUtils = new GUIUtils(); + final SystemIcons systemIcons = new SystemIcons(guiUtils); + final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); + final AnimationObjects animationObjects = new DefaultAnimationObjects("animtree"); + final ArchetypeTypeSet archetypeTypeSet = new ArchetypeTypeSet(); + final DefaultGameObjectFactory gameObjectFactory = new DefaultGameObjectFactory(faceObjectProviders, animationObjects, archetypeTypeSet); + final DefaultArchetypeFactory archetypeFactory = new DefaultArchetypeFactory(faceObjectProviders, animationObjects); + archetypeSet = new ArchetypeSet(archetypeFactory); + archetypeSet.setLoadedFromArchive(true); + assert archetypeSet != null; + final IsoMapSquareInfo isoMapSquareInfo = new IsoMapSquareInfo(1, 1, 1, 1); + final MultiPositionData multiPositionData = new MultiPositionData(isoMapSquareInfo); + assert archetypeSet != null; + return new ArchetypeParser(animationObjects, archetypeSet, gameObjectFactory, multiPositionData); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected ArchetypeSet getArchetypeSet() { + if (archetypeSet == null) { + throw new IllegalStateException(); + } + return archetypeSet; + } + +} // class ArchetypeParserTest Property changes on: trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParserTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/build.xml 2010-06-02 07:20:40 UTC (rev 8060) @@ -458,9 +458,13 @@ <copy todir="classes/test"> <fileset dir="resource" includes="**/*.properties,**/*.dtd"/> <fileset dir="src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="atrinik/src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="atrinik/src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="crossfire/src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="crossfire/src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="daimonin/src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="daimonin/src/app" includes="**/*.properties,**/*.testdata"/> </copy> <junit printsummary="no" haltonfailure="yes"> <classpath> Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -154,7 +154,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetypePart(@NotNull final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { + protected void finishParseArchetypePart(@Nullable final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { } /** Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/daimonin/ChangeLog 2010-06-02 07:20:40 UTC (rev 8060) @@ -1,3 +1,8 @@ +2010-06-02 Andreas Kirschbaum + + * Fix archetype collection: do not drop mpart_id attributes for + tail parts. + 2010-05-29 Andreas Kirschbaum * Fix incorrect resource path names on Windows machines. Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -129,11 +129,10 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetypePart(@NotNull final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { - // set or check mpart_nr - if (firstArch.getMultiRefCount() == 2) { - firstArch.setMultiShapeID(multiShapeID); - } else if (multiShapeID != firstArch.getMultiShapeID()) { + protected void finishParseArchetypePart(@Nullable final Archetype firstArch, @NotNull final Archetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { + // set or check mpart_id + archetype.setMultiShapeID(multiShapeID); + if (firstArch != null && multiShapeID != firstArch.getMultiShapeID()) { errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDefArchWithInvalidMpartNr", archetype.getArchetypeName(), firstArch.getArchetypeName(), Integer.toString(multiShapeID), Integer.toString(firstArch.getMultiShapeID()))); } } Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -198,7 +198,6 @@ if (firstArch != null) { firstArch.addTailPart(archetype); - finishParseArchetypePart(firstArch, archetype, errorViewCollector); } else if (addToPanel(isInternPath, editorFolder, archetype)) { final String panel; final String folder; @@ -217,6 +216,7 @@ } else { archetype.setEditorFolder(GameObject.EDITOR_FOLDER_INTERN); } + finishParseArchetypePart(firstArch, archetype, errorViewCollector); try { archetypeSet.addArchetype(archetype); } catch (final DuplicateArchetypeException ex) { @@ -338,12 +338,13 @@ protected abstract boolean processLine(@NotNull final BufferedReader in, @NotNull final String line, @NotNull final String line2, @NotNull final B archetypeBuilder, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final List<G> invObjects) throws IOException; /** - * Called after the "end" line of a tail part has been read. - * @param firstArch the head part + * Called after the "end" line of a part has been read. + * @param firstArch the head part or <code>null</code> if + * <code>archetype</code> is the head part * @param archetype the tail part * @param errorViewCollector the error view collector for reporting errors */ - protected abstract void finishParseArchetypePart(@NotNull final R firstArch, @NotNull final R archetype, @NotNull final ErrorViewCollector errorViewCollector); + protected abstract void finishParseArchetypePart(@Nullable final R firstArch, @NotNull final R archetype, @NotNull final ErrorViewCollector errorViewCollector); /** * Called after all parts of an archetype have been processed. Added: trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -0,0 +1,80 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.archetype; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.List; +import net.sf.gridarta.model.errorview.ErrorViewCollector; +import net.sf.gridarta.model.errorview.TestErrorView; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; + +/** + * Abstract base class for regression tests for {@link ArchetypeParser}. + * @author Andreas Kirschbaum + */ +public abstract class AbstractArchetypeParserTest<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Creates a new archetype parser and parses the given input. + * @param input the input to parse + * @param hasErrors whether errors are expected + * @param hasWarnings whether warnings are expected + * @param archetypes the number of archetypes to expect + * @throws IOException if parsing fails + */ + protected void check(@NotNull final String input, final boolean hasErrors, final boolean hasWarnings, final int archetypes) throws IOException { + final AbstractArchetypeParser<G, A, R, ?> archetypeParser = newArchetypeParser(); + final TestErrorView errorView = new TestErrorView(); + final List<G> invObjects = new ArrayList<G>(); + final Reader reader = new StringReader(input); + final BufferedReader bufferedReader = new BufferedReader(reader); + try { + archetypeParser.parseArchetypeFromStream(bufferedReader, null, null, null, "panel", "folder", "", invObjects, new ErrorViewCollector(errorView, new File("*string*"))); + } finally { + bufferedReader.close(); + } + Assert.assertEquals(hasErrors, errorView.hasErrors()); + Assert.assertEquals(hasWarnings, errorView.hasWarnings()); + Assert.assertEquals(archetypes, getArchetypeSet().getArchetypeCount()); + } + + /** + * Creates a new {@link AbstractArchetypeParser} instance. + * @return the new instance + */ + @NotNull + protected abstract AbstractArchetypeParser<G, A, R, ? extends AbstractArchetypeBuilder<G, A, R>> newArchetypeParser(); + + /** + * Returns the {@link ArchetypeSet}. + * @return the archetype set + */ + @NotNull + protected abstract ArchetypeSet<G, A, R> getArchetypeSet(); + +} // class AbstractArchetypeParserTest Property changes on: trunk/src/test/net/sf/gridarta/model/archetype/AbstractArchetypeParserTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -19,18 +19,10 @@ package net.sf.gridarta.model.archetype; -import java.io.BufferedReader; -import java.io.File; import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; import java.util.regex.Pattern; import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.anim.DefaultAnimationObjects; -import net.sf.gridarta.model.errorview.ErrorViewCollector; -import net.sf.gridarta.model.errorview.TestErrorView; import net.sf.gridarta.model.face.ArchFaceProvider; import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; @@ -49,13 +41,13 @@ * Regression tests for {@link AbstractArchetypeParser}. * @author Andreas Kirschbaum */ -public class ArchetypeParserTest { +public class ArchetypeParserTest extends AbstractArchetypeParserTest<TestGameObject, TestMapArchObject, TestArchetype> { /** * The loaded archetypes. */ @Nullable - private TestArchetypeSet archetypeSet = null; + private ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet = null; /** * Checks that a missing "object" line is detected. @@ -83,9 +75,7 @@ @Test public void testMsgTextEmpty() throws IOException, UndefinedArchetypeException { check("Object test\nmsg\nendmsg\nend\n", false, false, 1); - assert archetypeSet != null; - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("test"); - Assert.assertNull(archetype.getMsgText()); + Assert.assertNull(getArchetypeSet().getArchetype("test").getMsgText()); } /** @@ -96,9 +86,7 @@ @Test public void testMsgTextLines() throws IOException, UndefinedArchetypeException { check("Object test\nmsg\nabc\ndef\nghi\nendmsg\nend\n", false, false, 1); - assert archetypeSet != null; - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("test"); - Assert.assertEquals("abc\ndef\nghi\n", archetype.getMsgText()); + Assert.assertEquals("abc\ndef\nghi\n", getArchetypeSet().getArchetype("test").getMsgText()); } /** @@ -109,9 +97,7 @@ @Test public void testMsgTextTrailingWhitespace() throws IOException, UndefinedArchetypeException { check("Object test\nmsg\nabc \ndef\nghi \n\nendmsg\nend\n", false, false, 1); - assert archetypeSet != null; - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("test"); - Assert.assertEquals("abc\ndef\nghi\n\n", archetype.getMsgText()); + Assert.assertEquals("abc\ndef\nghi\n\n", getArchetypeSet().getArchetype("test").getMsgText()); } /** @@ -122,9 +108,7 @@ @Test public void testMsgTextLeadingWhitespace() throws IOException, UndefinedArchetypeException { check("Object test\nmsg\n\n abc\ndef\n ghi\nendmsg\nend\n", false, false, 1); - assert archetypeSet != null; - final Archetype<TestGameObject, TestMapArchObject, TestArchetype> archetype = archetypeSet.getArchetype("test"); - Assert.assertEquals("\n abc\ndef\n ghi\n", archetype.getMsgText()); + Assert.assertEquals("\n abc\ndef\n ghi\n", getArchetypeSet().getArchetype("test").getMsgText()); } /** @@ -137,35 +121,11 @@ } /** - * Creates a new archetype parser and parses the given input. - * @param input the input to parse - * @param hasErrors whether errors are expected - * @param hasWarnings whether warnings are expected - * @param archetypes the number of archetypes to expect - * @throws IOException if parsing fails + * {@inheritDoc} */ - private void check(@NotNull final String input, final boolean hasErrors, final boolean hasWarnings, final int archetypes) throws IOException { - final AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, TestArchetypeBuilder> archetypeParser = newArchetypeParser(); - final TestErrorView errorView = new TestErrorView(); - final List<TestGameObject> invObjects = new ArrayList<TestGameObject>(); - final Reader reader = new StringReader(input); - final BufferedReader bufferedReader = new BufferedReader(reader); - try { - archetypeParser.parseArchetypeFromStream(bufferedReader, null, null, null, "panel", "folder", "", invObjects, new ErrorViewCollector(errorView, new File("*string*"))); - } finally { - bufferedReader.close(); - } - Assert.assertEquals(hasErrors, errorView.hasErrors()); - Assert.assertEquals(hasWarnings, errorView.hasWarnings()); - assert archetypeSet != null; - Assert.assertEquals(archetypes, archetypeSet.getArchetypeCount()); - } - - /** - * Creates a new {@link TestArchetypeParser} instance. - * @return the new instance - */ - public AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, TestArchetypeBuilder> newArchetypeParser() { + @NotNull + @Override + protected AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, ? extends AbstractArchetypeBuilder<TestGameObject, TestMapArchObject, TestArchetype>> newArchetypeParser() { final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); final FaceObjects faceObjects = new DefaultFaceObjects("png", "facetree", Pattern.compile(".*"), "facetree.output", archFaceProvider); final GUIUtils guiUtils = new GUIUtils(); @@ -181,4 +141,16 @@ return new TestArchetypeParser(archetypeBuilder, animationObjects, archetypeSet); } + /** + * {@inheritDoc} + */ + @NotNull + @Override + protected ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> getArchetypeSet() { + if (archetypeSet == null) { + throw new IllegalStateException(); + } + return archetypeSet; + } + } // class ArchetypeParserTest Modified: trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-05-31 17:53:34 UTC (rev 8059) +++ trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-06-02 07:20:40 UTC (rev 8060) @@ -72,7 +72,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetypePart(@NotNull final TestArchetype firstArch, @NotNull final TestArchetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { + protected void finishParseArchetypePart(@Nullable final TestArchetype firstArch, @NotNull final TestArchetype archetype, @NotNull final ErrorViewCollector errorViewCollector) { } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |