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; 021 022import junit.framework.TestCase; 023import net.sf.gridarta.model.archetype.TestArchetype; 024import net.sf.gridarta.model.gameobject.TestGameObject; 025import net.sf.gridarta.model.maparchobject.TestMapArchObject; 026import net.sf.gridarta.utils.TestActionBuilder; 027import org.jetbrains.annotations.Nullable; 028 029/** 030 * Test for {@link AbstractValidator}. 031 * @author <a href="mailto:cher@riedquat.de">Christian Hujer</a> 032 */ 033public class AbstractValidatorTest extends TestCase { 034 035 /** 036 * Object Under Test: A AbstractValidator. 037 */ 038 @Nullable 039 private Validator<?, ?, ?> oUT; 040 041 /** 042 * {@inheritDoc} 043 * @noinspection ProhibitedExceptionDeclared 044 */ 045 @Override 046 public void setUp() throws Exception { 047 super.setUp(); 048 TestActionBuilder.initialize(); 049 final ValidatorPreferences validatorPreferences = new TestValidatorPreferences(); 050 //noinspection EmptyClass 051 oUT = new AbstractValidator<TestGameObject, TestMapArchObject, TestArchetype>(validatorPreferences, DelegatingMapValidator.DEFAULT_KEY) { 052 053 }; 054 } 055 056 /** 057 * {@inheritDoc} 058 * @noinspection ProhibitedExceptionDeclared 059 */ 060 @Override 061 public void tearDown() throws Exception { 062 super.tearDown(); 063 oUT = null; 064 } 065 066 /** 067 * Test case for {@link AbstractValidator#setEnabled(boolean)}. 068 */ 069 public void testEnabled() { 070 assert oUT != null; 071 oUT.setEnabled(false); 072 assert oUT != null; 073 assertFalse(oUT.isEnabled()); 074 assert oUT != null; 075 oUT.setEnabled(true); 076 assert oUT != null; 077 assertTrue(oUT.isEnabled()); 078 } 079 080}