001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.test.rule.callback;
016    
017    import com.liferay.portal.kernel.dao.db.DB;
018    import com.liferay.portal.kernel.dao.db.DBManagerUtil;
019    import com.liferay.portal.kernel.dao.db.DBType;
020    import com.liferay.portal.kernel.dao.jdbc.DataAccess;
021    import com.liferay.portal.kernel.test.rule.callback.BaseTestCallback;
022    
023    import java.sql.Connection;
024    import java.sql.SQLException;
025    import java.sql.Statement;
026    
027    import org.junit.runner.Description;
028    
029    /**
030     * @author Shuyang Zhou
031     */
032    public class SybaseDumpTransactionLogTestCallback
033            extends BaseTestCallback<Void, Void> {
034    
035            public static final SybaseDumpTransactionLogTestCallback INSTANCE =
036                    new SybaseDumpTransactionLogTestCallback();
037    
038            @Override
039            public Void beforeClass(Description description) throws SQLException {
040                    DB db = DBManagerUtil.getDB();
041    
042                    if (db.getDBType() != DBType.SYBASE) {
043                            return null;
044                    }
045    
046                    try (Connection connection = DataAccess.getConnection();
047                                    Statement statement = connection.createStatement()) {
048    
049                            statement.execute(
050                                    "dump transaction " + connection.getCatalog() + " with no_log");
051                    }
052    
053                    return null;
054            }
055    
056            private SybaseDumpTransactionLogTestCallback() {
057            }
058    
059    }