tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe <fischauto...@yahoo.de>
Subject @PreDestroy in embedded unit test
Date Fri, 21 May 2010 13:26:24 GMT
Hi,

I have a stateless bean which executes some native SQL.

@PostConstruct
public void init()
{
   try
   {
     connection = unmanagedDataSource.getConnection();
     // create some tables
   }
   catch (SQLException e)
   {
     throw new RuntimeException(e);
   }
}

@PreDestroy
public void destroy()
{
   try
   {
     // drop some tables
     connection.close();
   }
   catch (SQLException e)
   {
     throw new RuntimeException(e);
   }
}

public void executeNativeSQL()
{
   // some native sql	
}

In my unit test the @PreDestroy annotated method is never invoked.
Is this the expected behaviour?
So in a unit test i have to call the destroy method manually from the 
unit test?






Mime
View raw message