14. twitter: @kubem
INFO - Configuring Service(id=Default Security Service,
type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Creating TransactionManager(id=Default Transaction Manager)
INFO - Creating SecurityService(id=Default Security Service)
INFO - Configuring enterprise application:
/home/kubam/workspaces/java/various/jee-examples/stockapp/stockapp-ejb-
openejbtest/DozerQuotationConverterIntegrationTest
INFO - Auto-deploying ejb DozerConverterCache: EjbDeployment(deployment-
id=DozerConverterCache)
INFO - Auto-deploying ejb DozerQuotationConverter: EjbDeployment(deployment-
id=DozerQuotationConverter)
INFO - Configuring Service(id=Default Managed Container, type=Container,
provider-id=Default ManagedContainer)
INFO - Auto-creating a container for bean
pl.marchwicki.jee.stockapp.ejb.DozerQuotationConverterIntegrationTest:
Container(type=MANAGED, id=Default Managed Container)
INFO - Creating Container(id=Default Managed Container)
INFO - Configuring Service(id=Default Security Service,
type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Creating TransactionManager(id=Default Transaction Manager)
INFO - Creating SecurityService(id=Default Security Service)
INFO - Configuring enterprise application:
/home/kubam/workspaces/java/various/jee-examples/stockapp/stockapp-ejb-
openejbtest/DozerQuotationConverterIntegrationTest
INFO - Auto-deploying ejb DozerConverterCache: EjbDeployment(deployment-
id=DozerConverterCache)
INFO - Auto-deploying ejb DozerQuotationConverter: EjbDeployment(deployment-
id=DozerQuotationConverter)
INFO - Configuring Service(id=Default Managed Container, type=Container,
provider-id=Default ManagedContainer)
INFO - Auto-creating a container for bean
pl.marchwicki.jee.stockapp.ejb.DozerQuotationConverterIntegrationTest:
Container(type=MANAGED, id=Default Managed Container)
INFO - Creating Container(id=Default Managed Container)
15. twitter: @kubem
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Hel l oWorl dServi ceInt egrat i onTest {
@EJB
Hel l oWor l dSer vi ceLocal hel l oWor l dSer vi ce;
@Test
publ i c voi d shoul dRet urnHel l o( ) {
a s s e r t Eq ua l s ( he l l o Wo r l d Se r v i c e . s a y He l l o ( " Ja kub" ) , " He l l o !
Ja kub" ) ;
}
/ / . . .
}
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Hel l oWorl dServi ceInt egrat i onTest {
@EJB
Hel l oWor l dSer vi ceLocal hel l oWor l dSer vi ce;
@Test
publ i c voi d shoul dRet urnHel l o( ) {
a s s e r t Eq ua l s ( he l l o Wo r l d Se r v i c e . s a y He l l o ( " Ja kub" ) , " He l l o !
Ja kub" ) ;
}
/ / . . .
}
16. twitter: @kubem
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Audi t MessageRecei verTest {
f i nal St ri ng ori gi nal Test Message = "Hel l o Worl d! ";
/ / . .
@Per si st enceCont ext
Ent i t yManager em;
@Test
publ i c voi d processQueue( ) t hrows JMSExcept i on {
Li st <Audi t Log> l i st = em. cr eat eQuer y( " f r om Audi t Log" ,
Audi t Log. cl ass) . get Resul t Li st ( ) ;
a s s e r t No t Nul l ( l i s t ) ;
a s s e r t Eq ua l s ( 1 , l i s t . s i z e ( ) ) ;
a s s e r t Eq ua l s ( o r i g i na l Te s t Me s s a g e , l i s t . g e t ( 0 ) . g e t Me s s a g e ( ) ) ;
}
/ / . .
}
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Audi t MessageRecei verTest {
f i nal St ri ng ori gi nal Test Message = "Hel l o Worl d! ";
/ / . .
@Per si st enceCont ext
Ent i t yManager em;
@Test
publ i c voi d processQueue( ) t hrows JMSExcept i on {
Li st <Audi t Log> l i st = em. cr eat eQuer y( " f r om Audi t Log" ,
Audi t Log. cl ass) . get Resul t Li st ( ) ;
a s s e r t No t Nul l ( l i s t ) ;
a s s e r t Eq ua l s ( 1 , l i s t . s i z e ( ) ) ;
a s s e r t Eq ua l s ( o r i g i na l Te s t Me s s a g e , l i s t . g e t ( 0 ) . g e t Me s s a g e ( ) ) ;
}
/ / . .
}
17. twitter: @kubem
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Audi t MessageProcessorTest {
@Resour ce( name = " Connect i onFact or y" , mappedName =
" Connect i onFact or y" )
Connect i onFact or y connect i onFact or y;
@Resour ce( name = " queue/ audi t " , mappedName = " queue/ audi t " )
Queue queue;
@Test ( t i meout = 2000)
publ i c voi d processQueue( ) t hrows Except i on {
f i nal Connect i on connect i on =
connect i onFact ory. creat eConnect i on( ) ;
connect i on. st ar t ( ) ;
f i nal Sessi on sessi on = connect i on. creat eSessi on( f al se,
Sessi on. AUTO_ ACKNOWLEDGE) ;
f i nal MessageConsumer i ncomi ng =
sessi on. creat eConsumer( queue) ;
Message r ecei ve = i ncomi ng. r ecei ve( ) ;
a s s e r t Tha t ( r e c e i v e , new IsInst anceOf (Text Message. cl ass));
a s s e r t Eq ua l s ( o r i g i na l Te s t Me s s a g e , ( ( Te x t Me s s a g e )
r e c e i v e ) . g e t Te x t ( ) ) ;
}
/ / . . .
}
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Audi t MessageProcessorTest {
@Resour ce( name = " Connect i onFact or y" , mappedName =
" Connect i onFact or y" )
Connect i onFact or y connect i onFact or y;
@Resour ce( name = " queue/ audi t " , mappedName = " queue/ audi t " )
Queue queue;
@Test ( t i meout = 2000)
publ i c voi d processQueue( ) t hrows Except i on {
f i nal Connect i on connect i on =
connect i onFact ory. creat eConnect i on( ) ;
connect i on. st ar t ( ) ;
f i nal Sessi on sessi on = connect i on. creat eSessi on( f al se,
Sessi on. AUTO_ ACKNOWLEDGE) ;
f i nal MessageConsumer i ncomi ng =
sessi on. creat eConsumer( queue) ;
Message r ecei ve = i ncomi ng. r ecei ve( ) ;
a s s e r t Tha t ( r e c e i v e , new IsInst anceOf (Text Message. cl ass));
a s s e r t Eq ua l s ( o r i g i na l Te s t Me s s a g e , ( ( Te x t Me s s a g e )
r e c e i v e ) . g e t Te x t ( ) ) ;
}
/ / . . .
}
18. twitter: @kubem
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Hel l oWorl dServi ceInt egrat i onTest {
@Test
publ i c voi d shoul dCal l WebServi ce( ) t hrows Except i on {
URL wsdl Document Locat i on =
new URL( "ht t p: //127. 0. 0. 1: 4204/modul e/Hel l oWorl dServi ce?
wsdl ") ;
St r i ng namespaceURI =
" ht t p: / / hw. ej b. st ockapp. j ee. mar chwi cki . pl / " ;
St r i ng ser vi cePar t = " Hel l oWor l dSer vi ceSer vi ce" ;
QName ser vi ceQN = new QName( namespaceURI, servi cePart ) ;
Ser vi ce ser vi ce = Ser vi ce. c r e a t e ( ws d l Do c ume nt Lo c a t i o n,
s e r v i c e QN) ;
Hel l oWor l dSer vi ceLocal hel l oWor l d =
ser vi ce. get Por t ( Hel l oWor l dSer vi ceLocal . cl ass) ;
St r i ng s = hel l oWor l d. sayHel l o( " Jakub" ) ;
a s s e r t Eq ua l s ( " He l l o ! Ja kub" , s ) ;
}
/ / . . .
}
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Hel l oWorl dServi ceInt egrat i onTest {
@Test
publ i c voi d shoul dCal l WebServi ce( ) t hrows Except i on {
URL wsdl Document Locat i on =
new URL( "ht t p: //127. 0. 0. 1: 4204/modul e/Hel l oWorl dServi ce?
wsdl ") ;
St r i ng namespaceURI =
" ht t p: / / hw. ej b. st ockapp. j ee. mar chwi cki . pl / " ;
St r i ng ser vi cePar t = " Hel l oWor l dSer vi ceSer vi ce" ;
QName ser vi ceQN = new QName( namespaceURI, servi cePart ) ;
Ser vi ce ser vi ce = Ser vi ce. c r e a t e ( ws d l Do c ume nt Lo c a t i o n,
s e r v i c e QN) ;
Hel l oWor l dSer vi ceLocal hel l oWor l d =
ser vi ce. get Por t ( Hel l oWor l dSer vi ceLocal . cl ass) ;
St r i ng s = hel l oWor l d. sayHel l o( " Jakub" ) ;
a s s e r t Eq ua l s ( " He l l o ! Ja kub" , s ) ;
}
/ / . . .
}
20. twitter: @kubem
JNDI tree
• {deploymentId} / {interfaceClass}
• {appName} / {moduleName} / {beanName}
But where it’s localted?
• java: app/*
• java: comp/env/*
• java: global/*
21. twitter: @kubem
Multiple names
publ i c i nt erf ace Servi ce
{
publ i c St ri ng
hel l o( ) ;
}
publ i c i nt erf ace Servi ce
{
publ i c St ri ng
hel l o( ) ;
}
22. twitter: @kubem
Multiple names
publ i c i nt erf ace Servi ce
{
publ i c St ri ng
hel l o( ) ;
}
publ i c i nt erf ace Servi ce
{
publ i c St ri ng
hel l o( ) ;
} @St at el ess
publ i c cl ass MyServi ce i mpl ement s
Servi ce {
publ i c St ri ng hel l o( ) {
ret urn "Hel l o worl d! ";
}
}
@St at el ess
publ i c cl ass MyServi ce i mpl ement s
Servi ce {
publ i c St ri ng hel l o( ) {
ret urn "Hel l o worl d! ";
}
}
23. twitter: @kubem
Multiple names
publ i c i nt erf ace Servi ce
{
publ i c St ri ng
hel l o( ) ;
}
publ i c i nt erf ace Servi ce
{
publ i c St ri ng
hel l o( ) ;
} @St at el ess
publ i c cl ass MyServi ce i mpl ement s
Servi ce {
publ i c St ri ng hel l o( ) {
ret urn "Hel l o worl d! ";
}
}
@St at el ess
publ i c cl ass MyServi ce i mpl ement s
Servi ce {
publ i c St ri ng hel l o( ) {
ret urn "Hel l o worl d! ";
}
}
@St at el ess
publ i c cl ass MyOt herServi ce i mpl ement s
Servi ce {
publ i c St ri ng hel l o( ) {
ret urn "Hel l o GeeCON! ";
}
}
@St at el ess
publ i c cl ass MyOt herServi ce i mpl ement s
Servi ce {
publ i c St ri ng hel l o( ) {
ret urn "Hel l o GeeCON! ";
}
}
24. twitter: @kubem
Multiple names
publ i c i nt erf ace Servi ce
{
publ i c St ri ng
hel l o( ) ;
}
publ i c i nt erf ace Servi ce
{
publ i c St ri ng
hel l o( ) ;
} @St at el ess
publ i c cl ass MyServi ce i mpl ement s
Servi ce {
publ i c St ri ng hel l o( ) {
ret urn "Hel l o worl d! ";
}
}
@St at el ess
publ i c cl ass MyServi ce i mpl ement s
Servi ce {
publ i c St ri ng hel l o( ) {
ret urn "Hel l o worl d! ";
}
}
@St at el ess
publ i c cl ass MyOt herServi ce i mpl ement s
Servi ce {
publ i c St ri ng hel l o( ) {
ret urn "Hel l o GeeCON! ";
}
}
@St at el ess
publ i c cl ass MyOt herServi ce i mpl ement s
Servi ce {
publ i c St ri ng hel l o( ) {
ret urn "Hel l o GeeCON! ";
}
}
@St ar t up
@Si ngl et on
publ i c cl ass Cl i ent {
@EJB
Ser vi ce ser vi ce;
@Post Const r uct
publ i c voi d i ni t ( ) {
Syst em. o ut . p r i nt l n( s e r v i c e . he l l o ( ) ) ;
}
}
@St ar t up
@Si ngl et on
publ i c cl ass Cl i ent {
@EJB
Ser vi ce ser vi ce;
@Post Const r uct
publ i c voi d i ni t ( ) {
Syst em. o ut . p r i nt l n( s e r v i c e . he l l o ( ) ) ;
}
}
25. twitter: @kubem
DEPLOYMENTS IN ERROR:
Deployment "vfs:///opt/java/jboss-
6.1.0.Final/server/default/deploy/module.jar" is in error due to the
following reason(s): java.lang.RuntimeException: Specified reference
[EJB Reference: beanInterface 'pl.marchwicki.jee6.Service', beanName
'null', mappedName 'null', lookupName 'null', owning unit
'ComponentDeploymentContext@2078856098{org.jboss.metadata.ejb.jboss.JBo
ssEnterpriseBeanMetaData.Client}'] was matched by more than one EJB:
[org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData@8b7ff749{MySer
vice},
org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData@5baed971{MyOthe
rService}]. Specify beanName explciitly or ensure beanInterface is
unique.
DEPLOYMENTS IN ERROR:
Deployment "vfs:///opt/java/jboss-
6.1.0.Final/server/default/deploy/module.jar" is in error due to the
following reason(s): java.lang.RuntimeException: Specified reference
[EJB Reference: beanInterface 'pl.marchwicki.jee6.Service', beanName
'null', mappedName 'null', lookupName 'null', owning unit
'ComponentDeploymentContext@2078856098{org.jboss.metadata.ejb.jboss.JBo
ssEnterpriseBeanMetaData.Client}'] was matched by more than one EJB:
[org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData@8b7ff749{MySer
vice},
org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData@5baed971{MyOthe
rService}]. Specify beanName explciitly or ensure beanInterface is
unique.
26. twitter: @kubem
INFO: Created Ejb(deployment-id=Client, ejb-name=Client, container=My
Singleton Container)
May 11, 013 4:23:24 PM org.apache.openejb.assembler.classic.Assembler
startEjbs
INFO: Started Ejb(deployment-id=MyService, ejb-name=MyService,
container=My Stateless Container)
May 11, 2013 4:23:24 PM org.apache.openejb.assembler.classic.Assembler
startEjbs
INFO: Started Ejb(deployment-id=MyOtherService,
ejb-name=MyOtherService, container=My Stateless Container)
Hello world!
INFO: Created Ejb(deployment-id=Client, ejb-name=Client, container=My
Singleton Container)
May 11, 013 4:23:24 PM org.apache.openejb.assembler.classic.Assembler
startEjbs
INFO: Started Ejb(deployment-id=MyService, ejb-name=MyService,
container=My Stateless Container)
May 11, 2013 4:23:24 PM org.apache.openejb.assembler.classic.Assembler
startEjbs
INFO: Started Ejb(deployment-id=MyOtherService,
ejb-name=MyOtherService, container=My Stateless Container)
Hello world!
27. twitter: @kubem
Different implementations
@Xml Root El ement
publ i c cl ass Todo {
pri vat e l ong i d;
@Not Nul l
@Si ze( mi n = 1)
pri vat e St ri ng t i t l e;
pri vat e l ong order;
pri vat e bool ean compl et ed;
/ / . . .
}
@Xml Root El ement
publ i c cl ass Todo {
pri vat e l ong i d;
@Not Nul l
@Si ze( mi n = 1)
pri vat e St ri ng t i t l e;
pri vat e l ong order;
pri vat e bool ean compl et ed;
/ / . . .
}
28. twitter: @kubem
Different implementations
@Xml Root El ement
publ i c cl ass Todo {
pri vat e l ong i d;
@Not Nul l
@Si ze( mi n = 1)
pri vat e St ri ng t i t l e;
pri vat e l ong order;
pri vat e bool ean compl et ed;
/ / . . .
}
@Xml Root El ement
publ i c cl ass Todo {
pri vat e l ong i d;
@Not Nul l
@Si ze( mi n = 1)
pri vat e St ri ng t i t l e;
pri vat e l ong order;
pri vat e bool ean compl et ed;
/ / . . .
}
@Pat h( " / t odos" )
@Pr oduces( Medi aType. APPLICATION_ JSON)
publ i c cl ass TodoResource {
@GET
publ i c Li st <Todo> get Al l ( ) {
ret urn st ore. get Al l ( ) ;
}
@GET
@Pat h( " / { i d} " )
publ i c Todo get ( @Pat hParam( "i d") l ong
i d) {
ret urn st ore. get ( i d) ;
}
/ / . . .
}
@Pat h( " / t odos" )
@Pr oduces( Medi aType. APPLICATION_ JSON)
publ i c cl ass TodoResource {
@GET
publ i c Li st <Todo> get Al l ( ) {
ret urn st ore. get Al l ( ) ;
}
@GET
@Pat h( " / { i d} " )
publ i c Todo get ( @Pat hParam( "i d") l ong
i d) {
ret urn st ore. get ( i d) ;
}
/ / . . .
}
33. twitter: @kubem
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Audi t MessageRecei verTest {
f i nal St ri ng ori gi nal Test Message = "Hel l o Worl d! ";
//. .
@Per si st enceCont ext
Ent i t yManager em;
@Test
publ i c voi d processQueue( ) t hrows JMSExcept i on {
Li st <Audi t Log> l i st = em. cr eat eQuer y( " f r om Audi t Log" ,
Audi t Log. cl ass) . get Resul t Li st ( ) ;
a s s e r t No t Nul l ( l i s t ) ;
a s s e r t Eq ua l s ( 1 , l i s t . s i z e ( ) ) ;
a s s e r t Eq ua l s ( o r i g i na l Te s t Me s s a g e , l i s t . g e t ( 0 ) . g e t Me s s a g e ( ) ) ;
}
//. .
}
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Audi t MessageRecei verTest {
f i nal St ri ng ori gi nal Test Message = "Hel l o Worl d! ";
//. .
@Per si st enceCont ext
Ent i t yManager em;
@Test
publ i c voi d processQueue( ) t hrows JMSExcept i on {
Li st <Audi t Log> l i st = em. cr eat eQuer y( " f r om Audi t Log" ,
Audi t Log. cl ass) . get Resul t Li st ( ) ;
a s s e r t No t Nul l ( l i s t ) ;
a s s e r t Eq ua l s ( 1 , l i s t . s i z e ( ) ) ;
a s s e r t Eq ua l s ( o r i g i na l Te s t Me s s a g e , l i s t . g e t ( 0 ) . g e t Me s s a g e ( ) ) ;
}
//. .
}
Configuration
34. twitter: @kubem
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Audi t MessageRecei verTest {
@Modul e
publ i c Ej bJar modul e( ) {
f i nal Ej bJar ej bJar = new Ej bJar( ) ;
ej bJar . addEnt er pr i seBean( new
St at el essBean( Audi t MessageProcessi ng. cl ass) ) ;
ej bJar . addEnt er pr i seBean( new
St at el essBean( Audi t LoggerServi ce. cl ass) ) ;
ej bJar . addEnt er pr i seBean( new
MessageDri venBean( Audi t i ngMessageLi st erner. cl ass) ) ;
ret urn ej bJar;
}
//. .
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Audi t MessageRecei verTest {
@Modul e
publ i c Ej bJar modul e( ) {
f i nal Ej bJar ej bJar = new Ej bJar( ) ;
ej bJar . addEnt er pr i seBean( new
St at el essBean( Audi t MessageProcessi ng. cl ass) ) ;
ej bJar . addEnt er pr i seBean( new
St at el essBean( Audi t LoggerServi ce. cl ass) ) ;
ej bJar . addEnt er pr i seBean( new
MessageDri venBean( Audi t i ngMessageLi st erner. cl ass) ) ;
ret urn ej bJar;
}
//. .
35. twitter: @kubem
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Audi t MessageRecei verTest {
//. .
@Modul e
publ i c Persi st enceUni t persi st ence( ) {
Per si st enceUni t uni t = new Persi st enceUni t ( "st ockapp- audi t ") ;
uni t . set Jt aDat aSour ce( " Def aul t DS" ) ;
uni t . set Pr ovi der ( Hi ber nat ePer si st ence. cl ass) ;
uni t . addCl ass( Audi t Log. cl ass) ;
Pr oper t i es dbPr oper t i es = new Propert i es( ) ;
dbPr oper t i es. set Pr oper t y( " hi ber nat e. hbm2ddl . aut o" , " cr eat e-
dr op" ) ;
dbPr oper t i es. set Pr oper t y( " hi ber nat e. di al ect " ,
" or g. hi ber nat e. di al ect . HSQLDi al ect " ) ;
dbPr oper t i es. set Pr oper t y" hi ber nat e. use_sql _comment s" , " t r ue" ) ;
dbPr oper t i es. set Pr oper t y( " hi ber nat e. show_sql " , " t r ue" ) ;
dbPr oper t i es. set Pr oper t y( " hi ber nat e. f or mat _sql " , " t r ue" ) ;
uni t . set Pr oper t i es( dbPr oper t i es) ;
ret urn uni t ;
}
//. .
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Audi t MessageRecei verTest {
//. .
@Modul e
publ i c Persi st enceUni t persi st ence( ) {
Per si st enceUni t uni t = new Persi st enceUni t ( "st ockapp- audi t ") ;
uni t . set Jt aDat aSour ce( " Def aul t DS" ) ;
uni t . set Pr ovi der ( Hi ber nat ePer si st ence. cl ass) ;
uni t . addCl ass( Audi t Log. cl ass) ;
Pr oper t i es dbPr oper t i es = new Propert i es( ) ;
dbPr oper t i es. set Pr oper t y( " hi ber nat e. hbm2ddl . aut o" , " cr eat e-
dr op" ) ;
dbPr oper t i es. set Pr oper t y( " hi ber nat e. di al ect " ,
" or g. hi ber nat e. di al ect . HSQLDi al ect " ) ;
dbPr oper t i es. set Pr oper t y" hi ber nat e. use_sql _comment s" , " t r ue" ) ;
dbPr oper t i es. set Pr oper t y( " hi ber nat e. show_sql " , " t r ue" ) ;
dbPr oper t i es. set Pr oper t y( " hi ber nat e. f or mat _sql " , " t r ue" ) ;
uni t . set Pr oper t i es( dbPr oper t i es) ;
ret urn uni t ;
}
//. .
36. twitter: @kubem
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Audi t MessageRecei verTest {
//. .
@Conf i gur at i on
publ i c Propert i es conf i g( ) t hrows Except i on {
Pr oper t i es p = new Propert i es( ) ;
p. put ( " Def aul t DS" , " new: / / Resour ce?t ype=Dat aSour ce" ) ;
p. put ( " Def aul t DS. JdbcDr i ver " , " or g. hsql db. j dbcDr i ver " ) ;
p. put ( " Def aul t DS. JdbcUr l " , " j dbc: hsql db: mem: t est db" ) ;
ret urn p;
}
//. .
@RunWi t h( Appl i cat i onComposer . cl ass)
publ i c cl ass Audi t MessageRecei verTest {
//. .
@Conf i gur at i on
publ i c Propert i es conf i g( ) t hrows Except i on {
Pr oper t i es p = new Propert i es( ) ;
p. put ( " Def aul t DS" , " new: / / Resour ce?t ype=Dat aSour ce" ) ;
p. put ( " Def aul t DS. JdbcDr i ver " , " or g. hsql db. j dbcDr i ver " ) ;
p. put ( " Def aul t DS. JdbcUr l " , " j dbc: hsql db: mem: t est db" ) ;
ret urn p;
}
//. .
37. twitter: @kubem
Test only EJB
It’s not a real application server
Webservices: Apache CXF
JMS: Apache MQ
JPA: OpenJPA
Hibernate
(any provider)
39. twitter: @kubem
The aliens have landed
• Arquillian is a testing framework
• There are runners…
• Containers…
• & Enrichers
40. twitter: @kubem
The aliens have landed
• Arquillian is a testing framework
• There are runners…
– JUnit
– TestNG
• Containers…
• & Enrichers
41. twitter: @kubem
The aliens have landed
• Arquillian is a testing framework
• There are runners…
• Containers…
– Weld
– Tomcat
– JBoss
– Glassfish
• & Enrichers
42. twitter: @kubem
The aliens have landed
• Arquillian is a testing framework
• There are runners…
• Containers…
• & Enrichers
– glue layer between
your code and
the container:
inject, track results
44. twitter: @kubem
The are three modes
• Embedded
– You run your app server together with your code, in a
single JVM
• Managed
– Arquillian starts and stops your nodes, together with an
app, in separate JVMs
• Remote
– Everything is remotly deployed
45. twitter: @kubem
And four ways for
communicating results
• Local
– Same JVM, local bindings
• Servlet 2.5
– Pre JEE-6 containers
• Servlet 3.0
– Leveraging async servlets
• JMX
– Jboss AS 7 way
53. twitter: @kubem
You can innovate on
nonfunctional areas, such as
devops, logging, metrics, etc, if
your core business needs to be
more conservative.
54. twitter: @kubem
Innovation comes not just from
using new technologies, but also
from using new techniques with
old boring technologies
It all started with OpenEJB – and that was the driver for last year talk. Much have changed since than – year is like an epoch, but lets recap
And that way I started digging embeddable containters. OpenEJB was the only option. We started with classpath scanning. We built a test. Run. Scan everything and got a result… or not ;-) So the test sometimes worked, sometimes didnt
It was possible to bootstrap the container Your test class was as EJB component – injections were possible Different granularity of test were possible (not only unit as in unit and not only end-2-end) Testing the border between application and the application server (configuration elements).
So we have an actual container
Our tests are EJB components
We can test certain slices within the container
Including JMS
And web services
OpenEJB is eventually one of many spec implementation – not necessary the one you use at production The spec is vague – and there are many little but important differences (duplicate names) Everything is run within a single JVM The spec is a set of libraries, components – implementations differs. Apache CXF and RestEASY (jettison and jackson)
I’ll not talk about non standard extensions (like additional annotations in Hibernate – that’s failry obvious). But take this example
I’ll not talk about non standard extensions (like additional annotations in Hibernate – that’s failry obvious). But take this example
This happens just by changing implementation from jackson (default on RestEASY and Jboss) to jettison (default on Apache CXF hence TomEE). From the application (front end perspective) it’s a huge difference.
Building and configuring the application (the deployment) was cumbersome If focus only on EJB the differences were minimal, magic happened when you started to test web services Your code never actually got deployed (similar to Spring Test) – it have never been tested against the actual application server: Tomcat, Jboss etc
We can test certain slices within the container
We can test certain slices within the container
We can test certain slices within the container
We can test certain slices within the container
What happened since then * Arquillian matured * ApplicationComposer is still alive – but it’s not the main driver * OpenEJB evolved into TomEE (which just become 1.5.2) * Arquillian become main driver for OpenSourced TCK
Arquillian abstract container or application startup logic away from your tests (that bit we had for openEJB) Allows to deploy your application to targeted runtime (embedded, managed)