1 /* $Id$ */ 2 /*************************************************************************** 3 * (C) Copyright 2003-2010 - Stendhal * 4 *************************************************************************** 5 *************************************************************************** 6 * * 7 * This program is free software; you can redistribute it and/or modify * 8 * it under the terms of the GNU General Public License as published by * 9 * the Free Software Foundation; either version 2 of the License, or * 10 * (at your option) any later version. * 11 * * 12 ***************************************************************************/ 13 package games.stendhal.server.actions; 14 15 import static org.junit.Assert.assertFalse; 16 import static org.junit.Assert.assertTrue; 17 18 import org.junit.BeforeClass; 19 import org.junit.Test; 20 21 import games.stendhal.server.actions.attack.StopAction; 22 import games.stendhal.server.entity.player.Player; 23 import marauroa.common.game.RPAction; 24 import marauroa.common.game.RPObject; 25 import utilities.PlayerTestHelper; 26 27 public class StopActionTest { 28 29 @BeforeClass setUpBeforeClass()30 public static void setUpBeforeClass() throws Exception { 31 } 32 33 /** 34 * Tests for onAction. 35 */ 36 @Test testOnAction()37 public void testOnAction() { 38 39 final StopAction sa = new StopAction(); 40 PlayerTestHelper.generatePlayerRPClasses(); 41 final Player player = new Player(new RPObject()) { 42 @Override 43 public void stopAttack() { 44 stopattack = true; 45 46 } 47 48 @Override 49 public void notifyWorldAboutChanges() { 50 notify = true; 51 52 } 53 54 }; 55 final RPAction action = new RPAction(); 56 sa.onAction(player, action); 57 58 assertTrue(notify); 59 assertFalse(stopattack); 60 action.put("attack", "value"); 61 notify = false; 62 stopattack = false; 63 64 sa.onAction(player, action); 65 66 assertTrue(notify); 67 assertTrue(stopattack); 68 69 } 70 71 private boolean stopattack; 72 private boolean notify; 73 74 } 75