Okey I finally sorted out:
public class UserProfileDaoLocalTest
{
@EJB
private UserProfileDaoLocal userDao;
private static EJBContainer container;
@BeforeClass
public static void start()
{
Properties props = new Properties();
// props.setProperty(EJBContainer.PROVIDER, "tomee-embedded");
// props.put(EJBContainer.MODULES, new File("target/classes"));
props.put("postgresDatabase", "new://Resource?type=DataSource");
props.put("postgresDatabase.JdbcDriver", "org.postgresql.Driver");
props.put("postgresDatabase.JdbcUrl",
"jdbc:postgresql://localhost:5432/aomdb");
props.put("postgresDatabase.JtaManaged", "true");
props.put("postgresDatabase.UserName", "omcadmin");
props.put("postgresDatabase.Password", "omcad1n");
container = EJBContainer.createEJBContainer(props);
}
@AfterClass
public static void stop()
{
container.close();
}
@Before
public void inject() throws NamingException
{
container.getContext().bind("inject", this);
}
@Test
public void testCreateUser() throws NamingException
{
Userprofile user =
new Userprofile();
user.setId("QuentinTarantino");
user.setPassword("123456");
userDao.createUser(user);
List<Userprofile> result =
userDao.findById("QuentinTarantino");
int expected = 1;
assertEquals( expected, result.size() );
}
@Test
public void testFindById() throws NamingException
{
List<Userprofile> result =
userDao.findById("QuentinTarantino");
int expected = 1;
assertEquals( expected, result.size() );
}
@Test
public void testDeleteUser() throws NamingException
{
Userprofile user =
new Userprofile();
user.setId("QuentinTarantino");
userDao.deleteUser(user);
List<Userprofile> result =
userDao.findById("QuentinTarantino");
int expected = 0;
assertEquals( expected, result.size() );
}
I did this and it worked. I hope this is the new good way.
Regards,
Antonio
--
View this message in context:
http://openejb.979440.n4.nabble.com/Impossible-to-instantiate-a-container-tp4660887p4661441.html
Sent from the OpenEJB User mailing list archive at Nabble.com.