001/* 002 * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. 003 * Copyright (C) 2000-2010 The Gridarta Developers. 004 * 005 * This program is free software; you can redistribute it and/or modify 006 * it under the terms of the GNU General Public License as published by 007 * the Free Software Foundation; either version 2 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU General Public License for more details. 014 * 015 * You should have received a copy of the GNU General Public License along 016 * with this program; if not, write to the Free Software Foundation, Inc., 017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 018 */ 019 020package net.sf.gridarta.model.validation.checks; 021 022import net.sf.gridarta.model.validation.NoSuchValidatorException; 023import net.sf.gridarta.model.validation.ValidationUtils; 024import net.sf.gridarta.utils.TestActionBuilder; 025import org.junit.BeforeClass; 026import org.junit.Test; 027 028/** 029 * Regression tests for {@link net.sf.gridarta.model.validation.checks.ValidatorFactory} 030 * to create validators. 031 * @author Andreas Kirschbaum 032 */ 033public class ValidatorFactoryTest { 034 035 /** 036 * Checks that creating an undefined validator results in an exception. 037 * @throws NoSuchValidatorException if the test succeeds 038 */ 039 @Test(expected = NoSuchValidatorException.class) 040 public void testNewUndefinedChecker() throws NoSuchValidatorException { 041 ValidationUtils.newValidatorFactory().newValidator("abc"); 042 } 043 044 /** 045 * Checks that {@link net.sf.gridarta.model.validation.checks.AttributeRangeChecker} 046 * can be instantiated. 047 * @throws NoSuchValidatorException if the test fails 048 */ 049 @Test 050 public void testNewAttributeRangeChecker() throws NoSuchValidatorException { 051 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.AttributeRangeChecker"); 052 } 053 054 /** 055 * Checks that {@link net.sf.gridarta.model.validation.checks.BlockedMobOrSpawnPointChecker} 056 * can be instantiated. 057 * @throws NoSuchValidatorException if the test fails 058 */ 059 @Test 060 public void testNewBlockedMobOrSpawnPointChecker() throws NoSuchValidatorException { 061 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.BlockedMobOrSpawnPointChecker 1,2,3"); 062 } 063 064 /** 065 * Checks that {@link net.sf.gridarta.model.validation.checks.BlockedSpawnPointChecker} 066 * can be instantiated. 067 * @throws NoSuchValidatorException if the test fails 068 */ 069 @Test 070 public void testNewBlockedSpawnPointChecker() throws NoSuchValidatorException { 071 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.BlockedSpawnPointChecker 1,2,3"); 072 } 073 074 /** 075 * Checks that {@link net.sf.gridarta.model.validation.checks.ConnectedInsideContainerChecker} 076 * can be instantiated. 077 * @throws NoSuchValidatorException if the test fails 078 */ 079 @Test 080 public void testNewConnectedInsideContainerChecker() throws NoSuchValidatorException { 081 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.ConnectedInsideContainerChecker"); 082 } 083 084 /** 085 * Checks that {@link net.sf.gridarta.model.validation.checks.ConnectedPickableChecker} 086 * can be instantiated. 087 * @throws NoSuchValidatorException if the test fails 088 */ 089 @Test 090 public void testNewConnectedPickableChecker() throws NoSuchValidatorException { 091 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.ConnectedPickableChecker"); 092 } 093 094 /** 095 * Checks that {@link net.sf.gridarta.model.validation.checks.ConnectionChecker} 096 * can be instantiated. 097 * @throws NoSuchValidatorException if the test fails 098 */ 099 @Test 100 public void testNewConnectionChecker() throws NoSuchValidatorException { 101 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.ConnectionChecker matcher matcher matcher"); 102 } 103 104 /** 105 * Checks that {@link net.sf.gridarta.model.validation.checks.CustomTypeChecker} 106 * can be instantiated. 107 * @throws NoSuchValidatorException if the test fails 108 */ 109 @Test 110 public void testNewCustomTypeChecker() throws NoSuchValidatorException { 111 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.CustomTypeChecker 1,2 1,2,3"); 112 } 113 114 /** 115 * Checks that {@link net.sf.gridarta.model.validation.checks.DoubleLayerChecker} 116 * can be instantiated. 117 * @throws NoSuchValidatorException if the test fails 118 */ 119 @Test 120 public void testNewDoubleLayerChecker() throws NoSuchValidatorException { 121 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.DoubleLayerChecker"); 122 } 123 124 /** 125 * Checks that {@link net.sf.gridarta.model.validation.checks.DoubleTypeChecker} 126 * can be instantiated. 127 * @throws NoSuchValidatorException if the test fails 128 */ 129 @Test 130 public void testNewDoubleTypeChecker() throws NoSuchValidatorException { 131 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.DoubleTypeChecker"); 132 } 133 134 /** 135 * Checks that {@link net.sf.gridarta.model.validation.checks.EmptySpawnPointChecker} 136 * can be instantiated. 137 * @throws NoSuchValidatorException if the test fails 138 */ 139 @Test 140 public void testNewEmptySpawnPointChecker() throws NoSuchValidatorException { 141 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.EmptySpawnPointChecker 1,2,3"); 142 } 143 144 /** 145 * Checks that {@link net.sf.gridarta.model.validation.checks.EnvironmentChecker} 146 * can be instantiated. 147 * @throws NoSuchValidatorException if the test fails 148 */ 149 @Test 150 public void testNewEnvironmentChecker() throws NoSuchValidatorException { 151 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.EnvironmentChecker"); 152 } 153 154 /** 155 * Checks that {@link net.sf.gridarta.model.validation.checks.ExitChecker} 156 * can be instantiated. 157 * @throws NoSuchValidatorException if the test fails 158 */ 159 @Test 160 public void testNewExitChecker() throws NoSuchValidatorException { 161 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.ExitChecker 1"); 162 } 163 164 /** 165 * Checks that {@link net.sf.gridarta.model.validation.checks.MapDifficultyChecker} 166 * can be instantiated. 167 * @throws NoSuchValidatorException if the test fails 168 */ 169 @Test 170 public void testNewMapDifficultyChecker() throws NoSuchValidatorException { 171 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.MapDifficultyChecker 1 2"); 172 } 173 174 /** 175 * Checks that {@link net.sf.gridarta.model.validation.checks.MobOutsideSpawnPointChecker} 176 * can be instantiated. 177 * @throws NoSuchValidatorException if the test fails 178 */ 179 @Test 180 public void testNewMobOutsideSpawnPointChecker() throws NoSuchValidatorException { 181 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.MobOutsideSpawnPointChecker 1,2,3"); 182 } 183 184 /** 185 * Checks that {@link net.sf.gridarta.model.validation.checks.PaidItemShopSquareChecker} 186 * can be instantiated. 187 * @throws NoSuchValidatorException if the test fails 188 */ 189 @Test 190 public void testNewPaidItemShopSquareChecker() throws NoSuchValidatorException { 191 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.PaidItemShopSquareChecker matcher matcher"); 192 } 193 194 /** 195 * Checks that {@link net.sf.gridarta.model.validation.checks.ShopSquareChecker} 196 * can be instantiated. 197 * @throws NoSuchValidatorException if the test fails 198 */ 199 @Test 200 public void testNewShopSquareChecker() throws NoSuchValidatorException { 201 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.ShopSquareChecker matcher matcher matcher"); 202 } 203 204 /** 205 * Checks that {@link net.sf.gridarta.model.validation.checks.SlayingChecker} 206 * can be instantiated. 207 * @throws NoSuchValidatorException if the test fails 208 */ 209 @Test 210 public void testNewSlayingChecker() throws NoSuchValidatorException { 211 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.SlayingChecker pattern matcher,pattern"); 212 } 213 214 /** 215 * Checks that {@link net.sf.gridarta.model.validation.checks.SquareWithoutFloorChecker} 216 * can be instantiated. 217 * @throws NoSuchValidatorException if the test fails 218 */ 219 @Test 220 public void testNewSquareWithoutFloorChecker() throws NoSuchValidatorException { 221 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.SquareWithoutFloorChecker 1,2,3"); 222 } 223 224 /** 225 * Checks that {@link net.sf.gridarta.model.validation.checks.SysObjectNotOnLayerZeroChecker} 226 * can be instantiated. 227 * @throws NoSuchValidatorException if the test fails 228 */ 229 @Test 230 public void testNewSysObjectNotOnLayerZeroChecker() throws NoSuchValidatorException { 231 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.SysObjectNotOnLayerZeroChecker"); 232 } 233 234 /** 235 * Checks that {@link net.sf.gridarta.model.validation.checks.TilePathsChecker} 236 * can be instantiated. 237 * @throws NoSuchValidatorException if the test fails 238 */ 239 @Test 240 public void testNewTilePathsChecker() throws NoSuchValidatorException { 241 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.TilePathsChecker 4"); 242 } 243 244 /** 245 * Checks that {@link net.sf.gridarta.model.validation.checks.UndefinedArchetypeChecker} 246 * can be instantiated. 247 * @throws NoSuchValidatorException if the test fails 248 */ 249 @Test 250 public void testNewUndefinedArchetypeChecker() throws NoSuchValidatorException { 251 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.UndefinedArchetypeChecker"); 252 } 253 254 /** 255 * Checks that {@link net.sf.gridarta.model.validation.checks.UndefinedFaceChecker} 256 * can be instantiated. 257 * @throws NoSuchValidatorException if the test fails 258 */ 259 @Test 260 public void testNewUndefinedFaceChecker() throws NoSuchValidatorException { 261 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.UndefinedFaceChecker"); 262 } 263 264 /** 265 * Checks that {@link net.sf.gridarta.model.validation.checks.UnsetSlayingChecker} 266 * can be instantiated. 267 * @throws NoSuchValidatorException if the test fails 268 */ 269 @Test 270 public void testNewUnsetSlayingChecker() throws NoSuchValidatorException { 271 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.UnsetSlayingChecker 1,2,3 player"); 272 } 273 274 /** 275 * Checks that {@link net.sf.gridarta.model.validation.checks.MapCheckerScriptChecker} 276 * can be instantiated. 277 * @throws NoSuchValidatorException if the test fails 278 */ 279 @Test(expected = NoSuchValidatorException.class) 280 public void testNewMapCheckerScriptChecker1() throws NoSuchValidatorException { 281 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.MapCheckerScriptChecker a b c"); 282 } 283 284 /** 285 * Checks that {@link net.sf.gridarta.model.validation.checks.MapCheckerScriptChecker} 286 * can be instantiated. 287 * @throws NoSuchValidatorException if the test fails 288 */ 289 @Test 290 public void testNewMapCheckerScriptChecker2() throws NoSuchValidatorException { 291 ValidationUtils.newValidatorFactory().newValidator("net.sf.gridarta.model.validation.checks.MapCheckerScriptChecker a ${MAP} c"); 292 } 293 294 /** 295 * Initializes the action builder. 296 */ 297 @BeforeClass 298 public static void setUp() { 299 TestActionBuilder.initialize(); 300 } 301 302}