import org.slf4j.LoggerFactory;
import org.sonar.api.BatchComponent;
import org.sonar.api.ServerComponent;
-import org.sonar.api.config.Settings;
import org.sonar.api.database.model.MeasureMapper;
import org.sonar.api.database.model.MeasureModel;
import org.sonar.core.component.ComponentDto;
public class MyBatis implements BatchComponent, ServerComponent {
private final Database database;
- private final Settings settings;
private final Logback logback;
private SqlSessionFactory sessionFactory;
- public MyBatis(Database database, Settings settings, Logback logback) {
+ public MyBatis(Database database, Logback logback) {
this.database = database;
- this.settings = settings;
this.logback = logback;
}
if ("prepareStatement".equals(method.getName())) {
PreparedStatement statement = (PreparedStatement) result;
String sql = (String) args[0];
- return Proxy.newProxyInstance(ProfilingConnectionHandler.class.getClassLoader(), new Class[] { PreparedStatement.class }, new ProfilingPreparedStatementHandler(statement, sql));
+ return Proxy.newProxyInstance(ProfilingConnectionHandler.class.getClassLoader(), new Class[] { PreparedStatement.class },
+ new ProfilingPreparedStatementHandler(statement, sql));
} else if ("createStatement".equals(method.getName())) {
Statement statement = (Statement) result;
- return Proxy.newProxyInstance(ProfilingConnectionHandler.class.getClassLoader(), new Class[] { Statement.class }, new ProfilingStatementHandler(statement));
+ return Proxy.newProxyInstance(ProfilingConnectionHandler.class.getClassLoader(), new Class[] { Statement.class },
+ new ProfilingStatementHandler(statement));
} else {
return result;
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.core.persistence.profiling;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
import org.dbunit.IDatabaseTester;
import org.dbunit.database.DatabaseConfig;
import org.dbunit.database.IDatabaseConnection;
-import org.dbunit.dataset.CompositeDataSet;
-import org.dbunit.dataset.DataSetException;
-import org.dbunit.dataset.IDataSet;
-import org.dbunit.dataset.ITable;
-import org.dbunit.dataset.ReplacementDataSet;
+import org.dbunit.dataset.*;
import org.dbunit.dataset.filter.DefaultColumnFilter;
import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.dbunit.ext.mssql.InsertIdentityOperation;
databaseCommands = DatabaseCommands.forDialect(database.getDialect());
databaseTester = new DataSourceDatabaseTester(database.getDataSource());
- myBatis = new MyBatis(database, settings, new Logback());
+ myBatis = new MyBatis(database, new Logback());
myBatis.start();
}
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.sonar.api.config.Settings;
import org.sonar.core.config.Logback;
import org.sonar.core.rule.RuleMapper;
@Test
public void shouldConfigureMyBatis() {
- MyBatis myBatis = new MyBatis(database, new Settings(), logback);
+ MyBatis myBatis = new MyBatis(database, logback);
myBatis.start();
Configuration conf = myBatis.getSessionFactory().getConfiguration();
@Test
public void shouldOpenBatchSession() {
- MyBatis myBatis = new MyBatis(database, new Settings(), logback);
+ MyBatis myBatis = new MyBatis(database, logback);
myBatis.start();
SqlSession session = myBatis.openBatchSession();
commands = DatabaseCommands.forDialect(db.getDialect());
tester = new DataSourceDatabaseTester(db.getDataSource());
- myBatis = new MyBatis(db, settings, new Logback());
+ myBatis = new MyBatis(db, new Logback());
myBatis.start();
}
commands.truncateDatabase(db.getDataSource());