/** * Test Chinese character in database name, user and password, using DriverManager methods. * * @throws SQLException */ public void testDriverManagerConnect() throws SQLException { // get a connection to load the driver getConnection(); Connection conn = null; String url = null; try { // Test Chinese database name url = TestConfiguration.getCurrent().getJDBCUrl("\u4e10;create=true"); conn = DriverManager.getConnection(url); conn.close(); } catch (SQLException se) { if (usingEmbedded()) throw se; else assertSQLState("22005", se); } try { // Test Chinese user name url = TestConfiguration.getCurrent().getJDBCUrl("\u4e10;user=\u4e10"); conn = DriverManager.getConnection(url); conn.close(); } catch (SQLException se) { if (usingEmbedded()) throw se; else assertSQLState("22005", se); } try { // Test Chinese user name in parameter to getConnection url = TestConfiguration.getCurrent().getJDBCUrl("\u4e10"); conn = DriverManager.getConnection(url, "\u4e10", "pass"); conn.close(); } catch (SQLException se) { if (usingEmbedded()) throw se; else assertSQLState("22005", se); } try { // Test Chinese password in url url = TestConfiguration.getCurrent().getJDBCUrl("\u4e10;user=user;password=\u4e10"); conn = DriverManager.getConnection(url); conn.close(); } catch (SQLException se) { if (usingEmbedded()) throw se; else assertSQLState("22005", se); } try { // Test Chinese password in parameter to getConnection() url = TestConfiguration.getCurrent().getJDBCUrl("\u4e10"); conn = DriverManager.getConnection(url, "\u4e10", "\u4e10"); conn.close(); } catch (SQLException se) { if (usingEmbedded()) throw se; else assertSQLState("22005", se); } }
/** * Checks whether the server shuts down causes the databases it has booted to be shut down. * * <p>Creates a database and shuts down the server. If the server was started from the command * line the database should be shut down. If the server was started from the api the database * should not be shut down. * * <p>If the database has been shut down the db.lck file should not exist. * * @param dbShutDown Indicates whether the database should have been shut down. */ private void shutdownServerCheckDBShutDown(boolean dbShutDown) throws Exception { // connect to database createDatabase(); NetworkServerControl server = NetworkServerTestSetup.getNetworkServerControl(); // shut down the server server.shutdown(); // check if db.lck exists String fileName = getSystemProperty("gemfirexd.system.home") + java.io.File.separator + TestConfiguration.getCurrent().getDefaultDatabaseName() + java.io.File.separator + "db.lck"; boolean fileNotFound = false; int i = 0; do { Thread.sleep(500); fileNotFound = !fileExists(fileName); i++; } while (fileNotFound != dbShutDown && i < 120); assertEquals("Database is shut down", dbShutDown, fileNotFound); }
/** * Test that a shutdown of the engine does not take down the network server. Before DERBY-1326 was * fixed, shutting down the engine would leave the network server in an inconsistent state which * could make clients hang infinitely. */ private void scenarioEngineShutdownDoesNotTakeDownNS(boolean loadEmbeddedDriver) throws Exception { Connection[] conns = new Connection[20]; // first make sure there are 20 active worker threads on the server for (int i = 0; i < conns.length; i++) { conns[i] = openDefaultConnection(); } // then close them, leaving 20 free worker threads ready to pick up new // sessions for (int i = 0; i < conns.length; i++) { conns[i].close(); conns[i] = null; } // Give the free threads a little time to close their sessions. This is // done to ensure that there are free threads waiting for new sessions, // which makes the DERBY-1326 hang more reliably reproducible. Thread.sleep(500); // shut down the engine TestConfiguration.getCurrent().shutdownEngine(); if (loadEmbeddedDriver) Class.forName("com.pivotal.gemfirexd.jdbc.EmbeddedDriver").newInstance(); // see if it is still possible to connect to the server (before // DERBY-1326, this would hang) for (int i = 0; i < 20; i++) { openDefaultConnection().close(); } }
/** Run in both embedded and client. */ public static Test suite() { TestSuite suite = baseSuite("UpdateXXXTest"); suite.addTest(TestConfiguration.clientServerDecorator(baseSuite("UpdateXXXTest:client"))); return suite; }
public void tearDown() throws SQLException { String shutdownUrl = TestConfiguration.getCurrent().getJDBCUrl("\u4e10;shutdown=true"); try { DriverManager.getConnection(shutdownUrl); } catch (SQLException se) { // ignore shutdown exception } removeDirectory(getSystemProperty("derby.system.home") + File.separator + "\u4e10"); }
public static Test suite() { Test suite = TestConfiguration.defaultSuite(OptimizerOverridesTest.class, false); suite = new CleanDatabaseTestSetup(suite) { /* Create tables, indices and views. * @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement) */ protected void decorateSQL(Statement st) throws SQLException { st.getConnection().setAutoCommit(false); st.addBatch( "create table t1 (c1 int, " + "c2 int, c3 int," + " constraint cons1 primary key(c1, c2))"); st.addBatch( "create table t2 (c1 int not null, " + "c2 int not null, c3 int, " + "constraint cons2 unique(c1, c2))"); st.addBatch("insert into t1 values (1, 1, 1), " + "(2, 2, 2), (3, 3, 3), (4, 4, 4)"); ; st.addBatch("insert into t2 values (1, 1, 1), " + "(2, 2, 2), (3, 3, 3), (4, 4, 4)"); st.addBatch("create index t1_c1c2c3 on t1(c1, c2, c3)"); st.addBatch("create index t1_c3c2c1 on t1(c3, c2, c1)"); st.addBatch("create index t1_c1 on t1(c1)"); st.addBatch("create index t1_c2 on t1(c2)"); st.addBatch("create index t1_c3 on t1(c3)"); st.addBatch("create index \"t1_c2c1\" on t1(c2, c1)"); st.addBatch("create index t2_c1c2c3 on t2(c1, c2, c3)"); st.addBatch("create index t2_c3c2c1 on t2(c3, c2, c1)"); st.addBatch("create index t2_c1 on t2(c1)"); st.addBatch("create index t2_c2 on t2(c2)"); st.addBatch("create index t2_c3 on t2(c3)"); st.addBatch("create view v1 as select * from t1 " + "--derby-properties index = t1_c1"); st.addBatch("create view v2 as select t1.* from t1, t2"); st.addBatch("create view v3 as select * from v1"); st.addBatch( "create view neg_v1 as select * from t1" + " --derby-properties asdf = fdsa"); st.executeBatch(); } }; return suite; }
/** Only run the fixtures in network server mode as that's what they are testing. */ public static Test suite() { TestSuite suite = new TestSuite("ShutDownDBWhenNSShutsDownTest"); suite.addTest( TestConfiguration.clientServerDecorator( new ShutDownDBWhenNSShutsDownTest("testEngineShutdownDoesNotTakeDownNSManualReload"))); /* DERBY-2066 suite.addTest(TestConfiguration.clientServerDecorator( new ShutDownDBWhenNSShutsDownTest( "testEngineShutdownDoesNotTakeDownNSAutoReload"))); */ // GemStone changes BEGIN // not meaningful for GemFireXD /* (original code) suite.addTest(TestConfiguration.clientServerDecorator( new ShutDownDBWhenNSShutsDownTest( "testDatabasesShutDownWhenNSShutdownAPI"))); */ // GemStone changes END return suite; }
/** Test only runs in embedded as it is testing server side SQL routines implemented in Java. */ public static Test suite() { Test suite = TestConfiguration.embeddedSuite(RoutineSecurityTest.class); // Create all the routines we need up front. return new CleanDatabaseTestSetup(suite) { protected void decorateSQL(Statement s) throws SQLException { s.executeUpdate( "CREATE FUNCTION GET_SYS_PROP(PROPERTY_KEY VARCHAR(60)) " + "RETURNS VARCHAR(255) " + "EXTERNAL NAME 'java.lang.System.getProperty' " + "LANGUAGE JAVA PARAMETER STYLE JAVA"); s.executeUpdate( "CREATE PROCEDURE DENIAL_OF_SERVICE(RC INT) " + "EXTERNAL NAME 'java.lang.System.exit' " + "LANGUAGE JAVA PARAMETER STYLE JAVA"); s.executeUpdate( "CREATE PROCEDURE FORCEGC() " + "EXTERNAL NAME 'java.lang.System.gc' " + "LANGUAGE JAVA PARAMETER STYLE JAVA"); } }; }
public static Test suite() { return TestConfiguration.defaultSuite(FloatTypesTest.class); }
/** Construct top level suite in this JUnit test */ public static Test suite() { TestSuite suite = (TestSuite) TestConfiguration.defaultSuite(AnsiSignaturesTest.class); return new CleanDatabaseTestSetup(suite); }
/** Create test suite for this test. */ public static Test suite() { return new BlobClobTestSetup( // Reduce lock timeouts so lock test case does not take too long DatabasePropertyTestSetup.setLockTimeouts( TestConfiguration.defaultSuite(ClobTest.class, false), 2, 4)); }
public static Test suite() { return TestConfiguration.defaultSuite(UnsupportedVetter.class); }
/** * Returns a suite running with a single use database with the embedded driver only. * * @return A test suite. */ public static Test suite() { TestSuite suite = new TestSuite(BackupRestoreTest.class); return new SupportFilesSetup(TestConfiguration.singleUseDatabaseDecorator(suite)); }
public static Test suite() { return TestConfiguration.defaultSuite(InternationalConnectTest.class); }
/** * Returns a suite of tests running in a client-server environment. * * @return A test suite. */ public static Test suite() { return TestConfiguration.clientServerSuite(LogicalStatementEntityTest.class); }