Package test.org.magicbox.dbunit

Examples of test.org.magicbox.dbunit.DBCentro


  }
 
  public void testUpdateGruppo() throws Exception {

    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
    DBGruppi dbGruppi = new DBGruppi();
    dbGruppi.preparaDb();
   
    _reqMock = new MockHttpServletRequest("GET", "/gruppo.page");
    _reqMock.getSession().setAttribute(Constant.ID_CENTRO_SESSIONE, 46l);
    GruppoImpl gruppo = new GruppoImpl();
    gruppo.setId(1);
    gruppo.setIdCentro(46);
    gruppo.setNome("paperopoli");
        ModelAndView mav = _controller.onSubmit(_reqMock, _resMock,gruppo,new BindException(gruppo, Constant.GRUPPO));
    assertEquals("redirect:gruppi.page?action=elenco", mav.getViewName());

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


    assertEquals("donors/ricercaByCap", mav.getViewName());
  }
 
  public void testCap() throws Exception {

    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
    DBUtenti dbUtenti = new DBUtenti();
    dbUtenti.preparaDb();
    _reqMock = new MockHttpServletRequest("GET", "/ricerche.page?action=cap");
    _reqMock.addRole(Constant.ROLE_USER)
    _reqMock.getSession().setAttribute(Constant.ID_CENTRO_SESSIONE, new Long(46));
    _reqMock.setParameter(Constant.CAP, "09100");
   
    ModelAndView mav = _controller.cap(_reqMock, _resMock);
    assertEquals("donors/elencoRicercaDonatori", mav.getViewName());

    List donors = (List) mav.getModel().get(Constant.ELENCO_DONATORI);
    assertEquals(donors.size(), 11);
    Page pageVO = (Page) mav.getModel().get(Constant.PAGE_VO);
    assertEquals(pageVO.getNumeroMaxPagine(), 1);
    assertEquals(pageVO.getPagina(), 0);
   
    dbUtenti.pulisciDb();
    dbCentro.pulisciDb();
    dbUtenti = null;
    dbCentro = null;
  }
View Full Code Here

    assertEquals("donors/ricercaByCitta", mav.getViewName());
  }
 
  public void testCitta() throws Exception {

    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
    DBUtenti dbUtenti = new DBUtenti();
    dbUtenti.preparaDb();
    _reqMock = new MockHttpServletRequest("GET", "/ricerche.page?action=citta");
    _reqMock.addRole(Constant.ROLE_USER)
    _reqMock.getSession().setAttribute(Constant.ID_CENTRO_SESSIONE, new Long(46));
    _reqMock.setParameter(Constant.CITTA, "cagliari");
   
    ModelAndView mav = _controller.citta(_reqMock, _resMock);
    assertEquals("donors/elencoRicercaDonatori", mav.getViewName());

    List donors = (List) mav.getModel().get(Constant.ELENCO_DONATORI);
    assertEquals(donors.size(), 10);
    Page pageVO = (Page) mav.getModel().get(Constant.PAGE_VO);
    assertEquals(pageVO.getNumeroMaxPagine(), 1);
    assertEquals(pageVO.getPagina(), 0);
   
    dbUtenti.pulisciDb();
    dbCentro.pulisciDb();
    dbUtenti = null;
    dbCentro = null;
  }
View Full Code Here

    assertEquals("donors/ricercaByProvincia", mav.getViewName());
  }
 
  public void testProvincia() throws Exception {

    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
    DBUtenti dbUtenti = new DBUtenti();
    dbUtenti.preparaDb();
    _reqMock = new MockHttpServletRequest("GET", "/ricerche.page?action=provincia");
    _reqMock.addRole(Constant.ROLE_USER)
    _reqMock.getSession().setAttribute(Constant.ID_CENTRO_SESSIONE, new Long(46));
    _reqMock.setParameter(Constant.PROVINCIA, "CA");
   
    ModelAndView mav = _controller.provincia(_reqMock, _resMock);
    assertEquals("donors/elencoRicercaDonatori", mav.getViewName());

    List donors = (List) mav.getModel().get(Constant.ELENCO_DONATORI);
    assertEquals(donors.size(), 11);
    Page pageVO = (Page) mav.getModel().get(Constant.PAGE_VO);
    assertEquals(pageVO.getNumeroMaxPagine(), 1);
    assertEquals(pageVO.getPagina(), 0);
   
    dbUtenti.pulisciDb();
    dbCentro.pulisciDb();
    dbUtenti = null;
    dbCentro = null;
  }
View Full Code Here

  }
 
 
  public void testAlfabetico() throws Exception {

    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
    DBUtenti dbUtenti = new DBUtenti();
    dbUtenti.preparaDb();
    _reqMock = new MockHttpServletRequest("GET", "/ricerche.page?action=alfabetico");
    _reqMock.addRole(Constant.ROLE_USER)
    _reqMock.getSession().setAttribute(Constant.ID_CENTRO_SESSIONE, new Long(46));
    _reqMock.setParameter(Constant.CHAR, "b");
   
    ModelAndView mav = _controller.alfabetico(_reqMock, _resMock);
    assertEquals("donors/elencoRicercaDonatori", mav.getViewName());

    List donors = (List) mav.getModel().get(Constant.ELENCO_DONATORI);
    assertEquals(donors.size(), 15);
    Page pageVO = (Page) mav.getModel().get(Constant.PAGE_VO);
    assertEquals(pageVO.getNumeroMaxPagine(), 1);
    assertEquals(pageVO.getPagina(), 0);
   
    dbUtenti.pulisciDb();
    dbCentro.pulisciDb();
    dbUtenti = null;
    dbCentro = 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

    dbCredentials = null;
  }
 
  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

    _resMock = new MockHttpServletResponse();
  }

  public void testUpdateCentro() throws Exception {

    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();

    _reqMock = new MockHttpServletRequest("GET", "/centro.admin");
    _reqMock.addParameter(Constant.ID, "46");
    Indirizzo indirizzo = new IndirizzoImpl("09100", "cagliari", "CA", "casamia 3");
    //use impl only for test
    CentroLightImpl centroLight = new CentroLightImpl();
    centroLight.setCreditoResiduoSms(200);
    centroLight.setId(46);
    centroLight.setNomeCentro("Centro del quartiere di S.Benedetto");
    centroLight.setNumeroDonatori(200);
   
    Centro centro = new CentroImpl("http://magic-box.wiki.sourceforge.net/",
        "070789123", "0709876543", "gooo46@yahoo.it",
         "Cagliari Due", indirizzo, centroLight);

    ModelAndView mav = _controller.onSubmit(_reqMock, _resMock, centro,
        new BindException(centro, Constant.CENTRO));
    assertEquals(Constant.REDIRECT_ELENCO_CENTRI, mav.getViewName());

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

    _ctx = SpringFactory.getXmlWebApplicationContext();
    _validator = (CentroValidator) _ctx.getBean("magicbox.admin.centroValidator");
  }
 
  public void testAllEmpty() {
    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();

    Centro centro = new CentroImpl();
   
    Errors errors = new BindException(centro, "command");

    _validator.validate(centro, errors);

    assertTrue(errors.hasErrors());
    assertTrue(errors.getErrorCount() == 1);

    dbCentro.pulisciDb();
  }
View Full Code Here

    dbCentro.pulisciDb();
  }
 
  public void testCorrect() {
    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();

    Indirizzo indirizzo = new IndirizzoImpl("09100","cagliari","CA","via casamia 1");
    //use impl only for test
    CentroLightImpl centroLight = new CentroLightImpl();
    centroLight.setCreditoResiduoSms(200);
    centroLight.setId(0);
    centroLight.setNomeCentro("nome");
    centroLight.setNumeroDonatori(300);
   
    Centro centro = new CentroImpl("http://www.casa.org","070123456","070234567","casa@avis.it","descrizione",indirizzo,centroLight);
   
    Errors errors = new BindException(centro, "command");

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

    dbCentro.pulisciDb();
  }
View Full Code Here

TOP

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

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.