Search in sources :

Example 36 with TestProblemException

use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.

the class RMIIIOPRemoteModel method createConnection.

public RMIConnection createConnection() {
    RMIServerManager serverManager = null;
    Context initialNamingContext = null;
    try {
        initialNamingContext = new InitialContext();
    } catch (NamingException exception) {
        System.out.println("Naming Exception " + exception.toString());
    }
    ;
    // Set the client security manager
    try {
        System.setSecurityManager(new RMISecurityManager());
    } catch (Exception exception) {
        System.out.println("Security violation " + exception.toString());
    }
    // Get the remote factory object from the Registry
    try {
        serverManager = (RMIServerManager) initialNamingContext.lookup("SERVER-MANAGER");
    } catch (Exception exception) {
        throw new TestProblemException(exception.toString());
    }
    RMIConnection rmiConnection = null;
    try {
        rmiConnection = new RMIConnection(serverManager.createRemoteSessionController());
    } catch (RemoteException exception) {
        System.out.println("Error in invocation " + exception.toString());
    }
    return rmiConnection;
}
Also used : TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException)

Example 37 with TestProblemException

use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.

the class SessionsXMLBasicTestModel method setup.

@Override
public void setup() {
    originalSession = getSession();
    if ((getSession().getPlatform() instanceof TimesTenPlatform)) {
        throw new TestProblemException("This model is not intended for TimesTen databases.");
    }
    XMLSessionConfigLoader xmlLoader = new XMLSessionConfigLoader("org/eclipse/persistence/testing/models/sessionsxml/sessions.xml");
    // Do not login here, login later on.
    newXMLSession = SessionManager.getManager().getSession(xmlLoader, "EmployeeSession", getClass().getClassLoader(), false, true);
    newXMLSession.setSessionLog(originalSession.getSessionLog());
    newXMLSession.setLogLevel(originalSession.getLogLevel());
    ((DatabaseSession) originalSession).logout();
    newXMLSession.getLogin().setPlatform(originalSession.getLogin().getPlatform());
    newXMLSession.getLogin().setDriverClassName(originalSession.getLogin().getDriverClassName());
    newXMLSession.getLogin().setConnectionString(originalSession.getLogin().getConnectionString());
    newXMLSession.getLogin().setUserName(originalSession.getLogin().getUserName());
    newXMLSession.getLogin().setEncryptedPassword(originalSession.getLogin().getPassword());
    ((DatabaseSession) newXMLSession).login();
    getExecutor().setSession(newXMLSession);
    new EmployeeSystem().createTables((DatabaseSession) newXMLSession);
    new EmployeeSystem().populate((DatabaseSession) newXMLSession);
}
Also used : DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) TimesTenPlatform(org.eclipse.persistence.platform.database.TimesTenPlatform) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) XMLSessionConfigLoader(org.eclipse.persistence.sessions.factories.XMLSessionConfigLoader) EmployeeSystem(org.eclipse.persistence.testing.models.employee.relational.EmployeeSystem)

Example 38 with TestProblemException

use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.

the class SessionsXMLTestModel method addSessionsXMLSchemaWriteTest.

public void addSessionsXMLSchemaWriteTest(TestSuite suite) {
    try {
        Class<?> testCaseClass = Class.forName("org.eclipse.persistence.testing.tests.sessionsxml.SessionsXMLSchemaWriteTest");
        junit.framework.Test testCase = (junit.framework.Test) testCaseClass.getConstructor().newInstance();
        suite.addTest(testCase);
    } catch (Exception e) {
        getSession().logMessage("Unable to load SessionsXMLSchemaWriteTest.  This usually occurs when the tests were compiled " + " on a non-Oracle environment. If you are not running on Oracle, this is not a problem.");
        if (getSession().getPlatform().isOracle()) {
            throw new TestProblemException("Could not load: SessionsXMLSchemaWriteTest", e);
        }
    }
}
Also used : TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException)

Example 39 with TestProblemException

use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.

the class AddDescriptorsMultithreadedTest method createMultithreadedTest.

protected static AddDescriptorsMultithreadedTest createMultithreadedTest(int nAddDescriptorsTests, long timeToSleepBetweenAddingDescriptors, String testName, int nTests, long timeToStopTests) {
    AddDescriptorsMultithreadedTest test = new AddDescriptorsMultithreadedTest();
    Vector tests = new Vector(nAddDescriptorsTests + nTests);
    InterfaceHashtableProject project = new InterfaceHashtableProject();
    for (int i = 0; i < nAddDescriptorsTests; i++) {
        tests.add(new AddDescriptorsTest(i, nAddDescriptorsTests, timeToSleepBetweenAddingDescriptors, project));
    }
    for (int i = 0; i < nTests; i++) {
        if (testName.equals("SequencePreallocationTest")) {
            tests.add(new SequencePreallocationTest(i));
        } else if (testName.equals("InsertTest")) {
            tests.add(new InsertTest(i, nTests));
        } else {
            throw new TestProblemException("Unknown test name: " + testName);
        }
    }
    if (nAddDescriptorsTests == 0 && timeToStopTests > 0) {
        tests.add(new Timer(timeToStopTests));
    }
    test.setTests(tests);
    test.generateTestName();
    return test;
}
Also used : TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) Vector(java.util.Vector) InterfaceHashtableProject(org.eclipse.persistence.testing.models.interfaces.InterfaceHashtableProject)

Example 40 with TestProblemException

use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.

the class GetObjectFromIdentityMapTest method setup.

@Override
public void setup() {
    getSession().getIdentityMapAccessor().initializeIdentityMaps();
    ExpressionBuilder employees = new ExpressionBuilder();
    employee = (Employee) getSession().readObject(Employee.class);
    if (employee == null) {
        throw new TestProblemException("No employees available");
    }
}
Also used : TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Aggregations

TestProblemException (org.eclipse.persistence.testing.framework.TestProblemException)48 TestSetup (junit.extensions.TestSetup)18 TestSuite (junit.framework.TestSuite)18 PersistenceProvider (jakarta.persistence.spi.PersistenceProvider)7 HashMap (java.util.HashMap)7 Map (java.util.Map)7 SQLException (java.sql.SQLException)4 Vector (java.util.Vector)3 NamingException (javax.naming.NamingException)3 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)3 DatabaseAccessor (org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor)3 DatabaseSession (org.eclipse.persistence.sessions.DatabaseSession)3 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)3 TestWarningException (org.eclipse.persistence.testing.framework.TestWarningException)3 RMISecurityManager (java.rmi.RMISecurityManager)2 RemoteException (java.rmi.RemoteException)2 Connection (java.sql.Connection)2 Statement (java.sql.Statement)2 DatabaseException (org.eclipse.persistence.exceptions.DatabaseException)2 Expression (org.eclipse.persistence.expressions.Expression)2