Search in sources :

Example 1 with DefaultSessionLog

use of org.eclipse.persistence.logging.DefaultSessionLog in project eclipselink by eclipse-ee4j.

the class FailoverBase method prepare.

@Before
public void prepare() {
    DatabaseLogin login = new DatabaseLogin();
    login.useDirectDriverConnect();
    login.setDriverClass(EmulatedDriver.class);
    login.setConnectionString("jdbc:emulateddriver");
    login.getPlatform().setPingSQL("SELECT 1");
    Project p = new Project(login);
    ClassDescriptor cd = Address.descriptor();
    p.addDescriptor(cd);
    session = createSession(p);
    SessionLog log = new DefaultSessionLog(new OutputStreamWriter(System.out));
    int logLevel = AbstractSessionLog.translateStringToLoggingLevel(System.getProperty(PersistenceUnitProperties.LOGGING_LEVEL, "INFO"));
    session.setSessionLog(log);
    session.setLogLevel(logLevel);
    session.login();
    // this will actually store the results on the driver for subsequent connections.
    EmulatedConnection con = (EmulatedConnection) ((DatabaseSessionImpl) session).getAccessor().getConnection();
    Vector<DatabaseField> pingFields = new Vector<DatabaseField>() {

        {
            add(new DatabaseField("1"));
        }
    };
    con.putRows("SELECT 1", new Vector() {

        {
            add(new ArrayRecord(pingFields, pingFields.toArray(new DatabaseField[0]), new Object[] { "1" }));
        }
    });
    con.putRows(Address.getSQL(), Address.getData(cd));
}
Also used : ClassDescriptor(org.eclipse.persistence.descriptors.ClassDescriptor) EmulatedConnection(org.eclipse.persistence.testing.tests.junit.failover.emulateddriver.EmulatedConnection) ArrayRecord(org.eclipse.persistence.internal.sessions.ArrayRecord) DatabaseLogin(org.eclipse.persistence.sessions.DatabaseLogin) Project(org.eclipse.persistence.sessions.Project) AbstractSessionLog(org.eclipse.persistence.logging.AbstractSessionLog) DefaultSessionLog(org.eclipse.persistence.logging.DefaultSessionLog) SessionLog(org.eclipse.persistence.logging.SessionLog) DatabaseSessionImpl(org.eclipse.persistence.internal.sessions.DatabaseSessionImpl) DatabaseField(org.eclipse.persistence.internal.helper.DatabaseField) DefaultSessionLog(org.eclipse.persistence.logging.DefaultSessionLog) OutputStreamWriter(java.io.OutputStreamWriter) Vector(java.util.Vector) Before(org.junit.Before)

Example 2 with DefaultSessionLog

use of org.eclipse.persistence.logging.DefaultSessionLog in project eclipselink by eclipse-ee4j.

the class SessionsFactory method buildDefaultSessionLogConfig.

/**
 * INTERNAL:
 * Wrapped by the getSessionLog() call, therefore, config can't be null at
 * this point.
 */
protected SessionLog buildDefaultSessionLogConfig(DefaultSessionLogConfig defaultSessionLogConfig) {
    DefaultSessionLog defaultSessionLog = new DefaultSessionLog();
    // Log level - XML Schema default is info
    defaultSessionLog.setLevel(m_logLevels.get(defaultSessionLogConfig.getLogLevel()));
    // Filename - setWriter will handle nulls
    defaultSessionLog.setWriter(defaultSessionLogConfig.getFilename());
    // Process the common elements from LogConfig
    processLogConfig(defaultSessionLogConfig, defaultSessionLog);
    return defaultSessionLog;
}
Also used : DefaultSessionLog(org.eclipse.persistence.logging.DefaultSessionLog)

Example 3 with DefaultSessionLog

use of org.eclipse.persistence.logging.DefaultSessionLog in project eclipselink by eclipse-ee4j.

the class MessageLoggingEfficiencyTest method setup.

@Override
public void setup() {
    caughtException = null;
    oldLog = getSession().getSessionLog();
    DefaultSessionLog newLog = new DefaultSessionLog();
    newLog.setLevel(SessionLog.FINE);
    getSession().setSessionLog(newLog);
}
Also used : DefaultSessionLog(org.eclipse.persistence.logging.DefaultSessionLog)

Example 4 with DefaultSessionLog

use of org.eclipse.persistence.logging.DefaultSessionLog in project eclipselink by eclipse-ee4j.

the class FieldedMessageLoggingTest method setup.

@Override
public void setup() {
    caughtException = null;
    oldLog = getSession().getSessionLog();
    DefaultSessionLog newLog = new DefaultSessionLog();
    newLog.setLevel(SessionLog.FINE);
    getSession().setSessionLog(newLog);
}
Also used : DefaultSessionLog(org.eclipse.persistence.logging.DefaultSessionLog)

Example 5 with DefaultSessionLog

use of org.eclipse.persistence.logging.DefaultSessionLog in project eclipselink by eclipse-ee4j.

the class FieldedMessageLoggingTraceLocalizationTest method setup.

@Override
public void setup() {
    caughtException = null;
    oldLog = getSession().getSessionLog();
    DefaultSessionLog newLog = new DefaultSessionLog();
    newLog.setLevel(SessionLog.FINE);
    getSession().setSessionLog(newLog);
}
Also used : DefaultSessionLog(org.eclipse.persistence.logging.DefaultSessionLog)

Aggregations

DefaultSessionLog (org.eclipse.persistence.logging.DefaultSessionLog)6 AbstractSessionLog (org.eclipse.persistence.logging.AbstractSessionLog)2 SessionLog (org.eclipse.persistence.logging.SessionLog)2 OutputStreamWriter (java.io.OutputStreamWriter)1 StringWriter (java.io.StringWriter)1 Vector (java.util.Vector)1 PortableRemoteObject (javax.rmi.PortableRemoteObject)1 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)1 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)1 AbstractSession (org.eclipse.persistence.internal.sessions.AbstractSession)1 ArrayRecord (org.eclipse.persistence.internal.sessions.ArrayRecord)1 DatabaseSessionImpl (org.eclipse.persistence.internal.sessions.DatabaseSessionImpl)1 DatabaseLogin (org.eclipse.persistence.sessions.DatabaseLogin)1 Project (org.eclipse.persistence.sessions.Project)1 EmulatedConnection (org.eclipse.persistence.testing.tests.junit.failover.emulateddriver.EmulatedConnection)1 Before (org.junit.Before)1