Package test.org.magicbox.dbunit

Examples of test.org.magicbox.dbunit.DBCredentials


    _dao = (DaoAuthenticationProvider) _ctx
        .getBean("daoAuthenticationProvider");
  }

  public void testAdmin() {
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
    DBRoles dbRoles = new DBRoles();
    dbRoles.preparaDb();

    Authentication authentication = new UsernamePasswordAuthenticationToken(
        "max", "max");
    Authentication authenticated = _dao.authenticate(authentication);
    assertNotNull(authenticated);
    GrantedAuthority[] authorities = authenticated.getAuthorities();
    assertNotNull(authorities);
    assertEquals(1, authorities.length);
    assertEquals(Constant.ROLE_ADMIN, authorities[0].getAuthority());

    dbRoles.pulisciDb();
    dbCredentials.pulisciDb();
  }
View Full Code Here


    dbRoles.pulisciDb();
    dbCredentials.pulisciDb();
  }

  public void testReferenteCentro() {
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
    DBRoles dbRoles = new DBRoles();
    dbRoles.preparaDb();

    Authentication authentication = new UsernamePasswordAuthenticationToken(
        "pippo", "pippo");
    Authentication authenticated = _dao.authenticate(authentication);
    assertNotNull(authenticated);
    GrantedAuthority[] authorities = authenticated.getAuthorities();
    assertNotNull(authorities);
    assertEquals(1, authorities.length);
    assertEquals(Constant.ROLE_USER, authorities[0].getAuthority());

    dbRoles.pulisciDb();
    dbCredentials.pulisciDb();
  }
View Full Code Here

    dbRoles.pulisciDb();
    dbCredentials.pulisciDb();
  }

  public void testBadCredentials() {
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
    DBRoles dbRoles = new DBRoles();
    dbRoles.preparaDb();

    Authentication authentication = new UsernamePasswordAuthenticationToken(
        "gargoile", "notredame");
    boolean flag = false;
    try {
      _dao.authenticate(authentication);
    } catch (BadCredentialsException e) {
      flag = true;
    }
    assertTrue(flag);

    dbRoles.pulisciDb();
    dbCredentials.pulisciDb();
  }
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", "/ricercheAdmin.admin?action=elenco");
    _reqMock.setParameter(Constant.LETTERA, "p");
    ModelAndView mav = _controller.elenco(_reqMock, _resMock);
    assertEquals("admin/elencoRicercaAlfabeticaAdmins", mav.getViewName());
    List admins = (List) mav.getModel().get(Constant.ELENCO_ADMIN);
    assertEquals(1,admins.size() );

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

 
  public void testPrepara() throws Exception {

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

    _reqMock = new MockHttpServletRequest("GET", "/ricercheAdmin.admin?action=prepara");
    ModelAndView mav = _controller.prepara(_reqMock, _resMock);
    assertEquals("admin/ricercaAlfabeticaReferenti", mav.getViewName());
   
    dbAdmin.pulisciDb();
    dbCredentials.pulisciDb();
    dbCentro.pulisciDb();
  }
View Full Code Here

  public void testUpdate() throws Exception {

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

    _reqMock = new MockHttpServletRequest("GET", "/amministratore.admin");
    _reqMock.addParameter(Constant.ID, "1");
    RecapitoTelefonico recapitotel = new RecapitoTelefonicoImpl("", "", "", "");
    Amministratore admin = new AmministratoreImpl("pippo", "pippo", 46,
        1, false, "", "centrotest@avis.it", recapitotel);

    ModelAndView mav = _controller.onSubmit(_reqMock, _resMock, admin,
        new BindException(admin, Constant.ADMIN));
    assertEquals(Constant.REDIRECT_ELENCO_AMMINISTRATORI, mav.getViewName());

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

    _manager = (AmministratoriManager) _ctx.getBean("magicbox.admin.adminService");
  }
 
 
  public void testGetAmministratori(){
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
    DBAdmin dbAdmin = new DBAdmin();
   
    assertTrue(_manager.getAmministratori().size()==0);
    //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 adminInsert = new AmministratoreImpl();
    adminInsert.setRecapiti(recapito);
    adminInsert.setAmministratoreLight(adminLight);
    adminInsert.setSysadmin(false);
    adminInsert.setEmail("pippo@yahoo.it");
    adminInsert.setPassword("hola");
   
    assertTrue(_manager.saveAmministratore(adminInsert) > 1);
    //use impl only for test
    RecapitoTelefonicoImpl recapitoBis = new RecapitoTelefonicoImpl();
    recapitoBis.setCellulare("3391234567");
    AmministratoreLight adminLightBis = 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(adminLightBis);
    admin.setSysadmin(false);
    admin.setEmail("pippo@yahoo.it");
    admin.setPassword("hola");
   
    assertTrue(_manager.saveAmministratore(admin) > 1);
   
    assertTrue(_manager.getAmministratori().size()==2);

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

    dbCredentials = null;
  }
 
 
  public void testGetAmministratore(){
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
    DBAdmin dbAdmin = new DBAdmin();
    dbAdmin.preparaDb();
   
   
    Amministratore admin = _manager.getAmministratore(1);
    assertEquals(admin.getCellulare(),"03394523123");
    assertEquals(admin.getUsername(),"pippo");
    assertEquals(admin.getEmail(),"centrotest@avis.it");
    assertEquals(admin.getNominativo(),"pippo");
    assertEquals(admin.getIdCentro(),new Long(46));
   
    dbAdmin.pulisciDb();
    dbCentro.pulisciDb()
    dbCredentials.pulisciDb();
    dbAdmin = null;
    dbCentro = null;
    dbCredentials = null;
  }
View Full Code Here

    dbCredentials = null;
  }
 
 
  public void testInsertAmministratore(){
    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
    DBAdmin dbAdmin = new DBAdmin();
    //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 adminInsert = new AmministratoreImpl();
    adminInsert.setRecapiti(recapito);
    adminInsert.setAmministratoreLight(adminLight);
    adminInsert.setSysadmin(false);
    adminInsert.setEmail("pippo@yahoo.it");
    adminInsert.setPassword("hola");
   
   
    assertTrue(_manager.saveAmministratore(adminInsert)>1);

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

  }


  public void testDeleteAmministratore(){

    DBCredentials dbCredentials = new DBCredentials();
    dbCredentials.preparaDb();
    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
    DBAdmin dbAdmin = new DBAdmin();
   
    assertTrue(_manager.getAmministratori().size()==0);
   
    dbAdmin.preparaDb();
   
    assertTrue(_manager.getAmministratori().size()==1);
   
    _manager.deleteAmministratore(1, 46);
   
    assertTrue(_manager.getAmministratori().size()==0);

    dbAdmin.pulisciDb();
    dbCentro.pulisciDb();
    dbCredentials.pulisciDb();
    dbAdmin = 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.