[jboss-user] [JBoss Seam] - Seam and testing fail. TestNG

maykellff do-not-reply at jboss.com
Tue Jan 22 10:34:41 EST 2008


Hi all, i'am following the book "Begining JBoss Seam. From novice to Profesional" like a helper to introduce my self in Seam. Now i've transformed a simple jsf application into a Seam-EJB3 application, everything works well but the tests. I'am using Red Hat Developer Studio, it comes with  the TestNG plugin, i try to use TestNG to run a test i wrotte but always i get the same error.

Can it be something related to the package structure i have? Maybe TestNG most have some specific package structure in order to look for the resources it need to run the tests.

Any help will be very appreciated.

This is the error i get:
anonymous wrote : 
  | [Parser] Running:
  |   D:\workspaceRHDS\jsfTest\temp-testng-customsuite.xml
  | 
  | log4j:WARN No appenders could be found for logger (org.hibernate.ejb.Version).
  | log4j:WARN Please initialize the log4j system properly.
  | FAILED CONFIGURATION: @BeforeClass init
  | javax.persistence.PersistenceException: No Persistence provider for EntityManager named jsfTest
  | 	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
  | 	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
  | 	at pruebas.ExpedienteFacadeTest.init(ExpedienteFacadeTest.java:47)
  | ... Removed 22 stack frames
  | SKIPPED CONFIGURATION: @AfterClass destroy
  | SKIPPED: testBuscarExpediente
  | 
  | ===============================================
  |     pruebas.ExpedienteFacadeTest
  |     Tests run: 1, Failures: 0, Skips: 1
  |     Configuration Failures: 1, Skips: 1
  | ===============================================
  | 
  | 
  | ===============================================
  | jsfTest
  | Total tests run: 1, Failures: 0, Skips: 1
  | Configuration Failures: 1, Skips: 1
  | ===============================================

I don't know what is happening, i've tried every posible solution but without results. It seens like it doesn't found the persistence.xml.

This is my persistence.xml:
anonymous wrote : 
  | <?xml version="1.0" encoding="UTF-8"?>
  | <!-- Persistence deployment descriptor for dev profile -->
  | <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
  |              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |              xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
  |              version="1.0">
  |              
  |    <persistence-unit name="jsfTest">
  |       org.hibernate.ejb.HibernatePersistence
  |       <jta-data-source>java:/jsfTestDatasource</jta-data-source>
  |       
  |          
  |          
  |          
  |          
  |          
  |       
  |    </persistence-unit>
  |     
  |  


This is my components.xml:
anonymous wrote : 
  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | 
  | true
  | true
  | jsfTest/#{ejbName}/local
  | 
  | 
  | <managed-persistence-context name="em" auto-create="true" persistence-unit-jndi-name="java:/jsfTestEntityManagerFactory"/>			
  | 
  | 
  | 
  | <entity-query name="queryExpedientes" ejbql="select e from Expediente e"/>
  | 
  |  <persistence:managed-persistence-context name="em"
  |                                      auto-create="true"
  |                           entity-manager-factory="#{emf}"/>
  | 
  |   <persistence:entity-manager-factory name="emf" 
  |                       persistence-unit-name="jsfTest"/>
  | 
  | 


This is my test class:
anonymous wrote : 
  | package pruebas;
  | 
  | import javax.persistence.EntityManager;
  | import javax.persistence.EntityManagerFactory;
  | import javax.persistence.Persistence;
  | 
  | import org.jboss.seam.annotations.In;
  | import org.testng.annotations.Configuration;
  | import org.testng.annotations.Test;
  | 
  | import com.domain.Expediente;
  | import com.domain.nomenclador.NTipoAcusado;
  | import com.facade.ExpedienteFacade;
  | import com.facade.impl.ExpedienteFacadeImpl;
  | 
  | 
  | 
  | public class ExpedienteFacadeTest {
  | 
  |     @In
  | 	EntityManagerFactory emf;
  | 	
  | 	@Test
  | 	public void testBuscarExpediente()
  | 	{
  | 		EntityManager em = emf.createEntityManager();
  | 		em.getTransaction().begin();
  | 		
  |         NTipoAcusado ta = new NTipoAcusado();
  |         ta.setId_tipoacusado(1);ta.setValor("Acusado Libre");
  | 
  |         Expediente exp = new Expediente();
  |         exp.setTipoAcusado(ta);
  | 		
  | 		ExpedienteFacadeImpl ef = new ExpedienteFacadeImpl();
  | 		ef.setEm(em);ef.setExpediente(exp);
  | 		
  | 		String strResult = ef.buscarExpediente();
  | 		assert "some".equals(strResult);
  | 		em.getTransaction().rollback();
  | 		em.close();
  | 	}
  | 	
  | 	@Configuration(beforeTestClass=true)
  | 	public void init()
  | 	{
  | 		emf = Persistence.createEntityManagerFactory("jsfTest");
  | 	}
  | 	
  | 	@Configuration(afterTestClass=true)
  | 	public void destroy()
  | 	{
  | 		emf.close();
  | 	}
  | }



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122260#4122260

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4122260



More information about the jboss-user mailing list