Problema com Testes da JUNIT - Curso Loja Virtual completa com JavaEE e JavaSE

14/03/2013

1

Olá, eu estou na parte 4 do curso Loja Virtual completa com JavaEE e JavaSE, começando os testes dos SessionBeans. Entretanto, os testes não estão rodando corretamente, ou melhor, eles iniciam e não param, como se estivesse num loop infinito.

Imagem do Problema:
[url]http://img545.imageshack.us/img545/4465/problemanosteste.jpg[/url]

Segue abaixo o código do teste:


package br.com.ecommerce.session;

import br.com.ecommerce.entity.User;
import javax.ejb.embeddable.EJBContainer;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
*
* @author JOAO PAULO
*/
public class UserSessionTest {

public UserSessionTest() {
}

@BeforeClass
public static void setUpClass() {
}

@AfterClass
public static void tearDownClass() {
}

@Before
public void setUp() {
}

@After
public void tearDown() {
}

/**
* Test of saveUser method, of class UserSession.
*/
@Test
public void testSaveUser() throws Exception {
System.out.println("saveUser");
User us = new User();
us.setEmail("jpaulobenevides@gmail.com");
us.setName("Joao Paulo");
us.setPassword("12345");
us.setUsername("jpaulo");
EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer();
UserSession instance = (UserSession) container.getContext().lookup("java:global/classes/UserSession");
User result = instance.saveUser(us);
assertTrue(result.getId().intValue() > 0);
assertTrue(result.getListOfAddresses().get(0).getId().intValue() > 0);
container.close();
}
}


Mesmo fazendo o teste somente da saveUser, o teste continua indefinidamente.

Segue abaixo a saída do teste:


WARNING: multiple versions of ant detected in path for junit
jar:file:/C:/Program%20Files/NetBeans%207.3/java/ant/lib/ant.jar!/org/apache/tools/ant/Project.class
and jar:file:/C:/Program%20Files/NetBeans%207.3/Servers/glassfish%203.1.2.2/glassfish/modules/ant.jar!/org/apache/tools/ant/Project.class
Testsuite: br.com.ecommerce.session.UserSessionTest
saveUser
Mar 14, 2013 11:16:41 AM org.glassfish.ha.store.spi.BackingStoreFactoryRegistry register
INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
Mar 14, 2013 11:16:41 AM org.hibernate.validator.util.Version <clinit>
INFO: Hibernate Validator 4.2.0.Final
Mar 14, 2013 11:16:42 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: GlassFish Server Open Source Edition 3.1.2.2 (5) startup time : Embedded (680ms), startup services(938ms), total(1.618ms)
Mar 14, 2013 11:16:42 AM org.glassfish.admin.mbeanserver.JMXStartupService$JMXConnectorsStarterThread run
INFO: JMX006: JMXStartupService had disabled JMXConnector system
Mar 14, 2013 11:16:43 AM org.glassfish.admin.mbeanserver.JMXStartupService shutdown
INFO: JMX001: JMXStartupService and JMXConnectors have been shut down.
Mar 14, 2013 11:16:43 AM com.sun.enterprise.v3.server.AppServerStartup stop
INFO: Shutdown procedure finished
Mar 14, 2013 11:16:43 AM AppServerStartup run
INFO: [Thread[GlassFish Kernel Main Thread,5,main]] exiting
Mar 14, 2013 11:16:43 AM org.glassfish.ha.store.spi.BackingStoreFactoryRegistry register
INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
Mar 14, 2013 11:16:43 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: GlassFish Server Open Source Edition 3.1.2.2 (5) startup time : Embedded (3.219ms), startup services(59ms), total(3.278ms)
Mar 14, 2013 11:16:43 AM org.glassfish.admin.mbeanserver.JMXStartupService$JMXConnectorsStarterThread run
INFO: JMX006: JMXStartupService had disabled JMXConnector system
Mar 14, 2013 11:16:44 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping entry with a Manifest file with a special attribute: javax.faces.jar
Mar 14, 2013 11:16:44 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping entry with a Manifest file with a special attribute: org.eclipse.persistence.jpa.jpql_1.0.1.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.servlet.jsp.jstl.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.management.j2ee.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.ejb.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.transaction.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.mail.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.security.jacc.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping entry with a Manifest file with a special attribute: javax.annotation.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.servlet.jsp-api.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping entry with a Manifest file with a special attribute: webservices-api-osgi.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.faces.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.enterprise.deploy.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: weld-osgi-bundle.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.resource.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: jaxb-osgi.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.servlet.jsp.jstl-api.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.persistence.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: jersey-core.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.security.auth.message.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.jms.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: bean-validator.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.servlet-api.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: webservices-osgi.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping module: javax.el-api.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar
INFO: ... skipping entry with a Manifest file with a special attribute: glassfish-embedded-static-shell.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding EJB module to ScatteredArchive classes
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive hibernate
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive classes
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive validation-api-1.0.0.GA.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive jaxb-api-osgi.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive ant-junit.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive junit-4.10.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive ant-junit4.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive jaxm-api.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive jstl.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive eclipselink-2.3.2.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive standard.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive postgresql-9.1-901.jdbc4.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive hibernate-validator-4.2.0.Final.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive ant.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive javax.persistence-2.0.3.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive ant-launcher.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication
INFO: [DeploymentElement] adding library to ScatteredArchive primefaces-3.4.jar
Mar 14, 2013 11:16:45 AM org.glassfish.ejb.embedded.EJBContainerImpl deploy
INFO: [EJBContainerImpl] Deploying app: org.glassfish.embeddable.archive.ScatteredArchive@48a5dd31
Mar 14, 2013 11:17:54 AM com.sun.ejb.containers.EjbContainerUtilImpl createThreadPoolExecutor
INFO: Created EjbThreadPoolExecutor with thread-core-pool-size 16 thread-max-pool-size 32 thread-keep-alive-seconds 60 thread-queue-capacity 2147483647 allow-core-thread-timeout false
Mar 14, 2013 11:17:54 AM com.sun.enterprise.security.SecurityLifecycle <init>
INFO: SEC1002: Security Manager is OFF.
Mar 14, 2013 11:17:54 AM com.sun.enterprise.security.SecurityLifecycle onInitialization
INFO: SEC1010: Entering Security Startup Service
Mar 14, 2013 11:17:54 AM com.sun.enterprise.security.PolicyLoader loadPolicy
INFO: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
Mar 14, 2013 11:17:54 AM com.sun.enterprise.security.auth.realm.Realm doInstantiate
INFO: SEC1115: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
Mar 14, 2013 11:17:54 AM com.sun.enterprise.security.auth.realm.Realm doInstantiate
INFO: SEC1115: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
Mar 14, 2013 11:17:54 AM com.sun.enterprise.security.auth.realm.Realm doInstantiate
INFO: SEC1115: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
Mar 14, 2013 11:17:54 AM com.sun.enterprise.security.SecurityLifecycle onInitialization
INFO: SEC1011: Security Service(s) Started Successfully
Responder

Posts

16/03/2013

Glauter Lemos

Pelo que foi me dito, nós deveríamos receber uma resposta em até 8 horas pela equipe do Devmedia e já fazem dias que estou esperando.
Responder

16/03/2013

Joel Rodrigues

Olá, esse tipo de dúvida deve ser postada diretamente na página da aula que você está acompanhando. Dessa forma, o autor é notificado quando a aula recebe um comentário e pode lhe responder mais rapidamente. Ainda temos um monitoramento diário dos comentários das aulas, os quais direcionamos ao autor e a consultores especialistas na tecnologia em questão, buscando dar uma resposta ao usuário no menor tempo possível.
Sendo assim, lhe peço que faça o comentário na aula.
Obrigado.
Responder

26/03/2013

Glauter Lemos

Tudo bem, obrigado.
Responder