Package org.groovymud.object.alive

Examples of org.groovymud.object.alive.Player


    final String password = "x123456";
    final String username = "blow";
    Subject mockSubject = new Subject();
    mockSubject.getPrivateCredentials().add(new PlayerCredentials(username, password));
    MockControl playerCtrl = MockControl.createNiceControl(Player.class);
    Player player = (Player) playerCtrl.getMock();
    player.getSubject();
    playerCtrl.setReturnValue(mockSubject);
    playerCtrl.replay();
    final PasswordCallback mockCallback = new PasswordCallback("password: ", false);
    mockCallback.setPassword(password.toCharArray());
    final Callback[] callbacks = new Callback[1];
View Full Code Here


  }

  public void testCheckPasswordValidExistingPlayerFails() throws IOException, UnsupportedCallbackException, FailedLoginException {
    final String password = "x123456";
    MockControl playerCtrl = MockControl.createNiceControl(Player.class);
    Player player = (Player) playerCtrl.getMock();
    player.getSubject();
    playerCtrl.setDefaultReturnValue(new Subject());
    playerCtrl.replay();
    final PasswordCallback mockCallback = new PasswordCallback("password: ", false);
    mockCallback.setPassword(password.toCharArray());
    final Callback[] callbacks = new Callback[1];
View Full Code Here

  protected boolean doCreatePlayerCallbackCalled;

  public void testCheckPasswordValidNewPlayer() throws IOException, UnsupportedCallbackException, FailedLoginException {
    final String password = "x123456";
    Player player = null;
    final PasswordCallback mockCallback1 = new PasswordCallback("password: ", false);
    final PasswordCallback mockCallback2 = new PasswordCallback("again: ", false);
    mockCallback1.setPassword(password.toCharArray());
    mockCallback2.setPassword(password.toCharArray());
View Full Code Here

    return username;
  }

  protected Player doRegisterNewPlayer(String username) {
    Player p = null;
    try {
      p = getObjectLoader().createNewPlayer(username);
      p.setTerminalOutput(getExtendedTerminalIO());
      getObjectRegistry().register(p);
    } catch (CompilationFailedException e) {
      logger.error(e, e);
    } catch (MudCloneException e) {
      logger.error(e, e);
View Full Code Here

  }

  public void testCheckPasswordValidNewPlayerFailed() throws IOException, UnsupportedCallbackException, FailedLoginException {
    final String password = "x123456";
    Player player = null;
    final PasswordCallback mockCallback1 = new PasswordCallback("password: ", false);
    final PasswordCallback mockCallback2 = new PasswordCallback("again: ", false);
    mockCallback1.setPassword(password.toCharArray());
    mockCallback2.setPassword(password.toCharArray());
View Full Code Here

  protected Player loadPlayer(String username) throws CompilationFailedException, ResourceException, ScriptException, InstantiationException, DataSourceException {
    return getObjectLoader().loadPlayerData(username);
  }

  public Player tryToloadPlayer(String username) {
    Player p = null;
    try {
      p = loadPlayer(username);

    } catch (CompilationFailedException e) {
      logger.error(e, e);
View Full Code Here

  public void testRetrieveExistingPlayer() throws IOException, UnsupportedCallbackException, FailedLoginException {
    final String username = "user";

    final ActionCallback mockActionCallback = new ActionCallback(username, ActionCallback.EXISTS_ACTION);
    MockControl playerCtrl = MockControl.createNiceControl(Player.class);
    Player player = (Player) playerCtrl.getMock();

    mockActionCallback.setMudObject(player);
    final Callback[] callbacks = new Callback[2];
    callbacks[0] = mockActionCallback;
View Full Code Here

    final Subject playerSubject = new Subject();
    playerSubject.getPrincipals().addAll(playerPrincipals);

    MockControl playerControl = MockControl.createControl(Player.class);
    final Player mockPlayer = (Player) playerControl.getMock();
    mockPlayer.getSubject();
    playerControl.setDefaultReturnValue(playerSubject);
    mockPlayer.setSubject(mockSubject);
    playerControl.setDefaultVoidCallable();
    mockPlayer.setSubject(mockSubject);
    playerControl.setDefaultVoidCallable();
    mockPlayer.setPlayerCredentials(mockCredentials);
    playerControl.setDefaultVoidCallable();
    playerControl.replay();

    MudLoginModule mockMod = new MudLoginModule() {

      @Override
      public char[] getPassword() {
        // TODO Auto-generated method stub
        return password.toCharArray();
      }

      @Override
      public Set<Principal> getPlayerPrincipals() {
        // TODO Auto-generated method stub
        return playerPrincipals;
      }

      @Override
      public Subject getSubject() {
        // TODO Auto-generated method stub
        return mockSubject;
      }

      protected void cleanup() {
        assertTrue(hasSucceeded());
        cleanupCalled = true;
      }

      @Override
      public String getUsername() {
        // TODO Auto-generated method stub
        return username;
      }

      @Override
      public Player getPlayer() {
        // TODO Auto-generated method stub
        return mockPlayer;
      }
    };
    mockMod.setSucceeded(true);
    mockMod.commit();
    mockPlayer.getSubject().getPrincipals().contains(playerPrincipal);
    mockPlayer.getSubject().getPrincipals().contains(new MudPrincipal("player"));
    mockPlayer.getSubject().getPrincipals().contains(new MudPrincipal("guest"));

    assertTrue(mockMod.hasCommitSucceeded());
    playerControl.verify();
  }
View Full Code Here

  public void run(Connection connection) {
    setConnection(connection);
    setExtendedTerminalIO((ExtendedTerminalIO) getConnection().getConnectionData().getEnvironment().get("terminalIO"));

    referenceToPlayer = new WeakReference<Player>((Player) getConnection().getConnectionData().getEnvironment().get("player"));
    Player player = referenceToPlayer.get();
    LoginContext lc = (LoginContext) getConnection().getConnectionData().getEnvironment().get("loginContext");
    getInterpreter().doShellCommand("look", player);
    try {
      while (getObjectRegistry().getMudObject(player.getName()) != null) {
        handleRequest(player);
      }
    } catch (Exception e) {
      logger.error(e, e);
    } finally {
View Full Code Here

  }

  // this implements the ConnectionListener!
  public void connectionTimedOut(ConnectionEvent ce) {
    try {
      Player p = referenceToPlayer.get();
      getExtendedTerminalIO().writeln("Sorry, you timed out. See ya!");
      getObjectRegistry().dest(p);
      getExtendedTerminalIO().write("CONNECTION_TIMEDOUT");
      getExtendedTerminalIO().flush();
      // close connection
View Full Code Here

TOP

Related Classes of org.groovymud.object.alive.Player

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.