public class DatabaseClassLoadingTest extends BaseJDBCTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
DatabaseClassLoadingTest(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
(package private) static void |
addEntries(java.util.zip.ZipOutputStream zos,
java.io.File dir,
java.lang.String dbName,
int old) |
private static void |
addFile(java.util.zip.ZipOutputStream zos,
java.io.File f,
java.lang.String dbName,
int old) |
private void |
checkConnectionToClasspathDB(boolean databaseInClasspath)
Check if it is possible to connect to a classpath database.
|
private void |
checkCorrectLoader(java.lang.String className,
java.sql.PreparedStatement ps1,
java.sql.PreparedStatement ps2,
java.sql.PreparedStatement ps3) |
private void |
checkLoading(java.lang.String order)
Run a number of tests to ensure classes are loaded
from the correct class loader.
|
private static void |
createArchive(java.lang.String jarName,
java.io.File dbDir,
java.lang.String dbName)
jarname - jarname to use path - path to database dbname - database name
in archive
|
private void |
derby2035Workaround() |
private static void |
getResourceTests(java.sql.Connection conn) |
private void |
installJar(java.lang.String resource,
java.lang.String jarName) |
private void |
loadJavaClass(java.lang.String method,
java.lang.String expectedSQLState)
Test loading classes in the java. and javax. namespaces
from a jar, it should be disallowed or be ignored.
|
private static junit.framework.Test |
loginTimeoutSuite()
Create a test suite that verifies the fix for DERBY-6107.
|
private static void |
readOnlyTest(javax.sql.DataSource ds)
Run an number of statements against a jar'ed database to
ensure it is read-only and that class loading works from
jar files embedded in jar'ed up databases.
|
private void |
removeJar(java.lang.String jarName) |
private void |
replaceJar(java.lang.String resource,
java.lang.String jarName) |
private void |
setDBClasspath(java.lang.String cp) |
private static void |
signersTests(java.sql.Connection conn) |
static junit.framework.Test |
suite()
Run the tests only in embedded since this is testing
server side behaviour.
|
void |
test_5352()
Test that restricted table functions can be invoked from inside jar files stored in
the database.
|
void |
testAddContact()
Test that a new connection successfully sees the changes.
|
void |
testAlterTable()
Alter the table to add a column, the add contact procedure
should still work.
|
void |
testClassLoadOrdering()
Test ordering of class loading.
|
void |
testClassPathRollback()
check the roll back of class loading.
|
void |
testCreateDatabaseJar()
Create a Jar of the current database.
|
void |
testDatabaseInClasspath() |
void |
testDatabaseInJar()
Test the jar'ed up database created by testCreateDatabaseJar
accessing the database using the jar(path to archive)db form
of database name.
|
void |
testGetResource() |
void |
testHackedJarReplacedClass()
Replace the signed jar with a hacked jar. emc.class modified to diable
valid e-mail address check but using same signatures within jar.
|
void |
testIndirectLoading()
Test that loading of Derby's internal classes from
an installed jar file is disallowed.
|
void |
testInvalidJar()
replace with a hacked jar file, emc.class modified to
be an invalid class (no signing on this jar).
|
void |
testJarHandling()
Test the sqlj procedures without setting any database
classpath.
|
void |
testLoadDerbyClassIndirectly()
Load a org.apache.derby class directly (ie. through a direct procedure call)
from the jar file.
|
void |
testLoadJavaClassDirectly()
Load a java.sql class directly (ie. through a direct procedure call)
from the jar file.
|
void |
testLoadJavaClassDirectly2()
Load a java.derby99 class directly (ie. through a direct procedure call)
from the jar file.
|
void |
testLoadJavaClassDirectly3()
Load a javax.derby99 class directly (ie. through a direct procedure call)
from the jar file.
|
void |
testLoadJavaClassIndirectly()
Load a java.sql class indirectly (ie. through a valid class
in the installed jar file) from the jar file.
|
void |
testLoginTimeoutInClasspath()
Test that a classpath database is found when it's in the
classpath and there is a login timeout.
|
void |
testLoginTimeoutNotInClasspath()
Test that a classpath database is not found when it's not in the
classpath and there is a login timeout.
|
void |
testRemoveJar() |
void |
testReplacedClass()
Change of class due to testReplaceJar that
changes the application to run checks on the e-mail
to ensure it is valid (in this case by seeing if
it simply includes 'spam' in the title).
|
void |
testReplaceJar()
Replace the jar to later test the prepare from a different
connection picks up the new version.
|
void |
testSecondJar()
now add another jar in to test two jars and
a quoted identifer for the jar names.
|
void |
testSetClasspath()
Set the classpath to include the MAIL_APP jar.
|
void |
testSignedJar()
Test to see if the jar signatures can be obtained from the jar file.
|
void |
testTableFunctionInJar()
Test that table functions can be invoked from inside jar files stored in
the database.
|
void |
testUDAInJar()
Test that user-defined aggregates can be invoked from inside jar files stored in
the database.
|
void |
testWithNoClasspath()
Install the jar, but don't set the classpath.
|
void |
testWithNoInstalledJars()
Test the routines fail before the jars that contain their
code have been installed and/or set in the classpath.
|
assertCallError, assertCheckTable, assertCommitError, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertResults, assertResults, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, chattyPrepare, chattyPrepareCall, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, dumpRs, dumpRs, emptyStatementCache, executeQuery, expectCompilationError, expectCompilationError, expectExecutionError, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, goodStatement, goodUpdate, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, tearDown, usingDB2Client, usingDerbyNetClient, usingEmbedded
alarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSameNullness, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, newAssertionFailedError, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemErr, setSystemOut, setSystemProperty, sleep, sleepAtLeastOneTick, traceit, vmAtLeast
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, setUp, toString
public static junit.framework.Test suite() throws java.lang.Exception
java.lang.Exception
private static junit.framework.Test loginTimeoutSuite() throws java.lang.Exception
java.lang.Exception
public void testWithNoInstalledJars() throws java.sql.SQLException
java.sql.SQLException
public void testJarHandling() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void testWithNoClasspath() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void testSetClasspath() throws java.sql.SQLException
java.sql.SQLException
public void testAddContact() throws java.sql.SQLException
java.sql.SQLException
public void testGetResource() throws java.sql.SQLException
java.sql.SQLException
private static void getResourceTests(java.sql.Connection conn) throws java.sql.SQLException
java.sql.SQLException
public void testAlterTable() throws java.sql.SQLException
java.sql.SQLException
public void testClassPathRollback() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void testReplaceJar() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void testReplacedClass() throws java.sql.SQLException
java.sql.SQLException
public void testSecondJar() throws java.sql.SQLException, java.net.MalformedURLException
java.net.MalformedURLException
java.sql.SQLException
public void testSignedJar() throws java.sql.SQLException, java.net.MalformedURLException
keytool -delete -alias emccto -keystore emcks -storepass ab987c
keytool -genkey -dname "cn=EMC CTO, ou=EMC APP, o=Easy Mail Company, c=US" -alias emccto -keypass kpi135 -keystore emcks -storepass ab987c
keytool -selfcert -alias emccto -keypass kpi135 -validity 36500 -keystore emcks -storepass ab987c
keytool -keystore emcks -storepass ab987c -list -v
jarsigner -keystore emcks -storepass ab987c -keypass kpi135 -signedjar dcl_emc2s.jar dcl_emc2.jar emccto
keytool -delete -alias emccto -keystore emcks -storepass ab987c
java.sql.SQLException
java.net.MalformedURLException
private static void signersTests(java.sql.Connection conn) throws java.sql.SQLException
java.sql.SQLException
public void testHackedJarReplacedClass() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void testInvalidJar() throws java.sql.SQLException, java.net.MalformedURLException
java.net.MalformedURLException
java.sql.SQLException
public void testRemoveJar() throws java.sql.SQLException
java.sql.SQLException
public void testCreateDatabaseJar() throws java.lang.Exception
java.lang.Exception
public void testDatabaseInJar() throws java.sql.SQLException
java.sql.SQLException
public void testDatabaseInClasspath() throws java.sql.SQLException
java.sql.SQLException
public void testLoadJavaClassIndirectly() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void testLoadJavaClassDirectly() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void testLoadJavaClassDirectly2() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void testLoadJavaClassDirectly3() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void testLoadDerbyClassIndirectly() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
private void loadJavaClass(java.lang.String method, java.lang.String expectedSQLState) throws java.sql.SQLException, java.net.MalformedURLException
java.net.MalformedURLException
java.sql.SQLException
private static void readOnlyTest(javax.sql.DataSource ds) throws java.sql.SQLException
java.sql.SQLException
public void testClassLoadOrdering() throws java.sql.SQLException, java.net.MalformedURLException
java.net.MalformedURLException
java.sql.SQLException
private void checkLoading(java.lang.String order) throws java.sql.SQLException
order
- Order the entry point classes will be loaded.java.sql.SQLException
private void checkCorrectLoader(java.lang.String className, java.sql.PreparedStatement ps1, java.sql.PreparedStatement ps2, java.sql.PreparedStatement ps3) throws java.sql.SQLException
java.sql.SQLException
public void testIndirectLoading() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void testTableFunctionInJar() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void testUDAInJar() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void test_5352() throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
public void testLoginTimeoutNotInClasspath() throws java.sql.SQLException
java.sql.SQLException
loginTimeoutSuite()
public void testLoginTimeoutInClasspath() throws java.sql.SQLException
java.sql.SQLException
loginTimeoutSuite()
private void checkConnectionToClasspathDB(boolean databaseInClasspath)
databaseInClasspath
- if true
, expect that the database
can be connected to; otherwise, expect that the database cannot be
found.private void installJar(java.lang.String resource, java.lang.String jarName) throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
private void replaceJar(java.lang.String resource, java.lang.String jarName) throws java.sql.SQLException, java.net.MalformedURLException
java.sql.SQLException
java.net.MalformedURLException
private void removeJar(java.lang.String jarName) throws java.sql.SQLException
java.sql.SQLException
private void setDBClasspath(java.lang.String cp) throws java.sql.SQLException
java.sql.SQLException
private void derby2035Workaround() throws java.sql.SQLException
java.sql.SQLException
private static void createArchive(java.lang.String jarName, java.io.File dbDir, java.lang.String dbName) throws java.lang.Exception
java.lang.Exception
static void addEntries(java.util.zip.ZipOutputStream zos, java.io.File dir, java.lang.String dbName, int old) throws java.lang.Exception
java.lang.Exception
private static void addFile(java.util.zip.ZipOutputStream zos, java.io.File f, java.lang.String dbName, int old) throws java.io.IOException
java.io.IOException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.