Galera gostaria de saber se alguem pode me ajudar estou fazendo uns ejbs e quando e quando vou testalos com un junit me dá o seguinte erro, ja ñ sei mais o q fazer acho q sei + ou - o erro mais ñ consigo resolver se alguem puder me ajudar ficarei muito grato.
Poste seu código para fornecer mais base para nós ajudarmos
Como você está resolvendo as dependências de seu EJB nos unit tests?
robson_vs
Cara vou passar para vcs darem uma olhada em parte do código pois está espalhado em varias camadas
classe de teste
packagebr.com.greenline.falegreen.junit;importjava.util.List;importjunit.framework.Test;importjunit.framework.TestCase;importjunit.framework.TestSuite;importbr.com.greenline.falegreen.delegate.FuncionarioDelegate;importbr.com.greenline.falegreen.model.Funcionario;/** * @author Robson Vieira da Silva */publicclassFuncionarioEJBTestextendsTestCase{// Mensagens geraisprivatestaticfinalStringTESTE_OK="O TESTE REALIZADO COM SUCESSO!!!";privatestaticfinalStringTESTE_ERRO="O TESTE NÃO FOI REALIZADO COM SUCESSO!!!";privatestaticFuncionarioDelegatefuncionarioDelegate;privateFuncionariofuncionario;// Dados para os testes.privatestaticfinalLongFUNCIONARIO_IDENTIFICADOR=newLong(1);publicFuncionarioEJBTest(){super();}publicFuncionarioEJBTest(StringtesteName){super(testeName);}publicstaticTestsuite(){TestSuitesuite=newTestSuite("Teste de Funcionario");suite.addTest(newFuncionarioEJBTest("testeListar"));returnsuite;}static{funcionarioDelegate=newFuncionarioDelegate();}publicvoidtesteListar(){try{Listfuncionarios=funcionarioDelegate.listar();assertNotNull(TESTE_OK+"Numero de Elementos: "+funcionarios.size());}catch(Exceptione){//throw new AssertionFailedError(TESTE_ERRO + e.getMessage());e.printStackTrace();System.out.println(TESTE_ERRO);}}}
classe delegate
packagebr.com.greenline.falegreen.delegate;importjava.rmi.RemoteException;importjava.util.List;importjavax.ejb.CreateException;importjavax.naming.NamingException;importbr.com.greenline.falegreen.interfaces.Funcionario;importbr.com.greenline.falegreen.interfaces.FuncionarioUtil;importbr.com.greenline.falegreen.servicelocator.ICParams;/** * @author Robson Vieira da Silva */publicclassFuncionarioDelegate{privateFuncionarioejb;publicFuncionarioDelegate(){try{ejb=FuncionarioUtil.getHome(ICParams.getParams()).create();}catch(RemoteExceptione){thrownewRuntimeException(e);}catch(CreateExceptione){thrownewRuntimeException(e);}catch(NamingExceptione){thrownewRuntimeException(e);//e.printStackTrace();}}publicvoidsalvar(br.com.greenline.falegreen.model.Funcionariofuncionario){try{ejb.salvar(funcionario);}catch(RemoteExceptione){thrownewRuntimeException(e);}}publicListlistar(){try{returnejb.listar();}catch(RemoteExceptione){thrownewRuntimeException(e);}}publicvoidexcluir(br.com.greenline.falegreen.model.Funcionariofuncionario){try{ejb.excluir(funcionario);}catch(RemoteExceptione){thrownewRuntimeException(e);}}}
classe ejb o restante dos ejbs focam gerados pelo x-doclets