Package nz.ac.massey.softwarec.group3.reverseAJAX

Examples of nz.ac.massey.softwarec.group3.reverseAJAX.ReverseAJAXCallTest


     */
    @Override
    public void setScriptSessionGame() {
        final ScriptSession scriptSession = WebContextFactory.get().getScriptSession();
        final HttpSession session = WebContextFactory.get().getSession();
        final Game game = (Game) session.getAttribute("game");
        final String email = (String) session.getAttribute("email");
        scriptSession.setAttribute("game", game);
        scriptSession.setAttribute("email", email);
    }
View Full Code Here


   
    @Before
    public void setUp() {
       
        player=new Player(4,4,4,false);
        game=new Game("username",001);
        action=new Action(player,"BAH","value",game,session);
    }
View Full Code Here

     */
    @Test
    public void testSetScriptSessionGame() {
        System.out.println("setScriptSessionGame");
  
        final Game game=new Game("user@gmail.com",1);
        context.checking(new Expectations(){
            {
                one(session).getAttribute("game");
                will(returnValue(game));
            }
        });
       
        Game resultgame=(Game) session.getAttribute("game");
        assertEquals(game,resultgame);
       
  
        context.checking(new Expectations(){
            {
View Full Code Here

     * @param action - The Action object to be performed.
     */
    public static void performAction(final Action action) {
        final String actionType = action.getActionType();
        final String value = action.getValue();
        Game game = action.getGame();
        final HttpSession session = action.getSession();
        if ("startgame".equals(actionType)) {
            game.setPlaying(true);
            game.startGame();
        }
        if ("setmap".equals(actionType)) {
            game = SessionListener.getSessionTracker().getGameTracker().createNewGame((String) session.getAttribute("email"));
            game.setMap(new Map(value));
            session.setAttribute("game", game);
        }
        if ("setmapname".equals(actionType)) {
            game.getMap().setMapName(value);
        }
        if ("setgamecreator".equals(actionType)) {
            game.setCreatorName(value);
            game.tellLobby();
        }
        if ("joingame".equals(actionType)) {
            game = SessionListener.getSessionTracker().getGameTracker().getGameMadeByCreator(value);
            game.addUserToGame((String) session.getAttribute("email"));
            session.setAttribute("game", game);
        }
        if("takeTurn".equals(actionType)) {
            try {
                game.playerTakesTurn(value);
            } catch (ParserConfigurationException ex) {
                System.err.print(ex);
            } catch (SAXException ex) {
                System.err.print(ex);
            } catch (IOException ex) {
                System.err.print(ex);
            }
        }
        if ("startDoubleMove".equals(actionType)) {
            game.startDoubleTurn();
        }
        if ("cancelDoubleMove".equals(actionType)) {
            game.cancelDoubleTurn();
        }
        if("cannotMove".equals(actionType)) {
            game.getPlayers().get(Integer.parseInt(value)).setCanMove(false);
        }
        if("checkGameEnd".equals(actionType)) {
            game.checkPlayersLose();
        }
        if("leaveGame".equals(actionType)) {
            if (game != null) {
                for (Player player : game.getPlayers()) {
                    if (player.getPlayerEmail().equals(value)) {
                        player.leaveGame();
                        if (game.getWhosTurn() == game.getPlayers().indexOf(player)) {
                            game.determineWhosTurnItIsNext();
                        }
                    }
                }
                session.setAttribute("game", null);
                if (!game.isFinished()) {
                    game.checkEnd();
                }
            }
        }
    }
View Full Code Here

     * Test of getPlayer method, of class Action.
     */
    @Test
    public void testGetPlayer() {
        System.out.println("getPlayer");
        Player result = actionTest.getPlayer();
        Player expResult = player;
        assertEquals(result, expResult);
    }
View Full Code Here

    }

   
    @Before
    public void setUp() {
        player=new Player(5,5,5,false);
        game=new Game("username",001);
        instance=new Action(player,"action","value",game,session);
    }
View Full Code Here

     */
    @Test
    public void testGetPlayer() {
        System.out.println("getPlayer");

        Player result = instance.getPlayer();
        assertEquals(player, result);

    }
View Full Code Here

    @Test
    public void testPerformAction() {
        System.out.println("performAction");
       
     
       Player  player=new Player(5,5,5,false);
       Game game=new Game("username",001);
       Action action=new Action(player,"action","value",game,session);
       
        ActionPerformerInterface instance = new ActionPerformerInterfaceImpl();
        instance.performAction(action);
View Full Code Here

    protected void processRequest(final HttpServletRequest request, final HttpServletResponse response)
            throws ServletException, IOException {
        final HttpSession session = request.getSession();
        final String email = (String) session.getAttribute("email");
        final Game game = (Game) session.getAttribute("game");
        Player player = null;
        if (game != null) {
            player = game.getPlayer(email);
        }
        final String actionType = (String) request.getParameter("action");
        final String value = (String) request.getParameter("value");
View Full Code Here

   
    @Before
    public void setUp() {
       
        player=new Player(4,4,4,false);
        game=new Game("username",001);
        action=new Action(player,"BAH","value",game,session);
    }
View Full Code Here

TOP

Related Classes of nz.ac.massey.softwarec.group3.reverseAJAX.ReverseAJAXCallTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.