Hi,

I have a ProcessBeanBase subclass that is my business object.
I implemented a JUnit test to see why I was getting the final Response  "Cannot create 
iterator for this collection' in my browser screen, 
and I always fall in that ClassCastException. 
Need help to understand why. Tks!
 
Here is my business object, that extends "Empresa" that extends ProcessBeanBase :

public class BuscaEmpresasComProjeto extends Empresa{
 
 public final String LEGENDA = "Empresas com Projetos.";
 
 public Object execute(Object parametros) throws Exception{
  
  super.execute(parametros);
  
  ResultList list = new ResultListBase( 
TatilFacade.getInstance().getEmpresasComProjeto(this) );
  
  list.setLegend(LEGENDA);
  
  return new ProcessResultBase(list);
 }

}

Here is the test:

/*
 * Test for Object execute(Object)
 */
final public void testExecuteObject() {
 
 /**
  * Subclass of ProcessBeanBase.
  * Implements execute(Object) method;
  */
 BuscaEmpresasComProjeto busca = new BuscaEmpresasComProjeto();
  
 ArrayList c = null;
 try {
  c = (ArrayList) busca.execute(null);
 } 
 catch (ClassCastException ex){
  Assert.fail("Nao conseguiu fazer o cast de Object para ArrayList, vinda de 
BuscaEmpresasComProjeto.execute() ");
  ex.printStackTrace();
 }
 catch (Exception e) {
  e.printStackTrace();
 }
 Assert.assertTrue( c.size() > 0);
 Iterator i = c.iterator();
 Assert.assertNotNull(i);
}

Felipe

Reply via email to