Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

GeeCON 2013 - EJB application guided by tests

659 views

Published on

Published in: Technology, Business
  • D0WNL0AD FULL ▶ ▶ ▶ ▶ http://1lite.top/L2Pxm ◀ ◀ ◀ ◀
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Hi there! Get Your Professional Job-Winning Resume Here - Check our website! http://bit.ly/resumpro
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

GeeCON 2013 - EJB application guided by tests

  1. 1. EJB applications guided by testsJakub Marchwicki
  2. 2. twitter: @kubem?
  3. 3. twitter: @kubemThe experimentpain
  4. 4. twitter: @kubemThe experimentnb of slidespain
  5. 5. twitter: @kubemThe experimentOKSeverehealthrisk20 slidesnb of slidespain
  6. 6. twitter: @kubemThe experimentOKSeverehealthrisk60 slides + IDEnb of slidespain
  7. 7. twitter: @kubem
  8. 8. It started a year ago
  9. 9. twitter: @kubemGeeCon 2012 @ Poznań
  10. 10. twitter: @kubemGeeCon 2012 @ Poznań
  11. 11. twitter: @kubemBut in fact it started much earlierJBoss 4.xTaking form 7 to 20 minutes to startNo CI environment
  12. 12. twitter: @kubemDelivery a feature withonly a single deploy
  13. 13. twitter: @kubemThe GoodEmbedded containerYour test is you componentFocused integration testing
  14. 14. twitter: @kubemINFO - 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/DozerQuotationConverterIntegrationTestINFO - 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 beanpl.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/DozerQuotationConverterIntegrationTestINFO - 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 beanpl.marchwicki.jee.stockapp.ejb.DozerQuotationConverterIntegrationTest:Container(type=MANAGED, id=Default Managed Container)INFO - Creating Container(id=Default Managed Container)
  15. 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 {@EJBHel l oWor l dSer vi ceLocal hel l oWor l dSer vi ce;@Testpubl 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 {@EJBHel l oWor l dSer vi ceLocal hel l oWor l dSer vi ce;@Testpubl 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. 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 extEnt i t yManager em;@Testpubl 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 extEnt i t yManager em;@Testpubl 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. 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. 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 {@Testpubl 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 {@Testpubl 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 ) ;}/ / . . .}
  19. 19. twitter: @kubemThe BadDifferences betweencontainersVagueness of the EJBspecNo test with the actualserver
  20. 20. twitter: @kubemJNDI tree• {deploymentId} / {interfaceClass}• {appName} / {moduleName} / {beanName}But where it’s localted?• java: app/*• java: comp/env/*• java: global/*
  21. 21. twitter: @kubemMultiple namespubl i c i nt erf ace Servi ce{publ i c St ri nghel l o( ) ;}publ i c i nt erf ace Servi ce{publ i c St ri nghel l o( ) ;}
  22. 22. twitter: @kubemMultiple namespubl i c i nt erf ace Servi ce{publ i c St ri nghel l o( ) ;}publ i c i nt erf ace Servi ce{publ i c St ri nghel l o( ) ;} @St at el esspubl i c cl ass MyServi ce i mpl ement sServi ce {publ i c St ri ng hel l o( ) {ret urn "Hel l o worl d! ";}}@St at el esspubl i c cl ass MyServi ce i mpl ement sServi ce {publ i c St ri ng hel l o( ) {ret urn "Hel l o worl d! ";}}
  23. 23. twitter: @kubemMultiple namespubl i c i nt erf ace Servi ce{publ i c St ri nghel l o( ) ;}publ i c i nt erf ace Servi ce{publ i c St ri nghel l o( ) ;} @St at el esspubl i c cl ass MyServi ce i mpl ement sServi ce {publ i c St ri ng hel l o( ) {ret urn "Hel l o worl d! ";}}@St at el esspubl i c cl ass MyServi ce i mpl ement sServi ce {publ i c St ri ng hel l o( ) {ret urn "Hel l o worl d! ";}}@St at el esspubl i c cl ass MyOt herServi ce i mpl ement sServi ce {publ i c St ri ng hel l o( ) {ret urn "Hel l o GeeCON! ";}}@St at el esspubl i c cl ass MyOt herServi ce i mpl ement sServi ce {publ i c St ri ng hel l o( ) {ret urn "Hel l o GeeCON! ";}}
  24. 24. twitter: @kubemMultiple namespubl i c i nt erf ace Servi ce{publ i c St ri nghel l o( ) ;}publ i c i nt erf ace Servi ce{publ i c St ri nghel l o( ) ;} @St at el esspubl i c cl ass MyServi ce i mpl ement sServi ce {publ i c St ri ng hel l o( ) {ret urn "Hel l o worl d! ";}}@St at el esspubl i c cl ass MyServi ce i mpl ement sServi ce {publ i c St ri ng hel l o( ) {ret urn "Hel l o worl d! ";}}@St at el esspubl i c cl ass MyOt herServi ce i mpl ement sServi ce {publ i c St ri ng hel l o( ) {ret urn "Hel l o GeeCON! ";}}@St at el esspubl i c cl ass MyOt herServi ce i mpl ement sServi ce {publ i c St ri ng hel l o( ) {ret urn "Hel l o GeeCON! ";}}@St ar t up@Si ngl et onpubl i c cl ass Cl i ent {@EJBSer vi ce ser vi ce;@Post Const r uctpubl 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 onpubl i c cl ass Cl i ent {@EJBSer vi ce ser vi ce;@Post Const r uctpubl 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. 25. twitter: @kubemDEPLOYMENTS IN ERROR:Deployment "vfs:///opt/java/jboss-6.1.0.Final/server/default/deploy/module.jar" is in error due to thefollowing reason(s): java.lang.RuntimeException: Specified reference[EJB Reference: beanInterface pl.marchwicki.jee6.Service, beanNamenull, mappedName null, lookupName null, owning unitComponentDeploymentContext@2078856098{org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData.Client}] was matched by more than one EJB:[org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData@8b7ff749{MyService},org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData@5baed971{MyOtherService}]. Specify beanName explciitly or ensure beanInterface isunique.DEPLOYMENTS IN ERROR:Deployment "vfs:///opt/java/jboss-6.1.0.Final/server/default/deploy/module.jar" is in error due to thefollowing reason(s): java.lang.RuntimeException: Specified reference[EJB Reference: beanInterface pl.marchwicki.jee6.Service, beanNamenull, mappedName null, lookupName null, owning unitComponentDeploymentContext@2078856098{org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData.Client}] was matched by more than one EJB:[org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData@8b7ff749{MyService},org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData@5baed971{MyOtherService}]. Specify beanName explciitly or ensure beanInterface isunique.
  26. 26. twitter: @kubemINFO: Created Ejb(deployment-id=Client, ejb-name=Client, container=MySingleton Container)May 11, 013 4:23:24 PM org.apache.openejb.assembler.classic.AssemblerstartEjbsINFO: Started Ejb(deployment-id=MyService, ejb-name=MyService,container=My Stateless Container)May 11, 2013 4:23:24 PM org.apache.openejb.assembler.classic.AssemblerstartEjbsINFO: Started Ejb(deployment-id=MyOtherService,ejb-name=MyOtherService, container=My Stateless Container)Hello world!INFO: Created Ejb(deployment-id=Client, ejb-name=Client, container=MySingleton Container)May 11, 013 4:23:24 PM org.apache.openejb.assembler.classic.AssemblerstartEjbsINFO: Started Ejb(deployment-id=MyService, ejb-name=MyService,container=My Stateless Container)May 11, 2013 4:23:24 PM org.apache.openejb.assembler.classic.AssemblerstartEjbsINFO: Started Ejb(deployment-id=MyOtherService,ejb-name=MyOtherService, container=My Stateless Container)Hello world!
  27. 27. twitter: @kubemDifferent implementations@Xml Root El ementpubl 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 ementpubl 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. 28. twitter: @kubemDifferent implementations@Xml Root El ementpubl 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 ementpubl 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 {@GETpubl 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 ongi d) {ret urn st ore. get ( i d) ;}/ / . . .}@Pat h( " / t odos" )@Pr oduces( Medi aType. APPLICATION_ JSON)publ i c cl ass TodoResource {@GETpubl 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 ongi d) {ret urn st ore. get ( i d) ;}/ / . . .}
  29. 29. twitter: @kubemGET /todos/1 HTTP/1.1Host: localhostHTTP/1.1 200 OK{"id": 1,"title": "First todo","order": 1,"completed": false}GET /todos/1 HTTP/1.1Host: localhostHTTP/1.1 200 OK{"id": 1,"title": "First todo","order": 1,"completed": false}GET /todos HTTP/1.1Host: localhostHTTP/1.1 200 OK[{"id": 1,"title": "First todo","order": 1,"completed": false},{"id": 2,"title": "Second todo","order": 2,"completed": false}]GET /todos HTTP/1.1Host: localhostHTTP/1.1 200 OK[{"id": 1,"title": "First todo","order": 1,"completed": false},{"id": 2,"title": "Second todo","order": 2,"completed": false}]
  30. 30. twitter: @kubemGET /todos/1 HTTP/1.1Host: localhostHTTP/1.1 200 OK{todo: {"id": 1,"title": "First todo","order": 1,"completed": false}}GET /todos/1 HTTP/1.1Host: localhostHTTP/1.1 200 OK{todo: {"id": 1,"title": "First todo","order": 1,"completed": false}}GET /todos HTTP/1.1Host: localhostHTTP/1.1 200 OK{todo: [{"id": 1,"title": "First todo","order": 1,"completed": false},{"id": 2,"title": "Second todo","order": 2,"completed": false}]}GET /todos HTTP/1.1Host: localhostHTTP/1.1 200 OK{todo: [{"id": 1,"title": "First todo","order": 1,"completed": false},{"id": 2,"title": "Second todo","order": 2,"completed": false}]}
  31. 31. twitter: @kubemGET /todos/1 HTTP/1.1Host: localhostHTTP/1.1 200 OK{todo: {"id": 1,"title": "First todo","order": 1,"completed": false}}GET /todos/1 HTTP/1.1Host: localhostHTTP/1.1 200 OK{todo: {"id": 1,"title": "First todo","order": 1,"completed": false}}GET /todos HTTP/1.1Host: localhostHTTP/1.1 200 OK{todo: [{"id": 1,"title": "First todo","order": 1,"completed": false},{"id": 2,"title": "Second todo","order": 2,"completed": false}]}GET /todos HTTP/1.1Host: localhostHTTP/1.1 200 OK{todo: [{"id": 1,"title": "First todo","order": 1,"completed": false},{"id": 2,"title": "Second todo","order": 2,"completed": false}]}
  32. 32. twitter: @kubemThe UglyLoads of boilerplate codeTests only EJBsNever deployed
  33. 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 extEnt i t yManager em;@Testpubl 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 extEnt i t yManager em;@Testpubl 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. 34. twitter: @kubem@RunWi t h( Appl i cat i onComposer . cl ass)publ i c cl ass Audi t MessageRecei verTest {@Modul epubl i c Ej bJar modul e( ) {f i nal Ej bJar ej bJar = new Ej bJar( ) ;ej bJar . addEnt er pr i seBean( newSt at el essBean( Audi t MessageProcessi ng. cl ass) ) ;ej bJar . addEnt er pr i seBean( newSt at el essBean( Audi t LoggerServi ce. cl ass) ) ;ej bJar . addEnt er pr i seBean( newMessageDri 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 epubl i c Ej bJar modul e( ) {f i nal Ej bJar ej bJar = new Ej bJar( ) ;ej bJar . addEnt er pr i seBean( newSt at el essBean( Audi t MessageProcessi ng. cl ass) ) ;ej bJar . addEnt er pr i seBean( newSt at el essBean( Audi t LoggerServi ce. cl ass) ) ;ej bJar . addEnt er pr i seBean( newMessageDri venBean( Audi t i ngMessageLi st erner. cl ass) ) ;ret urn ej bJar;}//. .
  35. 35. twitter: @kubem@RunWi t h( Appl i cat i onComposer . cl ass)publ i c cl ass Audi t MessageRecei verTest {//. .@Modul epubl 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 epubl 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. 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 onpubl 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 onpubl 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. 37. twitter: @kubemTest only EJBIt’s not a real application serverWebservices: Apache CXFJMS: Apache MQJPA: OpenJPAHibernate(any provider)
  38. 38. Where we are now?
  39. 39. twitter: @kubemThe aliens have landed• Arquillian is a testing framework• There are runners…• Containers…• & Enrichers
  40. 40. twitter: @kubemThe aliens have landed• Arquillian is a testing framework• There are runners…– JUnit– TestNG• Containers…• & Enrichers
  41. 41. twitter: @kubemThe aliens have landed• Arquillian is a testing framework• There are runners…• Containers…– Weld– Tomcat– JBoss– Glassfish• & Enrichers
  42. 42. twitter: @kubemThe aliens have landed• Arquillian is a testing framework• There are runners…• Containers…• & Enrichers– glue layer betweenyour code andthe container:inject, track results
  43. 43. twitter: @kubemA natural evolution
  44. 44. twitter: @kubemThe are three modes• Embedded– You run your app server together with your code, in asingle JVM• Managed– Arquillian starts and stops your nodes, together with anapp, in separate JVMs• Remote– Everything is remotly deployed
  45. 45. twitter: @kubemAnd four ways forcommunicating results• Local– Same JVM, local bindings• Servlet 2.5– Pre JEE-6 containers• Servlet 3.0– Leveraging async servlets• JMX– Jboss AS 7 way
  46. 46. How it works in practice
  47. 47. twitter: @kubemWhy we do it?• Real test with real services (no mocksmovement)• With real environment• Short feedback cycle
  48. 48. twitter: @kubemWhat’s next• Persitence Extension (DBUnit)• GWT Extension• JSFUnit• BPEL testing• Performance• … ?
  49. 49. twitter: @kubemCall for armsArquillian Test Porting Initiative
  50. 50. twitter: @kubemhttps://issues.apache.org/jira/browse/TOMEE-746http://tomee.apache.org/dev/arquillian-test-porting-initiative.html
  51. 51. twitter: @kubemProjects to tackle• Active MQ• Apache CXF• TomEE & OpenEJB• MyFaces• OpenWenBeans• BVal
  52. 52. Lemme show you
  53. 53. twitter: @kubemYou can innovate onnonfunctional areas, such asdevops, logging, metrics, etc, ifyour core business needs to bemore conservative.
  54. 54. twitter: @kubemInnovation comes not just fromusing new technologies, but alsofrom using new techniques withold boring technologies
  55. 55. twitter: @kubemQuestions

×