org.apache.derbyTesting.junit.TestConfiguration Java Examples

The following examples show how to use org.apache.derbyTesting.junit.TestConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StandardTests.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static Test createTableFromQueryTest(String serverHost, int serverPort)
{
    Test t = TestConfiguration.existingServerSuite(CreateTableFromQueryTest.class, false, // false: because adds clean/decorate below
            serverHost,serverPort);
    CleanDatabaseTestSetup cdts = 
            new CleanDatabaseTestSetup(t, 
                    true,// Use networkclient when running setUp/decorateSQL
                    serverHost,
                    serverPort
                ) 
    {
        protected void decorateSQL(Statement stmt) 
            throws SQLException
        {
            CreateTableFromQueryTest.decorate(stmt);
        }
    };
    return cdts;
}
 
Example #2
Source File: SuicideOfStreamingTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Return a test suite.
 *
 * @return an empty suite if Derby is built with in INSANE mode,
 *      a suite with one or more tests otherwise.
 */
public static Test suite() {
    if (SanityManager.DEBUG) {
        // [NOTE] Observe that the CleanDatabaseTestSetup is wrapping the
        //      client/server decorator. This is intentional, because the
        //      network server tend to enter an invalid state when setting
        //      the debug property used by this test. To avoid the error,
        //      we use an embedded connection to clean the database, while
        //      the test itself uses a network connection.
        //      This means this test will not run with a remote server.

        // [NOTE] To observe the protocol error that should not be seen,
        //      move the CleanDatabaseTestSetup inside the client/server
        //      decorator. The error is intermittent, so more than one run
        //      may be required.
        return new CleanDatabaseTestSetup(
                TestConfiguration.clientServerDecorator(
                    new TestSuite(SuicideOfStreamingTest.class,
                                  "SuicideOfStreamingTest")));
    }
    return new TestSuite("SuicideOfStreamingTest <DISABLED IN INSANE MODE>");
}
 
Example #3
Source File: UpdatableResultSetTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/** Create a test suite with all tests in this class. */
    public static Test suite() {

        // Test will fail with JCC.
        if (usingDB2Client()) {
            // empty suite
            return new TestSuite();
        }

// GemStone changes BEGIN
        // updatable resultsets not yet implemented for clients
        return TestConfiguration.embeddedSuite(UpdatableResultSetTest.class);
        /* (original code)
        return TestConfiguration.defaultSuite(UpdatableResultSetTest.class);
        */
// GemStone changes END
    }
 
Example #4
Source File: SURQueryMixTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Run in client and embedded.
 */
public static Test suite() 
{   
    TestSuite mainSuite = new TestSuite("SURQueryMixTest suite");
    
    // DB2 client doesn't support this functionality
    if (usingDB2Client())
        return mainSuite;
    
    mainSuite.addTest(baseSuite("SURQueryMixTest:embedded"));
    mainSuite.addTest(
            TestConfiguration.clientServerDecorator(
                    baseSuite("SURQueryMixTest:client")));
    
    return mainSuite;
    
}
 
Example #5
Source File: DboPowersTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Wraps the shutdown fixture in decorators to run with data
 * base owner and one other valid user.
 *
 * @param autLev security context to use
 */

private static Test wrapShutdownUserTests(int autLev)
{
    // add decorator for different users authenticated
    TestSuite usersSuite =
        new TestSuite("usersSuite: security level=" +
                      secLevelNames[autLev]);

    // First decorate with users, then with
    for (int userNo = 0; userNo < users.length; userNo++) {
        usersSuite.addTest
            (TestConfiguration.changeUserDecorator
             (new DboPowersTest("testShutDown", autLev),
              users[autLev-1][userNo],
              users[autLev-1][userNo].concat(pwSuffix)));
    }

    return DatabasePropertyTestSetup.
        builtinAuthentication(usersSuite, users[autLev-1], pwSuffix);
}
 
Example #6
Source File: RolesTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Wrap in decorators to run with data base owner and one other
 * valid user in sqlAuthorization mode.
 *
 * @param testName test to wrap
 */
private static Test wrapInAuthorization(String testName)
{
    // add decorator for different users authenticated
    TestSuite usersSuite =
        new TestSuite("suite: security level=sqlAuthorization");

    // First decorate with users, then with authorization
    // decorator
    for (int userNo = 0; userNo < users.length; userNo++) {
        usersSuite.addTest
            (TestConfiguration.changeUserDecorator
             (new RolesTest(testName,
                            SQLAUTHORIZATION,
                            users[userNo],
                            users[userNo].concat(pwSuffix)),
              users[userNo],
              users[userNo].concat(pwSuffix)));
    }

    return TestConfiguration.sqlAuthorizationDecorator(
        DatabasePropertyTestSetup.builtinAuthentication(
            usersSuite, users, pwSuffix));
}
 
Example #7
Source File: SuicideOfStreamingTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Return a test suite.
 *
 * @return an empty suite if Derby is built with in INSANE mode,
 *      a suite with one or more tests otherwise.
 */
public static Test suite() {
    if (SanityManager.DEBUG) {
        // [NOTE] Observe that the CleanDatabaseTestSetup is wrapping the
        //      client/server decorator. This is intentional, because the
        //      network server tend to enter an invalid state when setting
        //      the debug property used by this test. To avoid the error,
        //      we use an embedded connection to clean the database, while
        //      the test itself uses a network connection.
        //      This means this test will not run with a remote server.

        // [NOTE] To observe the protocol error that should not be seen,
        //      move the CleanDatabaseTestSetup inside the client/server
        //      decorator. The error is intermittent, so more than one run
        //      may be required.
        return new CleanDatabaseTestSetup(
                TestConfiguration.clientServerDecorator(
                    new TestSuite(SuicideOfStreamingTest.class,
                                  "SuicideOfStreamingTest")));
    }
    return new TestSuite("SuicideOfStreamingTest <DISABLED IN INSANE MODE>");
}
 
Example #8
Source File: NetworkServerMBeanTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * This method invokes the ping operation. Because this will currently
 * result in a security exception on the server side when running with Jars
 * (due to a lacking SocketPermission), the ping operation is actually
 * only invoked when running from the classes directory.
 * This is hopefully only a temporary solution...
 * 
 * @throws java.lang.Exception if the operation fails
 */
public void testOperationPing() throws Exception {
    /* disabling the contents of this test fixture when running with 
     * jars, until the network server has the permission to connect to 
     * itself.
     * Otherwise we get a security exception (if the security manager has 
     * been enabled).
     * 
     *    java.net.SocketPermission <host>:<port> connect,resolve
     * 
     * Since the default server policy file doesn't work when running with
     * classes, the network server should in that case have been started 
     * with no security manager (see 
     * NetworkServerTestSetup#startSeparateProcess).
     */
    if (TestConfiguration.loadingFromJars()) {
        println("testOperationPing: Won't invoke the ping operation " +
                "since the code has been loaded from the jars.");
        return;
    } 
    // if the server is not running, an exception will be thrown when
    // invoking the ping operation.
    // assumes noSecurityManager or that the required SocketPermission has
    // been given to the network server.
    invokeOperation(getNetworkServerMBeanObjectName(), "ping");
}
 
Example #9
Source File: StandardTests.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static Test ansiTrimTest(String serverHost, int serverPort)
{
    Test t = TestConfiguration.existingServerSuite(AnsiTrimTest.class, false, // false: because adds clean/decorate below
            serverHost,serverPort); 
    CleanDatabaseTestSetup cdts = 
            new CleanDatabaseTestSetup(t, 
                    true,// Use networkclient when running setUp/decorateSQL
                    serverHost,
                    serverPort
                ) 
    {
        public void decorateSQL(Statement s)
                throws SQLException 
        {
            AnsiTrimTest.decorate(s);
        }            
    };
    return cdts;
}
 
Example #10
Source File: UpdatableResultSetTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/** Create a test suite with all tests in this class. */
    public static Test suite() {

        // Test will fail with JCC.
        if (usingDB2Client()) {
            // empty suite
            return new TestSuite();
        }

// GemStone changes BEGIN
        // updatable resultsets not yet implemented for clients
        return TestConfiguration.embeddedSuite(UpdatableResultSetTest.class);
        /* (original code)
        return TestConfiguration.defaultSuite(UpdatableResultSetTest.class);
        */
// GemStone changes END
    }
 
Example #11
Source File: RolesTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 *
 * Construct suite of tests for positive syntax (edge cases)
 *
 * @param framework Derby framework indication
 * @return A suite containing the test cases for  syntax
 * edge cases. Incarnated only for sqlAuthorization, dbo.
 */
private static Test positiveSyntaxSuite(String framework)
{
    String dbo = users[dboIndex];
    String dbopw = dbo.concat(pwSuffix);

    Test t = (TestConfiguration.changeUserDecorator
              (new RolesTest("testPositiveSyntax",
                             SQLAUTHORIZATION,
                             dbo, dbopw),
               dbo, dbopw));

    return TestConfiguration.sqlAuthorizationDecorator(
        DatabasePropertyTestSetup.builtinAuthentication(
            t, users, pwSuffix));
}
 
Example #12
Source File: SecureServerTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private void    connectToServer()
    throws Exception
{
    final TestConfiguration config = getTestConfiguration();
    String  url
        = ( "jdbc:derby://localhost:" + config.getPort()
            + "/" + "wombat;create=true"
            + ";user=" + config.getUserName()
            + ";password=" + config.getUserPassword() );

    println( "XXX in connectToServer(). url = " + url );

    // just try to get a connection
    Class.forName( "com.pivotal.gemfirexd.jdbc.ClientDriver" );
    
    Connection  conn = DriverManager.getConnection(  url );

    assertNotNull( "Connection should not be null...", conn );

    conn.close();
}
 
Example #13
Source File: RolesTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private void assertSysRolesRowCount(int rcNoAuth,
                                    int rcDbo,
                                    int rcMereMortal)
    throws SQLException
{

    if (TestConfiguration.getCurrent().isVerbose()) {
        dumpSysRoles();
    }

    assertSystableRowCount("SYS.SYSROLES",
                           rcNoAuth, rcDbo, rcMereMortal);
}
 
Example #14
Source File: TestPreStoppedSlave.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
  * Adds this class to the *existing server* suite.
  */
 public static Test suite(String serverHost, int serverPort)
 {
     System.out.println("*** TestPreStoppedSlave.suite(serverHost,serverPort)");
  
     Test t = TestConfiguration.existingServerSuite(TestPreStoppedSlave.class,false,serverHost,serverPort);
     System.out.println("*** Done TestConfiguration.existingServerSuite(TestPreStoppedSlave.class,false,serverHost,serverPort)");
     return t;
}
 
Example #15
Source File: AuthenticationTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static Test baseSuite(String name) {
    TestSuite suite = new TestSuite("AuthenticationTest");
    
    Test test = new AuthenticationTest(
        "testConnectShutdownAuthentication");
    setBaseProps(suite, test);
    
    test = new AuthenticationTest("testUserCasing");
    setBaseProps(suite, test);
    
    test = new AuthenticationTest("testUserFunctions");
    setBaseProps(suite, test);

    test = new AuthenticationTest("testNotFullAccessUsers");
    setBaseProps(suite, test);
    
    test = new AuthenticationTest("testUserAccessRoutines");
    setBaseProps(suite, test);
    
    test = new AuthenticationTest(
        "testChangePasswordAndDatabasePropertiesOnly");
    setBaseProps(suite, test);

    // only part of this fixture runs with network server / client
    test = new AuthenticationTest("testGreekCharacters");
    setBaseProps(suite, test);

    test = new AuthenticationTest("testSystemShutdown");
    setBaseProps(suite, test);
    
    // This test needs to run in a new single use database as we're setting
    // a number of properties
    return TestConfiguration.singleUseDatabaseDecorator(suite);
}
 
Example #16
Source File: LobStreamTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Suite method automatically generated by JUnit module.
 */
public static Test suite() {
    //testing only embedded driver generic test suite testing both
    //client and ebedded is present in jdbcapi/LobStreamsTest
    TestSuite ts  = new TestSuite ("LobStreamTest");
    ts.addTest(TestConfiguration.embeddedSuite(LobStreamTest.class));
    TestSuite encSuite = new TestSuite ("LobStreamsTest:encrypted");
    encSuite.addTestSuite (LobStreamTest.class);
    ts.addTest(Decorator.encryptedDatabase (encSuite));
    return ts;
}
 
Example #17
Source File: ResultSetTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/************************************************************************
 **                        T E S T  S E T U P                           *
 ************************************************************************/

public static Test suite() {
    TestSuite rsSuite = new TestSuite("ResultSetTest suite");
    rsSuite.addTest(decorateTestSuite(TestConfiguration.defaultSuite
        (ResultSetTest.class,false)));
    return rsSuite;
}
 
Example #18
Source File: Bug4356Test.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the implemented tests.
 *
 * @return An instance of <code>Test</code> with the implemented tests to
 *         run.
 */
public static Test suite() {
    return new CleanDatabaseTestSetup(TestConfiguration
            .embeddedSuite(Bug4356Test.class)) {
        protected void decorateSQL(Statement stmt) throws SQLException {
            stmt.executeUpdate("CREATE TABLE T1 (a integer, b integer)");
            stmt.executeUpdate("CREATE TABLE T2 (a integer)");
            stmt.executeUpdate("INSERT INTO T2 VALUES(1)");
        }
    };
}
 
Example #19
Source File: AuthenticationTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static Test baseSuite(String name) {
    TestSuite suite = new TestSuite("AuthenticationTest");
    
    Test test = new AuthenticationTest(
        "testConnectShutdownAuthentication");
    setBaseProps(suite, test);
    
    test = new AuthenticationTest("testUserCasing");
    setBaseProps(suite, test);
    
    test = new AuthenticationTest("testUserFunctions");
    setBaseProps(suite, test);

    test = new AuthenticationTest("testNotFullAccessUsers");
    setBaseProps(suite, test);
    
    test = new AuthenticationTest("testUserAccessRoutines");
    setBaseProps(suite, test);
    
    test = new AuthenticationTest(
        "testChangePasswordAndDatabasePropertiesOnly");
    setBaseProps(suite, test);

    // only part of this fixture runs with network server / client
    test = new AuthenticationTest("testGreekCharacters");
    setBaseProps(suite, test);

    test = new AuthenticationTest("testSystemShutdown");
    setBaseProps(suite, test);
    
    // This test needs to run in a new single use database as we're setting
    // a number of properties
    return TestConfiguration.singleUseDatabaseDecorator(suite);
}
 
Example #20
Source File: LobStreamsTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Run with DerbyNetClient only.
 * Embedded Clob/Blob.setXXXStream() methods are not implemented.
 */
public static Test suite() {

    TestSuite ts  = new TestSuite ("LobStreamsTest");
    ts.addTest(TestConfiguration.defaultSuite (LobStreamsTest.class));
    // JSR169 does not have support for encryption
    if (JDBC.vmSupportsJDBC3()) {
        TestSuite encSuite = new TestSuite ("LobStreamsTest:encrypted");
        encSuite.addTestSuite (LobStreamsTest.class);
        ts.addTest(Decorator.encryptedDatabase (encSuite));
    }
    return ts;
}
 
Example #21
Source File: HoldabilityTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static Test suite() {
           
    // DB2 client doesn't support this functionality
    if (usingDB2Client())
        return new TestSuite();
    
    return TestConfiguration.defaultSuite(HoldabilityTest.class);
}
 
Example #22
Source File: VerifySignatures.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Obtain a connection from an <code>XADataSource</code> object
 * and perform JDBC operations on it. Collect the classes of all
 * JDBC objects that are found.
 *
 * @param classes set into which classes are collected
 * @exception SQLException if a database error occurs
 */
private static void collectClassesFromXADataSource(Set<ClassInfo> classes)
    throws SQLException
{
    XADataSource xads = J2EEDataSource.getXADataSource();
    addClass(classes, xads.getClass(), javax.sql.XADataSource.class);

    XAConnection xaconn = xads.getXAConnection(TestConfiguration.getCurrent().getUserName(),
            TestConfiguration.getCurrent().getUserPassword());
    addClass(classes, xaconn.getClass(), javax.sql.XAConnection.class);

    collectClassesFromConnection(xaconn.getConnection(), classes);
}
 
Example #23
Source File: DriverMgrAuthenticationTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected void assertShutdownFail(
        String expectedSqlState, String dbName, String user, String password) 
throws SQLException
{
    String url = TestConfiguration.getCurrent().getJDBCUrl(dbName) +
        ";shutdown=true";      
    try {
        DriverManager.getConnection(url, user, password);
        fail("expected failed shutdown");
    } catch (SQLException e) {
        assertSQLState(expectedSqlState, e);
    }
}
 
Example #24
Source File: DestroySlaveDB.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
  * Adds this class to the *existing server* suite.
  */
 public static Test suite(String serverHost, int serverPort)
 {
     System.out.println("*** DestroySlaveDB.suite("+serverHost+","+serverPort+")");
     
     Test t = TestConfiguration.existingServerSuite(DestroySlaveDB.class,false,serverHost,serverPort);
     System.out.println("*** Done TestConfiguration.existingServerSuite(DestroySlaveDB.class,false,"
             +serverHost+","+serverPort+")");
     return t;
}
 
Example #25
Source File: DboPowersTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Wraps the encryption fixtures in decorators to run with data
 * base owner and one other valid user.
 *
 * @param autLev security context to use
 */

private static Test wrapEncryptionUserTests(int autLev)
{
    // add decorator for different users authenticated
    TestSuite usersSuite =
        new TestSuite("usersSuite: security level=" +
                      secLevelNames[autLev]);

    // First decorate with users, then with authentication.  Note
    // use of no teardown / no shutdown decorator variants:
    // Necessary since framework doesnt know bootPassword
    for (int userNo = 0; userNo < users.length; userNo++) {
        for (int tNo = 0; tNo < encryptionTests.length; tNo++) {
            Test test = TestConfiguration.changeUserDecorator
                (new DboPowersTest(encryptionTests[tNo],
                                   autLev,
                                   users[autLev-1][0], // dbo
                                   users[autLev-1][0].concat(pwSuffix)),
                 users[autLev-1][userNo],
                 users[autLev-1][userNo].concat(pwSuffix));
            test = DatabasePropertyTestSetup.builtinAuthenticationNoTeardown
                (test, users[autLev-1], pwSuffix);
            if (autLev == AUTHENTICATION) {
                test = TestConfiguration.
                    singleUseDatabaseDecoratorNoShutdown(test);
            } else {
                test = TestConfiguration.
                    sqlAuthorizationDecoratorSingleUse(test);
            }
            usersSuite.addTest(test);
        }
    }
    return usersSuite;
}
 
Example #26
Source File: ShutdownMasterServerByOsKill.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Adds this class to the *existing server* suite.
 */
public static Test suite(String serverHost, int serverPort)
throws IOException
{
    System.out.println("*** ShutdownMasterServerByOsKill.suite("+serverHost+","+serverPort+")");
    
    Test t = TestConfiguration.existingServerSuite(ShutdownMasterServerByOsKill.class,false,serverHost,serverPort);
    System.out.println("*** Done TestConfiguration.existingServerSuite(ShutdownMasterServerByOsKill.class,false,"
            +serverHost+":"+serverPort+")");
    return t;
}
 
Example #27
Source File: DriverMgrAuthenticationTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void assertConnectionFail(String dbName) throws SQLException {
    // this method needs to not use default user/pwd (APP, APP).
    
    String url = TestConfiguration.getCurrent().getJDBCUrl(dbName);
    try {
        DriverManager.getConnection(url);
        fail("expected connection to fail");
    }
    catch (SQLException e) {
        assertSQLState("08004", e);
    }
}
 
Example #28
Source File: DRDAProtocolTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static Test suite() {
    Test test;
    test = TestConfiguration.clientServerSuite(DRDAProtocolTest.class);
    test = TestConfiguration.additionalDatabaseDecorator(test, "FIRSTDB1");
    test = TestConfiguration.additionalDatabaseDecorator(test, "SECONDDB2");
    return test;
}
 
Example #29
Source File: Bug5052rtsTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the implemented tests.
 * 
 * @return An instance of <code>Test</code> with the implemented tests to
 *         run.
 */
public static Test suite() {
    return new CleanDatabaseTestSetup(TestConfiguration
            .embeddedSuite(Bug5052rtsTest.class)) {
        protected void decorateSQL(Statement stmt) throws SQLException {
            stmt
                    .execute("create table tab1 (COL1 int, COL2 smallint, COL3 real)");
            stmt.executeUpdate("insert into tab1 values(1, 2, 3.1)");
            stmt.executeUpdate("insert into tab1 values(2, 2, 3.1)");
        }
    };
}
 
Example #30
Source File: ShutdownSlaveDb.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Adds this class to the *existing server* suite.
 */
public static Test suite(String serverHost, int serverPort)
throws IOException
{
    System.out.println("*** ShutdownSlaveDb.suite("+serverHost+","+serverPort+")");
    
    Test t = TestConfiguration.existingServerSuite(ShutdownSlaveDb.class,false,serverHost,serverPort);
    System.out.println("*** Done TestConfiguration.existingServerSuite(ShutdownSlaveDb.class,false,"
            +serverHost+":"+serverPort+")");
    return t;
}