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.DBFactoryUtil;
019    import com.liferay.portal.kernel.dao.jdbc.DataAccess;
020    import com.liferay.portal.kernel.test.rule.callback.BaseTestCallback;
021    
022    import java.sql.Connection;
023    import java.sql.SQLException;
024    import java.sql.Statement;
025    
026    import org.junit.runner.Description;
027    
028    /**
029     * @author Shuyang Zhou
030     */
031    public class SybaseDumpTransactionLogTestCallback
032            extends BaseTestCallback<Void, Void> {
033    
034            public static final SybaseDumpTransactionLogTestCallback INSTANCE =
035                    new SybaseDumpTransactionLogTestCallback();
036    
037            @Override
038            public Void beforeClass(Description description) throws SQLException {
039                    DB db = DBFactoryUtil.getDB();
040    
041                    String type = db.getType();
042    
043                    if (!type.equals(DB.TYPE_SYBASE)) {
044                            return null;
045                    }
046    
047                    try (Connection connection = DataAccess.getConnection();
048                            Statement statement = connection.createStatement()) {
049    
050                            statement.execute(
051                                    "dump transaction " + connection.getCatalog() + " with no_log");
052                    }
053    
054                    return null;
055            }
056    
057            private SybaseDumpTransactionLogTestCallback() {
058            }
059    
060    }