Package test.org.magicbox.dbunit

Examples of test.org.magicbox.dbunit.DBCredentials


    assertTrue(errors.hasFieldErrors("username"));
    assertTrue(errors.getErrorCount() == 2);
  }

  public void testWrongPassword() {
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
    Credenziali creds = new Credenziali();
    creds.setUsername("pippo");
    creds.setOldPassword("giulio");
    creds.setPassword("");
    creds.setConfermaPassword("");

   
    Errors errors = new BindException(creds, "command");

    _validator.validate(creds, errors);
    assertTrue(errors.hasErrors());

    assertTrue(errors.hasFieldErrors("oldPassword"));
    assertTrue(errors.getErrorCount() == 1);
   
    dbCredentials.pulisciDb();
    dbCredentials = null;
  }
View Full Code Here


    dbCredentials.pulisciDb();
    dbCredentials = null;
  }
 
  public void testWrongusername() {
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
    Credenziali creds = new Credenziali();
    creds.setUsername("gargoile");
    creds.setOldPassword("giulio");
    creds.setPassword("");
    creds.setConfermaPassword("");

   
    Errors errors = new BindException(creds, "command");

    _validator.validate(creds, errors);
    assertTrue(errors.hasErrors());

    assertTrue(errors.hasFieldErrors("oldPassword"));
    assertTrue(errors.getErrorCount() == 1);
   
    dbCredentials.pulisciDb();
  }
View Full Code Here

    dbCredentials.pulisciDb();
  }
 
 
  public void testCorrectPassword() {
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
    Credenziali creds = new Credenziali();
    creds.setUsername("pippo");
    creds.setOldPassword("pippo");
    creds.setPassword("");
    creds.setConfermaPassword("");
 
    Errors errors = new BindException(creds, "command");

    _validator.validate(creds, errors);
    assertTrue(!errors.hasErrors());

    assertTrue(errors.getErrorCount() == 0);
   
    dbCredentials.pulisciDb();
    dbCredentials = null;
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public void testElenco() throws Exception {

    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
    DBAdmin dbAdmin = new DBAdmin();
    dbAdmin.preparaDb();

    _reqMock = new MockHttpServletRequest("GET", "/amministratori.admin?action=elenco");

    ModelAndView mav = _controller.elenco(_reqMock, _resMock);
    assertEquals("admin/elencoAdmin", mav.getViewName());
    List centri = (List) mav.getModel().get(Constant.ELENCO_ADMIN);
    assertEquals(1,centri.size() );

    dbAdmin.pulisciDb();
    dbCredentials.pulisciDb();
    dbCentro.pulisciDb();
    dbAdmin = null;
    dbCentro = null;
    dbCredentials = null;
  }
View Full Code Here

 
  public void testDettaglio() throws Exception {

    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
    DBAdmin dbAdmin = new DBAdmin();
    dbAdmin.preparaDb();

    _reqMock = new MockHttpServletRequest("GET", "/amministratori.admin?action=dettaglio");
    _reqMock.setParameter(Constant.ID, "1");
    ModelAndView mav = _controller.dettaglio(_reqMock, _resMock);
    assertEquals("admin/dettaglioAdmin", mav.getViewName());

    Amministratore admin = (Amministratore) mav.getModel().get(Constant.ADMIN);
    assertNotNull(admin);
   
   
    dbAdmin.pulisciDb();
    dbCredentials.pulisciDb();
    dbCentro.pulisciDb();
    dbAdmin = null;
    dbCentro = null;
    dbCredentials = null;
  }
View Full Code Here

  public void setUp() throws Exception {
    _ctx = SpringFactory.getXmlWebApplicationContext();
    _service = (CredentialService) _ctx.getBean("magicbox.admin.credentialsService");
  }
  public void testInsertCredentials() {
    DBCredentials dbCredentials = new DBCredentials();
    Credenziali credenziali = new Credenziali();
    credenziali.setUsername("pippo");
    credenziali.setPassword("postgres");
   
    assertTrue(_service.insertCredentials(credenziali));;
    Credenziali retrieve =_service.getAdminByUsername("pippo");
    assertEquals(credenziali.getUsername(), retrieve.getUsername());
    assertNull(retrieve.getPassword());

    dbCredentials.pulisciDb();
    dbCredentials = null;
  }
View Full Code Here

    dbCredentials = null;
  }

  public void testUpdateCredentials(){
    // inserisco max e pippo sul db
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
   
    Credenziali credenziali = _service.getUser("pippo", Cripto.stringToSHA("pippo"));

    assertEquals(credenziali.getUsername(),"pippo");
    assertNull(credenziali.getPassword());
   
    Credenziali update = new Credenziali();
    update.setUsername("pippo");
    update.setPassword(Cripto.stringToSHA("pluto"));
    update.setOldPassword(Cripto.stringToSHA("pippo"));
    update.setConfermaPassword(Cripto.stringToSHA("pluto"));
    assertTrue(_service.updateCredentials(update));

    Credenziali retrieve = _service.getUser("pippo", update.getPassword());
    assertNotNull(retrieve);
    assertEquals(credenziali.getUsername(),retrieve.getUsername());
    assertNull(retrieve.getPassword());
   
    dbCredentials.pulisciDb();
  }
View Full Code Here

  }
   

  public void testGetAdminByUsername(){
    // inserisco max e pippo sul db
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
   
    Credenziali credenziali = _service.getAdminByUsername("pippo");

    assertEquals(credenziali.getUsername(),"pippo");
    assertNull(credenziali.getPassword());

    dbCredentials.pulisciDb();
    dbCredentials = null;
  }
View Full Code Here

    dbCredentials.pulisciDb();
    dbCredentials = null;
  }
  public void testGetUser(){
    // inserisco max e pippo sul db
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
   
    Credenziali credenziali = _service.getUser("pippo", Cripto.stringToSHA("pippo"));

    assertEquals(credenziali.getUsername(),"pippo");
    assertNull(credenziali.getPassword());

    dbCredentials.pulisciDb();
    dbCredentials = null;
  }
View Full Code Here

 
    public void testInsert() {
    DBCentro dbcentro = new DBCentro();
    dbcentro.preparaDb();
    DBRoles dbRoles = new DBRoles();
    DBCredentials dbCredentials = new DBCredentials();
     
    Indirizzo indirizzo = new IndirizzoImpl("09129","Cagliari","CA","Via casamia 74");
    //use impl only for test
    CentroLightImpl centroLight = new CentroLightImpl();
    centroLight.setCreditoResiduoSms(1000);
    centroLight.setId(0);
    centroLight.setNomeCentro("Casa mia");
    centroLight.setNumeroDonatori(144);
    Centro centroView = new CentroImpl("http://www.magicbox.org","070123456","0701234567","desmatik@yahoo.it","Centro San Benedetto",indirizzo,centroLight);
    //use impl only for test
    RecapitoTelefonicoImpl recapito = new RecapitoTelefonicoImpl();
    recapito.setCellulare("3391234567");
    AmministratoreLight adminLight = new AmministratoreLightImpl("pippo","ciccio pasticcio", new Long(46),new Long(0));
    //use implement only for tests
    AmministratoreImpl admin = new AmministratoreImpl();
    admin.setRecapiti(recapito);
    admin.setAmministratoreLight(adminLight);
    admin.setSysadmin(false);
    admin.setEmail("pippo@yahoo.it");
    admin.setPassword("hola");
   
   
    Credenziali creds = new Credenziali("pippo","postgres");
    NuovoCentroView centro = new NuovoCentroView(centroView,"postgres",admin,creds);
   
    assertTrue(_facade.insert(centro));
   
    dbRoles.pulisciDb();
    dbcentro.pulisciDb();
    dbCredentials.pulisciDb();
    dbRoles = null;
    dbcentro = null;
    dbCredentials = null;
  }
View Full Code Here

TOP

Related Classes of test.org.magicbox.dbunit.DBCredentials

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.