From: <aki...@us...> - 2011-12-16 19:26:17
|
Revision: 9121 http://gridarta.svn.sourceforge.net/gridarta/?rev=9121&view=rev Author: akirschbaum Date: 2011-12-16 19:26:09 +0000 (Fri, 16 Dec 2011) Log Message: ----------- Move classes to correct packages. Modified Paths: -------------- trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/validation/checks/ValidatorFactoryTest.java Added Paths: ----------- trunk/model/src/test/net/sf/gridarta/model/validation/ trunk/model/src/test/net/sf/gridarta/model/validation/AbstractValidatorTest.java trunk/model/src/test/net/sf/gridarta/model/validation/TestValidatorPreferences.java trunk/model/src/test/net/sf/gridarta/model/validation/ValidationUtils.java trunk/model/src/test/net/sf/gridarta/model/validation/checks/ trunk/model/src/test/net/sf/gridarta/model/validation/checks/ValidatorFactoryTest.java Removed Paths: ------------- trunk/model/src/test/net/sf/gridarta/validation/ Modified: trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/validation/checks/ValidatorFactoryTest.java =================================================================== --- trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/validation/checks/ValidatorFactoryTest.java 2011-12-16 19:18:31 UTC (rev 9120) +++ trunk/crossfire/src/test/net/sf/gridarta/var/crossfire/model/validation/checks/ValidatorFactoryTest.java 2011-12-16 19:26:09 UTC (rev 9121) @@ -20,7 +20,7 @@ package net.sf.gridarta.var.crossfire.model.validation.checks; import net.sf.gridarta.model.validation.NoSuchValidatorException; -import net.sf.gridarta.validation.ValidationUtils; +import net.sf.gridarta.model.validation.ValidationUtils; import org.junit.Test; /** Copied: trunk/model/src/test/net/sf/gridarta/model/validation/AbstractValidatorTest.java (from rev 9120, trunk/model/src/test/net/sf/gridarta/validation/AbstractValidatorTest.java) =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/validation/AbstractValidatorTest.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/validation/AbstractValidatorTest.java 2011-12-16 19:26:09 UTC (rev 9121) @@ -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.validation; + +import junit.framework.TestCase; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.gridarta.utils.TestActionBuilder; +import org.jetbrains.annotations.Nullable; + +/** + * Test for {@link AbstractValidator}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class AbstractValidatorTest extends TestCase { + + /** + * Object Under Test: A AbstractValidator. + */ + @Nullable + private Validator<?, ?, ?> oUT; + + /** + * {@inheritDoc} + * @noinspection ProhibitedExceptionDeclared + */ + @Override + public void setUp() throws Exception { + super.setUp(); + TestActionBuilder.initialize(); + final ValidatorPreferences validatorPreferences = new TestValidatorPreferences(); + //noinspection EmptyClass + oUT = new AbstractValidator<TestGameObject, TestMapArchObject, TestArchetype>(validatorPreferences, DelegatingMapValidator.DEFAULT_KEY) { + + }; + } + + /** + * {@inheritDoc} + * @noinspection ProhibitedExceptionDeclared + */ + @Override + public void tearDown() throws Exception { + super.tearDown(); + oUT = null; + } + + /** + * Test case for {@link AbstractValidator#setEnabled(boolean)}. + */ + public void testEnabled() { + assert oUT != null; + oUT.setEnabled(false); + assert oUT != null; + assertFalse(oUT.isEnabled()); + assert oUT != null; + oUT.setEnabled(true); + assert oUT != null; + assertTrue(oUT.isEnabled()); + } + +} // class AbstractValidatorTest Property changes on: trunk/model/src/test/net/sf/gridarta/model/validation/AbstractValidatorTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: trunk/model/src/test/net/sf/gridarta/model/validation/TestValidatorPreferences.java (from rev 9120, trunk/model/src/test/net/sf/gridarta/validation/TestValidatorPreferences.java) =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/validation/TestValidatorPreferences.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/validation/TestValidatorPreferences.java 2011-12-16 19:26:09 UTC (rev 9121) @@ -0,0 +1,47 @@ +/* + * 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.validation; + +import org.jetbrains.annotations.NotNull; + +/** + * {@link ValidatorPreferences} implementation for regression tests. The + * settings are not stored or restored. + * @author Andreas Kirschbaum + */ +public class TestValidatorPreferences implements ValidatorPreferences { + + /** + * {@inheritDoc} + */ + @Override + public boolean loadEnabled(@NotNull final String key, final boolean defaultEnabled) { + return defaultEnabled; + } + + /** + * {@inheritDoc} + */ + @Override + public void saveEnabled(@NotNull final String key, final boolean enabled) { + // ignore + } + +} // class TestValidatorPreferences Property changes on: trunk/model/src/test/net/sf/gridarta/model/validation/TestValidatorPreferences.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: trunk/model/src/test/net/sf/gridarta/model/validation/ValidationUtils.java (from rev 9120, trunk/model/src/test/net/sf/gridarta/validation/ValidationUtils.java) =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/validation/ValidationUtils.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/validation/ValidationUtils.java 2011-12-16 19:26:09 UTC (rev 9121) @@ -0,0 +1,68 @@ +/* + * 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.validation; + +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.io.DefaultMapWriter; +import net.sf.gridarta.model.io.GameObjectParser; +import net.sf.gridarta.model.io.MapArchObjectParserFactory; +import net.sf.gridarta.model.io.MapWriter; +import net.sf.gridarta.model.io.TestMapArchObjectParserFactory; +import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.mapmodel.TestMapModelCreator; +import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.match.NamedGameObjectMatcher; +import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher; +import net.sf.gridarta.model.settings.GlobalSettings; +import net.sf.gridarta.model.settings.TestGlobalSettings; +import net.sf.gridarta.model.validation.checks.ValidatorFactory; +import org.jetbrains.annotations.NotNull; + +/** + * Utility class for helper functions needed be regression tests. + * @author Andreas Kirschbaum + */ +public class ValidationUtils { + + /** + * Private constructor to prevent instantiation. + */ + private ValidationUtils() { + } + + /** + * Creates a new {@link ValidatorFactory} instance. + * @return the new instance + */ + @NotNull + public static ValidatorFactory<TestGameObject, TestMapArchObject, TestArchetype> newValidatorFactory() { + final ValidatorPreferences validatorPreferences = new TestValidatorPreferences(); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final GameObjectMatchers gameObjectMatchers = mapModelCreator.getGameObjectMatchers(); + gameObjectMatchers.addGameObjectMatcher(new NamedGameObjectMatcher(0, "matcher", "name", false, null, new TypeNrsGameObjectMatcher(1))); + final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser = mapModelCreator.newGameObjectParser(); + final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory = new TestMapArchObjectParserFactory(); + final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new DefaultMapWriter<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, gameObjectParser); + final GlobalSettings globalSettings = new TestGlobalSettings(); + return new ValidatorFactory<TestGameObject, TestMapArchObject, TestArchetype>(validatorPreferences, gameObjectMatchers, globalSettings, mapWriter); + } + +} // class ValidationUtils Property changes on: trunk/model/src/test/net/sf/gridarta/model/validation/ValidationUtils.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: trunk/model/src/test/net/sf/gridarta/model/validation/checks/ValidatorFactoryTest.java (from rev 9120, trunk/model/src/test/net/sf/gridarta/validation/checks/ValidatorFactoryTest.java) =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/validation/checks/ValidatorFactoryTest.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/validation/checks/ValidatorFactoryTest.java 2011-12-16 19:26:09 UTC (rev 9121) @@ -0,0 +1,302 @@ +/* + * 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.validation.checks; + +import net.sf.gridarta.model.validation.NoSuchValidatorException; +import net.sf.gridarta.model.validation.ValidationUtils; +import net.sf.gridarta.utils.TestActionBuilder; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Regression tests for {@link net.sf.gridarta.model.validation.checks.ValidatorFactory} + * to create validators. + * @author Andreas Kirschbaum + */ +public class ValidatorFactoryTest { + + /** + * Checks that creating an undefined validator results in an exception. + * @throws NoSuchValidatorException if the test succeeds + */ + @Test(expected = NoSuchValidatorException.class) + public void testNewUndefinedChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("abc"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.AttributeRangeChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewAttributeRangeChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.AttributeRangeChecker"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.BlockedMobOrSpawnPointChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewBlockedMobOrSpawnPointChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.BlockedMobOrSpawnPointChecker 1,2,3"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.BlockedSpawnPointChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewBlockedSpawnPointChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.BlockedSpawnPointChecker 1,2,3"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.ConnectedInsideContainerChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewConnectedInsideContainerChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.ConnectedInsideContainerChecker"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.ConnectedPickableChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewConnectedPickableChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.ConnectedPickableChecker"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.ConnectionChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewConnectionChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.ConnectionChecker matcher matcher matcher"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.CustomTypeChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewCustomTypeChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.CustomTypeChecker 1,2 1,2,3"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.DoubleLayerChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewDoubleLayerChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.DoubleLayerChecker"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.DoubleTypeChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewDoubleTypeChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.DoubleTypeChecker"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.EmptySpawnPointChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewEmptySpawnPointChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.EmptySpawnPointChecker 1,2,3"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.EnvironmentChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewEnvironmentChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.EnvironmentChecker"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.ExitChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewExitChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.ExitChecker 1"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.MapDifficultyChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewMapDifficultyChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.MapDifficultyChecker 1 2"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.MobOutsideSpawnPointChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewMobOutsideSpawnPointChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.MobOutsideSpawnPointChecker 1,2,3"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.PaidItemShopSquareChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewPaidItemShopSquareChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.PaidItemShopSquareChecker matcher matcher"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.ShopSquareChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewShopSquareChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.ShopSquareChecker matcher matcher matcher"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.SlayingChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewSlayingChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.SlayingChecker pattern matcher,pattern"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.SquareWithoutFloorChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewSquareWithoutFloorChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.SquareWithoutFloorChecker 1,2,3"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.SysObjectNotOnLayerZeroChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewSysObjectNotOnLayerZeroChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.SysObjectNotOnLayerZeroChecker"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.TilePathsChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewTilePathsChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.TilePathsChecker 4"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.UndefinedArchetypeChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewUndefinedArchetypeChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.UndefinedArchetypeChecker"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.UndefinedFaceChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewUndefinedFaceChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.UndefinedFaceChecker"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.UnsetSlayingChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewUnsetSlayingChecker() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.UnsetSlayingChecker 1,2,3 player"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.MapCheckerScriptChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test(expected = NoSuchValidatorException.class) + public void testNewMapCheckerScriptChecker1() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.MapCheckerScriptChecker a b c"); + } + + /** + * Checks that {@link net.sf.gridarta.model.validation.checks.MapCheckerScriptChecker} + * can be instantiated. + * @throws NoSuchValidatorException if the test fails + */ + @Test + public void testNewMapCheckerScriptChecker2() throws NoSuchValidatorException { + ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.MapCheckerScriptChecker a ${MAP} c"); + } + + /** + * Initializes the action builder. + */ + @BeforeClass + public static void setUp() { + TestActionBuilder.initialize(); + } + +} // class ValidatorFactoryTest Property changes on: trunk/model/src/test/net/sf/gridarta/model/validation/checks/ValidatorFactoryTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |