Applied MyEclipse and JUnit to do Hibernate Code Gen and Testing Albert Guo [email_address]
Agenda <ul><li>High Level Picture </li></ul><ul><li>Hibernate Code Generation </li></ul><ul><ul><ul><li>Code Gen Process <...
High Level Picture Application Context DAO Classes ApplicationContext.xml Hibernate Mapping files Client Layer Business La...
Code Gen Process including POJOs, DAOs,  hibernate mapping files and  Spring configuration file
Filled in connection info. Add  MS SQL driver Save password, then you do not need to type in again
Click Test Driver to test database connection If you connect to database successfully,  then you can see this popup window
Generate DAO for the four tables
Select tables which we would like to  do code gen. Click Hibernate Reverse  Engineering
Assign destination Generate hibernate mapping file Generate POJO Generate Spring DAO
Select ID Generator
Artifacts We had generated POJOs,  hibernate mapping files, and  DAOs
Spring Configuration File Inject webSiteDataSource into  sessionFactory
Spring Configuration File – cont. Inject sessionFactory into each DAOs.
Sequence Diagram
Apply Junit to do DAOs Test
JUnit Framework
How to Test with JUnit? WipPortingDAO junit TestCase exercise 1..* TestRunner run 1..* WipPortingDAOTest test 1 test 2 …
Simplified Workflow of Applying JUnit Class files Test Cases Test Methods Test Suites Test Runner
Testing Process Overrides   setUp()   and/or  tearDown() Writes test methods, ex. test…() Uses  Assert.assert … () Writes ...
Create Fixture via MyEclipse
Create Fixture via MyEclipse – cont.
Create Fixture via MyEclipse – cont.
Create Fixture via MyEclipse – cont.
Exercise & Verify
Exercise & Verify – cont.
Suit Management
Suit Management
Generate Unit Test Result via Ant
Generate Unit Test Result via Ant
Upcoming SlideShare
Loading in …5
×

Applied MyEclipse and JUnit to do Hibernate Code Gen and Testing

3,638 views
3,401 views

Published on

Published in: Technology
1 Comment
2 Likes
Statistics
Notes
No Downloads
Views
Total views
3,638
On SlideShare
0
From Embeds
0
Number of Embeds
35
Actions
Shares
0
Downloads
115
Comments
1
Likes
2
Embeds 0
No embeds

No notes for slide

Applied MyEclipse and JUnit to do Hibernate Code Gen and Testing

  1. 1. Applied MyEclipse and JUnit to do Hibernate Code Gen and Testing Albert Guo [email_address]
  2. 2. Agenda <ul><li>High Level Picture </li></ul><ul><li>Hibernate Code Generation </li></ul><ul><ul><ul><li>Code Gen Process </li></ul></ul></ul><ul><ul><ul><li>Generate DAO for the four tables </li></ul></ul></ul><ul><ul><ul><li>Artifacts </li></ul></ul></ul><ul><ul><ul><li>Spring Configuration File </li></ul></ul></ul><ul><ul><ul><li>Sequence Diagram </li></ul></ul></ul><ul><li>Apply JUnit to do DAOs Test </li></ul><ul><ul><ul><li>JUnit Framework </li></ul></ul></ul><ul><ul><ul><li>How to Test with JUnit? </li></ul></ul></ul><ul><ul><ul><li>Simplified Workflow of Applying JUnit </li></ul></ul></ul><ul><ul><ul><li>Testing Process </li></ul></ul></ul><ul><ul><ul><li>Generate Unit Test Result via Ant </li></ul></ul></ul>
  3. 3. High Level Picture Application Context DAO Classes ApplicationContext.xml Hibernate Mapping files Client Layer Business Layer Persistence Layer Spring – IOC Container Hibernate Session Mgt. Business Service Classes Hibernate Windchill Workflow Data Source / Connection Pool
  4. 4. Code Gen Process including POJOs, DAOs, hibernate mapping files and Spring configuration file
  5. 5. Filled in connection info. Add MS SQL driver Save password, then you do not need to type in again
  6. 6. Click Test Driver to test database connection If you connect to database successfully, then you can see this popup window
  7. 7. Generate DAO for the four tables
  8. 8. Select tables which we would like to do code gen. Click Hibernate Reverse Engineering
  9. 9. Assign destination Generate hibernate mapping file Generate POJO Generate Spring DAO
  10. 10. Select ID Generator
  11. 11.
  12. 12. Artifacts We had generated POJOs, hibernate mapping files, and DAOs
  13. 13. Spring Configuration File Inject webSiteDataSource into sessionFactory
  14. 14. Spring Configuration File – cont. Inject sessionFactory into each DAOs.
  15. 15. Sequence Diagram
  16. 16. Apply Junit to do DAOs Test
  17. 17. JUnit Framework
  18. 18. How to Test with JUnit? WipPortingDAO junit TestCase exercise 1..* TestRunner run 1..* WipPortingDAOTest test 1 test 2 …
  19. 19. Simplified Workflow of Applying JUnit Class files Test Cases Test Methods Test Suites Test Runner
  20. 20. Testing Process Overrides setUp() and/or tearDown() Writes test methods, ex. test…() Uses Assert.assert … () Writes suite() and/or main()
  21. 21. Create Fixture via MyEclipse
  22. 22. Create Fixture via MyEclipse – cont.
  23. 23. Create Fixture via MyEclipse – cont.
  24. 24. Create Fixture via MyEclipse – cont.
  25. 25. Exercise & Verify
  26. 26. Exercise & Verify – cont.
  27. 27. Suit Management
  28. 28. Suit Management
  29. 29. Generate Unit Test Result via Ant
  30. 30. Generate Unit Test Result via Ant

×