use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class RMIServerManagerController method start.
public static void start(Session session, String nameToBind, String controllerClassName) {
System.out.println("The following environment properties must be set to run this test.");
System.out.println("-Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory -Djava.naming.provider.url=iiop://localhost:900");
System.out.println("The follwing corba naming server must also be started on the computer.");
System.out.println("<java_home>/bin/tnameserv.exe");
RMIServerManagerController manager = null;
Context initialNamingContext = null;
try {
initialNamingContext = new InitialContext();
} catch (NamingException exception) {
System.out.println("Naming Exception " + exception.toString());
}
// Set the security manager
try {
System.setSecurityManager(new RMISecurityManager());
} catch (Exception exception) {
System.out.println("Security violation 1" + exception.toString());
}
// Make sure RMI registry is started.
try {
java.rmi.registry.LocateRegistry.createRegistry(1099);
} catch (Exception exception) {
System.out.println("Security violation 2" + exception.toString());
}
// Create local instance of the factory
try {
manager = new RMIServerManagerController(session, controllerClassName);
} catch (RemoteException exception) {
throw new TestProblemException("Corba not configured correctly, see system.out", exception);
}
// Put the local instance into the Registry
try {
initialNamingContext.unbind(nameToBind);
} catch (Exception exception) {
System.out.println("Security violation " + exception.toString());
}
// Put the local instance into the Registry
try {
initialNamingContext.rebind(nameToBind, manager);
} catch (Exception exception) {
throw new TestProblemException("Corba not configured correctly, see system.out", exception);
}
}
use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class BroadcastSetupHelper method stopCacheSynchronization.
public void stopCacheSynchronization(AbstractSession session) {
try {
sessions.remove(session);
getEventLock().detach(session);
session.setShouldPropagateChanges(false);
session.getCommandManager().shutdown();
session.setCommandManager(null);
if (sessions.size() == 0) {
// destroy the factory
destroyFactory();
}
} catch (Exception ex) {
ex.printStackTrace();
throw new TestProblemException("exception in stopCacheSynchronization ", ex);
}
}
use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class SybaseTransactionIsolationListener method isDatabaseVersionSupported.
// verify that it's version 15 or higher - this doesn't work with version 12.5
public static boolean isDatabaseVersionSupported(ServerSession serverSession) {
DatabaseAccessor accessor = (DatabaseAccessor) serverSession.allocateReadConnection();
int version;
try {
String strVersion = accessor.getConnectionMetaData().getDatabaseProductVersion();
int iStart = strVersion.indexOf("/") + 1;
int iEnd = strVersion.indexOf(".");
String strIntVersion = strVersion.substring(iStart, iEnd);
version = Integer.parseInt(strIntVersion);
} catch (SQLException ex) {
throw new TestProblemException("failed to obtain database version number", ex);
}
return version >= requiredVersion;
}
use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class SybaseTransactionIsolationListener method postAcquireConnection.
@Override
public void postAcquireConnection(SessionEvent event) {
Connection conn = ((DatabaseAccessor) event.getResult()).getConnection();
Statement stmt1 = null;
Statement stmt2 = null;
ResultSet result = null;
Integer isolationLevel;
try {
stmt1 = conn.createStatement();
result = stmt1.executeQuery("select @@isolation");
result.next();
isolationLevel = result.getInt(1);
if (isolationLevel > 0) {
// If conn1 began transaction and updated the row (but hasn't committed the transaction yet),
// then conn2 should be able to read the original (not updated) state of the row.
// Without this conn2 reading the row hangs on Sybase.
stmt2 = conn.createStatement();
stmt2.execute("set transaction isolation level 0");
stmt2.close();
connections.put(conn, isolationLevel);
}
} catch (SQLException sqlException) {
throw new TestProblemException("postAcquireConnection failed. ", sqlException);
} finally {
if (result != null) {
try {
result.close();
} catch (SQLException ex) {
// Ignore
}
}
if (stmt1 != null) {
try {
stmt1.close();
} catch (SQLException ex) {
// Ignore
}
}
if (stmt2 != null) {
try {
stmt2.close();
} catch (SQLException ex) {
// Ignore
}
}
}
}
use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class SybaseTransactionIsolationListener method preReleaseConnection.
@Override
public void preReleaseConnection(SessionEvent event) {
Connection conn = ((DatabaseAccessor) event.getResult()).getConnection();
Statement stmt = null;
try {
Integer isolationLevel = connections.remove(conn);
if (isolationLevel != null) {
// reset the original transaction isolation.
stmt = conn.createStatement();
stmt.execute("set transaction isolation level " + isolationLevel);
stmt.close();
}
} catch (SQLException sqlException) {
throw new TestProblemException("preReleaseConnection failed. ", sqlException);
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException ex) {
// Ignore
}
}
}
}
Aggregations