Index: readme.txt =================================================================== RCS file: /cvs/glassfish/entity-persistence-tests/readme.txt,v retrieving revision 1.7 diff -c -w -r1.7 readme.txt *** readme.txt 27 Oct 2006 20:49:16 -0000 1.7 --- readme.txt 18 Dec 2006 11:15:20 -0000 *************** *** 1,33 **** How to run entity-persistence tests ----------------------------------- ! The entity-persistence tests are currently configured to build with maven, and to run with ant. 1. Ensure the entity-persistence module has successfully built ! 2. To clean the view run "maven clean" ! 3. Edit the build.properties file. Change the following entries: jdbc.driver.jar - point this to your jdbc driver db.driver - the name of the driver class db.url - the url to your database db.user - your database username db.pwd - your database password ! Adding these same settings to a build.properties in your user's home directory will also work. ! 4. To build the testing run "maven build". Note: The maven "build" target depends on the changes to the build.properties files to populate the persistence.xml files used for the testing persistence units. ! ! 5. Prepare to run ant by configuring your classpath to include a junit jar file. An appropriate junit.jar can be found in ../appserv-tests/lib. The ant tests make use of a junit task and ant requires that junit be on the classpath for this task to run. ! ! 6. Run "ant test" ! ! Note: As of February 21, 2006, the persistence.xml files stored in the config directories are no longer changed by the build script. Instead, changes occur in a temporary directory prior the building the testing jar files. As a result, users that check out the config directories after Februrary 21, 2006, should not have to worry about accidentally changing the persistence.xml files used in testing. Drop all tables of database ---------------------------- ! If you want to drop *all* tables from your database to run the test on a clean database, you can use the following ant target. Note, that all tables for your user will be dropped, not only those used by these tests. $ ant clean-db --- 1,41 ---- How to run entity-persistence tests ----------------------------------- ! The entity-persistence tests are currently configured to build with maven or ant, and to run with ant. 1. Ensure the entity-persistence module has successfully built ! 2. To clean the view run "maven clean" or "ant clean" ! 3. Edit the test.properties file for the target database. Default setting is to run on JavaDB(Derby). ! Or make another properties file and give it with -Dtest.properties option(see below). + Change the following entries: jdbc.driver.jar - point this to your jdbc driver db.driver - the name of the driver class db.url - the url to your database db.user - your database username db.pwd - your database password ! 4. To build the testing run "maven build" or "ant build". ! 5. Prepare to run ant by configuring your classpath to include a junit jar file. ! An appropriate junit.jar can be found in ../appserv-tests/lib. The ant tests make use of ! a junit task and ant requires that junit be on the classpath for this task to run. ! ! 6. Run "ant test". ! This will use test.properties file and run all tests. ! You can override this behaviour by using following options. ! ! Possible options: ! -Dtest.class=test_class_name If you want to run a single test class. ! -Dtest.properties=file_name If you want to run tests with another properties file Drop all tables of database ---------------------------- ! If you want to drop *all* tables from your database to run the test on a clean database, ! you can use the following ant target. ! Note, that all tables for your user will be dropped, not only those used by these tests. $ ant clean-db Index: build.xml =================================================================== RCS file: /cvs/glassfish/entity-persistence-tests/build.xml,v retrieving revision 1.13 diff -c -w -r1.13 build.xml *** build.xml 30 Nov 2006 09:10:54 -0000 1.13 --- build.xml 18 Dec 2006 11:15:20 -0000 *************** *** 8,13 **** --- 8,21 ---- + + + + + + + + *************** *** 50,63 **** - - - - - - - - ! ! --- 208,220 ---- ! ! ! Index: build.properties =================================================================== RCS file: /cvs/glassfish/entity-persistence-tests/build.properties,v retrieving revision 1.8 diff -c -w -r1.8 build.properties *** build.properties 7 Oct 2006 04:48:25 -0000 1.8 --- build.properties 18 Dec 2006 11:15:20 -0000 *************** *** 3,15 **** # SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. # - jdbc.driver.jar=C:/java/jdbc/1classes12_10.jar - db.driver=oracle.jdbc.driver.1OracleDriver - db.url=jdbc:oracle:thin:@loc1alhost:1521:orcl - db.user=sc1ott - db.pwd=tig1er - - db.type=true result.file=testresults junit.location=../appserv-tests/lib/junit.jar --- 3,8 ---- Index: test.properties =================================================================== RCS file: test.properties diff -N test.properties *** /dev/null 1 Jan 1970 00:00:00 -0000 --- test.properties 18 Dec 2006 11:15:20 -0000 *************** *** 0 **** --- 1,11 ---- + # Testing environment properties + # Set your target database properties here or give it by -Dtest.properties=file option + + jdbc.driver.jar=${glassfish.home}/javadb/lib/derbyclient.jar + db.driver=org.apache.derby.jdbc.ClientDriver + db.url=jdbc:derby://localhost:1527/entity-persistence-tests;create=true + db.user=app + db.pwd=app + + # Logging option for debugging + #toplink.logging.level=FINEST Index: src/java/oracle/toplink/essentials/testing/framework/junit/JUnitTestCase.java =================================================================== RCS file: /cvs/glassfish/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/framework/junit/JUnitTestCase.java,v retrieving revision 1.21 diff -c -w -r1.21 JUnitTestCase.java *** src/java/oracle/toplink/essentials/testing/framework/junit/JUnitTestCase.java 27 Oct 2006 20:49:17 -0000 1.21 --- src/java/oracle/toplink/essentials/testing/framework/junit/JUnitTestCase.java 18 Dec 2006 11:15:21 -0000 *************** *** 28,33 **** --- 28,36 ---- import java.util.Hashtable; import java.util.Properties; import java.net.URL; + import java.net.MalformedURLException; + import java.io.File; + import junit.framework.*; import javax.persistence.*; *************** *** 50,55 **** --- 53,60 ---- * login.driverClass */ public abstract class JUnitTestCase extends TestCase { + public static final String TEST_PROPERTIES_FILE_KEY = "test.properties"; + public static final String TEST_PROPERTIES_FILE_DEFAULT = "test.properties"; public static Map propertiesMap = null; public static Map persistencePropertiesTestMap = new HashMap(); *************** *** 107,130 **** return getEntityManagerFactory(persistenceUnitName, properties).createEntityManager(); } public static Map getDatabaseProperties(){ if (propertiesMap == null){ Properties properties = new Properties(); ! URL url = Thread.currentThread().getContextClassLoader().getResource("titl.properties"); propertiesMap = new HashMap(); if (url != null){ try{ properties.load(url.openStream()); } catch (java.io.IOException exception){ ! throw new RuntimeException("Error loading titl.properties.", exception); } - propertiesMap.put("toplink.jdbc.driver", properties.get("login.driverClass")); - propertiesMap.put("toplink.jdbc.url", properties.get("login.databaseURL")); - propertiesMap.put("toplink.jdbc.user", properties.get("login.username")); - propertiesMap.put("toplink.jdbc.password", properties.get("login.password")); - // let's use platform Auto detection - // propertiesMap.put("toplink.target-database", properties.get("login.databaseplatform")); - propertiesMap.put("toplink.logging.level", properties.get("toplink.log.level.on.server")); } propertiesMap.putAll(persistencePropertiesTestMap); } --- 112,164 ---- return getEntityManagerFactory(persistenceUnitName, properties).createEntityManager(); } + /** + * Read common properties (including database properties) from test.properties file. + * The location of properties file can be given by system property test.properties. + * The default location is "test.properties" file in current directory. + */ public static Map getDatabaseProperties(){ if (propertiesMap == null){ Properties properties = new Properties(); ! File testPropertiesFile ! = new File(System.getProperty(TEST_PROPERTIES_FILE_KEY, TEST_PROPERTIES_FILE_DEFAULT)); ! ! URL url = null; ! if (testPropertiesFile.exists()) { ! try { ! url = testPropertiesFile.toURL(); ! } catch (MalformedURLException exception) { ! throw new RuntimeException("Error loading " + testPropertiesFile.getName() + ".", exception); ! } ! } propertiesMap = new HashMap(); if (url != null){ try{ properties.load(url.openStream()); } catch (java.io.IOException exception){ ! throw new RuntimeException("Error loading " + testPropertiesFile.getName() + ".", exception); ! } ! String dbDriver = (String) properties.get("db.driver"); ! String dbUrl = (String) properties.get("db.url"); ! String dbUser = (String) properties.get("db.user"); ! String dbPwd = (String) properties.get("db.pwd"); ! String logLevel = (String) properties.get("toplink.logging.level"); ! ! if(dbDriver != null) { ! propertiesMap.put("toplink.jdbc.driver", dbDriver); ! } ! if(dbUrl != null) { ! propertiesMap.put("toplink.jdbc.url", dbUrl); ! } ! if(dbUser != null) { ! propertiesMap.put("toplink.jdbc.user", dbUser); ! } ! if(dbPwd != null) { ! propertiesMap.put("toplink.jdbc.password", dbPwd); ! } ! if(logLevel != null) { ! propertiesMap.put("toplink.logging.level", logLevel); } } propertiesMap.putAll(persistencePropertiesTestMap); } Index: config/META-INF/persistence.xml =================================================================== RCS file: /cvs/glassfish/entity-persistence-tests/config/META-INF/persistence.xml,v retrieving revision 1.28 diff -c -w -r1.28 persistence.xml *** config/META-INF/persistence.xml 6 Dec 2006 17:00:43 -0000 1.28 --- config/META-INF/persistence.xml 18 Dec 2006 11:15:32 -0000 *************** *** 32,42 **** false - - - - --- 32,39 ---- false + *************** *** 62,71 **** oracle.toplink.essentials.PersistenceProvider false - - - - --- 59,64 ---- *************** *** 81,90 **** true - - - - --- 74,79 ---- Index: config/ddl-generation-testmodel/META-INF/persistence.xml =================================================================== RCS file: /cvs/glassfish/entity-persistence-tests/config/ddl-generation-testmodel/META-INF/persistence.xml,v retrieving revision 1.6 diff -c -w -r1.6 persistence.xml *** config/ddl-generation-testmodel/META-INF/persistence.xml 30 Nov 2006 09:10:54 -0000 1.6 --- config/ddl-generation-testmodel/META-INF/persistence.xml 18 Dec 2006 11:15:32 -0000 *************** *** 14,24 **** META-INF/ddl-generation-model.xml oracle.toplink.essentials.testing.models.cmp3.xml.merge.inherited.EmbeddedSerialNumber - - - - --- 14,21 ---- META-INF/ddl-generation-model.xml oracle.toplink.essentials.testing.models.cmp3.xml.merge.inherited.EmbeddedSerialNumber + Index: config/validation-failed-testmodel/META-INF/persistence.xml =================================================================== RCS file: /cvs/glassfish/entity-persistence-tests/config/validation-failed-testmodel/META-INF/persistence.xml,v retrieving revision 1.6 diff -c -w -r1.6 persistence.xml *** config/validation-failed-testmodel/META-INF/persistence.xml 27 Oct 2006 20:49:16 -0000 1.6 --- config/validation-failed-testmodel/META-INF/persistence.xml 18 Dec 2006 11:15:32 -0000 *************** *** 3,12 **** oracle.toplink.essentials.PersistenceProvider false ! ! ! ! --- 3,9 ---- oracle.toplink.essentials.PersistenceProvider false !