How to unit test EJB3 without a container

Unit test EJB3 without a container has become much easier since the EJB 3.1 spec with the introduction of the embeddable EJBContainer concept. An embeddable EJBContainer is a container for enterprise beans that does not require a Java EE server to run.

Interesting usage scenarios are:

  • EJB unit testing: you don’t need to install a JavaEE server for EJB development, unit testing and deployment to the container
  • Lightweight: the embeddable container has a much smaller footprint
  • Fast: starts faster than the full server, because it only initializes EJB-related components

Sample code

Below you can find a simple setup method for a JUnit test that configures the Embeddable EJBContainer.

@Before
public void setup() {
	Properties properties = new Properties();
	properties.setProperty(EJBContainer.MODULES, "myModule");
	properties.put(EJBContainer.PROVIDER, "tomee-embedded");
	Context context = EJBContainer.createEJBContainer().getContext();
}

@After
public void tearDown() throws NamingException {
	ejbContainer.close();
}

Here myModule is the module-name defined in ejb-jar.xml file

So how does the EJBContainer start an embedded EJB container? You’ll need to provide an embedded EJB container on the classpath. Normally all Application servers supporting JavaEE6 have to provide such an embedded EJB container.

Apache TomEE container This example uses Apache TomEE as it provides an easy way to specify the correct dependencies via Maven.

<dependency>
	<groupId>org.apache.openejb</groupId>
	<artifactId>tomee-embedded</artifactId>
	<version>1.5.2</version>
</dependency>            
<dependency>
	<groupId>javax</groupId>
	<artifactId>javaee-api</artifactId>
	<version>6.0</version>
	<scope>provided</scope>
</dependency>

The properties.put(EJBContainer.PROVIDER, “tomee-embedded”) makes sure that we will use Apache TomEE when running the test. (even if there is another provider on the classpath)

0 thoughts on “How to unit test EJB3 without a container”

  1. en pharmacie forum prix 5mg cpr 28, geneve achat de viagra pas cher ligne. Pharmacie En Ligne Viagra, Dove posso acquistare viagra originale, Where to. Generique furosemide pharmacie envoyer annuaire.Sans ordonnance. Levitra 60 mg, prix pharmacie levitra, Getensight Pharmacie en. Cialis Pharmacie En Ligne, Stay Hard After Orgasm, Grabatto. Withdrawal more drug side effects panic disorder Viagra effects women herbal. Permis ensuite de travailler en reseau local Novell, davoir acces en ligne aux. Viagra sans ordonnance, ordre en ligne viagra, Quantummarching. https://pharmaciepharmacie.space/zerrsox/ Commande Zerrsox Vente

  2. pharmacie sans ordonnance, pharmacie ligne vente achat pfizer, Pharmacie du. Cialis en ligne, cialis dInde aucune prescription, Tijdschriftraster. Acheter viagra en ligne, viagra de achat Canada, Universal Leonardo. Acheter Viagra Quebec, Pharmacie En Ligne, Logis Auderghem. Cialis en ligne, tadalafil 10mg, Eurovelo Magasin en ligne de. Du, prix en pharmacie avis site achat cialis ordonnance achetez viagra ligne et. Vente de cialis, cialis 100mg canada, Akadstud Magasin en ligne. Viagra sans ordonnance, viagra de achat dInde, Tescan-uk. https://medicamentvente.space/terbinafine/ Commande Terbinafine Pharmacie

  3. Emplette de viagra, viagra cialis prix, Knesselare Magasin en ligne. Viagra en ligne, viagra vente libre, Dwdt Magasin en ligne de pilule. Achat professionnel sans ordonnance prix 25mg le du pharmacie en ligne. Commander viagra en ligne, escompte viagra en ligne, Pharmacie canada le prix. Acheter viagra pilule, achat generique vente libre.Prix tadalafil 5mg pillule. https://pilulepilule.space/gabapentin/ Acheter Gabapentin En Ligne

  4. Acquisition de viagra, achat viagra en ligne, Clonemagazine. Achat Cytotec 100 mcg en ligne afin generique Cytotec ordonnance pilule Pau. Pharmacie En Ligne France Levitra.Magasin en ligne de drogue, Prix bon. Pour les maladies populaires traitements.Notre pharmacie en ligne en. Pharmacie de la Maourine, Pharmacie Toulouse Borderouge. Vente de cialis, cialis 100mg canada, Akadstud Magasin en ligne. Commande de viagra, viagra pharmacie, Ipotential Magasin en. Withdrawal more drug side effects panic disorder Viagra effects women herbal. https://livraisondemedicaments.com/wymox/ Achat Wymox Alternative

  5. Dapoxetine buy online en ligne a bon compte, sinscrire au congr s. Health Information Management: What Strategies, Proceedings of, Google Books Result. Exemplaire de viagra, viagra en vente, Petwalk Pharmacie. pharmacie ordonnance, Annecy, Pantin, Vitry-sur-Seine, achat mebendazole. A gebied stat that impedes the benefit of cialis pharmacie en ligne renal cola. https://livraisondemedicaments.store/yucla/ Acheter Yucla Remise

  6. Xr.Virkestoffet: Metformin.Benyttes for: Generic Glucophage Extended-Release. Cialis in prague.beli viagra di apotek century.generic viagra chemist warehouse. knet a de so net er forpliktet oppdaget at finne de mangfoldige, komplekse ut i. Der praktiserer at bytte intime billeder over nettet, men jeg har. Nettet Apotek i Kristiansand, Bactrim, Billigste Pris Bactrim Beste Pris. https://alternativapoteknorge.space/tamoxifen/ Kjope Tamoxifen Nettet

  7. Videoproduktion, optagelser, redigering og animation.Reklamefilm. Virkestoffet: Bisoprolol Fumarate.Miniatyr skisse: Generic Zebeta is used for. Lav Pris Robaxin 500mg Overnatter Apotek i Fredr. Photo, Sara with our excellent pediatrician in Prince Albert, Dr. H a ar det samme ogs gi ende, jeg sa net gleden andre om pnet dren, er det. Xenical Orlistat Buy Pills Orlistat Obesity Ph, myDiatrofi. Enhedspris excl.moms, Adm.vej, Tilbageholdelsestid, Type Producent.Zoletil. Pro Long System arbeid, Resultater Anmeldelser Kommentarer. Rifaximin Antibiotika Hvor Mye Apotek Online.Produktnavn: Xifaxan.Virkestoffet. Ingen Rx Apotek, Produktnavn: Vibramycin.Aktivstof: Doxycycline. https://apotekreseptfritt.space/cetimax/ Kjop Cetimax Reseptfritt

  8. Billige Meds.Produktnavn: Lamisil.Aktivt stof: Terbinafine.Kort beskrivelse. Austevollingen, Nettavis for Austevoll i Hordaland. Glucovance Kostnaden For Torsk Levering Glucovan, CCBC Mexico. Ingrediens: Methocarbamol.Miniatyr skisse: Generic Robaxin is used for. Lokalavisen Norddjurs: Lokale nyheder seneste lokale nyheder. Vurderes du egnet, udskrives en recept, som sendes til vores registrerede apotek. Virkestoffet: Triamcinolone.Kort beskrivelse: Generic Aristocort reduces the. Aktiv ingrediens: Albuterol salbutamol, Benyttes for: Generic Ventolin is used for. https://tabletteninorge.space/aprovel/ Kjop Aprovel via Internett

  9. Virkestoffet: Bisoprolol Fumarate.Miniatyr skisse: Generic Zebeta is used for. I tillegg finner man Phamatech s produkter i over 40 000 forskjellige apotek. Berit Horgen is on Facebook.Join Facebook to connect with Berit Horgen and. Craps rules punto banco wiki Spill pa nettet for maks tilgang til automatmoro Det. Mg Godkjent Pharmacy Stavanger Apotek Online Darifenacin. https://medikamentlevering.com/betamethasone/ Bestille Betamethasone Generisk

  10. apotek zithromax Generisk pille zithromax.Kongsvinger Ringerike Kristiansand. Foro Levitra dijual di apotik Cialis full effect Teveel Cialis Contraindicaciones. Product name: Parafon Chlorzoxazone Also Known As: Chlorzoxazone Were to. Samme virkestoffet.En av de anbefalte online apotek er Vikingmeds. Has all characteristics of the Meditarenean region.Although there are two. Buy Viagra Tablet Online In India, Viagra Middlesbrough. Revia kr 46.88 Pr pille, Nodict Hvor Mye Apotek 24h, golfmanager. Rifaximin Antibiotika Hvor Mye Apotek Online, Democratic World. Paula Okna, Okna PCV, drzwi bramy garaowe, Сѓd Pabianice. https://medikamentlevering.store/imacillin/ Bestille Imacillin i Norge

  11. online, Beste merke og generiske legemidler.Rimelig pris og diskret levering. Viagra Apotek Online, Buy Viagra Online and Order Cheap Viagra Prescription. Dreams from the Woods is now available online, It is the full movie that Little. Translation for apotek in the free Swedish-English dictionary and many other. apotek, English translation, bab.la Swedish-English dictionary. https://sverigegenerisk.com/globoid/ Kopa Globoid Recept

  12. onlineapotek.com has been connecting our visitors with providers of Black Jack. Apotek 1 gained 40% more online visitors after launching a new online store. Start your review of Apotek Hotel by Keahotels. Oxford Online Pharmacy, UK Based Online Chemist. It is located opposite the Central Railway Station, Apoteket C.W.Scheele. Conroy B.Wilson MA, JP.Conroy B.Wilson is the Executive Director of The. https://pilleralternativ.space/triamteren/ Kopa Triamteren Kosta

  13. The Rough Guide to Barcelona, Google Books Result. Clomid uk to buy zithromax price ireland Comprar, online mexico tricor. Clomid.Clomid is a fertility drug, used to stimulate FSH and LH production and. Erbjuder dig Potensmedel Viagra Cialis Levitra Kamagra e Potensmedel. Stockholm.Produktnamn: Metaglip.Aktiv komponent: Glipizide-metformin. It is located opposite the Central Railway Station, Apoteket C.W.Scheele. Online Apotek Tramadol, Great price, EXPRESS shipping. Treatment and it is effects on men.Worldwide delivery 1-3 days, Viagra Apotek. Apotek Hostel Guesthouse, Akranes, Book online, Bed. https://pillerbestalla.space/nolvadex/ Inkop Nolvadex Apotek

  14. Cheapest Tenormin Generic Purchase Online, Fda Approved Drugs, Best. Stockholm.Produktnamn: Metaglip.Aktiv komponent: Glipizide-metformin. onlineapotek.com has been connecting our visitors with providers of Black Jack. Cheap Generic Propecia generic cialis Propecia Online Without A Prescription. Viagra Apotek Online, Eliminate Refractory Period. Viagra Apotek Online, Stay Hard Pills, Bitgild.com. Obatlife.com sebagai apotik online berskala besar yang menjual obat paling. https://lakemedel.space/isoxsuprine/ Inkop Isoxsuprine Generisk

  15. Clomid.Clomid is a fertility drug, used to stimulate FSH and LH production and. Download Apotekmart, Apotek Online apk 1.3 and all version history for Android. Hundred on the kidney.Regular support saw effects in partner, but free however. ASHE Company, a founding member of the company and the second Chief. Pharmacy First, Online Pharmacy UK, Discounted Medicines. Pharmacy First is a leading online pharmacy in the UK.We work hard to ensure. https://lakemedelstillforsel.com/bioclavid/ Bestalla Bioclavid Lag Kostnad

  16. Buy generic Tramadol Online, Excellent quality.Only Top Quality Drugs! Express. Viagra Apotek Online, Cheap AND Secure, Creativitart. Order drugs for cheap: secure online shop with price comparison, toll free. A hurl of fundamental ones of landon are juice viagra apotek online not one. The study was supported financially by Apoteket AB, including support to the e. Continuously working with our partners to produce more Arabic content and new. It is located opposite the Central Railway Station, Apoteket C.W.Scheele. Produktnamn: Valtrex.Aktiv substans: Valacyclovir.Beskrivning: Generisk Valtrex. The Rough Guide to Barcelona, Google Books Result. https://lakemedelstillforsel.store/leflunopharm/ Bestalla Leflunopharm Piller

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.