Skip to main content

Embeddable Container - glassfish-embedded-static-shell (3.1.2.1-SNAPSHOT)

3 replies [Last post]
sven-goran
Offline
Joined: 2012-10-10

Hi,
I am attempting to create Unit/Integration tests using the Embedded EJB 3.1 Container and have some issues and questions.

1) Is it possible to suppress the need for a datasource. Lets say I don't have any entities and just want to test some session beans. Is there any options using some properties or dummy domain.xml file to supress the need of a database?

2) I am just using Netbeans generated tests (and the project structure with the generated ant build) of some very basic sample Stateless EJB's but as soon as I add a MDB and start up the Embedded Container I get OutOfMemory Exceptions. I know that MDB's are not supported but how to I tell Embedded Contianer to just ignore it?

Test is below and I am just using Netbeans to run file.

<br />
EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer();<br />
PersonServiceLocal instance = (PersonServiceLocal)container.getContext().lookup("java:global/classes/PersonService");<br />
instance.addPerson(person);<br />
container.close();<br />

Thanks
Andreas

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mvatkina
Offline
Joined: 2005-04-04

If you don't have any entities, you should not need a database. That said, if you use embedded-static-shell.jar from the installation location (it won't work otherwise), you would have domain.xml that has default JavaDB set up (you can start it via 'asadmin start-database').

You can specify EJB modules (jars or directories) to be deployed via EJBContainer.MODULES but you cannot choose to skip an EJB.

sven-goran
Offline
Joined: 2012-10-10

Thanks for the reply. Would it be possible to get some clarifications on your answer?

1) Can I using the embedded-static-shell.jar provide a domain.xml that has no database connection set up? Like a unit test snippet domain.xml?

2) I was aware of the MODULES notation but I have not managed to get it to work from a Netbeans created project (without Maven). Would it be possible to store the MDB in a separate package (directory) and make use of this to exclude the bean? I have attempted to up Perm size but to no avail.

Any other suggestion how I can easily test Session beans within a project that has other beans which I don't want to include in certain tests? Maybe the best option for me is to move to a Maven based setup?

Thanks
/A

mvatkina
Offline
Joined: 2005-04-04

You can use your own domain.xml but it is not a supported configuration.

You can ask on the Netbeans forum how to set up your project, but in general yes, if your MDB is in a separate module, *and it has a different module name*, you can use MODULES property to choose which modules you want to test.

HTH,
-marina