Subversion Repositories sokoban

Rev

Blame | Last modification | View Log | RSS feed

  1. package gdi.ws0809.test;
  2. import static org.junit.Assert.assertFalse;
  3. import static org.junit.Assert.assertTrue;
  4.  
  5. import java.io.File;
  6. import java.net.URISyntaxException;
  7.  
  8. import org.junit.Before;
  9. import org.junit.BeforeClass;
  10. import org.junit.Test;
  11.  
  12. /**
  13. * Public tests for the 3rd extended Sokoban implementation level
  14. *
  15. * @author Steven Arzt, Oren Avni
  16. * @version 1.0
  17. */
  18. public class SokobanTestExtended3 {
  19.  
  20.                 /**
  21.                  * the tested Sokoban implementation
  22.                  */
  23.                 private SokobanTest testee = null;
  24.                 private static File deadlockLevel;
  25.                
  26.                 @BeforeClass
  27.                 public static void init() {
  28.                         try {
  29.                                 deadlockLevel = new File(ClassLoader.getSystemClassLoader().getResource("deadlock.txt").toURI());
  30.                         } catch (final URISyntaxException e) {
  31.                                 e.printStackTrace();
  32.                         }
  33.                         SokobanTestAdapter.init();
  34.                 }
  35.                
  36.                 @Before
  37.                 public void before() {
  38.                         testee = new SokobanTestAdapter();
  39.                 }
  40.                
  41.                 /**
  42.                  * Requirement "deadlock"
  43.                  * @throws Exception
  44.                  */
  45.                 @Test
  46.                 public void deadlock() throws Exception {
  47.                         testee.loadLevel(deadlockLevel);
  48.                         assertFalse("Initially there is no deadlock.", testee.isDeadlock());
  49.                         testee.moveWorker('R');
  50.                         testee.moveWorker('R');
  51.                         assertTrue("Deadlock not detected. Now there are four items in a square.", testee.isDeadlock());
  52.                 }
  53. }
  54.