Testing Polyglot Persistence Done Right

4,569 views

Published on

Data storage is one of the most crucial parts of any applications, and we use many different tools and tricks to keep it in a good shape. We frequently use both old school relational systems with new approaches commonly known as NoSQL. We write sophisticated queries and use optimization techniques to give our end users the greatest possible experience.

So why is persistence very often skipped in the testing efforts? Is it really that complex and painful to setup? During this talk we will have a closer look at Arquillian Persistence Extension together with NoSQLUnit. These tools remove that burden and boilerplate to make you a happy and productive programmer again! Join this session and see for yourself that writing tests for your data storage logic is as easy as writing normal unit tests!

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,569
On SlideShare
0
From Embeds
0
Number of Embeds
3,369
Actions
Shares
0
Downloads
18
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Testing Polyglot Persistence Done Right

  1. 1. Testing Polyglot Persistence Done Right Alex Soto @alexsotob Bartosz Majsak @majson
  2. 2. ● Open source advocate ● lordofthejars.com curator ● Father [alex@geecon ~]$ whoami @alexsotob lordofthejars
  3. 3. ● Java Developer by day ● Open source junkie by night ● Conference speaker by passion [bartek@geecon ~]$ whoami @majson bartoszmajsak
  4. 4. FIRST things first
  5. 5. Fast Run more often Isolated Can be executed in any order Repeatable Always return the same result Self-Validating Know exactly their purpose Timely Run before code
  6. 6. Frequently omittedrules in Persistencetests
  7. 7. FAST Fast
  8. 8. FAST Network access Long bootstrap Humongous amount of data
  9. 9. FASTHSQLDB MongoDB (fongo) Neo4J Cassandra Infinispan HBase
  10. 10. Isolation
  11. 11. ISOLATION BeerRepository beerRepository; @Test public void should_persist_beer() { beerRepository.save(new Beer(“Mocny Full”)); } @Test public void should_count_beers() { int beers = beerRepository.count(); assertThat(beers).isEqualTo(??); } }
  12. 12. ISOLATION DBUnit Unitils NoSQLUnit Arquillian Persistence Extension
  13. 13. Plain Old SQL World
  14. 14. Text TITLE
  15. 15. Text TITLE
  16. 16. FIRST ATTEMPT
  17. 17. FIRST ATTEMPT
  18. 18. FIRST ATTEMPT
  19. 19. FIRST ATTEMPT
  20. 20. <dataset> <brewery id="1" name="Brew Dog" country="Scotland" /> <beer id="1" name="End of History" price="756" alcohol="55.0" brewery_id="1" /> </dataset> We can do better
  21. 21. And even better
  22. 22. Hipster’s world of NoSQL
  23. 23. nding Topic Why NoSQL?
  24. 24. Why NoSQL? Clustering from scratch “Schemaless” Polyglot More Natural for Developer
  25. 25. Manage Lifecycle Maintain Database State Polyglot Persistence Spring Data Support
  26. 26. Text Not a single point of access
  27. 27. Supported EnginesMongoDB CouchDB asticsearch Neo4j Redis Infinispan HBase Cassandra
  28. 28. Text Starting/Stopping Databases
  29. 29. Manging MongoDB Lifecycle
  30. 30. Text Seeding Database with the Known Data
  31. 31. Seeding Database with Known Data
  32. 32. Demo Time
  33. 33. Arquillian
  34. 34. TITLE Integration
  35. 35. TITLE Containers
  36. 36. Text TITLE Deployments
  37. 37. TITLE
  38. 38. TITLE
  39. 39. TITLE
  40. 40. TITLE
  41. 41. TITLE
  42. 42. TITLE
  43. 43. @RunWith(Arquillian.class) public class FluidOunceConverterTestCase { @Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class, "test.jar") .addClasses(FluidOunceConverter.class, FluidOunceConverterBean.class); } @Inject FluidOunceConverter converter; @Test public void should_convert_fluid_ounces_to_millilitres() { // given double ouncesToConvert = 8d; double expectedMillilitres = 236.588237d; // when double ouncesInMl = converter.convertToMillilitres(ouncesToConvert); // then assertThat(ouncesInMl).isEqualTo(expectedMillilitres); } }
  44. 44. Demo Time
  45. 45. ● @UsingDataSet / @ShouldMatchDataSet ● @Cleanup / @CleanupUsingScript ● @ApplyScriptBefore / After ● @CreateSchema ● JPA 2nd level cache eviction
  46. 46. Demo Time
  47. 47. ● Standalone mode ● Scriptable data sets ● Full NoSQLUnit integration ● Schema validation FUTURE

×