Hi David,

great Idea to do unit-testing using the embedded functions of openejb. So I tried...

I have a JavaEE-5 application on Geronimo 2.1.1 with Postgres-DB. (Driver postgresql-8.2-508.jdbc3.jar). In Geronimo I defined a database pool with Pool-Type "TranQL XA Resource Adapter for PostgreSQL". I use Local Sesscion Beans in General. The Application works quite well.

Thus I tried to do this with embedded openejb. After quite a few problems to set up the system, my JUNIT-Test works up to a certain step. It seems there is maybe an impact with the transaction - functionality. The transaction could not be comitted. I could imagine not the XA-Datasource is taken, but who knows??

openejb.conf:
...
  <SecurityService id="Default Security Service"/>
  <TransactionManager id="Default Transaction Manager"/>  
</openejb>


JUNIT-Testcase:
        public void setUp() throws Exception {
                Properties properties = new Properties();
                properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                                "org.apache.openejb.client.LocalInitialContextFactory");
               
                properties.put("openejb.home", "/home/user/workspace/VesuvUnit/openejb");
           
                properties.put("openejb.configuration",
                  "/home/user/workspace/VesuvUnit/openejb/openejb.conf");

                ....
               
                properties.put("Postgres.postgres.vesuv", "new://Resource?type=DataSource");
                properties.put("Postgres.postgres.vesuv.JdbcDriver", "org.postgresql.Driver");
                properties.put("Postgres.postgres.vesuv.JdbcUrl", "jdbc:postgresql://localhost/bla");
                properties.put("Postgres.postgres.vesuv.UserName", "bla");
                properties.put("Postgres.postgres.vesuv.Password", "bla");
   ....

Lookup of the SessionBean works. Invoking the method is fine. SQL-Statements are done. But

LOG:
[DEBUG] [BenutzerManagerImpl] >> Mandant: Mandant:Vesuv Servicestelle Id:1 Kurzname: SS PersonFK:0 Tstaend:null
13:18:31,644 INFO  [Transaction] TX Required: Committing transaction org.apache.geronimo.transaction.manager.TransactionImpl@1579371
13:18:31,693 DEBUG [SQL] <t 15431769, conn 0> executing prepstmnt 31310826 UPDATE vesuv.v_org_einheit SET beziehung_org_einheit_typ = ?, kurz_name = ?, name = ?, org_einheit_typ = ?, person_fk = ?, rechtsform = ?, tstaend = ?, beziehung_org_einheit_fk = ?, uebergeordnete_org_einheit_fk = ? WHERE id = ? [params=(null) null, (String) SS, (String) Vesuv Servicestelle, (String) SS, (long) 1, (String) SS, (Timestamp) 2008-05-26 10:10:43.96, (null) null, (null) null, (long) 1]
13:18:31,702 DEBUG [SQL] <t 15431769, conn 0> [9 ms] spent
13:18:31,717 DEBUG [SQL] <t 15431769, conn 0> executing prepstmnt 23410971 UPDATE vesuv.benutzer SET anzahl_anmeldeversuche = ?, anzahl_anmeldungen = ?, benutzer_kennung = ?, datum_letzte_passwort_aenderung = ?, email_anlage = ?, historie_fk = ?, ist_gesperrt = ?, ist_gesperrt_seit = ?, kostenbefreiung_online_auskunft = ?, letzte_benutzer_gruppe_fk = ?, letzter_anmeldeversuch = ?, passwort_fehlversuche_zaehler = ?, passwort_historie = ?, passwort_sha256hash = ?, passwort_wechsel_erst_anmeldung = ?, person_info_fk = ?, sperrgrund = ?, verknuepft_mit_fk = ?, zuletzt_angemeldet_am = ? WHERE id = ? [params=(long) 0, (long) 0, (String) system, (Timestamp) 2008-05-26 10:10:49.2, (boolean) false, (long) 3, (boolean) false, (Timestamp) 2008-05-26 10:10:49.2, (boolean) false, (null) null, (Timestamp) 2008-05-26 10:10:49.2, (long) 0, (String) keine Historie, (String) 6ee4a469cd4e91053847f5d3fcb61dbcc91e8f0ef10be7748da4c4a1ba382d17, (boolean) false, (long) 2, (String) keiner, (long) 0, (Timestamp) 2008-05-26 10:10:49.2, (long) 8]
13:18:31,718 DEBUG [SQL] <t 15431769, conn 0> [1 ms] spent
13:18:31,719 DEBUG [SQL] <t 15431769, conn 0> executing prepstmnt 8929602 UPDATE vesuv.v_gruppe_org_einheit SET gruppe_name = ?, kurz_name = ?, name = ?, org_einheit_id = ?, org_einheit_typ = ?, person_fk = ?, rechtsform = ? WHERE gruppe_id = ? [params=(String) SystemManager, (String) SS, (String) Vesuv Servicestelle, (long) 1, (String) SS, (long) 1, (String) SS, (long) 1]
13:18:31,721 DEBUG [SQL] <t 15431769, conn 0> [2 ms] spent
13:18:31,721 DEBUG [SQL] <t 15431769, conn 0> executing prepstmnt 24403605 UPDATE vesuv.v_benutzer_gruppe SET benutzer_gruppe_zuordnung_fk = ?, benutzer_kennung = ?, gruppe_name = ? WHERE benutzer_gruppe_id = ? AND benutzer_id = ? [params=(long) 1, (String) system, (String) SystemManager, (long) 1, (long) 8]
13:18:31,722 DEBUG [SQL] <t 15431769, conn 0> [1 ms] spent
13:18:31,737 DEBUG [Runtime] An exception occurred while ending the transaction.  This exception will be re-thrown.
<openjpa-1.0.1-r420667:592145 fatal store error> org.apache.openjpa.util.StoreException: The transaction has been rolled back.  See the nested exceptions for details on the errors that occurred.
...
Caused by: <openjpa-1.0.1-r420667:592145 nonfatal store error> org.apache.openjpa.util.StoreException: FEHLER: kann eine Sicht nicht aktualisieren {prepstmnt 31310826 UPDATE vesuv.v_org_einheit SET beziehung_org_einheit_typ = ?, kurz_name = ?, name = ?, org_einheit_typ = ?, person_fk = ?, rechtsform = ?, tstaend = ?, beziehung_org_einheit_fk = ?, uebergeordnete_org_einheit_fk = ? WHERE id = ? [params=(null) null, (String) SS, (String) Vesuv Servicestelle, (String) SS, (long) 1, (String) SS, (Timestamp) 2008-05-26 10:10:43.96, (null) null, (null) null, (long) 1]} [code=0, state=0A000]
FailedObject: org.apache.openjpa.enhance.de$nrw$hagen$ggrz$bv$orgeinheit$db$VOrgEinheitPAO$pcsubclass-de.nrw.hagen.ggrz.bv.orgeinheit.db.VOrgEinheitPAO-1
...

The LOG-File is in German, therefore some translation: Sicht = View. The Update of the View-PAO does not work. Any suggestions ???


Thanx Josef





David Blevins <david.blevins@visi.com>

21.05.2008 05:12
Bitte antworten an
user@geronimo.apache.org

An
user@geronimo.apache.org
Kopie
Thema
EJB unit testing available





I just wanted to put this on everyone's radar in case it wasn't  
already known.  Those of you writing EJB applications run on Geronimo  
have an extra advantage that those applications can be easily unit  
tested by embedding the Geronimo EJB container (OpenEJB) into your  
test case.

This sort of in-container unit testing technique is something we've  
been innovating for a while and is likely to be a major addition to  
the EJB 3.1 specifications.  I strongly encourage anyone doing EJB  
development to check this out.  There are a number of examples  
available here:
http://openejb.apache.org/examples.html

The net result of this is that you should be able to quickly unit test  
your ejbs in your build as you would test a plain java application.  
With good EJB unit tests you'll get much faster development, fewer  
build/deploy cycles, and be able to quickly catch basic deployment  
issues that stem from incorrect or non-compliant apps.

-David





BGS Beratungsgesellschaft
Software Systemplanung AG
     
  Niederlassung Rhein/Main
Robert-Koch-Straße 41
55129 Mainz
Fon: +49 (0) 6131 / 914-0
Fax: +49 (0) 6131 / 914-400
www.bgs-ag.de
Geschäftssitz Mainz
Registergericht
Amtsgericht Mainz
HRB 62 50
 
Aufsichtsratsvorsitzender
Dr. Wolfgang Trommer
Vorstand
Hanspeter Gau
Hermann Kiefer
Nils Manegold
Heinz-Jörg Zimmermann
BGS Systemplanung AG

 Ein Unternehmen der nextevolution consulting group