You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2005/07/30 07:13:51 UTC

svn commit: r226474 - in /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/ suites/ tests/lang/

Author: djd
Date: Fri Jul 29 22:13:45 2005
New Revision: 226474

URL: http://svn.apache.org/viewcvs?rev=226474&view=rev
Log:
Add a test for database class loading (lang/dcl.sql)

Added:
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dcl.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl.sql   (with props)
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_app.properties   (with props)
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_emc1.jar   (with props)
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_emc2.jar   (with props)
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_emcaddon.jar   (with props)
Modified:
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dcl.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dcl.out?rev=226474&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dcl.out (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dcl.out Fri Jul 29 22:13:45 2005
@@ -0,0 +1,131 @@
+ij> -- test database class loading.
+create schema emc;
+0 rows inserted/updated/deleted
+ij> set schema emc;
+0 rows inserted/updated/deleted
+ij> create table contacts (id int primary key, e_mail varchar(30));
+0 rows inserted/updated/deleted
+ij> create procedure EMC.ADDCONTACT(id INT, e_mail VARCHAR(30))
+MODIFIES SQL DATA
+external name 'org.apache.derbyTesting.databaseclassloader.emc.addContact'
+language java parameter style java;
+0 rows inserted/updated/deleted
+ij> -- fails because no class in classpath, 
+CALL EMC.ADDCONTACT(1, 'bill@somecompany.com');
+ERROR 42X51: The class 'org.apache.derbyTesting.databaseclassloader.emc' does not exist or is inaccessible. This can happen if the class is not public.
+ERROR XJ001: Java exception: 'org.apache.derbyTesting.databaseclassloader.emc: java.lang.ClassNotFoundException'.
+ij> -- install the jar, copied there by the magic of supportfiles
+-- in the test harness (dcl_app.properties). The source for
+-- the class is contained within the jar for reference.
+CALL SQLJ.INSTALL_JAR('file:dcl_emc1.jar', 'EMC.MAIL_APP', 0);
+0 rows inserted/updated/deleted
+ij> -- fails because no class not in classpath, jar file not in database classpath.
+CALL EMC.ADDCONTACT(1, 'bill@somecompany.com');
+ERROR 42X51: The class 'org.apache.derbyTesting.databaseclassloader.emc' does not exist or is inaccessible. This can happen if the class is not public.
+ERROR XJ001: Java exception: 'org.apache.derbyTesting.databaseclassloader.emc: java.lang.ClassNotFoundException'.
+ij> -- now add this into the database class path
+call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', 'EMC.MAIL_APP');
+0 rows inserted/updated/deleted
+ij> -- all should work now
+CALL EMC.ADDCONTACT(1, 'bill@ruletheworld.com');
+0 rows inserted/updated/deleted
+ij> CALL EMC.ADDCONTACT(2, 'penguin@antartic.com');
+0 rows inserted/updated/deleted
+ij> SELECT id, e_mail from EMC.CONTACTS;
+ID         |E_MAIL                        
+------------------------------------------
+1          |bill@ruletheworld.com         
+2          |penguin@antartic.com          
+ij> -- now the application needs to track if e-mails are valid
+ALTER TABLE EMC.CONTACTS ADD COLUMN OK SMALLINT;
+0 rows inserted/updated/deleted
+ij> SELECT id, e_mail, ok from EMC.CONTACTS;
+ID         |E_MAIL                        |OK    
+-------------------------------------------------
+1          |bill@ruletheworld.com         |NULL  
+2          |penguin@antartic.com          |NULL  
+ij> -- well written application, INSERT used explicit column names
+-- ok defaults to NULL
+CALL EMC.ADDCONTACT(3, 'big@blue.com');
+0 rows inserted/updated/deleted
+ij> SELECT id, e_mail, ok from EMC.CONTACTS;
+ID         |E_MAIL                        |OK    
+-------------------------------------------------
+1          |bill@ruletheworld.com         |NULL  
+2          |penguin@antartic.com          |NULL  
+3          |big@blue.com                  |NULL  
+ij> -- now change the application to run checks on the e-mail
+-- address to ensure it is valid (in this case by seeing if
+-- simply includes 'spam' in the title.
+CALL SQLJ.REPLACE_JAR('file:dcl_emc2.jar', 'EMC.MAIL_APP');
+0 rows inserted/updated/deleted
+ij> CALL EMC.ADDCONTACT(4, 'spammer@ripoff.com');
+0 rows inserted/updated/deleted
+ij> CALL EMC.ADDCONTACT(5, 'open@source.org');
+0 rows inserted/updated/deleted
+ij> SELECT id, e_mail, ok from EMC.CONTACTS;
+ID         |E_MAIL                        |OK    
+-------------------------------------------------
+1          |bill@ruletheworld.com         |NULL  
+2          |penguin@antartic.com          |NULL  
+3          |big@blue.com                  |NULL  
+4          |spammer@ripoff.com            |0     
+5          |open@source.org               |1     
+ij> -- now add another jar in to test two jars and
+-- a quoted identifer for the jar names.
+create schema "emcAddOn";
+0 rows inserted/updated/deleted
+ij> set schema emcAddOn;
+ERROR 42Y07: Schema 'EMCADDON' does not exist
+ij> set schema "emcAddOn";
+0 rows inserted/updated/deleted
+ij> create function "emcAddOn".VALIDCONTACT(e_mail VARCHAR(30))
+RETURNS SMALLINT
+READS SQL DATA
+external name 'org.apache.derbyTesting.databaseclassloader.addon.vendor.util.valid'
+language java parameter style java;
+0 rows inserted/updated/deleted
+ij> CALL SQLJ.INSTALL_JAR('file:dcl_emcaddon.jar', '"emcAddOn"."MailAddOn"', 0);
+0 rows inserted/updated/deleted
+ij> call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', 'EMC.MAIL_APP:"emcAddOn"."MailAddOn"');
+0 rows inserted/updated/deleted
+ij> select e_mail, "emcAddOn".VALIDCONTACT(e_mail) from EMC.CONTACTS;
+E_MAIL                        |2     
+-------------------------------------
+bill@ruletheworld.com         |0     
+penguin@antartic.com          |0     
+big@blue.com                  |0     
+spammer@ripoff.com            |0     
+open@source.org               |1     
+ij> -- cleanup
+CALL SQLJ.REMOVE_JAR('EMC.MAIL_APP', 0);
+ERROR X0X07: Cannot drop jar file '"EMC"."MAIL_APP"' because its on your db2j.database.classpath '"EMC"."MAIL_APP"'.
+ij> call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', '"emcAddOn"."MailAddOn"');
+0 rows inserted/updated/deleted
+ij> CALL EMC.ADDCONTACT(99, 'cash@venture.com');
+ERROR 42X51: The class 'org.apache.derbyTesting.databaseclassloader.emc' does not exist or is inaccessible. This can happen if the class is not public.
+ERROR XJ001: Java exception: 'org.apache.derbyTesting.databaseclassloader.emc: java.lang.ClassNotFoundException'.
+ij> CALL SQLJ.REMOVE_JAR('EMC.MAIL_APP', 0);
+0 rows inserted/updated/deleted
+ij> DROP PROCEDURE EMC.ADDCONTACT;
+0 rows inserted/updated/deleted
+ij> select e_mail, "emcAddOn".VALIDCONTACT(e_mail) from EMC.CONTACTS;
+E_MAIL                        |2     
+-------------------------------------
+bill@ruletheworld.com         |0     
+penguin@antartic.com          |0     
+big@blue.com                  |0     
+spammer@ripoff.com            |0     
+open@source.org               |1     
+ij> call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', '');
+0 rows inserted/updated/deleted
+ij> select e_mail, "emcAddOn".VALIDCONTACT(e_mail) from EMC.CONTACTS;
+ERROR 42X51: The class 'org.apache.derbyTesting.databaseclassloader.addon.vendor.util' does not exist or is inaccessible. This can happen if the class is not public.
+ERROR XJ001: Java exception: 'org.apache.derbyTesting.databaseclassloader.addon.vendor.util: java.lang.ClassNotFoundException'.
+ij> CALL SQLJ.REMOVE_JAR('"emcAddOn"."MailAddOn"', 0);
+0 rows inserted/updated/deleted
+ij> DROP FUNCTION "emcAddOn".VALIDCONTACT;
+0 rows inserted/updated/deleted
+ij> DROP TABLE EMC.CONTACTS;
+0 rows inserted/updated/deleted
+ij> 

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall?rev=226474&r1=226473&r2=226474&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall Fri Jul 29 22:13:45 2005
@@ -39,6 +39,7 @@
 lang/datetime.sql
 lang/db2Compatibility.sql
 lang/dbManagerLimits.java
+lang/dcl.sql
 lang/ddlTableLockMode.sql
 lang/deadlockMode.java
 lang/declareGlobalTempTableJava.java

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant?rev=226474&r1=226473&r2=226474&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant Fri Jul 29 22:13:45 2005
@@ -49,6 +49,11 @@
 datetime.sql
 db2Compatibility.sql
 dbManagerLimits_app.properties
+dcl.sql
+dcl_app.properties
+dcl_emc1.jar
+dcl_emc2.jar
+dcl_emcaddon.jar
 ddlTableLockMode.sql
 ddlTableLockMode_app.properties
 deadlockMode_derby.properties

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl.sql
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl.sql?rev=226474&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl.sql (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl.sql Fri Jul 29 22:13:45 2005
@@ -0,0 +1,84 @@
+-- test database class loading.
+
+
+create schema emc;
+set schema emc;
+create table contacts (id int primary key, e_mail varchar(30));
+
+create procedure EMC.ADDCONTACT(id INT, e_mail VARCHAR(30))
+MODIFIES SQL DATA
+external name 'org.apache.derbyTesting.databaseclassloader.emc.addContact'
+language java parameter style java;
+
+-- fails because no class in classpath, 
+CALL EMC.ADDCONTACT(1, 'bill@somecompany.com');
+
+-- install the jar, copied there by the magic of supportfiles
+-- in the test harness (dcl_app.properties). The source for
+-- the class is contained within the jar for reference.
+CALL SQLJ.INSTALL_JAR('file:dcl_emc1.jar', 'EMC.MAIL_APP', 0);
+
+-- fails because no class not in classpath, jar file not in database classpath.
+CALL EMC.ADDCONTACT(1, 'bill@somecompany.com');
+
+-- now add this into the database class path
+call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', 'EMC.MAIL_APP');
+
+
+-- all should work now
+CALL EMC.ADDCONTACT(1, 'bill@ruletheworld.com');
+CALL EMC.ADDCONTACT(2, 'penguin@antartic.com');
+SELECT id, e_mail from EMC.CONTACTS;
+
+-- now the application needs to track if e-mails are valid
+ALTER TABLE EMC.CONTACTS ADD COLUMN OK SMALLINT;
+SELECT id, e_mail, ok from EMC.CONTACTS;
+
+-- well written application, INSERT used explicit column names
+-- ok defaults to NULL
+CALL EMC.ADDCONTACT(3, 'big@blue.com');
+SELECT id, e_mail, ok from EMC.CONTACTS;
+
+-- now change the application to run checks on the e-mail
+-- address to ensure it is valid (in this case by seeing if
+-- simply includes 'spam' in the title.
+CALL SQLJ.REPLACE_JAR('file:dcl_emc2.jar', 'EMC.MAIL_APP');
+
+CALL EMC.ADDCONTACT(4, 'spammer@ripoff.com');
+CALL EMC.ADDCONTACT(5, 'open@source.org');
+SELECT id, e_mail, ok from EMC.CONTACTS;
+
+-- now add another jar in to test two jars and
+-- a quoted identifer for the jar names.
+
+create schema "emcAddOn";
+set schema emcAddOn;
+set schema "emcAddOn";
+
+create function "emcAddOn".VALIDCONTACT(e_mail VARCHAR(30))
+RETURNS SMALLINT
+READS SQL DATA
+external name 'org.apache.derbyTesting.databaseclassloader.addon.vendor.util.valid'
+language java parameter style java;
+
+CALL SQLJ.INSTALL_JAR('file:dcl_emcaddon.jar', '"emcAddOn"."MailAddOn"', 0);
+
+call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', 'EMC.MAIL_APP:"emcAddOn"."MailAddOn"');
+
+select e_mail, "emcAddOn".VALIDCONTACT(e_mail) from EMC.CONTACTS;
+
+
+-- cleanup
+CALL SQLJ.REMOVE_JAR('EMC.MAIL_APP', 0);
+call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', '"emcAddOn"."MailAddOn"');
+CALL EMC.ADDCONTACT(99, 'cash@venture.com');
+CALL SQLJ.REMOVE_JAR('EMC.MAIL_APP', 0);
+DROP PROCEDURE EMC.ADDCONTACT;
+
+select e_mail, "emcAddOn".VALIDCONTACT(e_mail) from EMC.CONTACTS;
+call SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', '');
+select e_mail, "emcAddOn".VALIDCONTACT(e_mail) from EMC.CONTACTS;
+CALL SQLJ.REMOVE_JAR('"emcAddOn"."MailAddOn"', 0);
+DROP FUNCTION "emcAddOn".VALIDCONTACT;
+
+DROP TABLE EMC.CONTACTS;

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl.sql
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_app.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_app.properties?rev=226474&view=auto
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_app.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_app.properties Fri Jul 29 22:13:45 2005
@@ -0,0 +1,4 @@
+usedefaults=true
+supportfiles=tests/lang/dcl_emc1.jar,tests/lang/dcl_emc2.jar,tests/lang/dcl_emcaddon.jar
+#Exclude for J2ME/Foundation - test requires java.sql.DriverManager for server side JDBC
+runwithfoundation=false
\ No newline at end of file

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_app.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_emc1.jar
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_emc1.jar?rev=226474&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_emc1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_emc2.jar
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_emc2.jar?rev=226474&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_emc2.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_emcaddon.jar
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_emcaddon.jar?rev=226474&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dcl_emcaddon.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream