TS 73 PersistenceUnit

Persistence Unit Test Specification

Author: Radim Roska, Jan Horvath, Vladimir Riha, Jiri Skrivanek
Version: NetBeans 7.3
Last update: 11-th November 2012
Bugzilla: javaee/Persistence
Introduction: This test specification is focused on testing Persistence Unit creation and modification.

Contents


Test suite: Persistence Unit

  1. Create Persistence Unit
    1. Create new java project.
    2. Open new file wizard and select Persistence|Persistence Unit.
    3. Click Next.
    4. Verify "EclipseLink (JPA 2.0)" is default persistence library.
    5. Select sample database connection from the second combo box.
    6. Click Finish and check that persistence.xml is created in META-INF folder and it is opened in Design view.
  2. Modify Persistence Unit
    1. In section General change Persistence Unit Name.
    2. Change Table Generation Strategy.
    3. Change Validation Strategy.
    4. Change Shared Cache Mode.
    5. Open new file wizard.
    6. Select Persistence|Entity Class and click Next.
    7. Click Finish and close NewEntity class.
    8. Verify that javaapplication1.NewEntity class was added into Include Entity Classes in persistence unit.
    9. Expand Properties section and add some property with value from available options.
    10. Save file (Ctrl+S) and switch to Source view.
    11. Verify that all changed values are available in xml notation.
    12. Remove <class>, <shared-cache-mode>, <validation-mode> elements and added property.
    13. Save file (Ctrl+S) and switch to Design view.
    14. Check that removal is reflected in both General and Properties section.
    15. Click 'Add button at the top-right corner.
    16. Select again sample database connection in New Persistence Unit dialog and click OK.
    17. Click Add Class... in newly added persistence unit.
    18. Select javaapplication1.NewEntity and click OK.
    19. Save file (Ctrl+S), switch to Source view and check that new <persistence-unit> element is added to xml file.
    20. Switch back to Design view and click Remove to remove the second persistence unit.
    21. Click OK to confirm and verify that removal was successful.
  3. Code Completion in Persistence Unit
    1. Switch to Source view of persistence.xml.
    2. Place cursor next to <provider> and invoke code completion (Ctrl+Space).
    3. Two providers - eclipse and hibernate should be available.
    4. Place cursor next to <jta-data-source> (only applicable to web project) and invoke code completion.
    5. You should see list of available data sources.
    6. Insert new line and invoke code completion.
    7. Select <> class to include <class> into editor.
    8. Invoke code completion again and choose javaapplication1.NewEntity.
    9. Invoke code completion again and choose </class>.
    10. Place cursor at value attribute of javax.persistence.jdbc.url.
    11. invoke code completion and verify that existing sample connection and Add new connection is offered.File:Pucompletionjdbcconnection.png
    12. Click Add new connection and then close New Connection Wizard window.
    13. Place cursor at value attribute of eclipselink.ddl-generation.
    14. invoke code completion and check that specific values - create-tables, drop-and-create-tables, none - are provided.
    15. Insert new line in <properties> element and invoke code completion.
    16. It should insert empty property element.
    17. Place cursor at name attribute and invoke code completion.
    18. It offers eclipselink properties.
    19. Remove added property element and save file.
  4. Persistence Unit in Web Application
    1. Create web project with GlassFish server.
    2. Repeat all test cases in this project.
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo